mirror of
https://github.com/monero-project/monero.git
synced 2025-08-16 19:50:19 -04:00
core: protect precomputed block hashes with SHA256
This commit is contained in:
parent
d666339853
commit
583a7b5c74
3 changed files with 41 additions and 1 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue