From: Andre Noll Date: Fri, 10 Sep 2021 18:37:37 +0000 (+0200) Subject: openssl: Switch to evp API for sha1 and sha256. X-Git-Tag: v0.7.2~11^2 X-Git-Url: http://git.tuebingen.mpg.de/versions/paraslash-0.3.1.tar.bz2.asc?a=commitdiff_plain;h=a07746d8f55d0655510cad2448ef552288338c69;p=paraslash.git openssl: Switch to evp API for sha1 and sha256. This is easy to do and gets rid of some warnings about depreciated APIs (which got deactivated in the previous commit, but still). --- diff --git a/openssl.c b/openssl.c index 9d3ad577..71849876 100644 --- a/openssl.c +++ b/openssl.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "para.h" #include "error.h" @@ -409,16 +410,24 @@ void sc_crypt(struct stream_cipher *sc, struct iovec *src, struct iovec *dst) void hash_function(const char *data, unsigned long len, unsigned char *hash) { - SHA_CTX c; - SHA1_Init(&c); - SHA1_Update(&c, data, len); - SHA1_Final(hash, &c); + EVP_MD_CTX *c = EVP_MD_CTX_new(); + int ret = EVP_DigestInit_ex(c, EVP_sha1(), NULL); + assert(ret != 0); + ret = EVP_DigestUpdate(c, data, len); + assert(ret != 0); + ret = EVP_DigestFinal_ex(c, hash, NULL); + assert(ret != 0); + EVP_MD_CTX_free(c); } void hash2_function(const char *data, unsigned long len, unsigned char *hash) { - SHA256_CTX c; - SHA256_Init(&c); - SHA256_Update(&c, data, len); - SHA256_Final(hash, &c); + EVP_MD_CTX *c = EVP_MD_CTX_new(); + int ret = EVP_DigestInit_ex(c, EVP_sha256(), NULL); + assert(ret != 0); + ret = EVP_DigestUpdate(c, data, len); + assert(ret != 0); + ret = EVP_DigestFinal_ex(c, hash, NULL); + assert(ret != 0); + EVP_MD_CTX_free(c); }