#include "quiche/quic/core/crypto/quic_crypto_client_config.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "absl/base/macros.h"
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "openssl/ssl.h"
#include "quiche/quic/core/crypto/cert_compressor.h"
#include "quiche/quic/core/crypto/chacha20_poly1305_encrypter.h"
#include "quiche/quic/core/crypto/crypto_framer.h"
#include "quiche/quic/core/crypto/crypto_protocol.h"
#include "quiche/quic/core/crypto/crypto_utils.h"
#include "quiche/quic/core/crypto/curve25519_key_exchange.h"
#include "quiche/quic/core/crypto/key_exchange.h"
#include "quiche/quic/core/crypto/p256_key_exchange.h"
#include "quiche/quic/core/crypto/proof_verifier.h"
#include "quiche/quic/core/crypto/quic_encrypter.h"
#include "quiche/quic/core/crypto/quic_random.h"
#include "quiche/quic/core/crypto/tls_client_connection.h"
#include "quiche/quic/core/quic_connection_id.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/core/quic_utils.h"
#include "quiche/quic/platform/api/quic_bug_tracker.h"
#include "quiche/quic/platform/api/quic_client_stats.h"
#include "quiche/quic/platform/api/quic_hostname_utils.h"
#include "quiche/quic/platform/api/quic_logging.h"
namespace quic {
namespace {
void RecordInchoateClientHelloReason(
QuicCryptoClientConfig::CachedState::ServerConfigState state) { … }
void RecordDiskCacheServerConfigState(
QuicCryptoClientConfig::CachedState::ServerConfigState state) { … }
}
QuicCryptoClientConfig::QuicCryptoClientConfig(
std::unique_ptr<ProofVerifier> proof_verifier)
: … { … }
QuicCryptoClientConfig::QuicCryptoClientConfig(
std::unique_ptr<ProofVerifier> proof_verifier,
std::shared_ptr<SessionCache> session_cache)
: … { … }
QuicCryptoClientConfig::~QuicCryptoClientConfig() { … }
QuicCryptoClientConfig::CachedState::CachedState()
: … { … }
QuicCryptoClientConfig::CachedState::~CachedState() { … }
bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { … }
bool QuicCryptoClientConfig::CachedState::IsEmpty() const { … }
const CryptoHandshakeMessage*
QuicCryptoClientConfig::CachedState::GetServerConfig() const { … }
QuicCryptoClientConfig::CachedState::ServerConfigState
QuicCryptoClientConfig::CachedState::SetServerConfig(
absl::string_view server_config, QuicWallTime now, QuicWallTime expiry_time,
std::string* error_details) { … }
void QuicCryptoClientConfig::CachedState::InvalidateServerConfig() { … }
void QuicCryptoClientConfig::CachedState::SetProof(
const std::vector<std::string>& certs, absl::string_view cert_sct,
absl::string_view chlo_hash, absl::string_view signature) { … }
void QuicCryptoClientConfig::CachedState::Clear() { … }
void QuicCryptoClientConfig::CachedState::ClearProof() { … }
void QuicCryptoClientConfig::CachedState::SetProofValid() { … }
void QuicCryptoClientConfig::CachedState::SetProofInvalid() { … }
bool QuicCryptoClientConfig::CachedState::Initialize(
absl::string_view server_config, absl::string_view source_address_token,
const std::vector<std::string>& certs, const std::string& cert_sct,
absl::string_view chlo_hash, absl::string_view signature, QuicWallTime now,
QuicWallTime expiration_time) { … }
const std::string& QuicCryptoClientConfig::CachedState::server_config() const { … }
const std::string& QuicCryptoClientConfig::CachedState::source_address_token()
const { … }
const std::vector<std::string>& QuicCryptoClientConfig::CachedState::certs()
const { … }
const std::string& QuicCryptoClientConfig::CachedState::cert_sct() const { … }
const std::string& QuicCryptoClientConfig::CachedState::chlo_hash() const { … }
const std::string& QuicCryptoClientConfig::CachedState::signature() const { … }
bool QuicCryptoClientConfig::CachedState::proof_valid() const { … }
uint64_t QuicCryptoClientConfig::CachedState::generation_counter() const { … }
const ProofVerifyDetails*
QuicCryptoClientConfig::CachedState::proof_verify_details() const { … }
void QuicCryptoClientConfig::CachedState::set_source_address_token(
absl::string_view token) { … }
void QuicCryptoClientConfig::CachedState::set_cert_sct(
absl::string_view cert_sct) { … }
void QuicCryptoClientConfig::CachedState::SetProofVerifyDetails(
ProofVerifyDetails* details) { … }
void QuicCryptoClientConfig::CachedState::InitializeFrom(
const QuicCryptoClientConfig::CachedState& other) { … }
void QuicCryptoClientConfig::SetDefaults() { … }
QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
const QuicServerId& server_id) { … }
void QuicCryptoClientConfig::ClearCachedStates(const ServerIdFilter& filter) { … }
void QuicCryptoClientConfig::FillInchoateClientHello(
const QuicServerId& server_id, const ParsedQuicVersion preferred_version,
const CachedState* cached, QuicRandom* rand, bool demand_x509_proof,
quiche::QuicheReferenceCountedPointer<QuicCryptoNegotiatedParameters>
out_params,
CryptoHandshakeMessage* out) const { … }
QuicErrorCode QuicCryptoClientConfig::FillClientHello(
const QuicServerId& server_id, QuicConnectionId connection_id,
const ParsedQuicVersion preferred_version,
const ParsedQuicVersion actual_version, const CachedState* cached,
QuicWallTime now, QuicRandom* rand,
quiche::QuicheReferenceCountedPointer<QuicCryptoNegotiatedParameters>
out_params,
CryptoHandshakeMessage* out, std::string* error_details) const { … }
QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig(
const CryptoHandshakeMessage& message, QuicWallTime now,
QuicTransportVersion , absl::string_view chlo_hash,
const std::vector<std::string>& cached_certs, CachedState* cached,
std::string* error_details) { … }
QuicErrorCode QuicCryptoClientConfig::ProcessRejection(
const CryptoHandshakeMessage& rej, QuicWallTime now,
const QuicTransportVersion version, absl::string_view chlo_hash,
CachedState* cached,
quiche::QuicheReferenceCountedPointer<QuicCryptoNegotiatedParameters>
out_params,
std::string* error_details) { … }
QuicErrorCode QuicCryptoClientConfig::ProcessServerHello(
const CryptoHandshakeMessage& server_hello,
QuicConnectionId , ParsedQuicVersion version,
const ParsedQuicVersionVector& negotiated_versions, CachedState* cached,
quiche::QuicheReferenceCountedPointer<QuicCryptoNegotiatedParameters>
out_params,
std::string* error_details) { … }
QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate(
const CryptoHandshakeMessage& server_config_update, QuicWallTime now,
const QuicTransportVersion version, absl::string_view chlo_hash,
CachedState* cached,
quiche::QuicheReferenceCountedPointer<QuicCryptoNegotiatedParameters>
out_params,
std::string* error_details) { … }
ProofVerifier* QuicCryptoClientConfig::proof_verifier() const { … }
SessionCache* QuicCryptoClientConfig::session_cache() const { … }
void QuicCryptoClientConfig::set_session_cache(
std::shared_ptr<SessionCache> session_cache) { … }
ClientProofSource* QuicCryptoClientConfig::proof_source() const { … }
void QuicCryptoClientConfig::set_proof_source(
std::unique_ptr<ClientProofSource> proof_source) { … }
SSL_CTX* QuicCryptoClientConfig::ssl_ctx() const { … }
void QuicCryptoClientConfig::InitializeFrom(
const QuicServerId& server_id, const QuicServerId& canonical_server_id,
QuicCryptoClientConfig* canonical_crypto_config) { … }
void QuicCryptoClientConfig::AddCanonicalSuffix(const std::string& suffix) { … }
bool QuicCryptoClientConfig::PopulateFromCanonicalConfig(
const QuicServerId& server_id, CachedState* cached) { … }
}