Repository navigation
Conversation
A Noise IK initiator on the cryptography package's Dart code, the channel's frames, replay window and stream framing, and SecureChannel, which keeps a session up over any frame pipe: it handshakes on first use, after expiry, on an unknown session hint and ahead of the limits, and reports a clear error when the device doesn't answer. Tested against the contract's vectors and a fake device. Closes #129 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiWM4SEVB1xBTaoykRa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Michaël · project thread
What and why
Closes #129. Phase 1 of OpenCarControls/contracts#44: the app side of the secure channel (OpenCarControls/contracts#46), a transport-independent session the LAN (#130) and MQTT (#131) transports will plug into. Stacked on #133 (base
feat/client-key-enrollment); retarget tomainonce that merges.All in
lib/secure/, pure Dart with no Flutter imports (ready for the background isolate in #132):noise_ik.dart:Noise_IK_25519_ChaChaPoly_BLAKE2sinitiator, synchronous on thecryptographypackage's Dart implementations, with HMAC/HKDF from the Noise spec. Refuses a low-order device key, as the firmware does.secure_frames.dart: frame build/parse (malformed → dropped), the 64-counter replay window (updated only after a frame decrypts), and the 2-byte length framing for streams as a separate helper.secure_session.dart:SecureHandshake→SecureSession:seal(AppToDevice),sealKeepalive(),open(frame)→ message, keepalive, or drop with a reason. Tracks idle time, lifetime and message counts.SecureChannelover anySecureFramePipe: handshakes on first use, after expiry, on an unknown-session hint (keeping the old session meanwhile) and at 90 % of the lifetime or message limit (keeping the old session until the new one is up, still reading late frames on it). If the device doesn't answer withinhandshake_timeout_ms, it fails withSecureHandshakeTimeoutException, whose text tells the user to connect over Bluetooth.[secure_channel]constants are generated (SecureChannelConstantsBuilder, added in feat: enroll the app's client key once the phone is validated #133), not copied.docs/architecture.md.One choice to flag: the 90 % re-handshake threshold (
kSecureRehandshakeAt) is an app constant, not in the contract, since the device doesn't need it.How it was tested
test/secure_channel_test.dart, againstcontracts/docs/secure-channel-vectors.json: init frame byte for byte, response, handshake hash, transport frames both ways (including the out-of-order counter and the keepalive), unknown-session frame, response under another device key.SecureChannelagainst a fake device (test/support/fake_secure_device.dart, a small IK responder): messages both ways, a duplicated or replayed frame, a forged tag, timeouts (no answer, client key removed, wrong pinned device key), re-handshake after idle, before the lifetime (old session still read), after a device restart (unknown session), and after dispose.dart format,flutter analyze --fatal-infosand the fullflutter testpass.flutter testneededthermion_dart's native download skipped; that workaround is not committed.Checklist
feat:,fix:,docs:,chore:); CI validates itdart format,flutter analyze --fatal-infosandflutter testpassdocs/or README) updated if behaviour changedconfig.tomlor credentials committed; generated files not hand-editedSafety
Nothing calls the new code yet.
Generated by Claude Code