Skip to contentSkip to conversation

crypto: Fix OPENSSL_FIPS enabled builds

PATCH Superseded David Sommerseth 3 participants 4 messages Jan 19, 2022

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: Fix OPENSSL_FIPS enabled builds

From: David Sommerseth <[email protected]...>

On Fedora and RHEL/CentOS, the standard OpenSSL library has the FIPS module enabled by default. This revealed some incompatible code with the added DCO support.

---
 src/openvpn/crypto.c | 3 +++
 1 file changed, 3 insertions(+)
src/openvpn/crypto.c +3 -0
index 5626e2b6..0415f59d 100644
@@ -34,6 +34,7 @@
 #include "error.h"
 #include "integer.h"
 #include "platform.h"
+#include "openssl_compat.h"
 
 #include "memdbg.h"
 
@@ -1704,6 +1705,8 @@ print_cipher(const char *ciphername)
         printf(", TLS client/server mode only");
     }
 #ifdef OPENSSL_FIPS
+    evp_cipher_type *cipher = EVP_CIPHER_fetch(NULL, ciphername, NULL);
+
     if (FIPS_mode() && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_FIPS))
     {
         printf(", disabled by FIPS mode");
Signature · 1 line
2.27.0
#1 lore raw

Hi David,

Quoted 24 lines · David Sommerseth

From: David Sommerseth <[email protected]...>

On Fedora and RHEL/CentOS, the standard OpenSSL library has the FIPS module enabled by default. This revealed some incompatible code with the added DCO support.

---
  src/openvpn/crypto.c | 3 +++
  1 file changed, 3 insertions(+)
src/openvpn/crypto.c +1 -0
index 5626e2b6..0415f59d 100644
@@ -34,6 +34,7 @@
  #include "error.h"
  #include "integer.h"
  #include "platform.h"
+#include "openssl_compat.h"
 
  #include "memdbg.h"
 

src/openvpn/crypto.c print_cipher(const char *ciphername) · line 1709

Quoted 5 lines
src/openvpn/crypto.c +2 -0
@@ -1704,6 +1705,8 @@ print_cipher(const char *ciphername)
          printf(", TLS client/server mode only");
      }
  #ifdef OPENSSL_FIPS
+    evp_cipher_type *cipher = EVP_CIPHER_fetch(NULL, ciphername, NULL);
+

from the commit message it is clear that there are incompatibilities, but I am unable to guess what the real problem is.

Maybe you could extend your commit message or add a comment here?

How is declaring a non-used variable going to help?
Oh, now I see that cipher is used but was never declared/initialized. Still worth a word in the commit message? ;-)

On top of that, anything returned by EVP_get_cipherbyname() must be free'd later, or it will result in a memory leak.

On top of that ²: should we add some FIPS build to our GH Actions (for another patch of course)?

Regards,

Quoted 3 lines
src/openvpn/crypto.c +0 -0
      if (FIPS_mode() && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_FIPS))
      {
          printf(", disabled by FIPS mode");
Signature · 1 line
Antonio Quartulli
#2 lore raw
Quoted 33 lines · Antonio Quartulli

Hi David,

Quoted 22 lines · David Sommerseth

From: David Sommerseth <[email protected]...>

On Fedora and RHEL/CentOS, the standard OpenSSL library has the FIPS module enabled by default.  This revealed some incompatible code with the added DCO support.

---
  src/openvpn/crypto.c | 3 +++

  1 file changed, 3 insertions(+)
src/openvpn/crypto.c +1 -0
index 5626e2b6..0415f59d 100644
@@ -34,6 +34,7 @@
   #include "error.h"
   #include "integer.h"
   #include "platform.h"
+#include "openssl_compat.h"
   #include "memdbg.h"

src/openvpn/crypto.c print_cipher(const char *ciphername) · line 1709

Quoted 5 lines
src/openvpn/crypto.c +2 -0
@@ -1704,6 +1705,8 @@ print_cipher(const char *ciphername)
           printf(", TLS client/server mode only");
       }
   #ifdef OPENSSL_FIPS
+    evp_cipher_type *cipher = EVP_CIPHER_fetch(NULL, ciphername, NULL);
+

from the commit message it is clear that there are incompatibilities, but I am unable to guess what the real problem is.

Quoted 1 line

Maybe you could extend your commit message or add a comment here?

Will do!

Quoted 2 lines

How is declaring a non-used variable going to help > Oh, now I see that cipher is used but was never declared/initialized. Still worth a word in the commit message? ;-)

Yes!

Quoted 1 line

On top of that, anything returned by EVP_get_cipherbyname() must be free'd later, or it will result in a memory leak.

Will fix!

Quoted 1 line

On top of that ²: should we add some FIPS build to our GH Actions (for another patch of course)?

This exploded on stock Fedora 35 inside a mock build chroot, no FIPS enabling required. The devil in the detail is that the OPENSSL_FIPS macro is defined unconditionally in /usr/include/openssl/opensslconf-x86_64.h. So our OPENSSL_FIPS blocks are always built on Fedora and related downstream distros.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#3 lore raw
In reply to David Sommerseth

Am 19.01.22 um 12:34 schrieb David Sommerseth:

Quoted 24 lines

From: David Sommerseth <[email protected]...>

On Fedora and RHEL/CentOS, the standard OpenSSL library has the FIPS module enabled by default. This revealed some incompatible code with the added DCO support.

---
  src/openvpn/crypto.c | 3 +++
  1 file changed, 3 insertions(+)
src/openvpn/crypto.c +1 -0
index 5626e2b6..0415f59d 100644
@@ -34,6 +34,7 @@
  #include "error.h"
  #include "integer.h"
  #include "platform.h"
+#include "openssl_compat.h"
 
  #include "memdbg.h"
 

src/openvpn/crypto.c print_cipher(const char *ciphername) · line 1709

Quoted 5 lines
src/openvpn/crypto.c +2 -0
@@ -1704,6 +1705,8 @@ print_cipher(const char *ciphername)
          printf(", TLS client/server mode only");
      }
  #ifdef OPENSSL_FIPS
+    evp_cipher_type *cipher = EVP_CIPHER_fetch(NULL, ciphername, NULL);
+

EVP_CIPHER_fetch without EVP_CIPHER_free

Arne