﻿<?xml version='1.0' encoding='utf-8'?>
<rfc version="3" ipr="trust200902" docName="draft-pq-sectunnel-00" submissionType="IETF" category="info" xml:lang="en" indexInclude="true">

<front>
<title abbrev="PQ-SecTunnel">PQ-SecTunnel Protocol Specification</title><seriesInfo value="draft-pq-sectunnel-00" stream="IETF" status="informational" name="Internet-Draft" />
<author initials="K." surname="Fan" fullname="Kai Fan"><organization>Xidian University</organization><address><postal><city>Xi'an</city><region>Shaanxi</region><country>China</country>
</postal><email>kfan@mail.xidian.edu.cn</email>
</address></author><author initials="R." surname="Su" fullname="Ruidan Su"><organization>Xidian University</organization><address><postal><city>Xi'an</city><region>Shaanxi</region><country>China</country>
</postal><email>rdsu@xidian.edu.cn</email>
</address></author><author initials="Y." surname="Wang" fullname="Yi Wang"><organization>Xidian University</organization><address><postal><city>Xi'an</city><region>Shaanxi</region><country>China</country>
</postal><email>23151214152@stu.xidian.edu.cn</email>
</address></author><author initials="J." surname="Cheng" fullname="Jiaqing Cheng"><organization>Xidian University</organization><address><postal><city>Xi'an</city><region>Shaanxi</region><country>China</country>
</postal><email>jiaqing.ch@stu.xidian.edu.cn</email>
</address></author><date year="2026" month="August" day="13" />
<area>Internet</area>
<workgroup />
<keyword>PQ-SecTunnel</keyword>
<keyword>post-quantum</keyword>
<keyword>cryptography</keyword>

<abstract>
<t>This document specifies the PQ-SecTunnel protocol, a UDP-based quantum-resistant IP tunnel derived from the WireGuard architecture. Session keys are established by a three-message Noise_IKpsk1kem handshake that replaces Diffie-Hellman with dual Key Encapsulation Mechanism (KEM) operations (static and ephemeral). Authentication is implicit: peers prove possession of long-term KEM private keys through interlocking encapsulations rather than signing the transcript.
The protocol is organized as a multi-suite framework. Implementations MAY select ML-KEM-512 or ML-KEM-768 independently for the static and ephemeral KEM roles. This document RECOMMENDS the profile static=ML-KEM-512, ephemeral=ML-KEM-768, AEAD=SM4-GCM, Hash=SM3 (denoted mlkem512-mlkem768-sm4gcm-sm3). Other ML-KEM combinations with the same AEAD/Hash, and additional KEM families such as Aigis-enc (integration ongoing), are optional profiles.</t>
</abstract>

</front>

<middle>

<section anchor="sec-1-introduction"><name>Introduction</name>
<t>Traditional IP-layer security protocols such as IPsec commonly rely on classical public-key primitives (RSA, ECDH) for key exchange and authentication. Advances in large-scale quantum computing threaten those constructions. PQ-SecTunnel provides a quantum-resistant tunnel for IP traffic over UDP.</t>
<t>The protocol has two phases:</t>

<ol>
<li><t>Key Agreement Protocol: A 3-message handshake that performs mutual implicit authentication and establishes shared symmetric session keys. This handshake is based on post-quantum Key Encapsulation Mechanisms (KEMs).</t>
</li>
<li><t>Data Transport Protocol: The use of the derived session keys with an AEAD cipher to encrypt, authenticate, and transport the encapsulated IP packets over UDP.</t>
</li>
</ol>
<t>PQ-SecTunnel is specified as a suite framework. Algorithm identifiers are fixed at build or deployment time for a given peer pair; there is no in-band suite negotiation in the current design. Peers MUST use identical suite parameters.</t>
<t>This revision aligns the handshake description with the project handshake specification (Noise_IKpsk1kem chaining), documents little-endian field encoding as implemented, defines Cookie reply messages and application-layer fragmentation for oversized handshake datagrams, and adopts SM4-GCM / SM3 for the recommended Chinese national cryptography profile.</t>
</section>

<section anchor="sec-2-conventions-and-terminology"><name>Conventions and Terminology</name>
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
<t>Additional terms used in this document:</t>

<ul>
<li><t>AEAD: Authenticated Encryption with Associated Data.</t>
</li>
<li><t>Initiator: The party that sends Handshake Initiation.</t>
</li>
<li><t>Responder: The peer that receives Handshake Initiation and sends Handshake Response.</t>
</li>
<li><t>Static KEM: Long-term KEM used for ct_1 and ct_3.</t>
</li>
<li><t>Ephemeral KEM: Per-handshake KEM used for E_i key generation and ct_2.</t>
</li>
<li><t>KDF: HKDF-style extract-and-expand keyed by the chaining key (Section 4.5).</t>
</li>
<li><t>shk: Shared secret produced by a KEM encapsulation/decapsulation.</t>
</li>
<li><t>sid_i / sid_r: 32-bit sender indices allocated from the peer index table.</t>
</li>
<li><t>TK_i / TK_r: Unidirectional transport keys (Initiator-to-Responder / Responder-to-Initiator).</t>
</li>
<li><t>MAC: Keyed BLAKE2s <xref target="RFC7693"/> used for mac1/mac2 DoS cookies (independent of the suite Hash).</t>
</li>
</ul>
<t>Unless otherwise stated, multi-byte integer fields in PQ-SecTunnel messages are encoded in little-endian byte order (WireGuard-compatible). This includes the message type word, sender/receiver indices, data-packet counters, and fragment header integer fields. Cryptographic octet strings (public keys, ciphertexts, MACs, AEAD outputs) are opaque sequences in the order produced by the primitive.</t>
</section>

