1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

argon2 - copy raw hash after possible encoding, not before

(irrelevant in libsodium)
This commit is contained in:
Frank Denis 2020-08-16 11:35:08 +02:00
parent bc3b6a4694
commit ee6f457225

View File

@ -134,11 +134,6 @@ argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
return result; return result;
} }
/* if raw hash requested, write it */
if (hash) {
memcpy(hash, out, hashlen);
}
/* if encoding requested, write it */ /* if encoding requested, write it */
if (encoded && encodedlen) { if (encoded && encodedlen) {
if (argon2_encode_string(encoded, encodedlen, if (argon2_encode_string(encoded, encodedlen,
@ -150,6 +145,11 @@ argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
} }
} }
/* if raw hash requested, write it */
if (hash) {
memcpy(hash, out, hashlen);
}
sodium_memzero(out, hashlen); sodium_memzero(out, hashlen);
free(out); free(out);