Repository navigation
A slow moment is not a wrong passphrase (age's excessive-work refusal) - #19
Conversation
Found on macOS CI (PR #18's run, macOS Py 3.10): unlocking a key made a moment earlier failed with pyrage's "Excessive work parameter for passphrase", which codebud reported as "wrong passphrase". age sets the passphrase's scrypt work factor from the machine's speed when it seals the key, and on every unlock measures the speed again and refuses a work factor far above it. On a busy or throttled moment -- a loaded runner, a laptop on battery -- a correct passphrase is refused, and codebud told the user it was wrong: a lockout that sends them looking for a typo, or giving their data up for lost. pyrage offers no control over the work factor, so codebud now retries that specific refusal (age measures again each time) three times, then says what happened -- the machine was slower than when the key was sealed, the passphrase may well be right -- instead of "wrong passphrase". A genuinely wrong passphrase is still reported as such, and not retried. The manual's Troubleshooting chapter gains "Key Refused on a Slow Moment", including the persistent case of a key moved to a much slower machine.
Review summary: correct, with one documented limitOne full sweep over this PR's head: conditions → scenarios → code → De Morgan. Condition (
De Morgan: what's still reported as "wrong passphrase". age localises its error messages (Fluent), so on a system language other than English the excessive-work text may not contain "excessive work". That case falls back to today's behaviour: "wrong passphrase", no retry. That's no worse than before this PR, and pyrage gives no error code to match on instead. I'll record it as a known limit rather than block on it. Cost: a persistent refusal now takes up to three scrypt runs (a few seconds) before the message. That's acceptable. Verdict: correct. I'll merge with a merge commit once CI passes on all jobs, macOS included, and before #18, whose macOS failure this explains. |
|
Merging. The review found the fix correct, with one documented limit: on a non-English system, age's localised message falls back to today's behaviour. CI passes on all five jobs at |
A pre-existing defect found while PR #18's CI ran. It isn't caused by #18, which doesn't touch crypto.
The failure
macOS CI (Python 3.10) failed
test_crypto.py::test_create_unlock_and_round_trip: unlocking a key created a moment earlier raised pyrage's "Excessive work parameter for passphrase", which codebud reported as "wrong passphrase".Why
age sets the passphrase's scrypt work factor from the machine's speed when it seals the key. On every unlock it measures the speed again and refuses a work factor far above it. On a busy or throttled moment (a loaded CI runner, a laptop on battery), a correct passphrase is refused. Calling that a wrong passphrase sends the user looking for a typo, or giving their data up for lost.
Fix
pyrage exposes no work-factor control (
decrypt(ciphertext, passphrase)only). Socrypto._open_identitynow:A genuinely wrong passphrase is still reported as such, and isn't retried. The manual's Troubleshooting chapter gains "Key Refused on a Slow Moment", including the persistent case: a key moved to a much slower machine, which
key passwdcan't fix because it seals for the machine it runs on.Testing
3 new tests: retried then opened; a persistent refusal not called a wrong passphrase; a wrong passphrase reported once, not retried. 1457 tests pass, ruff is clean, the manual builds without warnings, and
make distcheckpasses.