-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed By: mingtaoy Differential Revision: D66243048 fbshipit-source-id: e05755ced88b958681d153a41c7b5f46f482bf3c
- Loading branch information
1 parent
c3ff89c
commit 3af2d30
Showing
6 changed files
with
129 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2018-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <fizz/server/HandshakeLogging.h> | ||
|
||
namespace fizz { | ||
namespace server { | ||
|
||
void HandshakeLogging::populateFromClientHello(const ClientHello& chlo) { | ||
clientLegacyVersion = chlo.legacy_version; | ||
auto supportedVersions = getExtension<SupportedVersions>(chlo.extensions); | ||
if (supportedVersions) { | ||
clientSupportedVersions = supportedVersions->versions; | ||
} | ||
clientCiphers = chlo.cipher_suites; | ||
clientExtensions.clear(); | ||
for (const auto& extension : chlo.extensions) { | ||
clientExtensions.push_back(extension.extension_type); | ||
if (extension.extension_type == ExtensionType::test_extension && | ||
extension.extension_data->length() == 1) { | ||
// Special extension we want to log the byte for | ||
testExtensionByte = *extension.extension_data->data(); | ||
} | ||
} | ||
clientAlpns.clear(); | ||
auto alpn = getExtension<ProtocolNameList>(chlo.extensions); | ||
if (alpn) { | ||
for (auto& protocol : alpn->protocol_name_list) { | ||
clientAlpns.push_back(protocol.name->to<std::string>()); | ||
} | ||
} | ||
auto sni = getExtension<ServerNameList>(chlo.extensions); | ||
if (sni && !sni->server_name_list.empty()) { | ||
clientSni = sni->server_name_list.front().hostname->to<std::string>(); | ||
} | ||
auto supportedGroups = getExtension<SupportedGroups>(chlo.extensions); | ||
if (supportedGroups) { | ||
clientSupportedGroups = std::move(supportedGroups->named_group_list); | ||
} | ||
|
||
auto keyShare = getExtension<ClientKeyShare>(chlo.extensions); | ||
if (keyShare && !clientKeyShares) { | ||
std::vector<NamedGroup> shares; | ||
for (const auto& entry : keyShare->client_shares) { | ||
shares.push_back(entry.group); | ||
} | ||
clientKeyShares = std::move(shares); | ||
} | ||
|
||
auto exchangeModes = getExtension<PskKeyExchangeModes>(chlo.extensions); | ||
if (exchangeModes) { | ||
clientKeyExchangeModes = std::move(exchangeModes->modes); | ||
} | ||
|
||
auto clientSigSchemes = getExtension<SignatureAlgorithms>(chlo.extensions); | ||
if (clientSigSchemes) { | ||
clientSignatureAlgorithms = | ||
std::move(clientSigSchemes->supported_signature_algorithms); | ||
} | ||
|
||
clientSessionIdSent = | ||
chlo.legacy_session_id && !chlo.legacy_session_id->empty(); | ||
clientRandom = chlo.random; | ||
|
||
if (chlo.originalEncoding.hasValue()) { | ||
originalChloSize = chlo.originalEncoding.value()->computeChainDataLength(); | ||
} | ||
} | ||
} // namespace server | ||
} // namespace fizz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2018-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <fizz/record/Extensions.h> | ||
|
||
namespace fizz { | ||
namespace server { | ||
|
||
struct HandshakeLogging { | ||
folly::Optional<ProtocolVersion> clientLegacyVersion; | ||
std::vector<ProtocolVersion> clientSupportedVersions; | ||
std::vector<CipherSuite> clientCiphers; | ||
std::vector<ExtensionType> clientExtensions; | ||
folly::Optional<ProtocolVersion> clientRecordVersion; | ||
folly::Optional<std::string> clientSni; | ||
std::vector<NamedGroup> clientSupportedGroups; | ||
folly::Optional<std::vector<NamedGroup>> clientKeyShares; | ||
std::vector<PskKeyExchangeMode> clientKeyExchangeModes; | ||
std::vector<SignatureScheme> clientSignatureAlgorithms; | ||
folly::Optional<bool> clientSessionIdSent; | ||
folly::Optional<Random> clientRandom; | ||
folly::Optional<uint8_t> testExtensionByte; | ||
std::vector<std::string> clientAlpns; | ||
size_t originalChloSize{0}; | ||
|
||
void populateFromClientHello(const ClientHello& chlo); | ||
}; | ||
} // namespace server | ||
} // namespace fizz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters