From 583a7b5c74239aa9e645ea5b604e4504b323271f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 23 Feb 2017 23:18:10 +0000 Subject: core: protect precomputed block hashes with SHA256 --- src/common/util.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/common/util.cpp') diff --git a/src/common/util.cpp b/src/common/util.cpp index cc2b5b8ff..046961b06 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -587,6 +587,18 @@ std::string get_nix_version_display_string() return 0; } + bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash) + { + SHA256_CTX ctx; + if (!SHA256_Init(&ctx)) + return false; + if (!SHA256_Update(&ctx, data, len)) + return false; + if (!SHA256_Final((unsigned char*)hash.data, &ctx)) + return false; + return true; + } + bool sha256sum(const std::string &filename, crypto::hash &hash) { if (!epee::file_io_utils::is_file_exist(filename)) -- cgit v1.2.3