commit b1cf0196dfc434c425b02512072553e6cbd4c09a (tree)
parent fad87bef9af8948a475fd4577b44082fdde303cd
Author: Mantas Jonytis <mantas@jonytis.eu>
Date: Sat, 1 Aug 2020 15:15:45 +0300
blake2s: off-by-one on update
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git 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);
}