<section anchor="sec-3-protocol-overview"><name>Protocol Overview</name>

<section anchor="sec-3-1-architecture"><name>Architecture</name>
<t>Logical components:</t>

<ul>
<li><t>Certificate / key provisioning: loads long-term KEM public keys (raw configuration or X.509).</t>
</li>
<li><t>Key agreement: three-message Noise_IKpsk1kem handshake.</t>
</li>
<li><t>Data plane: AEAD encapsulation of inner IP packets over UDP.</t>
</li>
<li><t>Virtual network interface: injects/captures plaintext IP for the host stack.</t>
</li>
<li><t>Optional application-layer fragmentation: splits oversized handshake UDP payloads.</t>
</li>
</ul>
</section>

<section anchor="sec-3-2-packet-flow"><name>Packet Flow</name>

<ol>
<li><t>An application emits an inner IP packet.</t>
</li>
<li><t>Routing directs the packet to the PQ-SecTunnel virtual interface.</t>
</li>
<li><t>The data plane looks up the peer session, assigns a counter, and AEAD-encrypts the inner packet.</t>
</li>
<li><t>The outer packet is UDP to the peer endpoint.</t>
</li>
<li><t>On receipt, the peer decrypts, anti-replay checks the counter, and injects the inner IP packet.</t>
</li>
</ol>
</section>

<section anchor="sec-3-3-threat-model"><name>Threat Model</name>
<t>The PQ-SecTunnel protocol is designed to resist the following:</t>

<ul>
<li><t>Confidentiality and integrity of tunnelled IP traffic against classical and quantum eavesdroppers (within the limits of the chosen suite).</t>
</li>
<li><t>MitM resistance given authentic pre-distributed long-term KEM public keys.</t>
</li>
<li><t>Forward secrecy for past sessions after ephemeral private key destruction.</t>
</li>
<li><t>DoS mitigation via mac1/mac2 and Cookie replies before expensive KEM operations.</t>
</li>
</ul>
<t>The protocol does not provide transport reliability. Handshake messages that exceed the path MTU MUST use application-layer fragmentation (Section 6) or otherwise ensure delivery; relying solely on IP fragmentation is NOT RECOMMENDED.</t>
</section>

<section anchor="sec-3-4-cryptographic-suites"><name>Cryptographic Suites</name>
<t>A suite is the 4-tuple (Static_KEM, Ephemeral_KEM, AEAD, Hash). Static_KEM and Ephemeral_KEM MAY differ. For ML-KEM, any combination of ML-KEM-512 and ML-KEM-768 in the two roles is permitted.</t>
<t>RECOMMENDED profile for this document: mlkem512-mlkem768-sm4gcm-sm3 (Static=ML-KEM-512, Ephemeral=ML-KEM-768, AEAD=SM4-GCM, Hash=SM3).</t>
<t>Other ML-KEM combinations with SM4-GCM/SM3 (for example mlkem512-mlkem512-sm4gcm-sm3 or mlkem768-mlkem768-sm4gcm-sm3) are OPTIONAL (MAY).</t>
<t>Aigis-enc parameter sets are envisioned as additional optional KEM choices in the same handshake framework. Normative sizes, OIDs, and interoperability requirements for Aigis-enc are left for a future revision; current implementations MAY experiment but MUST NOT claim conformance to an Aigis profile until specified.</t>
</section>
</section>

<section anchor="sec-4-key-agreement-protocol"><name>Key Agreement Protocol</name>

<section anchor="sec-4-1-handshake-overview"><name>Handshake Overview</name>
<t>Messages: Handshake Initiation (Initiator), Handshake Response (Responder), Key Confirmation (Initiator). Optional Cookie Reply (Responder) may be sent under load. After Key Confirmation verification, both sides derive TK_i and TK_r.</t>
<t>mac1/mac2 are computed over the wire encoding of each handshake message and are verified on receipt before KEM/AEAD processing. They do not enter the C/H chaining state.</t>
</section>

<section anchor="sec-4-2-pre-configuration"><name>Pre-Configuration</name>
<t>Before the handshake can be initiated, several prerequisites MUST be met:</t>
<t>1.Long-term Static KEM key pairs: Initiator (S_i^pub, S_i^priv), Responder (S_r^pub, S_r<sup>priv).</sup></t>
<t>2.Each peer MUST possess an authentic copy of the peer's long-term public key before handshake (out-of-band; certificates MAY be used, Section 8).</t>

<ol spacing="compact" start="3">
<li>Both peers MUST use the same suite parameters.</li>
</ol>
</section>

<section anchor="sec-4-3-message-formats"><name>Message Formats</name>
<t>All handshake and data messages begin with a 32-bit little-endian type field whose low 8 bits carry the message type and whose upper 24 bits MUST be zero (WireGuard-compatible packing).</t>
<t>Message types (see also Section 10):</t>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>

<tbody>
<tr>
<td>Type</td>
<td>Name</td>
</tr>

<tr>
<td>1</td>
<td>Handshake Initiation</td>
</tr>

<tr>
<td>2</td>
<td>Handshake Response</td>
</tr>

<tr>
<td>3</td>
<td>Key Confirmation</td>
</tr>

<tr>
<td>4</td>
<td>Cookie Reply</td>
</tr>

