<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sorry, I meant to include the config information in my previous email. I should probably go back to the beginning, I've been trying a lot of different combinations without success, so unwinding to the beginning and taking one step at a time is probably appropriate.
 Since I want the FIPS changes limited to my application only, this is based on the response from Dr. Paul Dale earlier in the thread, the first approach he recommended, so the application code looks like this:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
    fipsp = OSSL_PROVIDER_load(fips_libctx, "fips");
<div>    if (fipsp == NULL)</div>
<div>      {</div>
<div>        // error handling</div>
<div>     }</div>
<div>    </div>
<div>    basep = OSSL_PROVIDER_load(fips_libctx, "base"); /* can't load keys without this */</div>
<div>    if (basep == NULL)</div>
<div>      {</div>
<div>        /* error handling */</div>
<div>       }</div>
<div>   <br>
</div>
<div>    defp = OSSL_PROVIDER_load(non_fips_libctx, "default");</div>
<div>    if (defp == NULL)</div>
<div>      {</div>
<div>        /* error handling */</div>
<div><br>
</div>
<span>      }</span><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Since I'm back to not using my own config file, this is the relevant content in /usr/local/ssl/openssl.cnf. Again, from Dr. Paul Dale's advice of needing a FIPS section, and not needing base or default sections:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">openssl_conf = openssl_init<br>
</span></div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
.include /usr/local/ssl/fipsmodule.cnf
<div><br>
</div>
<div>[openssl_init]</div>
<div>providers = provider_sect</div>
<div><br>
</div>
<div># List of providers to load</div>
<div>[provider_sect]</div>
<div>default = default_sect</div>
<div># The fips section name should match the section name inside the</div>
<div># included fipsmodule.cnf.</div>
<span>fips = fips_sect</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>[default_sect]<br>
<span># activate = 1</span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span>Here is the /usr/local/ssl/fipsmodule.cnf file:</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span>[fips_sect]
<div>activate = 1</div>
<div>conditional-errors = 1</div>
<div>security-checks = 1</div>
<span>module-mac = E4:0D:C8:C3:1E:DB:2B:30:E6:F2:49:7B:F5:BD:10:5C:9A:2B:CC:C1:33:49:31:B5:C5:AF:50:AB:82:1E:AE:C9</span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span><span><br>
</span></span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
With these config files and the code above, the <span style="background-color:rgb(255, 255, 255);display:inline !important">OSSL_PROVIDER_load(fips_libctx, "fips") call fails. Here are the messages from the ERR_print_errors_fp() call:</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important">2097C692B57F0000:error:1C8000D5:Provider routines:(unknown function):missing config data:providers/fips/self_test.c:289:
<div>2097C692B57F0000:error:1C8000E0:Provider routines:(unknown function):fips module entering error state:providers/fips/self_test.c:387:</div>
<div>2097C692B57F0000:error:1C8000D8:Provider routines:(unknown function):self test post failure:providers/fips/fipsprov.c:706:</div>
<span>2097C692B57F0000:error:078C0105:common libcrypto routines:(unknown function):init fail:crypto/provider_core.c:903:name=fips</span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span>So this does seem like I have something wrong as far as setup/install or configuration. I'm not sure if it's something in the config files above, or something with my application
 being able to find the fips.so, which was also mentioned. The code above in self_test.c that's throwing the error looks like the st parameter to SELF_TESET_post() is NULL, but I'm not sure what the actual problem is. The self test isn't set up to run correctly,
 the self test failed, maybe both, or maybe something else?</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span>One of the links from Matt included a function  OSSL_PROVIDER_set_default_search_path(). I'm wondering if that's needed since I don't have any environment variables set up? I'm
 not sure what the default search path is. </span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span>Jason</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><span><span><br>
