Skip to content

Commit

Permalink
Adds support for linking against boringssl
Browse files Browse the repository at this point in the history
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: Matthew Maurer <mmaurer@google.com>
  • Loading branch information
benbrittain and maurer committed Sep 23, 2022
1 parent f8c321f commit e610c0f
Show file tree
Hide file tree
Showing 42 changed files with 845 additions and 477 deletions.
2 changes: 2 additions & 0 deletions openssl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
12 changes: 12 additions & 0 deletions openssl-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
64 changes: 32 additions & 32 deletions openssl-sys/src/handwritten/mod.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
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;
Expand Down
Loading

0 comments on commit e610c0f

Please sign in to comment.