Skip to content

Commit 17b0986

Browse files
committed
Decouple "fips-compat" from "fips"
Modify the "fips" feature so that it no longer implies "fips-compat". The latter is no longer needed for recent builds of boringSSL; users who need older builds will need to enable "fips-compat" explicitly.
1 parent f73439d commit 17b0986

File tree

7 files changed

+21
-38
lines changed

7 files changed

+21
-38
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ jobs:
263263
working-directory: ${{ runner.temp }}/llvm/bin
264264
run: ln -s clang clang++-12
265265
- name: Run tests
266-
run: cargo test --features fips
266+
run: cargo test --features fips,fips-compat
267267
- name: Test boring-sys cargo publish (FIPS)
268268
# Running `cargo publish --dry-run` tests two things:
269269
#
@@ -338,7 +338,7 @@ jobs:
338338
- name: Set CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER
339339
run: echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=${{ matrix.target }}-gcc" >> $GITHUB_ENV
340340
- name: Build for ${{ matrix.target }}
341-
run: cargo build --target ${{ matrix.target }} --all-targets --features fips
341+
run: cargo build --target ${{ matrix.target }} --all-targets --features fips,fips-compat
342342

343343
test-features:
344344
name: Test features

boring-sys/build/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ fn main() {
760760
"des.h",
761761
"dtls1.h",
762762
"hkdf.h",
763-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
763+
#[cfg(not(feature = "fips"))]
764764
"hpke.h",
765765
"hmac.h",
766766
"hrss.h",

boring/Cargo.toml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,13 @@ rustdoc-args = ["--cfg", "docsrs"]
1919
[features]
2020
# Controlling the build
2121

22-
# Use a FIPS-validated version of BoringSSL. This feature sets "fips-compat".
23-
fips = ["fips-compat", "boring-sys/fips"]
22+
# Use a FIPS-validated version of BoringSSL. Note that depending on how old the
23+
# version you're using, is, you may also need `fips-compat`.
24+
fips = ["boring-sys/fips"]
2425

25-
# Use a FIPS build of BoringSSL, but don't set "fips-compat".
26-
#
27-
# As of boringSSL commit a430310d6563c0734ddafca7731570dfb683dc19, we no longer
28-
# need to make exceptions for the types of BufLen, ProtosLen, and ValueLen,
29-
# which means the "fips-compat" feature is no longer needed.
30-
#
31-
# TODO(cjpatton) Delete this feature and modify "fips" so that it doesn't imply
32-
# "fips-compat".
33-
fips-no-compat = ["boring-sys/fips"]
34-
35-
# Build with compatibility for the BoringSSL FIPS version, without enabling the
36-
# `fips` feature itself (useful e.g. if `fips-link-precompiled` is used with an
37-
# older BoringSSL version).
26+
# Build with compatibility for older versions of boringSSL, primarily
27+
# fips-20220613. This feature doesn't enable `fips` itself, which is useful if,
28+
# e.g., you use `fips-link-precompiled`.
3829
fips-compat = []
3930

4031
# Link with precompiled FIPS-validated `bcm.o` module.

boring/src/fips.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,8 @@ pub fn enabled() -> bool {
1414

1515
#[test]
1616
fn is_enabled() {
17-
#[cfg(any(
18-
feature = "fips",
19-
feature = "fips-no-compat",
20-
feature = "fips-link-precompiled"
21-
))]
17+
#[cfg(any(feature = "fips", feature = "fips-link-precompiled"))]
2218
assert!(enabled());
23-
#[cfg(not(any(
24-
feature = "fips",
25-
feature = "fips-no-compat",
26-
feature = "fips-link-precompiled"
27-
)))]
19+
#[cfg(not(any(feature = "fips", feature = "fips-link-precompiled")))]
2820
assert!(!enabled());
2921
}

boring/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub mod error;
128128
pub mod ex_data;
129129
pub mod fips;
130130
pub mod hash;
131-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
131+
#[cfg(not(feature = "fips"))]
132132
pub mod hpke;
133133
pub mod memcmp;
134134
pub mod nid;

