Skip to content

Add tests that lock in v1.0.0 passwords - #2

Merged
edwest19 merged 1 commit into
mainfrom
tests/lock-v1-passwords
Nov 5, 2026
Merged

edwest19 merged 1 commit into
mainfrom
tests/lock-v1-passwords

Conversation

@edwest19

@edwest19 edwest19 commented Nov 5, 2026

Copy link
Copy Markdown
Owner

What this does

Adds automated tests that record the exact passwords SecretKey v1.0.0 produces for a set of sample accounts. No app code changes. Your existing passwords are not affected.

From now on, every pull request runs these tests. If a future change would alter any password, the tests fail and the pull request shows a red ❌ before anything is merged.

Why

SecretKey only works if the same root key and date code always regenerate the same passwords. Nothing was checking that, and the password math already changed twice in June 2026 without anyone noticing.

What's in it

  • SecretKey.Core.Tests/: a new test project (xUnit), also added to SecretKey.slnx so it shows up in Visual Studio's Test Explorer.
    • CryptoTests.cs: the building blocks (monthly key, HMAC-SHA256 checked against the published RFC 4231 test vector, mask mapping).
    • PasswordDerivationV1Tests.cs: full CSV-in/CSV-out runs, covering URL prefixing, trimming, quoted fields, accented characters, custom masks, different date codes, and sample_input.csv.
    • It also records three known v1 weaknesses (32-byte cut-off, no separator between fields, masks over 32 characters repeat). They're tested on purpose so nobody "fixes" them in place and breaks existing passwords. A fix would ship later as an explicit, opt-in v2.
    • It uses a test-only root key. No real keys are involved.
  • .github/workflows/build.yml: runs on pull requests too, adds a test job, and limits the workflow's GitHub token to read-only.

How it was checked

  • The expected passwords come from the v1.0.0 code and were cross-checked against a separate implementation of the same algorithm written independently (all matched).
  • To make sure the tests actually catch changes, seven deliberate edits to the password math were tried (e.g. the old pre-June padding, a 64-byte block, lowercasing URLs, skipping trimming). Every one made tests fail; the unchanged code passes all 21.
  • NuGet was blocked in the environment where this was written, so the real xUnit run happens here in GitHub Actions. Check the test job result below.

How to review

  1. Click Files changed to see every line.
  2. Wait for the checks at the bottom of the Conversation tab. test should be green.
  3. If you're happy, click Merge pull request, then run git pull on your PC.

Generated by Claude Code

SecretKey's promise is that the same root key and date code always
regenerate the same passwords. Nothing checked that, and the derivation
changed twice in June 2026 without a version marker.

This adds SecretKey.Core.Tests (xUnit) with known-answer tests for:
- the crypto building blocks (monthly key, HMAC-SHA256 incl. RFC 4231
  case 2, mask mapping),
- end-to-end CSV processing for typical accounts, URL prefixing,
  trimming, quoted fields, Unicode, custom masks, date codes,
- sample_input.csv,
- known v1 quirks (32-byte truncation, no field separator, mask wrap),
  so they can't be "fixed" in place and silently change passwords.

Expected values come from the v1.0.0 engine and were cross-checked
against an independent implementation. No app code is changed.

CI now runs these tests on pull requests, and the workflow token is
limited to read-only access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSQZn3X5gDJdRjbqMfKRpd
@edwest19
edwest19 merged commit 94ef6f1 into main Nov 5, 2026
2 checks passed
@edwest19
edwest19 deleted the tests/lock-v1-passwords branch November 6, 2026 03:16
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.

2 participants