From 1581d454a0d5b7c2dcc850f22051a1ecf3be3246 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Mon, 18 Oct 2021 16:43:23 +0100 Subject: [PATCH] Support OpenSSL configured with `no-chacha` --- openssl-sys/build/expando.c | 4 ++++ openssl-sys/build/main.rs | 1 + openssl-sys/src/evp.rs | 4 ++-- openssl/src/symm.rs | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openssl-sys/build/expando.c b/openssl-sys/build/expando.c index edf7431ea8..300c50bb05 100644 --- a/openssl-sys/build/expando.c +++ b/openssl-sys/build/expando.c @@ -23,6 +23,10 @@ RUST_CONF_OPENSSL_NO_BF RUST_CONF_OPENSSL_NO_BUF_FREELISTS #endif +#ifdef OPENSSL_NO_CHACHA +RUST_CONF_OPENSSL_NO_CHACHA +#endif + #ifdef OPENSSL_NO_CMS RUST_CONF_OPENSSL_NO_CMS #endif diff --git a/openssl-sys/build/main.rs b/openssl-sys/build/main.rs index 156056288d..e8dd5451ac 100644 --- a/openssl-sys/build/main.rs +++ b/openssl-sys/build/main.rs @@ -137,6 +137,7 @@ fn validate_headers(include_dirs: &[PathBuf]) -> Version { // file of OpenSSL, `opensslconf.h`, and then dump out everything it defines // as our own #[cfg] directives. That way the `ossl10x.rs` bindings can // account for compile differences and such. + println!("cargo:rerun-if-changed=build/expando.c"); let mut gcc = cc::Build::new(); for include_dir in include_dirs { gcc.include(include_dir); diff --git a/openssl-sys/src/evp.rs b/openssl-sys/src/evp.rs index 7616bafbc5..e5c2595d26 100644 --- a/openssl-sys/src/evp.rs +++ b/openssl-sys/src/evp.rs @@ -359,9 +359,9 @@ extern "C" { pub fn EVP_aes_256_ofb() -> *const EVP_CIPHER; #[cfg(ossl110)] pub fn EVP_aes_256_ocb() -> *const EVP_CIPHER; - #[cfg(ossl110)] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn EVP_chacha20() -> *const ::EVP_CIPHER; - #[cfg(ossl110)] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn EVP_chacha20_poly1305() -> *const ::EVP_CIPHER; #[cfg(not(osslconf = "OPENSSL_NO_SEED"))] pub fn EVP_seed_cbc() -> *const EVP_CIPHER; diff --git a/openssl/src/symm.rs b/openssl/src/symm.rs index f18c6f70c6..0f9b0d4860 100644 --- a/openssl/src/symm.rs +++ b/openssl/src/symm.rs @@ -279,13 +279,13 @@ impl Cipher { } /// Requires OpenSSL 1.1.0 or newer. - #[cfg(any(ossl110))] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn chacha20() -> Cipher { unsafe { Cipher(ffi::EVP_chacha20()) } } /// Requires OpenSSL 1.1.0 or newer. - #[cfg(any(ossl110))] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn chacha20_poly1305() -> Cipher { unsafe { Cipher(ffi::EVP_chacha20_poly1305()) } }