Commit e610c0fe authored by Benjamin Brittain's avatar Benjamin Brittain Committed by Matthew Maurer
Browse files

Adds support for linking against boringssl



The boringssl-sys crate is specific to the revision of boringssl you are
using, so you will need to generate it from a boringssl build tree and
point the openssl crate at it via cargo source replacement, or place the
build tree next to rust-openssl while building.

Co-authored-by: default avatarMatthew Maurer <mmaurer@google.com>
parent f8c321fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -15,9 +15,11 @@ build = "build/main.rs"

[features]
vendored = ['openssl-src']
unstable_boringssl = ['bssl-sys']

[dependencies]
libc = "0.2"
bssl-sys = { version = "0.1.0", optional = true }

[build-dependencies]
bindgen = { version = "0.59.2", optional = true }
+12 −0
Original line number Diff line number Diff line
@@ -60,9 +60,21 @@ fn find_openssl(target: &str) -> (Vec<PathBuf>, PathBuf) {
    find_normal::get_openssl(target)
}

fn check_ssl_kind() {
    if cfg!(feature = "unstable_boringssl") {
        println!("cargo:rustc-cfg=boringssl");
        // BoringSSL does not have any build logic, exit early
        std::process::exit(0);
    } else {
        println!("cargo:rustc-cfg=openssl");
    }
}

fn main() {
    check_rustc_versions();

    check_ssl_kind();

    let target = env::var("TARGET").unwrap();

    let (lib_dirs, include_dir) = find_openssl(&target);
+32 −32
Original line number Diff line number Diff line
pub use handwritten::aes::*;
pub use handwritten::asn1::*;
pub use handwritten::bio::*;
pub use handwritten::bn::*;
pub use handwritten::cms::*;
pub use handwritten::conf::*;
pub use handwritten::crypto::*;
pub use handwritten::dh::*;
pub use handwritten::dsa::*;
pub use handwritten::ec::*;
pub use handwritten::err::*;
pub use handwritten::evp::*;
pub use handwritten::hmac::*;
pub use handwritten::kdf::*;
pub use handwritten::object::*;
pub use handwritten::ocsp::*;
pub use handwritten::pem::*;
pub use handwritten::pkcs12::*;
pub use handwritten::pkcs7::*;
pub use handwritten::provider::*;
pub use handwritten::rand::*;
pub use handwritten::rsa::*;
pub use handwritten::safestack::*;
pub use handwritten::sha::*;
pub use handwritten::srtp::*;
pub use handwritten::ssl::*;
pub use handwritten::stack::*;
pub use handwritten::tls1::*;
pub use handwritten::types::*;
pub use handwritten::x509::*;
pub use handwritten::x509_vfy::*;
pub use handwritten::x509v3::*;
pub use self::aes::*;
pub use self::asn1::*;
pub use self::bio::*;
pub use self::bn::*;
pub use self::cms::*;
pub use self::conf::*;
pub use self::crypto::*;
pub use self::dh::*;
pub use self::dsa::*;
pub use self::ec::*;
pub use self::err::*;
pub use self::evp::*;
pub use self::hmac::*;
pub use self::kdf::*;
pub use self::object::*;
pub use self::ocsp::*;
pub use self::pem::*;
pub use self::pkcs12::*;
pub use self::pkcs7::*;
pub use self::provider::*;
pub use self::rand::*;
pub use self::rsa::*;
pub use self::safestack::*;
pub use self::sha::*;
pub use self::srtp::*;
pub use self::ssl::*;
pub use self::stack::*;
pub use self::tls1::*;
pub use self::types::*;
pub use self::x509::*;
pub use self::x509_vfy::*;
pub use self::x509v3::*;

mod aes;
mod asn1;
+159 −147
Original line number Diff line number Diff line
@@ -13,38 +13,47 @@
#![recursion_limit = "128"] // configure fixed limit across all rust versions

extern crate libc;
pub use libc::*;

#[cfg(boringssl)]
extern crate bssl_sys;
#[cfg(boringssl)]
pub use bssl_sys::*;

#[cfg(openssl)]
#[path = "."]
mod openssl {
    use libc::*;

    #[cfg(feature = "bindgen")]
    include!(concat!(env!("OUT_DIR"), "/bindgen.rs"));

pub use aes::*;
pub use asn1::*;
pub use bio::*;
pub use bn::*;
pub use cms::*;
pub use crypto::*;
pub use dtls1::*;
pub use ec::*;
pub use err::*;
pub use evp::*;
    pub use self::aes::*;
    pub use self::asn1::*;
    pub use self::bio::*;
    pub use self::bn::*;
    pub use self::cms::*;
    pub use self::crypto::*;
    pub use self::dtls1::*;
    pub use self::ec::*;
    pub use self::err::*;
    pub use self::evp::*;
    #[cfg(not(feature = "bindgen"))]
pub use handwritten::*;
pub use obj_mac::*;
pub use ocsp::*;
pub use pem::*;
pub use pkcs7::*;
pub use rsa::*;
pub use sha::*;
pub use srtp::*;
pub use ssl::*;
pub use ssl3::*;
pub use tls1::*;
pub use types::*;
pub use x509::*;
pub use x509_vfy::*;
pub use x509v3::*;
    pub use self::handwritten::*;
    pub use self::obj_mac::*;
    pub use self::ocsp::*;
    pub use self::pem::*;
    pub use self::pkcs7::*;
    pub use self::rsa::*;
    pub use self::sha::*;
    pub use self::srtp::*;
    pub use self::ssl::*;
    pub use self::ssl3::*;
    pub use self::tls1::*;
    pub use self::types::*;
    pub use self::x509::*;
    pub use self::x509_vfy::*;
    pub use self::x509v3::*;

    #[macro_use]
    mod macros;
@@ -172,3 +181,6 @@ pub fn init() {
            set_id_callback();
        })
    }
}
#[cfg(openssl)]
pub use openssl::*;
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ v111 = []

vendored = ['ffi/vendored']
bindgen = ['ffi/bindgen']
unstable_boringssl = ["ffi/unstable_boringssl"]
default = []

[dependencies]
bitflags = "1.0"
Loading