mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64960 Fixes: https://github.com/nodejs/node/issues/48379 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
38 lines
974 B
JavaScript
38 lines
974 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
generateKeyPair,
|
|
} = require('crypto');
|
|
const { hasFIPS } = require('../common/crypto');
|
|
|
|
const fips4 = hasFIPS(4);
|
|
|
|
// Passing an empty passphrase string should not throw ERR_OSSL_CRYPTO_MALLOC_FAILURE even on OpenSSL 3.
|
|
// Regression test for https://github.com/nodejs/node/issues/41428.
|
|
generateKeyPair('rsa', {
|
|
modulusLength: hasFIPS(3) ? 2048 : 1024,
|
|
publicKeyEncoding: {
|
|
type: 'spki',
|
|
format: 'pem'
|
|
},
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'pem',
|
|
cipher: 'aes-256-cbc',
|
|
passphrase: ''
|
|
}
|
|
}, common.mustCall((err, publicKey, privateKey) => {
|
|
if (fips4) {
|
|
assert.strictEqual(err?.code, 'ERR_OSSL_PASSWORD_STRENGTH_TOO_WEAK');
|
|
return;
|
|
}
|
|
assert.ifError(err);
|
|
assert.strictEqual(typeof publicKey, 'string');
|
|
assert.strictEqual(typeof privateKey, 'string');
|
|
}));
|