Rename GetConfigPtr to GetTestConfig.
GetConfigPtr was a silly name. GetTestConfig matches the type and GetTestState. Change-Id: I9998437a7be35dbdaab6e460954acf1b95375de0 Reviewed-on: https://boringssl-review.googlesource.com/8024 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
7fcfd3b37a
commit
7e7a82d962
@ -117,11 +117,11 @@ static void TestStateExFree(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
static int g_config_index = 0;
|
||||
static int g_state_index = 0;
|
||||
|
||||
static bool SetConfigPtr(SSL *ssl, const TestConfig *config) {
|
||||
static bool SetTestConfig(SSL *ssl, const TestConfig *config) {
|
||||
return SSL_set_ex_data(ssl, g_config_index, (void *)config) == 1;
|
||||
}
|
||||
|
||||
static const TestConfig *GetConfigPtr(const SSL *ssl) {
|
||||
static const TestConfig *GetTestConfig(const SSL *ssl) {
|
||||
return (const TestConfig *)SSL_get_ex_data(ssl, g_config_index);
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ struct Free {
|
||||
|
||||
static bool GetCertificate(SSL *ssl, ScopedX509 *out_x509,
|
||||
ScopedEVP_PKEY *out_pkey) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
|
||||
if (!config->digest_prefs.empty()) {
|
||||
std::unique_ptr<char, Free<char>> digest_prefs(
|
||||
@ -353,7 +353,7 @@ static bool InstallCertificate(SSL *ssl) {
|
||||
|
||||
if (pkey) {
|
||||
TestState *test_state = GetTestState(ssl);
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
if (config->async) {
|
||||
test_state->private_key = std::move(pkey);
|
||||
SSL_set_private_key_method(ssl, &g_async_private_key_method);
|
||||
@ -370,7 +370,7 @@ static bool InstallCertificate(SSL *ssl) {
|
||||
}
|
||||
|
||||
static int SelectCertificateCallback(const struct ssl_early_callback_ctx *ctx) {
|
||||
const TestConfig *config = GetConfigPtr(ctx->ssl);
|
||||
const TestConfig *config = GetTestConfig(ctx->ssl);
|
||||
GetTestState(ctx->ssl)->early_callback_called = true;
|
||||
|
||||
if (!config->expected_server_name.empty()) {
|
||||
@ -422,7 +422,7 @@ static int SelectCertificateCallback(const struct ssl_early_callback_ctx *ctx) {
|
||||
}
|
||||
|
||||
static int ClientCertCallback(SSL *ssl, X509 **out_x509, EVP_PKEY **out_pkey) {
|
||||
if (GetConfigPtr(ssl)->async && !GetTestState(ssl)->cert_ready) {
|
||||
if (GetTestConfig(ssl)->async && !GetTestState(ssl)->cert_ready) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -446,7 +446,7 @@ static int ClientCertCallback(SSL *ssl, X509 **out_x509, EVP_PKEY **out_pkey) {
|
||||
static int VerifySucceed(X509_STORE_CTX *store_ctx, void *arg) {
|
||||
SSL* ssl = (SSL*)X509_STORE_CTX_get_ex_data(store_ctx,
|
||||
SSL_get_ex_data_X509_STORE_CTX_idx());
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
|
||||
if (!config->expected_ocsp_response.empty()) {
|
||||
const uint8_t *data;
|
||||
@ -468,7 +468,7 @@ static int VerifyFail(X509_STORE_CTX *store_ctx, void *arg) {
|
||||
|
||||
static int NextProtosAdvertisedCallback(SSL *ssl, const uint8_t **out,
|
||||
unsigned int *out_len, void *arg) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
if (config->advertise_npn.empty()) {
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
}
|
||||
@ -480,7 +480,7 @@ static int NextProtosAdvertisedCallback(SSL *ssl, const uint8_t **out,
|
||||
|
||||
static int NextProtoSelectCallback(SSL* ssl, uint8_t** out, uint8_t* outlen,
|
||||
const uint8_t* in, unsigned inlen, void* arg) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
if (config->select_next_proto.empty()) {
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
}
|
||||
@ -492,7 +492,7 @@ static int NextProtoSelectCallback(SSL* ssl, uint8_t** out, uint8_t* outlen,
|
||||
|
||||
static int AlpnSelectCallback(SSL* ssl, const uint8_t** out, uint8_t* outlen,
|
||||
const uint8_t* in, unsigned inlen, void* arg) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
if (config->decline_alpn) {
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
}
|
||||
@ -514,7 +514,7 @@ static unsigned PskClientCallback(SSL *ssl, const char *hint,
|
||||
char *out_identity,
|
||||
unsigned max_identity_len,
|
||||
uint8_t *out_psk, unsigned max_psk_len) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
|
||||
if (strcmp(hint ? hint : "", config->psk_identity.c_str()) != 0) {
|
||||
fprintf(stderr, "Server PSK hint did not match.\n");
|
||||
@ -536,7 +536,7 @@ static unsigned PskClientCallback(SSL *ssl, const char *hint,
|
||||
|
||||
static unsigned PskServerCallback(SSL *ssl, const char *identity,
|
||||
uint8_t *out_psk, unsigned max_psk_len) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
|
||||
if (strcmp(identity, config->psk_identity.c_str()) != 0) {
|
||||
fprintf(stderr, "Client PSK identity did not match.\n");
|
||||
@ -584,7 +584,7 @@ static SSL_SESSION *GetSessionCallback(SSL *ssl, uint8_t *data, int len,
|
||||
}
|
||||
|
||||
static int DDoSCallback(const struct ssl_early_callback_ctx *early_context) {
|
||||
const TestConfig *config = GetConfigPtr(early_context->ssl);
|
||||
const TestConfig *config = GetTestConfig(early_context->ssl);
|
||||
static int callback_num = 0;
|
||||
|
||||
callback_num++;
|
||||
@ -597,7 +597,7 @@ static int DDoSCallback(const struct ssl_early_callback_ctx *early_context) {
|
||||
|
||||
static void InfoCallback(const SSL *ssl, int type, int val) {
|
||||
if (type == SSL_CB_HANDSHAKE_DONE) {
|
||||
if (GetConfigPtr(ssl)->handshake_never_done) {
|
||||
if (GetTestConfig(ssl)->handshake_never_done) {
|
||||
fprintf(stderr, "handshake completed\n");
|
||||
// Abort before any expected error code is printed, to ensure the overall
|
||||
// test fails.
|
||||
@ -633,7 +633,7 @@ static int TicketKeyCallback(SSL *ssl, uint8_t *key_name, uint8_t *iv,
|
||||
}
|
||||
|
||||
if (!encrypt) {
|
||||
return GetConfigPtr(ssl)->renew_ticket ? 2 : 1;
|
||||
return GetTestConfig(ssl)->renew_ticket ? 2 : 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -655,10 +655,10 @@ static int CustomExtensionAddCallback(SSL *ssl, unsigned extension_value,
|
||||
abort();
|
||||
}
|
||||
|
||||
if (GetConfigPtr(ssl)->custom_extension_skip) {
|
||||
if (GetTestConfig(ssl)->custom_extension_skip) {
|
||||
return 0;
|
||||
}
|
||||
if (GetConfigPtr(ssl)->custom_extension_fail_add) {
|
||||
if (GetTestConfig(ssl)->custom_extension_fail_add) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -888,7 +888,7 @@ static bool RetryAsync(SSL *ssl, int ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
TestState *test_state = GetTestState(ssl);
|
||||
if (test_state->clock_delta.tv_usec != 0 ||
|
||||
test_state->clock_delta.tv_sec != 0) {
|
||||
@ -926,7 +926,7 @@ static bool RetryAsync(SSL *ssl, int ret) {
|
||||
AsyncBioAllowWrite(test_state->async_bio, 1);
|
||||
return true;
|
||||
case SSL_ERROR_WANT_CHANNEL_ID_LOOKUP: {
|
||||
ScopedEVP_PKEY pkey = LoadPrivateKey(GetConfigPtr(ssl)->send_channel_id);
|
||||
ScopedEVP_PKEY pkey = LoadPrivateKey(GetTestConfig(ssl)->send_channel_id);
|
||||
if (!pkey) {
|
||||
return false;
|
||||
}
|
||||
@ -953,7 +953,7 @@ static bool RetryAsync(SSL *ssl, int ret) {
|
||||
// DoRead reads from |ssl|, resolving any asynchronous operations. It returns
|
||||
// the result value of the final |SSL_read| call.
|
||||
static int DoRead(SSL *ssl, uint8_t *out, size_t max_out) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
TestState *test_state = GetTestState(ssl);
|
||||
int ret;
|
||||
do {
|
||||
@ -974,7 +974,7 @@ static int DoRead(SSL *ssl, uint8_t *out, size_t max_out) {
|
||||
// WriteAll writes |in_len| bytes from |in| to |ssl|, resolving any asynchronous
|
||||
// operations. It returns the result of the final |SSL_write| call.
|
||||
static int WriteAll(SSL *ssl, const uint8_t *in, size_t in_len) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
int ret;
|
||||
do {
|
||||
ret = SSL_write(ssl, in, in_len);
|
||||
@ -989,7 +989,7 @@ static int WriteAll(SSL *ssl, const uint8_t *in, size_t in_len) {
|
||||
// DoShutdown calls |SSL_shutdown|, resolving any asynchronous operations. It
|
||||
// returns the result of the final |SSL_shutdown| call.
|
||||
static int DoShutdown(SSL *ssl) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
int ret;
|
||||
do {
|
||||
ret = SSL_shutdown(ssl);
|
||||
@ -1001,7 +1001,7 @@ static int DoShutdown(SSL *ssl) {
|
||||
// initial handshake (or False Starts), whether all the properties are
|
||||
// consistent with the test configuration and invariants.
|
||||
static bool CheckHandshakeProperties(SSL *ssl, bool is_resume) {
|
||||
const TestConfig *config = GetConfigPtr(ssl);
|
||||
const TestConfig *config = GetTestConfig(ssl);
|
||||
|
||||
if (SSL_get_current_cipher(ssl) == nullptr) {
|
||||
fprintf(stderr, "null cipher after handshake\n");
|
||||
@ -1187,7 +1187,7 @@ static bool DoExchange(ScopedSSL_SESSION *out_session, SSL_CTX *ssl_ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetConfigPtr(ssl.get(), config) ||
|
||||
if (!SetTestConfig(ssl.get(), config) ||
|
||||
!SetTestState(ssl.get(), std::unique_ptr<TestState>(new TestState))) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user