From b1cf0196dfc434c425b02512072553e6cbd4c09a Mon Sep 17 00:00:00 2001 From: Mantas Jonytis Date: Sat, 1 Aug 2020 15:15:45 +0300 Subject: [PATCH] blake2s: off-by-one on update --- lib/std/crypto/blake2.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/crypto/blake2.zig b/lib/std/crypto/blake2.zig index 366f6ec2cd..0afb520b0c 100644 --- a/lib/std/crypto/blake2.zig +++ b/lib/std/crypto/blake2.zig @@ -94,7 +94,7 @@ fn Blake2s(comptime out_len: usize) type { var off: usize = 0; // Partial buffer exists from previous update. Copy into buffer then hash. - if (d.buf_len != 0 and d.buf_len + b.len >= 64) { + if (d.buf_len != 0 and d.buf_len + b.len > 64) { off += 64 - d.buf_len; mem.copy(u8, d.buf[d.buf_len..], b[0..off]); d.t += 64; @@ -103,7 +103,7 @@ fn Blake2s(comptime out_len: usize) type { } // Full middle blocks. - while (off + 64 <= b.len) : (off += 64) { + while (off + 64 < b.len) : (off += 64) { d.t += 64; d.round(b[off .. off + 64], false); }