Skip to content

Commit 7e29841

Browse files
authored
Merge branch 'RustCrypto:master' into master
2 parents 4874840 + 336020c commit 7e29841

21 files changed

Lines changed: 145 additions & 162 deletions

Cargo.lock

Lines changed: 75 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ members = [
1818
"pkcs5",
1919
"pkcs8",
2020
"pkcs12",
21-
# "sec1",
21+
"sec1",
2222
"serdect",
2323
"spki",
2424
"tai64",
@@ -29,7 +29,6 @@ members = [
2929
"x509-cert/test-support",
3030
"x509-ocsp"
3131
]
32-
exclude = ["sec1"]
3332

3433
[profile.dev]
3534
opt-level = 2
@@ -52,7 +51,7 @@ pkcs1 = { path = "./pkcs1" }
5251
pkcs5 = { path = "./pkcs5" }
5352
pkcs8 = { path = "./pkcs8" }
5453
pkcs12 = { path = "./pkcs12" }
55-
#sec1 = { path = "./sec1" }
54+
sec1 = { path = "./sec1" }
5655
serdect = { path = "./serdect" }
5756
spki = { path = "./spki" }
5857
tai64 = { path = "./tai64" }

cms/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cbc = { version = "0.2.0-rc.2", optional = true }
2828
cipher = { version = "0.5.0-rc.3", features = ["alloc", "block-padding", "rand_core"], optional = true }
2929
digest = { version = "0.11.0-rc.5", optional = true }
3030
elliptic-curve = { version = "0.14.0-rc.21", optional = true }
31-
rsa = { version = "0.10.0-rc.11", optional = true }
31+
rsa = { version = "0.10.0-rc.13", optional = true }
3232
sha1 = { version = "0.11.0-rc.3", optional = true }
3333
sha2 = { version = "0.11.0-rc.3", optional = true }
3434
sha3 = { version = "0.11.0-rc.3", optional = true }
@@ -42,10 +42,10 @@ hex-literal = "1"
4242
pem-rfc7468 = "1"
4343
pkcs5 = "0.8.0-rc.12"
4444
pbkdf2 = "0.13.0-rc.6"
45-
rand = "0.10.0-rc.6"
46-
rsa = { version = "0.10.0-rc.11", features = ["sha2"] }
47-
ecdsa = { version = "0.17.0-rc.12", features = ["digest", "pem"] }
48-
p256 = "0.14.0-rc.4"
45+
rand = "0.10.0-rc.7"
46+
rsa = { version = "0.10.0-rc.13", features = ["sha2"] }
47+
ecdsa = { version = "0.17.0-rc.13", features = ["digest", "pem"] }
48+
p256 = "0.14.0-rc.5"
4949
tokio = { version = "1.45.1", features = ["macros", "rt"] }
5050
x509-cert = { version = "0.3.0-rc.3", features = ["pem"] }
5151

cms/src/builder.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ use alloc::{
2626
vec::Vec,
2727
};
2828
use cipher::{
29-
BlockModeEncrypt, Iv, Key, KeyIvInit,
30-
block_padding::Pkcs7,
31-
crypto_common::Generate,
32-
rand_core::{CryptoRng, RngCore},
29+
BlockModeEncrypt, Iv, Key, KeyIvInit, block_padding::Pkcs7, crypto_common::Generate,
30+
rand_core::CryptoRng,
3331
};
3432
use const_oid::ObjectIdentifier;
3533
use core::{cmp::Ordering, fmt, marker::PhantomData};
@@ -439,7 +437,7 @@ impl<'s> SignedDataBuilder<'s> {
439437
S: RandomizedSigner<Signature>,
440438
S::VerifyingKey: EncodePublicKey,
441439
Signature: SignatureBitStringEncoding,
442-
R: CryptoRng + RngCore + ?Sized,
440+
R: CryptoRng + ?Sized,
443441
{
444442
let signer_info = signer_info_builder
445443
.build_with_rng::<S, Signature, R>(signer, rng)
@@ -484,7 +482,7 @@ impl<'s> SignedDataBuilder<'s> {
484482
S: AsyncRandomizedSigner<Signature>,
485483
S::VerifyingKey: EncodePublicKey,
486484
Signature: SignatureBitStringEncoding,
487-
R: CryptoRng + RngCore + ?Sized,
485+
R: CryptoRng + ?Sized,
488486
{
489487
let signer_info = signer_info_builder
490488
.build_with_rng_async::<S, Signature, R>(signer, rng)
@@ -608,7 +606,7 @@ impl<'s> SignedDataBuilder<'s> {
608606
/// formats. All implementations must implement this trait.
609607
pub trait RecipientInfoBuilder {
610608
/// Associated Rng type
611-
type Rng: CryptoRng + RngCore + ?Sized;
609+
type Rng: CryptoRng + ?Sized;
612610

613611
/// Return the recipient info type
614612
fn recipient_info_type(&self) -> RecipientInfoType;
@@ -670,9 +668,9 @@ impl<R> KeyTransRecipientInfoBuilder<R> {
670668
}
671669
}
672670

673-
impl<R> RecipientInfoBuilder for KeyTransRecipientInfoBuilder<R>
671+
impl<R: ?Sized> RecipientInfoBuilder for KeyTransRecipientInfoBuilder<R>
674672
where
675-
R: CryptoRng + RngCore + ?Sized,
673+
R: CryptoRng,
676674
{
677675
type Rng = R;
678676

@@ -741,9 +739,9 @@ impl<R> KekRecipientInfoBuilder<R> {
741739
}
742740
}
743741

744-
impl<R> RecipientInfoBuilder for KekRecipientInfoBuilder<R>
742+
impl<R: ?Sized> RecipientInfoBuilder for KekRecipientInfoBuilder<R>
745743
where
746-
R: CryptoRng + RngCore + ?Sized,
744+
R: CryptoRng,
747745
{
748746
type Rng = R;
749747

@@ -784,7 +782,7 @@ pub trait PwriEncryptor {
784782
/// including eventual parameters (e.g. the used iv).
785783
fn key_encryption_algorithm(&self) -> Result<AlgorithmIdentifierOwned>;
786784
/// Encrypt the padded content-encryption key twice following RFC 3211, § 2.3.1
787-
fn encrypt_rfc3211<R: CryptoRng + RngCore + ?Sized>(
785+
fn encrypt_rfc3211<R: CryptoRng + ?Sized>(
788786
&mut self,
789787
padded_content_encryption_key: &[u8],
790788
rng: &mut R,
@@ -832,10 +830,10 @@ where
832830
}
833831
}
834832

835-
impl<P, R> PasswordRecipientInfoBuilder<P, R>
833+
impl<P, R: ?Sized> PasswordRecipientInfoBuilder<P, R>
836834
where
837835
P: PwriEncryptor,
838-
R: CryptoRng + RngCore + ?Sized,
836+
R: CryptoRng,
839837
{
840838
/// Wrap the content-encryption key according to [RFC 3211, §2.3.1]:
841839
/// ....
@@ -876,7 +874,7 @@ where
876874
impl<P, R> RecipientInfoBuilder for PasswordRecipientInfoBuilder<P, R>
877875
where
878876
P: PwriEncryptor,
879-
R: CryptoRng + RngCore + ?Sized,
877+
R: CryptoRng + ?Sized,
880878
{
881879
type Rng = R;
882880

@@ -935,7 +933,7 @@ impl<R> OtherRecipientInfoBuilder<R> {
935933

936934
impl<R> RecipientInfoBuilder for OtherRecipientInfoBuilder<R>
937935
where
938-
R: CryptoRng + RngCore + ?Sized,
936+
R: CryptoRng + ?Sized,
939937
{
940938
type Rng = R;
941939

@@ -1019,7 +1017,7 @@ impl<'c, R> EnvelopedDataBuilder<'c, R> {
10191017

10201018
impl<'c, R> EnvelopedDataBuilder<'c, R>
10211019
where
1022-
R: CryptoRng + RngCore + ?Sized,
1020+
R: CryptoRng + ?Sized,
10231021
{
10241022
/// Add recipient info. A builder is used, which generates a `RecipientInfo` according to
10251023
/// RFC 5652 § 6.2, when `EnvelopedData` is built.
@@ -1216,7 +1214,7 @@ fn encrypt_data<R>(
12161214
rng: &mut R,
12171215
) -> Result<(Vec<u8>, Vec<u8>, AlgorithmIdentifierOwned)>
12181216
where
1219-
R: CryptoRng + RngCore + ?Sized,
1217+
R: CryptoRng + ?Sized,
12201218
{
12211219
match encryption_algorithm_identifier {
12221220
ContentEncryptionAlgorithm::Aes128Cbc => encrypt_block_mode!(

cms/src/builder/kari.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
// Super imports
1010
use super::{
11-
AlgorithmIdentifierOwned, CryptoRng, RecipientInfoBuilder, RecipientInfoType, Result, RngCore,
11+
AlgorithmIdentifierOwned, CryptoRng, RecipientInfoBuilder, RecipientInfoType, Result,
1212
UserKeyingMaterial,
1313
utils::kw::{KeyWrapAlgorithm, WrappedKey},
1414
};
@@ -250,9 +250,10 @@ where
250250
})
251251
}
252252
}
253-
impl<R, C, KA, KW, Enc> RecipientInfoBuilder for KeyAgreeRecipientInfoBuilder<R, C, KA, KW, Enc>
253+
impl<R: ?Sized, C, KA, KW, Enc> RecipientInfoBuilder
254+
for KeyAgreeRecipientInfoBuilder<R, C, KA, KW, Enc>
254255
where
255-
R: CryptoRng + RngCore + ?Sized,
256+
R: CryptoRng,
256257
KA: KeyAgreementAlgorithm + AssociatedOid,
257258
C: CurveArithmetic + AssociatedOid + PointCompression,
258259
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,

cms/tests/builder.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use pem_rfc7468::LineEnding;
2323
use pkcs5::pbes2::Pbkdf2Params;
2424
use rand::rngs::SysRng;
2525
use rsa::pkcs1::DecodeRsaPrivateKey;
26-
use rsa::rand_core::{CryptoRng, RngCore, TryRngCore};
26+
use rsa::rand_core::{CryptoRng, TryRngCore};
2727
use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey};
2828
use rsa::{pkcs1v15, pss};
2929
use sha2::Sha256;
@@ -690,10 +690,7 @@ fn test_create_password_recipient_info() {
690690
key_derivation_params: pkcs5::pbes2::Pbkdf2Params,
691691
}
692692
impl<'a> Aes128CbcPwriEncryptor<'a> {
693-
pub fn new<R: CryptoRng + RngCore + ?Sized>(
694-
challenge_password: &'a [u8],
695-
rng: &mut R,
696-
) -> Self {
693+
pub fn new<R: CryptoRng + ?Sized>(challenge_password: &'a [u8], rng: &mut R) -> Self {
697694
let mut key_encryption_iv = [0u8; 16];
698695
rng.fill_bytes(key_encryption_iv.as_mut_slice());
699696
let key_encryption_iv = key_encryption_iv.into();
@@ -711,7 +708,7 @@ fn test_create_password_recipient_info() {
711708
}
712709
impl PwriEncryptor for Aes128CbcPwriEncryptor<'_> {
713710
const BLOCK_LENGTH_BITS: usize = 128; // AES block length
714-
fn encrypt_rfc3211<R: CryptoRng + RngCore + ?Sized>(
711+
fn encrypt_rfc3211<R: CryptoRng + ?Sized>(
715712
&mut self,
716713
padded_content_encryption_key: &[u8],
717714
_rng: &mut R,
@@ -921,7 +918,7 @@ fn test_create_password_recipient_info() {
921918
let enveloped_data = builder
922919
.add_recipient_info(recipient_info_builder)
923920
.expect("Could not add a recipient info")
924-
.build_with_rng(&mut the_one_and_only_rng.unwrap_mut())
921+
.build_with_rng(&mut the_one_and_only_rng)
925922
.expect("Building EnvelopedData failed");
926923
let enveloped_data_der = enveloped_data
927924
.to_der()

phc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ subtle = { version = "2", default-features = false }
2020

2121
# optional dependencies
2222
getrandom = { version = "0.4.0-rc.0", optional = true, default-features = false }
23-
rand_core = { version = "0.10.0-rc-3", optional = true, default-features = false }
23+
rand_core = { version = "0.10.0-rc-5", optional = true, default-features = false }
2424

2525
[features]
2626
default = ["rand_core"]

phc/src/salt.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core::{
88
str::{self, FromStr},
99
};
1010
#[cfg(feature = "rand_core")]
11-
use rand_core::{CryptoRng, RngCore, TryCryptoRng, TryRngCore};
11+
use rand_core::{CryptoRng, TryCryptoRng};
1212

1313
/// Error message used with `expect` for when internal invariants are violated
1414
/// (i.e. the contents of a [`Salt`] should always be valid)
@@ -117,14 +117,14 @@ impl Salt {
117117

118118
/// Generate a random [`Salt`] from the given [`CryptoRng`].
119119
#[cfg(feature = "rand_core")]
120-
pub fn from_rng<R: CryptoRng + RngCore + ?Sized>(rng: &mut R) -> Self {
120+
pub fn from_rng<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
121121
let Ok(out) = Self::try_from_rng(rng);
122122
out
123123
}
124124

125125
/// Generate a random [`Salt`] from the given [`TryCryptoRng`].
126126
#[cfg(feature = "rand_core")]
127-
pub fn try_from_rng<R: TryCryptoRng + TryRngCore + ?Sized>(
127+
pub fn try_from_rng<R: TryCryptoRng + ?Sized>(
128128
rng: &mut R,
129129
) -> core::result::Result<Self, R::Error> {
130130
let mut bytes = [0u8; Self::RECOMMENDED_LENGTH];
@@ -256,14 +256,14 @@ impl SaltString {
256256

257257
/// Generate a random B64-encoded [`SaltString`] from [`CryptoRng`].
258258
#[cfg(feature = "rand_core")]
259-
pub fn from_rng<R: CryptoRng + RngCore + ?Sized>(rng: &mut R) -> Self {
259+
pub fn from_rng<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
260260
let Ok(out) = Self::try_from_rng(rng);
261261
out
262262
}
263263

264264
/// Generate a random B64-encoded [`SaltString`] from [`TryCryptoRng`].
265265
#[cfg(feature = "rand_core")]
266-
pub fn try_from_rng<R: TryCryptoRng + TryRngCore + ?Sized>(
266+
pub fn try_from_rng<R: TryCryptoRng + ?Sized>(
267267
rng: &mut R,
268268
) -> core::result::Result<Self, R::Error> {
269269
Ok(Salt::try_from_rng(rng)?.to_salt_string())

pkcs5/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ aes = { version = "0.9.0-rc.2", optional = true, default-features = false }
2525
aes-gcm = { version = "0.11.0-rc.2", optional = true, default-features = false, features = ["aes"] }
2626
des = { version = "0.9.0-rc.2", optional = true, default-features = false }
2727
pbkdf2 = { version = "0.13.0-rc.6", optional = true, default-features = false, features = ["hmac"] }
28-
rand_core = { version = "0.10.0-rc-3", optional = true, default-features = false }
28+
rand_core = { version = "0.10.0-rc-5", optional = true, default-features = false }
2929
scrypt = { version = "0.12.0-rc.8", optional = true, default-features = false }
3030
sha1 = { version = "0.11.0-rc.3", optional = true, default-features = false }
3131
sha2 = { version = "0.11.0-rc.3", optional = true, default-features = false }

pkcs5/src/pbes2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use der::{
1919
};
2020

2121
#[cfg(feature = "rand_core")]
22-
use rand_core::{CryptoRng, RngCore};
22+
use rand_core::CryptoRng;
2323

2424
#[cfg(all(feature = "alloc", feature = "pbes2"))]
2525
use alloc::vec::Vec;
@@ -106,7 +106,7 @@ impl Parameters {
106106
/// This is currently an alias for [`Parameters::scrypt`]. See that method
107107
/// for more information.
108108
#[cfg(all(feature = "pbes2", feature = "rand_core"))]
109-
pub fn recommended<R: CryptoRng + RngCore + ?Sized>(rng: &mut R) -> Self {
109+
pub fn recommended<R: CryptoRng>(rng: &mut R) -> Self {
110110
Self::scrypt(rng)
111111
}
112112

@@ -118,7 +118,7 @@ impl Parameters {
118118
/// This will use AES-256-CBC as the encryption algorithm and SHA-256 as
119119
/// the hash function for PBKDF2.
120120
#[cfg(feature = "rand_core")]
121-
pub fn pbkdf2<R: CryptoRng + RngCore + ?Sized>(rng: &mut R) -> Self {
121+
pub fn pbkdf2<R: CryptoRng>(rng: &mut R) -> Self {
122122
let mut iv = [0u8; Self::DEFAULT_IV_LEN];
123123
rng.fill_bytes(&mut iv);
124124

@@ -169,7 +169,7 @@ impl Parameters {
169169
///
170170
/// [RustCrypto/formats#1205]: https://github.com/RustCrypto/formats/issues/1205
171171
#[cfg(all(feature = "pbes2", feature = "rand_core"))]
172-
pub fn scrypt<R: CryptoRng + RngCore + ?Sized>(rng: &mut R) -> Self {
172+
pub fn scrypt<R: CryptoRng>(rng: &mut R) -> Self {
173173
let mut iv = [0u8; Self::DEFAULT_IV_LEN];
174174
rng.fill_bytes(&mut iv);
175175

0 commit comments

Comments
 (0)