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 {...@@ -94,7 +94,7 @@ fn Blake2s(comptime out_len: usize) type {
94 var off: usize = 0;94 var off: usize = 0;
9595
96 // Partial buffer exists from previous update. Copy into buffer then hash.96 // 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) {
98 off += 64 - d.buf_len;98 off += 64 - d.buf_len;
99 mem.copy(u8, d.buf[d.buf_len..], b[0..off]);99 mem.copy(u8, d.buf[d.buf_len..], b[0..off]);
100 d.t += 64;100 d.t += 64;
...@@ -103,7 +103,7 @@ fn Blake2s(comptime out_len: usize) type {...@@ -103,7 +103,7 @@ fn Blake2s(comptime out_len: usize) type {
103 }103 }
104104
105 // Full middle blocks.105 // Full middle blocks.
106 while (off + 64 <= b.len) : (off += 64) {106 while (off + 64 < b.len) : (off += 64) {
107 d.t += 64;107 d.t += 64;
108 d.round(b[off .. off + 64], false);108 d.round(b[off .. off + 64], false);
109 }109 }