diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..e2b197d --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[patch.crates-io] +bssl-sys = { version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true } diff --git a/src/cipher.rs b/src/cipher.rs index ab5f49d..84a8265 100644 --- a/src/cipher.rs +++ b/src/cipher.rs @@ -208,6 +208,7 @@ impl Cipher { unsafe { CipherRef::from_ptr(ffi::EVP_aes_192_cfb1() as *mut _) } } + #[cfg(not(boringssl))] pub fn aes_192_cfb128() -> &'static CipherRef { unsafe { CipherRef::from_ptr(ffi::EVP_aes_192_cfb128() as *mut _) } } @@ -253,6 +254,7 @@ impl Cipher { unsafe { CipherRef::from_ptr(ffi::EVP_aes_256_cfb1() as *mut _) } } + #[cfg(not(boringssl))] pub fn aes_256_cfb128() -> &'static CipherRef { unsafe { CipherRef::from_ptr(ffi::EVP_aes_256_cfb128() as *mut _) } } @@ -282,11 +284,13 @@ impl Cipher { } #[cfg(not(osslconf = "OPENSSL_NO_BF"))] + #[cfg(not(boringssl))] pub fn bf_cbc() -> &'static CipherRef { unsafe { CipherRef::from_ptr(ffi::EVP_bf_cbc() as *mut _) } } #[cfg(not(osslconf = "OPENSSL_NO_BF"))] + #[cfg(not(boringssl))] pub fn bf_ecb() -> &'static CipherRef { unsafe { CipherRef::from_ptr(ffi::EVP_bf_ecb() as *mut _) } } diff --git a/src/encrypt.rs b/src/encrypt.rs index 3cb10fc..34a9eb8 100644 --- a/src/encrypt.rs +++ b/src/encrypt.rs @@ -148,7 +148,7 @@ impl<'a> Encrypter<'a> { /// This corresponds to [`EVP_PKEY_CTX_set_rsa_oaep_md`]. /// /// [`EVP_PKEY_CTX_set_rsa_oaep_md`]: https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_CTX_set_rsa_oaep_md.html - #[cfg(any(ossl102, libressl310))] + #[cfg(any(ossl102, libressl310, boringssl))] pub fn set_rsa_oaep_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EVP_PKEY_CTX_set_rsa_oaep_md( @@ -352,7 +352,7 @@ impl<'a> Decrypter<'a> { /// This corresponds to [`EVP_PKEY_CTX_set_rsa_oaep_md`]. /// /// [`EVP_PKEY_CTX_set_rsa_oaep_md`]: https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_CTX_set_rsa_oaep_md.html - #[cfg(any(ossl102, libressl310))] + #[cfg(any(ossl102, libressl310, boringssl))] pub fn set_rsa_oaep_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EVP_PKEY_CTX_set_rsa_oaep_md( diff --git a/src/lib.rs b/src/lib.rs index 891651e..f149bfd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -120,6 +120,9 @@ #![doc(html_root_url = "https://docs.rs/openssl/0.10")] #![warn(rust_2018_idioms)] +#[cfg(all(soong, boringssl))] +extern crate bssl_sys as ffi; + #[doc(inline)] pub use ffi::init; @@ -155,6 +158,10 @@ pub mod ex_data; #[cfg(not(any(libressl, ossl300)))] pub mod fips; pub mod hash; +#[cfg(boringssl)] +pub mod hkdf; +#[cfg(boringssl)] +pub mod hmac; #[cfg(ossl300)] pub mod lib_ctx; pub mod md; diff --git a/src/symm.rs b/src/symm.rs index c75bbc0..beff5fc 100644 --- a/src/symm.rs +++ b/src/symm.rs @@ -119,6 +119,7 @@ impl Cipher { unsafe { Cipher(ffi::EVP_aes_128_cfb1()) } } + #[cfg(not(boringssl))] pub fn aes_128_cfb128() -> Cipher { unsafe { Cipher(ffi::EVP_aes_128_cfb128()) } } @@ -164,6 +165,7 @@ impl Cipher { unsafe { Cipher(ffi::EVP_aes_192_cfb1()) } } + #[cfg(not(boringssl))] pub fn aes_192_cfb128() -> Cipher { unsafe { Cipher(ffi::EVP_aes_192_cfb128()) } } @@ -214,6 +216,7 @@ impl Cipher { unsafe { Cipher(ffi::EVP_aes_256_cfb1()) } } + #[cfg(not(boringssl))] pub fn aes_256_cfb128() -> Cipher { unsafe { Cipher(ffi::EVP_aes_256_cfb128()) } } @@ -242,12 +245,12 @@ impl Cipher { unsafe { Cipher(ffi::EVP_aes_256_ocb()) } } - #[cfg(not(osslconf = "OPENSSL_NO_BF"))] + #[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_BF")))] pub fn bf_cbc() -> Cipher { unsafe { Cipher(ffi::EVP_bf_cbc()) } } - #[cfg(not(osslconf = "OPENSSL_NO_BF"))] + #[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_BF")))] pub fn bf_ecb() -> Cipher { unsafe { Cipher(ffi::EVP_bf_ecb()) } }