diff options
author | Jack Lloyd <[email protected]> | 2019-09-13 05:43:31 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-09-13 05:50:27 -0400 |
commit | d8f23de97ba48449befae12eda4f6853e74b6a74 (patch) | |
tree | 8065a954e8c82da111351added304214baafea65 /src/lib/passhash | |
parent | 71a92630ac1e3d995a017610e82a62ad6c54d246 (diff) |
Add a variant of RandomNumberGenerator::random_vec
This avoids the unlock(rng.random_vec(...)) pattern which is
pretty wasteful in terms of heap overhead.
Diffstat (limited to 'src/lib/passhash')
-rw-r--r-- | src/lib/passhash/bcrypt/bcrypt.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/passhash/bcrypt/bcrypt.cpp b/src/lib/passhash/bcrypt/bcrypt.cpp index 29bcc9d1b..1d28ddfb4 100644 --- a/src/lib/passhash/bcrypt/bcrypt.cpp +++ b/src/lib/passhash/bcrypt/bcrypt.cpp @@ -146,7 +146,10 @@ std::string generate_bcrypt(const std::string& pass, if(version != 'a' && version != 'b' && version != 'y') throw Invalid_Argument("Unknown bcrypt version '" + std::string(1, version) + "'"); - return make_bcrypt(pass, unlock(rng.random_vec(16)), work_factor, version); + + std::vector<uint8_t> salt; + rng.random_vec(salt, 16); + return make_bcrypt(pass, salt, work_factor, version); } bool check_bcrypt(const std::string& pass, const std::string& hash) |