Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions crypto-common/src/generate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use hybrid_array::{Array, ArraySize};
use rand_core::{CryptoRng, TryCryptoRng};

#[cfg(feature = "getrandom")]
use crate::RngError;

/// Secure random generation.
pub trait Generate: Sized {
/// Generate random key using the provided [`TryCryptoRng`].
Expand All @@ -19,9 +16,10 @@ pub trait Generate: Sized {
/// random number generator.
///
/// # Errors
/// Returns [`RngError`] in the event the system's ambient RNG experiences an internal failure.
/// Returns [`getrandom::Error`] in the event the system's ambient RNG experiences an internal
/// failure.
#[cfg(feature = "getrandom")]
fn try_generate() -> Result<Self, RngError> {
fn try_generate() -> Result<Self, getrandom::Error> {
Self::try_generate_from_rng(&mut getrandom::SysRng)
}

Expand Down
4 changes: 2 additions & 2 deletions crypto-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ mod generate;
pub use hybrid_array as array;
pub use hybrid_array::typenum;

#[cfg(feature = "getrandom")]
pub use getrandom;
#[cfg(feature = "rand_core")]
pub use {generate::Generate, rand_core};
#[cfg(feature = "getrandom")]
pub use {getrandom::Error as RngError, getrandom::SysRng};

use core::fmt;
use hybrid_array::{
Expand Down
2 changes: 1 addition & 1 deletion kem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait Encapsulate<EK, SS> {
/// Encapsulate a fresh shared secret generated using the system's secure RNG.
#[cfg(feature = "getrandom")]
fn encapsulate(&self) -> Result<(EK, SS), Self::Error> {
self.encapsulate_with_rng(&mut crypto_common::SysRng)
self.encapsulate_with_rng(&mut crypto_common::getrandom::SysRng)
}
}

Expand Down