@@ -182,7 +182,7 @@ impl JsonWebKey<CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse>
182182 } ;
183183 crypto:: verify_rsa_signature (
184184 self ,
185- rsa:: PaddingScheme :: new_pkcs1v15_sign :: < sha2:: Sha256 > ( ) ,
185+ rsa:: Pkcs1v15Sign :: new :: < sha2:: Sha256 > ( ) ,
186186 message,
187187 signature,
188188 )
@@ -195,7 +195,7 @@ impl JsonWebKey<CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse>
195195 } ;
196196 crypto:: verify_rsa_signature (
197197 self ,
198- rsa:: PaddingScheme :: new_pkcs1v15_sign :: < sha2:: Sha384 > ( ) ,
198+ rsa:: Pkcs1v15Sign :: new :: < sha2:: Sha384 > ( ) ,
199199 message,
200200 signature,
201201 )
@@ -208,7 +208,7 @@ impl JsonWebKey<CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse>
208208 } ;
209209 crypto:: verify_rsa_signature (
210210 self ,
211- rsa:: PaddingScheme :: new_pkcs1v15_sign :: < sha2:: Sha512 > ( ) ,
211+ rsa:: Pkcs1v15Sign :: new :: < sha2:: Sha512 > ( ) ,
212212 message,
213213 signature,
214214 )
@@ -221,7 +221,7 @@ impl JsonWebKey<CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse>
221221 } ;
222222 crypto:: verify_rsa_signature (
223223 self ,
224- rsa:: PaddingScheme :: new_pss :: < sha2:: Sha256 > ( ) ,
224+ rsa:: Pss :: new :: < sha2:: Sha256 > ( ) ,
225225 message,
226226 signature,
227227 )
@@ -234,7 +234,7 @@ impl JsonWebKey<CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse>
234234 } ;
235235 crypto:: verify_rsa_signature (
236236 self ,
237- rsa:: PaddingScheme :: new_pss :: < sha2:: Sha384 > ( ) ,
237+ rsa:: Pss :: new :: < sha2:: Sha384 > ( ) ,
238238 message,
239239 signature,
240240 )
@@ -247,7 +247,7 @@ impl JsonWebKey<CoreJwsSigningAlgorithm, CoreJsonWebKeyType, CoreJsonWebKeyUse>
247247 } ;
248248 crypto:: verify_rsa_signature (
249249 self ,
250- rsa:: PaddingScheme :: new_pss :: < sha2:: Sha512 > ( ) ,
250+ rsa:: Pss :: new :: < sha2:: Sha512 > ( ) ,
251251 message,
252252 signature,
253253 )
@@ -449,82 +449,99 @@ impl
449449 signature_alg : & CoreJwsSigningAlgorithm ,
450450 msg : & [ u8 ] ,
451451 ) -> Result < Vec < u8 > , SigningError > {
452- let ( padding_alg , hash ) = match * signature_alg {
452+ match * signature_alg {
453453 CoreJwsSigningAlgorithm :: RsaSsaPkcs1V15Sha256 => {
454454 let mut hasher = sha2:: Sha256 :: new ( ) ;
455455 hasher. update ( msg) ;
456456 let hash = hasher. finalize ( ) . to_vec ( ) ;
457- (
458- rsa:: PaddingScheme :: new_pkcs1v15_sign :: < sha2:: Sha256 > ( ) ,
459- hash,
460- )
457+
458+ self . key_pair
459+ . sign_with_rng (
460+ & mut dyn_clone:: clone_box ( & self . rng ) ,
461+ rsa:: Pkcs1v15Sign :: new :: < sha2:: Sha256 > ( ) ,
462+ & hash,
463+ )
464+ . map_err ( |_| SigningError :: CryptoError )
461465 }
462466 CoreJwsSigningAlgorithm :: RsaSsaPkcs1V15Sha384 => {
463467 let mut hasher = sha2:: Sha384 :: new ( ) ;
464468 hasher. update ( msg) ;
465469 let hash = hasher. finalize ( ) . to_vec ( ) ;
466- (
467- rsa:: PaddingScheme :: new_pkcs1v15_sign :: < sha2:: Sha384 > ( ) ,
468- hash,
469- )
470+
471+ self . key_pair
472+ . sign_with_rng (
473+ & mut dyn_clone:: clone_box ( & self . rng ) ,
474+ rsa:: Pkcs1v15Sign :: new :: < sha2:: Sha384 > ( ) ,
475+ & hash,
476+ )
477+ . map_err ( |_| SigningError :: CryptoError )
470478 }
471479 CoreJwsSigningAlgorithm :: RsaSsaPkcs1V15Sha512 => {
472480 let mut hasher = sha2:: Sha512 :: new ( ) ;
473481 hasher. update ( msg) ;
474482 let hash = hasher. finalize ( ) . to_vec ( ) ;
475- (
476- rsa:: PaddingScheme :: new_pkcs1v15_sign :: < sha2:: Sha512 > ( ) ,
477- hash,
478- )
483+
484+ self . key_pair
485+ . sign_with_rng (
486+ & mut dyn_clone:: clone_box ( & self . rng ) ,
487+ rsa:: Pkcs1v15Sign :: new :: < sha2:: Sha512 > ( ) ,
488+ & hash,
489+ )
490+ . map_err ( |_| SigningError :: CryptoError )
479491 }
480492 CoreJwsSigningAlgorithm :: RsaSsaPssSha256 => {
481493 let mut hasher = sha2:: Sha256 :: new ( ) ;
482494 hasher. update ( msg) ;
483495 let hash = hasher. finalize ( ) . to_vec ( ) ;
484- (
485- rsa:: PaddingScheme :: new_pss_with_salt :: < sha2:: Sha256 > ( hash. len ( ) ) ,
486- hash,
487- )
496+
497+ self . key_pair
498+ . sign_with_rng (
499+ & mut dyn_clone:: clone_box ( & self . rng ) ,
500+ rsa:: Pss :: new_with_salt :: < sha2:: Sha256 > ( hash. len ( ) ) ,
501+ & hash,
502+ )
503+ . map_err ( |_| SigningError :: CryptoError )
488504 }
489505 CoreJwsSigningAlgorithm :: RsaSsaPssSha384 => {
490506 let mut hasher = sha2:: Sha384 :: new ( ) ;
491507 hasher. update ( msg) ;
492508 let hash = hasher. finalize ( ) . to_vec ( ) ;
493- (
494- rsa:: PaddingScheme :: new_pss_with_salt :: < sha2:: Sha384 > ( hash. len ( ) ) ,
495- hash,
496- )
509+
510+ self . key_pair
511+ . sign_with_rng (
512+ & mut dyn_clone:: clone_box ( & self . rng ) ,
513+ rsa:: Pss :: new_with_salt :: < sha2:: Sha384 > ( hash. len ( ) ) ,
514+ & hash,
515+ )
516+ . map_err ( |_| SigningError :: CryptoError )
497517 }
498518 CoreJwsSigningAlgorithm :: RsaSsaPssSha512 => {
499519 let mut hasher = sha2:: Sha512 :: new ( ) ;
500520 hasher. update ( msg) ;
501521 let hash = hasher. finalize ( ) . to_vec ( ) ;
502- (
503- rsa:: PaddingScheme :: new_pss_with_salt :: < sha2:: Sha512 > ( hash. len ( ) ) ,
504- hash,
505- )
506- }
507- ref other => {
508- return Err ( SigningError :: UnsupportedAlg (
509- serde_plain:: to_string ( other) . unwrap_or_else ( |err| {
510- panic ! (
511- "signature alg {:?} failed to serialize to a string: {}" ,
512- other, err
513- )
514- } ) ,
515- ) )
516- }
517- } ;
518522
519- let sig = self
520- . key_pair
521- . sign_blinded ( & mut dyn_clone:: clone_box ( & self . rng ) , padding_alg, & hash)
522- . map_err ( |_| SigningError :: CryptoError ) ?;
523- Ok ( sig)
523+ self . key_pair
524+ . sign_with_rng (
525+ & mut dyn_clone:: clone_box ( & self . rng ) ,
526+ rsa:: Pss :: new_with_salt :: < sha2:: Sha512 > ( hash. len ( ) ) ,
527+ & hash,
528+ )
529+ . map_err ( |_| SigningError :: CryptoError )
530+ }
531+ ref other => Err ( SigningError :: UnsupportedAlg (
532+ serde_plain:: to_string ( other) . unwrap_or_else ( |err| {
533+ panic ! (
534+ "signature alg {:?} failed to serialize to a string: {}" ,
535+ other, err
536+ )
537+ } ) ,
538+ ) ) ,
539+ }
524540 }
525541
526542 fn as_verification_key ( & self ) -> CoreJsonWebKey {
527- use rsa:: PublicKeyParts ;
543+ use rsa:: traits:: PublicKeyParts ;
544+
528545 let public_key = self . key_pair . to_public_key ( ) ;
529546 CoreJsonWebKey {
530547 kty : CoreJsonWebKeyType :: RSA ,
0 commit comments