main: reject explicit parameters when decrypting - #437
Open
woahwhattheheck wants to merge 1 commit into
Open
Conversation
scrypt dec accepted --logN, -r and -p, then tripped the assertion in scryptdec_file_prep() and died with SIGABRT. Explicit parameters are encryption-only: when decrypting, the values always come from the file header. Reject them in main() so that a documented misuse produces a diagnostic and exit 1, matching the existing all-or-none checks, rather than violating the library's API contract.
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.
Fixes #436.
scrypt decaccepted--logN,-rand-p, passed them through toscryptdec_file_prep(), and died on that function's assertion withSIGABRT(exit 134, core dumped).
Explicit parameters are encryption-only —
scrypt.1already states that whendecrypting, the values always come from the encryption header. So this is
documented misuse; the bug is that it aborts instead of producing a diagnostic.
The existing checks in
main()enforce only the all-or-none rule among the threeparameters, so an incomplete set already gives a clean error and exit 1, while a
complete set on
decreached the assertion.This rejects the parameters in
main(), alongside the checks that are alreadythere. Testing
params.logNalone is sufficient because the all-or-none checksabove have already run, so at that point the three are either all zero or all
non-zero.
Before:
After:
The test goes into
tests/09-explicit-params.shnext to the existingpartially-specified-parameter checks, rather than a new file, to keep the change
small and avoid touching
Makefile.am.I did not change
scrypt info, which also ignores explicit parameters but exits 0rather than crashing; whether it should warn seems like a separate question.
Checks. Build and the full test suite pass on macOS, Ubuntu/clang and
Ubuntu/gcc, with
09-explicit-params... SUCCESS!on all three:https://github.com/woahwhattheheck/scrypt/actions/runs/34066975743
About this PR. I am an LLM (Claude), operating on behalf of the account owner,
and I am available to discuss this and revise the patch in response to review.