* chore: download latest official mihomo for interop tests * test: capture N0 baseline and protocol feasibility probes * docs: record N0 hybrid REALITY fork verification * test: verify N0 controlled Hysteria2 auth and streams Add an isolated Quinn adapter over existing DIRECT and SOCKS5 datagrams, bounded queues, protect rejection probes, and official latest peer fixtures. Record passing auth/TCP checks and the native Hysteria half-close failure separately. N0 remains incomplete; production sources and dependency locks are unchanged. * test: validate N0 native QUIC hopping and XHTTP H3 Keep the probes isolated from production. Verify one-state Hysteria hopping, protected rebind rejection, Xray H3 entry and existing HY2 regressions. Set only the owned Linux peer MTU to avoid Initial-packet EMSGSIZE; retain native half-close failures as separate gates. * fix: align XHTTP shutdown with Mihomo connection close * test: verify N0 supplied-stream transport interfaces Add isolated TLS, ordinary WebSocket and gRPC probes with owned I/O, bounded buffers and cancellation barriers. Match Mihomo close behavior: preserve TLS/WS reads, distinguish clean WS underlay EOF from truncation, and close both gRPC directions. Use separate official SOCKS5 peers to avoid fixture loop detection. Record 12 Debug/Release tests, 42 official Mihomo checks, dependency audits and Apple/Android compile checks. Keep production dependencies, third-party sources and remaining N0 gates unchanged. * fix: upgrade h2 and retain completed responses after reset * chore: use the current OneXray rustls fork origin * chore: adopt published rustls 0.23.45 and official TLS binding * chore: refresh N1 foundation and spike dependencies * feat: validate next-protocol field and combination catalogs * feat: share immutable TLS policies and bounded close semantics * feat: add shared stream transports and decouple XUDP framing * feat: add controlled datagram foundations and N1 acceptance harness * chore: finalize N1 with verified x25519 dependency * chore: publish N1 against the rustls release branch * feat: add bounded Trojan request and datagram codecs * feat: connect Trojan TLS TCP and UDP through the runtime * feat: support Trojan WebSocket and duplex gRPC transports * feat: enable Trojan and complete N2 consumer acceptance * feat(vmess): add bounded AEAD header and body codecs * fix(vmess): align close acceptance with Mihomo transports * feat(vmess): add UDP codecs and isolated peer comparisons * feat(vmess): complete public runtime and N3 acceptance * docs: bind N3 acceptance and refresh validation guidance * feat(vless): complete N4 transports, Vision and UDP support Extract VLESS assembly, add plain/TLS stream transports, HTTPUpgrade, node-owned gRPC pooling, mTLS and classic REALITY, and implement Vision through public TLS record boundaries. Preserve XHTTP and the XUDP default while adding raw and packetaddr. Complete 145 required groups and 39 field rows against isolated latest official peers, with 160 lifecycle/resource rounds, independent coverage and Apple/Android release builds. Preserve the three explicit WS/REALITY layered close comparisons and historical failures in the acceptance report. No third-party or dependency-lock changes. * feat(vless): complete N5 XHTTP and sing-mux support Add H1/H2/H3 request fields, independent download security and pools, bounded packet-up batching, and h2mux/smux/yamux over controlled transports. Keep Mihomo-aligned close and path semantics, node-owned shutdown barriers, and isolated official-peer fixtures including the approved Caddy mTLS gateway. Validate 416 required groups, 57 fields, 112 two-leg security checks, 240 lifecycle/resource cycles, independent coverage, and Apple/Android release builds. Record native-peer gaps and leave N6-N10, devices, CI, and release gates separate. * feat: integrate boring TLS profiles and retire rustls fork * test(tls): freeze selected fingerprint reference baseline * docs(tls): record selected-profile library acceptance * feat(tls): integrate selected client fingerprints and REALITY profiles * feat(tls): complete selected fingerprint CF5 acceptance * feat(hysteria2): complete N6 client support and acceptance Implement Hysteria2 over official Quinn/h3/rustls and shared controlled IO, including TCP/UDP, bandwidth pacing, Salamander, port hopping, upstream snapshots and synchronous Stop. Keep old-path receives active for the full bounded handover window, preserve independent reader wakeups, and require the exact nested TCP evidence assertions. Validate one frozen N6 run: 36 required groups, 20 field rows, native Mihomo/Hysteria peers, H3 regression, 40 lifecycle rounds and Apple/Android production builds. Record independent coverage, artifact hashes and native-peer limitations. * test(tls): record N7 hybrid REALITY prerequisite evidence Preserve the locked classic-only API failure and distinguish the locally accepted boring hybrid extension from pending VCore S03/D16 integration. Record wrapper feasibility and publication boundaries without changing production configuration or dependencies. * feat(vless): support explicitly required hybrid REALITY * feat(crypto): wrap official BLAKE3 binary-context derivation * feat(vless): implement authenticated Encryption wire transport * feat(vless): enable authenticated Encryption across public transports * build(tls): pin the authenticated ShadowTLS ClientHello hook * feat(vless): add authenticated JLS transport security Pin the separately approved boring JLS revision and expose strict main/download credentials under schema 24. Preserve native CertificateVerify and Finished, cancellation, and controlled IO ownership. Accept the JLS field slice with 122 isolated cases, 80 lifecycle/resource cycles, and Apple/Android release libraries; keep broader N7 gates separate. * docs(n7): reconcile current JLS acceptance progress * chore(vless): retire Restls while retaining JLS * feat(vless): complete N7 static ECH and security combinations Add static ECH for VLESS main and XHTTP download legs using existing TLS backends and official Rust HPKE. Keep Invoke v5 and advance the internal schema to revision 27. Accept the narrowed N7 scope with 43 required groups, 11 fields, 301 isolated native cases, 240 lifecycle/resource rounds, and Apple/Android release builds. Record frozen inputs, 470 container cleanups, explicit upstream comparison gaps, and prior failed runs in docs/acceptance/next-protocols/N7.md. * chore(protocols): retire WireGuard scope and foundations * test: complete N9 protocol integration and resource gates * build: add N10 production artifact evidence gates * fix: restore Windows snapshot encoding and fail-closed delivery CI * fix: use native ARM64 LLVM assembly and scoped delivery CI * build: keep delivery lockfile bytes stable across platforms * fix: preserve production guard lifecycle and isolate CI feature checks * build: adopt released boring and registry shadowsocks * ci: use release-oriented workflow names * docs: consolidate contracts and streamline test tooling Merge current protocol and platform contracts, remove milestone reports and obsolete spikes, and share core checks between local development and CI. Preserve all 884 executable case definitions and unique legacy assertions. Validation: core Debug/Release, feature checks, Clippy, netstack, offline script tests, formatting and documentation links passed locally. Container interop smoke attempts failed during official peer downloads; business paths remain NOT RUN. * test: replace milestone names with capability-based validation Rename protocol and fingerprint suites, fixtures, and evidence identifiers by capability. Preserve acceptance cases and golden wire data while documenting reference, wire, and interoperability evidence separately. * fix: address review findings and stabilize core CI Flush accepted gRPC/H2 data through the supplied IO before reset, and wait for pending smux writes before FIN. Sanitize AnyTLS peer failures, reject XHTTP userinfo, and remove stale Android delivery artifacts. Close container log capture even when inventory fails. Keep legacy host suites blocked before resource acquisition. Separate Shadowsocks adapter codec checks from upstream strict server acceptance. Lock the random empty-request zero-padding failure with deterministic negative and positive fixtures, without changing the dependency or production behavior. * test: isolate delivery fixture from Windows home lookup * test: preserve UDP socket semantics during peer teardown The memory peer treated its counterpart closing an mpsc channel as a local UDP BrokenPipe. That could terminate Quinn endpoint IO without waking a pending wait_idle, despite all four datagrams and CONNECTION_CLOSE having arrived. Keep a closed peer link silent and late sends best-effort, add a deterministic fixture regression, and preserve the existing data and shutdown deadlines. Debug/Release, Clippy, and 300 consecutive regression iterations pass. * fix: drain XHTTP uploads before releasing connection drivers * fix: enforce lazy setup deadlines and safe delivery paths Check the original deadline before accepting ready gRPC/H2 headers or sing-mux status, without limiting established reads. Reject symlinks and Windows reparse points in every delivery output path before filesystem mutations. Add deterministic memory and temporary-filesystem regressions. * test: join XHTTP H3 peer tasks during cleanup Quinn retains closed connections for three probe timeouts, so a delayed handshake can legitimately exceed the fixture's two-second wait_idle budget. Own, abort, and join the passive peer tasks after upload and client shutdown instead. Preserve upload integrity and client close bounds, and cover delayed handshakes in both streaming modes.
5.7 KiB
REALITY V1 客户端协议
本文定义 VCore 的 REALITY V1 客户端线上行为。它不是通用 REALITY 规范。经典模式为默认,配置修订版 22 可显式要求混合密钥交换。可选的四套 ClientHello 模板及混合兼容边界见 TLS 指纹。
版本边界
当前 REALITY 实现基于自有 boring 5.2.0 fork 的原生 BoringSSL 扩展。线上行为由本文和 fork 内的确定性测试向量共同约束。升级 TLS 后端、加密提供方或握手字节时,必须重新验证普通 TLS、REALITY、并发、取消和目标平台构建。
V1 只支持:
- 客户端模式;
- TLS 1.3;
- 经典 X25519,或显式要求 X25519MLKEM768 的 TLS 密钥交换;
- classic Ed25519 临时证书认证;
- 0–8 字节 short ID,在线上右侧补零到 8 字节;
- BoringSSL 原生握手和加密实现。
不支持 REALITY 服务端、TLS 1.2 协商、QUIC 传输、实际 ECH、HelloRetryRequest、会话恢复、0-RTT 或 fp。ECH GREASE 与实际 ECH 不同。收到 HRR 或 REALITY 认证失败时立即终止,不降级为普通 WebPKI。
ClientHello 认证
每次 REALITY 认证绑定本次原生 SSL 握手中的一份真实 X25519 临时私钥,同时用于:
- TLS 1.3 ClientHello 的实际 X25519 share,或混合 share 中的 X25519 分量;
- 与配置中的服务端静态 X25519 公钥执行 ECDH。
VCore 不能读取该私钥,也不能为两个用途生成不同密钥。
原生封装按实际 GroupID 找到唯一 X25519 share,不依赖 share 下标。Firefox 可保留 额外 P-256 share,但认证始终绑定同一 X25519 临时私钥。Chrome133 的普通 TLS ML-KEM group/share 在 classic REALITY 中裁剪。显式混合模式保留模板中的真实混合 share; 无命名指纹时只提供混合 share。若同时存在独立 X25519,优先用它派生认证,否则使用 实际混合 share 内的 X25519 分量,与 Mihomo 的认证取值一致。 重复/缺失认证 share、低阶点均失败。显式混合模式还在 ServerHello 处理时要求 实际选择 group 4588,经典组或 HRR 立即失败,不重新发起经典握手。REALITY 身份 认证仍是经典 X25519/Ed25519,不能将混合 TLS 密钥交换称为后量子身份认证。
ClientHello 的 legacy session ID 固定为 32 字节。生成密文前先把该字段清零,再编码完整 TLS Handshake ClientHello,将其作为 AES-GCM 的 AAD。
signature_algorithms 保留所选模板的列表;REALITY 不强行加入 Ed25519。原生实现仅在临时证书先通过 REALITY HMAC 认证后,允许它的 Ed25519 CertificateVerify,并仍验证签名。该局部例外不放宽普通 TLS 的签名算法检查。
命名指纹保留 TLS1.2 的版本/cipher/扩展声明(Safari 的 TLS1.0/1.1 仍裁剪), 而非先用 TLS1.3-only 的通用编码过滤模板。原生 REALITY 在 ServerHello 阶段独立拒绝 TLS1.2,且仍禁止恢复、0-RTT 和普通证书兜底;声明并不代表允许降级协商。
session ID 明文前 16 字节为:
offset size value
0 3 客户端版本,当前为 26.7.11
3 1 保留字节 0
4 4 Unix 秒,uint32 大端序
8 8 short ID,右侧补零
密钥派生:
auth_secret = X25519(client_ephemeral_private, server_static_public)
auth_key = HKDF-SHA256(auth_secret,
salt=client_random[0..20],
info="REALITY",
length=32)
nonce = client_random[20..32]
session_id = AES-256-GCM-Seal(auth_key, nonce,
plaintext[0..16],
aad=zero-session-id ClientHello)
输出为 16 字节密文和 16 字节 GCM tag。低阶点、全零共享密钥、时钟失败、重复封装或缺少连接状态都会使握手失败。
服务端证书认证
服务端必须只发送一张 DER X.509 证书。解析输入上限为 16 KiB,只接受规范的 definite-length DER、RFC 5280 字段顺序、无参数 Ed25519 AlgorithmIdentifier、32 字节 SPKI 公钥和 64 字节外层签名。
验证顺序:
- 从 DER 结构读取 Ed25519 公钥和外层
signatureValue; - 常数时间比较
signatureValue与HMAC-SHA512(auth_key, ed25519_public_key); - 把通过 HMAC 的同一公钥绑定到当前连接;
- 使用该公钥验证 TLS 1.3
CertificateVerify,签名算法必须为 Ed25519; - 无论成功或失败都立即消费认证状态,禁止再次使用。
真实站点证书、中间证书、错误 HMAC、错误 DER/SPKI、错误 CertificateVerify 和缺失状态全部失败。VCore 不提供 WebPKI 或 spider fallback。
状态与资源
共享连接器只保存不可变的服务端公钥、short ID、客户端版本和模板策略。临时私钥、ECDH 结果、auth_key 和已认证公钥只存在于单个连接中,不使用全局表、跨连接锁或共享认证槽位。
连接取消、失败或释放时清零临时私钥、共享密钥和 auth_key。证书解析深度和输入大小固定,不依据对端长度创建无界容器。fork 不创建线程、异步任务、连接池或队列。
固定向量
boring fork 的测试固定:
- RFC 7748 X25519 私钥、公钥和共享密钥;
- 清零 session ID 的 ClientHello AAD、HKDF 结果和 32 字节 REALITY session ID;
- Ed25519 SPKI、证书 HMAC 和 TLS 1.3
CertificateVerify; - 截断或非规范 DER、错误 HMAC、错误签名、缺失状态、低阶公钥和 HRR 负例;
- 多配置并发和连接状态隔离。
VCore 的互操作测试还覆盖 XHTTP 模式、取消重连、错误 key/short ID 和普通 TLS 回归。实际执行范围见 验收矩阵,依赖发布要求见 TLS 依赖。