fix: always pad bytes with 10*0 (#267)
This commit is contained in:
parent
3882e0f719
commit
0acceaa526
1 changed files with 2 additions and 4 deletions
|
@ -88,10 +88,8 @@ impl Hasher for Rpx256 {
|
||||||
// `i` is not zero, then the chunks count wasn't enough to fill the state range, and an
|
// `i` is not zero, then the chunks count wasn't enough to fill the state range, and an
|
||||||
// additional permutation must be performed.
|
// additional permutation must be performed.
|
||||||
let i = bytes.chunks(BINARY_CHUNK_SIZE).fold(0, |i, chunk| {
|
let i = bytes.chunks(BINARY_CHUNK_SIZE).fold(0, |i, chunk| {
|
||||||
// the last element of the iteration may or may not be a full chunk. if it's not, then
|
// we always pad `bytes` with a 1 followed by as many 0's to fill up `buf`.
|
||||||
// we need to pad the remainder bytes of the chunk with zeroes, separated by a `1`.
|
if i != num_field_elem - 1 {
|
||||||
// this will avoid collisions at the bytes level.
|
|
||||||
if chunk.len() == BINARY_CHUNK_SIZE {
|
|
||||||
buf[..BINARY_CHUNK_SIZE].copy_from_slice(chunk);
|
buf[..BINARY_CHUNK_SIZE].copy_from_slice(chunk);
|
||||||
} else {
|
} else {
|
||||||
buf.fill(0);
|
buf.fill(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue