Skip to main content

RNG

Trait RNG 

Source
pub trait RNG: Default {
    // Required methods
    fn add_seed_keymaterial(
        &mut self,
        additional_seed: impl KeyMaterial,
    ) -> Result<(), RNGError>;
    fn next_int(&mut self) -> Result<u32, RNGError>;
    fn next_bytes(&mut self, len: usize) -> Result<Vec<u8>, RNGError>;
    fn next_bytes_out(&mut self, out: &mut [u8]) -> Result<usize, RNGError>;
    fn fill_keymaterial_out(
        &mut self,
        out: &mut impl KeyMaterial,
    ) -> Result<usize, RNGError>;
    fn security_strength(&self) -> SecurityStrength;
}
Expand description

An interface for random number generation. This interface is meant to be simpler and more ergonomic than the interfaces provided by the rng crate, but that one should be used by applications that intend to submit to FIPS certification as it more closely aligns with the requirements of SP 800-90A. Note: this interface produces bytes. If you want a KeyMaterial, then use KeyMaterialInternal::from_rng.

Required Methods§

Source

fn add_seed_keymaterial( &mut self, additional_seed: impl KeyMaterial, ) -> Result<(), RNGError>

Source

fn next_int(&mut self) -> Result<u32, RNGError>

Source

fn next_bytes(&mut self, len: usize) -> Result<Vec<u8>, RNGError>

Returns the number of requested bytes.

Source

fn next_bytes_out(&mut self, out: &mut [u8]) -> Result<usize, RNGError>

Returns the number of bytes written.

Source

fn fill_keymaterial_out( &mut self, out: &mut impl KeyMaterial, ) -> Result<usize, RNGError>

Source

fn security_strength(&self) -> SecurityStrength

Returns the Security Strength of this RNG.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§