Skip to content

Commit

Permalink
bump rand_core from 0.6.4 to 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Feb 14, 2025
1 parent 9e7faa4 commit 79160ae
Show file tree
Hide file tree
Showing 22 changed files with 283 additions and 162 deletions.
116 changes: 86 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ readme = "README.md"
rust-version = "1.83"

[dependencies]
rand_core = { version = "0.6.4", default-features = false }
rand_core = { version = "0.9.0", default-features = false }
const-oid = { version = "0.10.0-rc.3", default-features = false }
subtle = { version = "2.6.1", default-features = false }
digest = { version = "=0.11.0-pre.9", default-features = false, features = ["alloc", "oid"] }
pkcs1 = { version = "0.8.0-rc.1", default-features = false, features = ["alloc", "pkcs8"] }
pkcs8 = { version = "0.11.0-rc.1", default-features = false, features = ["alloc"] }
signature = { version = "=2.3.0-pre.4", default-features = false, features = ["alloc", "digest", "rand_core"] }
signature = { version = "=2.3.0-pre.5", default-features = false, features = ["alloc", "digest", "rand_core"] }
spki = { version = "0.8.0-rc.1", default-features = false, features = ["alloc"] }
zeroize = { version = "1.5", features = ["alloc"] }
crypto-bigint = { version = "0.6.0", default-features = false, features = ["zeroize", "alloc"] }
crypto-bigint = { version = "0.7.0-pre", default-features = false, features = ["zeroize", "alloc"] }
crypto-primes = { version = "0.6.0", default-features = false }

# optional dependencies
Expand All @@ -37,10 +37,10 @@ base64ct = { version = "1", features = ["alloc"] }
hex-literal = "0.4.1"
proptest = "1"
serde_test = "1.0.89"
rand_xorshift = "0.3"
rand_chacha = "0.3"
rand = "0.8"
rand_core = { version = "0.6", default-features = false }
rand_xorshift = "0.4"
rand_chacha = "0.9"
rand = "0.9"
rand_core = { version = "0.9.0", default-features = false }
sha1 = { version = "=0.11.0-pre.4", default-features = false, features = ["oid"] }
sha2 = { version = "=0.11.0-pre.4", default-features = false, features = ["oid"] }
sha3 = { version = "=0.11.0-pre.4", default-features = false, features = ["oid"] }
Expand All @@ -54,7 +54,7 @@ name = "key"
[features]
default = ["std", "pem"]
hazmat = []
getrandom = ["rand_core/getrandom", "crypto-bigint/rand_core"]
getrandom = ["rand_core/os_rng", "crypto-bigint/rand_core"]
serde = ["dep:serde", "dep:serdect", "crypto-bigint/serde"]
pem = ["pkcs1/pem", "pkcs8/pem"]
pkcs5 = ["pkcs8/encryption"]
Expand All @@ -70,3 +70,15 @@ opt-level = 2

[profile.bench]
debug = true

[patch.crates-io]
# https://github.com/RustCrypto/crypto-bigint/pull/762
# https://github.com/RustCrypto/crypto-bigint/pull/765
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" }

# https://github.com/entropyxyz/crypto-primes/pull/74
crypto-primes = { git = "https://github.com/baloo/crypto-primes.git", branch = "baloo/rand_core-0.9" }

# https://github.com/RustCrypto/formats/pull/1658
pkcs5 = { git = "https://github.com/baloo/formats.git", branch = "baloo/pkcs/rand-core-0.9" }
pkcs8 = { git = "https://github.com/baloo/formats.git", branch = "baloo/pkcs/rand-core-0.9" }
6 changes: 3 additions & 3 deletions src/algorithms/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crypto_primes::{
hazmat::{SetBits, SmallPrimesSieveFactory},
is_prime_with_rng, sieve_and_find,
};
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;

