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 cvt; 7 use error::ErrorStack; 8 use ffi; 9 10 /// Moves the library into or out of the FIPS 140-2 mode of operation. 11 /// 12 /// This corresponds to `FIPS_mode_set`. enable(enabled: bool) -> Result<(), ErrorStack>13pub fn enable(enabled: bool) -> Result<(), ErrorStack> { 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() -> bool20pub fn enabled() -> bool { 21 unsafe { ffi::FIPS_mode() != 0 } 22 } 23