Commit b1cf0196df

Mantas Jonytis <mantas@jonytis.eu>
2020-08-01 14:15:45
blake2s: off-by-one on update
1 parent fad87be
Changed files (1)
lib
std
crypto
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);
             }