Blake2f: compress a copy of the state, not the caller's Bytes - #220
Open
anvacaru wants to merge 2 commits into
Open
Blake2f: compress a copy of the state, not the caller's Bytes#220anvacaru wants to merge 2 commits into
anvacaru wants to merge 2 commits into
Conversation
…ler's Bytes blake2b_compress updates the state vector h in place; hook_KRYPTO_blake2compress pointed h straight into params->data, mutating the K Bytes object passed to the hook. Bytes terms can be structure-shared on the LLVM backend heap, so the in-place update corrupted unrelated terms sharing the buffer (observed as BLAKE2b IV bytes appearing inside a transaction's calldata term in evm-semantics conformance runs). Copy the 64-byte state to a local buffer and compress that.
…iasing The existing Blake2Compress test only checks the hook's return value, which was correct even while the hook mutated the Bytes it was given. blake2NoAlias passes one Bytes term to Blake2Compress and to the check that follows it, so an in-place update of the argument is observable: it is false before 996c251 and true after. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
plugin-c/crypto.cpp: copy the 64-byte blake2 state to a local buffer before compressing.krypto/src/tests/integration: regression test that fails when the hook mutates its argument.Blake2CompressNoAliasingcase fails against the pre-fix hook and passes after it; the other Blake2 cases pass in both states, since the return value was never wrong.