aboutsummaryrefslogtreecommitdiffstats
path: root/community/pev/fix-openssl.patch
blob: 2d52ab9c4da403fe31225adeeb46c9e883255aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- a/src/pehash.c
+++ b/src/pehash.c
@@ -215,13 +215,25 @@
 	unsigned char md_value[EVP_MAX_MD_SIZE];
 	unsigned int md_len;
 
-	EVP_MD_CTX md_ctx;
+// See https://wiki.openssl.org/index.php/1.1_API_Changes
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+	EVP_MD_CTX md_ctx_auto;
+	EVP_MD_CTX *md_ctx = &md_ctx_auto;
+#else
+	EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
+#endif
+
 	// FIXME: Handle errors - Check return values.
-	EVP_MD_CTX_init(&md_ctx);
-	EVP_DigestInit_ex(&md_ctx, md, NULL);
-	EVP_DigestUpdate(&md_ctx, data, size);
-	EVP_DigestFinal_ex(&md_ctx, md_value, &md_len);
-	EVP_MD_CTX_cleanup(&md_ctx);
+	EVP_MD_CTX_init(md_ctx);
+	EVP_DigestInit_ex(md_ctx, md, NULL);
+	EVP_DigestUpdate(md_ctx, data, size);
+	EVP_DigestFinal_ex(md_ctx, md_value, &md_len);
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+	EVP_MD_CTX_cleanup(md_ctx);
+#else
+	EVP_MD_CTX_free(md_ctx);
+#endif
 
 	for (unsigned int i=0; i < md_len; i++)
 		sprintf(&output[i * 2], "%02x", md_value[i]);
--- a/src/pesec.c
+++ b/src/pesec.c
@@ -225,7 +225,10 @@
 	PKCS7 *p7 = NULL;
 	BIO *in = NULL;
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
 	CRYPTO_malloc_init();
+#endif
+	
 	ERR_load_crypto_strings();
 	OpenSSL_add_all_algorithms();