<tr>
<td>5</td>
<td>Transport Data</td>
</tr>
</tbody>
</table>
<section anchor="sec-4-3-1-handshake-initiation"><name>Handshake Initiation</name>
<t>This message is sent by the Initiator to begin the handshake.</t>
<t>message HandshakeInitiation {</t>
<t>u8 type;</t>
<t>u8 reserved_zero[3];</t>
<t>u32 sid_i;</t>
<t>u8 E_i_pub[Ne];</t>
<t>u8 ct_1[Ns_ct];</t>
<t>u8 static[HashLen+Tag];</t>
<t>u8 time[12+Tag];</t>
<t>u8 mac1[16];</t>
<t>u8 mac2[16];</t>
<t>}</t>
<t>Ne / Ns_ct depend on Ephemeral_KEM / Static_KEM. For the recommended profile: Ne = 1184 (ML-KEM-768 public key), Ns_ct = 768 (ML-KEM-512 ciphertext). HashLen = 32 (SM3). Tag = 16 (SM4-GCM).</t>
</section>

<section anchor="sec-4-3-2-handshake-response"><name>Handshake Response</name>
<t>This message is sent by the Responder after validating the Handshake Initiation message.</t>
<t>message HandshakeResponse {</t>
<t>u8 type;</t>
<t>u8 reserved_zero[3];</t>
<t>u32 sid_r;</t>
<t>u32 sid_i;</t>
<t>u8 ct_2[Ne_ct];</t>
<t>u8 ct_3[Ns_ct];</t>
<t>u8 empty[Tag];</t>
<t>u8 mac1[16];</t>
<t>u8 mac2[16];</t>
<t>}</t>
<t>For the recommended profile: Ne_ct = 1088 (ML-KEM-768 ciphertext).</t>
</section>

<section anchor="sec-4-3-3-key-confirmation"><name>Key Confirmation</name>
<t>This message is sent by the Initiator after validating the Handshake Response message.</t>
<t>message KeyConfirmation {</t>
<t>u8 type;</t>
<t>u8 reserved_zero[3];</t>
<t>u32 sid_i;</t>
<t>u32 sid_r;</t>
<t>u8 conf[Tag];</t>
<t>u8 mac1[16];</t>
<t>u8 mac2[16];</t>
<t>}</t>
</section>

<section anchor="sec-4-3-4-cookie-reply"><name>Cookie Reply</name>
<t>message CookieReply {</t>
<t>u8 type;</t>
<t>u8 reserved_zero[3];</t>
<t>u32 receiver_index;</t>
<t>u8 nonce[24];</t>
<t>u8 encrypted_cookie[16+16];</t>
<t>}</t>
<t>Cookie Reply encrypts a 16-octet cookie under XChaCha20-Poly1305. The AEAD key is derived as BLAKE2s("cookie--" || S_r^pub) with output length as required by XChaCha20-Poly1305 (32 octets). Associated data is the mac1 field of the message that triggered the reply. This construction is independent of the suite AEAD (SM4-GCM) and matches the WireGuard cookie design retained by PQ-SecTunnel.</t>
</section>
</section>

<section anchor="sec-4-4-handshake-state-machine"><name>Handshake State Machine</name>
<t>Notation follows the project handshake specification. Hash is the suite hash (SM3). KDF is HKDF-HMAC-Hash (Section 4.5). AEAD.Enc(key, nonce, plaintext, AAD) uses nonce = 12 zero octets for all handshake AEAD operations; AAD is the current transcript hash H before encryption; after encryption, H is updated as H := Hash(H || ciphertext_with_tag).</t>
<t>KEM.Enc(pk) denotes standard encapsulation producing (ct, shk). KEM.Dec(sk, ct) produces shk. For static-KEM ciphertexts ct_1 and ct_3, after obtaining shk the implementation MUST replace the value mixed into the chain with Hash(ct) (same length as the KEM shared-secret buffer used by mix_kem_ss). For ephemeral ct_2, the raw shk_2 MUST be mixed (not Hash(ct_2)).</t>

<section anchor="sec-4-4-1-handshake-initiation-initiator"><name>Handshake Initiation (Initiator)</name>

<ol>
<li><t>sid_i &lt;- allocate sender_index</t>
</li>
<li><t>C_0 = Hash(label_1)</t>
</li>
<li><t>H_0 = Hash(C_0 || label_2)</t>
</li>
<li><t>H_1 = Hash(H_0 || S_r^pub); C_1 = KDF(C_0, S_r<sup>pub)</sup></t>
</li>
<li><t>(E_i^priv, E_i^pub) = EphemeralKEM.Gen()</t>
</li>
<li><t>H_2 = Hash(H_1 || E_i^pub); C_2 = KDF(C_1, E_i<sup>pub)</sup></t>
</li>
<li><t>(ct_1, shk_1) = StaticKEM.Enc(S_r<sup>pub)</sup></t>
</li>
<li><t>H_3 = Hash(H_2 || ct_1)</t>
</li>
<li><t>ss = Hash(ct_1); (C_3, K_1) = KDF(C_2, ss)</t>
</li>
<li><t>static = AEAD.Enc(K_1, 0, Hash(S_i^pub), H_3)</t>
</li>
<li><t>H_4 = Hash(H_3 || static)</t>
</li>
<li><t>C_4 = KDF(C_3, S_i<sup>pub)</sup></t>
</li>
</ol>
<t>(C_5, Htmp, K_2) = KDF(C_4, H_4 || PSK); H_5 = Hash(H_4 || Htmp)</t>

<ol start="13">
<li><t>time = AEAD.Enc(K_2, 0, t_now, H_5)</t>
</li>
<li><t>H_6 = Hash(H_5 || time)</t>
</li>
<li><t>mac1 / mac2 as in Section 4.6</t>
</li>
<li><t>Send HandshakeInitiation</t>
</li>
</ol>
<t>label_1 is the protocol name string for the suite (RECOMMENDED example: "Noise_IKpsk1kem_SM4GCM_SM3_EphemMLKEM768"). label_2 is the identifier string (example: "PQWireGuard v2 zx2c4 Jason@zx2c4.com"). Both include the terminating NUL octet when hashed, matching the reference implementation.</t>
</section>

