I am new to openssl, and I downloaded openssl-fips-2.0.1 codes from openssl, however, I was not able to trace to the definition of FIPS_mode_set() as stated in the documentation and security policy. I did find, however, fips_set_mode() in fips.c, but they are not referring to the same, am I right?
Where is the definition? Please advise me.
You have to know how to ask...
The declaration is in
crypto/crypto.h
and the definition is incrypto/o_fips.c
. Here's fromo_fips.c
:If you were looking for
FIPS_mode_set
to enter into "FIPS mode" with special setup or switch some algorithms, that does not happen at this step.It happens earlier when linking. What happens under the hood is
fipsld
is you compiler, and it looks for an invocation ofLD
. IfLD
is not invoked, thenfipsld
just calls your regular compiler (probably/usr/bin/gcc
). If it sees an invocation ofLD
, then it does three things.First, it compiles
fips_premin.c
. Then it calls the realld
to perform the final link with all your object file and thefips_premain.o
it produced. Finally, it callsincore
to swap in the FIPS Object Module, calculate the signature over the relevanttext
anddata
(relevant means the FIPS code and data), and then embeds the signature in the executable.The signature is generated with an HMAC, and the key is embedded in the executable. There's nothing special about it, and its constant across all executables throughout the world. Here's the key used:
etaonrishdlcupfm
.If you are not taking special steps when build your executable, then you are probably missing some steps. Here are the steps to use
fipsld
andincore
:Now, do a standard
config
andmake
. Sometimes you have to doconfig
, then adjustCC
andFIPSLD_CC
, and then runmake
because someconfig
files choke on the arrangement. Sometimes you have to open aMakefile
afterconfig
and changeCC
to/usr/local/ssl/fips-2.0/bin/fipsld
. There's lots of ways to do it in an effort to work around particular packaging.openssl-fips-NNN
provides the FIPS validated cryptography if you build the FIPS Object Module according to the Security Policy. You can find the OpenSSL FIPS 1402- Security Policy at here.If all you did was download and build
openssl-fips-NNN
, then you are probably not using FIPS validated cryptography. There's a procedure to follow, and that includes getting a "trusted" copy of the source code. You can download and verify a signature, but you need a FIPS validated signature checker, which creates a chicken-and-the-egg problem because you can't build it from sources. So the practical solution is to order the CD from the OpenSSL Foundation. Its bizarre, but its the truth. See, for example, the OpenSSL FIPS User Guide or the OpenSSL FIPS Security Policy, Appendix B, Controlled Distribution File Fingerprint.Once you have the FIPS Object Module built and installed, you can build the FIPS Capable version of the library. The FIPS Capable OpenSSL will use the FIPS Object Module, if available. Think of it as a "pluggable" architecture.
The FIPS Capable version of the library is simply
openssl-NNN
, such asopenssl-1.0.1e
andopenssl-1.0.1f
. Its what you know and love.You might also consider something like
ctags
as a source code browser to help you find things and jump around. See Exuberant Ctags on Sourceforge.