update master-with-bazel from main branch
This commit is contained in:
@@ -323,8 +323,7 @@ static bool CheckAuthProperties(SSL *ssl, bool is_resume,
|
||||
const uint8_t *data;
|
||||
size_t len;
|
||||
SSL_get0_ocsp_response(ssl, &data, &len);
|
||||
if (bssl::StringAsBytes(config->expect_ocsp_response) !=
|
||||
bssl::Span(data, len)) {
|
||||
if (bssl::Span(config->expect_ocsp_response) != bssl::Span(data, len)) {
|
||||
fprintf(stderr, "OCSP response mismatch\n");
|
||||
return false;
|
||||
}
|
||||
@@ -334,7 +333,7 @@ static bool CheckAuthProperties(SSL *ssl, bool is_resume,
|
||||
const uint8_t *data;
|
||||
size_t len;
|
||||
SSL_get0_signed_cert_timestamp_list(ssl, &data, &len);
|
||||
if (bssl::StringAsBytes(config->expect_signed_cert_timestamps) !=
|
||||
if (bssl::Span(config->expect_signed_cert_timestamps) !=
|
||||
bssl::Span(data, len)) {
|
||||
fprintf(stderr, "SCT list mismatch\n");
|
||||
return false;
|
||||
@@ -554,7 +553,7 @@ static bool CheckHandshakeProperties(SSL *ssl, bool is_resume,
|
||||
const uint8_t *peer_params;
|
||||
size_t peer_params_len;
|
||||
SSL_get_peer_quic_transport_params(ssl, &peer_params, &peer_params_len);
|
||||
if (bssl::StringAsBytes(config->expect_quic_transport_params) !=
|
||||
if (bssl::Span(config->expect_quic_transport_params) !=
|
||||
bssl::Span(peer_params, peer_params_len)) {
|
||||
fprintf(stderr, "QUIC transport params mismatch\n");
|
||||
return false;
|
||||
@@ -567,7 +566,7 @@ static bool CheckHandshakeProperties(SSL *ssl, bool is_resume,
|
||||
fprintf(stderr, "no channel id negotiated\n");
|
||||
return false;
|
||||
}
|
||||
if (bssl::StringAsBytes(config->expect_channel_id) != channel_id) {
|
||||
if (bssl::Span(config->expect_channel_id) != channel_id) {
|
||||
fprintf(stderr, "channel id mismatch\n");
|
||||
return false;
|
||||
}
|
||||
@@ -907,7 +906,7 @@ static bool DoConnection(bssl::UniquePtr<SSL_SESSION> *out_session,
|
||||
bssl::Span<const uint8_t> expected =
|
||||
config->expect_no_ech_retry_configs
|
||||
? bssl::Span<const uint8_t>()
|
||||
: bssl::StringAsBytes(config->expect_ech_retry_configs);
|
||||
: bssl::Span(config->expect_ech_retry_configs);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Expected ECH rejection, but connection succeeded.\n");
|
||||
return false;
|
||||
|
||||
+23
-32
@@ -147,25 +147,25 @@ Flag<Config> OptionalStringFlag(const char *name,
|
||||
}};
|
||||
}
|
||||
|
||||
bool DecodeBase64(std::string *out, const std::string &in) {
|
||||
bool DecodeBase64(std::vector<uint8_t> *out, const std::string &in) {
|
||||
size_t len;
|
||||
if (!EVP_DecodedLength(&len, in.size())) {
|
||||
fprintf(stderr, "Invalid base64: %s.\n", in.c_str());
|
||||
return false;
|
||||
}
|
||||
std::vector<uint8_t> buf(len);
|
||||
if (!EVP_DecodeBase64(buf.data(), &len, buf.size(),
|
||||
out->resize(len);
|
||||
if (!EVP_DecodeBase64(out->data(), &len, out->size(),
|
||||
reinterpret_cast<const uint8_t *>(in.data()),
|
||||
in.size())) {
|
||||
fprintf(stderr, "Invalid base64: %s.\n", in.c_str());
|
||||
return false;
|
||||
}
|
||||
out->assign(reinterpret_cast<const char *>(buf.data()), len);
|
||||
out->resize(len);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Config>
|
||||
Flag<Config> Base64Flag(const char *name, std::string Config::*field,
|
||||
Flag<Config> Base64Flag(const char *name, std::vector<uint8_t> Config::*field,
|
||||
bool skip_handshaker = false) {
|
||||
return Flag<Config>{name, true, skip_handshaker,
|
||||
[=](Config *config, const char *param) -> bool {
|
||||
@@ -175,11 +175,11 @@ Flag<Config> Base64Flag(const char *name, std::string Config::*field,
|
||||
|
||||
template <typename Config>
|
||||
Flag<Config> Base64VectorFlag(const char *name,
|
||||
std::vector<std::string> Config::*field,
|
||||
std::vector<std::vector<uint8_t>> Config::*field,
|
||||
bool skip_handshaker = false) {
|
||||
return Flag<Config>{name, true, skip_handshaker,
|
||||
[=](Config *config, const char *param) -> bool {
|
||||
std::string value;
|
||||
std::vector<uint8_t> value;
|
||||
if (!DecodeBase64(&value, param)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1385,8 +1385,7 @@ static bssl::UniquePtr<SSL_CREDENTIAL> CredentialFromConfig(
|
||||
|
||||
if (!cred_config.delegated_credential.empty()) {
|
||||
bssl::UniquePtr<CRYPTO_BUFFER> buf(
|
||||
CRYPTO_BUFFER_new(reinterpret_cast<const uint8_t *>(
|
||||
cred_config.delegated_credential.data()),
|
||||
CRYPTO_BUFFER_new(cred_config.delegated_credential.data(),
|
||||
cred_config.delegated_credential.size(), nullptr));
|
||||
if (buf == nullptr ||
|
||||
!SSL_CREDENTIAL_set1_delegated_credential(cred.get(), buf.get())) {
|
||||
@@ -1395,9 +1394,9 @@ static bssl::UniquePtr<SSL_CREDENTIAL> CredentialFromConfig(
|
||||
}
|
||||
|
||||
if (!cred_config.ocsp_response.empty()) {
|
||||
bssl::UniquePtr<CRYPTO_BUFFER> buf(CRYPTO_BUFFER_new(
|
||||
reinterpret_cast<const uint8_t *>(cred_config.ocsp_response.data()),
|
||||
cred_config.ocsp_response.size(), nullptr));
|
||||
bssl::UniquePtr<CRYPTO_BUFFER> buf(
|
||||
CRYPTO_BUFFER_new(cred_config.ocsp_response.data(),
|
||||
cred_config.ocsp_response.size(), nullptr));
|
||||
if (buf == nullptr ||
|
||||
!SSL_CREDENTIAL_set1_ocsp_response(cred.get(), buf.get())) {
|
||||
return nullptr;
|
||||
@@ -1406,8 +1405,7 @@ static bssl::UniquePtr<SSL_CREDENTIAL> CredentialFromConfig(
|
||||
|
||||
if (!cred_config.signed_cert_timestamps.empty()) {
|
||||
bssl::UniquePtr<CRYPTO_BUFFER> buf(
|
||||
CRYPTO_BUFFER_new(reinterpret_cast<const uint8_t *>(
|
||||
cred_config.signed_cert_timestamps.data()),
|
||||
CRYPTO_BUFFER_new(cred_config.signed_cert_timestamps.data(),
|
||||
cred_config.signed_cert_timestamps.size(), nullptr));
|
||||
if (buf == nullptr || !SSL_CREDENTIAL_set1_signed_cert_timestamp_list(
|
||||
cred.get(), buf.get())) {
|
||||
@@ -1576,7 +1574,7 @@ static bool CheckCertificateRequest(SSL *ssl) {
|
||||
const uint8_t *certificate_types;
|
||||
size_t certificate_types_len =
|
||||
SSL_get0_certificate_types(ssl, &certificate_types);
|
||||
if (bssl::StringAsBytes(config->expect_certificate_types) !=
|
||||
if (bssl::Span(config->expect_certificate_types) !=
|
||||
bssl::Span(certificate_types, certificate_types_len)) {
|
||||
fprintf(stderr, "certificate types mismatch.\n");
|
||||
return false;
|
||||
@@ -2217,9 +2215,8 @@ bssl::UniquePtr<SSL> TestConfig::NewSSL(
|
||||
return nullptr;
|
||||
}
|
||||
if (!ech_config_list.empty() &&
|
||||
!SSL_set1_ech_config_list(
|
||||
ssl.get(), reinterpret_cast<const uint8_t *>(ech_config_list.data()),
|
||||
ech_config_list.size())) {
|
||||
!SSL_set1_ech_config_list(ssl.get(), ech_config_list.data(),
|
||||
ech_config_list.size())) {
|
||||
return nullptr;
|
||||
}
|
||||
if (ech_server_configs.size() != ech_server_keys.size() ||
|
||||
@@ -2235,18 +2232,14 @@ bssl::UniquePtr<SSL> TestConfig::NewSSL(
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < ech_server_configs.size(); i++) {
|
||||
const std::string &ech_config = ech_server_configs[i];
|
||||
const std::string &ech_private_key = ech_server_keys[i];
|
||||
bssl::Span<const uint8_t> ech_config = ech_server_configs[i];
|
||||
bssl::Span<const uint8_t> ech_private_key = ech_server_keys[i];
|
||||
const int is_retry_config = ech_is_retry_config[i];
|
||||
bssl::ScopedEVP_HPKE_KEY key;
|
||||
if (!EVP_HPKE_KEY_init(
|
||||
key.get(), EVP_hpke_x25519_hkdf_sha256(),
|
||||
reinterpret_cast<const uint8_t *>(ech_private_key.data()),
|
||||
ech_private_key.size()) ||
|
||||
!SSL_ECH_KEYS_add(
|
||||
keys.get(), is_retry_config,
|
||||
reinterpret_cast<const uint8_t *>(ech_config.data()),
|
||||
ech_config.size(), key.get())) {
|
||||
if (!EVP_HPKE_KEY_init(key.get(), EVP_hpke_x25519_hkdf_sha256(),
|
||||
ech_private_key.data(), ech_private_key.size()) ||
|
||||
!SSL_ECH_KEYS_add(keys.get(), is_retry_config, ech_config.data(),
|
||||
ech_config.size(), key.get())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -2367,10 +2360,8 @@ bssl::UniquePtr<SSL> TestConfig::NewSSL(
|
||||
SSL_set_quic_use_legacy_codepoint(ssl.get(), quic_use_legacy_codepoint);
|
||||
}
|
||||
if (!quic_transport_params.empty()) {
|
||||
if (!SSL_set_quic_transport_params(
|
||||
ssl.get(),
|
||||
reinterpret_cast<const uint8_t *>(quic_transport_params.data()),
|
||||
quic_transport_params.size())) {
|
||||
if (!SSL_set_quic_transport_params(ssl.get(), quic_transport_params.data(),
|
||||
quic_transport_params.size())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -32,9 +32,9 @@ struct CredentialConfig {
|
||||
std::string cert_file;
|
||||
std::string key_file;
|
||||
std::vector<uint16_t> signing_prefs;
|
||||
std::string delegated_credential;
|
||||
std::string ocsp_response;
|
||||
std::string signed_cert_timestamps;
|
||||
std::vector<uint8_t> delegated_credential;
|
||||
std::vector<uint8_t> ocsp_response;
|
||||
std::vector<uint8_t> signed_cert_timestamps;
|
||||
};
|
||||
|
||||
struct TestConfig {
|
||||
@@ -56,16 +56,16 @@ struct TestConfig {
|
||||
std::string trust_cert;
|
||||
std::string expect_server_name;
|
||||
bool enable_ech_grease = false;
|
||||
std::vector<std::string> ech_server_configs;
|
||||
std::vector<std::string> ech_server_keys;
|
||||
std::vector<std::vector<uint8_t>> ech_server_configs;
|
||||
std::vector<std::vector<uint8_t>> ech_server_keys;
|
||||
std::vector<int> ech_is_retry_config;
|
||||
bool expect_ech_accept = false;
|
||||
std::string expect_ech_name_override;
|
||||
bool expect_no_ech_name_override = false;
|
||||
std::string expect_ech_retry_configs;
|
||||
std::vector<uint8_t> expect_ech_retry_configs;
|
||||
bool expect_no_ech_retry_configs = false;
|
||||
std::string ech_config_list;
|
||||
std::string expect_certificate_types;
|
||||
std::vector<uint8_t> ech_config_list;
|
||||
std::vector<uint8_t> expect_certificate_types;
|
||||
bool require_any_client_certificate = false;
|
||||
std::string advertise_npn;
|
||||
bool advertise_empty_npn = false;
|
||||
@@ -83,7 +83,7 @@ struct TestConfig {
|
||||
bool no_tls11 = false;
|
||||
bool no_tls1 = false;
|
||||
bool no_ticket = false;
|
||||
std::string expect_channel_id;
|
||||
std::vector<uint8_t> expect_channel_id;
|
||||
bool enable_channel_id = false;
|
||||
std::string send_channel_id;
|
||||
bool shim_writes_first = false;
|
||||
@@ -99,8 +99,8 @@ struct TestConfig {
|
||||
std::vector<std::pair<std::string, std::string>> application_settings;
|
||||
std::optional<std::string> expect_peer_application_settings;
|
||||
bool alps_use_new_codepoint = false;
|
||||
std::string quic_transport_params;
|
||||
std::string expect_quic_transport_params;
|
||||
std::vector<uint8_t> quic_transport_params;
|
||||
std::vector<uint8_t> expect_quic_transport_params;
|
||||
// Set quic_use_legacy_codepoint to 0 or 1 to configure, -1 uses default.
|
||||
int quic_use_legacy_codepoint = -1;
|
||||
bool expect_session_miss = false;
|
||||
@@ -109,9 +109,9 @@ struct TestConfig {
|
||||
std::string psk_identity;
|
||||
std::string srtp_profiles;
|
||||
bool enable_ocsp_stapling = false;
|
||||
std::string expect_ocsp_response;
|
||||
std::vector<uint8_t> expect_ocsp_response;
|
||||
bool enable_signed_cert_timestamps = false;
|
||||
std::string expect_signed_cert_timestamps;
|
||||
std::vector<uint8_t> expect_signed_cert_timestamps;
|
||||
uint16_t min_version = 0;
|
||||
uint16_t max_version = 0;
|
||||
uint16_t expect_version = 0;
|
||||
@@ -142,14 +142,14 @@ struct TestConfig {
|
||||
bool renew_ticket = false;
|
||||
bool skip_ticket = false;
|
||||
bool enable_early_data = false;
|
||||
std::string ocsp_response;
|
||||
std::vector<uint8_t> ocsp_response;
|
||||
bool check_close_notify = false;
|
||||
bool shim_shuts_down = false;
|
||||
bool verify_fail = false;
|
||||
bool verify_peer = false;
|
||||
bool verify_peer_if_no_obc = false;
|
||||
bool expect_verify_result = false;
|
||||
std::string signed_cert_timestamps;
|
||||
std::vector<uint8_t> signed_cert_timestamps;
|
||||
int expect_total_renegotiations = 0;
|
||||
bool renegotiate_once = false;
|
||||
bool renegotiate_freely = false;
|
||||
@@ -167,7 +167,7 @@ struct TestConfig {
|
||||
bool enable_grease = false;
|
||||
bool permute_extensions = false;
|
||||
int max_cert_list = 0;
|
||||
std::string ticket_key;
|
||||
std::vector<uint8_t> ticket_key;
|
||||
bool use_exporter_between_reads = false;
|
||||
uint16_t expect_cipher_aes = 0;
|
||||
uint16_t expect_cipher_no_aes = 0;
|
||||
|
||||
Reference in New Issue
Block a user