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// This test makes sure deprecated and new options may be used
13// simultaneously so long as they're identical values.
14{
15  generateKeyPair('rsa-pss', {
16    modulusLength: 512,
17    saltLength: 16,
18    hash: 'sha256',
19    hashAlgorithm: 'sha256',
20    mgf1Hash: 'sha256',
21    mgf1HashAlgorithm: 'sha256'
22  }, common.mustSucceed((publicKey, privateKey) => {
23    assert.strictEqual(publicKey.type, 'public');
24    assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
25    assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
26      modulusLength: 512,
27      publicExponent: 65537n,
28      hashAlgorithm: 'sha256',
29      mgf1HashAlgorithm: 'sha256',
30      saltLength: 16
31    });
32
33    assert.strictEqual(privateKey.type, 'private');
34    assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
35    assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
36      modulusLength: 512,
37      publicExponent: 65537n,
38      hashAlgorithm: 'sha256',
39      mgf1HashAlgorithm: 'sha256',
40      saltLength: 16
41    });
42  }));
43}
44