diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 3ddda9a77449db..5f135c2e0ab39c 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4864,8 +4864,10 @@ class RSAKeyPairGenerationConfig : public KeyPairGenerationConfig { BignumPointer bn(BN_new()); CHECK_NOT_NULL(bn.get()); CHECK(BN_set_word(bn.get(), exponent_)); + // EVP_CTX acceps ownership of bn on success. if (EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx.get(), bn.get()) <= 0) return false; + bn.release(); } return true; diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 0ffaa1c7255004..f164938d975b80 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -86,7 +86,7 @@ function convertDERToPEM(label, der) { // To make the test faster, we will only test sync key generation once and // with a relatively small key. const ret = generateKeyPairSync('rsa', { - publicExponent: 0x10001, + publicExponent: 3, modulusLength: 512, publicKeyEncoding: { type: 'pkcs1', @@ -144,7 +144,7 @@ function convertDERToPEM(label, der) { // Now do the same with an encrypted private key. generateKeyPair('rsa', { - publicExponent: 0x10001, + publicExponent: 0x1001, modulusLength: 512, publicKeyEncoding: { type: 'pkcs1',