Skip to contentSkip to conversation

package/luaossl: force libopenssl usage

PATCH New Thomas Perale via buildroot 1 participant 3 messages Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/luaossl: force libopenssl usage

Trying to build luaossl with LibreSSL would result in a number of implicit declaration errors [1].

This can be reproduced with the following defconfig:

```
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUAOSSL=y
BR2_PACKAGE_LIBRESSL=y
```

While the luaossl package originally supported libressl, since libressl version 3.4 (buildroot commit [2]), it's no longer the case and fails with the following error:

```
src/openssl.c: In function ‘compat_SSL_CTX_set1_cert_store’:
src/openssl.c:2152:16: error: invalid use of incomplete typedef ‘SSL_CTX’ {aka ‘struct ssl_ctx_st’}
 2152 |         if (ctx->cert_store) {
      |                ^~

...
src/openssl.c:2175:20: error: invalid use of incomplete typedef ‘SSL_CTX’ {aka ‘struct ssl_ctx_st’}
 2175 |                 ctx->cert_store = NULL;
      |                    ^~
```

Triggered by the upstream project making some structure internal [3].

This error is present on the autobuilder since at least 2022 [4].

This commit then force the usage of libopenssl. The 'Config.in' condition on 'LIBOPENSSL_ENABLE_DES' is then no longer required.

[1] https://autobuild.buildroot.org/results/b77/b777364eb186efdcbcce132f1099b8abe08762d0/build-end.log
[2] 25ef2c26da package/libressl: bump to version 3.4.1
[3] https://github.com/libressl/openbsd/commit/7be6981c90fe38ee2134896c1d9ee7f27a5ac680
[4] https://autobuild.buildroot.org/index.php?reason=luaossl%25&symbols%5BBR2_PACKAGE_LIBRESSL%5D=y

---
 package/luaossl/Config.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/luaossl/Config.in +2 -1
index f84c59f2a0..927c301688 100644
@@ -2,7 +2,8 @@ config BR2_PACKAGE_LUAOSSL
 	bool "luaossl"
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	select BR2_PACKAGE_OPENSSL
-	select BR2_PACKAGE_LIBOPENSSL_ENABLE_DES if BR2_PACKAGE_LIBOPENSSL
+	select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
+	select BR2_PACKAGE_LIBOPENSSL_ENABLE_DES
 	help
 	  luaossl is a comprehensive binding to OpenSSL for Lua 5.1,
 	  5.2, and later.
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/3 package/strongswan: force libopenssl usage

Building the strongswan package with LibreSSL will result in the following error:

```
openssl_util.c: In function 'openssl_wrap_private_key':
openssl_util.c:163:30: error: 'EVP_PKEY_ED448' undeclared (first use in this function); did you mean 'EVP_PKEY_DSA2'?
  163 |                         case EVP_PKEY_ED448:
      |                              ^~~~~~~~~~~~~~
      |                              EVP_PKEY_DSA2
...
```

This can be reproduces with the following defconfig:

```
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_LIBRESSL=y
BR2_PACKAGE_STRONGSWAN=y
BR2_PACKAGE_STRONGSWAN_OPENSSL=y
```

The OpenSSL option had been introduced in strongswan in 2013 [1]. Before the introduction of LibreSSL [2] in 2017.

In version 5.7.2 the upstream project added support for Ed25519/Ed448 (part of buildroot commit [4]). LibreSSL doesn't support ED448.

This commit assume that the strongswan project doesn't support LibreSSL as it appears there isn't any conditional checks for LibreSSL in the codebase.

The oldest autobuild error goes back to 2022 [5].

[1] 89719fce71 strongswan: new package
[2] be76f4dd20 libressl: new package
[3] https://github.com/strongswan/strongswan/commit/cbf07ab5b0b644c7bf5f7177efabc841b230b551
[4] da912a3d2a package/strongswan: bump to version 5.9.0
[5] https://autobuild.buildroot.org/index.php?reason=strongswan%25&symbols[BR2_PACKAGE_LIBRESSL]=y

