Skip to content

Commit

Permalink
Add grease ech to the requested extensions
Browse files Browse the repository at this point in the history
Summary: Sets the requested extensions properly when sending grease ech.

Reviewed By: mingtaoy

Differential Revision: D65679082

fbshipit-source-id: 30a2a48414e51e893438f154f712a7cb88169b64
  • Loading branch information
abakiaydin authored and facebook-github-bot committed Nov 9, 2024
1 parent 6c81cf4 commit 79253e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fizz/client/ClientProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ EventHandler<ClientTypes, StateEnum::Uninitialized, Event::Connect>::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;
Expand Down Expand Up @@ -978,6 +979,7 @@ EventHandler<ClientTypes, StateEnum::Uninitialized, Event::Connect>::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);
}
Expand Down
12 changes: 12 additions & 0 deletions fizz/client/test/ClientProtocolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 79253e0

Please sign in to comment.