-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes also enabled support of OpenSSL 3 via `openssl` PortGroup for `retdec-devel`. Anyway, `v4.0` is shipped with OpenSSL 1.1.1 and should be build against OpenSSL 1.1 branch. Fixes: https://trac.macports.org/ticket/63882
- Loading branch information
Showing
2 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
commit 3dbe9deaf35ad423769104db70dd062dba2973cc | ||
Author: Kirill A. Korinsky <[email protected]> | ||
Date: Mon Nov 8 11:48:09 2021 +0100 | ||
|
||
Update API for OpenSSL 3.0 | ||
|
||
Fixes: https://github.com/avast/retdec/issues/1040 | ||
|
||
diff --git a/deps/authenticode-parser/src/authenticode.c b/deps/authenticode-parser/src/authenticode.c | ||
index bd860fe3..724b64f9 100644 | ||
--- a/deps/authenticode-parser/src/authenticode.c | ||
+++ b/deps/authenticode-parser/src/authenticode.c | ||
@@ -581,7 +581,11 @@ AuthenticodeArray* parse_authenticode(const uint8_t* pe_data, long pe_len) | ||
continue; | ||
} | ||
|
||
+#if OPENSSL_VERSION_NUMBER >= 0x3000000fL | ||
+ int mdlen = EVP_MD_get_size(md); | ||
+#else | ||
int mdlen = EVP_MD_size(md); | ||
+#endif | ||
sig->file_digest.len = mdlen; | ||
sig->file_digest.data = (uint8_t*)malloc(mdlen); | ||
if (!sig->file_digest.data) | ||
diff --git a/deps/authenticode-parser/src/certificate.c b/deps/authenticode-parser/src/certificate.c | ||
index 7686c516..2f1a4f0c 100644 | ||
--- a/deps/authenticode-parser/src/certificate.c | ||
+++ b/deps/authenticode-parser/src/certificate.c | ||
@@ -287,7 +287,11 @@ Certificate* certificate_new(X509* x509) | ||
EVP_PKEY* pkey = X509_get0_pubkey(x509); | ||
if (pkey) { | ||
result->key = pubkey_to_pem(pkey); | ||
+#if OPENSSL_VERSION_NUMBER >= 0x3000000fL | ||
+ result->key_alg = strdup(OBJ_nid2sn(EVP_PKEY_get_base_id(pkey))); | ||
+#else | ||
result->key_alg = strdup(OBJ_nid2sn(EVP_PKEY_base_id(pkey))); | ||
+#endif | ||
} | ||
|
||
return result; | ||
diff --git a/deps/authenticode-parser/src/countersignature.c b/deps/authenticode-parser/src/countersignature.c | ||
index 5bc2c108..59ca8038 100644 | ||
--- a/deps/authenticode-parser/src/countersignature.c | ||
+++ b/deps/authenticode-parser/src/countersignature.c | ||
@@ -137,7 +137,11 @@ Countersignature* pkcs9_countersig_new( | ||
* but other times it is just purely and I didn't find another way to distinguish it but only | ||
* based on the length of data we get. Found mention of this in openssl mailing list: | ||
* https://mta.openssl.org/pipermail/openssl-users/2015-September/002054.html */ | ||
+#if OPENSSL_VERSION_NUMBER >= 0x3000000fL | ||
+ size_t mdLen = EVP_MD_get_size(md); | ||
+#else | ||
size_t mdLen = EVP_MD_size(md); | ||
+#endif | ||
if (mdLen == decLen) { | ||
isValid = !memcmp(calc_digest, decData, mdLen); | ||
} else { | ||
@@ -238,7 +242,11 @@ Countersignature* ms_countersig_new(const uint8_t* data, long size, ASN1_STRING* | ||
|
||
uint8_t calc_digest[EVP_MAX_MD_SIZE]; | ||
calculate_digest(md, enc_digest->data, enc_digest->length, calc_digest); | ||
+#if OPENSSL_VERSION_NUMBER >= 0x3000000fL | ||
+ int mdLen = EVP_MD_get_size(md); | ||
+#else | ||
int mdLen = EVP_MD_size(md); | ||
+#endif | ||
|
||
if (digestLen != mdLen || memcmp(calc_digest, digestData, mdLen) != 0) { | ||
result->verify_flags = COUNTERSIGNATURE_VFY_DOESNT_MATCH_SIGNATURE; | ||
@@ -251,7 +259,11 @@ Countersignature* ms_countersig_new(const uint8_t* data, long size, ASN1_STRING* | ||
|
||
TS_VERIFY_CTX_set_flags(ctx, TS_VFY_VERSION | TS_VFY_IMPRINT); | ||
TS_VERIFY_CTX_set_store(ctx, store); | ||
+#if OPENSSL_VERSION_NUMBER >= 0x3000000fL | ||
+ TS_VERIFY_CTX_set_store(ctx, p7->d.sign->cert); | ||
+#else | ||
TS_VERIFY_CTS_set_certs(ctx, p7->d.sign->cert); | ||
+#endif | ||
TS_VERIFY_CTX_set_imprint(ctx, calc_digest, mdLen); | ||
|
||
bool isValid = TS_RESP_verify_token(ctx, p7) == 1; |