@@ -369,6 +369,43 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
369369 } ) ) ;
370370}
371371
372+ {
373+ // RFC 8017, A.2.3.: "For a given hashAlgorithm, the default value of
374+ // saltLength is the octet length of the hash value."
375+
376+ generateKeyPair ( 'rsa-pss' , {
377+ modulusLength : 512 ,
378+ hashAlgorithm : 'sha512'
379+ } , common . mustSucceed ( ( publicKey , privateKey ) => {
380+ const expectedKeyDetails = {
381+ modulusLength : 512 ,
382+ publicExponent : 65537n ,
383+ hashAlgorithm : 'sha512' ,
384+ mgf1HashAlgorithm : 'sha512' ,
385+ saltLength : 64
386+ } ;
387+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
388+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
389+ } ) ) ;
390+
391+ // It is still possible to explicitly set saltLength to 0.
392+ generateKeyPair ( 'rsa-pss' , {
393+ modulusLength : 512 ,
394+ hashAlgorithm : 'sha512' ,
395+ saltLength : 0
396+ } , common . mustSucceed ( ( publicKey , privateKey ) => {
397+ const expectedKeyDetails = {
398+ modulusLength : 512 ,
399+ publicExponent : 65537n ,
400+ hashAlgorithm : 'sha512' ,
401+ mgf1HashAlgorithm : 'sha512' ,
402+ saltLength : 0
403+ } ;
404+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
405+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
406+ } ) ) ;
407+ }
408+
372409{
373410 const privateKeyEncoding = {
374411 type : 'pkcs8' ,
0 commit comments