boring_imp/
fips.rs

1//! FIPS 140-2 support.
2//!
3//! See [OpenSSL's documentation] for details.
4//!
5//! [OpenSSL's documentation]: https://www.openssl.org/docs/fips/UserGuide-2.0.pdf
6use crate::ffi;
7
8/// Determines if the library is running in the FIPS 140-2 mode of operation.
9///
10/// This corresponds to `FIPS_mode`.
11pub fn enabled() -> bool {
12    unsafe { ffi::FIPS_mode() != 0 }
13}
14
15#[test]
16fn is_enabled() {
17    #[cfg(any(feature = "fips", feature = "fips-link-precompiled"))]
18    assert!(enabled());
19    #[cfg(not(any(feature = "fips", feature = "fips-link-precompiled")))]
20    assert!(!enabled());
21}