<section anchor="sec-4-4-2-handshake-response-responder"><name>Handshake Response (Responder)</name>

<ol>
<li><t>Verify mac1/mac2; on failure silently drop</t>
</li>
<li><t>Recompute C_0..H_6 through decryption of static and time as Initiation inverse</t>
</li>
<li><t>sid_r &lt;- allocate sender_index</t>
</li>
<li><t>(ct_2, shk_2) = EphemeralKEM.Enc(E_i<sup>pub)</sup></t>
</li>
<li><t>H_7 = Hash(H_6 || ct_2); C_6 = KDF(C_5, ct_2)</t>
</li>
<li><t>C_7 = KDF(C_6, shk_2)</t>
</li>
<li><t>(ct_3, shk_3) = StaticKEM.Enc(S_i<sup>pub)</sup></t>
</li>
<li><t>H_8 = Hash(H_7 || ct_3)</t>
</li>
<li><t>ss = Hash(ct_3); C_8 = KDF(C_7, ss)</t>
</li>
<li><t>(C_9, Htmp, K_3) = KDF(C_8, H_8 || PSK); H_9 = Hash(H_8 || Htmp)</t>
</li>
<li><t>empty = AEAD.Enc(K_3, 0, empty, H_9)</t>
</li>
<li><t>H_10 = Hash(H_9 || empty)</t>
</li>
<li><t>(C_10, K_4) = KDF(C_9, empty)</t>
</li>
<li><t>mac1/mac2; send HandshakeResponse</t>
</li>
</ol>
</section>

<section anchor="sec-4-4-3-key-confirmation-initiator"><name>Key Confirmation (Initiator)</name>

<ol>
<li><t>Verify mac1/mac2; on failure abort</t>
</li>
<li><t>shk_2 = EphemeralKEM.Dec(E_i^priv, ct_2); destroy E_i<sup>priv</sup></t>
</li>
<li><t>H_7 = Hash(H_6 || ct_2); C_6 = KDF(C_5, ct_2)</t>
</li>
<li><t>C_7 = KDF(C_6, shk_2)</t>
</li>
<li><t>shk_3 = StaticKEM.Dec(S_i^priv, ct_3)</t>
</li>
<li><t>H_8 = Hash(H_7 || ct_3)</t>
</li>
<li><t>ss = Hash(ct_3); C_8 = KDF(C_7, ss)</t>
</li>
<li><t>(C_9, Htmp, K_3) = KDF(C_8, H_8 || PSK); H_9 = Hash(H_8 || Htmp)</t>
</li>
<li><t>AEAD.Dec(K_3, 0, empty, H_9); require empty plaintext</t>
</li>
<li><t>H_10 = Hash(H_9 || empty)</t>
</li>
<li><t>(C_10, K_4) = KDF(C_9, empty)</t>
</li>
<li><t>conf = AEAD.Enc(K_4, 0, empty, H_10)</t>
</li>
<li><t>mac1/mac2; send KeyConfirmation</t>
</li>
<li><t>(TK_i, TK_r) = KDF(C_10, empty_input)</t>
</li>
</ol>
</section>

<section anchor="sec-4-4-4-key-confirmation-responder"><name>Key Confirmation (Responder)</name>

<ol>
<li><t>Verify mac1/mac2; on failure abort</t>
</li>
<li><t>AEAD.Dec(K_4, 0, conf, H_10); require empty plaintext</t>
</li>
<li><t>(TK_i, TK_r) = KDF(C_10, empty_input)</t>
</li>
</ol>
</section>
</section>

