@@ -26,8 +26,10 @@ use alloc::{
2626 vec:: Vec ,
2727} ;
2828use cipher:: {
29- BlockModeEncrypt , Iv , Key , KeyIvInit , block_padding:: Pkcs7 , crypto_common:: Generate ,
30- rand_core:: CryptoRng ,
29+ BlockModeEncrypt , Iv , Key , KeyIvInit ,
30+ block_padding:: Pkcs7 ,
31+ crypto_common:: Generate ,
32+ rand_core:: { CryptoRng , RngCore } ,
3133} ;
3234use const_oid:: ObjectIdentifier ;
3335use core:: { cmp:: Ordering , fmt, marker:: PhantomData } ;
@@ -437,7 +439,7 @@ impl<'s> SignedDataBuilder<'s> {
437439 S : RandomizedSigner < Signature > ,
438440 S :: VerifyingKey : EncodePublicKey ,
439441 Signature : SignatureBitStringEncoding ,
440- R : CryptoRng + ?Sized ,
442+ R : CryptoRng + RngCore + ?Sized ,
441443 {
442444 let signer_info = signer_info_builder
443445 . build_with_rng :: < S , Signature , R > ( signer, rng)
@@ -482,7 +484,7 @@ impl<'s> SignedDataBuilder<'s> {
482484 S : AsyncRandomizedSigner < Signature > ,
483485 S :: VerifyingKey : EncodePublicKey ,
484486 Signature : SignatureBitStringEncoding ,
485- R : CryptoRng + ?Sized ,
487+ R : CryptoRng + RngCore + ?Sized ,
486488 {
487489 let signer_info = signer_info_builder
488490 . build_with_rng_async :: < S , Signature , R > ( signer, rng)
@@ -606,7 +608,7 @@ impl<'s> SignedDataBuilder<'s> {
606608/// formats. All implementations must implement this trait.
607609pub trait RecipientInfoBuilder {
608610 /// Associated Rng type
609- type Rng : CryptoRng + ?Sized ;
611+ type Rng : CryptoRng + RngCore + ?Sized ;
610612
611613 /// Return the recipient info type
612614 fn recipient_info_type ( & self ) -> RecipientInfoType ;
@@ -668,9 +670,9 @@ impl<R> KeyTransRecipientInfoBuilder<R> {
668670 }
669671}
670672
671- impl < R : ? Sized > RecipientInfoBuilder for KeyTransRecipientInfoBuilder < R >
673+ impl < R > RecipientInfoBuilder for KeyTransRecipientInfoBuilder < R >
672674where
673- R : CryptoRng ,
675+ R : CryptoRng + RngCore + ? Sized ,
674676{
675677 type Rng = R ;
676678
@@ -739,9 +741,9 @@ impl<R> KekRecipientInfoBuilder<R> {
739741 }
740742}
741743
742- impl < R : ? Sized > RecipientInfoBuilder for KekRecipientInfoBuilder < R >
744+ impl < R > RecipientInfoBuilder for KekRecipientInfoBuilder < R >
743745where
744- R : CryptoRng ,
746+ R : CryptoRng + RngCore + ? Sized ,
745747{
746748 type Rng = R ;
747749
@@ -782,7 +784,7 @@ pub trait PwriEncryptor {
782784 /// including eventual parameters (e.g. the used iv).
783785 fn key_encryption_algorithm ( & self ) -> Result < AlgorithmIdentifierOwned > ;
784786 /// Encrypt the padded content-encryption key twice following RFC 3211, § 2.3.1
785- fn encrypt_rfc3211 < R : CryptoRng + ?Sized > (
787+ fn encrypt_rfc3211 < R : CryptoRng + RngCore + ?Sized > (
786788 & mut self ,
787789 padded_content_encryption_key : & [ u8 ] ,
788790 rng : & mut R ,
@@ -830,10 +832,10 @@ where
830832 }
831833}
832834
833- impl < P , R : ? Sized > PasswordRecipientInfoBuilder < P , R >
835+ impl < P , R > PasswordRecipientInfoBuilder < P , R >
834836where
835837 P : PwriEncryptor ,
836- R : CryptoRng ,
838+ R : CryptoRng + RngCore + ? Sized ,
837839{
838840 /// Wrap the content-encryption key according to [RFC 3211, §2.3.1]:
839841 /// ....
@@ -874,7 +876,7 @@ where
874876impl < P , R > RecipientInfoBuilder for PasswordRecipientInfoBuilder < P , R >
875877where
876878 P : PwriEncryptor ,
877- R : CryptoRng + ?Sized ,
879+ R : CryptoRng + RngCore + ?Sized ,
878880{
879881 type Rng = R ;
880882
@@ -933,7 +935,7 @@ impl<R> OtherRecipientInfoBuilder<R> {
933935
934936impl < R > RecipientInfoBuilder for OtherRecipientInfoBuilder < R >
935937where
936- R : CryptoRng + ?Sized ,
938+ R : CryptoRng + RngCore + ?Sized ,
937939{
938940 type Rng = R ;
939941
@@ -1017,7 +1019,7 @@ impl<'c, R> EnvelopedDataBuilder<'c, R> {
10171019
10181020impl < ' c , R > EnvelopedDataBuilder < ' c , R >
10191021where
1020- R : CryptoRng + ?Sized ,
1022+ R : CryptoRng + RngCore + ?Sized ,
10211023{
10221024 /// Add recipient info. A builder is used, which generates a `RecipientInfo` according to
10231025 /// RFC 5652 § 6.2, when `EnvelopedData` is built.
@@ -1214,7 +1216,7 @@ fn encrypt_data<R>(
12141216 rng : & mut R ,
12151217) -> Result < ( Vec < u8 > , Vec < u8 > , AlgorithmIdentifierOwned ) >
12161218where
1217- R : CryptoRng + ?Sized ,
1219+ R : CryptoRng + RngCore + ?Sized ,
12181220{
12191221 match encryption_algorithm_identifier {
12201222 ContentEncryptionAlgorithm :: Aes128Cbc => encrypt_block_mode ! (
0 commit comments