From a30a00b972e9b3b0d6f6561d1a31cc04ec977321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20He=C3=9F?= <tim.hess@rwth-aachen.de> Date: Fri, 19 Apr 2024 13:10:44 +0200 Subject: [PATCH] use new ssl/tls openssh toolkit Fixes #647 --- src/SIGN/Hasher.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/SIGN/Hasher.cpp b/src/SIGN/Hasher.cpp index e1284f0..fcc9474 100644 --- a/src/SIGN/Hasher.cpp +++ b/src/SIGN/Hasher.cpp @@ -1,19 +1,18 @@ #include "Hasher.h" -#include <openssl/sha.h> +#include <openssl/evp.h> #include <sstream> #include <iomanip> - std::vector<unsigned char> SIGN::Hasher::sha256(const unsigned char* data, size_t length) { - SHA256_CTX context; - SHA256_Init(&context); - SHA256_Update(&context, data, length); - std::vector<unsigned char> buffer(SHA256_DIGEST_LENGTH); - SHA256_Final(buffer.data(), &context); + EVP_MD_CTX* context = EVP_MD_CTX_new(); + EVP_DigestInit_ex(context, EVP_sha256(), NULL); + EVP_DigestUpdate(context, data, length); + std::vector<unsigned char> buffer(EVP_MD_size(EVP_sha256())); + EVP_DigestFinal_ex(context, buffer.data(), NULL); + EVP_MD_CTX_free(context); return buffer; - } SIGN::Hasher::Hasher() @@ -37,7 +36,7 @@ void SIGN::Hasher::reset() size_t SIGN::Hasher::size(void) { - return SHA256_DIGEST_LENGTH; ; + return EVP_MD_size(EVP_sha256()); } std::string SIGN::Hasher::print(std::vector<unsigned char> bytes, bool uppercase) -- GitLab