summaryrefslogtreecommitdiff
path: root/src/apk_crypto.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-06-12 08:40:53 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-06-12 08:40:53 +0300
commitaeeb119fd8652c044cd5ceebce572b5c716914e3 (patch)
tree9c966f0505db774c55d38c37647554399d90180d /src/apk_crypto.h
parent4403e7ec32c99ecf079e187d7010d19fe72f0c76 (diff)
downloadapk-tools-aeeb119fd8652c044cd5ceebce572b5c716914e3.tar.gz
apk-tools-aeeb119fd8652c044cd5ceebce572b5c716914e3.tar.bz2
apk-tools-aeeb119fd8652c044cd5ceebce572b5c716914e3.tar.xz
apk-tools-aeeb119fd8652c044cd5ceebce572b5c716914e3.zip
crypto: make EVP_MD_CTX_FLAG_FINALISE optional
Improves compatibility with libressl, wolfssl and older openssl libraries not having the flag. Usage of this is optional as it's purely performance optimization related flag.
Diffstat (limited to 'src/apk_crypto.h')
-rw-r--r--src/apk_crypto.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/apk_crypto.h b/src/apk_crypto.h
index 4697901..6f6e801 100644
--- a/src/apk_crypto.h
+++ b/src/apk_crypto.h
@@ -85,7 +85,9 @@ static inline int apk_digest_ctx_init(struct apk_digest_ctx *dctx, uint8_t alg)
dctx->mdctx = EVP_MD_CTX_new();
if (!dctx->mdctx) return -ENOMEM;
dctx->alg = alg;
+#ifdef EVP_MD_CTX_FLAG_FINALISE
EVP_MD_CTX_set_flags(dctx->mdctx, EVP_MD_CTX_FLAG_FINALISE);
+#endif
EVP_DigestInit_ex(dctx->mdctx, apk_digest_alg_to_evp(alg), 0);
return 0;
}