FIPS mode is only available with the OpenSSL backend. The Botan backend does not support FIPS 140-2 operation.
Overview
FIPS 140-2 support in OpenSSL is provided through a validated cryptographic module (the “FIPS canister”). To use it, you must:- Build a FIPS-capable OpenSSL static library with position-independent code (PIC).
- Use the
fipsldlinker script (supplied by OpenSSL) as your C and C++ compiler wrapper when building SoftHSM.
Building a FIPS-capable OpenSSL
Obtain a validated OpenSSL source
Download an OpenSSL source release that carries a FIPS 140-2 validation (e.g. OpenSSL 1.0.1e or a later validated version). Consult the CMVP certificate for the exact version.
Build with PIC
The The FIPS module canister is already compiled with PIC, but the surrounding OpenSSL code must be as well.
libsofthsm2.so shared library requires all statically linked code to be compiled as position-independent code. Pass the PIC flag when configuring OpenSSL:Using fipsld as the compiler
fipsld is a shell script that wraps the linker to inject FIPS integrity checks into the final binary. You must set both CC and CXX to fipsld when running ./configure or cmake:
Handling the C/C++ compiler mismatch
A common problem is that the C++ compiler (g++) does not compile.c files as C code. You can verify this with a quick test:
fipsld script, you need a wrapper that inserts -x c and -x none around each .c file in C++ compiler invocations.
Wrapper script
Create a wrapper script (e.g./usr/local/bin/fipsld-wrapper) that calls fipsld but handles .c files correctly:
CXX to your wrapper instead of fipsld directly:
Self-test status
At startup,OSSLCryptoFactory runs the FIPS self-tests required by the module. You can query the result through the CryptoFactory interface:
false and SoftHSM will refuse to perform cryptographic operations.