Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
home/desktop: recovery code, key blobs and the no-TPM key store (bento/id H1, part 2) (#779)
nyblnete431d90695e3
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a1913436..69e55ad3 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2873,3 +2873,14 @@ jobs:sudo apt-get update -qqsudo apt-get install -y -qq libtss2-dev swtpm swtpm-tools >/dev/null./tpm-rig.sh+ - name: Desktop agent no-TPM keyring rigs (gnome-keyring)+ # On a Linux machine without a usable TPM the agent falls back to the+ # Secret Service. Against a real gnome-keyring in a D-Bus session: the+ # routine key signs and verifies; there is no consent key, so consent is+ # refused (AAL3 routed elsewhere); wipe removes the keys; and the stated+ # exposure is asserted: a second connection reads the account key with+ # no prompt once the keyring is unlocked.+ working-directory: home/desktop/agent+ run: |+ sudo apt-get install -y -qq gnome-keyring dbus >/dev/null+ ./keyring-rig.shdiff --git a/docs/DECISIONS.md b/docs/DECISIONS.mdindex b4b34d68..b0ddb07e 100644--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@ -11136,3 +11136,37 @@ The passkey blob and the recovery code follow the exact bytes in the identitydesign's §2f (raw 32-byte scalars checked to lie in 1..n−1 and to match thebinding; the code is 16 Crockford base-32 characters plus a mod-37 checksymbol, and the 10 decoded bytes, never the string, feed the derivation).++## 2026-10-18 — bento/id: the desktop agent's recovery code, key blobs and no-TPM store (home/desktop/agent)++Follows the desktop agent core entry above.++- **The recovery code and key blobs are a byte-exact port of+ `kernel/src/recovery.ts`.** `kernel/fixtures/recovery-v1.json` is+ deterministic, so every printed code, parse result, derivation, blob and+ pepper value must match to the byte. Argon2id is checked against the RFC 9106+ §5.3 vector before anything relies on it, and the port's parameters are+ asserted equal to the fixture's.+- **The scalar import is constant-time.** A recovered private scalar is checked+ through p256's constant-time decode (which refuses 0 and anything ≥ n) and+ its constant-time scalar multiplication. Only public points are compared.+ There is no bignum and no hand-rolled d·G.+- **Display names need Unicode 17.0 or later.** A test fails if the+ normalisation data ever drops below 17.0.+- **The no-TPM Linux store** is the Secret Service, used when there is no TPM+ this user can open. The routine key and the account key are software keys,+ loaded only while in use and zeroized afterwards. There is no consent key, so+ every high-assurance consent is refused and routed to a phone or security+ key. The exposure is stated and asserted by a rig: once the keyring is+ unlocked, any same-user process can read these keys with no prompt.+ Organisations can refuse such machines.+- **The Windows consent key** must be a P-256 key that prompts for Windows+ Hello on every use. The Passport key storage provider is preferred, once it is+ measured on real Windows. If it can't do that, consent falls back to a+ device-bound Windows Hello WebAuthn assertion, verified by the directory with+ an empty `consentPub`, which is the existing light-tier path and not a format+ change. RSA consent keys and the legacy password dialog are both refused.++Rigs: `tests/recovery.rs`, where each of these mutations turns a test red: the+old pepper labels, losing O→0 when reading a code, and skipping the range+check. Also `tests/secret_linux.rs` via `keyring-rig.sh`.diff --git a/home/desktop/agent/Cargo.lock b/home/desktop/agent/Cargo.lockindex f663923b..a416a329 100644--- a/home/desktop/agent/Cargo.lock+++ b/home/desktop/agent/Cargo.lock@@ -2,6 +2,52 @@# It is not intended for manual editing.version = 4+[[package]]+name = "aead"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"+dependencies = [+ "crypto-common 0.1.6",+ "generic-array",+]++[[package]]+name = "aes"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"+dependencies = [+ "cfg-if",+ "cipher 0.4.4",+ "cpufeatures 0.2.17",+]++[[package]]+name = "aes"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32"+dependencies = [+ "cipher 0.5.2",+ "cpubits",+ "cpufeatures 0.3.1",+]++[[package]]+name = "aes-gcm"+version = "0.10.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"+dependencies = [+ "aead",+ "aes 0.8.4",+ "cipher 0.4.4",+ "ctr",+ "ghash",+ "subtle",+]+[[package]]name = "aho-corasick"version = "1.1.5"@@ -11,6 +57,156 @@ dependencies = ["memchr",]+[[package]]+name = "argon2"+version = "0.5.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072"+dependencies = [+ "base64ct",+ "blake2",+ "cpufeatures 0.2.17",+ "password-hash",+ "zeroize",+]++[[package]]+name = "async-broadcast"+version = "0.7.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"+dependencies = [+ "event-listener",+ "event-listener-strategy",+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "async-channel"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2"+dependencies = [+ "concurrent-queue",+ "event-listener-strategy",+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "async-executor"+version = "1.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a"+dependencies = [+ "async-task",+ "concurrent-queue",+ "fastrand",+ "futures-lite",+ "pin-project-lite",+ "slab",+]++[[package]]+name = "async-io"+version = "2.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"+dependencies = [+ "autocfg",+ "cfg-if",+ "concurrent-queue",+ "futures-io",+ "futures-lite",+ "parking",+ "polling",+ "rustix",+ "slab",+ "windows-sys",+]++[[package]]+name = "async-lock"+version = "3.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311"+dependencies = [+ "event-listener",+ "event-listener-strategy",+ "pin-project-lite",+]++[[package]]+name = "async-process"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75"+dependencies = [+ "async-channel",+ "async-io",+ "async-lock",+ "async-signal",+ "async-task",+ "blocking",+ "cfg-if",+ "event-listener",+ "futures-lite",+ "rustix",+]++[[package]]+name = "async-recursion"+version = "1.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "async-signal"+version = "0.2.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485"+dependencies = [+ "async-io",+ "async-lock",+ "atomic-waker",+ "cfg-if",+ "futures-core",+ "futures-io",+ "rustix",+ "signal-hook-registry",+ "slab",+ "windows-sys",+]++[[package]]+name = "async-task"+version = "4.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"++[[package]]+name = "async-trait"+version = "0.1.92"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "atomic-waker"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"+[[package]]name = "autocfg"version = "1.5.1"@@ -45,10 +241,15 @@ checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"name = "bento-id-agent"version = "0.1.0"dependencies = [+ "aes-gcm",+ "argon2","base64 0.22.1",+ "hkdf 0.12.4",+ "hmac 0.12.1","p256",+ "secret-service","serde_json",- "sha2",+ "sha2 0.10.9","tss-esapi","unicode-normalization","zeroize",@@ -74,6 +275,21 @@ dependencies = ["syn 3.0.9",]+[[package]]+name = "bitflags"+version = "2.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"++[[package]]+name = "blake2"+version = "0.10.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"+dependencies = [+ "digest 0.10.7",+]+[[package]]name = "block-buffer"version = "0.10.4"@@ -83,18 +299,111 @@ dependencies = ["generic-array",]+[[package]]+name = "block-buffer"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"+dependencies = [+ "hybrid-array",+]++[[package]]+name = "block-padding"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b"+dependencies = [+ "hybrid-array",+]++[[package]]+name = "blocking"+version = "1.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa"+dependencies = [+ "async-channel",+ "async-task",+ "futures-io",+ "futures-lite",+ "piper",+]++[[package]]+name = "bumpalo"+version = "3.20.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"++[[package]]+name = "cbc"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896"+dependencies = [+ "cipher 0.5.2",+]+[[package]]name = "cfg-if"version = "1.0.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"+[[package]]+name = "cipher"+version = "0.4.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"+dependencies = [+ "crypto-common 0.1.6",+ "inout 0.1.4",+]++[[package]]+name = "cipher"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"+dependencies = [+ "crypto-common 0.2.2",+ "inout 0.2.4",+]++[[package]]+name = "cmov"+version = "0.5.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"++[[package]]+name = "concurrent-queue"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"+dependencies = [+ "crossbeam-utils",+]+[[package]]name = "const-oid"version = "0.9.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"+[[package]]+name = "const-oid"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"++[[package]]+name = "cpubits"+version = "0.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"+[[package]]name = "cpufeatures"version = "0.2.17"@@ -104,6 +413,21 @@ dependencies = ["libc",]+[[package]]+name = "cpufeatures"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"+dependencies = [+ "libc",+]++[[package]]+name = "crossbeam-utils"+version = "0.8.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"+[[package]]name = "crypto-bigint"version = "0.5.5"@@ -123,16 +447,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"dependencies = ["generic-array",+ "rand_core","typenum",]+[[package]]+name = "crypto-common"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"+dependencies = [+ "hybrid-array",+]++[[package]]+name = "ctr"+version = "0.9.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"+dependencies = [+ "cipher 0.4.4",+]++[[package]]+name = "ctutils"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "03bb0e1cc970d482d121d9a1744999169b69a07470b3d644a7894e53fcaf4574"+dependencies = [+ "cmov",+]+[[package]]name = "der"version = "0.7.10"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"dependencies = [- "const-oid",+ "const-oid 0.9.6","pem-rfc7468","zeroize",]@@ -143,12 +495,24 @@ version = "0.10.7"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"dependencies = [- "block-buffer",- "const-oid",- "crypto-common",+ "block-buffer 0.10.4",+ "const-oid 0.9.6",+ "crypto-common 0.1.6","subtle",]+[[package]]+name = "digest"+version = "0.11.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"+dependencies = [+ "block-buffer 0.12.1",+ "const-oid 0.10.2",+ "crypto-common 0.2.2",+ "ctutils",+]+[[package]]name = "ecdsa"version = "0.16.9"@@ -156,7 +520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"dependencies = ["der",- "digest",+ "digest 0.10.7","elliptic-curve","rfc6979","signature",@@ -171,7 +535,7 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"dependencies = ["base16ct","crypto-bigint",- "digest",+ "digest 0.10.7","ff","generic-array","group",@@ -183,6 +547,12 @@ dependencies = ["zeroize",]+[[package]]+name = "endi"+version = "1.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"+[[package]]name = "enumflags2"version = "0.7.12"@@ -190,6 +560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"dependencies = ["enumflags2_derive",+ "serde",][[package]]@@ -203,6 +574,48 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "equivalent"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"++[[package]]+name = "errno"+version = "0.3.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"+dependencies = [+ "libc",+ "windows-sys",+]++[[package]]+name = "event-listener"+version = "5.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2"+dependencies = [+ "parking",+ "pin-project-lite",+]++[[package]]+name = "event-listener-strategy"+version = "0.5.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"+dependencies = [+ "event-listener",+ "pin-project-lite",+]++[[package]]+name = "fastrand"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"+[[package]]name = "ff"version = "0.13.1"@@ -213,6 +626,61 @@ dependencies = ["subtle",]+[[package]]+name = "futures-core"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"++[[package]]+name = "futures-io"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"++[[package]]+name = "futures-lite"+version = "2.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"+dependencies = [+ "fastrand",+ "futures-core",+ "futures-io",+ "parking",+ "pin-project-lite",+]++[[package]]+name = "futures-macro"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "futures-task"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"++[[package]]+name = "futures-util"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"+dependencies = [+ "futures-core",+ "futures-macro",+ "futures-task",+ "pin-project-lite",+ "slab",+]+[[package]]name = "generic-array"version = "0.14.9"@@ -246,6 +714,16 @@ dependencies = ["r-efi",]+[[package]]+name = "ghash"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"+dependencies = [+ "opaque-debug",+ "polyval",+]+[[package]]name = "group"version = "0.13.0"@@ -257,13 +735,58 @@ dependencies = ["subtle",]+[[package]]+name = "hashbrown"+version = "0.17.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"++[[package]]+name = "hermit-abi"+version = "0.5.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"++[[package]]+name = "hex"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"++[[package]]+name = "hkdf"+version = "0.12.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"+dependencies = [+ "hmac 0.12.1",+]++[[package]]+name = "hkdf"+version = "0.13.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018"+dependencies = [+ "hmac 0.13.0",+]+[[package]]name = "hmac"version = "0.12.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"dependencies = [- "digest",+ "digest 0.10.7",+]++[[package]]+name = "hmac"+version = "0.13.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"+dependencies = [+ "digest 0.11.3",][[package]]@@ -272,18 +795,73 @@ version = "1.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f558a64ac9af88b5ba400d99b579451af0d39c6d360980045b91aac966d705e2"+[[package]]+name = "hybrid-array"+version = "0.4.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"+dependencies = [+ "typenum",+]++[[package]]+name = "indexmap"+version = "2.14.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"+dependencies = [+ "equivalent",+ "hashbrown",+]++[[package]]+name = "inout"+version = "0.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"+dependencies = [+ "generic-array",+]++[[package]]+name = "inout"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ce983bb6fb399067d101fbfc9e74174e07e9f29a2bc679efefeb8c645819c3f"+dependencies = [+ "block-padding",+ "hybrid-array",+]+[[package]]name = "itoa"version = "1.0.18"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"+[[package]]+name = "js-sys"+version = "0.3.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"+dependencies = [+ "cfg-if",+ "futures-util",+ "wasm-bindgen",+]+[[package]]name = "libc"version = "0.2.191"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"+[[package]]+name = "linux-raw-sys"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"+[[package]]name = "log"version = "0.4.34"@@ -301,20 +879,92 @@ dependencies = [][[package]]-name = "memchr"-version = "2.8.3"+name = "memchr"+version = "2.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"++[[package]]+name = "memoffset"+version = "0.9.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"+dependencies = [+ "autocfg",+]++[[package]]+name = "num"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"+dependencies = [+ "num-bigint",+ "num-complex",+ "num-integer",+ "num-iter",+ "num-rational",+ "num-traits",+]++[[package]]+name = "num-bigint"+version = "0.4.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"+dependencies = [+ "num-integer",+ "num-traits",+]++[[package]]+name = "num-complex"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"+dependencies = [+ "num-traits",+]++[[package]]+name = "num-derive"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "num-integer"+version = "0.1.47"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"+dependencies = [+ "num-traits",+]++[[package]]+name = "num-iter"+version = "0.1.46"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"+checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"+dependencies = [+ "num-integer",+ "num-traits",+][[package]]-name = "num-derive"+name = "num-rational"version = "0.4.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"+checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"dependencies = [- "proc-macro2",- "quote",- "syn 2.0.119",+ "num-bigint",+ "num-integer",+ "num-traits",][[package]]@@ -335,6 +985,28 @@ dependencies = ["serde",]+[[package]]+name = "once_cell"+version = "1.21.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"++[[package]]+name = "opaque-debug"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"++[[package]]+name = "ordered-stream"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"+dependencies = [+ "futures-core",+ "pin-project-lite",+]+[[package]]name = "p256"version = "0.13.2"@@ -344,7 +1016,24 @@ dependencies = ["ecdsa","elliptic-curve","primeorder",- "sha2",+ "sha2 0.10.9",+]++[[package]]+name = "parking"+version = "2.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"++[[package]]+name = "password-hash"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"+dependencies = [+ "base64ct",+ "rand_core",+ "subtle",][[package]]@@ -391,6 +1080,23 @@ dependencies = ["serde",]+[[package]]+name = "pin-project-lite"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"++[[package]]+name = "piper"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1"+dependencies = [+ "atomic-waker",+ "fastrand",+ "futures-io",+]+[[package]]name = "pkcs8"version = "0.10.2"@@ -407,6 +1113,32 @@ version = "0.3.34"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"+[[package]]+name = "polling"+version = "3.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"+dependencies = [+ "cfg-if",+ "concurrent-queue",+ "hermit-abi",+ "pin-project-lite",+ "rustix",+ "windows-sys",+]++[[package]]+name = "polyval"+version = "0.6.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25"+dependencies = [+ "cfg-if",+ "cpufeatures 0.2.17",+ "opaque-debug",+ "universal-hash",+]+[[package]]name = "primeorder"version = "0.13.6"@@ -416,6 +1148,15 @@ dependencies = ["elliptic-curve",]+[[package]]+name = "proc-macro-crate"+version = "3.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"+dependencies = [+ "toml_edit",+]+[[package]]name = "proc-macro2"version = "1.0.107"@@ -484,10 +1225,29 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"dependencies = [- "hmac",+ "hmac 0.12.1","subtle",]+[[package]]+name = "rustix"+version = "1.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"+dependencies = [+ "bitflags",+ "errno",+ "libc",+ "linux-raw-sys",+ "windows-sys",+]++[[package]]+name = "rustversion"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"+[[package]]name = "sec1"version = "0.7.3"@@ -502,6 +1262,25 @@ dependencies = ["zeroize",]+[[package]]+name = "secret-service"+version = "5.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5107b24b91445dd2aa449a258a1807b63240942157292354dc5bfdbeb8bc6db8"+dependencies = [+ "aes 0.9.3",+ "cbc",+ "futures-util",+ "getrandom 0.4.3",+ "hkdf 0.13.0",+ "hybrid-array",+ "num",+ "once_cell",+ "serde",+ "sha2 0.11.1",+ "zbus",+]+[[package]]name = "serde"version = "1.0.229"@@ -555,6 +1334,17 @@ dependencies = ["zmij",]+[[package]]+name = "serde_repr"+version = "0.1.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]+[[package]]name = "sha2"version = "0.10.9"@@ -562,8 +1352,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"dependencies = ["cfg-if",- "cpufeatures",- "digest",+ "cpufeatures 0.2.17",+ "digest 0.10.7",+]++[[package]]+name = "sha2"+version = "0.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"+dependencies = [+ "cfg-if",+ "cpufeatures 0.3.1",+ "digest 0.11.3",+]++[[package]]+name = "signal-hook-registry"+version = "1.4.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"+dependencies = [+ "errno",+ "libc",][[package]]@@ -572,10 +1383,16 @@ version = "2.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"dependencies = [- "digest",+ "digest 0.10.7","rand_core",]+[[package]]+name = "slab"+version = "0.4.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"+[[package]]name = "spki"version = "0.7.3"@@ -626,12 +1443,86 @@ version = "0.12.16"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"+[[package]]+name = "tempfile"+version = "3.27.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"+dependencies = [+ "fastrand",+ "getrandom 0.4.3",+ "once_cell",+ "rustix",+ "windows-sys",+]+[[package]]name = "tinyvec"version = "1.13.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"+[[package]]+name = "toml_datetime"+version = "1.1.2+spec-1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053"+dependencies = [+ "serde_core",+]++[[package]]+name = "toml_edit"+version = "0.25.17+spec-1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c"+dependencies = [+ "indexmap",+ "toml_datetime",+ "toml_parser",+ "winnow",+]++[[package]]+name = "toml_parser"+version = "1.1.5+spec-1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c"+dependencies = [+ "winnow",+]++[[package]]+name = "tracing"+version = "0.1.44"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"+dependencies = [+ "pin-project-lite",+ "tracing-attributes",+ "tracing-core",+]++[[package]]+name = "tracing-attributes"+version = "0.1.31"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "tracing-core"+version = "0.1.36"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"+dependencies = [+ "once_cell",+]+[[package]]name = "tss-esapi"version = "7.7.0"@@ -671,6 +1562,17 @@ version = "1.20.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"+[[package]]+name = "uds_windows"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"+dependencies = [+ "memoffset",+ "tempfile",+ "windows-sys",+]+[[package]]name = "unicode-ident"version = "1.0.27"@@ -686,6 +1588,27 @@ dependencies = ["tinyvec",]+[[package]]+name = "universal-hash"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"+dependencies = [+ "crypto-common 0.1.6",+ "subtle",+]++[[package]]+name = "uuid"+version = "1.28.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7cc1186384beb7dd8eedea376413fd654937285ea6c9cfbb928dc3043ea4b606"+dependencies = [+ "js-sys",+ "serde_core",+ "wasm-bindgen",+]+[[package]]name = "version_check"version = "0.9.5"@@ -698,6 +1621,145 @@ version = "0.11.1+wasi-snapshot-preview1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"+[[package]]+name = "wasm-bindgen"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"+dependencies = [+ "cfg-if",+ "once_cell",+ "rustversion",+ "wasm-bindgen-macro",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-macro"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"+dependencies = [+ "quote",+ "wasm-bindgen-macro-support",+]++[[package]]+name = "wasm-bindgen-macro-support"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"+dependencies = [+ "bumpalo",+ "proc-macro2",+ "quote",+ "syn 3.0.9",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-shared"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "windows-link"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"++[[package]]+name = "windows-sys"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"+dependencies = [+ "windows-link",+]++[[package]]+name = "winnow"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"+dependencies = [+ "memchr",+]++[[package]]+name = "zbus"+version = "5.19.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907"+dependencies = [+ "async-broadcast",+ "async-executor",+ "async-io",+ "async-lock",+ "async-process",+ "async-recursion",+ "async-task",+ "async-trait",+ "blocking",+ "enumflags2",+ "event-listener",+ "futures-core",+ "futures-lite",+ "hex",+ "libc",+ "ordered-stream",+ "rustix",+ "serde",+ "serde_repr",+ "tracing",+ "uds_windows",+ "uuid",+ "windows-sys",+ "winnow",+ "zbus_macros",+ "zbus_names",+ "zvariant",+]++[[package]]+name = "zbus_macros"+version = "5.19.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"+dependencies = [+ "proc-macro-crate",+ "proc-macro2",+ "quote",+ "syn 3.0.9",+ "zbus_names",+ "zvariant",+ "zvariant_utils",+]++[[package]]+name = "zbus_names"+version = "4.3.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd"+dependencies = [+ "serde",+ "winnow",+ "zvariant",+]++[[package]]+name = "zcheapstr"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d1afec51604565183aeb5c54c20aeab286120d4e4460f7f76e3e8bb8c0d99473"+dependencies = [+ "serde",+]+[[package]]name = "zeroize"version = "1.9.1"@@ -723,3 +1785,44 @@ name = "zmij"version = "1.0.23"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"++[[package]]+name = "zvariant"+version = "5.15.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7"+dependencies = [+ "endi",+ "enumflags2",+ "serde",+ "winnow",+ "zcheapstr",+ "zvariant_derive",+ "zvariant_utils",+]++[[package]]+name = "zvariant_derive"+version = "5.15.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d"+dependencies = [+ "proc-macro-crate",+ "proc-macro2",+ "quote",+ "syn 3.0.9",+ "zvariant_utils",+]++[[package]]+name = "zvariant_utils"+version = "4.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3"+dependencies = [+ "proc-macro2",+ "quote",+ "serde",+ "syn 3.0.9",+ "winnow",+]diff --git a/home/desktop/agent/Cargo.toml b/home/desktop/agent/Cargo.tomlindex 8e24c365..4fef2807 100644--- a/home/desktop/agent/Cargo.toml+++ b/home/desktop/agent/Cargo.toml@@ -11,16 +11,31 @@ p256 = { version = "0.13", features = ["ecdsa"] }sha2 = "0.10"base64 = "0.22"zeroize = "1"+argon2 = { version = "0.5", features = ["zeroize"] }+hkdf = "0.12"+hmac = "0.12"+aes-gcm = "0.10"unicode-normalization = "0.1"[target.'cfg(target_os = "linux")'.dependencies]tss-esapi = { version = "7", optional = true }+secret-service = { version = "5", features = ["rt-async-io-crypto-rust"], optional = true }[features]# the Linux TPM key store (needs libtss2)tpm = ["dep:tss-esapi"]+# the Linux no-TPM key store (freedesktop Secret Service)+keyring = ["dep:secret-service"]# the in-memory software key store: tests and rigs only, never a shipped pathtest-store = [][dev-dependencies]+unicode-normalization = "0.1.26"serde_json = "1"++# Argon2id at 64 MiB / t=3 is minutes unoptimised: optimise the crypto crates+# even in debug and test builds (the rest stays debug).+[profile.dev.package.argon2]+opt-level = 3+[profile.dev.package.blake2]+opt-level = 3diff --git a/home/desktop/agent/keyring-rig.sh b/home/desktop/agent/keyring-rig.shnew file mode 100755index 00000000..74c30e65--- /dev/null+++ b/home/desktop/agent/keyring-rig.sh@@ -0,0 +1,10 @@+#!/usr/bin/env bash+# The no-TPM store's rigs against gnome-keyring under a D-Bus session, the+# login keyring unlocked as a desktop session would. Linux only.+set -euo pipefail+exec dbus-run-session -- bash -euo pipefail -c '+ echo -n "rig-login-password" | gnome-keyring-daemon --unlock --components=secrets >/dev/null+ out=$(cargo test --features keyring --test secret_linux -- --test-threads=1 "$@" 2>&1) || { echo "$out"; exit 1; }+ echo "$out"+ echo "$out" | grep -qE "test result: ok\. [1-9][0-9]* passed" || { echo "FAIL: no keyring rig ran"; exit 1; }+' -- "$@"diff --git a/home/desktop/agent/src/lib.rs b/home/desktop/agent/src/lib.rsindex 4014889e..861c2570 100644--- a/home/desktop/agent/src/lib.rs+++ b/home/desktop/agent/src/lib.rs@@ -13,8 +13,12 @@ pub mod address;pub mod agent;pub mod b64u;pub mod device_list;+pub mod recovery;mod display_table;pub mod statements;#[cfg(all(target_os = "linux", feature = "tpm"))]pub mod tpm_linux;++#[cfg(all(target_os = "linux", feature = "keyring"))]+pub mod secret_linux;diff --git a/home/desktop/agent/src/recovery.rs b/home/desktop/agent/src/recovery.rsnew file mode 100644index 00000000..337b4571--- /dev/null+++ b/home/desktop/agent/src/recovery.rs@@ -0,0 +1,331 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+//+// bento/id — the recovery code and the key blobs, a port of+// kernel/src/recovery.ts (identity-design §2f, security §28). Every value is+// DETERMINISTIC in kernel/fixtures/recovery-v1.json, so this port reproduces the+// exact bytes end to end; tests/recovery.rs runs every row.+//+// Secrets (codes, Argon2id outputs, wrap keys, scalars) are returned in+// `Zeroizing` so they are wiped when dropped (§26b: plaintext key material+// lives only for the prompted use).++use crate::{b64u, statements::KxMode};+use aes_gcm::{aead::{Aead, KeyInit, Payload}, Aes256Gcm, Nonce};+use hkdf::Hkdf;+use hmac::{Hmac, Mac};+use p256::elliptic_curve::sec1::ToEncodedPoint;+use sha2::{Digest, Sha256};+use zeroize::Zeroizing;++pub type Secret = Zeroizing<Vec<u8>>;++// --- parameters (security §28) -------------------------------------------------++pub const ARGON2_VERSION: u32 = 0x13;+pub const ARGON2_PARALLELISM: u32 = 1;+pub const ARGON2_MEMORY_KIB: u32 = 65536;+pub const ARGON2_PASSES: u32 = 3;+pub const ARGON2_TAG_LEN: usize = 32;+pub const SALT_LEN: usize = 16;+pub const CODE_BYTES: usize = 10;++/// Raw Argon2id with explicit parameters, an optional secret and associated+/// data (the RFC 9106 §5.3 vector needs both). Our derivations use `argon2id`.+pub fn argon2id_raw(+ password: &[u8],+ salt: &[u8],+ secret: Option<&[u8]>,+ ad: Option<&[u8]>,+ memory_kib: u32,+ passes: u32,+ parallelism: u32,+ tag_len: usize,+) -> Result<Secret, String> {+ use argon2::{Algorithm, Argon2, AssociatedData, ParamsBuilder, Version};+ let mut pb = ParamsBuilder::new();+ pb.m_cost(memory_kib).t_cost(passes).p_cost(parallelism).output_len(tag_len);+ if let Some(ad) = ad {+ pb.data(AssociatedData::new(ad).map_err(|e| e.to_string())?);+ }+ let params = pb.build().map_err(|e| e.to_string())?;+ let a = match secret {+ Some(s) => Argon2::new_with_secret(s, Algorithm::Argon2id, Version::V0x13, params).map_err(|e| e.to_string())?,+ None => Argon2::new(Algorithm::Argon2id, Version::V0x13, params),+ };+ let mut out = Zeroizing::new(vec![0u8; tag_len]);+ a.hash_password_into(password, salt, &mut out).map_err(|e| e.to_string())?;+ Ok(out)+}++/// Argon2id with OUR parameters (v0x13, p=1, 64 MiB, t=3, 32 bytes).+pub fn argon2id(password: &[u8], salt: &[u8]) -> Secret {+ argon2id_raw(password, salt, None, None, ARGON2_MEMORY_KIB, ARGON2_PASSES, ARGON2_PARALLELISM, ARGON2_TAG_LEN)+ .expect("fixed Argon2id parameters are valid")+}++// --- the recovery code: 80 bits, Crockford base32, with a check symbol ----------++const ALPHABET: &[u8; 32] = b"0123456789ABCDEFGHJKMNPQRSTVWXYZ";+const CHECK_ALPHABET: &[u8; 37] = b"0123456789ABCDEFGHJKMNPQRSTVWXYZ*~$=U";++fn to_u128(b: &[u8]) -> u128 {+ b.iter().fold(0u128, |x, v| (x << 8) | *v as u128)+}++/// The printed form: XXXX-XXXX-XXXX-XXXX-C.+pub fn format_recovery_code(code: &[u8]) -> String {+ assert_eq!(code.len(), CODE_BYTES, "a recovery code is 10 bytes");+ let n = to_u128(code);+ let s: String = (0..16).rev().map(|i| ALPHABET[((n >> (i * 5)) & 31) as usize] as char).collect();+ let check = CHECK_ALPHABET[(n % 37) as usize] as char;+ format!("{}-{}-{}-{}-{check}", &s[0..4], &s[4..8], &s[8..12], &s[12..16])+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum CodeRefusal {+ Length,+ Character,+ Check,+}+impl CodeRefusal {+ pub fn as_str(self) -> &'static str {+ match self {+ CodeRefusal::Length => "length",+ CodeRefusal::Character => "character",+ CodeRefusal::Check => "check",+ }+ }+}++/// Read what a person typed (recovery.ts parseRecoveryCode). JS semantics kept+/// on purpose: `toUpperCase()` then strip JS `\s` and '-', then O→0, I/L→1.+/// Non-ASCII survives as a non-alphabet character and is refused. Returns the+/// 10 bytes Argon2id takes, never the string.+pub fn parse_recovery_code(input: &str) -> Result<Zeroizing<[u8; CODE_BYTES]>, CodeRefusal> {+ let upper = input.to_uppercase();+ let s: Vec<char> = upper+ .chars()+ .filter(|c| !js_regex_space(*c) && *c != '-')+ .map(|c| match c {+ 'O' => '0',+ 'I' | 'L' => '1',+ c => c,+ })+ .collect();+ if s.len() != 17 {+ return Err(CodeRefusal::Length);+ }+ let mut n: u128 = 0;+ for c in &s[..16] {+ let v = ALPHABET.iter().position(|a| *a as char == *c).ok_or(CodeRefusal::Character)?;+ n = (n << 5) | v as u128;+ }+ let check = CHECK_ALPHABET.iter().position(|a| *a as char == s[16]).ok_or(CodeRefusal::Character)?;+ if check as u128 != n % 37 {+ return Err(CodeRefusal::Check);+ }+ let mut code = Zeroizing::new([0u8; CODE_BYTES]);+ for i in (0..CODE_BYTES).rev() {+ code[i] = (n & 0xff) as u8;+ n >>= 8;+ }+ Ok(code)+}++/// The JS regex `\s` class (WhiteSpace + LineTerminator).+fn js_regex_space(c: char) -> bool {+ matches!(c,+ '\u{0009}'..='\u{000D}' | '\u{0020}' | '\u{00A0}' | '\u{1680}' | '\u{2000}'..='\u{200A}'+ | '\u{2028}' | '\u{2029}' | '\u{202F}' | '\u{205F}' | '\u{3000}' | '\u{FEFF}')+}++// --- derivations ------------------------------------------------------------------++/// HKDF-SHA-256 → 32 bytes. An EMPTY salt is zero-length (= 32 zero bytes).+fn hkdf(ikm: &[u8], salt: &[u8], info: &str) -> Secret {+ let h = Hkdf::<Sha256>::new(Some(salt), ikm);+ let mut out = Zeroizing::new(vec![0u8; 32]);+ h.expand(info.as_bytes(), &mut out).expect("32 bytes is a valid HKDF length");+ out+}++/// HKDF-SHA-256(Argon2id(code, salt), empty, "bento/id/rc-wrap/v1").+pub fn recovery_wrap_key(code: &[u8], salt: &[u8]) -> Secret {+ assert_eq!((code.len(), salt.len()), (CODE_BYTES, SALT_LEN));+ hkdf(&argon2id(code, salt), &[], "bento/id/rc-wrap/v1")+}++/// What the client sends the directory: Argon2id(code, salt_v).+pub fn recovery_verifier(code: &[u8], salt_v: &[u8]) -> Secret {+ assert_eq!((code.len(), salt_v.len()), (CODE_BYTES, SALT_LEN));+ argon2id(code, salt_v)+}++/// HKDF-SHA-256(PRF output, 32-byte salt, "bento/id/acct-wrap/v1").+pub fn prf_kek(prf_output: &[u8], salt: &[u8]) -> Secret {+ assert_eq!((prf_output.len(), salt.len()), (32, 32));+ hkdf(prf_output, salt, "bento/id/acct-wrap/v1")+}++// --- blob plaintext: raw private scalars, checked on import ------------------------++fn blob_kx(mode: KxMode) -> bool {+ matches!(mode, KxMode::A | KxMode::C)+}++pub struct BlobKeys {+ pub account: Zeroizing<[u8; 32]>,+ pub kx: Option<Zeroizing<[u8; 32]>>,+}++pub fn pack_scalars(keys: &BlobKeys, mode: KxMode) -> Secret {+ match (blob_kx(mode), &keys.kx) {+ (false, None) => Zeroizing::new(keys.account.to_vec()),+ (true, Some(kx)) => {+ let mut v = Zeroizing::new(keys.account.to_vec());+ v.extend_from_slice(&kx[..]);+ v+ }+ (false, Some(_)) => panic!("this kx mode carries no kx in the blob"),+ (true, None) => panic!("this kx mode needs a kx in the blob"),+ }+}++/// d·G as a raw uncompressed point, base64url; None when d is 0 or ≥ n.+///+/// CONSTANT-TIME by construction (security, #770 review): the recovered scalar+/// is SECRET, so the range check is p256's own `SecretKey::from_slice` (a+/// constant-time decode that refuses 0 and ≥ n) and d·G is p256's+/// constant-time scalar multiplication. Only the resulting PUBLIC points are+/// compared. Never replace this with a bignum compare or a hand-rolled+/// double-and-add: both branch on the secret.+fn public_of(d: &[u8]) -> Option<String> {+ let sk = p256::SecretKey::from_slice(d).ok()?;+ Some(b64u::enc(sk.public_key().to_encoded_point(false).as_bytes()))+}++/// Check a blob's plaintext before anything uses it: the right length for the+/// mode, every scalar in 1..n−1, and each one's public half equal to the+/// directory-signed one. A swapped blob fails closed here.+pub fn unpack_scalars(pt: &[u8], account_pub: &str, kx_pub: Option<&str>, mode: KxMode) -> Result<BlobKeys, &'static str> {+ let with_kx = blob_kx(mode);+ if pt.len() != if with_kx { 64 } else { 32 } {+ return Err("length");+ }+ let mut out = vec![];+ for (i, want) in [Some(account_pub), kx_pub].iter().take(if with_kx { 2 } else { 1 }).enumerate() {+ let d = &pt[i * 32..i * 32 + 32];+ // range first (1..n−1), as the reference+ let pub_d = public_of(d).ok_or("scalar-range")?;+ if *want != Some(pub_d.as_str()) {+ return Err("key-mismatch");+ }+ let mut s = Zeroizing::new([0u8; 32]);+ s.copy_from_slice(d);+ out.push(s);+ }+ let mut it = out.into_iter();+ Ok(BlobKeys { account: it.next().unwrap(), kx: it.next() })+}++// --- AES-256-GCM ------------------------------------------------------------------------++fn gcm_seal(key: &[u8], iv: &[u8], aad: &str, pt: &[u8]) -> Vec<u8> {+ assert_eq!((key.len(), iv.len()), (32, 12));+ Aes256Gcm::new_from_slice(key).unwrap().encrypt(&Nonce::from(<[u8; 12]>::try_from(iv).unwrap()), Payload { msg: pt, aad: aad.as_bytes() }).unwrap()+}+fn gcm_open(key: &[u8], iv: &[u8], aad: &str, ct: &[u8]) -> Option<Secret> {+ if key.len() != 32 || iv.len() != 12 {+ return None;+ }+ Aes256Gcm::new_from_slice(key).ok()?.decrypt(&Nonce::from(<[u8; 12]>::try_from(iv).ok()?), Payload { msg: ct, aad: aad.as_bytes() }).ok().map(Zeroizing::new)+}+fn sha256_b64u(b: &[u8]) -> String {+ b64u::enc(&Sha256::digest(b))+}+fn account_tag(account_pub: &str) -> String {+ sha256_b64u(account_pub.as_bytes())+}++// --- the PRF blob (one per passkey) -------------------------------------------------++#[derive(Debug, Clone, PartialEq, Eq)]+pub struct PrfBlob {+ pub v: u32,+ pub cred: String,+ pub salt: String,+ pub iv: String,+ pub ct: String,+}++pub fn seal_prf_blob(prf_output: &[u8], credential_id: &[u8], salt: &[u8], iv: &[u8], keys: &BlobKeys, mode: KxMode) -> PrfBlob {+ let cred = sha256_b64u(credential_id);+ let kek = prf_kek(prf_output, salt);+ let ct = gcm_seal(&kek, iv, &format!("bento/id/acct-wrap/v1.{cred}"), &pack_scalars(keys, mode));+ PrfBlob { v: 1, cred, salt: b64u::enc(salt), iv: b64u::enc(iv), ct: b64u::enc(&ct) }+}++pub fn open_prf_blob(+ blob: &PrfBlob,+ prf_output: &[u8],+ credential_id: &[u8],+ account_pub: &str,+ kx_pub: Option<&str>,+ mode: KxMode,+) -> Result<BlobKeys, &'static str> {+ if blob.v != 1 {+ return Err("version");+ }+ let cred = sha256_b64u(credential_id);+ if blob.cred != cred {+ return Err("credential");+ }+ let (salt, iv, ct) = (b64u::dec(&blob.salt), b64u::dec(&blob.iv), b64u::dec(&blob.ct));+ let (Some(salt), Some(iv), Some(ct)) = (salt, iv, ct) else { return Err("grammar") };+ if salt.len() != 32 || iv.len() != 12 {+ return Err("grammar");+ }+ let pt = gcm_open(&prf_kek(prf_output, &salt), &iv, &format!("bento/id/acct-wrap/v1.{cred}"), &ct).ok_or("decrypt")?;+ unpack_scalars(&pt, account_pub, kx_pub, mode)+}++// --- the recovery-code blob, and the directory's pepper layer -------------------------++pub fn seal_recovery_inner(wrap_key: &[u8], iv: &[u8], account_pub: &str, keys: &BlobKeys, mode: KxMode) -> Vec<u8> {+ gcm_seal(wrap_key, iv, &format!("bento/id/rc-wrap/v1.{}", account_tag(account_pub)), &pack_scalars(keys, mode))+}++pub fn open_recovery_inner(+ ct: &[u8],+ wrap_key: &[u8],+ iv: &[u8],+ account_pub: &str,+ kx_pub: Option<&str>,+ mode: KxMode,+) -> Result<BlobKeys, &'static str> {+ let pt = gcm_open(wrap_key, iv, &format!("bento/id/rc-wrap/v1.{}", account_tag(account_pub)), ct).ok_or("decrypt")?;+ unpack_scalars(&pt, account_pub, kx_pub, mode)+}++/// The directory's per-account pepper keys (server side; here so the vectors+/// can be checked from Rust too): (verifyKey, wrapKey). Subkey labels per+/// security §28a.+pub fn pepper_keys(pepper: &[u8], account_pub: &str) -> (Secret, Secret) {+ let p = hkdf(pepper, &[], &format!("bento/id/pepper/v1.{}", account_tag(account_pub)));+ (hkdf(&p, &[], "bento/id/pepper/v1/verify"), hkdf(&p, &[], "bento/id/pepper/v1/wrap"))+}++pub fn pepper_verifier_tag(verify_key: &[u8], verifier: &[u8]) -> Vec<u8> {+ let mut m = <Hmac<Sha256> as Mac>::new_from_slice(verify_key).unwrap();+ m.update(verifier);+ m.finalize().into_bytes().to_vec()+}++pub fn pepper_seal(wrap_key: &[u8], iv: &[u8], inner: &[u8], account_pub: &str) -> Vec<u8> {+ gcm_seal(wrap_key, iv, &format!("bento/id/rc-pepper/v1.{}", account_tag(account_pub)), inner)+}++pub fn pepper_open(wrap_key: &[u8], iv: &[u8], outer: &[u8], account_pub: &str) -> Option<Secret> {+ gcm_open(wrap_key, iv, &format!("bento/id/rc-pepper/v1.{}", account_tag(account_pub)), outer)+}diff --git a/home/desktop/agent/src/secret_linux.rs b/home/desktop/agent/src/secret_linux.rsnew file mode 100644index 00000000..310b7be5--- /dev/null+++ b/home/desktop/agent/src/secret_linux.rs@@ -0,0 +1,170 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+//+// The Linux key store for a machine WITHOUT a usable TPM (H1b, the no-TPM+// column of the H1 key table): the freedesktop Secret Service (GNOME Keyring,+// KWallet).+//+// STATED EXPOSURE (security §26): the keyring is unlocked at login, so ANY+// process running as this user can read these keys silently — routine and+// account alike. There is no consent key here, so every AAL3 action is refused+// and routed to a phone or a security key (§2e (E)), and an org's attestation+// policy can refuse such machines outright. The host must say all of this to+// the person when it falls back to this store.+//+// Keys are software P-256 scalars stored as keyring secrets, loaded only for+// the moment they are used and zeroized after.++use crate::agent::{KeyRole, KeyStore, Prompt, StoreError};+use p256::ecdsa::{signature::Signer, Signature, SigningKey};+use secret_service::blocking::SecretService;+use secret_service::EncryptionType;+use std::collections::HashMap;+use zeroize::Zeroizing;++const APP: &str = "page.bento.home";++fn ss_err(e: impl std::fmt::Display) -> StoreError {+ StoreError::Unavailable(e.to_string())+}++fn role_name(role: &KeyRole) -> &'static str {+ match role {+ KeyRole::Account => "account",+ KeyRole::Device => "device",+ KeyRole::Consent => "consent",+ }+}++pub struct SecretStore {+ ss: SecretService<'static>,+ /// separates profiles (and test runs) within one keyring+ profile: String,+}++impl SecretStore {+ pub fn open(profile: &str) -> Result<SecretStore, StoreError> {+ let ss = SecretService::connect(EncryptionType::Dh).map_err(ss_err)?;+ Ok(SecretStore { ss, profile: profile.to_string() })+ }++ fn attrs<'a>(&'a self, role: &'a KeyRole) -> HashMap<&'a str, &'a str> {+ HashMap::from([("application", APP), ("profile", self.profile.as_str()), ("role", role_name(role))])+ }++ fn read(&self, role: &KeyRole) -> Result<Option<Zeroizing<Vec<u8>>>, StoreError> {+ let items = self.ss.search_items(self.attrs(role)).map_err(ss_err)?;+ let item = match (items.unlocked.first(), items.locked.first()) {+ (Some(i), _) => i,+ (None, Some(i)) => {+ i.unlock().map_err(ss_err)?;+ i+ }+ (None, None) => return Ok(None),+ };+ Ok(Some(Zeroizing::new(item.get_secret().map_err(ss_err)?)))+ }++ fn write(&self, role: &KeyRole, secret: &[u8]) -> Result<(), StoreError> {+ let c = self.ss.get_default_collection().map_err(ss_err)?;+ if c.is_locked().map_err(ss_err)? {+ c.unlock().map_err(ss_err)?;+ }+ c.create_item(&format!("bento/id {} key", role_name(role)), self.attrs(role), secret, true, "application/octet-stream")+ .map_err(ss_err)?;+ Ok(())+ }++ /// Mint the routine device key in software and store it. The consent key+ /// is refused: this store has none (AAL3 is routed elsewhere).+ pub fn create_device_key(&self) -> Result<[u8; 65], StoreError> {+ let key = SigningKey::random(&mut p256::elliptic_curve::rand_core::OsRng);+ let d = Zeroizing::new(key.to_bytes().to_vec());+ self.write(&KeyRole::Device, &d)?;+ Ok(key.verifying_key().to_encoded_point(false).as_bytes().try_into().unwrap())+ }++ /// Store the account key's scalar. Readable by any same-user process.+ pub fn store_account(&self, scalar: &[u8]) -> Result<(), StoreError> {+ self.write(&KeyRole::Account, scalar)+ }++ /// The account scalar for one prompted use; zeroized when dropped.+ pub fn account(&self) -> Result<Zeroizing<Vec<u8>>, StoreError> {+ self.read(&KeyRole::Account)?.ok_or(StoreError::NoKey)+ }++ /// Remove every key of this profile (device retirement, the wipe path).+ /// Locked items are unlocked and deleted too, and the store is searched+ /// again afterwards: wipe reports success only when NOTHING of this profile+ /// remains, locked or not (security, #779 review). A keyring that cannot be+ /// unlocked here makes wipe FAIL; it never pretends.+ pub fn wipe(&self) -> Result<(), StoreError> {+ for role in [KeyRole::Account, KeyRole::Device, KeyRole::Consent] {+ let found = self.ss.search_items(self.attrs(&role)).map_err(ss_err)?;+ for item in found.locked.iter() {+ item.unlock().map_err(ss_err)?;+ }+ for item in found.unlocked.iter().chain(found.locked.iter()) {+ item.delete().map_err(ss_err)?;+ }+ let left = self.ss.search_items(self.attrs(&role)).map_err(ss_err)?;+ if !left.unlocked.is_empty() || !left.locked.is_empty() {+ return Err(StoreError::Unavailable(format!(+ "wipe incomplete: {} {} key item(s) remain",+ left.unlocked.len() + left.locked.len(),+ role_name(&role)+ )));+ }+ }+ Ok(())+ }++ /// Lock the default collection (rigs: the wipe-while-locked row).+ #[doc(hidden)]+ pub fn lock_collection(&self) -> Result<(), StoreError> {+ self.ss.get_default_collection().map_err(ss_err)?.lock().map_err(ss_err)+ }++ /// How many items of this profile exist, locked or not (rigs).+ #[doc(hidden)]+ pub fn count_items(&self) -> Result<usize, StoreError> {+ let mut n = 0;+ for role in [KeyRole::Account, KeyRole::Device, KeyRole::Consent] {+ let f = self.ss.search_items(self.attrs(&role)).map_err(ss_err)?;+ n += f.unlocked.len() + f.locked.len();+ }+ Ok(n)+ }+}++impl KeyStore for SecretStore {+ fn public_key(&self, role: &KeyRole) -> Result<Option<[u8; 65]>, StoreError> {+ if *role != KeyRole::Device {+ return Ok(None);+ }+ match self.read(role)? {+ Some(d) => {+ let key = SigningKey::from_slice(&d).map_err(ss_err)?;+ Ok(Some(key.verifying_key().to_encoded_point(false).as_bytes().try_into().unwrap()))+ }+ None => Ok(None),+ }+ }++ fn sign(&mut self, role: &KeyRole, msg: &[u8], _prompt: Option<&Prompt>) -> Result<[u8; 64], StoreError> {+ if *role != KeyRole::Device {+ // No consent key on a no-TPM machine; the account key is used by+ // the account flows via `account()`, never through `sign`.+ return Err(StoreError::Unavailable("no hardware consent key on this machine".into()));+ }+ let d = self.read(role)?.ok_or(StoreError::NoKey)?;+ let key = SigningKey::from_slice(&d).map_err(ss_err)?;+ let sig: Signature = key.sign(msg);+ Ok(sig.to_bytes().into())+ }++ fn has_consent_key(&self) -> bool {+ false+ }+}diff --git a/home/desktop/agent/tests/recovery.rs b/home/desktop/agent/tests/recovery.rsnew file mode 100644index 00000000..d5a34003--- /dev/null+++ b/home/desktop/agent/tests/recovery.rs@@ -0,0 +1,171 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+//+// The recovery code and key blobs against kernel/fixtures/recovery-v1.json,+// mirroring scripts/test-recovery.ts. Every value is DETERMINISTIC: this port+// must reproduce the exact bytes. The Argon2id primitive is checked against+// RFC 9106 §5.3 FIRST, before anything trusts it. A missing fixture fails.+// Override the path with BENTO_RECOVERY_FIXTURE.++use bento_id_agent::recovery as rc;+use bento_id_agent::statements::KxMode;+use serde_json::Value;+use zeroize::Zeroizing;++fn fixture() -> Value {+ let path = std::env::var("BENTO_RECOVERY_FIXTURE").unwrap_or_else(|_| {+ format!("{}/../../../kernel/fixtures/recovery-v1.json", env!("CARGO_MANIFEST_DIR"))+ });+ let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("the recovery fixture is required ({path}): {e}"));+ serde_json::from_str(&text).unwrap()+}+fn unhex(s: &str) -> Vec<u8> {+ (0..s.len()).step_by(2).map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap()).collect()+}+fn hex(b: &[u8]) -> String {+ b.iter().map(|x| format!("{x:02x}")).collect()+}+fn s<'a>(v: &'a Value, k: &str) -> &'a str {+ v[k].as_str().unwrap_or_else(|| panic!("missing {k}"))+}+fn key32(h: &str) -> Zeroizing<[u8; 32]> {+ Zeroizing::new(unhex(h).try_into().unwrap())+}+fn blob(v: &Value) -> rc::PrfBlob {+ rc::PrfBlob { v: v["v"].as_u64().unwrap() as u32, cred: s(v, "cred").into(), salt: s(v, "salt").into(), iv: s(v, "iv").into(), ct: s(v, "ct").into() }+}++#[test]+fn argon2id_primitive_matches_rfc9106_and_the_fixture_states_our_parameters() {+ let f = fixture();+ let v = &f["rfc9106"];+ let tag = rc::argon2id_raw(+ &unhex(s(v, "password")),+ &unhex(s(v, "salt")),+ Some(&unhex(s(v, "secret"))),+ Some(&unhex(s(v, "ad"))),+ v["memoryKiB"].as_u64().unwrap() as u32,+ v["passes"].as_u64().unwrap() as u32,+ v["parallelism"].as_u64().unwrap() as u32,+ v["tagLength"].as_u64().unwrap() as usize,+ )+ .unwrap();+ assert_eq!(hex(&tag), s(v, "tag"), "Argon2id(RFC 9106 §5.3) = the published tag");+ let p = &f["params"]["argon2"];+ assert_eq!(+ (p["version"].as_u64(), p["parallelism"].as_u64(), p["memoryKiB"].as_u64(), p["passes"].as_u64(), p["tagLength"].as_u64()),+ (Some(rc::ARGON2_VERSION as u64), Some(rc::ARGON2_PARALLELISM as u64), Some(rc::ARGON2_MEMORY_KIB as u64),+ Some(rc::ARGON2_PASSES as u64), Some(rc::ARGON2_TAG_LEN as u64)),+ "the port's parameters are the fixture's (v0x13, p=1, 64 MiB, t=3, 32 bytes)"+ );+}++#[test]+fn printed_codes_including_every_extra_check_symbol() {+ let f = fixture();+ let codes = f["codes"].as_array().unwrap();+ for c in codes {+ assert_eq!(rc::format_recovery_code(&unhex(s(c, "bytes"))), s(c, "printed"));+ }+ for sym in ["*", "~", "$", "=", "U"] {+ assert!(codes.iter().any(|c| c["check"] == sym), "a code whose check symbol is {sym}");+ }+}++#[test]+fn reading_what_a_person_typed() {+ let f = fixture();+ let mut bad = vec![];+ for r in f["parse"].as_array().unwrap() {+ let got = rc::parse_recovery_code(s(r, "input"));+ let ok = match (r["bytes"].as_str(), &got) {+ (Some(b), Ok(code)) => hex(&code[..]) == b,+ (None, Err(e)) => e.as_str() == s(r, "reason"),+ _ => false,+ };+ if !ok {+ bad.push(format!("{:?} → {:?}", s(r, "input"), got.map(|c| hex(&c[..]))));+ }+ }+ assert!(bad.is_empty(), "{}", bad.join("\n"));+}++#[test]+fn derivations() {+ let f = fixture();+ let d = &f["derivations"];+ let (code, salt, salt_v) = (unhex(s(d, "code")), unhex(s(d, "salt")), unhex(s(d, "saltV")));+ assert_eq!(hex(&rc::argon2id(&code, &salt)), s(d, "argon2_A"), "A = Argon2id(code bytes, salt)");+ assert_eq!(hex(&rc::recovery_wrap_key(&code, &salt)), s(d, "wrapKey"), "wrap key = HKDF(A, empty, rc-wrap)");+ assert_eq!(hex(&rc::recovery_verifier(&code, &salt_v)), s(d, "verifier"), "verifier = Argon2id(code, salt_v)");+ assert_ne!(s(d, "verifier"), s(d, "argon2_A"));+ assert_eq!(hex(&rc::prf_kek(&unhex(s(&d["prf"], "output")), &unhex(s(&d["prf"], "salt")))), s(d, "prfKek"));+}++#[test]+fn whole_blobs_end_to_end() {+ let f = fixture();+ let b = &f["blobs"];+ let k = &b["keys"];+ let i = &b["prf"]["inputs"];+ let (prf, cred, salt, iv) = (unhex(s(i, "prfOutput")), unhex(s(i, "credentialId")), unhex(s(i, "salt")), unhex(s(i, "iv")));+ let acct = s(k, "accountPub");+ let kx_pub = s(k, "kxPub");++ let only = rc::BlobKeys { account: key32(s(k, "accountD")), kx: None };+ assert_eq!(rc::seal_prf_blob(&prf, &cred, &salt, &iv, &only, KxMode::Unruled), blob(&b["prf"]["unruled"]), "PRF blob re-seals byte for byte");+ let with_kx = rc::BlobKeys { account: key32(s(k, "accountD")), kx: Some(key32(s(k, "kxD"))) };+ assert_eq!(rc::seal_prf_blob(&prf, &cred, &salt, &iv, &with_kx, KxMode::A), blob(&b["prf"]["modeA"]), "mode A re-seals byte for byte");++ let opened = rc::open_prf_blob(&blob(&b["prf"]["unruled"]), &prf, &cred, acct, None, KxMode::Unruled).unwrap();+ assert_eq!(hex(&opened.account[..]), s(k, "accountD"));+ let opened_a = rc::open_prf_blob(&blob(&b["prf"]["modeA"]), &prf, &cred, acct, Some(kx_pub), KxMode::A).unwrap();+ assert_eq!(hex(&opened_a.kx.unwrap()[..]), s(k, "kxD"));+ let flip = |v: &[u8]| v.iter().map(|x| x ^ 1).collect::<Vec<u8>>();+ assert_eq!(rc::open_prf_blob(&blob(&b["prf"]["unruled"]), &flip(&prf), &cred, acct, None, KxMode::Unruled).err(), Some("decrypt"));+ assert_eq!(rc::open_prf_blob(&blob(&b["prf"]["unruled"]), &prf, &flip(&cred), acct, None, KxMode::Unruled).err(), Some("credential"));+ assert_eq!(rc::open_prf_blob(&blob(&b["prf"]["unruled"]), &prf, &cred, acct, Some(kx_pub), KxMode::A).err(), Some("length"));++ let r = &b["recovery"]["inputs"];+ let wk = rc::recovery_wrap_key(&unhex(s(r, "code")), &unhex(s(r, "salt")));+ let riv = unhex(s(r, "iv"));+ assert_eq!(hex(&rc::seal_recovery_inner(&wk, &riv, acct, &only, KxMode::Unruled)), s(&b["recovery"], "inner"), "recovery inner re-seals");+ let inner = unhex(s(&b["recovery"], "inner"));+ assert_eq!(hex(&rc::open_recovery_inner(&inner, &wk, &riv, acct, None, KxMode::Unruled).unwrap().account[..]), s(k, "accountD"));+ let other = rc::parse_recovery_code(s(&f["codes"][1], "printed")).unwrap();+ let wk2 = rc::recovery_wrap_key(&other[..], &unhex(s(r, "salt")));+ assert_eq!(rc::open_recovery_inner(&inner, &wk2, &riv, acct, None, KxMode::Unruled).err(), Some("decrypt"), "another code cannot open it");+ assert_eq!(rc::open_recovery_inner(&inner, &wk, &riv, kx_pub, None, KxMode::Unruled).err(), Some("decrypt"), "aad binds the account");++ let pp = &b["pepper"];+ let (vk, wkey) = rc::pepper_keys(&unhex(s(pp, "secret")), acct);+ assert_eq!((hex(&vk), hex(&wkey)), (s(pp, "verifyKey").to_string(), s(pp, "wrapKey").to_string()));+ let d = &f["derivations"];+ let verifier = rc::recovery_verifier(&unhex(s(d, "code")), &unhex(s(d, "saltV")));+ assert_eq!(hex(&rc::pepper_verifier_tag(&vk, &verifier)), s(pp, "verifierTag"));+ let piv = unhex(s(pp, "iv"));+ assert_eq!(hex(&rc::pepper_seal(&wkey, &piv, &inner, acct)), s(pp, "outer"));+ assert_eq!(hex(&rc::pepper_open(&wkey, &piv, &unhex(s(pp, "outer")), acct).unwrap()), s(&b["recovery"], "inner"));+ assert!(rc::pepper_open(&wkey, &piv, &unhex(s(pp, "outer")), kx_pub).is_none(), "presented as another account's, it fails");+}++#[test]+fn scalars_on_import() {+ let f = fixture();+ for sc in f["scalars"].as_array().unwrap() {+ let v = rc::unpack_scalars(&unhex(s(sc, "d")), s(sc, "pub"), None, KxMode::Unruled);+ match s(sc, "expect") {+ "accept" => assert!(v.is_ok(), "{}", s(sc, "name")),+ _ => assert_eq!(v.err(), Some(s(sc, "reason")), "{}", s(sc, "name")),+ }+ }+}++#[test]+fn normaliser_is_unicode_17_or_later() {+ // kernel/fixtures/README.md: NFC must be computed with Unicode ≥ 17.0 data+ // (the display table refuses everything unassigned at 17.0). Fails if the+ // crate is ever pinned or downgraded below that.+ let (major, _, _) = unicode_normalization::UNICODE_VERSION;+ assert!(major >= 17, "unicode-normalization data is {:?}", unicode_normalization::UNICODE_VERSION);+}diff --git a/home/desktop/agent/tests/secret_linux.rs b/home/desktop/agent/tests/secret_linux.rsnew file mode 100644index 00000000..80b36b18--- /dev/null+++ b/home/desktop/agent/tests/secret_linux.rs@@ -0,0 +1,79 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+//+// The no-TPM Linux store against a real Secret Service (gnome-keyring under a+// D-Bus session, as at login). Run via keyring-rig.sh. The EXPOSURE is+// asserted, not hidden: once the keyring is unlocked, a second connection reads+// the account key with no prompt.+#![cfg(all(target_os = "linux", feature = "keyring"))]++use bento_id_agent::agent::{Agent, Caller, Clock, KeyRole, KeyStore, Policy, Refusal};+use bento_id_agent::secret_linux::SecretStore;+use bento_id_agent::{b64u, statements as st};++struct Now;+impl Clock for Now {+ fn now_ms(&self) -> u64 {+ std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_millis() as u64+ }+}+fn profile(tag: &str) -> String {+ format!("rig-{tag}-{}", std::process::id())+}++#[test]+fn routine_key_signs_and_verifies() {+ let mut s = SecretStore::open(&profile("routine")).unwrap();+ let pubk = b64u::enc(&s.create_device_key().unwrap());+ assert_eq!(s.public_key(&KeyRole::Device).unwrap().map(|p| b64u::enc(&p)), Some(pubk.clone()));+ let raw = s.sign(&KeyRole::Device, b"live", None).unwrap();+ assert!(st::verify_statement_sig(&pubk, &b64u::enc(&st::low_s(&raw)), "live"));+ s.wipe().unwrap();+ assert_eq!(s.public_key(&KeyRole::Device).unwrap(), None, "wipe removes the key");+}++#[test]+fn no_consent_key_so_aal3_is_refused() {+ let s = SecretStore::open(&profile("aal3")).unwrap();+ s.create_device_key().unwrap();+ assert!(!s.has_consent_key());+ let mut a = Agent::new(s, Now, Policy::default());+ let caller = Caller { verified: true, doc_id: Some("d1".into()) };+ let r = a.consent(&caller, "revoke", "rev.x", &b64u::enc(&[1u8; 24]));+ assert_eq!(r.unwrap_err(), Refusal::Unavailable, "no consent key on a no-TPM machine: AAL3 refused");+ a.begin_session();+ assert!(a.sign(&caller, "show", "live").is_ok(), "routine signing still works");+}++#[test]+fn stated_exposure_a_second_connection_reads_the_account_key_without_a_prompt() {+ let p = profile("exposure");+ let first = SecretStore::open(&p).unwrap();+ first.store_account(&[9u8; 32]).unwrap();+ drop(first);+ let other = SecretStore::open(&p).unwrap();+ assert_eq!(&other.account().unwrap()[..], &[9u8; 32][..], "RESIDUAL (stated): readable by any same-user process");+ other.wipe().unwrap();+ assert!(other.account().is_err());+}++#[test]+fn wipe_with_a_locked_keyring_never_reports_success_while_keys_remain() {+ // Security, #779 review: wipe() used to delete only UNLOCKED items, so with+ // a locked keyring every key survived and wipe still returned Ok.+ let s = SecretStore::open(&profile("locked")).unwrap();+ s.create_device_key().unwrap();+ s.store_account(&[3u8; 32]).unwrap();+ assert_eq!(s.count_items().unwrap(), 2);+ s.lock_collection().unwrap();+ match s.wipe() {+ // either it unlocked and removed everything…+ Ok(()) => assert_eq!(s.count_items().unwrap(), 0, "wipe said Ok, so nothing may remain"),+ // …or it refused to claim success; then the keys are still there, and+ // the caller knows the wipe did not happen.+ Err(e) => {+ eprintln!("wipe refused on a locked keyring: {e:?}");+ assert!(s.count_items().unwrap() > 0, "an Err means keys remain");+ }+ }+}