rustls 0.5.5

Rustls is a modern TLS library written in Rust.
Documentation

/// The single place where we generate random material
/// for our own use.  These functions never fail,
/// they panic on error.

use ring;
use msgs::codec;

/// Fill the whole slice with random material.
pub fn fill_random(bytes: &mut [u8]) {
    ring::rand::SystemRandom::new()
        .fill(bytes)
        .unwrap();
}

pub fn random_u32() -> u32 {
    let mut buf = [0u8; 4];
    fill_random(&mut buf);
    codec::decode_u32(&buf)
        .unwrap()
}