boring/src/ssl/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ pub use self::async_callbacks::{
104104
pub use self::connector::{
105105
ConnectConfiguration, SslAcceptor, SslAcceptorBuilder, SslConnector, SslConnectorBuilder,
106106
};
107-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
107+
#[cfg(not(feature = "fips"))]
108108
pub use self::ech::{SslEchKeys, SslEchKeysRef};
109109
pub use self::error::{Error, ErrorCode, HandshakeError};
110110

111111
mod async_callbacks;
112112
mod bio;
113113
mod callbacks;
114114
mod connector;
115-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
115+
#[cfg(not(feature = "fips"))]
116116
mod ech;
117117
mod error;
118118
mod mut_only;
@@ -714,7 +714,7 @@ impl SslCurve {
714714

715715
pub const X25519: SslCurve = SslCurve(ffi::SSL_CURVE_X25519 as _);
716716

717-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
717+
#[cfg(not(feature = "fips"))]
718718
pub const X25519_KYBER768_DRAFT00: SslCurve =
719719
SslCurve(ffi::SSL_CURVE_X25519_KYBER768_DRAFT00 as _);
720720

@@ -759,7 +759,7 @@ impl SslCurve {
759759
ffi::SSL_CURVE_SECP384R1 => Some(ffi::NID_secp384r1),
760760
ffi::SSL_CURVE_SECP521R1 => Some(ffi::NID_secp521r1),
761761
ffi::SSL_CURVE_X25519 => Some(ffi::NID_X25519),
762-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
762+
#[cfg(not(feature = "fips"))]
763763
ffi::SSL_CURVE_X25519_KYBER768_DRAFT00 => Some(ffi::NID_X25519Kyber768Draft00),
764764
#[cfg(feature = "pq-experimental")]
765765
ffi::SSL_CURVE_X25519_KYBER768_DRAFT00_OLD => Some(ffi::NID_X25519Kyber768Draft00Old),
@@ -2010,7 +2010,7 @@ impl SslContextBuilder {
20102010
/// ECHConfigs to allow stale DNS caches to update. Unlike most `SSL_CTX` APIs, this function
20112011
/// is safe to call even after the `SSL_CTX` has been associated with connections on various
20122012
/// threads.
2013-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
2013+
#[cfg(not(feature = "fips"))]
20142014
#[corresponds(SSL_CTX_set1_ech_keys)]
20152015
pub fn set_ech_keys(&self, keys: &SslEchKeys) -> Result<(), ErrorStack> {
20162016
unsafe { cvt(ffi::SSL_CTX_set1_ech_keys(self.as_ptr(), keys.as_ptr())).map(|_| ()) }
@@ -2267,7 +2267,7 @@ impl SslContextRef {
22672267
/// ECHConfigs to allow stale DNS caches to update. Unlike most `SSL_CTX` APIs, this function
22682268
/// is safe to call even after the `SSL_CTX` has been associated with connections on various
22692269
/// threads.
2270-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
2270+
#[cfg(not(feature = "fips"))]
22712271
#[corresponds(SSL_CTX_set1_ech_keys)]
22722272
pub fn set_ech_keys(&self, keys: &SslEchKeys) -> Result<(), ErrorStack> {
22732273
unsafe { cvt(ffi::SSL_CTX_set1_ech_keys(self.as_ptr(), keys.as_ptr())).map(|_| ()) }

boring/src/ssl/test/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ use crate::ssl::{
2121
use crate::x509::verify::X509CheckFlags;
2222
use crate::x509::{X509Name, X509};
2323

24-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
24+
#[cfg(not(feature = "fips"))]
2525
use super::CompliancePolicy;
2626

2727
mod cert_compressor;
2828
mod cert_verify;
2929
mod custom_verify;
30-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
30+
#[cfg(not(feature = "fips"))]
3131
mod ech;
3232
mod private_key_method;
3333
mod server;
@@ -990,7 +990,7 @@ fn test_get_ciphers() {
990990
}
991991

992992
#[test]
993-
#[cfg(not(any(feature = "fips", feature = "fips-no-compat")))]
993+
#[cfg(not(feature = "fips"))]
994994
fn test_set_compliance() {
995995
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
996996
ctx.set_compliance_policy(CompliancePolicy::FIPS_202205)

0 commit comments

Comments
 (0)