Skip to content

Commit d7b995c

Browse files
tniessendanielleadams
authored andcommitted
test: cover publicExponent validation in OpenSSL
Add a test case for public exponents that are invalid according to some internal OpenSSL validation logic, but which are accepted by node's own validation logic. PR-URL: #46632 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
1 parent ea411d6 commit d7b995c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/parallel/test-crypto-keygen.js

+11
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,17 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
12001200
code: 'ERR_OUT_OF_RANGE',
12011201
});
12021202
}
1203+
1204+
// Test invalid exponents. (caught by OpenSSL)
1205+
for (const publicExponent of [1, 1 + 0x10001]) {
1206+
generateKeyPair('rsa', {
1207+
modulusLength: 4096,
1208+
publicExponent
1209+
}, common.mustCall((err) => {
1210+
assert.strictEqual(err.name, 'Error');
1211+
assert.match(err.message, common.hasOpenSSL3 ? /exponent/ : /bad e value/);
1212+
}));
1213+
}
12031214
}
12041215

12051216
// Test DSA parameters.

0 commit comments

Comments
 (0)