Skip to content

Commit c4ca98e

Browse files
tniessenMylesBorins
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 <panva.ip@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent f390841 commit c4ca98e

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)