Skip to content

Commit

Permalink
Add chlo size to handshake logging
Browse files Browse the repository at this point in the history
Summary: Adds original chlo size field to handshake logging.

Reviewed By: NickR23

Differential Revision: D65761796

fbshipit-source-id: 8708f8c9b0562d450444c33ec2ca75c863578be5
  • Loading branch information
abakiaydin authored and facebook-github-bot committed Nov 15, 2024
1 parent 7d77f57 commit 519ca76
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions fizz/server/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ void HandshakeLogging::populateFromClientHello(const ClientHello& chlo) {
clientSessionIdSent =
chlo.legacy_session_id && !chlo.legacy_session_id->empty();
clientRandom = chlo.random;

if (chlo.originalEncoding.hasValue()) {
originalChloSize = chlo.originalEncoding.value()->computeChainDataLength();
}
}

folly::StringPiece toString(StateEnum state) {
Expand Down
1 change: 1 addition & 0 deletions fizz/server/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct HandshakeLogging {
folly::Optional<Random> clientRandom;
folly::Optional<uint8_t> testExtensionByte;
std::vector<std::string> clientAlpns;
size_t originalChloSize{0};

void populateFromClientHello(const ClientHello& chlo);
};
Expand Down
11 changes: 9 additions & 2 deletions fizz/server/test/ServerProtocolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5074,7 +5074,13 @@ TEST_F(ServerProtocolTest, TestClientHelloRejectEarlyDataInvalidAppToken) {
TEST_F(ServerProtocolTest, TestClientHelloHandshakeLogging) {
setUpExpectingClientHello();
state_.handshakeLogging() = std::make_unique<HandshakeLogging>();
fizz::Param param = TestMessages::clientHello();
auto chlo = TestMessages::clientHello();
size_t originalEncodingSize = 0;
if (chlo.originalEncoding.hasValue()) {
originalEncodingSize =
chlo.originalEncoding.value()->computeChainDataLength();
}
fizz::Param param = std::move(chlo);
auto actions = getActions(detail::processEvent(state_, param));
processStateMutations(actions);
EXPECT_EQ(
Expand Down Expand Up @@ -5103,7 +5109,8 @@ TEST_F(ServerProtocolTest, TestClientHelloHandshakeLogging) {
{SignatureScheme::ecdsa_secp256r1_sha256,
SignatureScheme::rsa_pss_sha256}));
EXPECT_EQ(*state_.handshakeLogging()->clientSessionIdSent, false);
EXPECT_TRUE(state_.handshakeLogging()->clientRandom.has_value());
EXPECT_TRUE(state_.handshakeLogging()->clientRandom.hasValue());
EXPECT_EQ(originalEncodingSize, state_.handshakeLogging()->originalChloSize);
}

TEST_F(ServerProtocolTest, TestClientHelloTestByte) {
Expand Down

0 comments on commit 519ca76

Please sign in to comment.