diff --git a/docs/pqc-test-scenario.md b/docs/pqc-test-scenario.md index f2b30ed..e67a78b 100644 --- a/docs/pqc-test-scenario.md +++ b/docs/pqc-test-scenario.md @@ -377,14 +377,16 @@ would produce a *different observable*: |---|---|---|---| | HELLO size / fragment count | 137 B / 1 | 137 B / 1 — **unchanged** | no — HELLO carries the classic projection only | | HELLO capability bit | 0 | 1 | yes | -| `VERB_PQ_KEYS` frames on wire | none | present, carrying the 1088 B ct | yes | +| `VERB_PQ_KEYS` exchange on wire | none | ~13 fragments of one 4257 B packet | yes — but **encrypted**: match on size/fragmentation, not `zt.verb` | | Identity type byte | 0 | 1 | yes | | COM type byte | 1 | 2 | yes | -| `_key` value | n/a off-wire | n/a off-wire | **no** — must be inferred from the above | +| Session key actually installed | `false` | `true` (`pqcHybridActive`) | yes — the only data-channel assertion | -Nothing about the negotiated symmetric key is directly observable. A test that -only does "ping works" passes trivially under M2 (classical fallback) and must not -be counted. +The session key is not readable from the wire — data frames are armored, so no +filter can reveal it. But its *installation* is directly observable via +`pqcHybridActive` (`Peer::hybridSessionKeyInstalled()`), which is a real +data-channel assertion. A test that only does "ping works" still passes trivially +under M2 (classical fallback) and must not be counted. --- diff --git a/docs/two-host-pq-manual-test.md b/docs/two-host-pq-manual-test.md index af99916..5b408c4 100644 --- a/docs/two-host-pq-manual-test.md +++ b/docs/two-host-pq-manual-test.md @@ -295,6 +295,47 @@ for p in json.load(sys.stdin): > The *identity file* is 6415 B because it holds the full type-1 record > (ML-KEM-768 + ML-DSA-65 public keys); the *HELLO packet* is not. +### 6.3 Data-channel gate — proving the *data* key is PQ-derived + +§6.2 proves the handshake advertises and exchanges PQ material. It does **not** +prove the session key protecting your frames came from it. Those are different +claims, and the gap matters: `pqcHybridActive` is the closest thing to a direct +answer, but read what it actually reports. + +```sh +A=$(sudo -n cat /var/lib/backone/authtoken.secret) +curl -s -m 8 -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/peer | python3 -c " +import json,sys +for p in json.load(sys.stdin): + if p.get('role') != 'PLANET': + print(p['address'], 'capable=', p.get('pqcCapable'), 'hybrid=', p.get('pqcHybridActive'))" +``` + +| Field | What it actually means | +|---|---| +| `pqcCapable` | Peer set the capability bit. Advertised support only. | +| `pqcHybridActive` | `Peer::hybridSessionKeyInstalled()` — the derived key is **installed into `_key`**, the buffer every data frame is armored with. | + +`pqcHybridActive: true` is a genuine assertion about the data channel, and it is +deliberately stricter than "eligible": the code comment at `node/Peer.hpp:710` +says eligibility "is true a full round trip before the key exists, so reporting +it as 'hybrid active' claims protection that is not in use." + +**Why tcpdump/tshark cannot answer this directly.** Data frames are armored with +the session key (`Peer.cpp:645`), so the payload — and the verb byte — is +ciphertext. No filter can distinguish a PQ-derived key from a classical one, +because that property is not visible in the output of a cipher. Any "the data +frames look post-quantum" check is vacuous. + +**The one wire artifact that does bear on it.** `Peer::pqConfirmTag` +(`node/Peer.hpp:67`) is `HMAC-SHA384(installed session key, min(addr) ‖ +max(addr))` truncated to `ZT_PQ_KEYS_CONFIRM_LEN` = 4 bytes, appended **last** +in `VERB_PQ_KEYS` so its position is unambiguous. Recomputing it offline under a +candidate key and comparing proves which key both peers derived — but it is a +verifier requiring the session key, not a passive observation, so it must be +run on one of the hosts. Treat it as a lab tool for the key-confirmation path +(`IncomingPacket.cpp:1613`), not as a routine capture check. + --- ## 7. Capture and dissection @@ -322,24 +363,31 @@ tshark -X lua_script:tools/zt-dissector.lua -r /tmp/pq.pcap \ | Filter | Shows | |---|---| | `zt` | any BackOne frame | +| `zt.verb` | **only on unencrypted frames** — absent on encrypted ones | | `zt.verb == 1` | HELLO only (`Packet.hpp:617`) | | `zt.hello.cap` | capability bit — `0` classical, `1` hybrid | | `zt.hello.idtype` | identity type **in HELLO** — `0` even in hybrid (classic projection only) | | `zt.hello.idsize` | serialized classic identity size (39 B) | +| `zt.flags` | cipher suite in bits 3-5; `0x80` is the pre-1.0.3 legacy bit | | `zt.frag` / `zt.fragno` / `zt.fragtot` | fragment header — only for large frames | -| `zt.verb == 23` | `VERB_PQ_KEYS` (`0x17`), carries the PQ keys + 1088 B ML-KEM ct | **Verified live 2026-10-07** on a hybrid↔hybrid link: ``` -ZT HELLO type=0 DBFA939D58 cap=1 # 185 B, single fragment -ZT ... Len=1432 # VERB_PQ_KEYS, well over one MTU +ZT HELLO type=0 DBFA939D58 cap=1 185 B # unencrypted, cap bit set +ZT ... Len=1480 flags=0x58 # PQ_KEYS fragments, cipher 3 (AES-GCM) ``` -Expect `cap=1` on HELLO **and** at least one `VERB_PQ_KEYS` frame. The -capability bit alone proves only that the peer *advertises* support; the -`VERB_PQ_KEYS` frame is what actually carries the material, and a missing one is -the signature of bug B7. +> **`VERB_PQ_KEYS` is encrypted and its verb is NOT visible.** It is armored +> with the *classical* key and `encryptPayload=true` (`Peer.cpp:628`), so byte 27 +> is ciphertext like any other data packet — that is what lets the peer read it +> before it has switched to the hybrid session key. A 4257 B PQ_KEYS arrives as +> ~13 fragments at 1480 B each; identify it by **size and fragmentation**, not by +> `zt.verb`. The capture above shows 13 such frames. +> +> The capability bit proves only that the peer *advertises* support. That the +> PQ exchange actually happened is a **state** question, answered in §6.3 — +> not something a dissector can show. **Run tshark as your normal user, not root.** As superuser, Wireshark silently skips user Lua scripts and the dissector appears to be broken. If the pcap lives diff --git a/tools/zt-dissector.lua b/tools/zt-dissector.lua index c65d68d..2afd134 100644 --- a/tools/zt-dissector.lua +++ b/tools/zt-dissector.lua @@ -10,6 +10,10 @@ local IDENTITY_SIZE_CLASSIC = 39 -- 5 addr + 1 type + 32 pub + 1 privlen local IDENTITY_SIZE_PQ = 3175 -- classic + 1184 ML-KEM-768 pk + 1952 ML-DSA-65 pk local HELLO_IDENTITY_OFF = 13 -- payload + (pv1+maj1+min1+rev2+timestamp8) +local CIPHER_NONE = 0 -- C25519_POLY1305_NONE, payload left in the clear +local CIPHER_SALSA20 = 1 -- C25519_POLY1305_SALSA2012 +local CIPHER_AES_GCM = 3 -- AES_GMAC_SIV + local f = { iv = ProtoField.bytes("zt.iv", "Packet ID / IV"), dest = ProtoField.string("zt.dest", "Destination"), @@ -83,14 +87,22 @@ function zt.dissector(buf, pinfo, tree) if buf:len() < 28 then return end - local verb = buf(27, 1):uint() - local encrypted = bit.band(buf(18, 1):uint(), 0x80) ~= 0 - local t = tree:add(zt, buf(), "BackOne, verb " .. verb) + -- Cipher suite lives in flags bits 3-5 (FFCCCHHH, Packet.hpp:1319). Suite 0 + -- (C25519_POLY1305_NONE) leaves the payload in the clear; suites 1 and 3 + -- encrypt from ZT_PACKET_IDX_VERB (27) onward, so byte 27 is ciphertext and + -- must not be presented as a verb. Checking only the pre-1.0.3 0x80 bit + -- misreads every AES-GCM frame, which is what a PQ link uses. + local cipher = bit.band(bit.rshift(buf(18, 1):uint(), 3), 0x07) + local encrypted = (cipher ~= CIPHER_NONE) and (cipher == CIPHER_SALSA20 or cipher == CIPHER_AES_GCM) + local verb = encrypted and 0 or buf(27, 1):uint() + local t = tree:add(zt, buf(), encrypted and "BackOne, encrypted" or ("BackOne, verb " .. verb)) t:add(f.iv, buf(0, 8)) t:add(f.dest, addr(buf, 8)) t:add(f.src, addr(buf, 13)) t:add(f.flags, buf(18, 1)) - t:add(f.verb, buf(27, 1)) + if not encrypted then + t:add(f.verb, buf(27, 1)) + end -- Head of a fragmented packet still carries the original header, so the -- verb and the leading payload bytes are parseable.