summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-keygen.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-crypto-keygen.js')
-rw-r--r--test/parallel/test-crypto-keygen.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js
index e5c8a107ba..8f37277713 100644
--- a/test/parallel/test-crypto-keygen.js
+++ b/test/parallel/test-crypto-keygen.js
@@ -12,6 +12,7 @@ const {
createVerify,
generateKeyPair,
generateKeyPairSync,
+ getCurves,
publicEncrypt,
privateDecrypt,
sign,
@@ -1314,3 +1315,33 @@ if (!common.hasOpenSSL3) {
);
}
}
+
+{
+ // This test creates EC key pairs on curves without associated OIDs.
+ // Specifying a key encoding should not crash.
+
+ if (process.versions.openssl >= '1.1.1i') {
+ for (const namedCurve of ['Oakley-EC2N-3', 'Oakley-EC2N-4']) {
+ if (!getCurves().includes(namedCurve))
+ continue;
+
+ const params = {
+ namedCurve,
+ publicKeyEncoding: {
+ format: 'der',
+ type: 'spki'
+ }
+ };
+
+ 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');
+ }));
+ }
+ }
+}