use crate::{
algorithms::rsa::{compute_modulus, compute_private_exponent_euler_totient},
Expand All @@ -31,7 +31,7 @@ pub struct RsaPrivateKeyComponents {
///
/// [1]: https://patents.google.com/patent/US4405829A/en
/// [2]: http://www.cacr.math.uwaterloo.ca/techreports/2006/cacr2006-16.pdf
pub(crate) fn generate_multi_prime_key_with_exp<R: CryptoRngCore>(
pub(crate) fn generate_multi_prime_key_with_exp<R: CryptoRng>(
rng: &mut R,
nprimes: usize,
bit_size: usize,
Expand Down Expand Up @@ -120,7 +120,7 @@ pub(crate) fn generate_multi_prime_key_with_exp<R: CryptoRngCore>(
})
}

fn generate_prime_with_rng<R: CryptoRngCore>(rng: &mut R, bit_length: u32) -> BoxedUint {
fn generate_prime_with_rng<R: CryptoRng>(rng: &mut R, bit_length: u32) -> BoxedUint {
sieve_and_find(
rng,
SmallPrimesSieveFactory::new(bit_length, SetBits::TwoMsb),
Expand Down
8 changes: 4 additions & 4 deletions src/algorithms/oaep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::boxed::Box;
use alloc::vec::Vec;

use digest::{Digest, DynDigest, FixedOutputReset};
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
use zeroize::Zeroizing;

Expand All @@ -19,7 +19,7 @@ use crate::errors::{Error, Result};
const MAX_LABEL_LEN: u64 = 1 << 61;

#[inline]
fn encrypt_internal<R: CryptoRngCore + ?Sized, MGF: FnMut(&mut [u8], &mut [u8])>(
fn encrypt_internal<R: CryptoRng + ?Sized, MGF: FnMut(&mut [u8], &mut [u8])>(
rng: &mut R,
msg: &[u8],
p_hash: &[u8],
Expand Down Expand Up @@ -57,7 +57,7 @@ fn encrypt_internal<R: CryptoRngCore + ?Sized, MGF: FnMut(&mut [u8], &mut [u8])>
///
/// [PKCS#1 OAEP]: https://datatracker.ietf.org/doc/html/rfc8017#section-7.1
#[inline]
pub(crate) fn oaep_encrypt<R: CryptoRngCore + ?Sized>(
pub(crate) fn oaep_encrypt<R: CryptoRng + ?Sized>(
rng: &mut R,
msg: &[u8],
digest: &mut dyn DynDigest,
Expand Down Expand Up @@ -90,7 +90,7 @@ pub(crate) fn oaep_encrypt<R: CryptoRngCore + ?Sized>(
/// [PKCS#1 OAEP]: https://datatracker.ietf.org/doc/html/rfc8017#section-7.1
#[inline]
pub(crate) fn oaep_encrypt_digest<
R: CryptoRngCore + ?Sized,
R: CryptoRng + ?Sized,
D: Digest,
MGD: Digest + FixedOutputReset,
>(
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/pkcs1v15.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use alloc::vec::Vec;
use digest::Digest;
use pkcs8::AssociatedOid;
use rand_core::CryptoRngCore;
use rand_core::CryptoRng;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
use zeroize::Zeroizing;

Expand All @@ -18,7 +18,7 @@ use crate::errors::{Error, Result};
/// Fills the provided slice with random values, which are guaranteed
/// to not be zero.
#[inline]
fn non_zero_random_bytes<R: CryptoRngCore + ?Sized>(rng: &mut R, data: &mut [u8]) {
fn non_zero_random_bytes<R: CryptoRng + ?Sized>(rng: &mut R, data: &mut [u8]) {
rng.fill_bytes(data);

for el in data {
Expand All @@ -39,7 +39,7 @@ pub(crate) fn pkcs1v15_encrypt_pad<R>(
k: usize,
) -> Result<Zeroizing<Vec<u8>>>
where
R: CryptoRngCore + ?Sized,
R: CryptoRng + ?Sized,
{
if msg.len() + 11 > k {
return Err(Error::MessageTooLong);
Expand Down
Loading

0 comments on commit 79160ae

Please sign in to comment.