Skip to main content

RandomSource

Trait RandomSource 

Source
pub trait RandomSource {
    // Required method
    fn fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), RandomError>;
}
Expand description

A source of cryptographically secure random bytes.

Implementations must fill the entire buffer with unpredictable bytes or return RandomError. Returning Ok(()) after a partial or zeroed fill is a security defect.

Required Methods§

Source

fn fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), RandomError>

Fill dest entirely with secure random bytes, or fail.

§Errors

Returns RandomError if secure randomness cannot be obtained. Callers must propagate the error and must not substitute any default value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§