authorgravatar for mantas@jonytis.euMantas Jonytis <mantas@jonytis.eu> 2020-08-01 15:31:46+03:00
committergravatar for mantas@jonytis.euMantas Jonytis <mantas@jonytis.eu> 2020-08-01 15:31:46+03:00
log1ae40146e68720047190f3c5cbd693669bbb1d87
tree203725fc133fa751e9207a745eaf2e66c215a24c
parenteee9abe1b48c06e2a56cc955c0a773dc7a8de514

blake2b: off-by-one on update


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

lib/std/crypto/blake2.zig+2-2
...@@ -382,7 +382,7 @@ fn Blake2b(comptime out_len: usize) type {...@@ -382,7 +382,7 @@ fn Blake2b(comptime out_len: usize) type {
382 var off: usize = 0;382 var off: usize = 0;
383383
384 // Partial buffer exists from previous update. Copy into buffer then hash.384 // Partial buffer exists from previous update. Copy into buffer then hash.
385 if (d.buf_len != 0 and d.buf_len + b.len >= 128) {385 if (d.buf_len != 0 and d.buf_len + b.len > 128) {
386 off += 128 - d.buf_len;386 off += 128 - d.buf_len;
387 mem.copy(u8, d.buf[d.buf_len..], b[0..off]);387 mem.copy(u8, d.buf[d.buf_len..], b[0..off]);
388 d.t += 128;388 d.t += 128;
...@@ -391,7 +391,7 @@ fn Blake2b(comptime out_len: usize) type {...@@ -391,7 +391,7 @@ fn Blake2b(comptime out_len: usize) type {
391 }391 }
392392
393 // Full middle blocks.393 // Full middle blocks.
394 while (off + 128 <= b.len) : (off += 128) {394 while (off + 128 < b.len) : (off += 128) {
395 d.t += 128;395 d.t += 128;
396 d.round(b[off .. off + 128], false);396 d.round(b[off .. off + 128], false);
397 }397 }