Skip to content

Conversation

@Galoretka
Copy link

The buffer was zeroed after each full chunk in KangarooTwelveCore::process_chunk(). This is unnecessary because subsequent reads only consume [..bufpos] and bufpos is reset to 0. Removing the memset avoids extra work on long inputs and aligns with the project’s pattern of cleaning sensitive data via Drop under the zeroize feature.

@tarcieri
Copy link
Member

tarcieri commented Dec 1, 2025

This is unnecessary because subsequent reads only consume [..bufpos]

I would feel better about that if there were a debug_assert_eq!(self.bufpos, CHUNK_SIZE) for the if self.chain_length == 0 above, though I guess if that weren't the case it could be unnecessarily hashing zeros

@newpavlov
Copy link
Member

I wonder why the implementation simply does not use CHUNK_SIZE for block size.

@tarcieri
Copy link
Member

tarcieri commented Dec 2, 2025

@newpavlov IIUC, the block size is implicitly CHUNK_SIZE unless chaining is being used

@Galoretka
Copy link
Author

This is unnecessary because subsequent reads only consume [..bufpos]

I would feel better about that if there were a debug_assert_eq!(self.bufpos, CHUNK_SIZE) for the if self.chain_length == 0 above, though I guess if that weren't the case it could be unnecessarily hashing zeros

corrected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants