Commit 156fc65e authored by Chris Cole's avatar Chris Cole
Browse files

Merge remote-tracking branch 'upstream/master'

Conflicts:
	openssl-sys/src/lib.rs
parents 38682821 49a72ae9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
[package]
name = "openssl"
version = "0.2.3"
version = "0.2.8"
authors = ["Steven Fackler <sfackler@gmail.com>"]
license = "Apache-2.0"
description = "OpenSSL bindings"
@@ -17,4 +17,4 @@ aes_xts = ["openssl-sys/aes_xts"]

[dependencies.openssl-sys]
path = "openssl-sys"
version = "0.2.3"
version = "0.2.8"
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ For some reason, the OpenSSL distribution for Windows is structured differently,
2. Run the installer, making note of where it's installing OpenSSL. The option to copy the libraries to the Windows system directory or `[OpenSSL folder]/bin` is your choice. The latter is probably preferable, and the default.
3. Navigate to `[OpenSSL folder]/lib/MinGW/`, and copy `libeay32.a` and `ssleay32.a` (If 64-bit, then they will have `64` instead of `32`.) to your Rust install's libs folder. The default should be: 
  * 32-bit: `C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib`
  * 64-bit: TODO
  * 64-bit: `C:\Program Files (x86)\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib`
4. Rename `libeay32.a` and `ssleay32.a` to `libcrypto.a` and `libssl.a`, respectively. 
5. Run `cargo build`.

+1 −1
Original line number Diff line number Diff line
[package]
name = "openssl-sys"
version = "0.2.3"
version = "0.2.8"
authors = ["Alex Crichton <alex@alexcrichton.com>",
           "Steven Fackler <sfackler@gmail.com>"]
license = "MIT"
+8 −3
Original line number Diff line number Diff line
@@ -9,9 +9,14 @@ fn main() {


    if pkg_config::find_library("openssl").is_err() {
        let mut flags = " -l crypto -l ssl".to_string();

        let target = os::getenv("TARGET").unwrap();
        let is_android = target.find_str("android").is_some();

        let mut flags = if is_android {
            " -l crypto:static -l ssl:static"
        } else {
            " -l crypto -l ssl"
        }.to_string();

        let win_pos = target.find_str("windows")
                            .or(target.find_str("win32"))
@@ -23,7 +28,7 @@ fn main() {
           flags.push_str(" -l gdi32 -l wsock32");
        }

        if target.find_str("android").is_some() {
        if is_android {
            let path = os::getenv("OPENSSL_PATH").expect("Android does not provide openssl libraries, please \
                                                          build them yourselves (instructions in the README) \
                                                          and provide their location through $OPENSSL_PATH.");
+16 −6
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
#![allow(dead_code)]

extern crate libc;
extern crate rustrt;

#[cfg(feature = "libressl-pnacl-sys")]
extern crate "libressl-pnacl-sys" as _for_linkage;
@@ -10,7 +9,7 @@ extern crate "libressl-pnacl-sys" as _for_linkage;
use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t};
use std::mem;
use std::ptr;
use rustrt::mutex::NativeMutex;
use std::sync::{StaticMutex, StaticMutexGuard, MUTEX_INIT};
use std::sync::{Once, ONCE_INIT};

pub type ASN1_INTEGER = c_void;
@@ -49,6 +48,8 @@ pub struct EVP_MD_CTX {
    update: *mut c_void
}

impl Copy for EVP_MD_CTX {}

#[repr(C)]
pub struct HMAC_CTX {
    md: *mut EVP_MD,
@@ -59,6 +60,8 @@ pub struct HMAC_CTX {
    key: [c_uchar, ..128]
}

impl Copy for HMAC_CTX {}

#[repr(C)]
pub struct X509V3_CTX {
    flags: c_int,
@@ -72,6 +75,8 @@ pub struct X509V3_CTX {
    // Maybe more here
}

impl Copy for X509V3_CTX {}

#[repr(C)]
pub struct BIGNUM {
    pub d: *mut c_void,
@@ -81,6 +86,8 @@ pub struct BIGNUM {
    pub flags: c_int,
}

impl Copy for BIGNUM {}

#[repr(C)]
pub struct BIGNUM_PTR {
    pub ptr: *mut BIGNUM,
@@ -189,7 +196,8 @@ pub const X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: c_int = 45;
pub const X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: c_int = 53;
pub const X509_V_OK: c_int = 0;

static mut MUTEXES: *mut Vec<NativeMutex> = 0 as *mut Vec<NativeMutex>;
static mut MUTEXES: *mut Vec<StaticMutex> = 0 as *mut Vec<StaticMutex>;
static mut GUARDS: *mut Vec<Option<StaticMutexGuard>> = 0 as *mut Vec<Option<StaticMutexGuard>>;

extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char,
                               _line: c_int) {
@@ -197,9 +205,9 @@ extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char,
        let mutex = &(*MUTEXES)[n as uint];

        if mode & CRYPTO_LOCK != 0 {
            mutex.lock_noguard();
            (*GUARDS)[n as uint] = Some(mutex.lock());
        } else {
            mutex.unlock_noguard();
            &(*GUARDS)[n as uint].take();
        }
    }
}
@@ -213,8 +221,10 @@ pub fn init() {
            SSL_load_error_strings();

            let num_locks = CRYPTO_num_locks();
            let mutexes = box Vec::from_fn(num_locks as uint, |_| NativeMutex::new());
            let mutexes = box Vec::from_fn(num_locks as uint, |_| MUTEX_INIT);
            MUTEXES = mem::transmute(mutexes);
            let guards: Box<Vec<Option<StaticMutexGuard>>> = box Vec::from_fn(num_locks as uint, |_| None);
            GUARDS = mem::transmute(guards);

            CRYPTO_set_locking_callback(locking_function);
        })
Loading