Merge pull request #680 from twiss/native-brainpool-node

Add native Brainpool support on Node.js
This commit is contained in:
Bart Butler 2018-03-26 12:36:53 -07:00 committed by GitHub
commit c13960a9aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -98,32 +98,32 @@ const curves = {
node: false // nodeCurves.ed25519 TODO node: false // nodeCurves.ed25519 TODO
}, },
curve25519: { curve25519: {
oid: [0x06, 0x08, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x97, 0x55, 0x01, 0x05, 0x01], oid: [0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x97, 0x55, 0x01, 0x05, 0x01],
keyType: enums.publicKey.ecdsa, keyType: enums.publicKey.ecdsa,
hash: enums.hash.sha256, hash: enums.hash.sha256,
cipher: enums.symmetric.aes128, cipher: enums.symmetric.aes128,
node: false // nodeCurves.curve25519 TODO node: false // nodeCurves.curve25519 TODO
}, },
brainpoolP256r1: { brainpoolP256r1: {
oid: [0x06, 0x07, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07], oid: [0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07],
keyType: enums.publicKey.ecdsa, keyType: enums.publicKey.ecdsa,
hash: enums.hash.sha256, hash: enums.hash.sha256,
cipher: enums.symmetric.aes128, cipher: enums.symmetric.aes128,
node: false // nodeCurves.brainpoolP256r1 TODO node: nodeCurves.brainpoolP256r1
}, },
brainpoolP384r1: { brainpoolP384r1: {
oid: [0x06, 0x07, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B], oid: [0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B],
keyType: enums.publicKey.ecdsa, keyType: enums.publicKey.ecdsa,
hash: enums.hash.sha384, hash: enums.hash.sha384,
cipher: enums.symmetric.aes192, cipher: enums.symmetric.aes192,
node: false // nodeCurves.brainpoolP384r1 TODO node: nodeCurves.brainpoolP384r1
}, },
brainpoolP512r1: { brainpoolP512r1: {
oid: [0x06, 0x07, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0D], oid: [0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0D],
keyType: enums.publicKey.ecdsa, keyType: enums.publicKey.ecdsa,
hash: enums.hash.sha512, hash: enums.hash.sha512,
cipher: enums.symmetric.aes256, cipher: enums.symmetric.aes256,
node: false // nodeCurves.brainpoolP512r1 TODO node: nodeCurves.brainpoolP512r1
} }
}; };

View File

@ -47,6 +47,9 @@ function OID(oid) {
util.isUint8Array(oid)) { util.isUint8Array(oid)) {
oid = new Uint8Array(oid); oid = new Uint8Array(oid);
if (oid[0] === 0x06) { // DER encoded oid byte array if (oid[0] === 0x06) { // DER encoded oid byte array
if (oid[1] !== oid.length - 2) {
throw new Error('Length mismatch in DER encoded oid');
}
oid = oid.subarray(2); oid = oid.subarray(2);
} }
this.oid = oid; this.oid = oid;