Panic if unexpected length in PassthroughDigest #335
Closed
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.
PassthroughDigest
represents a workaround for the requirement for a Digest implementation for use with thek256
andp256
crates.Even though it it is only meant to be used internally for these specific uses, this PR updates it to add an additional requirement for security/robustness. This change is to require that the input data length is exactly 32 bytes, rather than allowing other lengths.
This change enables panic to happen if an incorrect length is passed. An incorrect length would not be passed in the current code but could occur if code is changed resulting in incorrect use ofPassthroughDigest
. In case of such a change, we could consider it better to panic and reveal the bug during development, rather than potentially allow execution to proceed in a bad state.Edit: test failure suggests this is not a correct change.