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
6 use crate::cvt;
7 use crate::error::ErrorStack;
8 
9 /// Moves the library into or out of the FIPS 140-2 mode of operation.
10 ///
11 /// This corresponds to `FIPS_mode_set`.
enable(enabled: bool) -> Result<(), ErrorStack>12 pub fn enable(enabled: bool) -> Result<(), ErrorStack> {
13     ffi::init();
14     unsafe { cvt(ffi::FIPS_mode_set(enabled as _)).map(|_| ()) }
15 }
16 
17 /// Determines if the library is running in the FIPS 140-2 mode of operation.
18 ///
19 /// This corresponds to `FIPS_mode`.
enabled() -> bool20 pub fn enabled() -> bool {
21     unsafe { ffi::FIPS_mode() != 0 }
22 }
23