Validate scrypt work factor at construction#18
Merged
Conversation
The encrypt path accepted any work factor: values >= 31 overflowed 1 << workFactor, and anything above 20 produced files this library's own decrypt cap refuses to read back. Enforce [1, 20] eagerly, matching the existing decrypt-side maximum.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
+ Coverage 91.99% 92.00% +0.01%
==========================================
Files 41 41
Lines 2385 2390 +5
Branches 312 313 +1
==========================================
+ Hits 2194 2199 +5
Misses 133 133
Partials 58 58 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
ScryptRecipient(passphrase, workFactor)(andAgeKeygen.EncryptIdentityFile) accepted any work factor on the encrypt path: values ≥ 31 overflowed1 << workFactor, and anything above 20 produced files this library's own decrypt cap (MaxWorkFactor = 20) refuses to read back. Enforce[1, 20]eagerly at construction, throwingArgumentOutOfRangeException.Decrypt behavior is unchanged — every existing file still decrypts identically (CCTV corpus passes) — this only turns a silently-broken encrypt input into an immediate, clear error, using the cap already present on the decrypt side.
Ported from the
security-hardeningbranch (PR #1, commit 33a3040). Full suite green (371 unit + 143 CCTV).