diff options
| author | Steven Fackler <[email protected]> | 2016-10-17 09:14:33 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-10-17 09:14:33 -0700 |
| commit | f6bf022cf214869fc5a4be80617759fe7ee89d8f (patch) | |
| tree | 0a13df9c28a0a967ba7477979c2c0883aa6ef456 /openssl/src/crypto/rand.rs | |
| parent | Merge pull request #475 from sfackler/no-enums (diff) | |
| parent | Fix missing import (diff) | |
| download | rust-openssl-f6bf022cf214869fc5a4be80617759fe7ee89d8f.tar.xz rust-openssl-f6bf022cf214869fc5a4be80617759fe7ee89d8f.zip | |
Merge pull request #476 from sfackler/error-handling
Overhaul error handling plus random APIs
Diffstat (limited to 'openssl/src/crypto/rand.rs')
| -rw-r--r-- | openssl/src/crypto/rand.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/openssl/src/crypto/rand.rs b/openssl/src/crypto/rand.rs index 519449e9..c1c49e7b 100644 --- a/openssl/src/crypto/rand.rs +++ b/openssl/src/crypto/rand.rs @@ -1,13 +1,14 @@ use libc::c_int; use ffi; + +use cvt; use error::ErrorStack; pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> { unsafe { ffi::init(); assert!(buf.len() <= c_int::max_value() as usize); - try_ssl_if!(ffi::RAND_bytes(buf.as_mut_ptr(), buf.len() as c_int) != 1); - Ok(()) + cvt(ffi::RAND_bytes(buf.as_mut_ptr(), buf.len() as c_int)).map(|_| ()) } } |