</span></span></span></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matt Caswell <matt@openssl.org><br>
<b>Sent:</b> Wednesday, October 27, 2021 10:34 AM<br>
<b>To:</b> Jason Schultz <jetson23@hotmail.com>; Dr Paul Dale <pauli@openssl.org>; openssl-users@openssl.org <openssl-users@openssl.org><br>
<b>Subject:</b> Re: OpenSSL 3.0 FIPS questions</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText"><br>
<br>
On 26/10/2021 20:17, Jason Schultz wrote:<br>
> Thanks for all of the help so far. Unfortunately, I'm still struggling <br>
> with this. There could be a number of issues, starting with the <br>
> installation of OpenSSL. I basically followed the documentation and did <br>
> the following:<br>
> <br>
> ./Configure enable-fips<br>
> <br>
> make<br>
> <br>
> make test<br>
> <br>
> make install<br>
> <br>
> <br>
> The "make test" actually fails, but I did not troubleshoot as it seems <br>
> like a lot of systems have issues here. But I know the .so produced when <br>
> I build my application is linking to the correct OpenSSL libraries <br>
> (libssl.so.3 and libcrypto.so.3). Checking the OpenSSL version shows 3.0.<br>
> <br>
> I've tried a number of combinations trying to make this work, starting <br>
> with the code from Dr. Paul Dale in a previous message:<br>
> <br>
>      fips_libctx = OSSL_LIB_CTX_new();<br>
>      if (!fips_libctx)<br>
>          // error handling<br>
> <br>
>      non_fips_libctx = OSSL_LIB_CTX_new();<br>
>      if (!non_fips_libctx)<br>
>          // error handling<br>
> <br>
>      fipsp = OSSL_PROVIDER_load(fips_libctx, "fips");<br>
>      if (fipsp == NULL)<br>
>        {<br>
>          /* error handling */<br>
>        }<br>
> <br>
>      basep = OSSL_PROVIDER_load(fips_libctx, "base");<br>
>      if (basep == NULL)<br>
>        {<br>
>          /* error handling */<br>
>        }<br>
> <br>
>      defp = OSSL_PROVIDER_load(non_fips_libctx, "default");<br>
>      if (defp == NULL)<br>
>        {<br>
>          /* error handling */<br>
>        }<br>
> <br>
>      /* Disallow falling back to the default library context */<br>
>      nullp = OSSL_PROVIDER_load(NULL, "null");<br>
>      if (nullp == NULL)<br>
>        {<br>
>          /*error handling */<br>
>        }<br>
> <br>
> With the code like the above, the OSSL_PROVIDER_load() calls fails for <br>
> fips. If I try to use the fips_libctx in SSL_CTX_new_ex(), it fails and <br>
> returns NULL, which is probably expected given the fips provider didn't <br>
> load.<br>
> <br>
> At that point, I wasn't sure if my application was using the (correct) <br>
> config file in /usr/local/ssl/. I don't have any environment variables <br>
> set up, and would prefer not to have to set any to get this to work. So <br>
> I changed the provider load for FIPS to use OSSL_LIB_CTX_load_config():<br>
> <br>
>      if (!OSSL_LIB_CTX_load_config(fips_libctx, <br>
> "/usr/local/ssl/openssl-fips.cnf"))<br>
<br>
What is in the /usr/local/ssl/openssl-fips.cnf config file?<br>
<br>
Does the config file attempt to activate the FIPS provider itself? Does <br>
it supply the necessary FIPS provider config parameters?<br>
<br>
Typically the config file has a ".include" directive in it which <br>
includes the necessary FIPS config params. That included file will look <br>
something like this:<br>
<br>
$ cat fipsmodule.cnf<br>
<br>
[fips_sect]<br>
<br>
activate = 1<br>
<br>
conditional-errors = 1<br>
<br>
security-checks = 1<br>
<br>
module-mac = <br>
95:06:06:D1:85:17:92:F6:7B:7D:C2:43:36:A4:59:5D:75:6F:39:E6:13:0B:4B:26:5A:1B:48:78:33:5B:BE:F0<br>
<br>
Most likely what is happening is that the FIPS provider is failing to <br>
load. Either because it cannot find the fips.so file, or because the <br>
necessary FIPS config parameters above are not found or not correct.<br>
<br>
You can test whether a provider is actually available for use or not <br>
using the OSSL_PROVIDER_available() function call. E.g.:<br>
<br>
if (!OSSL_PROVIDER_available(fips_libctx, "fips")) {<br>
     /* error handling */<br>
}<br>
<br>
<a href="https://www.openssl.org/docs/man3.0/man3/OSSL_PROVIDER_available.html">https://www.openssl.org/docs/man3.0/man3/OSSL_PROVIDER_available.html</a><br>
<br>
If things are failing then you might find it helpful to dump the OpenSSL <br>
error stack to try and get some clues as to what the problem might be, e.g.<br>
<br>
ERR_print_errors_fp(stdout);<br>
<br>
<a href="https://www.openssl.org/docs/man3.0/man3/ERR_print_errors_fp.html">https://www.openssl.org/docs/man3.0/man3/ERR_print_errors_fp.html</a><br>
<br>
Matt<br>
<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>