Skip to main content

TryCryptoRng

Trait TryCryptoRng 

Source
pub trait TryCryptoRng: TryRng { }
Expand description

A marker trait over TryRng 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.

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.

Implementors of TryCryptoRng should only implement Default if a default-constructed instance is itself a secure generator, for example getrandom::SysRng which is a stateless interface.

Implementors§