Line 0
Link Here
|
|
|
1 |
From 98f5f22f91f02821be1604bbce61efb45f7e3696 Mon Sep 17 00:00:00 2001 |
2 |
From: Jardel Weyrich <jweyrich@gmail.com> |
3 |
Date: Thu, 12 Jan 2017 16:45:24 -0200 |
4 |
Subject: [PATCH] Make pehash compatible with OpenSSL 1.1.0. |
5 |
|
6 |
--- |
7 |
src/pehash.c | 24 ++++++++++++++++++------ |
8 |
1 file changed, 18 insertions(+), 6 deletions(-) |
9 |
|
10 |
diff --git src/pehash.c src/pehash.c |
11 |
index e03a0a9..619a1ef 100644 |
12 |
--- src/pehash.c |
13 |
+++ src/pehash.c |
14 |
@@ -215,13 +215,25 @@ static void calc_hash(const char *alg_name, const unsigned char *data, size_t si |
15 |
unsigned char md_value[EVP_MAX_MD_SIZE]; |
16 |
unsigned int md_len; |
17 |
|
18 |
- EVP_MD_CTX md_ctx; |
19 |
+// See https://wiki.openssl.org/index.php/1.1_API_Changes |
20 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
21 |
+ EVP_MD_CTX md_ctx_auto; |
22 |
+ EVP_MD_CTX *md_ctx = &md_ctx_auto; |
23 |
+#else |
24 |
+ EVP_MD_CTX *md_ctx = EVP_MD_CTX_new(); |
25 |
+#endif |
26 |
+ |
27 |
// FIXME: Handle errors - Check return values. |
28 |
- EVP_MD_CTX_init(&md_ctx); |
29 |
- EVP_DigestInit_ex(&md_ctx, md, NULL); |
30 |
- EVP_DigestUpdate(&md_ctx, data, size); |
31 |
- EVP_DigestFinal_ex(&md_ctx, md_value, &md_len); |
32 |
- EVP_MD_CTX_cleanup(&md_ctx); |
33 |
+ EVP_MD_CTX_init(md_ctx); |
34 |
+ EVP_DigestInit_ex(md_ctx, md, NULL); |
35 |
+ EVP_DigestUpdate(md_ctx, data, size); |
36 |
+ EVP_DigestFinal_ex(md_ctx, md_value, &md_len); |
37 |
+ |
38 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
39 |
+ EVP_MD_CTX_cleanup(md_ctx); |
40 |
+#else |
41 |
+ EVP_MD_CTX_free(md_ctx); |
42 |
+#endif |
43 |
|
44 |
for (unsigned int i=0; i < md_len; i++) |
45 |
sprintf(&output[i * 2], "%02x", md_value[i]); |
46 |
-- |
47 |
2.15.1 |
48 |
|