feat(crypto): KEY-13 KDF floors + cross-verified golden vectors + downgrade rejection (#15) #197

Merged
amiryahaya merged 1 commit from feat/key13-kdf-floors into main 2026-11-13 14:00:58 +01:00
Owner

Closes the remaining scope of #15 (exit criteria: floor vectors pass; downgrade-rejection test exists). The OAuth state-signing half (IDA-10) already ships — IdpStateService is asymmetric-signed via IKeyStore, TTL 10 min, atomic single-use nonce consume — nothing to do there.

rust failsulit-crypto

  • KEY-13 floor table (audit H-2): native 64 MiB / WASM 32 MiB, t ≥ 3, Argon2Params::meets_key13_floor(tier). p is a validity check (≥ 1): parallelism only parallelizes memory access, it does not lower offline attack cost at fixed m/t (SRS wording p = 1 is the RFC 9106 recommended profile, not a minimum).
  • Two golden vectors (native + WASM floor profiles) cross-verified against the C reference implementation (argon2-cffi / phc-winner-argon2, RFC 9106 suite) in a throwaway container — not self-generated. Frozen fixed inputs (passphrase + bytes(range(16)) salt) → these are the cross-client contract for the SEC-05/KEY-06 golden-vector suite (desktop native / future WASM / SDK must all derive identical keys).
  • Ladder-vs-floor documentation test: Argon2idStandard (64 MiB, p=4) conforms; Argon2idLow (19 MiB) is below EVERY KEY-13 floor — dormant tier (no wrap path consumes it), behavior unchanged here; filed as a follow-up for the iOS/mobile tier ladder decision.
  • (The RFC 9106 §5.3 vector itself needs secret + associated-data inputs; argon2 0.5.3 supports secret but not AD, so the C-reference cross-check on the floor profiles is the chosen KAT form.)

desktop master_key_service

  • Real/decoy/wipe passphrase layers now parse the stored argon2id;m=…;t=…;p=… entry and derive under it; unparseable or below-floor entries refuse to derive (KEY-13 downgrade rejection). Previously the stored params were informational only and the derivation always used hardcoded floor params.
  • unlock_with_passphrase now distinguishes wrong passphrase (ladder counts) from broken wrap state (refusal surfaces immediately) — a tampered params entry can no longer masquerade as an endless "incorrect passphrase" ladder; change/remove flows propagate the refusal too.
  • Behavioral compat: every shipped layer stores exactly the floor profile, so parse → derive is byte-identical to the old path (roundtrip tests unchanged and green).

server backstop

  • KeyFeature.ValidateKdfFloor enforces the published absolute floor (WASM tier: m ≥ 32768, t ≥ 3) on all three wrap-write paths (self upload /wraps, pairing approve, recovery rekey). Fields remain optional (pre-#15 rows legal); per-tier floors stay client-side per KEY-13.

Verification

  • rust: native crate 38/38, src-tauri 61/61 (6 new floor/KAT tests + 5 new downgrade-rejection tests incl. tampered-layer, garbage, missing-params, decoy-layer variants)
  • server: 1038 total, 0 failed, 39 skipped (known skip set) — 5 new WrapKdfFloorTests (below-floor m/t → 400 + nothing stored, at-floor 32768/3 accepted, null accepted, pairing-approve below-floor → 400)

Follow-ups filed separately

  • iOS Argon2idLow tier vs KEY-13 native floor (mobile ladder reconciliation)
  • #196 (migration smoke test — the staging incident), #146 (runner isolation)
Closes the remaining scope of #15 (exit criteria: **floor vectors pass; downgrade-rejection test exists**). The OAuth state-signing half (IDA-10) already ships — `IdpStateService` is asymmetric-signed via `IKeyStore`, TTL 10 min, atomic single-use nonce consume — nothing to do there. ## rust `failsulit-crypto` - **KEY-13 floor table** (audit H-2): native 64 MiB / WASM 32 MiB, t ≥ 3, `Argon2Params::meets_key13_floor(tier)`. `p` is a validity check (≥ 1): parallelism only parallelizes memory access, it does not lower offline attack cost at fixed m/t (SRS wording `p = 1` is the RFC 9106 recommended profile, not a minimum). - **Two golden vectors** (native + WASM floor profiles) **cross-verified against the C reference implementation** (argon2-cffi / phc-winner-argon2, RFC 9106 suite) in a throwaway container — not self-generated. Frozen fixed inputs (passphrase + `bytes(range(16))` salt) → these are the cross-client contract for the SEC-05/KEY-06 golden-vector suite (desktop native / future WASM / SDK must all derive identical keys). - Ladder-vs-floor documentation test: `Argon2idStandard` (64 MiB, p=4) conforms; **`Argon2idLow` (19 MiB) is below EVERY KEY-13 floor** — dormant tier (no wrap path consumes it), behavior unchanged here; filed as a follow-up for the iOS/mobile tier ladder decision. - (The RFC 9106 §5.3 vector itself needs secret + associated-data inputs; argon2 0.5.3 supports secret but not AD, so the C-reference cross-check on the floor profiles is the chosen KAT form.) ## desktop `master_key_service` - Real/decoy/wipe passphrase layers now **parse the stored `argon2id;m=…;t=…;p=…` entry and derive under it**; unparseable or below-floor entries **refuse to derive** (KEY-13 downgrade rejection). Previously the stored params were informational only and the derivation always used hardcoded floor params. - `unlock_with_passphrase` now distinguishes **wrong passphrase** (ladder counts) from **broken wrap state** (refusal surfaces immediately) — a tampered params entry can no longer masquerade as an endless "incorrect passphrase" ladder; change/remove flows propagate the refusal too. - Behavioral compat: every shipped layer stores exactly the floor profile, so parse → derive is byte-identical to the old path (roundtrip tests unchanged and green). ## server backstop - `KeyFeature.ValidateKdfFloor` enforces the published **absolute** floor (WASM tier: m ≥ 32768, t ≥ 3) on all three wrap-write paths (self upload `/wraps`, pairing approve, recovery rekey). Fields remain optional (pre-#15 rows legal); per-tier floors stay client-side per KEY-13. ## Verification - rust: native crate **38/38**, src-tauri **61/61** (6 new floor/KAT tests + 5 new downgrade-rejection tests incl. tampered-layer, garbage, missing-params, decoy-layer variants) - server: **1038 total, 0 failed, 39 skipped** (known skip set) — 5 new `WrapKdfFloorTests` (below-floor m/t → 400 + nothing stored, at-floor 32768/3 accepted, null accepted, pairing-approve below-floor → 400) ## Follow-ups filed separately - iOS `Argon2idLow` tier vs KEY-13 native floor (mobile ladder reconciliation) - #196 (migration smoke test — the staging incident), #146 (runner isolation)
feat(crypto): KEY-13 KDF floors + cross-verified golden vectors + downgrade rejection (#15)
All checks were successful
Security CI / security-scan (pull_request) Successful in 3m13s
API CI / build-and-test (pull_request) Successful in 5m2s
Desktop CI / lint-and-test (pull_request) Successful in 12m29s
34f26f1674
Closes the remaining #15 scope (exit: floor vectors pass; downgrade-
rejection test exists). The OAuth state-signing half (IDA-10) already
ships — IdpStateService is asymmetric-signed via IKeyStore, TTL 10 min,
single-use nonce consume; nothing to do there.

rust failsulit-crypto:
- KEY-13 floor table: FLOOR_NATIVE_MEMORY_KIB = 65536 (64 MiB),
  FLOOR_WASM_MEMORY_KIB = 32768 (32 MiB), FLOOR_MIN_TIME_COST = 3, plus
  Argon2Params::meets_key13_floor(tier). p is a validity check (>= 1):
  parallelism only parallelizes memory access and does not lower offline
  crack cost at fixed m/t.
- Two golden vectors (native + WASM floor profiles, fixed passphrase +
  salt) CROSS-VERIFIED against the C reference implementation
  (argon2-cffi / phc-winner-argon2) — not self-generated. These are the
  cross-client contract for the SEC-05/KEY-06 golden-vector suite.
- Ladder-vs-floor documentation test: Argon2idStandard conforms;
  Argon2idLow (19 MiB) is below EVERY KEY-13 floor — tracked as a
  separate mobile-tier follow-up, dormant tier, no behavior change.

desktop master_key_service:
- Passphrase layers (real/decoy/wipe) now parse the stored
  argon2id;m=;t=;p= entry and derive under it; unparseable or
  below-floor entries REFUSE to derive (KEY-13 downgrade rejection) —
  previously the stored params were informational only.
- unlock_with_passphrase distinguishes wrong-passphrase (ladder) from
  broken wrap state (surface immediately): a tampered params entry can
  no longer masquerade as an endless 'incorrect passphrase' ladder, and
  change/remove flows propagate the refusal instead of reporting a typo.

server (defense-in-depth backstop):
- KeyFeature.ValidateKdfFloor enforces the absolute floor (WASM tier,
  m >= 32768, t >= 3) on the three wrap-write paths (self upload,
  pairing approve, recovery rekey); fields stay optional (pre-#15 rows
  legal). Client-tier floors remain client-side per KEY-13.

tests: rust 99 green (38 native + 61 src-tauri); server suite 1038 total
(1033 + 5 new WrapKdfFloorTests), 0 failed, 39 skipped (known set).
Sign in to join this conversation.
No description provided.