11cb0ef41Sopenharmony_ci// Flags: --pending-deprecation
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciif (!common.hasCrypto)
71cb0ef41Sopenharmony_ci  common.skip('missing crypto');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst DeprecationWarning = [];
101cb0ef41Sopenharmony_ciDeprecationWarning.push([
111cb0ef41Sopenharmony_ci  '"options.hash" is deprecated, use "options.hashAlgorithm" instead.',
121cb0ef41Sopenharmony_ci  'DEP0154']);
131cb0ef41Sopenharmony_ciDeprecationWarning.push([
141cb0ef41Sopenharmony_ci  '"options.mgf1Hash" is deprecated, use "options.mgf1HashAlgorithm" instead.',
151cb0ef41Sopenharmony_ci  'DEP0154']);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cicommon.expectWarning({ DeprecationWarning });
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconst assert = require('assert');
201cb0ef41Sopenharmony_ciconst { generateKeyPair } = require('crypto');
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci{
231cb0ef41Sopenharmony_ci  // This test makes sure deprecated options still work as intended
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  generateKeyPair('rsa-pss', {
261cb0ef41Sopenharmony_ci    modulusLength: 512,
271cb0ef41Sopenharmony_ci    saltLength: 16,
281cb0ef41Sopenharmony_ci    hash: 'sha256',
291cb0ef41Sopenharmony_ci    mgf1Hash: 'sha256'
301cb0ef41Sopenharmony_ci  }, common.mustSucceed((publicKey, privateKey) => {
311cb0ef41Sopenharmony_ci    assert.strictEqual(publicKey.type, 'public');
321cb0ef41Sopenharmony_ci    assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
331cb0ef41Sopenharmony_ci    assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
341cb0ef41Sopenharmony_ci      modulusLength: 512,
351cb0ef41Sopenharmony_ci      publicExponent: 65537n,
361cb0ef41Sopenharmony_ci      hashAlgorithm: 'sha256',
371cb0ef41Sopenharmony_ci      mgf1HashAlgorithm: 'sha256',
381cb0ef41Sopenharmony_ci      saltLength: 16
391cb0ef41Sopenharmony_ci    });
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci    assert.strictEqual(privateKey.type, 'private');
421cb0ef41Sopenharmony_ci    assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
431cb0ef41Sopenharmony_ci    assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
441cb0ef41Sopenharmony_ci      modulusLength: 512,
451cb0ef41Sopenharmony_ci      publicExponent: 65537n,
461cb0ef41Sopenharmony_ci      hashAlgorithm: 'sha256',
471cb0ef41Sopenharmony_ci      mgf1HashAlgorithm: 'sha256',
481cb0ef41Sopenharmony_ci      saltLength: 16
491cb0ef41Sopenharmony_ci    });
501cb0ef41Sopenharmony_ci  }));
511cb0ef41Sopenharmony_ci}
52