boring/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;
7use openssl_macros::corresponds;
8
9/// Determines if the library is running in the FIPS 140-2 mode of operation.
10#[corresponds(FIPS_mode)]
11#[must_use]
12pub fn enabled() -> bool {
13 unsafe { ffi::FIPS_mode() != 0 }
14}
15
16#[test]
17fn is_enabled() {
18 #[cfg(feature = "fips")]
19 assert!(enabled());
20 #[cfg(not(feature = "fips"))]
21 assert!(!enabled());
22}