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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Tobias Nießen authored and GitHub committed 2023-02-18 00:27:24 +00:00
1 parent c566a04c86
commit f1a30b9bd4
1 file changed
+11
+11
View File
@@ -1200,6 +1200,17 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
code: 'ERR_OUT_OF_RANGE',
});
}
// Test invalid exponents. (caught by OpenSSL)
for (const publicExponent of [1, 1 + 0x10001]) {
generateKeyPair('rsa', {
modulusLength: 4096,
publicExponent
}, common.mustCall((err) => {
assert.strictEqual(err.name, 'Error');
assert.match(err.message, common.hasOpenSSL3 ? /exponent/ : /bad e value/);
}));
}
}
// Test DSA parameters.