@@ -56,6 +56,10 @@ impl fmt::Debug for SignatureAlgorithm {
5656 write ! ( f, "PKCS_RSA_SHA512" )
5757 } else if self == & PKCS_RSA_PSS_SHA256 {
5858 write ! ( f, "PKCS_RSA_PSS_SHA256" )
59+ } else if self == & PKCS_RSA_PSS_SHA384 {
60+ write ! ( f, "PKCS_RSA_PSS_SHA384" )
61+ } else if self == & PKCS_RSA_PSS_SHA512 {
62+ write ! ( f, "PKCS_RSA_PSS_SHA512" )
5963 } else if self == & PKCS_ECDSA_P256_SHA256 {
6064 write ! ( f, "PKCS_ECDSA_P256_SHA256" )
6165 } else if self == & PKCS_ECDSA_P384_SHA384 {
@@ -103,7 +107,9 @@ impl SignatureAlgorithm {
103107 & PKCS_RSA_SHA256 ,
104108 & PKCS_RSA_SHA384 ,
105109 & PKCS_RSA_SHA512 ,
106- //&PKCS_RSA_PSS_SHA256,
110+ & PKCS_RSA_PSS_SHA256 ,
111+ & PKCS_RSA_PSS_SHA384 ,
112+ & PKCS_RSA_PSS_SHA512 ,
107113 & PKCS_ECDSA_P256_SHA256 ,
108114 & PKCS_ECDSA_P384_SHA384 ,
109115 #[ cfg( feature = "aws_lc_rs" ) ]
@@ -163,13 +169,8 @@ pub(crate) mod algo {
163169 params : SignatureAlgorithmParams :: Null ,
164170 } ;
165171
166- // TODO: not really sure whether the certs we generate actually work.
167- // Both openssl and webpki reject them. It *might* be possible that openssl
168- // accepts the certificate if the key is a proper RSA-PSS key, but ring doesn't
169- // support those: https://github.com/briansmith/ring/issues/1353
170- //
171172 /// RSA signing with PKCS#1 2.1 RSASSA-PSS padding and SHA-256 hashing as per [RFC 4055](https://tools.ietf.org/html/rfc4055)
172- pub ( crate ) static PKCS_RSA_PSS_SHA256 : SignatureAlgorithm = SignatureAlgorithm {
173+ pub static PKCS_RSA_PSS_SHA256 : SignatureAlgorithm = SignatureAlgorithm {
173174 // We could also use RSA_ENCRYPTION here, but it's recommended
174175 // to use ID-RSASSA-PSS if possible.
175176 oids_sign_alg : & [ RSASSA_PSS ] ,
@@ -180,7 +181,40 @@ pub(crate) mod algo {
180181 params : SignatureAlgorithmParams :: RsaPss {
181182 // id-sha256 in https://datatracker.ietf.org/doc/html/rfc4055#section-2.1
182183 hash_algorithm : & [ 2 , 16 , 840 , 1 , 101 , 3 , 4 , 2 , 1 ] ,
183- salt_length : 20 ,
184+ // Salt length = hash octets (RFC 4055, pg. 9)
185+ salt_length : 32 ,
186+ } ,
187+ } ;
188+
189+ /// RSA signing with PKCS#1 2.1 RSASSA-PSS padding and SHA-384 hashing as per [RFC 4055](https://tools.ietf.org/html/rfc4055)
190+ pub static PKCS_RSA_PSS_SHA384 : SignatureAlgorithm = SignatureAlgorithm {
191+ // We could also use RSA_ENCRYPTION here, but it's recommended
192+ // to use ID-RSASSA-PSS if possible.
193+ oids_sign_alg : & [ RSASSA_PSS ] ,
194+ #[ cfg( feature = "crypto" ) ]
195+ sign_alg : SignAlgo :: Rsa ( & signature:: RSA_PSS_SHA384 ) ,
196+ oid_components : RSASSA_PSS , //&[1, 2, 840, 113549, 1, 1, 13],
197+ params : SignatureAlgorithmParams :: RsaPss {
198+ // id-sha256 in https://datatracker.ietf.org/doc/html/rfc4055#section-2.1
199+ hash_algorithm : & [ 2 , 16 , 840 , 1 , 101 , 3 , 4 , 2 , 2 ] ,
200+ // Salt length = hash octets (RFC 4055, pg. 9)
201+ salt_length : 48 ,
202+ } ,
203+ } ;
204+
205+ /// RSA signing with PKCS#1 2.1 RSASSA-PSS padding and SHA-512 hashing as per [RFC 4055](https://tools.ietf.org/html/rfc4055)
206+ pub static PKCS_RSA_PSS_SHA512 : SignatureAlgorithm = SignatureAlgorithm {
207+ // We could also use RSA_ENCRYPTION here, but it's recommended
208+ // to use ID-RSASSA-PSS if possible.
209+ oids_sign_alg : & [ RSASSA_PSS ] ,
210+ #[ cfg( feature = "crypto" ) ]
211+ sign_alg : SignAlgo :: Rsa ( & signature:: RSA_PSS_SHA512 ) ,
212+ oid_components : RSASSA_PSS , //&[1, 2, 840, 113549, 1, 1, 13],
213+ params : SignatureAlgorithmParams :: RsaPss {
214+ // id-sha256 in https://datatracker.ietf.org/doc/html/rfc4055#section-2.1
215+ hash_algorithm : & [ 2 , 16 , 840 , 1 , 101 , 3 , 4 , 2 , 3 ] ,
216+ // Salt length = hash octets (RFC 4055, pg. 9)
217+ salt_length : 64 ,
184218 } ,
185219 } ;
186220
0 commit comments