Skip to content

Commit 870fec5

Browse files
authored
Bump getrandom to v0.4.0-rc.0 (#2146)
This notably includes the new `sys_rng` feature / `SysRng` type, which is the replacement for `OsRng`, and allows us to delete the vendored version thereof from `crypto-common`.
1 parent 9e87901 commit 870fec5

6 files changed

Lines changed: 22 additions & 41 deletions

File tree

Cargo.lock

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

crypto-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description = "Common cryptographic traits"
1616
hybrid-array = "0.4"
1717

1818
# optional dependencies
19-
getrandom = { version = "0.3", optional = true }
19+
getrandom = { version = "0.4.0-rc.0", optional = true, features = ["sys_rng"] }
2020
rand_core = { version = "0.10.0-rc-3", optional = true }
2121

2222
[features]

crypto-common/src/generate.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Generate: Sized {
2222
/// Returns [`RngError`] in the event the system's ambient RNG experiences an internal failure.
2323
#[cfg(feature = "getrandom")]
2424
fn try_generate() -> Result<Self, RngError> {
25-
Self::try_generate_from_rng(&mut sys_rng::SysRng)
25+
Self::try_generate_from_rng(&mut getrandom::SysRng)
2626
}
2727

2828
/// Randomly generate a value of this type using the system's ambient cryptographically secure
@@ -84,35 +84,3 @@ impl<U: ArraySize> Generate for Array<u64, U> {
8484
Self::try_from_fn(|_| rng.try_next_u64())
8585
}
8686
}
87-
88-
#[cfg(feature = "getrandom")]
89-
pub(crate) mod sys_rng {
90-
use getrandom::Error;
91-
use rand_core::{TryCryptoRng, TryRngCore};
92-
93-
/// A [`TryRngCore`] interface over the system's preferred random number source
94-
// TODO(tarcieri): replace this with `getrandom::SysRng` when `sys_rng` feature is available
95-
#[derive(Clone, Copy, Debug, Default)]
96-
pub struct SysRng;
97-
98-
impl TryRngCore for SysRng {
99-
type Error = Error;
100-
101-
#[inline]
102-
fn try_next_u32(&mut self) -> Result<u32, Error> {
103-
getrandom::u32()
104-
}
105-
106-
#[inline]
107-
fn try_next_u64(&mut self) -> Result<u64, Error> {
108-
getrandom::u64()
109-
}
110-
111-
#[inline]
112-
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
113-
getrandom::fill(dest)
114-
}
115-
}
116-
117-
impl TryCryptoRng for SysRng {}
118-
}

crypto-common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub use hybrid_array::typenum;
2222
#[cfg(feature = "rand_core")]
2323
pub use {generate::Generate, rand_core};
2424
#[cfg(feature = "getrandom")]
25-
pub use {generate::sys_rng::SysRng, getrandom::Error as RngError};
25+
pub use {getrandom::Error as RngError, getrandom::SysRng};
2626

2727
use core::fmt;
2828
use hybrid_array::{

elliptic-curve/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ zeroize = { version = "1.7", default-features = false }
2727
# optional dependencies
2828
digest = { version = "0.11.0-rc.4", optional = true }
2929
ff = { version = "=0.14.0-pre.0", package = "rustcrypto-ff", optional = true, default-features = false }
30-
getrandom = { version = "0.3", optional = true }
30+
getrandom = { version = "0.4.0-rc.0", optional = true }
3131
group = { version = "=0.14.0-pre.0", package = "rustcrypto-group", optional = true, default-features = false }
3232
hkdf = { version = "0.13.0-rc.3", optional = true, default-features = false }
3333
hex-literal = { version = "1", optional = true }

password-hash/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ as well as a `no_std`-friendly implementation of the PHC string format
1717
"""
1818

1919
[dependencies]
20-
getrandom = { version = "0.3", optional = true, default-features = false }
20+
getrandom = { version = "0.4.0-rc.0", optional = true, default-features = false }
2121
phc = { version = "0.6.0-rc.0", optional = true, default-features = false }
2222
rand_core = { version = "0.10.0-rc-3", optional = true, default-features = false }
2323

0 commit comments

Comments
 (0)