aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-02-24 12:00:51 +0200
committerRiccardo Spagni <ric@spagni.net>2017-02-24 12:00:51 +0200
commited6f2e8323b4313e97ad6a43aa13abaf7d099296 (patch)
tree5977dfa9a688be93d2059e28fa2d552359f1041e /src/common/util.cpp
parentMerge pull request #1784 (diff)
parentcore: protect precomputed block hashes with SHA256 (diff)
downloadmonero-ed6f2e8323b4313e97ad6a43aa13abaf7d099296.tar.xz
Merge pull request #1785
583a7b5c core: protect precomputed block hashes with SHA256 (moneromooo-monero)
Diffstat (limited to 'src/common/util.cpp')
-rw-r--r--src/common/util.cpp12
1 files changed, 12 insertions, 0 deletions
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))