Compare commits
No commits in common. "82d272cdb8f0d46dd559c249769dba73db5209e1" and "70495f7fdc0671239fbcfc24882bb8cb764ff872" have entirely different histories.
82d272cdb8
...
70495f7fdc
|
@ -213,9 +213,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.134"
|
||||
version = "0.2.133"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
|
||||
checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
|
@ -278,9 +278,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.46"
|
||||
version = "1.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
|
||||
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ version = "0.0.5-pre.0"
|
|||
authors = ["Aydin Mercan <aydin@mercan.dev>"]
|
||||
license = "BSD-3-Clause"
|
||||
readme = "README.md"
|
||||
build = "build/main.rs"
|
||||
categories = ["cryptography", "no-std", "external-ffi-bindings"]
|
||||
keywords = ["bearssl", "crypto", "tls", "ssl"]
|
||||
edition = "2021"
|
||||
|
@ -15,7 +14,7 @@ rust-version = "1.64"
|
|||
maintenance = { status = "actively-developed" }
|
||||
|
||||
[dependencies]
|
||||
libc = { version = "0.2.134", optional = true }
|
||||
libc = { version = "0.2.133", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.60.1"
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(not(feature = "bundled"))]
|
||||
static HEADER_PATH: &str = "wrapper.h";
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
static HEADER_PATH: &str = "bundled/inc/bearssl.h";
|
||||
|
||||
#[cfg(feature = "dont-assume-size_t-equals-uintptr_t")]
|
||||
static CTYPES_PREFIX: &str = "::libc";
|
||||
|
||||
#[cfg(not(feature = "dont-assume-size_t-equals-uintptr_t"))]
|
||||
static CTYPES_PREFIX: &str = "::core::ffi";
|
||||
|
||||
#[cfg(not(feature = "bundled"))]
|
||||
fn bearssl_handle_linkage() {
|
||||
#[cfg(not(unix))]
|
||||
panic!("linking dynamically is currently supported in only unix targets");
|
||||
|
||||
println!("cargo:rustc-link-search=/lib");
|
||||
println!("cargo:rustc-link-search=/usr/lib");
|
||||
println!("cargo:rustc-link-search=/usr/local/lib");
|
||||
println!("cargo:rustc-link-lib=dylib=bearssl");
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn build_configure_arch_specific(build: &mut cc::Build) {
|
||||
let compiler = build.get_compiler();
|
||||
|
||||
build.define("BR_64", "1");
|
||||
|
||||
if compiler.is_like_gnu() || compiler.is_like_clang() {
|
||||
build.define("BR_INT128", "1");
|
||||
} else if compiler.is_like_msvc() {
|
||||
build.define("BR_UMUL128", "1");
|
||||
}
|
||||
|
||||
#[cfg(target_feature = "sse2")]
|
||||
build.define("BR_SSE2", "1");
|
||||
|
||||
#[cfg(target_feature = "aes")]
|
||||
build.define("BR_AES_X86NI", "1");
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
fn build_configure_arch_specific(build: &mut cc::Build) {
|
||||
#[cfg(target_pointer_width = 64)]
|
||||
build.define("BR_64", "1");
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
#[cfg(unix)]
|
||||
fn build_configure_os_specific(build: &mut cc::Build) {
|
||||
build.define("BR_USE_UNIX_TIME", "1").define("BR_USE_URANDOM", "1");
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
#[cfg(windows)]
|
||||
fn build_configure_os_specific(build: &mut cc::Build) {
|
||||
build.define("BR_USE_WIN32_RAND", "1").define("BR_USE_WIN32_TIME", "1");
|
||||
}
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
fn bearssl_handle_linkage() {
|
||||
let mut build = cc::Build::new();
|
||||
|
||||
build_configure_os_specific(&mut build);
|
||||
build_configure_arch_specific(&mut build);
|
||||
|
||||
build
|
||||
.include("bundled/inc")
|
||||
.files(
|
||||
std::fs::read_dir("bundled/src")
|
||||
.expect("failed to get bundled source path")
|
||||
.map(|e| e.expect("failed to read get file entry").path()),
|
||||
)
|
||||
.static_flag(true)
|
||||
.compile("bearssl");
|
||||
|
||||
println!("cargo:lib_dir={}", env::var("OUT_DIR").unwrap());
|
||||
println!("cargo:rustc-link-lib=static=bearssl");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
bearssl_handle_linkage();
|
||||
|
||||
let bindings = bindgen::builder()
|
||||
.use_core()
|
||||
.ctypes_prefix(CTYPES_PREFIX)
|
||||
.header(HEADER_PATH)
|
||||
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.allowlist_type("(br|BR)_.*")
|
||||
.allowlist_var("(br|BR)_.*")
|
||||
.allowlist_function("(br|BR)_.*")
|
||||
.blocklist_type("__.*_t")
|
||||
.blocklist_type("size_t")
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#[cfg(not(feature = "bundled"))]
|
||||
mod dynamichost;
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
mod bundled;
|
||||
|
||||
#[cfg(feature = "bundled")]
|
||||
pub use bundled::{configure, HEADER_PATH};
|
||||
|
||||
#[cfg(not(feature = "bundled"))]
|
||||
pub use dynamichost::{configure, HEADER_PATH};
|
|
@ -1,24 +0,0 @@
|
|||
mod arch;
|
||||
mod os;
|
||||
|
||||
pub static HEADER_PATH: &str = "bundled/inc/bearssl.h";
|
||||
|
||||
pub fn configure() {
|
||||
let mut build = cc::Build::new();
|
||||
|
||||
os::configure(&mut build);
|
||||
arch::configure(&mut build);
|
||||
|
||||
build
|
||||
.include("bundled/inc")
|
||||
.files(
|
||||
std::fs::read_dir("bundled/src")
|
||||
.expect("failed to get bundled source path")
|
||||
.map(|e| e.expect("failed to read get file entry").path()),
|
||||
)
|
||||
.static_flag(true)
|
||||
.compile("bearssl");
|
||||
|
||||
println!("cargo:lib_dir={}", std::env::var("OUT_DIR").unwrap());
|
||||
println!("cargo:rustc-link-lib=static=bearssl");
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn configure(build: &mut cc::Build) {
|
||||
let compiler = build.get_compiler();
|
||||
|
||||
build.define("BR_64", "1");
|
||||
|
||||
if compiler.is_like_gnu() || compiler.is_like_clang() {
|
||||
build.define("BR_INT128", "1");
|
||||
} else if compiler.is_like_msvc() {
|
||||
build.define("BR_UMUL128", "1");
|
||||
}
|
||||
|
||||
#[cfg(target_feature = "sse2")]
|
||||
build.define("BR_SSE2", "1");
|
||||
|
||||
#[cfg(target_feature = "aes")]
|
||||
build.define("BR_AES_X86NI", "1");
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
pub fn configure(build: &mut cc::Build) {
|
||||
#[cfg(target_pointer_width = 64)]
|
||||
build.define("BR_64", "1");
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#[cfg(unix)]
|
||||
pub fn configure(build: &mut cc::Build) {
|
||||
build.define("BR_USE_UNIX_TIME", "1").define("BR_USE_URANDOM", "1");
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn configure(build: &mut cc::Build) {
|
||||
build.define("BR_USE_WIN32_RAND", "1").define("BR_USE_WIN32_TIME", "1");
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
pub static HEADER_PATH: &str = "wrapper.h";
|
||||
|
||||
pub fn configure() {
|
||||
#[cfg(not(unix))]
|
||||
panic!("linking dynamically is currently supported in only unix targets");
|
||||
|
||||
println!("cargo:rustc-link-search=/lib");
|
||||
println!("cargo:rustc-link-search=/usr/lib");
|
||||
println!("cargo:rustc-link-search=/usr/local/lib");
|
||||
println!("cargo:rustc-link-lib=dylib=bearssl");
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
mod linkage;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
linkage::configure();
|
||||
|
||||
let bindings = bindgen::builder()
|
||||
.use_core()
|
||||
.ctypes_prefix("::core::ffi")
|
||||
.header(linkage::HEADER_PATH)
|
||||
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.allowlist_type("(br|BR)_.*")
|
||||
.allowlist_var("(br|BR)_.*")
|
||||
.allowlist_function("(br|BR)_.*")
|
||||
.blocklist_type("__.*_t")
|
||||
.blocklist_type("size_t")
|
||||
.generate_comments(false)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
|
@ -15,7 +15,7 @@ maintenance = { status = "actively-developed" }
|
|||
|
||||
[dependencies]
|
||||
bearssl-sys = { path = "../bearssl-sys" }
|
||||
libc = { version = "0.2.134", optional = true }
|
||||
libc = { version = "0.2.133", optional = true }
|
||||
rand_core = { version = "0.6.3", default-features = false }
|
||||
zeroize = { version = "1.5.7", default-features = false, optional = true }
|
||||
|
||||
|
|
Loading…
Reference in New Issue