Skip to content

Commit

Permalink
Support OpenSSL configured with no-chacha
Browse files Browse the repository at this point in the history
  • Loading branch information
bossmc committed Oct 18, 2021
1 parent 8f2063d commit 1581d45
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions openssl-sys/build/expando.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions openssl-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions openssl-sys/src/evp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions openssl/src/symm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) }
}
Expand Down

0 comments on commit 1581d45

Please sign in to comment.