Skip to main content

KeyGenerator

Trait KeyGenerator 

Source
pub trait KeyGenerator {
    // Required method
    fn fill_bytes(&mut self, out: &mut [u8]) -> Result<(), Error>;

    // Provided methods
    fn key_32(&mut self) -> Result<[u8; 32], Error> { ... }
    fn nonce_12(&mut self) -> Result<[u8; 12], Error> { ... }
}
Expand description

Common key-generation contract for benchmarked CSPRNG backends.

Required Methods§

Source

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

Fills out with CSPRNG output.

§Errors

Returns entropy, hardware, or fork-detection failures.

Provided Methods§

Source

fn key_32(&mut self) -> Result<[u8; 32], Error>

Generates a 32-byte AES-256 key.

§Errors

Returns the same errors as Self::fill_bytes.

Source

fn nonce_12(&mut self) -> Result<[u8; 12], Error>

Generates a 12-byte AES-GCM nonce.

§Errors

Returns the same errors as Self::fill_bytes.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§