aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorjohnthagen <[email protected]>2017-09-28 10:36:53 -0400
committerjohnthagen <[email protected]>2017-09-28 10:36:53 -0400
commitc4b044b6ba18f8703adcec3e2ee5a5155f75e979 (patch)
tree22c2f36820de00322f88306a4a31f1e1359bd8da /openssl/src
parentFix typos (diff)
downloadrust-openssl-c4b044b6ba18f8703adcec3e2ee5a5155f75e979.tar.xz
rust-openssl-c4b044b6ba18f8703adcec3e2ee5a5155f75e979.zip
Fix doc test and move external documentation link to rand_bytes function
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/rand.rs28
1 files changed, 19 insertions, 9 deletions
diff --git a/openssl/src/rand.rs b/openssl/src/rand.rs
index cd700ff1..da52ef5f 100644
--- a/openssl/src/rand.rs
+++ b/openssl/src/rand.rs
@@ -1,20 +1,15 @@
-//! Cryptographically strong random bytes.
-//!
-//! This module exposes functionality to put cryptographically strong
-//! pseudo-random bytes into a buffer.
+//! Utilities for secure random number generation.
//!
//! # Examples
//!
//! To generate a buffer with cryptographically strong bytes:
//!
//! ```
-//! let muf buf = [0; 256];
+//! use openssl::rand::rand_bytes;
+//!
+//! let mut 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;
@@ -22,6 +17,21 @@ use cvt;
use error::ErrorStack;
/// Fill buffer with cryptographically strong pseudo-random bytes.
+///
+/// # Examples
+///
+/// To generate a buffer with cryptographically strong bytes:
+///
+/// ```
+/// use openssl::rand::rand_bytes;
+///
+/// let mut 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)
pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> {
unsafe {
ffi::init();