<div dir="auto"><div>Thanks for reply. It really help to use fips lib.</div><div dir="auto"><br></div><div dir="auto">I have another doubts regarding the hmac stored in <span style="font-family:sans-serif">fipsinstall.conf. If some one modify the fips library after installation and modify the hmac in fipsinstall.conf accordingly, is openssl3.0 is able to identify this and fail the fips library loading.? </span></div><div dir="auto"><font face="sans-serif"><br></font></div><div dir="auto"><font face="sans-serif">fipsinstall.conf should be protected from corruption or modification?  If yes, current mechanism is able to that or not? <br></font><div dir="auto"><br></div>Regards</div><div dir="auto">Manish<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Thu, 16 Jan 2020, 8:29 pm Matt Caswell, <<a href="mailto:matt@openssl.org">matt@openssl.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 14/01/2020 04:51, Manish Patidar wrote:<br>
> Hi<br>
> <br>
> Can any guide me how to use fips api in openssl?<br>
> <br>
> I try to use like below but it always returns null. <br>
> <br>
> ctx = EVP_CIPHER_CTX_new() ;<br>
> ciph = EVP_CIPHER_fetch(NULL, "aes-128-cbc", "fips=yes") ;<br>
> <br>
> I am doubting fips provider is not loaded.  <br>
<br>
<br>
Right - the FIPS provider does not get loaded by default.<br>
<br>
First set some environment variables which will make the whole process a<br>
bit easier. The OpenSSL libraries read these to locate the various files:<br>
<br>
export OPENSSL_CONF_INCLUDE=/path/to/include/dir<br>
export OPENSSL_MODULES=/path/to/providers/dir<br>
export OPENSSL_CONF=/path/to/fips.cnf<br>
<br>
Next you will need to "install" the FIPS module. This will create a<br>
fipsinstall.conf file:<br>
<br>
openssl fipsinstall -out $OPENSSL_CONF_INCLUDE/fipsinstall.conf -module<br>
$OPENSSL_MODULES/fips.so -provider_name fips -mac_name HMAC -macopt<br>
'digest:SHA256' -macopt 'hexkey:00' -section_name fips_sect<br>
<br>
(Aside: probably we should do the above as part of "make install", but<br>
we don't do that AFAIK at the moment)<br>
<br>
Now create a config file to automatically load the FIPS module when<br>
OpenSSL starts. Store it in the file pointed to by $OPENSSL_CONF<br>
<br>
openssl_conf = openssl_init<br>
<br>
.include fipsinstall.conf<br>
<br>
[openssl_init]<br>
providers = provider_sect<br>
<br>
[provider_sect]<br>
fips = fips_sect<br>
<br>
<br>
This will have the effect of automatically loading the FIPS provider<br>
*and no others*. In this case you don't need the "fips=yes" in your<br>
EVP_CIPHER_fetch() call because there are no other providers loaded<br>
(although it does no harm).<br>
<br>
Alternatively you can load both the default and FIPS providers at the<br>
same time:<br>
<br>
openssl_conf = openssl_init<br>
<br>
.include fipsinstall.conf<br>
<br>
[openssl_init]<br>
providers = provider_sect<br>
<br>
[provider_sect]<br>
default = default_sect<br>
fips = fips_sect<br>
<br>
[default_sect]<br>
activate = 1<br>
<br>
In this case you will need to specify "fips=yes" in the fetch to<br>
disambiguate which implementation you want.<br>
<br>
Hope that helps,<br>
<br>
Matt<br>
</blockquote></div></div></div>