Repository navigation
Password math v2: fix collisions and bias before first use - #3
Merged
Merged
Conversation
v1 hashed only the first 32 bytes of title+url+username with no separator, so different logins on one site could share a password, fields could run together, characters were slightly biased, and masks over 32 characters repeated. Nobody depends on v1 passwords yet, so this replaces it now, once, before the first release. v2 (spec: docs/password-derivation.md): - root key must be 64 hex chars and is decoded to 32 bytes; anything else (including the config.example placeholder) is rejected - monthly key = HKDF-SHA256(root key, info = label + date code) - account input = label, title, url, username, mask, each length- prefixed; fields are trimmed and NFC-normalized; URLs without http:// or https:// get https:// - password bytes = HMAC-SHA256(monthly key, input || counter) blocks - each mask character uses rejection sampling, so picks are unbiased Tests now lock v2. All expected values were re-computed by a separate implementation written only from the spec, and nine deliberate breaks of the math were each caught. The CLI reports a bad root key instead of crashing; the UI already shows the error. Every generated password changes from v1. This is intentional. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSQZn3X5gDJdRjbqMfKRpd
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.
What this does
Replaces SecretKey's password math with a corrected version 2, before anyone starts using it. Every password SecretKey generates will be different from v1.0.0. That's intentional and safe, because no one has saved SecretKey passwords yet.
Why
The v1 math had four weaknesses (found in the evaluation, and locked by the tests from #2):
alice@…andbob@…on bhphotovideo.com got the same passwordAhluk3(oqe46vsYzlls2>wli85ab,c) and (a,bc) got the same passwordx×40 = 32 letters + the first 8 againHow v2 works
The exact recipe is in
docs/password-derivation.md, so the passwords can be regenerated even without this app. In short:REPLACE_WITH_YOUR_ROOT_KEYplaceholder, is now rejected instead of silently producing weak passwords.https://is added to bare URLs.Files changed
SecretKey.Core/Crypto.cs: the new math.SecretKey.Core/Processor.cs: calls the new math (CSV handling unchanged for now).SecretKey/Program.cs: the command-line app prints a clear error for a bad root key instead of crashing. The UI already shows errors.SecretKey.Core.Tests/: v1 tests replaced with 34 v2 tests (known passwords, plus tests proving each weakness above is gone).docs/password-derivation.md: the spec.How it was checked
After merging
git pullon your PC.Generated by Claude Code