Skip to content

Commit e476f9a

Browse files
committed
Honor OPENSSL_NO_OCB if OpenSSL was built this way
Setting ossl110 in the BoringSSL build (see #1944) causes rust-openssl to expect OCB support. However, OpenSSL already has a feature guard for OCB, which BoringSSL sets. rust-openssl just isn't honoring it. This fixes building against an OpenSSL built with ./config no-ocb
1 parent 9ef1fe3 commit e476f9a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

openssl-sys/build/expando.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ RUST_CONF_OPENSSL_NO_NEXTPROTONEG
7575
RUST_CONF_OPENSSL_NO_OCSP
7676
#endif
7777

78+
#ifdef OPENSSL_NO_OCB
79+
RUST_CONF_OPENSSL_NO_OCB
80+
#endif
81+
7882
#ifdef OPENSSL_NO_PSK
7983
RUST_CONF_OPENSSL_NO_PSK
8084
#endif

openssl/src/symm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Cipher {
142142
}
143143

144144
/// Requires OpenSSL 1.1.0 or newer.
145-
#[cfg(ossl110)]
145+
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
146146
pub fn aes_128_ocb() -> Cipher {
147147
unsafe { Cipher(ffi::EVP_aes_128_ocb()) }
148148
}
@@ -187,7 +187,7 @@ impl Cipher {
187187
}
188188

189189
/// Requires OpenSSL 1.1.0 or newer.
190-
#[cfg(ossl110)]
190+
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
191191
pub fn aes_192_ocb() -> Cipher {
192192
unsafe { Cipher(ffi::EVP_aes_192_ocb()) }
193193
}
@@ -237,7 +237,7 @@ impl Cipher {
237237
}
238238

239239
/// Requires OpenSSL 1.1.0 or newer.
240-
#[cfg(ossl110)]
240+
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
241241
pub fn aes_256_ocb() -> Cipher {
242242
unsafe { Cipher(ffi::EVP_aes_256_ocb()) }
243243
}
@@ -402,14 +402,14 @@ impl Cipher {
402402
}
403403

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

412-
#[cfg(not(ossl110))]
412+
#[cfg(any(not(ossl110), osslconf = "OPENSSL_NO_OCB"))]
413413
const fn is_ocb(self) -> bool {
414414
false
415415
}
@@ -1422,7 +1422,7 @@ mod tests {
14221422
}
14231423

14241424
#[test]
1425-
#[cfg(ossl110)]
1425+
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
14261426
fn test_aes_128_ocb() {
14271427
let key = "000102030405060708090a0b0c0d0e0f";
14281428
let aad = "0001020304050607";
@@ -1458,7 +1458,7 @@ mod tests {
14581458
}
14591459

14601460
#[test]
1461-
#[cfg(ossl110)]
1461+
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_OCB")))]
14621462
fn test_aes_128_ocb_fail() {
14631463
let key = "000102030405060708090a0b0c0d0e0f";
14641464
let aad = "0001020304050607";

0 commit comments

Comments
 (0)