Commit 220c707f authored by johnthagen's avatar johnthagen
Browse files

Document rand module

parent 2c58c39e
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
//! Cryptographically strong random bytes.
//!
//! This module exposes functionality to put cryptographically strong
//! pseudo-random bytes into a buffer.
//!
//! # Examples
//!
//! To generate a buffer with cryptographically strong bytes:
//!
//! ```
//! let muf buf = [0; 256]
//! rand_bytes(&mut buf).unwrap();
//! ```
//!
//! # External OpenSSL Documentation
//!
//! [RAND_bytes](https://www.openssl.org/docs/man1.1.0/crypto/RAND_bytes.html)
use libc::c_int;
use ffi;

use cvt;
use error::ErrorStack;

/// Fills buffer with cryptographically strong pseudo-random bytes.
pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> {
    unsafe {
        ffi::init();