aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/crypto/rand.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-10-16 19:06:02 -0700
committerSteven Fackler <[email protected]>2016-10-16 19:06:02 -0700
commit19440c298143aa311578ead17c8949312f4b94af (patch)
tree7d4eba1b3e7f56de19590267b6ee2881992d588d /openssl/src/crypto/rand.rs
parentContinue error handling cleanup (diff)
downloadrust-openssl-19440c298143aa311578ead17c8949312f4b94af.tar.xz
rust-openssl-19440c298143aa311578ead17c8949312f4b94af.zip
More error cleanup
Also allocation free RSA
Diffstat (limited to 'openssl/src/crypto/rand.rs')
-rw-r--r--openssl/src/crypto/rand.rs5
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(|_| ())
}
}