Repository navigation
Conversation
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.
Blake2Statekeeps whateverdigest_sizeit is handed and_checkparamsonly checks the upper bound, sogenerichash_blake2b_finalcan hand libsodium an out-of-range output length.blake2b_finaltreatsoutlen == 0oroutlen > 64as misuse and callssodium_misuse(), so these abort the interpreter with SIGABRT instead of raising (#967, #964):Blake2State(256)aborts the same way through the(uint8_t)cast incrypto_generichash_blake2b_final, and that 1..64 range is also what keepsffi.buffer(_digest, state.digest_size)inside the 64-byte buffer the function allocates fromcrypto_generichash_BYTES_MAX.Checking at the three points where a digest size enters the bindings means no caller can reach
blake2b_finalwith a size it rejects, including a state built directly rather than throughgenerichash_blake2b_init. The lower bound is 1 and notcrypto_generichash_BYTES_MIN: libsodium's C API accepts 1 to 64, and the blake2 vectors intests/datago down to a 1-byte digest, so enforcing 16 would break working callers. #886 covers that question separately.