polish P1: protocol §2.5 and §10.9, README D3 and Status, TODO §10

§2.5 is the legacy stream: the fixed salt, IV and iteration count with
citations into the pre-a9e1f0f20e Encryption.cs, the missing cleartext
header, why the sacrificial block exists, the MacCipherScheme setting and
the mismatch diagnostic. §2.3 now says plainly that it describes v0.101
and later only.

§10.9 records the one fact in this document confirmed against a live
Windows machine rather than the source: the lead's independent Python
probe completed the whole handshake against the user's PC under the
legacy scheme, which proves framing, the magic hash, the packet layout
and the handshake as transcribed, and localises the earlier failure to
the stream cipher alone.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 21:11:09 -07:00
1 parent 2de39f79de
commit 81e35b6691
4 files changed
+216 -4

No files matched your search

+15 -2
View File
@@ -23,13 +23,25 @@ are green, `mwb --version` / `--check-permissions` run. Lanes run one at
a time in the order of [`docs/loop.md`](docs/loop.md) §6; `packet-codec`
is next. There are no test suites by design: the user tests the app.
2026-09-16: all lanes through `extras` merged; checkpoints CP1–CP3 with
the user. The `polish` lane is now working the findings from that
testing ([`docs/features/polish/README.md`](docs/features/polish/README.md)).
P1 of it matters to anyone pairing with a PC: **the encryption changed
in PowerToys 0.101**, and a machine on stable PowerToys still speaks the
older scheme, so `MacCipherScheme` defaults to `legacy` and the Security
pane's "Encryption compatibility" picker is the switch to change if the
menu says a machine has the wrong one (protocol
[§2.5](docs/protocol.md)). The legacy handshake is the one part of this
protocol confirmed against a real Windows peer rather than against the
source (§10.9).
## Decisions
| # | Decision | Why |
|---|---|---|
| D1 | **Swift 6 + SwiftPM, no Xcode project.** The `.app` bundle is assembled by `tools/bundle.sh`. | Every platform surface the port needs (event taps, event posting, pasteboard, displays, Network.framework, menu bar) is an Apple framework; a second language would add an FFI boundary for nothing. Rust was considered for the protocol core and rejected as a second build system with no consumer that needs it. |
| D2 | **Three targets, layered by import rules.** `MWBCore` (Foundation + CommonCrypto only; sans-I/O protocol state machines), `MWBNet` (Network.framework), `MWBMac` (AppKit/CoreGraphics), executable `mwb`. | Protocol, crypto, matrix and coordinate logic stay readable and reviewable without any platform code around them. SwiftPM target boundaries make the layering a build failure rather than a convention. |
| D3 | **Settings file mirrors the PowerToys schema** (`{"name":"MouseWithoutBorders","version":"1.1","properties":{...}}`, same property names and defaults) at `~/Library/Application Support/mwb-mac/settings.json`, mode 0600. Key stored in plaintext like Windows. | Boring and copy-pasteable between machines. Keychain storage for the key is a backlog item, not a v1 blocker; the threat model equals the Windows one. |
| D3 | **Settings file mirrors the PowerToys schema** (`{"name":"MouseWithoutBorders","version":"1.1","properties":{...}}`, same property names and defaults) at `~/Library/Application Support/mwb-mac/settings.json`, mode 0600. Key stored in plaintext like Windows. Properties Windows writes and this port does not implement are round-tripped untouched. **One property is ours alone**: `MacCipherScheme` (`"legacy"` \| `"modern"`), because the wire has no way to ask a peer which encryption scheme it speaks (protocol §2.5) and Windows has no such switch — its build decides. A PowerToys that rewrites the file drops the key and the default, `legacy`, applies again. | Boring and copy-pasteable between machines. Keychain storage for the key is a backlog item, not a v1 blocker; the threat model equals the Windows one. A second settings file for one Mac-only property would be worse than one unknown key in a file that already tolerates unknown keys. |
| D4 | **Key mapping: Win↔Command, Alt↔Option, Ctrl↔Control**, with a static Windows-VK ↔ macOS-keycode table in `MWBCore/KeyMap.swift`. | Windows sends virtual-key codes only (protocol §5.1). A layout-independent table is the only thing both sides can agree on; a "swap Cmd/Ctrl when controlling Windows" option comes later. |
| D5 | **Permissions are the user's.** The app needs Accessibility (to post and swallow events) and Input Monitoring (to listen). It detects and explains; it never scripts System Settings. The binary must carry a **stable code-signing identity** (self-signed certificate at minimum) or TCC forgets the grant on every rebuild. | macOS TCC keys grants by code signature. Ad-hoc signatures change per build. |
| D6 | **Out of scope for v1**: Windows service / logon-screen control, Explorer drag-and-drop, screen capture to Paint, GPO, telemetry, key propagation via `Heartbeat_ex`, the animated fake cursor (`DrawMouse`). | No macOS equivalent, or Windows-shell specific, or not needed to join a matrix. Listed in TODO §9 with reasons. |
@@ -43,7 +55,8 @@ Sources/
Packet.swift DATA layout, PackageType, big/small rule (§1.1-1.2)
Framing.swift magic + checksum encode/validate (§1.3)
MagicHash.swift Get24BitHash (§2.1)
CipherStream.swift PBKDF2 + AES-256-CBC zero-padding stream codec (§2.2-2.3)
CipherStream.swift PBKDF2 + AES-256-CBC zero-padding stream codec,
legacy and modern schemes (§2.2-2.5)
Session.swift handshake / dedup / heartbeat state machine,
sans-I/O: bytes in, (packets, actions) out (§1.4, §3.2-3.3)
Matrix.swift 4-slot matrix, pool, LiveMachineMatrix (§4.1-4.2)