87 lines
4.0 KiB
Markdown
87 lines
4.0 KiB
Markdown
# polish
|
||
|
||
## Goal
|
||
|
||
Lane 10: fixes driven by the user's testing (CP1–CP3). Each item below
|
||
is one finding, with the evidence, the decision and the file that owns
|
||
the fix. Items are worked in order by one Dev → QA → lead round per
|
||
batch; the lead re-bundles after each batch.
|
||
|
||
## Findings and decisions
|
||
|
||
### P1 — PowerToys stable uses the pre-June-2026 cipher scheme (CP1, 2026-09-16)
|
||
|
||
**Evidence.** The user's PC `Lu-Corsair` (10.233.33.52) accepts TCP on
|
||
15101 but every packet decrypts to garbage under our scheme. An
|
||
independent Python probe in the lead's scratchpad reproduced the whole
|
||
handshake against that PC with the **legacy** scheme and got: ten
|
||
`Handshake` packets named `Lu-Corsair`, a `HandshakeAck` whose nonce
|
||
was the complement of ours, then `Heartbeat_ex (51)` — the PC trusted
|
||
the probe. So `Framing`, `MagicHash` and `Session`'s handshake are
|
||
proven against real Windows; only the stream cipher differs.
|
||
|
||
**Why.** PowerToys commit `a9e1f0f20e` (2026-06-22, PR #48742) replaced
|
||
a fixed salt/IV with the per-connection cleartext header
|
||
(`docs/protocol.md` §2.3). It is only in the `v0.101.*` build tags;
|
||
stable releases up to `v0.100.2` (2026-06-26) still use the old code.
|
||
Users on stable PowerToys are the common case.
|
||
|
||
**Legacy scheme** (`git show a9e1f0f20e^:src/modules/MouseWithoutBorders/App/Core/Encryption.cs`):
|
||
|
||
- `InitialIV = ulong.MaxValue.ToString()` = `"18446744073709551615"`.
|
||
- Key = `PBKDF2-HMAC-SHA512(password: MyKey (UTF-8), salt:
|
||
UTF-16LE("18446744073709551615") (40 bytes), iterations: 50 000,
|
||
length: 32)` (legacy `GenLegalKey`).
|
||
- IV = ASCII of `InitialIV` truncated to 16 bytes = `"1844674407370955"`
|
||
(legacy `GenLegalIV`).
|
||
- **No cleartext header.** The stream is AES-256-CBC(key, IV) of
|
||
`[16 random sacrificial bytes][packets…]` — the sacrificial block
|
||
(`SendOrReceiveARandomDataBlockPerInitialIV`) exists precisely
|
||
because the IV was fixed. Same for the clipboard bulk connection.
|
||
|
||
**Decision.** A new Mac-only setting `MacCipherScheme` with values
|
||
`"legacy"` (default — matches current stable PowerToys) and `"modern"`
|
||
(PowerToys 0.101+ / the header scheme), stored in the same
|
||
`settings.json` (unknown to Windows, preserved). Applied to every
|
||
control and bulk connection. Shown in the Security pane as
|
||
"Encryption compatibility: PowerToys 0.100 and earlier / 0.101 and
|
||
later". Auto-negotiation is not attempted: both versions of Windows
|
||
write first and never adapt, and two auto-detecting Macs would
|
||
deadlock waiting for each other. **Diagnostic**: when the first packet
|
||
from a peer fails framing under the configured scheme, the reader
|
||
tries the other scheme on the same bytes; if that passes, the
|
||
connection reports status `.invalidKey` with a distinct reason
|
||
`.cipherSchemeMismatch` that the menu shows as "wrong encryption
|
||
setting (peer uses PowerToys 0.100 / 0.101 scheme)". This costs one
|
||
extra AES setup per failed connection and nothing on success.
|
||
|
||
**Files.** `Sources/MWBCore/CipherStream.swift` (a `CipherScheme` enum;
|
||
`CipherWriter`/`CipherReader` take it; legacy constants cited),
|
||
`Sources/MWBCore/Settings.swift` (accessor + default),
|
||
`Sources/MWBNet/ChannelConfig.swift` + `PeerConnection.swift` +
|
||
`BulkConnection.swift` (pass the scheme; the mismatch diagnostic),
|
||
`Sources/MWBCore/Session.swift` (`InvalidKeyReason.cipherSchemeMismatch`),
|
||
`Sources/mwb/Engine.swift` (config mapping), `Sources/MWBMac/SettingsWindow/SecurityPane.swift`
|
||
(the picker), `Sources/MWBMac/StatusItem.swift` (the wording),
|
||
`docs/protocol.md` (§2.5 "Legacy stream, PowerToys ≤ 0.100" and §10.9
|
||
"verified against a real Windows peer"), `README.md` (D3 note, §Status).
|
||
|
||
### P2 — event tap not installed at first launch (CP1)
|
||
|
||
`mwb.log`: `event tap not installed (creationFailed)`. Expected: the
|
||
user had not granted Accessibility yet; the menu says so. No code
|
||
change unless the user reports the menu text was unclear. Kept here so
|
||
the CP1 record is complete.
|
||
|
||
## Status / TODO
|
||
|
||
- [ ] P1: legacy scheme + setting + diagnostic, files as listed;
|
||
`docs/protocol.md` §2.5 and §10.9.
|
||
- [ ] P2: none.
|
||
|
||
## Work log
|
||
|
||
## QA log
|
||
|
||
## Review
|