From 79253e0c7a965cf1460a020b363d5878cb1e094d Mon Sep 17 00:00:00 2001 From: Abdulbaki Aydin Date: Sat, 9 Nov 2024 08:51:28 -0800 Subject: [PATCH] Add grease ech to the requested extensions Summary: Sets the requested extensions properly when sending grease ech. Reviewed By: mingtaoy Differential Revision: D65679082 fbshipit-source-id: 30a2a48414e51e893438f154f712a7cb88169b64 --- fizz/client/ClientProtocol.cpp | 2 ++ fizz/client/test/ClientProtocolTest.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/fizz/client/ClientProtocol.cpp b/fizz/client/ClientProtocol.cpp index 54f629ecf1b..9f33f9f73dc 100644 --- a/fizz/client/ClientProtocol.cpp +++ b/fizz/client/ClientProtocol.cpp @@ -888,6 +888,7 @@ EventHandler::handle( auto greaseECH = ech::generateGreaseECH( *context->getGreaseECHSetting(), *context->getFactory(), 0); chlo.extensions.push_back(encodeExtension(std::move(greaseECH))); + requestedExtensions.push_back(ExtensionType::encrypted_client_hello); } Buf encodedClientHello; @@ -978,6 +979,7 @@ EventHandler::handle( *context->getFactory(), encodedClientHello->computeChainDataLength()); chlo.extensions.push_back(encodeExtension(std::move(greaseECH))); + requestedExtensions.push_back(ExtensionType::encrypted_client_hello); // Update the client hello with the grease ECH extension encodedClientHello = encodeHandshake(chlo); } diff --git a/fizz/client/test/ClientProtocolTest.cpp b/fizz/client/test/ClientProtocolTest.cpp index 88ecd57401d..d9baf56ac91 100644 --- a/fizz/client/test/ClientProtocolTest.cpp +++ b/fizz/client/test/ClientProtocolTest.cpp @@ -1334,6 +1334,12 @@ TEST_F(ClientProtocolTest, TestConnectWithRandomGreaseECH) { echExtension->payload->computeChainDataLength(), setting.minPayloadSize); EXPECT_LE( echExtension->payload->computeChainDataLength(), setting.maxPayloadSize); + EXPECT_TRUE( + std::find( + state_.requestedExtensions()->begin(), + state_.requestedExtensions()->end(), + ExtensionType::encrypted_client_hello) != + state_.requestedExtensions()->end()); } TEST_F(ClientProtocolTest, TestConnectWithComputedGreaseECH) { @@ -1382,6 +1388,12 @@ TEST_F(ClientProtocolTest, TestConnectWithComputedGreaseECH) { echOverhead; EXPECT_EQ( expectedPayloadSize, echExtension->payload->computeChainDataLength()); + EXPECT_TRUE( + std::find( + state_.requestedExtensions()->begin(), + state_.requestedExtensions()->end(), + ExtensionType::encrypted_client_hello) != + state_.requestedExtensions()->end()); } TEST_F(ClientProtocolTest, TestConnectCompatEarly) {