Skip to content

Commit

Permalink
fixup! src: fix error handling for CryptoJob::ToResult
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Jan 26, 2021
1 parent 537d31d commit 49a1a79
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,26 +1289,28 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// This test creates EC key pairs on curves without associated OIDs.
// Specifying a key encoding should not crash.

const hasCurve = (c) => getCurves().includes(c);
const curvesWithoutOid = ['Oakley-EC2N-3', 'Oakley-EC2N-4'].filter(hasCurve);
if (process.versions.openssl >= '1.1.1i') {
const hasCurve = (c) => getCurves().includes(c);
const curvesWithoutOid = ['Oakley-EC2N-3', 'Oakley-EC2N-4'].filter(hasCurve);

for (const namedCurve of curvesWithoutOid) {
const params = {
namedCurve,
publicKeyEncoding: {
format: 'der',
type: 'spki'
}
};
for (const namedCurve of curvesWithoutOid) {
const params = {
namedCurve,
publicKeyEncoding: {
format: 'der',
type: 'spki'
}
};

assert.throws(() => {
generateKeyPairSync('ec', params);
}, {
code: 'ERR_OSSL_EC_MISSING_OID'
});
assert.throws(() => {
generateKeyPairSync('ec', params);
}, {
code: 'ERR_OSSL_EC_MISSING_OID'
});

generateKeyPair('ec', params, common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_OSSL_EC_MISSING_OID');
}));
generateKeyPair('ec', params, common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_OSSL_EC_MISSING_OID');
}));
}
}
}

0 comments on commit 49a1a79

Please sign in to comment.