Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Chris Cole 2014-12-10 22:09:20 -05:00
commit fb1c815274
9 changed files with 55 additions and 18 deletions

View File

@ -1,7 +1,5 @@
language: rust language: rust
env: env:
global:
- secure: qLvBJoJOJcPPZ+e31175O6sMUGBHgHe/kBuI0FCPeifYmpFyeRAkEvGddEkf8t3rojV+wE14CNYzzGsT/W/+JY7xW0C1FQKW3r+8SZ1Cave/8ahee0aCQVXGf0XY8c52uG6MrLGiUlNZbOsyFSdFUc/Io+kYZas4DxrinRSOIEA=
matrix: matrix:
- FEATURES="" - FEATURES=""
- FEATURES="tlsv1_1 tlsv1_2 aes_xts" - FEATURES="tlsv1_1 tlsv1_2 aes_xts"
@ -11,11 +9,4 @@ os:
before_script: before_script:
- openssl s_server -accept 15418 -www -cert test/cert.pem -key test/key.pem >/dev/null 2>&1 & - openssl s_server -accept 15418 -www -cert test/cert.pem -key test/key.pem >/dev/null 2>&1 &
script: script:
- cargo build --features "$FEATURES"
- cargo test --features "$FEATURES" - cargo test --features "$FEATURES"
- cargo doc --features "sslv2 tlsv1_1 tlsv1_2 aes_xts"
after_success: |
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
cd target/doc &&
(curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh)

View File

@ -1,6 +1,6 @@
[package] [package]
name = "openssl" name = "openssl"
version = "0.2.1" version = "0.2.3"
authors = ["Steven Fackler <sfackler@gmail.com>"] authors = ["Steven Fackler <sfackler@gmail.com>"]
license = "Apache-2.0" license = "Apache-2.0"
description = "OpenSSL bindings" description = "OpenSSL bindings"
@ -17,4 +17,4 @@ aes_xts = ["openssl-sys/aes_xts"]
[dependencies.openssl-sys] [dependencies.openssl-sys]
path = "openssl-sys" path = "openssl-sys"
version = "0.2.1" version = "0.2.3"

View File

@ -14,6 +14,11 @@ For some reason, the OpenSSL distribution for Windows is structured differently,
1. Run `sudo apt-get install libssl-dev`. 1. Run `sudo apt-get install libssl-dev`.
2. Run `cargo build`. 2. Run `cargo build`.
###Android
1. Follow the steps [here](wiki.openssl.org/index.php/Android) to build OpenSSL for android
2. Provide the path to the libssl and libcrypto binaries via `$OPENSSL_PATH`
3. Build the package with `cargo build`
###Windows ###Windows
1. Grab the latest Win32 OpenSSL installer [here][1]. At the time of this writing, it's v1.0.1i. If you're using 64-bit Rust (coming to Windows soon), then you should get the Win64 installer instead. 1. Grab the latest Win32 OpenSSL installer [here][1]. At the time of this writing, it's v1.0.1i. If you're using 64-bit Rust (coming to Windows soon), then you should get the Win64 installer instead.

View File

@ -1,6 +1,6 @@
[package] [package]
name = "openssl-sys" name = "openssl-sys"
version = "0.2.1" version = "0.2.3"
authors = ["Alex Crichton <alex@alexcrichton.com>", authors = ["Alex Crichton <alex@alexcrichton.com>",
"Steven Fackler <sfackler@gmail.com>"] "Steven Fackler <sfackler@gmail.com>"]
license = "MIT" license = "MIT"
@ -17,4 +17,13 @@ sslv2 = []
aes_xts = [] aes_xts = []
[build-dependencies] [build-dependencies]
pkg-config = "0.1" pkg-config = "0.1.1"
[target.le32-unknown-nacl.dependencies]
libressl-pnacl-sys = "2.1.0"
[target.x86_64-unknown-nacl.dependencies]
libressl-pnacl-sys = "2.1.0"
[target.i686-unknown-nacl.dependencies]
libressl-pnacl-sys = "2.1.0"
[target.arm-unknown-nacl.dependencies]
libressl-pnacl-sys = "2.1.0"

