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// RFC 8017, 9.1.: "Assuming that the mask generation function is based on a
13// hash function, it is RECOMMENDED that the hash function be the same as the
14// one that is applied to the message."
15{
16
17  generateKeyPair('rsa-pss', {
18    modulusLength: 512,
19    hashAlgorithm: 'sha256',
20    saltLength: 16
21  }, common.mustSucceed((publicKey, privateKey) => {
22    const expectedKeyDetails = {
23      modulusLength: 512,
24      publicExponent: 65537n,
25      hashAlgorithm: 'sha256',
26      mgf1HashAlgorithm: 'sha256',
27      saltLength: 16
28    };
29    assert.deepStrictEqual(publicKey.asymmetricKeyDetails, expectedKeyDetails);
30    assert.deepStrictEqual(privateKey.asymmetricKeyDetails, expectedKeyDetails);
31  }));
32}
33