Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #184 from sandynomad/master
Browse files Browse the repository at this point in the history
Add OpenSSL version conditional around use of EVP_MD_CTX_new/_free
  • Loading branch information
jpmens authored Mar 6, 2017
2 parents e2bc941 + db7e8ba commit 34886c2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ static unsigned int sha_hash(const char *data, size_t size, unsigned char *out)
const EVP_MD *md = EVP_get_digestbyname("SHA1");

if (md != NULL) {
#if OPENSSL_VERSION_NUMBER < 0x10100000
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
#else
EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
#endif
EVP_MD_CTX_init(mdctx);
EVP_DigestInit_ex(mdctx, md, NULL);
EVP_DigestUpdate(mdctx, data, size);
EVP_DigestFinal_ex(mdctx, out, &md_len);
#if OPENSSL_VERSION_NUMBER < 0x10100000
EVP_MD_CTX_destroy(mdctx);
#else
EVP_MD_CTX_free(mdctx);
#endif
}
return md_len;
}
Expand Down

0 comments on commit 34886c2

Please sign in to comment.