1
0
mirror of https://github.com/henrydcase/nobs.git synced 2024-11-22 23:28:57 +00:00

sha3: simplifies Read function

This commit is contained in:
Henry Case 2020-10-03 22:08:28 +01:00
parent cccb9890e1
commit bd23898fdb

View File

@ -179,22 +179,17 @@ func (c *state) Read(out []byte) (nread int, err error) {
// copy out full blocks and squeeze. at this point
// there is no more data in the buffer.
nblocks := l / rate
for i := 0; i < nblocks; i++ {
for nblocks > 0 {
keccakF1600(&c.a)
copyOut(c, out[:rate])
out = out[rate:]
}
// produce more if needed
l = len(out)
if l == 0 {
return nread, nil
nblocks--
}
keccakF1600(&c.a)
copyOut(c, buf)
copy(out, buf[:l])
c.idx = rate - l
copy(out, buf[:len(out)])
c.idx = rate - len(out)
return nread, nil
}