Trait CryptoRng

Source
pub trait CryptoRng: RngCore { }
Expand description

A marker trait over RngCore for securely unpredictable RNGs

This marker trait indicates that the implementing generator is intended, when correctly seeded and protected from side-channel attacks such as a leaking of state, to be a cryptographically secure generator. This trait is provided as a tool to aid review of cryptographic code, but does not by itself guarantee suitability for cryptographic applications.

Implementors of CryptoRng automatically implement the TryCryptoRng trait.

Implementors of CryptoRng should only implement Default if the default() instances are themselves secure generators: for example if the implementing type is a stateless interface over a secure external generator (like OsRng) or if the default() instance uses a strong, fresh seed.

Formally, a CSPRNG (Cryptographically Secure Pseudo-Random Number Generator) should satisfy an additional property over other generators: assuming that the generator has been appropriately seeded and has unknown state, then given the first k bits of an algorithm’s output sequence, it should not be possible using polynomial-time algorithms to predict the next bit with probability significantly greater than 50%.

An optional property of CSPRNGs is backtracking resistance: if the CSPRNG’s state is revealed, it will not be computationally-feasible to reconstruct prior output values. This property is not required by CryptoRng.

Implementations on Foreign Types§

Source§

impl CryptoRng for ChaCha8Rng

Source§

impl CryptoRng for ChaCha12Rng

Source§

impl CryptoRng for ChaCha20Rng

Implementors§

Source§

impl CryptoRng for StdRng

Source§

impl CryptoRng for ThreadRng

Source§

impl<R> CryptoRng for BlockRng64<R>
where R: CryptoBlockRng<Item = u64> + BlockRngCore,

Source§

impl<R> CryptoRng for BlockRng<R>
where R: CryptoBlockRng<Item = u32> + BlockRngCore,

Source§

impl<R> CryptoRng for UnwrapErr<R>
where R: TryCryptoRng,

Source§

impl<R> CryptoRng for UnwrapMut<'_, R>
where R: TryCryptoRng + ?Sized,

Source§

impl<R, Rsdr> CryptoRng for ReseedingRng<R, Rsdr>

Source§

impl<T> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,