#ifndef QUICHE_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
#define QUICHE_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <utility>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "openssl/evp.h"
#include "quiche/quic/core/crypto/crypto_framer.h"
#include "quiche/quic/core/crypto/quic_random.h"
#include "quiche/quic/core/quic_connection.h"
#include "quiche/quic/core/quic_framer.h"
#include "quiche/quic/core/quic_packets.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/test_tools/quic_test_utils.h"
#include "quiche/common/quiche_callbacks.h"
namespace quic {
class ProofSource;
class ProofVerifier;
class ProofVerifyContext;
class QuicClock;
class QuicConfig;
class QuicCryptoClientStream;
class QuicCryptoServerConfig;
class QuicCryptoServerStreamBase;
class QuicCryptoStream;
class QuicServerId;
namespace test {
class PacketSaver;
class PacketSavingConnection;
namespace crypto_test_utils {
class CallbackSource { … };
struct FakeClientOptions { … };
std::unique_ptr<QuicCryptoServerConfig> CryptoServerConfigForTesting();
int HandshakeWithFakeServer(QuicConfig* server_quic_config,
QuicCryptoServerConfig* crypto_config,
MockQuicConnectionHelper* helper,
MockAlarmFactory* alarm_factory,
PacketSavingConnection* client_conn,
QuicCryptoClientStreamBase* client,
std::string alpn);
int HandshakeWithFakeClient(MockQuicConnectionHelper* helper,
MockAlarmFactory* alarm_factory,
PacketSavingConnection* server_conn,
QuicCryptoServerStreamBase* server,
const QuicServerId& server_id,
const FakeClientOptions& options, std::string alpn);
void SetupCryptoServerConfigForTest(const QuicClock* clock, QuicRandom* rand,
QuicCryptoServerConfig* crypto_config);
void SendHandshakeMessageToStream(QuicCryptoStream* stream,
const CryptoHandshakeMessage& message,
Perspective perspective);
void CommunicateHandshakeMessages(PacketSavingConnection* client_conn,
QuicCryptoStream* client,
PacketSavingConnection* server_conn,
QuicCryptoStream* server);
void CommunicateHandshakeMessages(QuicConnection& client_conn,
QuicCryptoStream& client,
QuicConnection& server_conn,
QuicCryptoStream& server,
PacketProvider& packets_from_client,
PacketProvider& packets_from_server);
bool CommunicateHandshakeMessagesUntil(
PacketSavingConnection* client_conn, QuicCryptoStream* client,
quiche::UnretainedCallback<bool()> client_condition,
PacketSavingConnection* server_conn, QuicCryptoStream* server,
quiche::UnretainedCallback<bool()> server_condition,
bool process_stream_data);
bool CommunicateHandshakeMessagesUntil(
QuicConnection& client_conn, QuicCryptoStream& client,
quiche::UnretainedCallback<bool()> client_condition,
QuicConnection& server_conn, QuicCryptoStream& server,
quiche::UnretainedCallback<bool()> server_condition,
bool process_stream_data, PacketProvider& packets_from_client,
PacketProvider& packets_from_server);
std::pair<size_t, size_t> AdvanceHandshake(PacketSavingConnection* client_conn,
QuicCryptoStream* client,
size_t client_i,
PacketSavingConnection* server_conn,
QuicCryptoStream* server,
size_t server_i);
void AdvanceHandshake(
absl::Span<const QuicEncryptedPacket* const> packets_from_client,
QuicConnection& client_conn, QuicCryptoStream& client,
absl::Span<const QuicEncryptedPacket* const> packets_from_server,
QuicConnection& server_conn, QuicCryptoStream& server);
std::string GetValueForTag(const CryptoHandshakeMessage& message, QuicTag tag);
std::unique_ptr<ProofSource> ProofSourceForTesting();
std::unique_ptr<ProofVerifier> ProofVerifierForTesting();
std::string CertificateHostnameForTesting();
uint64_t LeafCertHashForTesting();
std::unique_ptr<ProofVerifyContext> ProofVerifyContextForTesting();
void FillInDummyReject(CryptoHandshakeMessage* rej);
QuicTag ParseTag(const char* tagstr);
CryptoHandshakeMessage CreateCHLO(
std::vector<std::pair<std::string, std::string>> tags_and_values);
CryptoHandshakeMessage CreateCHLO(
std::vector<std::pair<std::string, std::string>> tags_and_values,
int minimum_size_bytes);
CryptoHandshakeMessage GenerateDefaultInchoateCHLO(
const QuicClock* clock, QuicTransportVersion version,
QuicCryptoServerConfig* crypto_config);
void GenerateFullCHLO(
const CryptoHandshakeMessage& inchoate_chlo,
QuicCryptoServerConfig* crypto_config, QuicSocketAddress server_addr,
QuicSocketAddress client_addr, QuicTransportVersion transport_version,
const QuicClock* clock,
quiche::QuicheReferenceCountedPointer<QuicSignedServerConfig> signed_config,
QuicCompressedCertsCache* compressed_certs_cache,
CryptoHandshakeMessage* out);
void CompareClientAndServerKeys(QuicCryptoClientStreamBase* client,
QuicCryptoServerStreamBase* server);
std::string GenerateClientNonceHex(const QuicClock* clock,
QuicCryptoServerConfig* crypto_config);
std::string GenerateClientPublicValuesHex();
}
}
}
#endif