@@ -581,11 +581,21 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
581
581
const publicKey = createPublicKey ( publicPem ) ;
582
582
const privateKey = createPrivateKey ( privatePem ) ;
583
583
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
+
584
592
assert . strictEqual ( publicKey . type , 'public' ) ;
585
593
assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
594
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
586
595
587
596
assert . strictEqual ( privateKey . type , 'private' ) ;
588
597
assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
598
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
589
599
590
600
assert . throws (
591
601
( ) => publicKey . export ( { format : 'jwk' } ) ,
@@ -623,6 +633,38 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
623
633
} ) ;
624
634
}
625
635
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
+
626
668
{
627
669
// This key pair enforces sha256 as the message digest and the MGF1
628
670
// message digest and a salt length of at least 16 bytes.
@@ -681,11 +723,21 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
681
723
const publicKey = createPublicKey ( publicPem ) ;
682
724
const privateKey = createPrivateKey ( privatePem ) ;
683
725
726
+ const expectedKeyDetails = {
727
+ modulusLength : 2048 ,
728
+ publicExponent : 65537n ,
729
+ hashAlgorithm : 'sha512' ,
730
+ mgf1HashAlgorithm : 'sha256' ,
731
+ saltLength : 20
732
+ } ;
733
+
684
734
assert . strictEqual ( publicKey . type , 'public' ) ;
685
735
assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
736
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , expectedKeyDetails ) ;
686
737
687
738
assert . strictEqual ( privateKey . type , 'private' ) ;
688
739
assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
740
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , expectedKeyDetails ) ;
689
741
690
742
// Node.js usually uses the same hash function for the message and for MGF1.
691
743
// However, when a different MGF1 message digest algorithm has been
0 commit comments