PQ: fix membership for post-quantum nodes (three control-plane defects)

A PQ node could complete the hybrid handshake and still never join the
network: status ACCESS_DENIED, peers [], frames dropped. Three separate
defects, none in the key exchange itself.

1. EmbeddedNetworkController::_request gated known members with
   Identity(haveIdStr) != identity. HELLO carries only the classic
   projection (Identity::serializeClassic), so peer->identity() stays
   type 0 while a stored record is type 1, and operator== -- which
   compares PQ material -- always reported a mismatch. Use the existing
   sameClassicalIdentity(); PQ key rotation stays detectable via
   VERB_PQ_KEYS.

2. Peer::setPQPublicKeys() cached the received PQ keys for the crypto
   path only and never wrote them into _id. The controller's identity
   therefore stayed type 0 in every table, com.verify() returned 1, and
   Membership deferred for WHOIS forever -- a WHOIS cannot help, the
   keys arrive in VERB_PQ_KEYS. Add Identity::attachPQPublicKeys() and
   call it so the peer's Identity is complete once keys arrive.

3. OneServiceImpl::run constructed an EmbeddedNetworkController
   unconditionally, so a member-only node answered its own
   NETWORK_CONFIG_REQUESTs and self-signed a local config, never
   contacting the node that owned the network. Add
   settings.disableController (default false, so existing installs are
   unchanged) for member-only nodes.

Verified live on two hosts with pqcMode: hybrid on both sides: status OK,
peer DIRECT over 192.168.122.85/9993, pqcCapable and pqcHybridActive true
both directions, ping 0% loss both ways, selftest exit 0.

The selftest regression covers the controller match and keeps rejecting an
impostor identity at the same address.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
proitlabandClaude Opus 4.8 committed 2026-10-07 21:37:05 +00:00
1 parent ad01fbcccb
commit a224dbbc53
24 files changed
+1423 -168

No files matched your search

+16 -3
View File
@@ -1085,14 +1085,27 @@ bool Packet::dearmor(const void *key,const AES aesKeys[2])
tag[1] = *reinterpret_cast<uint64_t *>(data + ZT_PACKET_IDX_MAC);
#endif
// GMAC-SIV decrypts in place, so a failed attempt would leave
// garbage in the payload and make any retry on another key hash
// ciphertext that no longer exists. Callers rely on being able to
// retry -- HELLO, OK(HELLO) and PQ_KEYS stay armed with the
// classical key while the session key is hybrid -- so decrypt to
// scratch, authenticate it, and only then commit.
uint8_t scratch[ZT_PROTO_MAX_PACKET_LENGTH];
memcpy(scratch, payload, payloadLen);
AES::GMACSIVDecryptor dec(aesKeys[0],aesKeys[1]);
dec.init(tag, payload);
dec.init(tag, scratch);
const uint8_t oldFlags = data[ZT_PACKET_IDX_FLAGS];
data[ZT_PACKET_IDX_FLAGS] &= 0xf8;
dec.aad(data + ZT_PACKET_IDX_DEST,11);
data[ZT_PACKET_IDX_FLAGS] = oldFlags;
dec.update(payload, payloadLen);
return dec.finish();
dec.update(scratch, payloadLen);
if (!dec.finish()) {
return false;
}
memcpy(payload, scratch, payloadLen);
return true;
}
} else if ((cs == ZT_PROTO_CIPHER_SUITE__C25519_POLY1305_NONE)||(cs == ZT_PROTO_CIPHER_SUITE__C25519_POLY1305_SALSA2012)) {
uint8_t mangledKey[32];