aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-28 13:08:54 -0400
committerFranklin Wei <me@fwei.tk>2018-06-28 13:08:54 -0400
commitedc1562fb2f2724570ab7d2bc6fd47f6115df4ab (patch)
tree064fb0a6a52ee3e0733950c07c0925d9e2058e0c
parentf1ebf26828f93fea21fe9632d16277791342e388 (diff)
downloadcsaa-edc1562fb2f2724570ab7d2bc6fd47f6115df4ab.zip
csaa-edc1562fb2f2724570ab7d2bc6fd47f6115df4ab.tar.gz
csaa-edc1562fb2f2724570ab7d2bc6fd47f6115df4ab.tar.bz2
csaa-edc1562fb2f2724570ab7d2bc6fd47f6115df4ab.tar.xz
Work around old OpenSSL API
-rw-r--r--crypto.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/crypto.c b/crypto.c
index 7fb667f..ce77461 100644
--- a/crypto.c
+++ b/crypto.c
@@ -221,6 +221,36 @@ hash_t hash_increment(hash_t h)
return u64_to_hash(hash_to_u64(h) + 1);
}
+/* workaround for old openssl */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+
+#include <string.h>
+#include <openssl/engine.h>
+
+ HMAC_CTX *HMAC_CTX_new(void)
+ {
+ HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
+ if (ctx != NULL) {
+ if (!HMAC_CTX_reset(ctx)) {
+ HMAC_CTX_free(ctx);
+ return NULL;
+ }
+ }
+ return ctx;
+ }
+
+ void HMAC_CTX_free(HMAC_CTX *ctx)
+ {
+ if (ctx != NULL) {
+ hmac_ctx_cleanup(ctx);
+ EVP_MD_CTX_free(ctx->i_ctx);
+ EVP_MD_CTX_free(ctx->o_ctx);
+ EVP_MD_CTX_free(ctx->md_ctx);
+ OPENSSL_free(ctx);
+ }
+ }
+#endif
+
/* simple XOR cipher, so encryption and decryption are symmetric */
hash_t crypt_secret(hash_t encrypted_secret,
uint64_t file_idx, uint64_t file_version,