11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst { 91cb0ef41Sopenharmony_ci generateKeyPair, 101cb0ef41Sopenharmony_ci} = require('crypto'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci// Passing an empty passphrase string should not throw ERR_OSSL_CRYPTO_MALLOC_FAILURE even on OpenSSL 3. 131cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/41428. 141cb0ef41Sopenharmony_cigenerateKeyPair('rsa', { 151cb0ef41Sopenharmony_ci modulusLength: 1024, 161cb0ef41Sopenharmony_ci publicKeyEncoding: { 171cb0ef41Sopenharmony_ci type: 'spki', 181cb0ef41Sopenharmony_ci format: 'pem' 191cb0ef41Sopenharmony_ci }, 201cb0ef41Sopenharmony_ci privateKeyEncoding: { 211cb0ef41Sopenharmony_ci type: 'pkcs8', 221cb0ef41Sopenharmony_ci format: 'pem', 231cb0ef41Sopenharmony_ci cipher: 'aes-256-cbc', 241cb0ef41Sopenharmony_ci passphrase: '' 251cb0ef41Sopenharmony_ci } 261cb0ef41Sopenharmony_ci}, common.mustSucceed((publicKey, privateKey) => { 271cb0ef41Sopenharmony_ci assert.strictEqual(typeof publicKey, 'string'); 281cb0ef41Sopenharmony_ci assert.strictEqual(typeof privateKey, 'string'); 291cb0ef41Sopenharmony_ci})); 30