Files
jaap-jan 7016ce36f1 Key the local cache to the identity, not to the door it was opened through
Groundwork for a device key, and a spec change rather than a feature. ADR 0007
records the decision it clears the way for: a Windows Hello gesture guarding a
protected blob, with the passphrase kept as a permanent fallback.

The reason that decision needed this first is that a device key cannot open a
session on its own. SessionOpener derived two things from the passphrase master
key — the bundle, and the local cache key — and a device wrap is
SealTo(device_x25519_pk), which yields the bundle and never computes a master key
at all. A device unlock could therefore have opened the identity and still not
read the cache it had itself written.

So LocalCacheKey now derives from the bundle: dsh1/localcache/v1 → v2, specified
in crypto.md §3.2. Every wrap that opens a vault ends up holding the bundle, so
every door reaches the same cache.

Extract-and-expand, not expand alone. Everything derived from the master key uses
HKDF-Expand directly, which is sound because an Argon2id output is uniformly
random over its whole length. The bundle's encoding is not — it opens with a
fixed 14-byte label and carries a version, a generation and a timestamp before
reaching any key material — so it needs the extract step to become a pseudorandom
key first.

Two consequences fell out, both improvements and neither the point:

- A passphrase change no longer discards the local cache. The bundle is unchanged
  by a re-wrap, so the cache key is too. Under v1 changing a passphrase silently
  orphaned every cached row and the next launch re-pulled the whole vault.
- Recovery-code unlock is fixed before it ships. It derives a different master key
  from a different secret and a different salt, so under v1 it would have had the
  same defect as the device path, and nobody would have noticed until it landed.

The cache becomes unreadable exactly when the identity is rotated, which is the
correct moment to discard it. Existing caches are discarded and re-pulled on
upgrade — already the specified behaviour for a stale cache, and the reason the
label is versioned rather than reused: a v1 cache must fail to open rather than
decrypt to nonsense.

One stated guarantee got weaker and now says so. crypto.md §10 claimed locking
meant "nothing on disk can be read again without the passphrase." Where a device
wrap exists that is no longer true, and it would have been untrue under either
candidate design — the alternative was storing a copy of the cache key in the
device blob, which is the same door with an extra key lying next to it. The
wording now points at ADR 0007, because what guards the device key is a platform
decision and not a property of this specification.

A golden vector was quietly lying, which is the part worth reading twice. The
"local-cache" entry pinned HKDF-SHA512-Expand over a fixed PRK — a construction
the cache key no longer uses. Regenerating it would have produced a green suite
describing a derivation this code does not perform. It is replaced by a vector
over a bundle whose every byte is pinned: the label, version 1, generation 1, a
fixed timestamp and two recognisable key scalars, all visible in the fixture so a
second implementation can check itself against it. UserSecretBundle.TryDecode is
internal for this, because Create draws fresh randomness and so can never produce
a reproducible input.

Mutation tested, and this one earns its keep: dropping the extract step now fails
CommittedVectors_MatchCurrentImplementation. The vector it replaced could not
have caught that, because it never touched the bundle at all.

One test became false and says so. ARecordSealedUnderAnotherPassphrase is now
ARecordSealedByAnotherIdentity: a different passphrase deliberately no longer
changes the cache key, and TheLocalCacheKey_SurvivesAPassphraseChange pins that.
What must still be unreadable is another user's cache. CacheHarness therefore
generates an identity rather than deriving from a passphrase, and has no
passphrase parameter left — the cache key is not a question about passphrases any
more.

SyncHarness's two simulated machines now derive the same cache key, which is what
keying on the bundle means: they are the same user holding the same identity. They
still have separate cache databases, so nothing is shared between them but the key
that would open either. Both harnesses lost a MasterKey field that existed only to
make a protector.

858 tests green. Zero warnings, dotnet format clean.

Not done: the device key itself. Three pieces remain, and the middle one was a
discovery rather than a plan — EnrollmentService.AddDevice runs only during
enrollment, so every already-enrolled account, which is all of them, needs an
endpoint to add a device wrap while unlocked. The client proves possession by
producing the wrap, so that shape falls out of the crypto. After that: the
protector seam with the wrap cached locally for offline unlock, then the Hello
implementation and the unlock-screen UI, which is where the Windows TFM lands and
where automated testing stops.
2026-07-30 12:46:55 +02:00

309 lines
15 KiB
JSON