<section anchor="sec-4-5-key-derivation-and-chaining"><name>Key Derivation and Chaining</name>
<t>KDF is Hugo Krawczyk's HKDF using HMAC with the suite Hash (HMAC-SM3 for the recommended profile) <xref target="RFC5869"/>. Let CK be the chaining key. KDF(CK, input) producing n outputs means: PRK = HMAC(CK, input); then Expand with counters 0x01, 0x02, ... as in Noise/WireGuard. When this document writes (C', K) = KDF(C, ss), the first output updates the chaining key and the second is an AEAD key of AEAD-key length.</t>
<t>mix_psk(C, H, PSK) computes KDF outputs (C', Htmp, K) from input (H || PSK), then sets H' = Hash(H || Htmp). The AEAD key K is used for the subsequent encrypted field (time or empty).</t>
<t>Table 1: Informative chaining summary (Initiation through transport keys)</t>
<table>
<thead>
<tr>
<th />
<th />
<th />
</tr>
</thead>

<tbody>
<tr>
<td>Step</td>
<td>Hash update</td>
<td>Chain-key update</td>
</tr>

<tr>
<td>0</td>
<td>H_0 = Hash(C_0 || label_2)</td>
<td>C_0 = Hash(label_1)</td>
</tr>

<tr>
<td>1</td>
<td>H_1 = Hash(H_0 || S_r<sup>pub)</sup></td>
<td>C_1 = KDF(C_0, S_r<sup>pub)</sup></td>
</tr>

<tr>
<td>2</td>
<td>H_2 = Hash(H_1 || E_i<sup>pub)</sup></td>
<td>C_2 = KDF(C_1, E_i<sup>pub)</sup></td>
</tr>

<tr>
<td>3</td>
<td>H_3 = Hash(H_2 || ct_1)</td>
<td>(C_3,K_1)=KDF(C_2, Hash(ct_1))</td>
</tr>

<tr>
<td>4</td>
<td>H_4 = Hash(H_3 || static)</td>
<td>C_4 = KDF(C_3, S_i^pub); then mix_psk -&gt; C_5,H_5,K_2</td>
</tr>

<tr>
<td>5</td>
<td>H_6 = Hash(H_5 || time)</td>
<td>(after time AEAD)</td>
</tr>

<tr>
<td>6</td>
<td>H_7 = Hash(H_6 || ct_2)</td>
<td>C_6 = KDF(C_5, ct_2); C_7 = KDF(C_6, shk_2)</td>
</tr>

<tr>
<td>7</td>
<td>H_8 = Hash(H_7 || ct_3)</td>
<td>C_8 = KDF(C_7, Hash(ct_3)); mix_psk -&gt; C_9,H_9,K_3</td>
</tr>

<tr>
<td>8</td>
<td>H_10 = Hash(H_9 || empty)</td>
<td>(C_10,K_4)=KDF(C_9, empty)</td>
</tr>

<tr>
<td>9</td>
<td>(transport)</td>
<td>(TK_i,TK_r)=KDF(C_10, "")</td>
</tr>
</tbody>
</table></section>

<section anchor="sec-4-6-mac1-mac2-and-cookie-messages"><name>MAC1/MAC2 and Cookie Messages</name>
<t>Let MsgPrefix be the message bytes excluding mac1 and mac2. Keys:</t>
<t>mac1_key = BLAKE2s("mac1----" || S_r<sup>pub)</sup></t>
<t>mac1 = BLAKE2s(key=mac1_key, data=MsgPrefix)[0:16]</t>
<t>if Cookie available:</t>
<t>mac2 = BLAKE2s(key=Cookie, data=MsgPrefix||mac1)[0:16]</t>
<t>else:</t>
<t>mac2 = 16 zero octets</t>
<t>Under load, a Responder MAY ignore KEM processing and send Cookie Reply (Section 4.3.4). The Initiator decrypts the cookie and includes mac2 on retry. Receivers MUST verify mac1 (and mac2 when required) before expensive KEM work.</t>
</section>

<section anchor="sec-4-7-implicit-authentication-model"><name>Implicit Authentication Model</name>
<t>The Initiator proves knowledge bound to S_i by producing static = AEAD(Hash(S_i^pub)) under a key derived from ct_1 encapsulated to S_r. The Responder proves possession of S_r^priv by decapsulating ct_1 and later producing ct_3 to S_i^pub. Successful completion binds both long-term identities into TK_i/TK_r without transcript signatures.</t>
</section>
</section>

<section anchor="sec-5-data-transport-protocol"><name>Data Transport Protocol</name>

<section anchor="sec-5-1-packet-format"><name>Packet Format</name>
<t>message TransportData {</t>
<t>u8 type;</t>
<t>u8 reserved_zero[3];</t>
<t>u32 key_idx;</t>
<t>u64 counter;</t>
<t>u8 ciphertext[];</t>
<t>}</t>
<t>On the wire the UDP payload is exactly this structure. The outer UDP/IP headers are ordinary Internet headers toward the peer endpoint.</t>
</section>

<section anchor="sec-5-2-packet-encryption"><name>Packet Encryption</name>
<t>When the virtual network interface captures a plaintext IP packet (Inner IP Packet) for transmission:</t>

<ol>
<li><t>Select the sending key (TK_i on Initiator, TK_r on Responder) and remote key_idx.</t>
</li>
<li><t>Let counter be the next 64-bit sending counter (MUST NOT reuse under the same key).</t>
</li>
<li><t>For SM4-GCM: form a 12-octet IV as four zero octets followed by the eight little-endian octets of counter (IV bytes 4..11).</t>
</li>
<li><t>Encrypt with AEAD key = transport key, nonce/IV as above, plaintext = inner IP packet, AAD length = 0 (empty AAD).</t>
</li>
<li><t>Emit TransportData with ciphertext||tag.</t>
</li>
</ol>
</section>

<section anchor="sec-5-3-packet-decryption"><name>Packet Decryption</name>

<ol>
<li><t>Parse type/key_idx/counter; look up receiving key.</t>
</li>
<li><t>Anti-replay: maintain a sliding window; silently drop duplicates or out-of-window counters.</t>
</li>
<li><t>AEAD-decrypt with empty AAD; on failure silently drop.</t>
</li>
<li><t>Inject recovered inner IP packet into the local stack.</t>
</li>
</ol>
</section>
</section>

<section anchor="sec-6-application-layer-fragmentation"><name>Application-Layer Fragmentation</name>
<t>When a handshake message (after mac1/mac2 are attached) exceeds the maximum fragment payload size, implementations MUST fragment at the application layer rather than relying on IP fragmentation.</t>
<t>Fragment header (8 octets, little-endian where noted):</t>
<t>struct PqcFragHdr {</t>
<t>u16 magic;</t>
<t>u16 msg_id;</t>
<t>u8 frag_index;</t>
<t>u8 frag_total;</t>
<t>u16 frag_len;</t>
<t>};</t>
<t>The magic field MUST be 0x5051 (ASCII "PQ"), encoded little-endian. msg_id is a random reassembly identifier. frag_index is zero-based; frag_total is the number of fragments; frag_len is the number of payload octets in this fragment.</t>
<t>Maximum fragment payload size is 1400 octets. The receiver reassembles fragments sharing (endpoint, msg_id) and passes the completed handshake buffer to the normal handshake parser (without the fragment header).</t>
<t>Control encoding: frag_total = 0xFF and frag_index = 0xFF denotes a fragment ACK used by the sender for retransmission. Implementations SHOULD retransmit unacknowledged fragments with bounded retries.</t>
<t>Fragmentation MUST be applied after mac1/mac2 computation so that MACs cover the original handshake message. Receivers MUST accept fragmented handshake messages for suites whose initiation or response exceeds typical path MTU (including the recommended mlkem512-mlkem768-sm4gcm-sm3 profile).</t>
</section>

<section anchor="sec-7-cryptographic-algorithms"><name>Cryptographic Algorithms</name>

<section anchor="sec-7-1-asymmetric-algorithms"><name>Asymmetric Algorithms</name>
<t>Implementations of this specification's ML-KEM profiles MUST implement ML-KEM as specified in <xref target="FIPS203"/>. Support for both ML-KEM-512 and ML-KEM-768 as Static_KEM and as Ephemeral_KEM is RECOMMENDED so that operators MAY choose any pairing. The profile mlkem512-mlkem768-sm4gcm-sm3 is RECOMMENDED.</t>
<t>Digital signatures for out-of-band X.509 certificates: implementations that use the certificate path MUST support a quantum-resistant signature algorithm such as ML-DSA <xref target="FIPS204"/>. Tunnel handshake authentication itself does not use signatures.</t>
<t>Aigis-enc MAY appear in experimental builds as Static_KEM and/or Ephemeral_KEM using the same message layout and chaining rules; interoperable Aigis profiles are not yet normatively defined here.</t>
</section>

<section anchor="sec-7-2-symmetric-algorithms"><name>Symmetric Algorithms</name>
<t>For the recommended profile, AEAD MUST be SM4-GCM with 128-bit keys, 128-bit authentication tags, and 96-bit nonces, following the GCM construction as used with SM4 in national standards practice (see <xref target="GBT32907"/> for SM4; GCM as referenced by related TLCP guidance <xref target="GB38636"/>).</t>
<t>Handshake AEAD nonce is 12 zero octets. Transport AEAD nonce/IV construction is defined in Section 5.2. Handshake AAD is the current transcript hash; transport AAD is empty.</t>
</section>

<section anchor="sec-7-3-hash-kdf-and-dos-mac"><name>Hash, KDF, and DoS MAC</name>
<t>Suite Hash for the recommended profile MUST be SM3 <xref target="GBT32905"/>. KDF is HKDF with HMAC-SM3 <xref target="RFC5869"/>.</t>
<t>mac1/mac2 and cookie key derivation use keyed BLAKE2s <xref target="RFC7693"/> as in Section 4.6, even when the suite Hash is SM3. This separation follows the WireGuard DoS design retained by PQ-SecTunnel and is independent of the C/H hash chain.</t>
</section>
</section>

<section anchor="sec-8-certificate-management"><name>Certificate Management</name>

<section anchor="sec-8-1-certificate-format"><name>Certificate Format</name>
<t>When certificates are used to distribute long-term KEM public keys, they MUST be X.509 v3 certificates.</t>
</section>

<section anchor="sec-8-2-public-key-information"><name>Public Key Information</name>
<t>The SubjectPublicKeyInfo field MUST carry the long-term PQC KEM public key. The AlgorithmIdentifier OID MUST identify the KEM algorithm (Appendix A).</t>
</section>

<section anchor="sec-8-3-oid-mapping"><name>OID Mapping</name>
<t>Implementations MUST map SubjectPublicKeyInfo OIDs to the corresponding KEM implementation. Informative OID values under the Chinese national arc appear in Appendix A.</t>
</section>

<section anchor="sec-8-4-certificate-validation"><name>Certificate Validation</name>
<t>Certificates MUST be distributed and validated out-of-band before handshake when the certificate path is used. Implementations MUST validate the signature chain against a configured trust anchor, check validity periods, and ensure the peer identity matches local policy. Raw public-key configuration without certificates remains permitted.</t>
</section>
</section>

<section anchor="sec-9-security-considerations"><name>Security Considerations</name>

<section anchor="sec-9-1-quantum-resistance"><name>Quantum Resistance</name>
<t>Asymmetric handshake secrets are established with ML-KEM <xref target="FIPS203"/>. Symmetric security for the recommended profile uses SM4-128 and SM3-256. Operators needing higher classical margins MAY select ML-KEM-768 for both roles.</t>
</section>

<section anchor="sec-9-2-authentication-and-key-pre-distribution"><name>Authentication and Key Pre-Distribution</name>
<t>Implicit authentication requires authentic pre-distribution of long-term KEM public keys. Compromise or substitution of the preloaded peer public key enables MitM.</t>
</section>

<section anchor="sec-9-3-forward-secrecy"><name>Forward Secrecy</name>
<t>Session keys depend on shk_2 bound to the ephemeral private key E_i^priv, which MUST be destroyed after processing Handshake Response. Compromise of both long-term static private keys after the fact does not recover past TK_i/TK_r if E_i^priv was erased and the ephemeral KEM remains unbroken.</t>
</section>

<section anchor="sec-9-4-replay-and-mitm-protection"><name>Replay and MitM Protection</name>
<t>Handshake: the encrypted timestamp and transcript hash chain bind messages. Transport: the 64-bit counter with sliding-window anti-replay MUST be enforced.</t>
</section>

<section anchor="sec-9-5-denial-of-service-considerations"><name>Denial-of-Service Considerations</name>
<t>mac1 provides a cheap filter keyed by the Responder public key. Under load, Cookie Reply enables mac2 checks before KEM decapsulation.</t>
</section>

<section anchor="sec-9-6-static-kem-hash-ct-mixing"><name>Static KEM Hash(ct) Mixing</name>
<t>Mixing Hash(ct_1)/Hash(ct_3) instead of the raw static KEM shared secret is the current protocol rule and must be implemented for interoperability. It differs from the raw-shk rule used for ct_2. Changing this rule would be a breaking revision.</t>
</section>
</section>

<section anchor="sec-10-iana-considerations"><name>IANA Considerations</name>

<section anchor="sec-10-1-service-name-and-transport-protocol-port-number-registry"><name>Service Name and Transport Protocol Port Number Registry</name>
<t>IANA is requested to register PQ-SecTunnel in the "Service Name and Transport Protocol Port Number Registry".</t>

<ul>
<li><t>Service Name: pq-sectunnel</t>
</li>
<li><t>Transport Protocol: UDP</t>
</li>
<li><t>Port Number: TBD</t>
</li>
</ul>
</section>

<section anchor="sec-10-2-pq-sectunnel-message-types-registry"><name>PQ-SecTunnel Message Types Registry</name>
<t>IANA is requested to create a registry "PQ-SecTunnel Message Types" with Specification Required registration policy. Initial values:</t>
<table>
<thead>
<tr>
<th />
<th />
<th />
</tr>
</thead>

<tbody>
<tr>
<td>Value</td>
<td>Description</td>
<td>Reference</td>
</tr>

<tr>
<td>0</td>
<td>Invalid / reserved</td>
<td>this document</td>
</tr>

<tr>
<td>1</td>
<td>Handshake Initiation</td>
<td>this document</td>
</tr>

<tr>
<td>2</td>
<td>Handshake Response</td>
<td>this document</td>
</tr>

<tr>
<td>3</td>
<td>Key Confirmation</td>
<td>this document</td>
</tr>

<tr>
<td>4</td>
<td>Cookie Reply</td>
<td>this document</td>
</tr>

<tr>
<td>5</td>
<td>Transport Data</td>
<td>this document</td>
</tr>
</tbody>
</table></section>

<section anchor="sec-10-3-oid-registrations"><name>OID Registrations</name>
<t>OIDs under 1.2.156 used in Appendix A are outside IANA; no IANA action is requested.</t>
</section>
</section>

</middle>

<back>

<references anchor="sec-11-references"><name>References</name>

<references anchor="sec-11-1-normative-references"><name>Normative References</name>
<reference anchor="RFC2119">
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials="S." surname="Bradner" fullname="Scott Bradner"><organization /></author>
<date year="1997" month="March" />
</front>
<seriesInfo name="BCP" value="14" />
<seriesInfo name="RFC" value="2119" />

</reference>
<reference anchor="RFC8174">
<front>
<title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
<author initials="B." surname="Leiba" fullname="Barry Leiba"><organization /></author>
<date year="2017" month="May" />
</front>
<seriesInfo name="BCP" value="14" />
<seriesInfo name="RFC" value="8174" />

</reference>
<reference anchor="RFC5869">
<front>
<title>HMAC-based Extract-and-Expand Key Derivation Function (HKDF)</title>
<author initials="H." surname="Krawczyk" fullname="Hugo Krawczyk"><organization /></author>
<author initials="P." surname="Eronen" fullname="Patrik Eronen"><organization /></author>
<date year="2010" month="May" />
</front>
<seriesInfo name="RFC" value="5869" />

</reference>
<reference anchor="RFC7693">
<front>
<title>The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)</title>
<author initials="M.-J." surname="Saarinen" fullname="Markku-Juhani Saarinen" role="editor"><organization /></author>
<author initials="J.-P." surname="Aumasson" fullname="Jean-Philippe Aumasson"><organization /></author>
<date year="2015" month="November" />
</front>
<seriesInfo name="RFC" value="7693" />

