Struct linux_kcapi::Rng[][src]

pub struct Rng { /* fields omitted */ }

Random Generator.

If the rand_trait feature is enabled, it implements the rand_core::RngCore and rand_core::CryptoRng traits.

Sample usage

use linux_kcapi::{RngType, Rng};

let rng = Rng::new(RngType::DrbgPrHmacSha256, &seed)?;
rng.get_bytes(&mut data)?;
assert_ne!(zero, data);
rng.get_bytes(&mut data2)?;
assert_ne!(data, data2);

Implementations

impl Rng[src]

pub fn new<T>(rng: RngType, seed: &T) -> Result<Self, Error> where
    T: AsRef<[u8]> + Clone
[src]

Create a new random generator.

Errors

#[must_use]pub fn name(&self) -> RngType[src]

Get Rng type

pub fn get_bytes(&self, dest: &mut [u8]) -> Result<(), Error>[src]

fill destination with random bytes

Errors

Trait Implementations

impl CryptoRng for Rng[src]

Only available with "rand_trait" feature

impl RngCore for Rng[src]

Only available with "rand_trait" feature

Panic

next_u32, next_u64 and fill_bytes will panic in case of error

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.