{
"_comment": "Generated by DodoSSH.Crypto.Tests.GoldenVectors. Normative source: docs/crypto.md.",
"_warning": "A failing assertion here is a regression or an intentional versioned format change. Do not regenerate to make it pass.",
"specVersion": 1,
"aad": [
{
"name": "item-payload",
"purpose": 4,
"resourceType": 5,
"resourceId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"keyId": "0192f0c8-9999-7aaa-8bbb-cccccccccccc",
"keyGeneration": 7,
"itemVersion": 3,
"aadVersion": 1,
"schemaVersion": 1,
"canonicalEncoding": "647368310a0104050192f0c81a2b7c3d8e4f5a6b7c8d9e0f0192f0c899997aaa8bbbcccccccccccc000000070000000300010000000000000000000000000000",
"aad": "bb106e753e2fd9ac31142889a4356cbf9fc1f8db3777a1921ecbb5481bd4379e"
},
{
"name": "item-payload-other-resource",
"purpose": 4,
"resourceType": 5,
"resourceId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e10",
"keyId": "0192f0c8-9999-7aaa-8bbb-cccccccccccc",
"keyGeneration": 7,
"itemVersion": 3,
"aadVersion": 1,
"schemaVersion": 1,
"canonicalEncoding": "647368310a0104050192f0c81a2b7c3d8e4f5a6b7c8d9e100192f0c899997aaa8bbbcccccccccccc000000070000000300010000000000000000000000000000",
"aad": "ae87f8da1a55b36286ed103a11fb51145adff18a222557db30422918eba6c29f"
},
{
"name": "item-metadata",
"purpose": 5,
"resourceType": 4,
"resourceId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"keyId": "00000000-0000-0000-0000-000000000000",
"keyGeneration": 1,
"itemVersion": 1,
"aadVersion": 1,
"schemaVersion": 1,
"canonicalEncoding": "647368310a0105040192f0c81a2b7c3d8e4f5a6b7c8d9e0f00000000000000000000000000000000000000010000000100010000000000000000000000000000",
"aad": "cfb042451484a4f484b45e812a2c7667d12592bcb8ec47be5b5ef95c38b1d3ad"
},
{
"name": "vault-key-grant",
"purpose": 2,
"resourceType": 3,
"resourceId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"keyId": "00000000-0000-0000-0000-000000000000",
"keyGeneration": 2,
"itemVersion": 0,
"aadVersion": 1,
"schemaVersion": 1,
"canonicalEncoding": "647368310a0102030192f0c81a2b7c3d8e4f5a6b7c8d9e0f00000000000000000000000000000000000000020000000000010000000000000000000000000000",
"aad": "5c9444daa7f74193b04abefb57d5a49a8782e8e1a7fd97771865f9e038f8c957"
},
{
"name": "user-secret-bundle",
"purpose": 1,
"resourceType": 1,
"resourceId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"keyId": "00000000-0000-0000-0000-000000000000",
"keyGeneration": 1,
"itemVersion": 0,
"aadVersion": 1,
"schemaVersion": 1,
"canonicalEncoding": "647368310a0101010192f0c81a2b7c3d8e4f5a6b7c8d9e0f00000000000000000000000000000000000000010000000000010000000000000000000000000000",
"aad": "9f73034823c49cdfcad4fcc75e67ae22be151a92afed72ab7548097ef5a99f68"
},
{
"name": "all-zero-ids",
"purpose": 6,
"resourceType": 0,
"resourceId": "00000000-0000-0000-0000-000000000000",
"keyId": "00000000-0000-0000-0000-000000000000",
"keyGeneration": 0,
"itemVersion": 0,
"aadVersion": 1,
"schemaVersion": 1,
"canonicalEncoding": "647368310a0106000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000",
"aad": "cebc8d57709c0ebe47874c85fc39aa538e17c4202b767673c8636ef181cd1664"
}
],
"envelope": [
{
"name": "xchacha20poly1305",
"algId": 1,
"nonce": "a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7",
"ciphertext": "000102030405060708090a0b0c0d0e0f10111213",
"prefixSize": 30,
"envelope": "445348310100a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7000102030405060708090a0b0c0d0e0f10111213"
},
{
"name": "aes256gcm",
"algId": 2,
"nonce": "b0b1b2b3b4b5b6b7b8b9babb",
"ciphertext": "000102030405060708090a0b0c0d0e0f10111213",
"prefixSize": 18,
"envelope": "445348310200b0b1b2b3b4b5b6b7b8b9babb000102030405060708090a0b0c0d0e0f10111213"
},
{
"name": "sealto-x25519",
"algId": 3,
"nonce": "a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7",
"ephemeralPublicKey": "c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf",
"ciphertext": "000102030405060708090a0b0c0d0e0f10111213",
"prefixSize": 62,
"envelope": "445348310300c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7000102030405060708090a0b0c0d0e0f10111213"
}
],
"aead": [
{
"name": "xchacha20poly1305-with-canonical-aad",
"key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"nonce": "101112131415161718191a1b1c1d1e1f2021222324252627",
"aad": "bb106e753e2fd9ac31142889a4356cbf9fc1f8db3777a1921ecbb5481bd4379e",
"plaintext": "636f727265637420686f727365206261747465727920737461706c65",
"ciphertext": "4793718431eb55f3feed50be98b0416d7bff929d804d53a7873495132465b6b1da6e73e042821964543ecd90",
"envelope": "445348310100101112131415161718191a1b1c1d1e1f20212223242526274793718431eb55f3feed50be98b0416d7bff929d804d53a7873495132465b6b1da6e73e042821964543ecd90"
}
],
"hkdf": [
{
"name": "passphrase-kek",
"algorithm": "HKDF-SHA512-Expand",
"prk": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f",
"info": "dsh1/kek/passphrase/v1",
"outputLength": 32,
"output": "652b3a4a3ce03b235095ad32f1eed2cfdae915b5b0a98cc9f96face30853f4c7"
}
],
"localCacheKey": [
{
"name": "local-cache-key-from-bundle",
"algorithm": "HKDF-SHA512 extract-and-expand, no salt",
"bundle": "647368312f62756e646c652f76310001000000010000019b76daa800404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"info": "dsh1/localcache/v2",
"outputLength": 32,
"output": "65bcac61e28f526f6aabfa91dd4ff3e519eaa0724a5729e890a1ef71d69062a0"
}
],
"argon2id": [
{
"name": "passphrase-default",
"memoryMebibytes": 256,
"memoryKibibytes": 262144,
"passes": 4,
"parallelism": 1
},
{
"name": "passphrase-reduced",
"memoryMebibytes": 128,
"memoryKibibytes": 131072,
"passes": 3,
"parallelism": 1
},
{
"name": "passphrase-high",
"memoryMebibytes": 512,
"memoryKibibytes": 524288,
"passes": 4,
"parallelism": 1
},
{
"name": "random-secret",
"memoryMebibytes": 64,
"memoryKibibytes": 65536,
"passes": 3,
"parallelism": 1
},
{
"name": "random-secret-output",
"memoryMebibytes": 64,
"memoryKibibytes": 65536,
"passes": 3,
"parallelism": 1,
"passphrase": "correct horse battery staple",
"salt": "202122232425262728292a2b2c2d2e2f",
"outputLength": 32,
"output": "3573a601a50874c6c4222082d040f039ba4f557a0151e0357e8abb66fed7b29e"
}
],
"fingerprint": [
{
"name": "identity-fingerprint",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"fingerprint": "fe8d8673f517688bf0d5d9b812327619a303c765af1f47dbd6a777db193c36e5"
}
],
"keyStatement": [
{
"name": "with-email",
"version": 1,
"issuer": "https://idp.example/realms/dodossh",
"subject": "alice-subject",
"email": "alice@example.com",
"keyGeneration": 1,
"createdAtUnixMilliseconds": 1750000000123,
"deviceName": "alice-laptop",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"canonicalEncoding": "647368312f6b657973746174656d656e742f7631000100000001000001977420dc7b404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f010000002268747470733a2f2f6964702e6578616d706c652f7265616c6d732f646f646f737368010000000d616c6963652d7375626a6563740100000011616c696365406578616d706c652e636f6d010000000c616c6963652d6c6170746f70",
"binding": "2540115460ae00848233d56a19e6c8e48fafcfe96de649b63a325946524aa294",
"nonce": "JUARVGCuAISCM9VqGebI5I-vz-lt5km2OjJZRlJKopQ"
},
{
"name": "without-email",
"version": 1,
"issuer": "https://idp.example/realms/dodossh",
"subject": "alice-subject",
"email": null,
"keyGeneration": 1,
"createdAtUnixMilliseconds": 1750000000123,
"deviceName": "alice-laptop",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"canonicalEncoding": "647368312f6b657973746174656d656e742f7631000100000001000001977420dc7b404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f010000002268747470733a2f2f6964702e6578616d706c652f7265616c6d732f646f646f737368010000000d616c6963652d7375626a65637400010000000c616c6963652d6c6170746f70",
"binding": "e1d73073fe20c35ec4afbd89c7d03525aebe34047dd4695970de95fb4c845be4",
"nonce": "4dcwc_4gw17Er72Jx9A1Ja6-NAR91GlZcN6V-0yEW-Q"
},
{
"name": "empty-email",
"version": 1,
"issuer": "https://idp.example/realms/dodossh",
"subject": "alice-subject",
"email": "",
"keyGeneration": 1,
"createdAtUnixMilliseconds": 1750000000123,
"deviceName": "alice-laptop",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"canonicalEncoding": "647368312f6b657973746174656d656e742f7631000100000001000001977420dc7b404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f010000002268747470733a2f2f6964702e6578616d706c652f7265616c6d732f646f646f737368010000000d616c6963652d7375626a6563740100000000010000000c616c6963652d6c6170746f70",
"binding": "1106dc5bc7da7941ab565b40ec1a32d36472bac3ced03b5013ed0375d19b4585",
"nonce": "EQbcW8faeUGrVltA7Boy02RyusPO0DtQE-0DddGbRYU"
},
{
"name": "unicode-device-name",
"version": 1,
"issuer": "https://idp.example/realms/dodossh",
"subject": "alice-subject",
"email": "alice@example.com",
"keyGeneration": 1,
"createdAtUnixMilliseconds": 1750000000123,
"deviceName": "alice\u0027s ThinkPad \u2014 b\u00FCro",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"canonicalEncoding": "647368312f6b657973746174656d656e742f7631000100000001000001977420dc7b404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f010000002268747470733a2f2f6964702e6578616d706c652f7265616c6d732f646f646f737368010000000d616c6963652d7375626a6563740100000011616c696365406578616d706c652e636f6d010000001a616c6963652773205468696e6b50616420e280942062c3bc726f",
"binding": "dbf47dd3bbce9b94b42b815758dfe599841aeca0a042da9b778036ff53f4d536",
"nonce": "2_R907vOm5S0K4FXWN_lmYQa7KCgQtqbd4A2_1P01TY"
},
{
"name": "offset-and-sub-millisecond-timestamp",
"version": 1,
"issuer": "https://idp.example/realms/dodossh",
"subject": "alice-subject",
"email": "alice@example.com",
"keyGeneration": 1,
"createdAtUnixMilliseconds": 1750000000123,
"deviceName": "alice-laptop",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"canonicalEncoding": "647368312f6b657973746174656d656e742f7631000100000001000001977420dc7b404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f010000002268747470733a2f2f6964702e6578616d706c652f7265616c6d732f646f646f737368010000000d616c6963652d7375626a6563740100000011616c696365406578616d706c652e636f6d010000000c616c6963652d6c6170746f70",
"binding": "2540115460ae00848233d56a19e6c8e48fafcfe96de649b63a325946524aa294",
"nonce": "JUARVGCuAISCM9VqGebI5I-vz-lt5km2OjJZRlJKopQ"
},
{
"name": "later-generation",
"version": 1,
"issuer": "https://idp.example/realms/dodossh",
"subject": "alice-subject",
"email": "alice@example.com",
"keyGeneration": 4,
"createdAtUnixMilliseconds": 1750000000123,
"deviceName": "alice-laptop",
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"canonicalEncoding": "647368312f6b657973746174656d656e742f7631000100000004000001977420dc7b404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f010000002268747470733a2f2f6964702e6578616d706c652f7265616c6d732f646f646f737368010000000d616c6963652d7375626a6563740100000011616c696365406578616d706c652e636f6d010000000c616c6963652d6c6170746f70",
"binding": "2c760b871347d072ee58c407a710cb9b8cc53bd36dc698a955ae7a708db386ee",
"nonce": "LHYLhxNH0HLuWMQHpxDLm4zFO9NtxpipVa56cI2zhu4"
}
],
"keyLog": [
{
"name": "genesis",
"previousHash": "0000000000000000000000000000000000000000000000000000000000000000",
"userId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"generation": 1,
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"statementSignature": "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf",
"createdAtUnixMilliseconds": 1750000000123,
"hash": "de9419c582e4729b937f4e2f5043ed4ee51f5b2e6297e65ffea50e30e3e67d57"
},
{
"name": "second-entry",
"previousHash": "de9419c582e4729b937f4e2f5043ed4ee51f5b2e6297e65ffea50e30e3e67d57",
"userId": "0192f0c8-1a2b-7c3d-8e4f-5a6b7c8d9e10",
"generation": 1,
"x25519PublicKey": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
"ed25519PublicKey": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f",
"statementSignature": "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf",
"createdAtUnixMilliseconds": 1750000000123,
"hash": "e0ac141a9113afa2e4ce5e9562641f706449a52bc63f5249baa7fa9bd8326187"
}
]
}