@@ -581,11 +581,21 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
581581 const publicKey = createPublicKey ( publicPem ) ;
582582 const privateKey = createPrivateKey ( privatePem ) ;
583583
584+ // Because no RSASSA-PSS-params appears in the PEM, no defaults should be
585+ // added for the PSS parameters. This is different from an empty
586+ // RSASSA-PSS-params sequence (see test below).
587+ const expectedKeyDetails = {
588+ modulusLength : 2048 ,
589+ publicExponent : 65537n
590+ } ;
591+
584592 assert . strictEqual ( publicKey . type , 'public' ) ;
585593 assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
594+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
586595
587596 assert . strictEqual ( privateKey . type , 'private' ) ;
588597 assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
598+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
589599
590600 assert . throws (
591601 ( ) => publicKey . export ( { format : 'jwk' } ) ,
@@ -623,6 +633,38 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
623633 } ) ;
624634 }
625635
636+ {
637+ // This key pair enforces sha1 as the message digest and the MGF1
638+ // message digest and a salt length of 20 bytes.
639+
640+ const publicPem = fixtures . readKey ( 'rsa_pss_public_2048_sha1_sha1_20.pem' ) ;
641+ const privatePem =
642+ fixtures . readKey ( 'rsa_pss_private_2048_sha1_sha1_20.pem' ) ;
643+
644+ const publicKey = createPublicKey ( publicPem ) ;
645+ const privateKey = createPrivateKey ( privatePem ) ;
646+
647+ // Unlike the previous key pair, this key pair contains an RSASSA-PSS-params
648+ // sequence. However, because all values in the RSASSA-PSS-params are set to
649+ // their defaults (see RFC 3447), the ASN.1 structure contains an empty
650+ // sequence. Node.js should add the default values to the key details.
651+ const expectedKeyDetails = {
652+ modulusLength : 2048 ,
653+ publicExponent : 65537n ,
654+ hashAlgorithm : 'sha1' ,
655+ mgf1HashAlgorithm : 'sha1' ,
656+ saltLength : 20
657+ } ;
658+
659+ assert . strictEqual ( publicKey . type , 'public' ) ;
660+ assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
661+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
662+
663+ assert . strictEqual ( privateKey . type , 'private' ) ;
664+ assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
665+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
666+ }
667+
626668 {
627669 // This key pair enforces sha256 as the message digest and the MGF1
628670 // message digest and a salt length of at least 16 bytes.
@@ -681,11 +723,21 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
681723 const publicKey = createPublicKey ( publicPem ) ;
682724 const privateKey = createPrivateKey ( privatePem ) ;
683725
726+ const expectedKeyDetails = {
727+ modulusLength : 2048 ,
728+ publicExponent : 65537n ,
729+ hashAlgorithm : 'sha512' ,
730+ mgf1HashAlgorithm : 'sha256' ,
731+ saltLength : 20
732+ } ;
733+
684734 assert . strictEqual ( publicKey . type , 'public' ) ;
685735 assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
736+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
686737
687738 assert . strictEqual ( privateKey . type , 'private' ) ;
688739 assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
740+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
689741
690742 // Node.js usually uses the same hash function for the message and for MGF1.
691743 // However, when a different MGF1 message digest algorithm has been
0 commit comments