</reference>
<reference anchor="FIPS203">
<front>
<title>Module-Lattice-Based Key-Encapsulation Mechanism Standard</title>
<author><organization>National Institute of Standards and Technology</organization></author>
<date year="2024" month="August" />
</front>
<seriesInfo name="FIPS" value="203" />

</reference>
<reference anchor="FIPS204">
<front>
<title>Module-Lattice-Based Digital Signature Standard</title>
<author><organization>National Institute of Standards and Technology</organization></author>
<date year="2024" month="August" />
</front>
<seriesInfo name="FIPS" value="204" />

</reference>
<reference anchor="GBT32905">
<front>
<title>Information security technology - SM3 cryptographic hash algorithm</title>
<author><organization>Standardization Administration of China (SAC)</organization></author>
<date year="2016" />
</front>
<seriesInfo name="GB/T" value="32905" />

</reference>
<reference anchor="GBT32907">
<front>
<title>Information security technology - SM4 block cipher algorithm</title>
<author><organization>Standardization Administration of China (SAC)</organization></author>
<date year="2016" />
</front>
<seriesInfo name="GB/T" value="32907" />

</reference>
<reference anchor="GB38636">
<front>
<title>Information security technology - Transport Layer Cryptography Protocol (TLCP)</title>
<author><organization>Standardization Administration of China (SAC)</organization></author>
<date year="2020" />
</front>
<seriesInfo name="GB/T" value="38636" />

