lordgamez commented on code in PR #1583: URL: https://github.com/apache/nifi-minifi-cpp/pull/1583#discussion_r1247505883
########## extensions/standard-processors/processors/HashContent.h: ########## @@ -49,21 +48,25 @@ namespace { // NOLINT HashReturnType ret_val; ret_val.second = 0; std::array<std::byte, HASH_BUFFER_SIZE> buffer{}; - MD5_CTX context; - MD5_Init(&context); + EVP_MD_CTX *context = EVP_MD_CTX_new(); + const auto guard = gsl::finally([&context]() { + EVP_MD_CTX_free(context); + }); + const EVP_MD *md = EVP_md5(); + EVP_DigestInit_ex(context, md, nullptr); Review Comment: I can be inlined, updated in 5ebb285e42f5ea89391d5b126bcbecb2b27c77d9 ########## extensions/standard-processors/processors/HashContent.h: ########## @@ -49,21 +48,25 @@ namespace { // NOLINT HashReturnType ret_val; ret_val.second = 0; std::array<std::byte, HASH_BUFFER_SIZE> buffer{}; - MD5_CTX context; - MD5_Init(&context); + EVP_MD_CTX *context = EVP_MD_CTX_new(); + const auto guard = gsl::finally([&context]() { + EVP_MD_CTX_free(context); + }); + const EVP_MD *md = EVP_md5(); + EVP_DigestInit_ex(context, md, nullptr); size_t ret = 0; do { ret = stream->read(buffer); if (ret > 0) { - MD5_Update(&context, buffer.data(), ret); + EVP_DigestUpdate(context, buffer.data(), ret); ret_val.second += gsl::narrow<int64_t>(ret); } } while (ret > 0); if (ret_val.second > 0) { - std::array<std::byte, MD5_DIGEST_LENGTH> digest{}; - MD5_Final(reinterpret_cast<unsigned char*>(digest.data()), &context); + std::array<std::byte, EVP_MAX_MD_SIZE> digest{}; + EVP_DigestFinal_ex(context, reinterpret_cast<unsigned char*>(digest.data()), nullptr); Review Comment: Great catch! I didn't realize this because the HashContentTest was passing. After checking the test I saw that it was passing on the wrong hash value because only a partial match was required in the assertion instead of an exact match. Fixed in 5ebb285e42f5ea89391d5b126bcbecb2b27c77d9 ########## libminifi/src/core/state/Value.cpp: ########## @@ -34,25 +34,29 @@ const std::type_index Value::BOOL_TYPE = std::type_index(typeid(bool)); const std::type_index Value::DOUBLE_TYPE = std::type_index(typeid(double)); const std::type_index Value::STRING_TYPE = std::type_index(typeid(std::string)); -void hashNode(const SerializedResponseNode& node, SHA512_CTX& ctx) { - SHA512_Update(&ctx, node.name.c_str(), node.name.length()); +void hashNode(const SerializedResponseNode& node, EVP_MD_CTX* ctx) { Review Comment: Updated in 5ebb285e42f5ea89391d5b126bcbecb2b27c77d9 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org