embassy-crypto-driver

Crates

git

Versions

default

Flavors

Skip to main content

Rng

Trait Rng 

Source
pub trait Rng {
    // Required method
    fn rng_fill(&mut self, buf: &mut [u8]) -> Result<(), CryptoError>;
}
Expand description

Caller-provided entropy source for crypto operations that need fresh randomness (ECDSA nonces, ephemeral key generation).

Object-safe so it can be passed as &mut dyn Rng into driver traits. Production implementations wrap a hardware TRNG or a CSPRNG seeded from one. Test code may inject a deterministic implementation (seeded DRBG or fixed bytes) to get reproducible outputs for known-answer tests.

Required Methods§

Source

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

Fill buf with cryptographically secure random bytes.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§