diff options
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/chacha8.h | 8 | ||||
-rw-r--r-- | src/crypto/groestl.c | 4 | ||||
-rw-r--r-- | src/crypto/slow-hash.c | 1 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/crypto/chacha8.h b/src/crypto/chacha8.h index 9527e4016..8e58f42a2 100644 --- a/src/crypto/chacha8.h +++ b/src/crypto/chacha8.h @@ -70,13 +70,17 @@ namespace crypto { chacha8(data, length, reinterpret_cast<const uint8_t*>(&key), reinterpret_cast<const uint8_t*>(&iv), cipher); } - inline void generate_chacha8_key(std::string password, chacha8_key& key) { + inline void generate_chacha8_key(const void *data, size_t size, chacha8_key& key) { static_assert(sizeof(chacha8_key) <= sizeof(hash), "Size of hash must be at least that of chacha8_key"); char pwd_hash[HASH_SIZE]; - crypto::cn_slow_hash(password.data(), password.size(), pwd_hash); + crypto::cn_slow_hash(data, size, pwd_hash); memcpy(&key, pwd_hash, sizeof(key)); memset(pwd_hash, 0, sizeof(pwd_hash)); } + + inline void generate_chacha8_key(std::string password, chacha8_key& key) { + return generate_chacha8_key(password.data(), password.size(), key); + } } #endif diff --git a/src/crypto/groestl.c b/src/crypto/groestl.c index e1c89cc3b..c8258add3 100644 --- a/src/crypto/groestl.c +++ b/src/crypto/groestl.c @@ -8,6 +8,7 @@ * */ +#include <stddef.h> #include "groestl.h" #include "groestl_tables.h" @@ -204,10 +205,9 @@ static void OutputTransformation(hashState *ctx) { /* initialise context */ static void Init(hashState* ctx) { - int i = 0; /* allocate memory for state and data buffer */ - for(;i<(SIZE512/sizeof(uint32_t));i++) + for(size_t i = 0; i < (SIZE512/sizeof(uint32_t)); i++) { ctx->chaining[i] = 0; } diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 60699d4e6..679edf7f9 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -413,7 +413,6 @@ BOOL SetLockPagesPrivilege(HANDLE hProcess, BOOL bEnable) void slow_hash_allocate_state(void) { - int state = 0; if(hp_state != NULL) return; |