Skip to content

Commit

Permalink
Merge pull request #1952 from davidben/no-ocb
Browse files Browse the repository at this point in the history
Honor OPENSSL_NO_OCB if OpenSSL was built this way
  • Loading branch information
alex committed Jun 4, 2023
2 parents 9ef1fe3 + e476f9a commit e641bd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions openssl-sys/build/expando.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ RUST_CONF_OPENSSL_NO_NEXTPROTONEG
RUST_CONF_OPENSSL_NO_OCSP
#endif

#ifdef OPENSSL_NO_OCB
RUST_CONF_OPENSSL_NO_OCB
#endif

#ifdef OPENSSL_NO_PSK
RUST_CONF_OPENSSL_NO_PSK
#endif
Expand Down
14 changes: 7 additions & 7 deletions openssl/src/symm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Cipher {
}

/// Requires OpenSSL 1.1.0 or newer.
#[cfg(ossl110)]
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
pub fn aes_128_ocb() -> Cipher {
unsafe { Cipher(ffi::EVP_aes_128_ocb()) }
}
Expand Down Expand Up @@ -187,7 +187,7 @@ impl Cipher {
}

/// Requires OpenSSL 1.1.0 or newer.
#[cfg(ossl110)]
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
pub fn aes_192_ocb() -> Cipher {
unsafe { Cipher(ffi::EVP_aes_192_ocb()) }
}
Expand Down Expand Up @@ -237,7 +237,7 @@ impl Cipher {
}

/// Requires OpenSSL 1.1.0 or newer.
#[cfg(ossl110)]
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
pub fn aes_256_ocb() -> Cipher {
unsafe { Cipher(ffi::EVP_aes_256_ocb()) }
}
Expand Down Expand Up @@ -402,14 +402,14 @@ impl Cipher {
}

/// Determines whether the cipher is using OCB mode
#[cfg(ossl110)]
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
fn is_ocb(self) -> bool {
self == Cipher::aes_128_ocb()
|| self == Cipher::aes_192_ocb()
|| self == Cipher::aes_256_ocb()
}

#[cfg(not(ossl110))]
#[cfg(any(not(ossl110), osslconf = "OPENSSL_NO_OCB"))]
const fn is_ocb(self) -> bool {
false
}
Expand Down Expand Up @@ -1422,7 +1422,7 @@ mod tests {
}

#[test]
#[cfg(ossl110)]
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
fn test_aes_128_ocb() {
let key = "000102030405060708090a0b0c0d0e0f";
let aad = "0001020304050607";
Expand Down Expand Up @@ -1458,7 +1458,7 @@ mod tests {
}

#[test]
#[cfg(ossl110)]
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
fn test_aes_128_ocb_fail() {
let key = "000102030405060708090a0b0c0d0e0f";
let aad = "0001020304050607";
Expand Down

0 comments on commit e641bd2

Please sign in to comment.