authorgravatar for mantas@jonytis.euMantas Jonytis <mantas@jonytis.eu> 2020-08-01 15:15:45+03:00
committergravatar for mantas@jonytis.euMantas Jonytis <mantas@jonytis.eu> 2020-08-01 15:15:45+03:00
logb1cf0196dfc434c425b02512072553e6cbd4c09a
treeb3ec188147a5482cad3a1422bba8fd21ae334738
parentfad87bef9af8948a475fd4577b44082fdde303cd

blake2s: off-by-one on update


1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/crypto/blake2.zig+2-2
......@@ -94,7 +94,7 @@ fn Blake2s(comptime out_len: usize) type {
9494 var off: usize = 0;
9595
9696 // Partial buffer exists from previous update. Copy into buffer then hash.
97 if (d.buf_len != 0 and d.buf_len + b.len >= 64) {
97 if (d.buf_len != 0 and d.buf_len + b.len > 64) {
9898 off += 64 - d.buf_len;
9999 mem.copy(u8, d.buf[d.buf_len..], b[0..off]);
100100 d.t += 64;
......@@ -103,7 +103,7 @@ fn Blake2s(comptime out_len: usize) type {
103103 }
104104
105105 // Full middle blocks.
106 while (off + 64 <= b.len) : (off += 64) {
106 while (off + 64 < b.len) : (off += 64) {
107107 d.t += 64;
108108 d.round(b[off .. off + 64], false);
109109 }