Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! crypto: add API to retrieve key type OID
  • Loading branch information
tniessen committed Mar 17, 2019
commit a030a5d6603a99bc1eaead3293caa04e6c859364
16 changes: 16 additions & 0 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if (!common.hasCrypto)

const assert = require('assert');
const {
createPrivateKey,
createPublicKey,
createSign,
createVerify,
generateKeyPair,
Expand Down Expand Up @@ -275,6 +277,15 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
assertApproximateSize(publicKey, 440);
assertApproximateSize(privateKeyDER, 336);

assert.strictEqual(createPublicKey(publicKey).asymmetricKeyTypeOid,
'1.2.840.10040.4.1');
assert.strictEqual(createPrivateKey({
key: privateKeyDER,
...privateKeyEncoding,
passphrase: 'secret'
}).asymmetricKeyTypeOid,
'1.2.840.10040.4.1');

// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => {
testSignVerify(publicKey, {
Expand Down Expand Up @@ -314,6 +325,11 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
assert.strictEqual(typeof privateKey, 'string');
assert(sec1Exp.test(privateKey));

assert.strictEqual(createPublicKey(publicKey).asymmetricKeyTypeOid,
'1.2.840.10045.2.1');
assert.strictEqual(createPrivateKey(privateKey).asymmetricKeyTypeOid,
'1.2.840.10045.2.1');

testSignVerify(publicKey, privateKey);
}));

Expand Down