aboutsummaryrefslogtreecommitdiff
path: root/src/bn
diff options
context:
space:
mode:
authorValerii Hiora <[email protected]>2014-10-13 17:41:03 +0300
committerValerii Hiora <[email protected]>2014-10-14 08:31:42 +0300
commitdd46d1922e4706cf4c15c8cd915c1254363def8c (patch)
tree9be063d21a6ca4c90f20be1dd54d0dc3144b959f /src/bn
parentMerge pull request #83 from jmesmon/set-cipher-list (diff)
downloadrust-openssl-dd46d1922e4706cf4c15c8cd915c1254363def8c.tar.xz
rust-openssl-dd46d1922e4706cf4c15c8cd915c1254363def8c.zip
Correct init mutexes and locking function
`libcrypto` uses locks quite intensively even without SSL. So they should be initialized before everything else to function properly in multi-threaded apps in which SSL operations are absent or delayed. Finishes #79
Diffstat (limited to 'src/bn')
-rw-r--r--src/bn/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bn/mod.rs b/src/bn/mod.rs
index 129f6b90..510c9269 100644
--- a/src/bn/mod.rs
+++ b/src/bn/mod.rs
@@ -79,8 +79,10 @@ macro_rules! with_bn_in_ctx(
)
impl BigNum {
+ // FIXME: squash 3 constructors into one
pub fn new() -> Result<BigNum, SslError> {
unsafe {
+ ffi::init();
let v = ffi::BN_new();
if v.is_null() {
Err(SslError::get())
@@ -92,6 +94,7 @@ impl BigNum {
pub fn new_from(n: u64) -> Result<BigNum, SslError> {
unsafe {
+ ffi::init();
let bn = ffi::BN_new();
if bn.is_null() || ffi::BN_set_word(bn, n as c_ulong) == 0 {
Err(SslError::get())
@@ -103,6 +106,7 @@ impl BigNum {
pub fn new_from_slice(n: &[u8]) -> Result<BigNum, SslError> {
unsafe {
+ ffi::init();
let bn = ffi::BN_new();
if bn.is_null() || ffi::BN_bin2bn(n.as_ptr(), n.len() as c_int, bn).is_null() {
Err(SslError::get())