Skip to content

Commit 64b7d93

Browse files
authored
pkcs5,pkcs8: bump rand_core from 0.6.4 to 0.9.0 (#1658)
1 parent c2bbe33 commit 64b7d93

File tree

7 files changed

+64
-35
lines changed

7 files changed

+64
-35
lines changed

Cargo.lock

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

pkcs5/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ aes = { version = "=0.9.0-pre.2", optional = true, default-features = false }
2525
aes-gcm = { version = "=0.11.0-pre.2", optional = true, default-features = false, features = ["aes"] }
2626
des = { version = "=0.9.0-pre.2", optional = true, default-features = false }
2727
pbkdf2 = { version = "=0.13.0-pre.1", optional = true, default-features = false, features = ["hmac"] }
28-
rand_core = { version = "0.6.4", optional = true, default-features = false }
28+
rand_core = { version = "0.9.0", optional = true, default-features = false }
2929
scrypt = { version = "=0.12.0-pre.2", optional = true, default-features = false }
3030
sha1 = { version = "=0.11.0-pre.4", optional = true, default-features = false }
3131
sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false }
@@ -39,7 +39,7 @@ std = []
3939

4040
3des = ["dep:des", "pbes2"]
4141
des-insecure = ["dep:des", "pbes2"]
42-
getrandom = ["rand_core/getrandom"]
42+
getrandom = ["rand_core/os_rng"]
4343
pbes2 = ["dep:aes", "dep:cbc", "dep:pbkdf2", "dep:scrypt", "dep:sha2", "dep:aes-gcm"]
4444
sha1-insecure = ["dep:sha1", "pbes2"]
4545

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::CryptoRngCore;
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(rng: &mut impl CryptoRngCore) -> 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(rng: &mut impl CryptoRngCore) -> 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(rng: &mut impl CryptoRngCore) -> 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

pkcs8/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ der = { version = "0.8.0-rc.0", features = ["oid"] }
2121
spki = { version = "0.8.0-rc.0" }
2222

2323
# optional dependencies
24-
rand_core = { version = "0.6", optional = true, default-features = false }
24+
rand_core = { version = "0.9.0", optional = true, default-features = false }
2525
pkcs5 = { version = "0.8.0-rc.0", optional = true, features = ["rand_core"] }
2626
subtle = { version = "2", optional = true, default-features = false }
2727

@@ -36,7 +36,7 @@ std = ["alloc", "der/std", "spki/std"]
3636
3des = ["encryption", "pkcs5/3des"]
3737
des-insecure = ["encryption", "pkcs5/des-insecure"]
3838
encryption = ["alloc", "pkcs5/alloc", "pkcs5/pbes2", "rand_core"]
39-
getrandom = ["rand_core/getrandom"]
39+
getrandom = ["rand_core/os_rng"]
4040
pem = ["alloc", "der/pem", "spki/pem"]
4141
sha1-insecure = ["encryption", "pkcs5/sha1-insecure"]
4242

pkcs8/src/encrypted_private_key_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use pkcs5::EncryptionScheme;
1212
use der::{asn1::OctetString, SecretDocument};
1313

1414
#[cfg(feature = "encryption")]
15-
use {pkcs5::pbes2, rand_core::CryptoRngCore};
15+
use {pkcs5::pbes2, rand_core::CryptoRng};
1616

1717
#[cfg(feature = "pem")]
1818
use der::pem::PemLabel;
@@ -64,8 +64,8 @@ where
6464
/// Encrypt the given ASN.1 DER document using a symmetric encryption key
6565
/// derived from the provided password.
6666
#[cfg(feature = "encryption")]
67-
pub(crate) fn encrypt(
68-
rng: &mut impl CryptoRngCore,
67+
pub(crate) fn encrypt<R: CryptoRng>(
68+
rng: &mut R,
6969
password: impl AsRef<[u8]>,
7070
doc: &[u8],
7171
) -> Result<SecretDocument> {

pkcs8/src/private_key_info.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ use der::{
1717

1818
#[cfg(feature = "encryption")]
1919
use {
20-
crate::EncryptedPrivateKeyInfoRef, der::zeroize::Zeroizing, pkcs5::pbes2,
21-
rand_core::CryptoRngCore,
20+
crate::EncryptedPrivateKeyInfoRef, der::zeroize::Zeroizing, pkcs5::pbes2, rand_core::CryptoRng,
2221
};
2322

2423
#[cfg(feature = "pem")]
@@ -146,9 +145,9 @@ where
146145
/// - p: 1
147146
/// - Cipher: AES-256-CBC (best available option for PKCS#5 encryption)
148147
#[cfg(feature = "encryption")]
149-
pub fn encrypt(
148+
pub fn encrypt<R: CryptoRng>(
150149
&self,
151-
rng: &mut impl CryptoRngCore,
150+
rng: &mut R,
152151
password: impl AsRef<[u8]>,
153152
) -> Result<SecretDocument> {
154153
let der = Zeroizing::new(self.to_der()?);

pkcs8/src/traits.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{Error, PrivateKeyInfoRef, Result};
66
use der::SecretDocument;
77

88
#[cfg(feature = "encryption")]
9-
use {crate::EncryptedPrivateKeyInfoRef, rand_core::CryptoRngCore};
9+
use {crate::EncryptedPrivateKeyInfoRef, rand_core::CryptoRng};
1010

1111
#[cfg(feature = "pem")]
1212
use {
@@ -101,9 +101,9 @@ pub trait EncodePrivateKey {
101101
/// Create an [`SecretDocument`] containing the ciphertext of
102102
/// a PKCS#8 encoded private key encrypted under the given `password`.
103103
#[cfg(feature = "encryption")]
104-
fn to_pkcs8_encrypted_der(
104+
fn to_pkcs8_encrypted_der<R: CryptoRng>(
105105
&self,
106-
rng: &mut impl CryptoRngCore,
106+
rng: &mut R,
107107
password: impl AsRef<[u8]>,
108108
) -> Result<SecretDocument> {
109109
EncryptedPrivateKeyInfoRef::encrypt(rng, password, self.to_pkcs8_der()?.as_bytes())
@@ -119,9 +119,9 @@ pub trait EncodePrivateKey {
119119
/// Serialize this private key as an encrypted PEM-encoded PKCS#8 private
120120
/// key using the `provided` to derive an encryption key.
121121
#[cfg(all(feature = "encryption", feature = "pem"))]
122-
fn to_pkcs8_encrypted_pem(
122+
fn to_pkcs8_encrypted_pem<R: CryptoRng>(
123123
&self,
124-
rng: &mut impl CryptoRngCore,
124+
rng: &mut R,
125125
password: impl AsRef<[u8]>,
126126
line_ending: LineEnding,
127127
) -> Result<Zeroizing<String>> {

0 commit comments

Comments
 (0)