Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
24320ad
fix(reality): imitate target TLS 1.3 post-handshake records
Nemu-x Oct 3, 2026
c61133f
fix(reality): raise the target record buffer to 17 KiB
Nemu-x Oct 11, 2026
a21435a
feat(reality): sign the temporary certificate with ML-DSA-65
Nemu-x Oct 11, 2026
e845842
feat(reality): optionally require an X25519MLKEM768 key share
Nemu-x Oct 11, 2026
6630200
test(reality): browser fingerprints pass the X25519MLKEM768 requirement
Nemu-x Oct 11, 2026
974cea2
fix(ech): return the outer ClientHello build error
Nemu-x Oct 13, 2026
72306d9
fix(ech): pass the server certificates to EncryptedClientHelloRejecti…
Nemu-x Oct 13, 2026
c7889ab
fix: default the server minimum version to TLS 1.2
Nemu-x Oct 13, 2026
b605f45
fix: return errors instead of panicking on malformed ClientHello imports
Nemu-x Oct 13, 2026
86e294b
fix(roller): close the TCP connection after a failed handshake
Nemu-x Oct 13, 2026
4da4d83
fix: bound compressed certificate decompression
Nemu-x Oct 13, 2026
45903f8
fix(mlkem): panic when crypto/rand fails instead of using zero bytes
Nemu-x Oct 13, 2026
c57d07e
port: follow the v1.9 mlkem and hpke package layout
Nemu-x Nov 11, 2026
6a87928
fix: return errors for out-of-range HKDF and exporter lengths
Nemu-x Oct 13, 2026
fa224e2
crypto/tls: validate ECH outer extension references
thatnealpatel Sep 28, 2026
e788649
crypto/tls: do not count handshake messages as state-advancing post-h…
Nemu-x Oct 13, 2026
78bccfa
ci: test the citrus branch on push and pull requests
Nemu-x Oct 14, 2026
7f0c8af
test: report ApplyPreset errors without racing on err
Nemu-x Oct 14, 2026
b60d673
ci: run on main and dev, skip loopclosure in vet, keep LF on Windows
Nemu-x Oct 14, 2026
14b5323
crypto/tls: write the records of one write together
Nemu-x Oct 17, 2026
757e109
test: wait for the client before closing in TestWriteSmallRecordsUnch…
Nemu-x Oct 18, 2026
3f03773
fix: bound REALITY handshakes and preserve JLS application verification
Nemu-x Oct 20, 2026
2454432
fix(reality): release hosting handshake guards on fallback
Nemu-x Oct 20, 2026
d0ddc8d
feat: add HelloChrome_155 and make it HelloChrome_Auto
Nemu-x Nov 10, 2026
3431473
test: build the Chrome 155 tests with Go 1.20
Nemu-x Nov 10, 2026
8bc84a5
test: check that ApplyPreset keeps the Chrome 155 preset unshared
Nemu-x Nov 11, 2026
55f3fd1
ci: run on dev-1.9
Nemu-x Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [main, dev, dev-1.9]
pull_request:
branches: [main, dev, dev-1.9]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, go: '1.26' }
- { os: windows-latest, go: '1.26' }
- { os: ubuntu-latest, go: '1.20' }
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 0
GOTOOLCHAIN: local
steps:
# Keep testdata byte-exact: autocrlf on Windows runners rewrites LF.
- name: Disable CRLF conversion
if: runner.os == 'Windows'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
# go.mod says go 1.20, so loopclosure flags upstream Go tests that assume
# per-iteration loop variables; the rest of vet stays on.
- name: Vet
if: matrix.go == '1.26'
run: go vet -loopclosure=false ./...
- name: Test
run: go test -count=1 ./...

race:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Test with the race detector
run: go test -race -count=1 ./...
47 changes: 0 additions & 47 deletions .github/workflows/go.yml

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,16 @@ will prepare ClientHello with empty uconn.Extensions so you can fill it with TLS
4. The rest will will parrot given browser. Such parrots include, for example:
* `utls.HelloChrome_Auto`- parrots recommended(usually latest) Google Chrome version
* `utls.HelloChrome_58` - parrots Google Chrome 58
* `utls.HelloChrome_155` - parrots a fresh Chrome 155.0.8059.40 connection on macOS
* `utls.HelloFirefox_Auto` - parrots recommended(usually latest) Firefox version
* `utls.HelloFirefox_55` - parrots Firefox 55

`HelloChrome_Auto` currently selects `HelloChrome_155`. This profile includes
GREASE and ML-DSA signature schemes and the 28 trust anchor IDs observed in a
[fresh Chrome capture](testdata/chrome155_clienthello.md). The IDs are a snapshot
of that build's Chrome Root Store; component updates and browser feature settings
can change the ClientHello. `TrustAnchorsExtension` preserves these IDs when
fingerprinting a capture and does not change `Config.RootCAs`.

# Usage
## Examples
Expand Down
145 changes: 145 additions & 0 deletions coalesce_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package tls

import (
"bytes"
"io"
"net"
"sync"
"testing"
)

// writeSizeConn records the size of every write to the connection.
type writeSizeConn struct {
net.Conn
mu sync.Mutex
writes []int
}

func (c *writeSizeConn) Write(b []byte) (int, error) {
c.mu.Lock()
c.writes = append(c.writes, len(b))
c.mu.Unlock()
return c.Conn.Write(b)
}

func (c *writeSizeConn) reset() []int {
c.mu.Lock()
defer c.mu.Unlock()
w := c.writes
c.writes = nil
return w
}

// TestWriteCoalescesRecords checks that the records of one large write go to
// the connection in writes of several records, up to coalesceLimit, and that
// the peer reads the same data, with every cipher kind.
func TestWriteCoalescesRecords(t *testing.T) {
configs := map[string]func(*Config){
"TLSv13": func(*Config) {},
"AEAD": func(c *Config) {
c.MaxVersion = VersionTLS12
c.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}
},
"CBC": func(c *Config) {
c.MaxVersion = VersionTLS12
c.CipherSuites = []uint16{TLS_RSA_WITH_AES_256_CBC_SHA}
},
"Stream": func(c *Config) {
c.MaxVersion = VersionTLS12
c.CipherSuites = []uint16{TLS_RSA_WITH_RC4_128_SHA}
},
}
for name, configure := range configs {
for _, dynamic := range []bool{false, true} {
config := testConfig.Clone()
configure(config)
serverConfig := config.Clone()
serverConfig.DynamicRecordSizingDisabled = !dynamic
testWriteCoalescesRecords(t, name, dynamic, config, serverConfig)
}
}
}

func testWriteCoalescesRecords(t *testing.T, name string, dynamic bool, clientConfig, serverConfig *Config) {
clientConn, serverConn := localPipe(t)
counted := &writeSizeConn{Conn: serverConn}
server := Server(counted, serverConfig)
defer server.Close()

plaintext := make([]byte, 1<<20+123)
for i := range plaintext {
plaintext[i] = byte(i * 7)
}
got := make(chan []byte, 1)
go func() {
client := Client(clientConn, clientConfig)
defer client.Close()
data, err := io.ReadAll(io.LimitReader(client, int64(len(plaintext))))
if err != nil {
t.Errorf("%s: client read: %v", name, err)
}
got <- data
}()
if err := server.Handshake(); err != nil {
t.Fatalf("%s: handshake: %v", name, err)
}
counted.reset()
if n, err := server.Write(plaintext); err != nil || n != len(plaintext) {
t.Fatalf("%s: write = %d, %v", name, n, err)
}
writes := counted.reset()
if data := <-got; !bytes.Equal(data, plaintext) {
t.Fatalf("%s: the client read other data (%d bytes)", name, len(data))
}

total := 0
for i, size := range writes {
total += size
if size > coalesceLimit {
t.Errorf("%s: write #%d of %d bytes, over the limit of %d", name, i, size, coalesceLimit)
}
}
fullRecords := len(plaintext)/maxPlaintext + 1
maxWrites := fullRecords/7 + 1 // about eight records per write
if dynamic {
maxWrites += recordSizeBoostThreshold / (8 * 1000) // the small records first
}
if len(writes) > maxWrites {
t.Errorf("%s (dynamic %v): %d writes for %d bytes of records, want at most %d", name, dynamic, len(writes), total, maxWrites)
}
}

