Skip to content

Commit 1db54d2

Browse files
committed
Enable compliance policy when in FIPS mode
1 parent a33bb90 commit 1db54d2

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

boring-sys/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ fn get_boringssl_cmake_config() -> cmake::Config {
308308

309309
/// Verify that the toolchains match https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp3678.pdf
310310
/// See "Installation Instructions" under section 12.1.
311+
// TODO: update above URL once BoringCrypto CMVP certification for `fips-20220613` is approved
311312
// TODO: maybe this should also verify the Go and Ninja versions? But those haven't been an issue in practice ...
312313
fn verify_fips_clang_version() -> (&'static str, &'static str) {
313314
fn version(tool: &str) -> String {

boring/src/fips.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//! FIPS 140-2 support.
1+
//! FIPS 140-3 support.
22
//!
33
//! See [OpenSSL's documentation] for details.
44
//!
55
//! [OpenSSL's documentation]: https://www.openssl.org/docs/fips/UserGuide-2.0.pdf
66
use crate::ffi;
77

8-
/// Determines if the library is running in the FIPS 140-2 mode of operation.
8+
/// Determines if the library is running in the FIPS 140-3 mode of operation.
99
///
1010
/// This corresponds to `FIPS_mode`.
1111
pub fn enabled() -> bool {

boring/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
//!
4242
//! ## Building with a FIPS-validated module
4343
//!
44-
//! Only BoringCrypto module version `853ca1ea1168dff08011e5d42d94609cc0ca2e27`, as certified with
45-
//! [FIPS 140-2 certificate 4407](https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/4407)
44+
//! Only BoringCrypto module version `0c6f40132b828e92ba365c6b7680e32820c63fa7`, as certified with
45+
//! [FIPS 140-3 certificate XXX](https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/XXX)
4646
//! is supported by this crate. Support is enabled by this crate's `fips` feature.
4747
//!
4848
//! `boring-sys` comes with a test that FIPS is enabled/disabled depending on the feature flag. You can run it as follows:

boring/src/ssl/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,8 @@ impl SslCurve {
703703

704704
/// A compliance policy.
705705
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
706-
#[cfg(not(feature = "fips"))]
707706
pub struct CompliancePolicy(ffi::ssl_compliance_policy_t);
708707

709-
#[cfg(not(feature = "fips"))]
710708
impl CompliancePolicy {
711709
/// Does nothing, however setting this does not undo other policies, so trying to set this is an error.
712710
pub const NONE: Self = Self(ffi::ssl_compliance_policy_t::ssl_compliance_policy_none);
@@ -826,6 +824,9 @@ impl SslContextBuilder {
826824
init();
827825
let ctx = cvt_p(ffi::SSL_CTX_new(method.as_ptr()))?;
828826

827+
#[cfg(feature = "fips")]
828+
ctx.set_compliance_policy(CompliancePolicy::FIPS_202205).unwrap();
829+
829830
#[cfg(feature = "rpk")]
830831
{
831832
Ok(SslContextBuilder::from_ptr(ctx, false))
@@ -1896,8 +1897,6 @@ impl SslContextBuilder {
18961897
/// This corresponds to [`SSL_CTX_set_compliance_policy`]
18971898
///
18981899
/// [`SSL_CTX_set_compliance_policy`] https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html#SSL_CTX_set_compliance_policy
1899-
/// This feature isn't available in the certified version of BoringSSL.
1900-
#[cfg(not(feature = "fips"))]
19011900
pub fn set_compliance_policy(&mut self, policy: CompliancePolicy) -> Result<(), ErrorStack> {
19021901
unsafe { cvt_0i(ffi::SSL_CTX_set_compliance_policy(self.as_ptr(), policy.0)).map(|_| ()) }
19031902
}

boring/src/ssl/test/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::ssl::{
2121
use crate::x509::verify::X509CheckFlags;
2222
use crate::x509::{X509Name, X509};
2323

24-
#[cfg(not(feature = "fips"))]
2524
use super::CompliancePolicy;
2625

2726
mod custom_verify;
@@ -948,7 +947,6 @@ fn test_get_ciphers() {
948947
}
949948

950949
#[test]
951-
#[cfg(not(feature = "fips"))]
952950
fn test_set_compliance() {
953951
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
954952
ctx.set_compliance_policy(CompliancePolicy::FIPS_202205)

0 commit comments

Comments
 (0)