Skip to main content

RTCRandom

Trait RTCRandom 

Source
pub trait RTCRandom: Send + Sync {
    // Required method
    fn fill(&self, output: &mut [u8]) -> Result<(), CryptoError>;

    // Provided method
    fn fill_secret(&self, output: &mut [u8]) -> Result<(), CryptoError> { ... }
}
Expand description

A cryptographically secure random byte generator.

Required Methods§

Source

fn fill(&self, output: &mut [u8]) -> Result<(), CryptoError>

Fills all of output with random bytes.

Provided Methods§

Source

fn fill_secret(&self, output: &mut [u8]) -> Result<(), CryptoError>

Fills all of output with random bytes that become a secret key (a cookie secret, a ticket key), from a source that keeps no copy of them.

A generator that buffers its output (as the built-in providers’ fill does, for speed) keeps the bytes it handed out in its buffer until it makes the next block: whatever key was drawn from it stays in memory after the key itself is erased. The default calls fill; the built-in providers draw from the operating system, which writes into output only.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§