// TestWriteSmallRecordsUnchanged checks that a write of one record is still
// one write of that record.
func TestWriteSmallRecordsUnchanged(t *testing.T) {
clientConn, serverConn := localPipe(t)
counted := &writeSizeConn{Conn: serverConn}
server := Server(counted, testConfig.Clone())
defer server.Close()
clientDone := make(chan struct{})
go func() {
defer close(clientDone)
client := Client(clientConn, testConfig.Clone())
defer client.Close()
buf := make([]byte, 100)
for i := 0; i < 3; i++ {
if _, err := io.ReadFull(client, buf[:10]); err != nil {
t.Errorf("client read: %v", err)
return
}
}
}()
if err := server.Handshake(); err != nil {
t.Fatal(err)
}
counted.reset()
for i := 0; i < 3; i++ {
if _, err := server.Write(bytes.Repeat([]byte{'a'}, 10)); err != nil {
t.Fatal(err)
}
if writes := counted.reset(); len(writes) != 1 || writes[0] != recordHeaderLen+10+1+16 {
t.Fatalf("write %d: writes %v, want one record of %d bytes", i, writes, recordHeaderLen+10+1+16)
}
}
<-clientDone // before the connections are closed
}
19 changes: 14 additions & 5 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ type ConnectionState struct {
// of RFC 5705 and RFC 7627), but can be re-enabled with the GODEBUG setting
// tlsunsafeekm=1.
func (cs *ConnectionState) ExportKeyingMaterial(label string, context []byte, length int) ([]byte, error) {
if length < 0 {
return nil, errors.New("crypto/tls: ExportKeyingMaterial length is negative")
}
return cs.ekm(label, context, length)
}

Expand Down Expand Up @@ -444,6 +447,12 @@ const (
// EdDSA algorithms.
Ed25519 SignatureScheme = 0x0807

// ML-DSA algorithms (draft-ietf-tls-mldsa). uTLS only advertises these
// codepoints for ClientHello parroting; it cannot verify ML-DSA signatures.
MLDSA44 SignatureScheme = 0x0904
MLDSA65 SignatureScheme = 0x0905
MLDSA87 SignatureScheme = 0x0906

// Legacy signature and hash algorithms for TLS 1.2.
PKCS1WithSHA1 SignatureScheme = 0x0201
ECDSAWithSHA1 SignatureScheme = 0x0203
Expand Down Expand Up @@ -851,8 +860,8 @@ type Config struct {
// By default, TLS 1.2 is currently used as the minimum. TLS 1.0 is the
// minimum supported by this package.
//
// The server-side default can be reverted to TLS 1.0 by including the value
// "tls10server=1" in the GODEBUG environment variable.
// [uTLS] The "tls10server=1" GODEBUG setting is not supported: set
// MinVersion to VersionTLS10 explicitly to accept TLS 1.0 on a server.
MinVersion uint16

// MaxVersion contains the maximum TLS version that is acceptable.
Expand Down Expand Up @@ -1320,9 +1329,9 @@ func (c *Config) supportedVersions(isClient bool) []uint16 {
// if isClient || tls10server.Value() != "1" {
// continue
// }
if isClient {
continue
}
// Without the godebug knob the documented default (TLS 1.2
// minimum) applies to servers as well as clients.
continue
// [uTLS SECTION END]
}
if isClient && c.EncryptedClientHelloConfigList != nil && v < VersionTLS13 {
Expand Down
8 changes: 8 additions & 0 deletions common_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading