@@ -391,6 +391,43 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
391
391
} ) ) ;
392
392
}
393
393
394
+ {
395
+ // RFC 8017, A.2.3.: "For a given hashAlgorithm, the default value of
396
+ // saltLength is the octet length of the hash value."
397
+
398
+ generateKeyPair ( 'rsa-pss' , {
399
+ modulusLength : 512 ,
400
+ hashAlgorithm : 'sha512'
401
+ } , common . mustSucceed ( ( publicKey , privateKey ) => {
402
+ const expectedKeyDetails = {
403
+ modulusLength : 512 ,
404
+ publicExponent : 65537n ,
405
+ hashAlgorithm : 'sha512' ,
406
+ mgf1HashAlgorithm : 'sha512' ,
407
+ saltLength : 64
408
+ } ;
409
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
410
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
411
+ } ) ) ;
412
+
413
+ // It is still possible to explicitly set saltLength to 0.
414
+ generateKeyPair ( 'rsa-pss' , {
415
+ modulusLength : 512 ,
416
+ hashAlgorithm : 'sha512' ,
417
+ saltLength : 0
418
+ } , common . mustSucceed ( ( publicKey , privateKey ) => {
419
+ const expectedKeyDetails = {
420
+ modulusLength : 512 ,
421
+ publicExponent : 65537n ,
422
+ hashAlgorithm : 'sha512' ,
423
+ mgf1HashAlgorithm : 'sha512' ,
424
+ saltLength : 0
425
+ } ;
426
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
427
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
428
+ } ) ) ;
429
+ }
430
+
394
431
{
395
432
const privateKeyEncoding = {
396
433
type : 'pkcs8' ,
0 commit comments