Skip to content

Commit a83ce98

Browse files
kazuhoclaude
andcommitted
skip ECH grease when client.ech.configs has NULL base
The header documented that {NULL, 0} disables ECH, but the client-side implementation took the grease branch whenever configs.len was zero -- including the zero-initialized {NULL, 0} default. That forced grease on any handshake that supplied handshake_properties for unrelated reasons (e.g., QUIC additional extensions), even though the context's ECH setup wasn't meant to apply. Gate the grease branch on configs.base != NULL to match the documented API, and expand the comment in picotls.h to cover all three states explicitly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e902898 commit a83ce98

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/picotls.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,8 +1123,9 @@ typedef struct st_ptls_handshake_properties_t {
11231123
*/
11241124
struct {
11251125
/**
1126-
* Config offered by server e.g., by HTTPS RR. If config.base is non-NULL but config.len is zero, a grease ECH will
1127-
* be sent, assuming that X25519-SHA256 KEM and SHA256-AES-128-GCM HPKE cipher is available.
1126+
* An ECH config offered by server e.g., by HTTPS RR. If config.len is zero and .base is non-NULL, a grease ECH will
1127+
* be sent, assuming that X25519-SHA256 KEM and SHA256-AES-128-GCM HPKE cipher is available. If .base is also NULL,
1128+
* ECH will not be used at all, even if the context provided the ECH ciphers.
11281129
*/
11291130
ptls_iovec_t configs;
11301131
/**

lib/picotls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,8 +2400,8 @@ static int send_client_hello(ptls_t *tls, ptls_message_emitter_t *emitter, ptls_
24002400
if ((ret = client_setup_ech(&tls->ech, &decoded, tls->ctx->random_bytes)) != 0)
24012401
goto Exit;
24022402
}
2403-
} else {
2404-
/* zero-length config indicates ECH greasing */
2403+
} else if (properties->client.ech.configs.base != NULL) {
2404+
/* zero-length config with non-NULL base indicates ECH greasing; NULL base means no ECH */
24052405
client_setup_ech_grease(&tls->ech, tls->ctx->random_bytes, tls->ctx->ech.client.kems, tls->ctx->ech.client.ciphers,
24062406
sni_name);
24072407
tls->ech.state = PTLS_ECH_STATE_GREASE;

0 commit comments

Comments
 (0)