Struct botan::RandomNumberGenerator[][src]

pub struct RandomNumberGenerator { /* fields omitted */ }

A cryptographic random number generator

Implementations

impl RandomNumberGenerator[src]

pub fn new_userspace() -> Result<RandomNumberGenerator>[src]

Create a new userspace RNG object

Examples

let userspace_rng = botan::RandomNumberGenerator::new_userspace().unwrap();

pub fn new_system() -> Result<RandomNumberGenerator>[src]

Create a new reference to the system PRNG

Examples

let system_rng = botan::RandomNumberGenerator::new_system().unwrap();

pub fn new() -> Result<RandomNumberGenerator>[src]

Create a new reference to an RNG of some arbitrary type

Examples

let a_rng = botan::RandomNumberGenerator::new().unwrap();

pub fn read(&self, len: usize) -> Result<Vec<u8>>[src]

Read bytes from an RNG

Examples

let rng = botan::RandomNumberGenerator::new().unwrap();
let output = rng.read(32).unwrap();
assert_eq!(output.len(), 32);

pub fn fill(&self, out: &mut [u8]) -> Result<()>[src]

Store bytes from the RNG into the passed slice

Examples

let rng = botan::RandomNumberGenerator::new().unwrap();
let mut output = vec![0; 32];
rng.fill(&mut output).unwrap();

pub fn reseed(&self, bits: usize) -> Result<()>[src]

Attempt to reseed the RNG by unspecified means

Examples

let rng = botan::RandomNumberGenerator::new().unwrap();
rng.reseed(256).unwrap();

pub fn reseed_from_rng(
    &self,
    source: &RandomNumberGenerator,
    bits: usize
) -> Result<()>
[src]

Attempt to reseed the RNG by getting data from source RNG

Examples

let system_rng = botan::RandomNumberGenerator::new_system().unwrap();
let rng = botan::RandomNumberGenerator::new_userspace().unwrap();
rng.reseed_from_rng(&system_rng, 256).unwrap();

pub fn add_entropy(&self, seed: &[u8]) -> Result<()>[src]

Add some seed material to the RNG

Examples

let rng = botan::RandomNumberGenerator::new_userspace().unwrap();
let my_seed = vec![0x42, 0x6F, 0x62];
rng.add_entropy(&my_seed);

Trait Implementations

impl Debug for RandomNumberGenerator[src]

impl Drop for RandomNumberGenerator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.