@@ -53,6 +53,53 @@ export class RsaSha256 implements SignatureAlgorithm {
53
53
} ;
54
54
}
55
55
56
+ export class RsaSha256Mgf1 implements SignatureAlgorithm {
57
+ getSignature = createOptionalCallbackFunction (
58
+ ( signedInfo : crypto . BinaryLike , privateKey : crypto . KeyLike ) : string => {
59
+ if ( ! ( typeof privateKey === "string" || Buffer . isBuffer ( privateKey ) ) ) {
60
+ throw new Error ( "keys must be strings or buffers" ) ;
61
+ }
62
+ const signer = crypto . createSign ( "RSA-SHA256" ) ;
63
+ signer . update ( signedInfo ) ;
64
+ const res = signer . sign (
65
+ {
66
+ key : privateKey ,
67
+ padding : crypto . constants . RSA_PKCS1_PSS_PADDING ,
68
+ saltLength : crypto . constants . RSA_PSS_SALTLEN_DIGEST ,
69
+ } ,
70
+ "base64" ,
71
+ ) ;
72
+
73
+ return res ;
74
+ } ,
75
+ ) ;
76
+
77
+ verifySignature = createOptionalCallbackFunction (
78
+ ( material : string , key : crypto . KeyLike , signatureValue : string ) : boolean => {
79
+ if ( ! ( typeof key === "string" || Buffer . isBuffer ( key ) ) ) {
80
+ throw new Error ( "keys must be strings or buffers" ) ;
81
+ }
82
+ const verifier = crypto . createVerify ( "RSA-SHA256" ) ;
83
+ verifier . update ( material ) ;
84
+ const res = verifier . verify (
85
+ {
86
+ key : key ,
87
+ padding : crypto . constants . RSA_PKCS1_PSS_PADDING ,
88
+ saltLength : crypto . constants . RSA_PSS_SALTLEN_DIGEST ,
89
+ } ,
90
+ signatureValue ,
91
+ "base64" ,
92
+ ) ;
93
+
94
+ return res ;
95
+ } ,
96
+ ) ;
97
+
98
+ getAlgorithmName = ( ) => {
99
+ return "http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1" ;
100
+ } ;
101
+ }
102
+
56
103
export class RsaSha512 implements SignatureAlgorithm {
57
104
getSignature = createOptionalCallbackFunction (
58
105
( signedInfo : crypto . BinaryLike , privateKey : crypto . KeyLike ) : string => {
0 commit comments