Skip to contentSkip to conversation

rsa: Support LibreSSL in rsa-sign.c

PATCH New parazyd 2 participants 2 messages Jun 27, 2018

lore
Share & tools
lore

parazyd

author
#0 lore raw

PATCH v2 1/1 rsa: Support LibreSSL in rsa-sign.c

At present rsa-sign.c can not be compiled with LibreSSL older than 2.7.0. This commit adjusts the guards in the rsa-sign.c to check for LiBRESSL_VERSION_NUMBER where necessary.

---
 lib/rsa/rsa-sign.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/rsa/rsa-sign.c +3 -3
index cfe09cc94c..ff866c6045 100644
@@ -20,7 +20,7 @@
 #define HAVE_ERR_REMOVE_THREAD_STATE
 #endif
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x2070000fL
 static void RSA_get0_key(const RSA *r,
                  const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
 {
@@ -299,7 +299,7 @@ static int rsa_init(void)
 {
 	int ret;
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x2070000fL
 	ret = SSL_library_init();
 #else
 	ret = OPENSSL_init_ssl(0, NULL);
@@ -432,7 +432,7 @@ static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
 		ret = rsa_err("Could not obtain signature");
 		goto err_sign;
 	}
-	#if OPENSSL_VERSION_NUMBER < 0x10100000L
+	#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x2070000fL
 		EVP_MD_CTX_cleanup(context);
 	#else
 		EVP_MD_CTX_reset(context);
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 1/1 rsa: Support LibreSSL in rsa-sign.c

Quoted 3 lines · parazyd

At present rsa-sign.c can not be compiled with LibreSSL older than 2.7.0. This commit adjusts the guards in the rsa-sign.c to check for LiBRESSL_VERSION_NUMBER where necessary.

These tests are wrong, an undefined cpp macro will be 0 so with OpenSSL >= 1.1 the 'LIBRESSL_VERSION_NUMBER < 0x2070000fL' test will pass as LIBRESSL_VERSION_NUMBER is not defined.

match the use in tools/kwbimage.c and tools/mxsimage.c

#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
    (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
Quoted 44 lines
---
 lib/rsa/rsa-sign.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/rsa/rsa-sign.c +3 -3
index cfe09cc94c..ff866c6045 100644
@@ -20,7 +20,7 @@
 #define HAVE_ERR_REMOVE_THREAD_STATE
 #endif
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x2070000fL
 static void RSA_get0_key(const RSA *r,
                  const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
 {
@@ -299,7 +299,7 @@ static int rsa_init(void)
 {
 	int ret;
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x2070000fL
 	ret = SSL_library_init();
 #else
 	ret = OPENSSL_init_ssl(0, NULL);
@@ -432,7 +432,7 @@ static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
 		ret = rsa_err("Could not obtain signature");
 		goto err_sign;
 	}
-	#if OPENSSL_VERSION_NUMBER < 0x10100000L
+	#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x2070000fL
 		EVP_MD_CTX_cleanup(context);
 	#else
 		EVP_MD_CTX_reset(context);
Signature · 6 lines
2.18.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot