Skip to content

Commit ab37775

Browse files
committed
refactor: remove unused cf circl ech config
Remove code using cloudflare circl's ECHConfig since ech has been implemented via the standard library. Given that real ech was never implemented using cf circl code in utls, this shouldn't be breaking any user's code from what I can tell.
1 parent d319820 commit ab37775

File tree

10 files changed

+0
-208
lines changed

10 files changed

+0
-208
lines changed

common.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,6 @@ type ConnectionState struct {
316316
// testingOnlyCurveID is the selected CurveID, or zero if an RSA exchanges
317317
// is performed.
318318
testingOnlyCurveID CurveID
319-
320-
// ECHRetryConfigs contains the ECH retry configurations sent by the server in
321-
// EncryptedExtensions message. It is only populated if the server sent the
322-
// ech extension in EncryptedExtensions message.
323-
ECHRetryConfigs []ECHConfig // [uTLS]
324319
}
325320

326321
// ExportKeyingMaterial returns length bytes of exported key material in a new
@@ -919,17 +914,6 @@ type Config struct {
919914
// autoSessionTicketKeys is like sessionTicketKeys but is owned by the
920915
// auto-rotation logic. See Config.ticketKeys.
921916
autoSessionTicketKeys []ticketKey
922-
923-
// ECHConfigs contains the ECH configurations to be used by the ECH
924-
// extension if any.
925-
// It could either be distributed by the server in EncryptedExtensions
926-
// message or out-of-band.
927-
//
928-
// If ECHConfigs is nil and an ECH extension is present, GREASEd ECH
929-
// extension will be sent.
930-
//
931-
// If GREASE ECH extension is present, this field will be ignored.
932-
ECHConfigs []ECHConfig // [uTLS]
933917
}
934918

