Avoid duplicating the ECH config in short payload test The hard-coded short-payload ClientHello only needs the configured ECH identifier, KEM, and HPKE cipher to match in order to exercise the intended server opener path. Parse ECH_CONFIG_LIST and assert those fields instead of carrying a second full byte copy of the config. Co-authored-by: Codex <codex@openai.com>
diff --git a/t/picotls.c b/t/picotls.c index bb7ce37..41adb66 100644 --- a/t/picotls.c +++ b/t/picotls.c
@@ -1748,13 +1748,6 @@ { /* This ClientHello is tied to ECH_CONFIG_LIST and the matching ECH_PRIVATE_KEY from t/test.h. The HPKE enc value is valid for * that key and config, which lets the server create the ECH AEAD context before it rejects the one-byte ECH payload. */ - static const uint8_t expected_ech_config_list[] = { - 0x00, 0x63, 0xfe, 0x0d, 0x00, 0x5f, 0x12, 0x00, 0x10, 0x00, 0x41, 0x04, 0xfe, 0x8c, 0x19, 0xce, 0x09, - 0x05, 0x19, 0x1e, 0xbc, 0x29, 0x8a, 0x92, 0x45, 0x79, 0x25, 0x31, 0xf2, 0x6f, 0x0c, 0xec, 0xe2, 0x46, - 0x06, 0x39, 0xe8, 0xbc, 0x39, 0xcb, 0x7f, 0x70, 0x6a, 0x82, 0x6a, 0x77, 0x9b, 0x4c, 0xf9, 0x69, 0xb8, - 0xa0, 0xe5, 0x39, 0xc7, 0xf6, 0x2f, 0xb3, 0xd3, 0x0a, 0xd6, 0xaa, 0x8f, 0x80, 0xe3, 0x0f, 0x1d, 0x12, - 0x8a, 0xaf, 0xd6, 0x8a, 0x2c, 0xe7, 0x2e, 0xa0, 0x00, 0x08, 0x00, 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, - 0x01, 0x40, 0x0b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00}; static const uint8_t ch[] = { 0x16, 0x03, 0x03, 0x01, 0x03, 0x01, 0x00, 0x00, 0xff, 0x03, 0x03, 0x6d, 0x64, 0xb4, 0x65, 0x77, 0xf2, 0xdd, 0x12, 0x97, 0xbe, 0x68, 0x53, 0x75, 0x3b, 0x27, 0x2f, 0xc9, 0xdc, 0x08, 0x3b, 0xa4, 0x7b, 0x93, @@ -1772,14 +1765,19 @@ 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x2b, 0x00, 0x03, 0x02, 0x03, 0x04, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0c, 0x08, 0x05, 0x08, 0x04, 0x05, 0x03, 0x04, 0x03, 0x04, 0x01, 0x02, 0x01, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x02, 0x00, 0x17}; + struct st_decoded_ech_config_t decoded; ptls_t *server; ptls_buffer_t sbuf; size_t consumed; int ret; ok(ctx_peer->ech.server.create_opener != NULL); - ok(sizeof(ECH_CONFIG_LIST) - 1 == sizeof(expected_ech_config_list)); - ok(memcmp(ECH_CONFIG_LIST, expected_ech_config_list, sizeof(expected_ech_config_list)) == 0); + ret = client_decode_ech_config_list(ctx_peer, &decoded, ptls_iovec_init(ECH_CONFIG_LIST, sizeof(ECH_CONFIG_LIST) - 1)); + ok(ret == 0); + ok(decoded.id == 0x12); + ok(decoded.kem != NULL && decoded.kem->id == PTLS_HPKE_KEM_P256_SHA256); + ok(decoded.cipher != NULL && decoded.cipher->id.kdf == PTLS_HPKE_HKDF_SHA384 && + decoded.cipher->id.aead == PTLS_HPKE_AEAD_AES_256_GCM); server = ptls_new(ctx_peer, 1); ptls_buffer_init(&sbuf, "", 0);