uboot-mxs: Fix build with libressl 2.7.2
[openwrt/staging/wigyori.git] / package / boot / uboot-mxs / patches / 002-tools-mxsimage-Support-building-with-LibreSSL.patch
1 From c5b0bca4c3ca5c3d1d8ee99fdbf3b494a3986dbd Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 18 Mar 2018 16:03:47 +0100
4 Subject: [PATCH] tools/mxsimage: Support building with LibreSSL
5
6 The mxsimage utility fails to compile against LibreSSL version < 2.7.0
7 because LibreSSL says it is OpenSSL 2.0, but it does not support the
8 complete OpenSSL 1.1 interface.
9
10 LibreSSL defines OPENSSL_VERSION_NUMBER with 0x20000000L and therefor
11 claims to have an API compatible with OpenSSL 2.0, but it implements
12 EVP_MD_CTX_new(), EVP_MD_CTX_free() and EVP_CIPHER_CTX_reset() only
13 starting with version 2.7.0, which is not yet released. OpenSSL
14 implements this function since version 1.1.0.
15
16 This commit will activate the compatibility code meant for
17 OpenSSL < 1.1.0 also for LibreSSL version < 2.7.0.
18
19 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
20 Reviewed-by: Jonathan Gray <jsg@jsg.id.au>
21 ---
22 tools/mxsimage.c | 3 ++-
23 1 file changed, 2 insertions(+), 1 deletion(-)
24
25 --- a/tools/mxsimage.c
26 +++ b/tools/mxsimage.c
27 @@ -26,7 +26,8 @@
28 * OpenSSL 1.1.0 and newer compatibility functions:
29 * https://wiki.openssl.org/index.php/1.1_API_Changes
30 */
31 -#if OPENSSL_VERSION_NUMBER < 0x10100000L
32 +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
33 + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
34 static void *OPENSSL_zalloc(size_t num)
35 {
36 void *ret = OPENSSL_malloc(num);