935919
// EncryptedClientHelloKey holds a private key that is associated
@@ -1036,7 +1020,6 @@ func (c *Config) Clone() *Config {
10361020
autoSessionTicketKeys: c.autoSessionTicketKeys,
10371021

10381022
PreferSkipResumptionOnNilExtension: c.PreferSkipResumptionOnNilExtension, // [UTLS]
1039-
ECHConfigs: c.ECHConfigs, // [uTLS]
10401023
}
10411024
}
10421025

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ retract (
99

1010
require (
1111
github.com/andybalholm/brotli v1.0.6
12-
github.com/cloudflare/circl v1.5.0
1312
github.com/klauspost/compress v1.17.4
1413
golang.org/x/crypto v0.36.0
1514
golang.org/x/net v0.38.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
22
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
3-
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
4-
github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
53
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
64
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
75
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=

tls_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,6 @@ func TestCloneNonFuncFields(t *testing.T) {
903903
continue // these are unexported fields that are handled separately
904904
case "ApplicationSettings": // [UTLS] ALPS (Application Settings)
905905
f.Set(reflect.ValueOf(map[string][]byte{"a": {1}}))
906-
case "ECHConfigs": // [UTLS] ECH (Encrypted Client Hello) Configs
907-
f.Set(reflect.ValueOf([]ECHConfig{{Version: 1}}))
908906
default:
909907
t.Errorf("all fields must be accounted for, but saw unknown field %q", fn)
910908
}

u_conn.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,6 @@ func (c *Conn) utlsHandshakeMessageType(msgType byte) (handshakeMessage, error)
841841
// Extending (*Conn).connectionStateLocked()
842842
func (c *Conn) utlsConnectionStateLocked(state *ConnectionState) {
843843
state.PeerApplicationSettings = c.utls.peerApplicationSettings
844-
state.ECHRetryConfigs = c.utls.echRetryConfigs
845844
}
846845

847846
type utlsConnExtraFields struct {
@@ -850,9 +849,6 @@ type utlsConnExtraFields struct {
850849
localApplicationSettings []byte
851850
applicationSettingsCodepoint uint16
852851

853-
// Encrypted Client Hello (ECH)
854-
echRetryConfigs []ECHConfig
855-
856852
sessionController *sessionController
857853
}
858854

u_ech.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ type EncryptedClientHelloExtension interface {
2626
// TLSExtension must be implemented by all EncryptedClientHelloExtension implementations.
2727
TLSExtension
2828

29-
// Configure configures the EncryptedClientHelloExtension with the given slice of ECHConfig.
30-
Configure([]ECHConfig) error
31-
3229
// MarshalClientHello is called by (*UConn).MarshalClientHello() when an ECH extension
3330
// is present to allow the ECH extension to take control of the generation of the
3431
// entire ClientHello message.
@@ -202,11 +199,6 @@ func (g *GREASEEncryptedClientHelloExtension) Read(b []byte) (int, error) {
202199
return g.Len(), io.EOF
203200
}
204201

205-
// Configure implements EncryptedClientHelloExtension.
206-
func (*GREASEEncryptedClientHelloExtension) Configure([]ECHConfig) error {
207-
return nil // no-op, it is not possible to configure a GREASE extension for now
208-
}
209-
210202
// MarshalClientHello implements EncryptedClientHelloExtension.
211203
func (*GREASEEncryptedClientHelloExtension) MarshalClientHello(*UConn) error {
212204
return errors.New("tls: grease ech: MarshalClientHello() is not implemented, use (*UConn).MarshalClientHello() instead")
@@ -289,11 +281,6 @@ func (*UnimplementedECHExtension) Read(_ []byte) (int, error) {
289281
return 0, errors.New("tls: unimplemented ECHExtension")
290282
}
291283

292-
// Configure implements EncryptedClientHelloExtension.
293-
func (*UnimplementedECHExtension) Configure([]ECHConfig) error {
294-
return errors.New("tls: unimplemented ECHExtension")
295-
}
296-
297284
// MarshalClientHello implements EncryptedClientHelloExtension.
298285
func (*UnimplementedECHExtension) MarshalClientHello(*UConn) error {
299286
return errors.New("tls: unimplemented ECHExtension")

u_ech_config.go

Lines changed: 0 additions & 135 deletions
This file was deleted.

u_handshake_client.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func (hs *clientHandshakeStateTLS13) sendClientEncryptedExtensions() error {
145145
func (hs *clientHandshakeStateTLS13) utlsReadServerParameters(encryptedExtensions *encryptedExtensionsMsg) error {
146146
hs.c.utls.peerApplicationSettings = encryptedExtensions.utls.applicationSettings
147147
hs.c.utls.applicationSettingsCodepoint = encryptedExtensions.utls.applicationSettingsCodepoint
148-
hs.c.utls.echRetryConfigs = encryptedExtensions.utls.echRetryConfigs
149148

150149
if hs.c.utls.applicationSettingsCodepoint != 0 {
151150
if hs.uconn.vers < VersionTLS13 {
@@ -165,23 +164,6 @@ func (hs *clientHandshakeStateTLS13) utlsReadServerParameters(encryptedExtension
165164
}
166165
}
167166

168-
if len(hs.c.utls.echRetryConfigs) > 0 {
169-
if hs.uconn.vers < VersionTLS13 {
170-
return errors.New("tls: server sent ECH retry configs at invalid version")
171-
}
172-
173-
// find ECH extension in ClientHello
174-
var echIncluded bool
175-
for _, ext := range hs.uconn.Extensions {
176-
if _, ok := ext.(ECHExtension); ok {
177-
echIncluded = true
178-
}
179-
}
180-
if !echIncluded {
181-
return errors.New("tls: server sent ECH retry configs without client sending ECH extension")
182-
}
183-
}
184-
185167
return nil
186168
}
187169

u_handshake_messages.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func (m *utlsCompressedCertificateMsg) unmarshal(data []byte) bool {
5656
type utlsEncryptedExtensionsMsgExtraFields struct {
5757
applicationSettings []byte
5858
applicationSettingsCodepoint uint16
59-
echRetryConfigs []ECHConfig
6059
customExtension []byte
6160
}
6261

@@ -67,12 +66,6 @@ func (m *encryptedExtensionsMsg) utlsUnmarshal(extension uint16, extData cryptob
6766
case utlsExtensionApplicationSettingsNew:
6867
m.utls.applicationSettingsCodepoint = extension
6968
m.utls.applicationSettings = []byte(extData)
70-
case utlsExtensionECH:
71-
var err error
72-
m.utls.echRetryConfigs, err = UnmarshalECHConfigs([]byte(extData))
73-
if err != nil {
74-
return false
75-
}
7669
}
7770
return true // success/unknown extension
7871
}

u_hpke.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package tls
22

33
import (
4-
"github.com/cloudflare/circl/kem"
54
"github.com/refraction-networking/utls/internal/hpke"
65
)
76

@@ -15,14 +14,6 @@ type HPKESymmetricCipherSuite struct {
1514
AeadId HPKE_AEAD_ID
1615
}
1716

18-
type HPKEKeyConfig struct {
19-
ConfigId uint8
20-
KemId HPKE_KEM_ID
21-
PublicKey kem.PublicKey
22-
rawPublicKey HPKERawPublicKey
23-
CipherSuites []HPKESymmetricCipherSuite
24-
}
25-
2617
const defaultHpkeKdf = hpke.KDF_HKDF_SHA256
2718
const defaultHpkeKem = hpke.DHKEM_X25519_HKDF_SHA256
2819
const defaultHpkeAead = hpke.AEAD_AES_128_GCM

0 commit comments

Comments
 (0)