diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 9d08e2d9fab3dd..1a77266b057041 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -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.