aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2014-10-13 23:19:14 -0700
committerSteven Fackler <[email protected]>2014-10-13 23:19:14 -0700
commit60dce4c2190ecb935044152c02f4362d76a381e2 (patch)
tree9be063d21a6ca4c90f20be1dd54d0dc3144b959f /src/crypto
parentMerge pull request #83 from jmesmon/set-cipher-list (diff)
parentCorrect init mutexes and locking function (diff)
downloadrust-openssl-60dce4c2190ecb935044152c02f4362d76a381e2.tar.xz
rust-openssl-60dce4c2190ecb935044152c02f4362d76a381e2.zip
Merge pull request #81 from vhbit/lock-init
Correct init mutexes and locking function
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/hash.rs2
-rw-r--r--src/crypto/hmac.rs2
-rw-r--r--src/crypto/pkcs5.rs2
-rw-r--r--src/crypto/pkey.rs2
-rw-r--r--src/crypto/rand.rs1
-rw-r--r--src/crypto/symm.rs2
6 files changed, 11 insertions, 0 deletions
diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs
index 61221cb5..a72b8d9f 100644
--- a/src/crypto/hash.rs
+++ b/src/crypto/hash.rs
@@ -36,6 +36,8 @@ pub struct Hasher {
impl Hasher {
pub fn new(ht: HashType) -> Hasher {
+ ffi::init();
+
let ctx = unsafe { ffi::EVP_MD_CTX_create() };
let (evp, mdlen) = evpmd(ht);
unsafe {
diff --git a/src/crypto/hmac.rs b/src/crypto/hmac.rs
index 4c8617ca..ef2a0414 100644
--- a/src/crypto/hmac.rs
+++ b/src/crypto/hmac.rs
@@ -27,6 +27,8 @@ pub struct HMAC {
#[allow(non_snake_case)]
pub fn HMAC(ht: hash::HashType, key: &[u8]) -> HMAC {
unsafe {
+ ffi::init();
+
let (evp, mdlen) = hash::evpmd(ht);
let mut ctx : ffi::HMAC_CTX = ::std::mem::uninitialized();
diff --git a/src/crypto/pkcs5.rs b/src/crypto/pkcs5.rs
index ec6e0cef..feaff9c8 100644
--- a/src/crypto/pkcs5.rs
+++ b/src/crypto/pkcs5.rs
@@ -9,6 +9,8 @@ pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint, keylen: uint) -> Ve
let mut out = Vec::with_capacity(keylen);
+ ffi::init();
+
let r = ffi::PKCS5_PBKDF2_HMAC_SHA1(
pass.as_ptr(), pass.len() as c_int,
salt.as_ptr(), salt.len() as c_int,
diff --git a/src/crypto/pkey.rs b/src/crypto/pkey.rs
index d95e7738..ac16f478 100644
--- a/src/crypto/pkey.rs
+++ b/src/crypto/pkey.rs
@@ -55,6 +55,8 @@ pub struct PKey {
impl PKey {
pub fn new() -> PKey {
unsafe {
+ ffi::init();
+
PKey {
evp: ffi::EVP_PKEY_new(),
parts: Neither,
diff --git a/src/crypto/rand.rs b/src/crypto/rand.rs
index dffddee7..5f94c93c 100644
--- a/src/crypto/rand.rs
+++ b/src/crypto/rand.rs
@@ -5,6 +5,7 @@ pub fn rand_bytes(len: uint) -> Vec<u8> {
unsafe {
let mut out = Vec::with_capacity(len);
+ ffi::init();
let r = ffi::RAND_bytes(out.as_mut_ptr(), len as c_int);
if r != 1 as c_int { fail!() }
diff --git a/src/crypto/symm.rs b/src/crypto/symm.rs
index 9953ac7b..171c1b05 100644
--- a/src/crypto/symm.rs
+++ b/src/crypto/symm.rs
@@ -50,6 +50,8 @@ pub struct Crypter {
impl Crypter {
pub fn new(t: Type) -> Crypter {
+ ffi::init();
+
let ctx = unsafe { ffi::EVP_CIPHER_CTX_new() };
let (evp, keylen, blocksz) = evpc(t);
Crypter { evp: evp, ctx: ctx, keylen: keylen, blocksize: blocksz }