Repository navigation
feat(system): add the device identity, client key enrollment and the secure channel spec - #50
Conversation
…secure channel spec Adds the trust anchor and the contract of the end-to-end encrypted channel (epic #44, phase 1): - DeviceIdentity (X25519 public key and key ID) in SystemState and in the answer to the new EnrollClientKeyCommand, with ClientKind (HUB reserved). - PairedPhone.remote_key_enrolled and remote_key_label. - docs/secure-channel.md: Noise_IK_25519_ChaChaPoly_BLAKE2s, prologue, frame format, replay window, session rules, identity and authorization. - [secure_channel] constants in transport.toml. - docs/secure-channel-vectors.json and the script that generates them with the noiseprotocol reference implementation. Closes #45 Closes #46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiWM4SEVB1xBTaoykRa
|
The latest Buf updates on your PR. Results from workflow Proto Check / check (pull_request).
|
Hardware test: WiCAN (ESP32-C3) + virtual-carTested together with firmware#124, mobile-app#133, firmware#125 and mobile-app#134. The schema and the test vectors are exercised by tests 1–3 and 5 (keys and enrollment over BLE) and test 6 (the channel, Dart ↔ Rust). Setup
Tests1. [Analysis] The identity is made on the ESP: passAfter the erase, the board created an identity. On boot it logged 2. [PR] Pairing, validation and key enrollment: passFresh pairing of the Virtual car, then validation with the cluster code. After that, Paired phones showed "Remote access set up (…)". No identity banner.
3. [PR]/[Analysis] Reset with the bond kept: passThe board was reset with
4. [Analysis] firmware#125 flashed over #124 without erasing: pass
5. [Analysis] New device identity: passI erased only the access flash range (
6. [Analysis] Live interop: the Dart
|
| Case | Result |
|---|---|
| Owner: handshake, 51 commands (each echoed back on the same session), a keepalive | 1 handshake. Every command reached BASIC_CMD_CHANNEL as Transport::Secure with the owner's ble: ID and an authorization. The keepalive was dropped silently |
| Device restart (sessions forgotten) while the client keeps its session | The next frame got the unknown-session reply (type 5). The client handshook again, and the next command went through. The command sent during the restart is lost, as designed |
| Second phone, enrolled but not validated | RejectedNotValidated from the dispatcher, sealed back on its session and decrypted by the client |
| Unknown client key / wrong pinned device key | No answer. The client failed with SecureHandshakeTimeoutException |
Host checks for the stacked PRs (CI only ran the title check, since their base isn't main)
- firmware#125:
cargo xtask test,cargo fmt --check, andcargo xtask clippyfor pc and esp × virtual-car and egmp all pass. The only warning is arustlsdeprecation inboard-pc, which also appears onmain. - mobile-app#134:
build_runner,dart format(non-generated files),flutter analyze --fatal-infosandflutter test(557 tests) all pass.
Not tested
- E-GMP in the car.
- iOS.
- A second phone: a stranger trying to enroll, or a key already enrolled by another phone.
- Xtensa/S3 flash cost.
- The channel over a real transport (LAN firmware#120, MQTT firmware#122) and its handshake time and memory on the C3.
- Re-enrolling after a lost key on the device. The unit tests cover it, but it can't be triggered on this board without also changing the identity.
|
🎉 This PR is included in version 0.16.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Requested by Michaël · project thread
What and why
Phase 1 of the epic #44 (keys and secure channel), contracts side. Closes #45 and #46 in one PR, since the firmware and the app need both to implement and test the channel.
#45, keys over BLE (
system.proto, append-only):DeviceIdentity { public_key, key_id }, reported inSystemState.device_identity(field 10, BLE only) and inSystemCommandResult.device_identity(field 5).EnrollClientKeyCommand { public_key, kind, label }(SystemCommandfield 14) andClientKind(PHONE;HUBreserved and refused for now). BLE only, validated phone only, re-enrolling replaces the key; revocation is documented in the comments.PairedPhone.remote_key_enrolled(4) andremote_key_label(5, so the phone list can show the label the issue mentions).mqtt_client_idis not deprecated here, as the issue says (that comes with the relay).#46, the channel spec:
docs/secure-channel.md, a[secure_channel]section intransport.tomlwith its constants,docs/secure-channel-vectors.json, and the generatortools/secure_channel_vectors.py(Pythonnoiseprotocol0.3.1, run withpython -I, deterministic output). README links the doc.Choices the issue left open (please check)
5(type + session ID, nothing else) answered to a transport frame for a session the device doesn't have. It is unauthenticated, so the client treats it as a hint and keeps its old session until a new handshake completes. It reveals nothing (session IDs are random) and is smaller than what triggered it.opencar/secure/1+0x00+ the key ID in ASCII. Transport messages use empty associated data (the counter is the nonce, and each session has its own keys).Checklist
buf format,buf lintandbuf breaking --against '.git#branch=main'passSource of the data
The vectors come from the
noiseprotocolreference implementation, with fixed static and ephemeral keys.Generated by Claude Code