Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VLESS Reality Protocol: Fix AES-256-GCM and Implement RealityServerCertVerifier
Summary
This PR fixes a critical authentication bug in the Reality protocol implementation
and completes the handshake by adding a custom certificate verifier that understands
Reality's non-standard server certificate format.
Background
VLESS Reality is a TLS extension used by proxy
servers to authenticate clients without being distinguishable from normal TLS traffic.
It works as follows:
auth_shared_secret.auth_key = HKDF-SHA256(auth_shared_secret, salt=random[:20], info="REALITY")—32 bytes.
[version(3) | reserved(1) | timestamp(4) | short_id(8)]with AES-256-GCM (key=auth_key,nonce=random[20:32],aad=ClientHello bytes) and places the 32-byte result in the TLSsession_idfield.
(ECDH with the server's ephemeral key from ServerHello).
session_id; on failure it transparently proxies theconnection to the SNI destination (fallback).
64 bytes are overwritten with
HMAC-SHA512(auth_key, ed25519_pubkey). StandardCA-chain verifiers reject this cert as
BadEncoding.Bug Fix: AES-128-GCM → AES-256-GCM
The previous implementation derived only 16 bytes from HKDF and used AES-128-GCM,
while the Xray-core reference implementation
derives 32 bytes and uses AES-256-GCM. This caused every Reality handshake to
fail authentication (server received an invalid
session_idand fell back to the SNIdestination).