[Sound-open-firmware] [PATCH] rimage: openssl: add compatibility for openssl 1.1.0

Xiuli Pan xiuli.pan at linux.intel.com
Mon May 14 08:03:52 CEST 2018


From: Pan Xiuli <xiuli.pan at linux.intel.com>

Add compatibility support for openssl 1.0.2 support alongsid with
openssl 1.1.0

References:
https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes
Compatibility Layer

Signed-off-by: Pan Xiuli <xiuli.pan at linux.intel.com>
---
 rimage/hash.c    | 26 ++++++++++++++++++++++++++
 rimage/pkcs1_5.c | 16 ++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/rimage/hash.c b/rimage/hash.c
index 2905d89..73b6d72 100644
--- a/rimage/hash.c
+++ b/rimage/hash.c
@@ -30,6 +30,32 @@
 #include "file_format.h"
 #include "manifest.h"
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
+EVP_MD_CTX *EVP_MD_CTX_new(void);
+
+static void *OPENSSL_zalloc(size_t num)
+{
+	void *ret = OPENSSL_malloc(num);
+
+	if (ret != NULL)
+		memset(ret, 0, num);
+	return ret;
+}
+
+EVP_MD_CTX *EVP_MD_CTX_new(void)
+{
+	return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
+}
+
+void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
+{
+	EVP_MD_CTX_cleanup(ctx);
+	OPENSSL_free(ctx);
+}
+#endif
+
+
 #define DEBUG_HASH 0
 
 void module_sha256_create(struct image *image)
diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c
index 0c91df0..d80cf8d 100644
--- a/rimage/pkcs1_5.c
+++ b/rimage/pkcs1_5.c
@@ -30,6 +30,22 @@
 #include "css.h"
 #include "manifest.h"
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+void RSA_get0_key(const RSA *r,
+		  const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
+
+void RSA_get0_key(const RSA *r,
+		  const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
+{
+	if (n != NULL)
+		*n = r->n;
+	if (e != NULL)
+		*e = r->e;
+	if (d != NULL)
+		*d = r->d;
+}
+#endif
+
 #define DEBUG_PKCS	0
 
 static void bytes_swap(uint8_t *ptr, uint32_t size)
-- 
2.7.4



More information about the Sound-open-firmware mailing list