1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const {
9  generateKeyPair,
10} = require('crypto');
11
12// Passing an empty passphrase string should not throw ERR_OSSL_CRYPTO_MALLOC_FAILURE even on OpenSSL 3.
13// Regression test for https://github.com/nodejs/node/issues/41428.
14generateKeyPair('rsa', {
15  modulusLength: 1024,
16  publicKeyEncoding: {
17    type: 'spki',
18    format: 'pem'
19  },
20  privateKeyEncoding: {
21    type: 'pkcs8',
22    format: 'pem',
23    cipher: 'aes-256-cbc',
24    passphrase: ''
25  }
26}, common.mustSucceed((publicKey, privateKey) => {
27  assert.strictEqual(typeof publicKey, 'string');
28  assert.strictEqual(typeof privateKey, 'string');
29}));
30