---
 package/strongswan/Config.in | 1 +
 1 file changed, 1 insertion(+)
package/strongswan/Config.in +1 -0
index 11c0ca7780..9d4cdc7e9a 100644
@@ -46,6 +46,7 @@ comment "botan backend needs a toolchain w/ C++, gcc >= 11"
 config BR2_PACKAGE_STRONGSWAN_OPENSSL
 	bool "OpenSSL"
 	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
 
 config BR2_PACKAGE_STRONGSWAN_GCRYPT
 	bool "libgcrypt"
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 3/3 package/mariadb: fix build with LibreSSL and GCC14

In reply to Thomas Perale via buildroot

The upstream commit [1] changed the function signature of the CRYPTO_set_mem_functions function. This has been introduced in buildroot commit [2].

As a consequence building MariaDB with LibreSSL resulted in the following error:

```
.../buildroot/output/build/mariadb-10.11.18/mysys_ssl/openssl.c:79:45: error: passing argument 2 of ‘CRYPTO_set_mem_functions’ from incompatible pointer type [-Wincompatible-pointer-types]
   79 |   if (!CRYPTO_set_mem_functions(coc_malloc, coc_realloc, coc_free))
      |                                             ^~~~~~~~~~~
      |                                             |
      |                                             void * (*)(void *, size_t) {aka void * (*)(void *, long unsigned int)}
```

This can be reproduced with the following defconfig:

```
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_LIBRESSL=y
BR2_PACKAGE_MARIADB=y
BR2_PACKAGE_MARIADB_SERVER=y
```

This commits adds the upstream patch [3] in the '10.11' stable branch. It will be included in the next release MariaDB release v10.11.20. It doesn't explicitely address the LibreSSL issue but fix it as a side effect since it removes mysys_ssl/openssl.c.

To also address the future support for libopenssl v4 in Buildroot the patch is kept as is and not re-worked.

[1] https://github.com/libressl/openbsd/commit/9175c6902a8e145ca23903d60576f90eb073d460
[2] d6a3f70bee package/libressl: security bump version to 4.3.2
[3] https://github.com/MariaDB/server/commit/fb641b0cd1810e7d148d6b4d70f915c06c2c0f9e

Fixes d6a3f70bee package/libressl: security bump version to 4.3.2
---
 ...and-KDF-return-NULL-with-OpenSSL-4-0.patch | 552 ++++++++++++++++++
 1 file changed, 552 insertions(+)
 create mode 100644 package/mariadb/0003-MDEV-40287-AES_ENCRYPT-and-KDF-return-NULL-with-OpenSSL-4-0.patch
