diff options
Diffstat (limited to 'test/core/tsi/ssl_transport_security_test.c')
-rw-r--r-- | test/core/tsi/ssl_transport_security_test.c | 204 |
1 files changed, 101 insertions, 103 deletions
diff --git a/test/core/tsi/ssl_transport_security_test.c b/test/core/tsi/ssl_transport_security_test.c index 2399b054b1..ad133bcd6c 100644 --- a/test/core/tsi/ssl_transport_security_test.c +++ b/test/core/tsi/ssl_transport_security_test.c @@ -52,8 +52,8 @@ typedef enum AlpnMode { typedef struct ssl_alpn_lib { AlpnMode alpn_mode; - char **server_alpn_protocols; - char **client_alpn_protocols; + char** server_alpn_protocols; + char** client_alpn_protocols; uint16_t num_server_alpn_protocols; uint16_t num_client_alpn_protocols; } ssl_alpn_lib; @@ -61,9 +61,9 @@ typedef struct ssl_alpn_lib { typedef struct ssl_key_cert_lib { bool use_bad_server_cert; bool use_bad_client_cert; - char *root_cert; - tsi_ssl_pem_key_cert_pair *server_pem_key_cert_pairs; - tsi_ssl_pem_key_cert_pair *bad_server_pem_key_cert_pairs; + char* root_cert; + tsi_ssl_pem_key_cert_pair* server_pem_key_cert_pairs; + tsi_ssl_pem_key_cert_pair* bad_server_pem_key_cert_pairs; tsi_ssl_pem_key_cert_pair client_pem_key_cert_pair; tsi_ssl_pem_key_cert_pair bad_client_pem_key_cert_pair; uint16_t server_num_key_cert_pairs; @@ -72,29 +72,29 @@ typedef struct ssl_key_cert_lib { typedef struct ssl_tsi_test_fixture { tsi_test_fixture base; - ssl_key_cert_lib *key_cert_lib; - ssl_alpn_lib *alpn_lib; + ssl_key_cert_lib* key_cert_lib; + ssl_alpn_lib* alpn_lib; bool force_client_auth; - char *server_name_indication; - tsi_ssl_server_handshaker_factory *server_handshaker_factory; - tsi_ssl_client_handshaker_factory *client_handshaker_factory; + char* server_name_indication; + tsi_ssl_server_handshaker_factory* server_handshaker_factory; + tsi_ssl_client_handshaker_factory* client_handshaker_factory; } ssl_tsi_test_fixture; -static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; +static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) { + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->key_cert_lib != NULL); GPR_ASSERT(ssl_fixture->alpn_lib != NULL); - ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib; - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; + ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; /* Create client handshaker factory. */ - tsi_ssl_pem_key_cert_pair *client_key_cert_pair = NULL; + tsi_ssl_pem_key_cert_pair* client_key_cert_pair = NULL; if (ssl_fixture->force_client_auth) { client_key_cert_pair = key_cert_lib->use_bad_client_cert ? &key_cert_lib->bad_client_pem_key_cert_pair : &key_cert_lib->client_pem_key_cert_pair; } - char **client_alpn_protocols = NULL; + char** client_alpn_protocols = NULL; uint16_t num_client_alpn_protocols = 0; if (alpn_lib->alpn_mode == ALPN_CLIENT_NO_SERVER || alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK || @@ -104,11 +104,10 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { } GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( client_key_cert_pair, key_cert_lib->root_cert, NULL, - (const char **)client_alpn_protocols, - num_client_alpn_protocols, + (const char**)client_alpn_protocols, num_client_alpn_protocols, &ssl_fixture->client_handshaker_factory) == TSI_OK); /* Create server handshaker factory. */ - char **server_alpn_protocols = NULL; + char** server_alpn_protocols = NULL; uint16_t num_server_alpn_protocols = 0; if (alpn_lib->alpn_mode == ALPN_SERVER_NO_CLIENT || alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK || @@ -127,18 +126,17 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { ? key_cert_lib->bad_server_num_key_cert_pairs : key_cert_lib->server_num_key_cert_pairs, key_cert_lib->root_cert, ssl_fixture->force_client_auth, NULL, - (const char **)server_alpn_protocols, - num_server_alpn_protocols, + (const char**)server_alpn_protocols, num_server_alpn_protocols, &ssl_fixture->server_handshaker_factory) == TSI_OK); /* Create server and client handshakers. */ - tsi_handshaker *client_handshaker = NULL; + tsi_handshaker* client_handshaker = NULL; GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker( ssl_fixture->client_handshaker_factory, ssl_fixture->server_name_indication, &client_handshaker) == TSI_OK); ssl_fixture->base.client_handshaker = tsi_create_adapter_handshaker(client_handshaker); - tsi_handshaker *server_handshaker = NULL; + tsi_handshaker* server_handshaker = NULL; GPR_ASSERT(tsi_ssl_server_handshaker_factory_create_handshaker( ssl_fixture->server_handshaker_factory, &server_handshaker) == TSI_OK); @@ -146,40 +144,40 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { tsi_create_adapter_handshaker(server_handshaker); } -static void check_alpn(ssl_tsi_test_fixture *ssl_fixture, - const tsi_peer *peer) { +static void check_alpn(ssl_tsi_test_fixture* ssl_fixture, + const tsi_peer* peer) { GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->alpn_lib != NULL); - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; - const tsi_peer_property *alpn_property = + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; + const tsi_peer_property* alpn_property = tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL); if (alpn_lib->alpn_mode != ALPN_CLIENT_SERVER_OK) { GPR_ASSERT(alpn_property == NULL); } else { GPR_ASSERT(alpn_property != NULL); - const char *expected_match = "baz"; + const char* expected_match = "baz"; GPR_ASSERT(memcmp(alpn_property->value.data, expected_match, alpn_property->value.length) == 0); } } -static const tsi_peer_property * -check_basic_authenticated_peer_and_get_common_name(const tsi_peer *peer) { - const tsi_peer_property *cert_type_property = +static const tsi_peer_property* +check_basic_authenticated_peer_and_get_common_name(const tsi_peer* peer) { + const tsi_peer_property* cert_type_property = tsi_peer_get_property_by_name(peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY); GPR_ASSERT(cert_type_property != NULL); GPR_ASSERT(memcmp(cert_type_property->value.data, TSI_X509_CERTIFICATE_TYPE, cert_type_property->value.length) == 0); - const tsi_peer_property *property = tsi_peer_get_property_by_name( + const tsi_peer_property* property = tsi_peer_get_property_by_name( peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY); GPR_ASSERT(property != NULL); return property; } -void check_server0_peer(tsi_peer *peer) { - const tsi_peer_property *property = +void check_server0_peer(tsi_peer* peer) { + const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); - const char *expected_match = "*.test.google.com.au"; + const char* expected_match = "*.test.google.com.au"; GPR_ASSERT(memcmp(property->value.data, expected_match, property->value.length) == 0); GPR_ASSERT(tsi_peer_get_property_by_name( @@ -194,9 +192,9 @@ void check_server0_peer(tsi_peer *peer) { tsi_peer_destruct(peer); } -static bool check_subject_alt_name(tsi_peer *peer, const char *name) { +static bool check_subject_alt_name(tsi_peer* peer, const char* name) { for (size_t i = 0; i < peer->property_count; i++) { - const tsi_peer_property *prop = &peer->properties[i]; + const tsi_peer_property* prop = &peer->properties[i]; if (strcmp(prop->name, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) { if (memcmp(prop->value.data, name, prop->value.length) == 0) { @@ -207,10 +205,10 @@ static bool check_subject_alt_name(tsi_peer *peer, const char *name) { return false; } -void check_server1_peer(tsi_peer *peer) { - const tsi_peer_property *property = +void check_server1_peer(tsi_peer* peer) { + const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); - const char *expected_match = "*.test.google.com"; + const char* expected_match = "*.test.google.com"; GPR_ASSERT(memcmp(property->value.data, expected_match, property->value.length) == 0); GPR_ASSERT(check_subject_alt_name(peer, "*.test.google.fr") == 1); @@ -226,29 +224,29 @@ void check_server1_peer(tsi_peer *peer) { tsi_peer_destruct(peer); } -static void check_client_peer(ssl_tsi_test_fixture *ssl_fixture, - tsi_peer *peer) { +static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture, + tsi_peer* peer) { GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->alpn_lib != NULL); - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; if (!ssl_fixture->force_client_auth) { GPR_ASSERT(peer->property_count == (alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ? 1 : 0)); } else { - const tsi_peer_property *property = + const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); - const char *expected_match = "testclient"; + const char* expected_match = "testclient"; GPR_ASSERT(memcmp(property->value.data, expected_match, property->value.length) == 0); } tsi_peer_destruct(peer); } -static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) { - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; +static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) { + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->key_cert_lib != NULL); - ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib; + ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; tsi_peer peer; bool expect_success = !(key_cert_lib->use_bad_server_cert || @@ -277,17 +275,17 @@ static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) { } static void ssl_test_pem_key_cert_pair_destroy(tsi_ssl_pem_key_cert_pair kp) { - gpr_free((void *)kp.private_key); - gpr_free((void *)kp.cert_chain); + gpr_free((void*)kp.private_key); + gpr_free((void*)kp.cert_chain); } -static void ssl_test_destruct(tsi_test_fixture *fixture) { - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; +static void ssl_test_destruct(tsi_test_fixture* fixture) { + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; if (ssl_fixture == NULL) { return; } /* Destroy ssl_alpn_lib. */ - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; for (size_t i = 0; i < alpn_lib->num_server_alpn_protocols; i++) { gpr_free(alpn_lib->server_alpn_protocols[i]); } @@ -298,7 +296,7 @@ static void ssl_test_destruct(tsi_test_fixture *fixture) { gpr_free(alpn_lib->client_alpn_protocols); gpr_free(alpn_lib); /* Destroy ssl_key_cert_lib. */ - ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib; + ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; for (size_t i = 0; i < key_cert_lib->server_num_key_cert_pairs; i++) { ssl_test_pem_key_cert_pair_destroy( key_cert_lib->server_pem_key_cert_pairs[i]); @@ -325,26 +323,26 @@ static const struct tsi_test_fixture_vtable vtable = { ssl_test_setup_handshakers, ssl_test_check_handshaker_peers, ssl_test_destruct}; -static char *load_file(const char *dir_path, const char *file_name) { - char *file_path = +static char* load_file(const char* dir_path, const char* file_name) { + char* file_path = gpr_zalloc(sizeof(char) * (strlen(dir_path) + strlen(file_name) + 1)); memcpy(file_path, dir_path, strlen(dir_path)); memcpy(file_path + strlen(dir_path), file_name, strlen(file_name)); grpc_slice slice; GPR_ASSERT(grpc_load_file(file_path, 1, &slice) == GRPC_ERROR_NONE); - char *data = grpc_slice_to_c_string(slice); + char* data = grpc_slice_to_c_string(slice); grpc_slice_unref(slice); gpr_free(file_path); return data; } -static tsi_test_fixture *ssl_tsi_test_fixture_create() { - ssl_tsi_test_fixture *ssl_fixture = gpr_zalloc(sizeof(*ssl_fixture)); +static tsi_test_fixture* ssl_tsi_test_fixture_create() { + ssl_tsi_test_fixture* ssl_fixture = gpr_zalloc(sizeof(*ssl_fixture)); tsi_test_fixture_init(&ssl_fixture->base); ssl_fixture->base.test_unused_bytes = false; ssl_fixture->base.vtable = &vtable; /* Create ssl_key_cert_lib. */ - ssl_key_cert_lib *key_cert_lib = gpr_zalloc(sizeof(*key_cert_lib)); + ssl_key_cert_lib* key_cert_lib = gpr_zalloc(sizeof(*key_cert_lib)); key_cert_lib->use_bad_server_cert = false; key_cert_lib->use_bad_client_cert = false; key_cert_lib->server_num_key_cert_pairs = @@ -380,11 +378,11 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() { key_cert_lib->root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem"); ssl_fixture->key_cert_lib = key_cert_lib; /* Create ssl_alpn_lib. */ - ssl_alpn_lib *alpn_lib = gpr_zalloc(sizeof(*alpn_lib)); + ssl_alpn_lib* alpn_lib = gpr_zalloc(sizeof(*alpn_lib)); alpn_lib->server_alpn_protocols = - gpr_zalloc(sizeof(char *) * SSL_TSI_TEST_ALPN_NUM); + gpr_zalloc(sizeof(char*) * SSL_TSI_TEST_ALPN_NUM); alpn_lib->client_alpn_protocols = - gpr_zalloc(sizeof(char *) * SSL_TSI_TEST_ALPN_NUM); + gpr_zalloc(sizeof(char*) * SSL_TSI_TEST_ALPN_NUM); alpn_lib->server_alpn_protocols[0] = gpr_strdup(SSL_TSI_TEST_ALPN1); alpn_lib->server_alpn_protocols[1] = gpr_strdup(SSL_TSI_TEST_ALPN3); alpn_lib->client_alpn_protocols[0] = gpr_strdup(SSL_TSI_TEST_ALPN2); @@ -400,28 +398,28 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() { } void ssl_tsi_test_do_handshake_tiny_handshake_buffer() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_small_handshake_buffer() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_client_authentication() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->force_client_auth = true; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); @@ -429,8 +427,8 @@ void ssl_tsi_test_do_handshake_with_client_authentication() { void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() { /* server1 cert contains "waterzooi.test.google.be" in SAN. */ - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->server_name_indication = "waterzooi.test.google.be"; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); @@ -438,24 +436,24 @@ void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() { void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain() { /* server1 cert contains "*.test.google.fr" in SAN. */ - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->server_name_indication = "juju.test.google.fr"; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_bad_server_cert() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->key_cert_lib->use_bad_server_cert = true; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_bad_client_cert() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->key_cert_lib->use_bad_client_cert = true; ssl_fixture->force_client_auth = true; tsi_test_do_handshake(fixture); @@ -463,39 +461,39 @@ void ssl_tsi_test_do_handshake_with_bad_client_cert() { } void ssl_tsi_test_do_handshake_alpn_client_no_server() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_NO_SERVER; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_alpn_server_no_client() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_SERVER_NO_CLIENT; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_alpn_client_server_mismatch() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_MISMATCH; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_alpn_client_server_ok() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_OK; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_round_trip_for_all_configs() { - unsigned int *bit_array = + unsigned int* bit_array = gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS); const unsigned int mask = 1U << (TSI_TEST_NUM_OF_ARGUMENTS - 1); for (unsigned int val = 0; val < TSI_TEST_NUM_OF_COMBINATIONS; val++) { @@ -504,8 +502,8 @@ void ssl_tsi_test_do_round_trip_for_all_configs() { bit_array[ind] = (v & mask) ? 1 : 0; v <<= 1; } - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; tsi_test_frame_protector_config_destroy(ssl_fixture->base.config); ssl_fixture->base.config = tsi_test_frame_protector_config_create( bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4], @@ -524,8 +522,8 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() { for (size_t ind3 = 0; ind3 < size; ind3++) { for (size_t ind4 = 0; ind4 < size; ind4++) { for (size_t ind5 = 0; ind5 < size; ind5++) { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; tsi_test_frame_protector_config_set_buffer_size( ssl_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2], odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]); @@ -538,11 +536,11 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() { } } -static const tsi_ssl_handshaker_factory_vtable *original_vtable; +static const tsi_ssl_handshaker_factory_vtable* original_vtable; static bool handshaker_factory_destructor_called; static void ssl_tsi_test_handshaker_factory_destructor( - tsi_ssl_handshaker_factory *factory) { + tsi_ssl_handshaker_factory* factory) { GPR_ASSERT(factory != NULL); handshaker_factory_destructor_called = true; if (original_vtable != NULL && original_vtable->destroy != NULL) { @@ -555,20 +553,20 @@ static tsi_ssl_handshaker_factory_vtable test_handshaker_factory_vtable = { void test_tsi_ssl_client_handshaker_factory_refcounting() { int i; - const char *cert_chain = + const char* cert_chain = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "client.pem"); - tsi_ssl_client_handshaker_factory *client_handshaker_factory; + tsi_ssl_client_handshaker_factory* client_handshaker_factory; GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( NULL, cert_chain, NULL, NULL, 0, &client_handshaker_factory) == TSI_OK); handshaker_factory_destructor_called = false; original_vtable = tsi_ssl_handshaker_factory_swap_vtable( - (tsi_ssl_handshaker_factory *)client_handshaker_factory, + (tsi_ssl_handshaker_factory*)client_handshaker_factory, &test_handshaker_factory_vtable); - tsi_handshaker *handshaker[3]; + tsi_handshaker* handshaker[3]; for (i = 0; i < 3; ++i) { GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker( @@ -588,14 +586,14 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() { tsi_handshaker_destroy(handshaker[2]); GPR_ASSERT(handshaker_factory_destructor_called); - gpr_free((void *)cert_chain); + gpr_free((void*)cert_chain); } void test_tsi_ssl_server_handshaker_factory_refcounting() { int i; - tsi_ssl_server_handshaker_factory *server_handshaker_factory; - tsi_handshaker *handshaker[3]; - const char *cert_chain = + tsi_ssl_server_handshaker_factory* server_handshaker_factory; + tsi_handshaker* handshaker[3]; + const char* cert_chain = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "server0.pem"); tsi_ssl_pem_key_cert_pair cert_pair; @@ -609,7 +607,7 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() { handshaker_factory_destructor_called = false; original_vtable = tsi_ssl_handshaker_factory_swap_vtable( - (tsi_ssl_handshaker_factory *)server_handshaker_factory, + (tsi_ssl_handshaker_factory*)server_handshaker_factory, &test_handshaker_factory_vtable); for (i = 0; i < 3; ++i) { @@ -635,9 +633,9 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() { /* Attempting to create a handshaker factory with invalid parameters should fail * but not crash. */ void test_tsi_ssl_client_handshaker_factory_bad_params() { - const char *cert_chain = "This is not a valid PEM file."; + const char* cert_chain = "This is not a valid PEM file."; - tsi_ssl_client_handshaker_factory *client_handshaker_factory; + tsi_ssl_client_handshaker_factory* client_handshaker_factory; GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( NULL, cert_chain, NULL, NULL, 0, &client_handshaker_factory) == TSI_INVALID_ARGUMENT); @@ -650,7 +648,7 @@ void ssl_tsi_test_handshaker_factory_internals() { test_tsi_ssl_client_handshaker_factory_bad_params(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); ssl_tsi_test_do_handshake_tiny_handshake_buffer(); |