@@ -302,8 +302,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
302
302
generateKeyPair ( 'rsa-pss' , {
303
303
modulusLength : 512 ,
304
304
saltLength : 16 ,
305
- hash : 'sha256' ,
306
- mgf1Hash : 'sha256'
305
+ hashAlgorithm : 'sha256' ,
306
+ mgf1HashAlgorithm : 'sha256'
307
307
} , common . mustSucceed ( ( publicKey , privateKey ) => {
308
308
assert . strictEqual ( publicKey . type , 'public' ) ;
309
309
assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
@@ -1324,12 +1324,12 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
1324
1324
assert . throws ( ( ) => {
1325
1325
generateKeyPairSync ( 'rsa-pss' , {
1326
1326
modulusLength : 4096 ,
1327
- hash : hashValue
1327
+ hashAlgorithm : hashValue
1328
1328
} ) ;
1329
1329
} , {
1330
1330
name : 'TypeError' ,
1331
1331
code : 'ERR_INVALID_ARG_VALUE' ,
1332
- message : "The property 'options.hash ' is invalid. " +
1332
+ message : "The property 'options.hashAlgorithm ' is invalid. " +
1333
1333
`Received ${ inspect ( hashValue ) } `
1334
1334
} ) ;
1335
1335
}
@@ -1339,8 +1339,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
1339
1339
generateKeyPair ( 'rsa-pss' , {
1340
1340
modulusLength : 512 ,
1341
1341
saltLength : 2147483648 ,
1342
- hash : 'sha256' ,
1343
- mgf1Hash : 'sha256'
1342
+ hashAlgorithm : 'sha256' ,
1343
+ mgf1HashAlgorithm : 'sha256'
1344
1344
} , common . mustNotCall ( ) ) ;
1345
1345
} , {
1346
1346
name : 'TypeError' ,
@@ -1353,8 +1353,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
1353
1353
generateKeyPair ( 'rsa-pss' , {
1354
1354
modulusLength : 512 ,
1355
1355
saltLength : - 1 ,
1356
- hash : 'sha256' ,
1357
- mgf1Hash : 'sha256'
1356
+ hashAlgorithm : 'sha256' ,
1357
+ mgf1HashAlgorithm : 'sha256'
1358
1358
} , common . mustNotCall ( ) ) ;
1359
1359
} , {
1360
1360
name : 'TypeError' ,
@@ -1451,8 +1451,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
1451
1451
generateKeyPair ( 'rsa-pss' , {
1452
1452
modulusLength : 512 ,
1453
1453
saltLength : 16 ,
1454
- hash : 'sha256' ,
1455
- mgf1Hash : undefined
1454
+ hashAlgorithm : 'sha256' ,
1455
+ mgf1HashAlgorithm : undefined
1456
1456
} ) ;
1457
1457
} ,
1458
1458
{
@@ -1462,21 +1462,21 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
1462
1462
}
1463
1463
) ;
1464
1464
1465
- for ( const mgf1Hash of [ null , 0 , false , { } , [ ] ] ) {
1465
+ for ( const mgf1HashAlgorithm of [ null , 0 , false , { } , [ ] ] ) {
1466
1466
assert . throws (
1467
1467
( ) => {
1468
1468
generateKeyPair ( 'rsa-pss' , {
1469
1469
modulusLength : 512 ,
1470
1470
saltLength : 16 ,
1471
- hash : 'sha256' ,
1472
- mgf1Hash
1471
+ hashAlgorithm : 'sha256' ,
1472
+ mgf1HashAlgorithm
1473
1473
} , common . mustNotCall ( ) ) ;
1474
1474
} ,
1475
1475
{
1476
1476
name : 'TypeError' ,
1477
1477
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 ) } `
1480
1480
1481
1481
}
1482
1482
) ;
@@ -1568,3 +1568,56 @@ if (!common.hasOpenSSL3) {
1568
1568
}
1569
1569
}
1570
1570
}
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