Skip to content

Validate scrypt work factor at construction#18

Merged
pscheid92 merged 1 commit into
mainfrom
fix/scrypt-work-factor
Jul 23, 2026
Merged

Validate scrypt work factor at construction#18
pscheid92 merged 1 commit into
mainfrom
fix/scrypt-work-factor

Conversation

@pscheid92

Copy link
Copy Markdown
Owner

ScryptRecipient(passphrase, workFactor) (and AgeKeygen.EncryptIdentityFile) accepted any work factor on the encrypt path: values ≥ 31 overflowed 1 << 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, throwing ArgumentOutOfRangeException.

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-hardening branch (PR #1, commit 33a3040). Full suite green (371 unit + 143 CCTV).

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.
@pscheid92
pscheid92 merged commit ad6b402 into main Jul 23, 2026
4 checks passed
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.00%. Comparing base (d618cdf) to head (182e183).
⚠️ Report is 4 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant