Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CryptoRng for EntropyRng and StdRng #323

Merged
merged 2 commits into from
Mar 22, 2018
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
4 changes: 3 additions & 1 deletion src/entropy_rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Entropy generator, or wrapper around external generators

use rand_core::{RngCore, Error, impls};
use rand_core::{RngCore, CryptoRng, Error, impls};
use {OsRng, JitterRng};

/// An RNG provided specifically for seeding PRNGs.
Expand Down Expand Up @@ -140,6 +140,8 @@ impl RngCore for EntropyRng {
}
}

impl CryptoRng for EntropyRng {}

#[cfg(test)]
mod test {
use super::*;
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ extern crate rand_core;
use core::{marker, mem, slice};

// re-exports from rand-core
pub use rand_core::{RngCore, CryptoRng, SeedableRng};
pub use rand_core::{RngCore, BlockRngCore, CryptoRng, SeedableRng};
pub use rand_core::{ErrorKind, Error};

// external rngs
Expand Down Expand Up @@ -865,6 +865,8 @@ impl SeedableRng for StdRng {
}
}

impl CryptoRng for StdRng {}

/// An RNG recommended when small state, cheap initialization and good
/// performance are required. The PRNG algorithm in `SmallRng` is chosen to be
/// efficient on the current platform, **without consideration for cryptography
Expand Down