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:
1 parent
2de39f79de
commit
81e35b6691
4 files changed
+216
-4
No files matched your search
@@ -163,6 +163,9 @@ Zero padding never adds bytes because every write is a multiple of 16.
|
||||
Framing is therefore entirely length-driven by `Type` (§1.1). The
|
||||
clipboard channel (§5.3) uses the same layout.
|
||||
|
||||
**This is the v0.101 layout only.** Every PowerToys up to v0.100.2 uses
|
||||
the fixed salt and IV of §2.5 instead, with no cleartext header.
|
||||
|
||||
### 2.4 The security key
|
||||
|
||||
- Minimum 16 characters; validation is length-only (`Encryption.cs:235-242`).
|
||||
@@ -172,6 +175,65 @@ clipboard channel (§5.3) uses the same layout.
|
||||
- Stored in **plaintext** in `settings.json` as `SecurityKey`
|
||||
(`Class/Setting.cs:479-511`); a key change reopens all sockets.
|
||||
|
||||
### 2.5 Legacy stream, PowerToys ≤ 0.100 **[verified against a real Windows peer]**
|
||||
|
||||
§2.2 and §2.3 describe **v0.101 and later** only. PR #48742
|
||||
(`a9e1f0f20e`, 2026-06-22) replaced a fixed salt and IV with the
|
||||
per-connection cleartext header; every release up to and including
|
||||
**v0.100.2** (2026-06-26) — which is what a machine on stable PowerToys
|
||||
still runs today — uses the fixed material below. Citations in this
|
||||
section are to the pre-change file:
|
||||
`git show a9e1f0f20e^:src/modules/MouseWithoutBorders/App/Core/Encryption.cs`.
|
||||
|
||||
- `InitialIV = ulong.MaxValue.ToString(InvariantCulture)` =
|
||||
`"18446744073709551615"` (`Encryption.cs:41`).
|
||||
- Key = `PBKDF2-HMAC-SHA512(password: MyKey (UTF-8), salt:
|
||||
Common.GetBytesU(InitialIV), iterations: 50 000, length: 32)`
|
||||
(`Encryption.cs:117-138`, the call at `:124-129`). `GetBytesU` is
|
||||
`Encoding.Unicode`, i.e. **UTF-16LE** (`Common.cs:407-410`), so the
|
||||
salt is 40 bytes — `31 00 38 00 34 00 … 35 00` — not the 20 ASCII
|
||||
digits. Note the iteration count: 50 000, half the modern 100 000.
|
||||
- IV = `GenLegalIV` (`Encryption.cs:140-154`): `InitialIV` cut to the
|
||||
16-byte block size and taken as **ASCII** (`Common.GetBytes`,
|
||||
`Common.cs:397-400`) — `"1844674407370955"`.
|
||||
- Cipher configuration is unchanged from §2.2: AES-256-CBC,
|
||||
`PaddingMode.Zeros`, 16-byte blocks (`Encryption.cs:93-113`).
|
||||
- **No cleartext header.** Each direction is simply:
|
||||
|
||||
```
|
||||
[16 bytes random] FIRST ciphertext block: the sacrificial block,
|
||||
written through the cipher and discarded by the reader
|
||||
(Common.cs:1528-1558, wired at SocketStuff.cs:104-105, 118-119)
|
||||
[32 or 64 byte packets ...] framed as §1.3
|
||||
```
|
||||
|
||||
The sacrificial block exists *because* the IV is fixed: without it the
|
||||
first real packet would be the block a constant IV protects directly, so
|
||||
identical first packets would encrypt identically. The header scheme kept
|
||||
the block even though a random IV makes it redundant.
|
||||
|
||||
Everything else is the same across the two schemes — the magic number
|
||||
(§2.1), the framing (§1.3), the packet layout (§1.1), the handshake
|
||||
(§3.2) and the bulk channel's own stream (§6.3), which uses whichever
|
||||
scheme the control channel does.
|
||||
|
||||
**Which one this port speaks.** The Mac-only `MacCipherScheme` setting,
|
||||
`"legacy"` (default) or `"modern"`, chosen in the Security pane as
|
||||
"Encryption compatibility". There is no auto-negotiation and there cannot
|
||||
be a useful one: both vintages of Windows write their preamble first and
|
||||
never adapt, so two auto-detecting machines would each wait for the other.
|
||||
|
||||
**Mismatch diagnostic.** There is no MAC anywhere in this protocol
|
||||
(§1.3), so a peer on the other scheme is indistinguishable from a peer
|
||||
with the wrong key: garbage plaintext, failed framing. When the first
|
||||
packet fails framing under the configured scheme, the reader replays the
|
||||
peer's raw opening bytes — up to 48 + 32, the longest preamble plus one
|
||||
packet — under the other scheme; if *that* frames, the key is right and
|
||||
the setting is wrong, and the connection ends as
|
||||
`InvalidKeyReason.cipherSchemeMismatch` with its own status row rather
|
||||
than as "wrong security key". One extra AES setup on a connection that
|
||||
was already failing, and nothing at all on a connection that works.
|
||||
|
||||
---
|
||||
|
||||
## 3. Connections and handshake — `Class/SocketStuff.cs`
|
||||
@@ -1173,3 +1235,40 @@ sees them. One subsection per lane, appended, never rewritten.
|
||||
`ClipboardBridge` has no equivalent, which means a second copy of identical
|
||||
content after a switch may be dropped where Windows would resend it — recorded
|
||||
here rather than fixed, since it is the clipboard lane's state.
|
||||
|
||||
### 10.9 polish — P1, the legacy stream, verified against a real Windows peer (2026-09-16)
|
||||
|
||||
The first fact in this document confirmed against a live, unmodified
|
||||
Windows machine rather than against the source alone.
|
||||
|
||||
**The peer.** The user's PC `Lu-Corsair` (10.233.33.52), running stable
|
||||
PowerToys, accepting TCP on 15101. Under our then-only scheme (§2.3,
|
||||
the cleartext header) every packet it sent decrypted to garbage and
|
||||
every packet we sent was ignored.
|
||||
|
||||
**The probe.** An independent Python re-implementation of §1–§3 in the
|
||||
lead's scratchpad — written from this document, not from the Swift —
|
||||
reproduced the whole handshake against that PC with the **legacy**
|
||||
scheme of §2.5 and got, in order:
|
||||
|
||||
1. ten `Handshake (126)` packets whose `MachineName` was `Lu-Corsair`,
|
||||
each framing cleanly under the magic derived from the shared key;
|
||||
2. a `HandshakeAck (127)` whose `Machine1..4` were the bitwise
|
||||
complement of the nonce the probe had sent;
|
||||
3. `Heartbeat_ex (51)` — i.e. the PC had marked the probe trusted and
|
||||
moved on to ordinary traffic.
|
||||
|
||||
**What that proves.** `Framing` (§1.3), `MagicHash` (§2.1), the packet
|
||||
layout (§1.1) and the handshake (§3.2) are correct as transcribed —
|
||||
they are exercised end to end by that exchange. The only thing that was
|
||||
wrong was the stream cipher's key, IV and preamble, which is exactly
|
||||
what §2.5 now records.
|
||||
|
||||
**What it does not prove.** Nothing about the `.modern` scheme, which
|
||||
has still only been transcribed: no v0.101 machine has been on the wire
|
||||
with us. And the run was a *probe*, not this port — the Swift side of
|
||||
§2.5 was checked separately, offline, by encrypting with `CipherWriter`
|
||||
and decrypting with Python's `cryptography` under
|
||||
`pbkdf2_hmac('sha512', key, '18446744073709551615'.encode('utf-16-le'),
|
||||
50000, 32)` and `AES-CBC("1844674407370955")`, and vice versa; both
|
||||
directions matched byte for byte.
|
||||
Reference in new issue
Block a user