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// 'rsa-pss' should not add a RSASSA-PSS-params sequence by default. 13// Regression test for: https://github.com/nodejs/node/issues/39936 14{ 15 generateKeyPair('rsa-pss', { 16 modulusLength: 512 17 }, common.mustSucceed((publicKey, privateKey) => { 18 const expectedKeyDetails = { 19 modulusLength: 512, 20 publicExponent: 65537n 21 }; 22 assert.deepStrictEqual(publicKey.asymmetricKeyDetails, expectedKeyDetails); 23 assert.deepStrictEqual(privateKey.asymmetricKeyDetails, expectedKeyDetails); 24 25 // To allow backporting the fix to versions that do not support 26 // asymmetricKeyDetails for RSA-PSS params, also verify that the exported 27 // AlgorithmIdentifier member of the SubjectPublicKeyInfo has the expected 28 // length of 11 bytes (as opposed to > 11 bytes if node added params). 29 const spki = publicKey.export({ format: 'der', type: 'spki' }); 30 assert.strictEqual(spki[3], 11, spki.toString('hex')); 31 })); 32} 33