hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 39579f220aa424220d1fe883ad207800bbbe3353
parent ae9f39ed90742d9384c6564199935a56d4727034
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Tue, 25 Jan 2022 20:27:54 +0100

crypto::argon2: make sure to close blake2b after use

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>

Diffstat:
Mcrypto/argon2/argon2.ha | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/crypto/argon2/argon2.ha b/crypto/argon2/argon2.ha @@ -292,6 +292,7 @@ fn inithash( ) void = { let u32buf: [4]u8 = [0...]; let h = blake2b::blake2b([], 64); + defer hash::close(&h); hash_leputu32(&h, cfg.parallel); hash_leputu32(&h, taglen); @@ -326,6 +327,7 @@ fn varhash(dest: []u8, block: []u8) void = { if (len(dest) <= 64) { let h = blake2b::blake2b([], len(dest)); + defer hash::close(&h); hash_leputu32(&h, len(dest): u32); hash::write(&h, block); hash::finish(&h, dest); @@ -337,6 +339,8 @@ fn varhash(dest: []u8, block: []u8) void = { const r = divceil(len(dest): u32, 32) - 2; let v: [64]u8 = [0...]; let h = blake2b::blake2b([], 64); + defer hash::close(&h); + let destbuf = bufio::fixed(dest, io::mode::WRITE); hash_leputu32(&h, len(dest): u32); @@ -354,6 +358,7 @@ fn varhash(dest: []u8, block: []u8) void = { const remainder = len(dest) - 32 * r; let hend = blake2b::blake2b([], remainder); + defer hash::close(&hend); hash::write(&hend, v[..]); hash::finish(&hend, v[..remainder]); io::write(&destbuf, v[..remainder])!;