1// Flags: --pending-deprecation 2 3'use strict'; 4 5const common = require('../common'); 6if (!common.hasCrypto) 7 common.skip('missing crypto'); 8 9const DeprecationWarning = []; 10DeprecationWarning.push([ 11 '"options.hash" is deprecated, use "options.hashAlgorithm" instead.', 12 'DEP0154']); 13DeprecationWarning.push([ 14 '"options.mgf1Hash" is deprecated, use "options.mgf1HashAlgorithm" instead.', 15 'DEP0154']); 16 17common.expectWarning({ DeprecationWarning }); 18 19const assert = require('assert'); 20const { generateKeyPair } = require('crypto'); 21 22{ 23 // This test makes sure deprecated options still work as intended 24 25 generateKeyPair('rsa-pss', { 26 modulusLength: 512, 27 saltLength: 16, 28 hash: 'sha256', 29 mgf1Hash: 'sha256' 30 }, common.mustSucceed((publicKey, privateKey) => { 31 assert.strictEqual(publicKey.type, 'public'); 32 assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss'); 33 assert.deepStrictEqual(publicKey.asymmetricKeyDetails, { 34 modulusLength: 512, 35 publicExponent: 65537n, 36 hashAlgorithm: 'sha256', 37 mgf1HashAlgorithm: 'sha256', 38 saltLength: 16 39 }); 40 41 assert.strictEqual(privateKey.type, 'private'); 42 assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss'); 43 assert.deepStrictEqual(privateKey.asymmetricKeyDetails, { 44 modulusLength: 512, 45 publicExponent: 65537n, 46 hashAlgorithm: 'sha256', 47 mgf1HashAlgorithm: 'sha256', 48 saltLength: 16 49 }); 50 })); 51} 52