package/mariadb/0003-MDEV-40287-AES_ENCRYPT-and-KDF-return-NULL-with-OpenSSL-4-0.patch new file +552 -0
new file mode 100644
index 0000000000..138bec1685
@@ -0,0 +1,552 @@
+From fb641b0cd1810e7d148d6b4d70f915c06c2c0f9e Mon Sep 17 00:00:00 2001
+From: Vladislav Vaintroub <[email protected]>
+Date: Tue, 20 Oct 2026 01:06:46 +0200
+Subject: [PATCH] MDEV-40287 AES_ENCRYPT() and KDF() return NULL with OpenSSL
+ 4.0
+
+MyCTX used an EVP_CIPHER_CTX in a stack buffer instead of allocating it
+with EVP_CIPHER_CTX_new(). OpenSSL 4.0 rejects a context that was not
+created that way for ciphers that use an IV: EVP_CipherInit_ex() fails
+with "invalid iv length", so AES_ENCRYPT() and KDF() in CBC/CTR/GCM
+modes return NULL. ECB has no IV and still works, which is why only the
+non-ECB modes broke.
+
+Allocate the context with EVP_CIPHER_CTX_new()/EVP_CIPHER_CTX_free(), and
+on an init error free and null it, so a later update()/finish() from a
+caller that ignored the error is a safe no-op, not a double free. Remove
+check_openssl_compatibility() and the EVP_CIPHER_CTX_SIZE and
+EVP_CIPHER_CTX_init macros.
+
+my_md5() used the same stack-buffer-sized-by-EVP_MD_CTX_SIZE hack, whose
+only guard was check_openssl_compatibility(). MD5_CTX is a concrete struct
+in both OpenSSL and WolfSSL, so use it directly with MD5_Init/Update/Final
+on a caller-owned context, like my_sha.inl does for SHA*_CTX; this removes
+the EVP_MD_CTX hack and EVP_MD_CTX_SIZE. The exception is OpenSSL 1.0.x,
+which aborts on the low-level MD5 API in FIPS mode (MDEV-7788): there, and
+only there, keep the EVP path with the non-FIPS flag. 1.1.0 removed the
+FIPS Object Module and 3.0+ low-level MD5 bypasses the provider, so the
+concrete MD5_CTX is correct on every other version. SHA is unaffected, it
+already used concrete SHA*_CTX structs.
+
+Verified against OpenSSL 4.0.1: the mysys aes-t test fails on the
+CBC/CTR/GCM cases with the stack buffer and passes with
+EVP_CIPHER_CTX_new(). The 1.0.x MD5 path verified against a FIPS build of
+OpenSSL 1.0.2u: the EVP path computes MD5, the low-level path aborts.
+
+No visible performance degradation: the extra allocation costs
+~12 ns/call (WolfSSL) and ~30 ns (OpenSSL) on Windows at a 30-byte
+payload, nothing at 16 KB, and nothing on Linux/glibc; sysbench OLTP
+over encrypted tables and redo log is unchanged.
+
+Tests main.tlsv13 and main.ssl_crl: OpenSSL 4.0.3 reports TLS alerts as
+"tls alert ..." (was "ssl/tls alert ..."), accept both.
+
+Assisted-by: Claude:claude-opus-4-8
+
+Upstream: https://github.com/MariaDB/server/commit/fb641b0cd1810e7d148d6b4d70f915c06c2c0f9e
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ include/ssl_compat.h         | 24 ---------
+ mysql-test/main/ssl_crl.test |  2 +-
+ mysql-test/main/tlsv13.test  |  4 +-
+ mysys_ssl/CMakeLists.txt     |  1 -
+ mysys_ssl/my_crypt.cc        | 45 +++++++++--------
+ mysys_ssl/my_md5.cc          | 96 ++++++++++++++++-------------------
+ mysys_ssl/openssl.c          | 98 ------------------------------------
+ sql/mysqld.cc                |  8 ---
+ 8 files changed, 70 insertions(+), 208 deletions(-)
+ delete mode 100644 mysys_ssl/openssl.c
+
+diff --git a/include/ssl_compat.h b/include/ssl_compat.h
+index 6bec4f482855c..200c4cbcf3db4 100644
+--- a/include/ssl_compat.h
++++ b/include/ssl_compat.h
+@@ -24,12 +24,6 @@
+ #define HAVE_OPENSSL11 1
+ #define SSL_LIBRARY OpenSSL_version(OPENSSL_VERSION)
+ #define ERR_remove_state(X) ERR_clear_error()
+-#define EVP_CIPHER_CTX_SIZE 200
+-#define EVP_MD_CTX_SIZE 80
+-#undef EVP_MD_CTX_init
+-#define EVP_MD_CTX_init(X) do { memset((X), 0, EVP_MD_CTX_SIZE); EVP_MD_CTX_reset(X); } while(0)
+-#undef EVP_CIPHER_CTX_init
+-#define EVP_CIPHER_CTX_init(X) do { memset((X), 0, EVP_CIPHER_CTX_SIZE); EVP_CIPHER_CTX_reset(X); } while(0)
+ 
+ /*
+   Macros below are deprecated. OpenSSL 1.1 may define them or not,
+@@ -66,24 +60,16 @@
+ #endif /* HAVE_OPENSSL11 */
+ #endif
+ 
+-#ifdef HAVE_WOLFSSL
+-#define EVP_MD_CTX_SIZE                 sizeof(wc_Md5)
+-#endif
+-
+ #ifndef HAVE_OPENSSL11
+ #ifndef ASN1_STRING_get0_data
+ #define ASN1_STRING_get0_data(X)        ASN1_STRING_data(X)
+ #endif
+-#ifndef EVP_MD_CTX_SIZE
+-#define EVP_MD_CTX_SIZE                 sizeof(EVP_MD_CTX)
+-#endif
+ 
+ #ifndef DH_set0_pqg
+ #define DH_set0_pqg(D,P,Q,G)            ((D)->p= (P), (D)->g= (G))
+ #endif
+ 
+ #define EVP_CIPHER_CTX_encrypting(ctx)  ((ctx)->encrypt)
+-#define EVP_CIPHER_CTX_SIZE             sizeof(EVP_CIPHER_CTX)
+ 
+ #ifndef HAVE_WOLFSSL
+ #define OPENSSL_init_ssl(X,Y)           SSL_library_init()
+@@ -97,13 +83,3 @@
+ #ifndef TLS1_3_VERSION
+ #define SSL_CTX_set_ciphersuites(X,Y) 0
+ #endif
+-
+-#ifdef	__cplusplus
+-extern "C" {
+-#endif /* __cplusplus */
+-
+-int check_openssl_compatibility();
+-
+-#ifdef	__cplusplus
+-}
+-#endif
+diff --git a/mysql-test/main/ssl_crl.test b/mysql-test/main/ssl_crl.test
+index 6da116f4ebe66..13958e33c1b54 100644
+--- a/mysql-test/main/ssl_crl.test
++++ b/mysql-test/main/ssl_crl.test
+@@ -8,6 +8,6 @@
+ 
+ --echo # try logging in with a certificate in the server's --ssl-crl : should fail
+ # OpenSSL 1.1.1a and later releases correctly rejects the certificate, but the error message is different
+---replace_regex /(ERROR 2013 \(HY000\): Lost connection to server at '.*', system error: [0-9]+|ERROR 2026 \(HY000\): TLS\/SSL error: sslv3 alert certificate revoked)/ERROR 2026 (HY000): TLS\/SSL error: ssl\/tls alert certificate revoked/
++--replace_regex /(ERROR 2013 \(HY000\): Lost connection to server at '.*', system error: [0-9]+|ERROR 2026 \(HY000\): TLS\/SSL error: (sslv3|tls) alert certificate revoked)/ERROR 2026 (HY000): TLS\/SSL error: ssl\/tls alert certificate revoked/
+ --error 1
+ --exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_version'" 2>&1
+diff --git a/mysql-test/main/tlsv13.test b/mysql-test/main/tlsv13.test
+index f90b6849a86a7..2c80b4c2089fc 100644
+--- a/mysql-test/main/tlsv13.test
++++ b/mysql-test/main/tlsv13.test
+@@ -19,11 +19,11 @@ source include/restart_mysqld.inc;
+ --exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES256-GCM-SHA384 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher%';"
+ 
+ # Check that other ciphers are correctly not supported by the server
+---replace_regex /sslv3 alert handshake failure/ssl\/tls alert handshake failure/
++--replace_regex /error: (sslv3|tls) alert/error: ssl\/tls alert/
+ --error 1
+ --exec $MYSQL --host=localhost --ssl-cipher=TLS_AES_256_GCM_SHA384 --tls-version=TLSv1.3 -e "SHOW STATUS LIKE 'Ssl_cipher';" 2>&1
+ 
+---replace_regex /sslv3 alert handshake failure/ssl\/tls alert handshake failure/
++--replace_regex /error: (sslv3|tls) alert/error: ssl\/tls alert/
+ --error 1
+ --exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES128-GCM-SHA256 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher';" 2>&1
+ 
+diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt
+index 1c3f60b5bb091..6a9c29449c655 100644
+--- a/mysys_ssl/CMakeLists.txt
++++ b/mysys_ssl/CMakeLists.txt
+@@ -28,7 +28,6 @@ SET(MYSYS_SSL_HIDDEN_SOURCES
+     my_sha384.cc
+     my_sha512.cc
+     my_md5.cc
+-    openssl.c
+    )
+ 
+ SET(MYSYS_SSL_SOURCES
+diff --git a/mysys_ssl/my_crypt.cc b/mysys_ssl/my_crypt.cc
+index 0356b64ccfb7c..792d8367875cb 100644
+--- a/mysys_ssl/my_crypt.cc
++++ b/mysys_ssl/my_crypt.cc
+@@ -27,29 +27,18 @@
+ 
+ #include <my_crypt.h>
+ #include <ssl_compat.h>
+-#include <cstdint>
+-
+-#define CTX_ALIGN 16
+ 
+ class MyCTX
+ {
+ public:
+-  char ctx_buf[EVP_CIPHER_CTX_SIZE + CTX_ALIGN];
+   EVP_CIPHER_CTX* ctx;
+   MyCTX()
+   {
+-#if CTX_ALIGN > 0
+-    uintptr_t p= ((uintptr_t)ctx_buf + (CTX_ALIGN - 1)) & ~(CTX_ALIGN - 1);
+-    ctx = reinterpret_cast<EVP_CIPHER_CTX*>(p);
+-#else
+-    ctx = (EVP_CIPHER_CTX*)ctx_buf;
+-#endif
+-
+-    EVP_CIPHER_CTX_init(ctx);
++    ctx= EVP_CIPHER_CTX_new();
+   }
+   virtual ~MyCTX()
+   {
+-    EVP_CIPHER_CTX_reset(ctx);
++    EVP_CIPHER_CTX_free(ctx);
+     ERR_remove_state(0);
+   }
+ 
+@@ -57,6 +46,8 @@ class MyCTX
+                    uint klen, const uchar *iv, uint ivlen)
+   {
+     compile_time_assert(MY_AES_CTX_SIZE >= sizeof(MyCTX));
++    if (unlikely(!ctx))
++      return MY_AES_OPENSSL_ERROR;
+     if (unlikely(!cipher))
+       return MY_AES_BAD_KEYSIZE;
+ 
+@@ -115,9 +106,11 @@ class MyCTX_nopad : public MyCTX
+     DBUG_ASSERT(ivlen == 0 || ivlen == sizeof(oiv));
+ 
+     int res= MyCTX::init(cipher, encrypt, key, klen, iv, ivlen);
++    if (res)
++      return res;
+ 
+     EVP_CIPHER_CTX_set_padding(ctx, 0);
+-    return res;
++    return MY_AES_OK;
+   }
+ 
+   /** Update last partial source block, stored in source_tail array. */
+@@ -213,10 +206,12 @@ class MyCTX_gcm : public MyCTX
+   {
+     compile_time_assert(MY_AES_CTX_SIZE >= sizeof(MyCTX_gcm));
+     int res= MyCTX::init(cipher, encrypt, key, klen, iv, ivlen);
++    if (res)
++      return res;
+     int real_ivlen= EVP_CIPHER_CTX_iv_length(ctx);
+     aad= iv + real_ivlen;
+     aadlen= ivlen - real_ivlen;
+-    return res;
++    return MY_AES_OK;
+   }
+ 
+   int update(const uchar *src, uint slen, uchar *dst, uint *dlen) override
+@@ -298,20 +293,30 @@ int my_aes_crypt_init(void *ctx, enum my_aes_mode mode, int flags,
+     new (ctx) MyCTX_nopad();
+   else
+     new (ctx) MyCTX();
+-  return ((MyCTX*)ctx)->init(ciphers[mode](klen), flags & 1,
+-                             key, klen, iv, ivlen);
++  MyCTX *c= (MyCTX*)ctx;
++  int res= c->init(ciphers[mode](klen), flags & 1, key, klen, iv, ivlen);
++  if (res)
++  {
++    /* release ctx but keep the object: a later update()/finish() from a
++       caller that ignored the error is then a safe no-op, not a double free */
++    EVP_CIPHER_CTX_free(c->ctx);
++    c->ctx= NULL;
++  }
++  return res;
+ }
+ 
+ int my_aes_crypt_update(void *ctx, const uchar *src, uint slen,
+                         uchar *dst, uint *dlen)
+ {
+-  return ((MyCTX*)ctx)->update(src, slen, dst, dlen);
++  MyCTX *c= (MyCTX*)ctx;
++  return c->ctx ? c->update(src, slen, dst, dlen) : MY_AES_OPENSSL_ERROR;
+ }
+ 
+ int my_aes_crypt_finish(void *ctx, uchar *dst, uint *dlen)
+ {
+-  int res= ((MyCTX*)ctx)->finish(dst, dlen);
+-  ((MyCTX*)ctx)->~MyCTX();
++  MyCTX *c= (MyCTX*)ctx;
++  int res= c->ctx ? c->finish(dst, dlen) : MY_AES_OPENSSL_ERROR;
++  c->~MyCTX();
+   return res;
+ }
+ 
+diff --git a/mysys_ssl/my_md5.cc b/mysys_ssl/my_md5.cc
+index 75995bccf9067..22682ddf70534 100644
+--- a/mysys_ssl/my_md5.cc
++++ b/mysys_ssl/my_md5.cc
+@@ -19,70 +19,60 @@
+   @file
+ 
+   @brief
+-  Wrapper functions for OpenSSL and YaSSL. Also provides a Compatibility layer
+-  to make available YaSSL's MD5 implementation.
++  Wrapper functions for the OpenSSL/WolfSSL MD5 implementation.
+ */
+ 
+ #include <my_global.h>
+ #include <my_md5.h>
+ #include <stdarg.h>
+-
+-#if defined(HAVE_WOLFSSL)
+-#include <wolfssl/wolfcrypt/md5.h>
+ #include <ssl_compat.h>
+-typedef wc_Md5 EVP_MD_CTX;
+-static void md5_init(EVP_MD_CTX *context)
+-{
+-  wc_InitMd5(context);;
+-}
+ 
+-static void md5_input(EVP_MD_CTX *context, const uchar *buf, unsigned len)
+-{
+-  wc_Md5Update(context, buf, len);
+-}
+-
+-static void md5_result(EVP_MD_CTX *context, uchar digest[MD5_HASH_SIZE])
+-{
+-  wc_Md5Final(context,digest);
+-}
+-
+-#elif defined(HAVE_OPENSSL)
++#if defined(HAVE_OPENSSL10) && !defined(HAVE_WOLFSSL) && \
++    !defined(LIBRESSL_VERSION_NUMBER)
++/*
++  OpenSSL 1.0.x in FIPS mode aborts on the low-level MD5 API (md5 is not used
++  for crypto here), so go through EVP with the non-FIPS flag.  MDEV-7788.
++*/
+ #include <openssl/evp.h>
+-#include <ssl_compat.h>
+-
+-static void md5_init(EVP_MD_CTX *context)
++typedef EVP_MD_CTX MY_MD5_CTX;
++static void md5_init(MY_MD5_CTX *context)
+ {
+-#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+-  EVP_MD *md5;
+-  EVP_MD_CTX_init(context);
+-  /* Ok to ignore FIPS: MD5 is not used for crypto here */
+-  /* In OpenSSL 3.0.0+ it is a different EVP_MD provider */
+-  md5 = EVP_MD_fetch(NULL, "MD5", "fips=no");
+-  EVP_DigestInit_ex(context, md5, NULL);
+-  EVP_MD_free(md5);
+-#else
+   EVP_MD_CTX_init(context);
+ #ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
+-  /* Ok to ignore FIPS: MD5 is not used for crypto here */
+-  /* In OpenSSL 1.1.1 the non FIPS allowed flag is context specific */
+   EVP_MD_CTX_set_flags(context, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+ #endif
+   EVP_DigestInit_ex(context, EVP_md5(), NULL);
+-#endif
+ }
+ 
+-static void md5_input(EVP_MD_CTX *context, const uchar *buf, unsigned len)
++static void md5_input(MY_MD5_CTX *context, const uchar *buf, unsigned len)
+ {
+   EVP_DigestUpdate(context, buf, len);
+ }
+ 
+-static void md5_result(EVP_MD_CTX *context, uchar digest[MD5_HASH_SIZE])
++static void md5_result(MY_MD5_CTX *context, uchar digest[MD5_HASH_SIZE])
+ {
+   EVP_DigestFinal_ex(context, digest, NULL);
+-  EVP_MD_CTX_reset(context);
++  EVP_MD_CTX_cleanup(context);
++}
++
++#else
++#include <openssl/md5.h>
++typedef MD5_CTX MY_MD5_CTX;
++static void md5_init(MY_MD5_CTX *context)
++{
++  MD5_Init(context);
+ }
+ 
+-#endif /* HAVE_WOLFSSL */
++static void md5_input(MY_MD5_CTX *context, const uchar *buf, unsigned len)
++{
++  MD5_Update(context, buf, len);
++}
++
++static void md5_result(MY_MD5_CTX *context, uchar digest[MD5_HASH_SIZE])
++{
++  MD5_Final(digest, context);
++}
++#endif
+ 
+ /**
+   Wrapper function to compute MD5 message digest.
+@@ -95,11 +85,10 @@ static void md5_result(EVP_MD_CTX *context, uchar digest[MD5_HASH_SIZE])
+ */
+ void my_md5(uchar *digest, const char *buf, size_t len)
+ {
+-  char ctx_buf[EVP_MD_CTX_SIZE];
+-  EVP_MD_CTX * const ctx= (EVP_MD_CTX*)ctx_buf;
+-  md5_init(ctx);
+-  md5_input(ctx, (const uchar *)buf, (uint) len);
+-  md5_result(ctx, digest);
++  MY_MD5_CTX context;
++  md5_init(&context);
++  md5_input(&context, (const uchar *)buf, (uint) len);
++  md5_result(&context, digest);
+ }
+ 
+ 
+@@ -119,34 +108,33 @@ void my_md5_multi(uchar *digest, ...)
+ {
+   va_list args;
+   const uchar *str;
+-  char ctx_buf[EVP_MD_CTX_SIZE];
+-  EVP_MD_CTX * const ctx= (EVP_MD_CTX*)ctx_buf;
++  MY_MD5_CTX context;
+   va_start(args, digest);
+ 
+-  md5_init(ctx);
++  md5_init(&context);
+   for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*))
+-    md5_input(ctx, str, (uint) va_arg(args, size_t));
++    md5_input(&context, str, (uint) va_arg(args, size_t));
+ 
+-  md5_result(ctx, digest);
++  md5_result(&context, digest);
+   va_end(args);
+ }
+ 
+ size_t my_md5_context_size()
+ {
+-  return EVP_MD_CTX_SIZE;
++  return sizeof(MY_MD5_CTX);
+ }
+ 
+ void my_md5_init(void *context)
+ {
+-  md5_init((EVP_MD_CTX *)context);
++  md5_init((MY_MD5_CTX *)context);
+ }
+ 
+ void my_md5_input(void *context, const uchar *buf, size_t len)
+ {
+-  md5_input((EVP_MD_CTX *)context, buf, (uint) len);
++  md5_input((MY_MD5_CTX *)context, buf, (uint) len);
+ }
+ 
+ void my_md5_result(void *context, uchar *digest)
+ {
+-  md5_result((EVP_MD_CTX *)context, digest);
++  md5_result((MY_MD5_CTX *)context, digest);
+ }
+diff --git a/mysys_ssl/openssl.c b/mysys_ssl/openssl.c
+deleted file mode 100644
+index 3890e3524bec4..0000000000000
+--- a/mysys_ssl/openssl.c
++++ /dev/null
+@@ -1,98 +0,0 @@
+-/*
+- Copyright (c) 2017, MariaDB Corporation.
+-
+- This program is free software; you can redistribute it and/or modify
+- it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; version 2 of the License.
+-
+- This program is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+- GNU General Public License for more details.
+-
+- You should have received a copy of the GNU General Public License
+- along with this program; if not, write to the Free Software
+- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
+-
+-#include <my_global.h>
+-#include <openssl/evp.h>
+-#include <ssl_compat.h>
+-
+-/*
+-  The check is only done for OpenSSL 1.1.x.
+-  It could run for OpenSSL 1.0.x but it doesn't make much sense
+-  and it hits this bug:
+-  https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1594748
+-*/
+-
+-#ifndef HAVE_OPENSSL11
+-int check_openssl_compatibility()
+-{
+-  return 0;
+-}
+-#else
+-#include <openssl/evp.h>
+-
+-static uint testing;
+-static size_t alloc_size, alloc_count;
+-
+-static void *coc_malloc(size_t size
+-#ifndef LIBRESSL_VERSION_NUMBER
+-                        , const char *f __attribute__((unused)),
+-                        int l __attribute__((unused))
+-#endif
+-)
+-{
+-  if (unlikely(testing))
+-  {
+-    alloc_size+= size;
+-    alloc_count++;
+-  }
+-  return malloc(size);
+-}
+-
+-static void *coc_realloc(void *addr, size_t num
+-#ifndef LIBRESSL_VERSION_NUMBER
+-                         , const char *file __attribute__((unused)),
+-                         int line __attribute__((unused))
+-#endif
+-)
+-{
+-  return realloc(addr, num);
+-}
+-
+-static void coc_free(void *addr
+-#ifndef LIBRESSL_VERSION_NUMBER
+-                     , const char *file __attribute__((unused)),
+-                     int line __attribute__((unused))
+-#endif
+-)
+-{
+-  free(addr);
+-}
+-
+-int check_openssl_compatibility()
+-{
+-  EVP_CIPHER_CTX *evp_ctx;
+-  EVP_MD_CTX     *md5_ctx;
+-
+-  if (!CRYPTO_set_mem_functions(coc_malloc, coc_realloc, coc_free))
+-    return 0;
+-
+-  testing= 1;
+-  alloc_size= alloc_count= 0;
+-  evp_ctx= EVP_CIPHER_CTX_new();
+-  EVP_CIPHER_CTX_free(evp_ctx);
+-  if (alloc_count != 1 || !alloc_size || alloc_size > EVP_CIPHER_CTX_SIZE)
+-    return 1;
+-
+-  alloc_size= alloc_count= 0;
+-  md5_ctx= EVP_MD_CTX_new();
+-  EVP_MD_CTX_free(md5_ctx);
+-  if (alloc_count != 1 || !alloc_size || alloc_size > EVP_MD_CTX_SIZE)
+-    return 1;
+-
+-  testing= 0;
+-  return 0;
+-}
+-#endif
+diff --git a/sql/mysqld.cc b/sql/mysqld.cc
+index 52938056f0b5d..d9e3cc4b6094b 100644
+--- a/sql/mysqld.cc
++++ b/sql/mysqld.cc
+@@ -4008,14 +4008,6 @@ static int init_common_variables()
+     exit(1);
+   }
+ 
+-#ifdef HAVE_OPENSSL
+-  if (check_openssl_compatibility())
+-  {
+-    sql_print_error("Incompatible OpenSSL version. Cannot continue...");
+-    exit(1);
+-  }
+-#endif
+-
+   if (init_thread_environment() || mysql_init_variables())
+     exit(1);
+ 
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot