@@ -302,8 +302,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
302302 generateKeyPair ( 'rsa-pss' , {
303303 modulusLength : 512 ,
304304 saltLength : 16 ,
305- hash : 'sha256' ,
306- mgf1Hash : 'sha256'
305+ hashAlgorithm : 'sha256' ,
306+ mgf1HashAlgorithm : 'sha256'
307307 } , common . mustSucceed ( ( publicKey , privateKey ) => {
308308 assert . strictEqual ( publicKey . type , 'public' ) ;
309309 assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
@@ -1324,12 +1324,12 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
13241324 assert . throws ( ( ) => {
13251325 generateKeyPairSync ( 'rsa-pss' , {
13261326 modulusLength : 4096 ,
1327- hash : hashValue
1327+ hashAlgorithm : hashValue
13281328 } ) ;
13291329 } , {
13301330 name : 'TypeError' ,
13311331 code : 'ERR_INVALID_ARG_VALUE' ,
1332- message : "The property 'options.hash ' is invalid. " +
1332+ message : "The property 'options.hashAlgorithm ' is invalid. " +
13331333 `Received ${ inspect ( hashValue ) } `
13341334 } ) ;
13351335 }
@@ -1339,8 +1339,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
13391339 generateKeyPair ( 'rsa-pss' , {
13401340 modulusLength : 512 ,
13411341 saltLength : 2147483648 ,
1342- hash : 'sha256' ,
1343- mgf1Hash : 'sha256'
1342+ hashAlgorithm : 'sha256' ,
1343+ mgf1HashAlgorithm : 'sha256'
13441344 } , common . mustNotCall ( ) ) ;
13451345 } , {
13461346 name : 'TypeError' ,
@@ -1353,8 +1353,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
13531353 generateKeyPair ( 'rsa-pss' , {
13541354 modulusLength : 512 ,
13551355 saltLength : - 1 ,
1356- hash : 'sha256' ,
1357- mgf1Hash : 'sha256'
1356+ hashAlgorithm : 'sha256' ,
1357+ mgf1HashAlgorithm : 'sha256'
13581358 } , common . mustNotCall ( ) ) ;
13591359 } , {
13601360 name : 'TypeError' ,
@@ -1451,8 +1451,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
14511451 generateKeyPair ( 'rsa-pss' , {
14521452 modulusLength : 512 ,
14531453 saltLength : 16 ,
1454- hash : 'sha256' ,
1455- mgf1Hash : undefined
1454+ hashAlgorithm : 'sha256' ,
1455+ mgf1HashAlgorithm : undefined
14561456 } ) ;
14571457 } ,
14581458 {
@@ -1462,21 +1462,21 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
14621462 }
14631463 ) ;
14641464
1465- for ( const mgf1Hash of [ null , 0 , false , { } , [ ] ] ) {
1465+ for ( const mgf1HashAlgorithm of [ null , 0 , false , { } , [ ] ] ) {
14661466 assert . throws (
14671467 ( ) => {
14681468 generateKeyPair ( 'rsa-pss' , {
14691469 modulusLength : 512 ,
14701470 saltLength : 16 ,
1471- hash : 'sha256' ,
1472- mgf1Hash
1471+ hashAlgorithm : 'sha256' ,
1472+ mgf1HashAlgorithm
14731473 } , common . mustNotCall ( ) ) ;
14741474 } ,
14751475 {
14761476 name : 'TypeError' ,
14771477 code : 'ERR_INVALID_ARG_VALUE' ,
1478- message : "The property 'options.mgf1Hash ' is invalid. " +
1479- `Received ${ inspect ( mgf1Hash ) } `
1478+ message : "The property 'options.mgf1HashAlgorithm ' is invalid. " +
1479+ `Received ${ inspect ( mgf1HashAlgorithm ) } `
14801480
14811481 }
14821482 ) ;
@@ -1568,3 +1568,56 @@ if (!common.hasOpenSSL3) {
15681568 }
15691569 }
15701570}
1571+
1572+ {
1573+ // This test makes sure deprecated and new options may be used
1574+ // simultaneously so long as they're identical values.
1575+
1576+ generateKeyPair ( 'rsa-pss' , {
1577+ modulusLength : 512 ,
1578+ saltLength : 16 ,
1579+ hash : 'sha256' ,
1580+ hashAlgorithm : 'sha256' ,
1581+ mgf1Hash : 'sha256' ,
1582+ mgf1HashAlgorithm : 'sha256'
1583+ } , common . mustSucceed ( ( publicKey , privateKey ) => {
1584+ assert . strictEqual ( publicKey . type , 'public' ) ;
1585+ assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
1586+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , {
1587+ modulusLength : 512 ,
1588+ publicExponent : 65537n ,
1589+ hashAlgorithm : 'sha256' ,
1590+ mgf1HashAlgorithm : 'sha256' ,
1591+ saltLength : 16
1592+ } ) ;
1593+
1594+ assert . strictEqual ( privateKey . type , 'private' ) ;
1595+ assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
1596+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , {
1597+ modulusLength : 512 ,
1598+ publicExponent : 65537n ,
1599+ hashAlgorithm : 'sha256' ,
1600+ mgf1HashAlgorithm : 'sha256' ,
1601+ saltLength : 16
1602+ } ) ;
1603+ } ) ) ;
1604+ }
1605+
1606+ {
1607+ // This test makes sure deprecated and new options must
1608+ // be the same value.
1609+
1610+ assert . throws ( ( ) => generateKeyPair ( 'rsa-pss' , {
1611+ modulusLength : 512 ,
1612+ saltLength : 16 ,
1613+ mgf1Hash : 'sha256' ,
1614+ mgf1HashAlgorithm : 'sha1'
1615+ } , common . mustNotCall ( ) ) , { code : 'ERR_INVALID_ARG_VALUE' } ) ;
1616+
1617+ assert . throws ( ( ) => generateKeyPair ( 'rsa-pss' , {
1618+ modulusLength : 512 ,
1619+ saltLength : 16 ,
1620+ hash : 'sha256' ,
1621+ hashAlgorithm : 'sha1'
1622+ } , common . mustNotCall ( ) ) , { code : 'ERR_INVALID_ARG_VALUE' } ) ;
1623+ }
0 commit comments