View File

@ -3,6 +3,11 @@ extern crate "pkg-config" as pkg_config;
use std::os; use std::os;
fn main() { fn main() {
// Without hackory, pkg-config will only look for host libraries.
// So, abandon ship if we're cross compiling.
if !pkg_config::target_supported() { return; }
if pkg_config::find_library("openssl").is_err() { if pkg_config::find_library("openssl").is_err() {
let mut flags = " -l crypto -l ssl".to_string(); let mut flags = " -l crypto -l ssl".to_string();
@ -17,6 +22,14 @@ fn main() {
if win_pos.is_some() { if win_pos.is_some() {
flags.push_str(" -l gdi32 -l wsock32"); flags.push_str(" -l gdi32 -l wsock32");
} }
if target.find_str("android").is_some() {
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.");
flags.push_str(format!(" -L {}", path).as_slice());
}
println!("cargo:rustc-flags={}", flags); println!("cargo:rustc-flags={}", flags);
} }
} }

View File

@ -4,6 +4,9 @@
extern crate libc; extern crate libc;
extern crate rustrt; extern crate rustrt;
#[cfg(feature = "libressl-pnacl-sys")]
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 libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t};
use std::mem; use std::mem;
use std::ptr; use std::ptr;
@ -359,6 +362,7 @@ extern "C" {
pub fn HMAC_Init_ex(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE); pub fn HMAC_Init_ex(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE);
pub fn HMAC_Final(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint); pub fn HMAC_Final(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint);
pub fn HMAC_Update(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint); pub fn HMAC_Update(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint);
pub fn HMAC_CTX_cleanup(ctx: *mut HMAC_CTX);
pub fn PEM_read_bio_X509(bio: *mut BIO, out: *mut *mut X509, callback: Option<PasswordCallback>, pub fn PEM_read_bio_X509(bio: *mut BIO, out: *mut *mut X509, callback: Option<PasswordCallback>,

View File

@ -61,6 +61,14 @@ impl HMAC {
} }
} }
impl Drop for HMAC {
fn drop(&mut self) {
unsafe {
ffi::HMAC_CTX_cleanup(&mut self.ctx);
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use serialize::hex::FromHex; use serialize::hex::FromHex;

View File

@ -410,7 +410,14 @@ impl<S: Stream> SslStream<S> {
stream: stream, stream: stream,
ssl: Arc::new(ssl), ssl: Arc::new(ssl),
// Maximum TLS record size is 16k // Maximum TLS record size is 16k
buf: Vec::from_elem(16 * 1024, 0u8) // We're just using this as a buffer, so there's no reason to pay
// to memset it
buf: {
const CAP: uint = 16 * 1024;
let mut v = Vec::with_capacity(CAP);
unsafe { v.set_len(CAP); }
v
}
} }
} }

View File

@ -145,15 +145,15 @@ impl<'a, T: AsStr<'a>> ToStr for Vec<T> {
/// use std::io::{File, Open, Write}; /// use std::io::{File, Open, Write};
/// # use std::io::fs; /// # use std::io::fs;
/// ///
/// use openssl::crypto::hash::SHA256; /// use openssl::crypto::hash::HashType;
/// use openssl::x509::{DigitalSignature, X509Generator}; /// use openssl::x509::{KeyUsage, X509Generator};
/// ///
/// let gen = X509Generator::new() /// let gen = X509Generator::new()
/// .set_bitlength(2048) /// .set_bitlength(2048)
/// .set_valid_period(365*2) /// .set_valid_period(365*2)
/// .set_CN("SuperMegaCorp Inc.") /// .set_CN("SuperMegaCorp Inc.")
/// .set_sign_hash(SHA256) /// .set_sign_hash(HashType::SHA256)
/// .set_usage(&[DigitalSignature]); /// .set_usage(&[KeyUsage::DigitalSignature]);
/// ///
/// let (cert, pkey) = gen.generate().unwrap(); /// let (cert, pkey) = gen.generate().unwrap();
/// ///