</reference>
</references>

<references anchor="sec-11-2-informative-references"><name>Informative References</name>
<reference anchor="WIREGUARD">
<front>
<title>WireGuard: Next Generation Kernel Network Tunnel</title>
<author initials="J.A." surname="Donenfeld" fullname="Jason A. Donenfeld"><organization /></author>
<date year="2017" />
</front>
<seriesInfo name="NDSS" value="2017" />

</reference>
</references>
</references>

<section anchor="appendix-a-oid-definitions"><name>OID Definitions</name>
<t>Informative Object Identifiers under the Chinese national registration arc, as used by related certificate tooling. Only OIDs required by a deployment need be recognized.</t>
<t>Table 2: PQC and GM/T OID Definitions</t>
<table>
<thead>
<tr>
<th />
<th />
<th />
</tr>
</thead>

<tbody>
<tr>
<td>Object Identifier (OID)</td>
<td>Object Identifier Definition</td>
<td>备注</td>
</tr>

<tr>
<td>General Object Identifiers</td>
<td />
<td />
</tr>

<tr>
<td>1.2</td>
<td>International Organization for Standardization (ISO) Member Identifier</td>
<td />
</tr>

<tr>
<td>1.2.156</td>
<td>China</td>
<td />
</tr>

<tr>
<td>1.2.156.197</td>
<td>State Cryptography Administration (SCA)</td>
<td />
</tr>

