aboutsummaryrefslogtreecommitdiff
path: root/openssl-sys
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-07-06 11:09:19 -0700
committerSteven Fackler <[email protected]>2015-07-06 11:09:19 -0700
commit114e8a5a58a8fb3c4cc37391fc2f5a7addd796fc (patch)
treed35618791cfc3bf1815b310639f74185a0d0464d /openssl-sys
parentMerge branch 'release-v0.6.3' into release (diff)
parentRelease v0.6.4 (diff)
downloadrust-openssl-0.6.4.tar.xz
rust-openssl-0.6.4.zip
Merge branch 'release-v0.6.4' into releasev0.6.4
Diffstat (limited to 'openssl-sys')
-rw-r--r--openssl-sys/Cargo.toml5
-rw-r--r--openssl-sys/build.rs26
-rw-r--r--openssl-sys/src/lib.rs81
-rw-r--r--openssl-sys/src/openssl_shim.c (renamed from openssl-sys/src/old_openssl_shim.c)35
4 files changed, 102 insertions, 45 deletions
diff --git a/openssl-sys/Cargo.toml b/openssl-sys/Cargo.toml
index f3fbfc18..5ed9d068 100644
--- a/openssl-sys/Cargo.toml
+++ b/openssl-sys/Cargo.toml
@@ -1,12 +1,12 @@
[package]
name = "openssl-sys"
-version = "0.6.3"
+version = "0.6.4"
authors = ["Alex Crichton <[email protected]>",
"Steven Fackler <[email protected]>"]
license = "MIT"
description = "FFI bindings to OpenSSL"
repository = "https://github.com/sfackler/rust-openssl"
-documentation = "https://sfackler.github.io/rust-openssl/doc/v0.6.3/openssl_sys"
+documentation = "https://sfackler.github.io/rust-openssl/doc/v0.6.4/openssl_sys"
links = "openssl"
build = "build.rs"
@@ -19,6 +19,7 @@ dtlsv1_2 = []
sslv2 = []
aes_xts = []
npn = []
+alpn = []
[dependencies]
libc = "0.1"
diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs
index de43c462..c1f12034 100644
--- a/openssl-sys/build.rs
+++ b/openssl-sys/build.rs
@@ -14,13 +14,16 @@ fn main() {
let include_dir = env::var("OPENSSL_INCLUDE_DIR").ok();
if lib_dir.is_none() && include_dir.is_none() {
- if let Ok(info) = pkg_config::find_library("openssl") {
- build_old_openssl_shim(&info.include_paths);
- return;
+ // rustc doesn't seem to work with pkg-config's output in mingw64
+ if !target.contains("windows") {
+ if let Ok(info) = pkg_config::find_library("openssl") {
+ build_openssl_shim(&info.include_paths);
+ return;
+ }
}
if let Some(mingw_paths) = get_mingw_in_path() {
for path in mingw_paths {
- println!("cargo:rustc-flags=-L native={}", path);
+ println!("cargo:rustc-link-search=native={}", path);
}
}
}
@@ -46,11 +49,12 @@ fn main() {
};
if let Some(lib_dir) = lib_dir {
- println!("cargo:rustc-flags=-L native={}", lib_dir);
+ println!("cargo:rustc-link-search=native={}", lib_dir);
}
- let libs_arg = libs.iter().fold(String::new(), |args, lib| args + &format!(" -l {0}={1}", mode, lib));
- println!("cargo:rustc-flags={0}", libs_arg);
+ for lib in libs {
+ println!("cargo:rustc-link-lib={}={}", mode, lib);
+ }
let mut include_dirs = vec![];
@@ -58,18 +62,18 @@ fn main() {
include_dirs.push(PathBuf::from(&include_dir));
}
- build_old_openssl_shim(&include_dirs);
+ build_openssl_shim(&include_dirs);
}
-fn build_old_openssl_shim(include_paths: &[PathBuf]) {
+fn build_openssl_shim(include_paths: &[PathBuf]) {
let mut config = gcc::Config::new();
for path in include_paths {
config.include(path);
}
- config.file("src/old_openssl_shim.c")
- .compile("libold_openssl_shim.a");
+ config.file("src/openssl_shim.c")
+ .compile("libopenssl_shim.a");
}
fn get_mingw_in_path() -> Option<Vec<String>> {
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index d77264be..eb7750f7 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -1,6 +1,6 @@
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(dead_code)]
-#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.6.3")]
+#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.6.4")]
extern crate libc;
@@ -9,7 +9,6 @@ extern crate libressl_pnacl_sys;
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 std::sync::{Mutex, MutexGuard};
use std::sync::{Once, ONCE_INIT};
@@ -263,35 +262,6 @@ pub fn init() {
}
}
-// Functions converted from macros
-pub unsafe fn BIO_eof(b: *mut BIO) -> bool {
- BIO_ctrl(b, BIO_CTRL_EOF, 0, ptr::null_mut()) == 1
-}
-
-pub unsafe fn SSL_CTX_set_options(ssl: *mut SSL_CTX, op: c_long) -> c_long {
- SSL_CTX_ctrl(ssl, SSL_CTRL_OPTIONS, op, ptr::null_mut())
-}
-
-pub unsafe fn BIO_set_mem_eof_return(b: *mut BIO, v: c_int) {
- BIO_ctrl(b, BIO_C_SET_BUF_MEM_EOF_RETURN, v as c_long, ptr::null_mut());
-}
-
-pub unsafe fn SSL_CTX_get_options(ssl: *mut SSL_CTX) -> c_long {
- SSL_CTX_ctrl(ssl, SSL_CTRL_OPTIONS, 0, ptr::null_mut())
-}
-
-pub unsafe fn SSL_CTX_clear_options(ssl: *mut SSL_CTX, op: c_long) -> c_long {
- SSL_CTX_ctrl(ssl, SSL_CTRL_CLEAR_OPTIONS, (op), ptr::null_mut())
-}
-
-pub unsafe fn SSL_CTX_add_extra_chain_cert(ssl: *mut SSL_CTX, cert: *mut X509) -> c_long {
- SSL_CTX_ctrl(ssl, SSL_CTRL_EXTRA_CHAIN_CERT, 0, cert)
-}
-
-pub unsafe fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long {
- SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, ptr::null_mut())
-}
-
// True functions
extern "C" {
pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int;
@@ -301,6 +271,7 @@ extern "C" {
pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long;
pub fn BIO_free_all(b: *mut BIO);
pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO;
+ pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
pub fn BIO_s_mem() -> *const BIO_METHOD;
@@ -445,10 +416,20 @@ extern "C" {
pub fn HMAC_CTX_copy(dst: *mut HMAC_CTX, src: *const HMAC_CTX) -> c_int;
// Pre-1.0 versions of these didn't return anything, so the shims bridge that gap
+ #[cfg_attr(not(target_os = "nacl"), link_name = "HMAC_Init_ex_shim")]
+ pub fn HMAC_Init_ex(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE) -> c_int;
+ #[cfg_attr(not(target_os = "nacl"), link_name = "HMAC_Final_shim")]
+ pub fn HMAC_Final(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint) -> c_int;
+ #[cfg_attr(not(target_os = "nacl"), link_name = "HMAC_Update_shim")]
+ pub fn HMAC_Update(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint) -> c_int;
+
+ /// Deprecated - use the non "_shim" version
#[cfg_attr(target_os = "nacl", link_name = "HMAC_Init_ex")]
pub fn HMAC_Init_ex_shim(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE) -> c_int;
+ /// Deprecated - use the non "_shim" version
#[cfg_attr(target_os = "nacl", link_name = "HMAC_Final")]
pub fn HMAC_Final_shim(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint) -> c_int;
+ /// Deprecated - use the non "_shim" version
#[cfg_attr(target_os = "nacl", link_name = "HMAC_Update")]
pub fn HMAC_Update_shim(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint) -> c_int;
@@ -566,13 +547,31 @@ extern "C" {
inlen: c_uint,
arg: *mut c_void) -> c_int,
arg: *mut c_void);
- #[cfg(feature = "npn")]
+ #[cfg(any(feature = "alpn", feature = "npn"))]
pub fn SSL_select_next_proto(out: *mut *mut c_uchar, outlen: *mut c_uchar,
inbuf: *const c_uchar, inlen: c_uint,
client: *const c_uchar, client_len: c_uint) -> c_int;
#[cfg(feature = "npn")]
pub fn SSL_get0_next_proto_negotiated(s: *const SSL, data: *mut *const c_uchar, len: *mut c_uint);
+ #[cfg(feature = "alpn")]
+ pub fn SSL_CTX_set_alpn_protos(s: *mut SSL_CTX, data: *const c_uchar, len: c_uint) -> c_int;
+
+ #[cfg(feature = "alpn")]
+ pub fn SSL_set_alpn_protos(s: *mut SSL, data: *const c_uchar, len: c_uint) -> c_int;
+
+ #[cfg(feature = "alpn")]
+ pub fn SSL_CTX_set_alpn_select_cb(ssl: *mut SSL_CTX,
+ cb: extern "C" fn(ssl: *mut SSL,
+ out: *mut *mut c_uchar,
+ outlen: *mut c_uchar,
+ inbuf: *const c_uchar,
+ inlen: c_uint,
+ arg: *mut c_void) -> c_int,
+ arg: *mut c_void);
+ #[cfg(feature = "alpn")]
+ pub fn SSL_get0_alpn_selected(s: *const SSL, data: *mut *const c_uchar, len: *mut c_uint);
+
pub fn X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int;
pub fn X509_digest(x: *mut X509, digest: *const EVP_MD, buf: *mut c_char, len: *mut c_uint) -> c_int;
pub fn X509_free(x: *mut X509);
@@ -610,6 +609,24 @@ extern "C" {
pub fn d2i_RSA_PUBKEY(k: *const *mut RSA, buf: *const *const u8, len: c_uint) -> *mut RSA;
pub fn i2d_RSAPrivateKey(k: *mut RSA, buf: *const *mut u8) -> c_int;
pub fn d2i_RSAPrivateKey(k: *const *mut RSA, buf: *const *const u8, len: c_uint) -> *mut RSA;
+
+ // These functions are defined in OpenSSL as macros, so we shim them
+ #[link_name = "BIO_eof_shim"]
+ pub fn BIO_eof(b: *mut BIO) -> c_int;
+ #[link_name = "BIO_set_mem_eof_return_shim"]
+ pub fn BIO_set_mem_eof_return(b: *mut BIO, v: c_int);
+ #[link_name = "SSL_CTX_set_options_shim"]
+ pub fn SSL_CTX_set_options(ctx: *mut SSL_CTX, options: c_long) -> c_long;
+ #[link_name = "SSL_CTX_get_options_shim"]
+ pub fn SSL_CTX_get_options(ctx: *mut SSL_CTX) -> c_long;
+ #[link_name = "SSL_CTX_clear_options_shim"]
+ pub fn SSL_CTX_clear_options(ctx: *mut SSL_CTX, options: c_long) -> c_long;
+ #[link_name = "SSL_CTX_add_extra_chain_cert_shim"]
+ pub fn SSL_CTX_add_extra_chain_cert(ctx: *mut SSL_CTX, x509: *mut X509) -> c_long;
+ #[link_name = "SSL_CTX_set_read_ahead_shim"]
+ pub fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long;
+ #[link_name = "SSL_set_tlsext_host_name_shim"]
+ pub fn SSL_set_tlsext_host_name(s: *mut SSL, name: *const c_char) -> c_long;
}
pub mod probe;
diff --git a/openssl-sys/src/old_openssl_shim.c b/openssl-sys/src/openssl_shim.c
index 19ce74fc..7b4f9c74 100644
--- a/openssl-sys/src/old_openssl_shim.c
+++ b/openssl-sys/src/openssl_shim.c
@@ -1,4 +1,5 @@
#include <openssl/hmac.h>
+#include <openssl/ssl.h>
#if OPENSSL_VERSION_NUMBER < 0x1000000L
// Copied from openssl crypto/hmac/hmac.c
@@ -47,3 +48,37 @@ int HMAC_Final_shim(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) {
return HMAC_Final(ctx, md, len);
}
#endif
+
+// shims for OpenSSL macros
+
+int BIO_eof_shim(BIO *b) {
+ return BIO_eof(b);
+}
+
+void BIO_set_mem_eof_return_shim(BIO *b, int v) {
+ BIO_set_mem_eof_return(b, v);
+}
+
+long SSL_CTX_set_options_shim(SSL_CTX *ctx, long options) {
+ return SSL_CTX_set_options(ctx, options);
+}
+
+long SSL_CTX_get_options_shim(SSL_CTX *ctx) {
+ return SSL_CTX_get_options(ctx);
+}
+
+long SSL_CTX_clear_options_shim(SSL_CTX *ctx, long options) {
+ return SSL_CTX_clear_options(ctx, options);
+}
+
+long SSL_CTX_add_extra_chain_cert_shim(SSL_CTX *ctx, X509 *x509) {
+ return SSL_CTX_add_extra_chain_cert(ctx, x509);
+}
+
+long SSL_CTX_set_read_ahead_shim(SSL_CTX *ctx, long m) {
+ return SSL_CTX_set_read_ahead(ctx, m);
+}
+
+long SSL_set_tlsext_host_name_shim(SSL *s, char *name) {
+ return SSL_set_tlsext_host_name(s, name);
+}