<tr>
<td>1.2.156.10197</td>
<td>Cryptography Industry Standardization Technical Committee</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1</td>
<td>Cryptographic Algorithms</td>
<td />
</tr>

<tr>
<td>Block Cipher Algorithm Object Identifiers</td>
<td />
<td />
</tr>

<tr>
<td>1.2.156.10197.1.100</td>
<td>Block Cipher Algorithms</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.102</td>
<td>SM1 Block Cipher Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.103</td>
<td>SSF33 Block Cipher Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.104</td>
<td>SM4 Block Cipher Algorithm</td>
<td />
</tr>

<tr>
<td>Stream Cipher Algorithm Object Identifiers</td>
<td />
<td />
</tr>

<tr>
<td>1.2.156.10197.1.200</td>
<td>Stream Cipher Algorithms</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.201</td>
<td>Zuchongzhi Stream Cipher Algorithm</td>
<td />
</tr>

<tr>
<td>Public Key Cryptographic Algorithm Object Identifiers</td>
<td />
<td />
</tr>

<tr>
<td>1.2.156.10197.1.300</td>
<td>Public Key Cryptographic Algorithms</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.301</td>
<td>SM2 Elliptic Curve Public Key Cryptographic Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.301.1</td>
<td>SM2-1 Digital Signature Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.301.2</td>
<td>SM2-2 Key Exchange Protocol</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.301.3</td>
<td>SM2-3 Public Key Encryption Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.302</td>
<td>SM9 Identity-Based Cryptographic Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.302.1</td>
<td>SM9-1 Digital Signature Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.302.2</td>
<td>SM9-2 Key Exchange Protocol</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.302.3</td>
<td>SM9-3 Key Encapsulation Mechanism and Public Key Encryption Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.303</td>
<td>Post-Quantum Key Encapsulation Algorithms</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.303.1</td>
<td>ML-KEM-512 Key Encapsulation Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.303.2</td>
<td>ML-KEM-768 Key Encapsulation Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.303.3</td>
<td>ML-KEM-1024 Key Encapsulation Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.304</td>
<td>Post-Quantum Digital Signature Algorithms</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.304.1</td>
<td>ML-DSA-44 Digital Signature Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.304.2</td>
<td>ML-DSA-65 Digital Signature Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.304.3</td>
<td>ML-DSA-87 Digital Signature Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>Hash Algorithm Object Identifiers</td>
<td />
<td />
</tr>

<tr>
<td>1.2.156.10197.1.400</td>
<td>Hash Algorithms</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.401</td>
<td>SM3 Cryptographic Hash Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.401.1</td>
<td>SM3 Cryptographic Hash Algorithm (No Key Used)</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.401.2</td>
<td>SM3 Cryptographic Hash Algorithm (Key Used)</td>
<td />
</tr>

<tr>
<td>Combined Operation Algorithm Object Identifiers</td>
<td />
<td />
</tr>

<tr>
<td>1.2.156.10197.1.500</td>
<td>Combined Operation Mechanisms</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.501</td>
<td>Signature Based on SM2 Algorithm and SM3 Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.504</td>
<td>Signature Based on RSA Algorithm and SM3 Algorithm</td>
<td />
</tr>

<tr>
<td>1.2.156.10197.1.505</td>
<td>Signature Based on ML-DSA Algorithm and SM3 Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.505.1</td>
<td>ML-DSA-44-with-SM3</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.505.2</td>
<td>ML-DSA-65-with-SM3</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.505.3</td>
<td>ML-DSA-87-with-SM3</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.506</td>
<td>Signature Based on SM2, ML-DSA Algorithms and SM3 Algorithm</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.506.1</td>
<td>ML-DSA-44-SM2-with-SM3</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.506.2</td>
<td>ML-DSA-65-SM2-with-SM3</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.506.3</td>
<td>ML-DSA-87-SM2-with-SM3</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.507</td>
<td>Based on SM2 and ML-KEM Algorithms</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.507.1</td>
<td>ML-KEM-512-SM2</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.507.2</td>
<td>ML-KEM-768-SM2</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.507.3</td>
<td>ML-KEM-1024-SM2</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.508</td>
<td>Based on SM2 and ML-DSA Algorithms</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.508.1</td>
<td>ML-DSA-44-SM2</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.508.2</td>
<td>ML-DSA-65-SM2</td>
<td>Post-Quantum</td>
</tr>

<tr>
<td>1.2.156.10197.1.508.3</td>
<td>ML-DSA-87-SM2</td>
<td>Post-Quantum</td>
</tr>
</tbody>
</table>
</section>

<section anchor="acknowledgments" numbered="false"><name>Acknowledgments</name>
<t>The authors thank contributors to the PQ-SecTunnel implementation and reviewers of earlier drafts. The handshake design builds on the Noise protocol framework and the WireGuard construction <xref target="WIREGUARD"/>.
Aigis-enc (and related lattice KEMs developed in the Chinese research community) are acknowledged as candidate additional KEM modules for the same tunnel framework; detailed Aigis profiles are deferred until implementation and interoperability work is complete. The designers of Kyber/ML-KEM and Dilithium/ML-DSA are likewise acknowledged.</t>
</section>

</back>

</rfc>