diff options
Diffstat (limited to 'src/core/lib/security/transport')
5 files changed, 51 insertions, 43 deletions
diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index b5171acc87..d2313807ff 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -93,7 +93,8 @@ static void add_error(grpc_error** combined, grpc_error* error) { } static void on_credentials_metadata(void* arg, grpc_error* input_error) { - grpc_transport_stream_op_batch* batch = static_cast<grpc_transport_stream_op_batch*>(arg); + grpc_transport_stream_op_batch* batch = + static_cast<grpc_transport_stream_op_batch*>(arg); grpc_call_element* elem = static_cast<grpc_call_element*>(batch->handler_private.extra_arg); call_data* calld = static_cast<call_data*>(elem->call_data); @@ -173,9 +174,8 @@ static void send_security_metadata(grpc_call_element* elem, call_data* calld = static_cast<call_data*>(elem->call_data); channel_data* chand = static_cast<channel_data*>(elem->channel_data); grpc_client_security_context* ctx = - static_cast<grpc_client_security_context*>(batch->payload - ->context[GRPC_CONTEXT_SECURITY] - .value); + static_cast<grpc_client_security_context*>( + batch->payload->context[GRPC_CONTEXT_SECURITY].value); grpc_call_credentials* channel_call_creds = chand->security_connector->request_metadata_creds; int call_creds_has_md = (ctx != nullptr) && (ctx->creds != nullptr); @@ -231,7 +231,8 @@ static void send_security_metadata(grpc_call_element* elem, } static void on_host_checked(void* arg, grpc_error* error) { - grpc_transport_stream_op_batch* batch = static_cast<grpc_transport_stream_op_batch*>(arg); + grpc_transport_stream_op_batch* batch = + static_cast<grpc_transport_stream_op_batch*>(arg); grpc_call_element* elem = static_cast<grpc_call_element*>(batch->handler_private.extra_arg); call_data* calld = static_cast<call_data*>(elem->call_data); @@ -283,9 +284,8 @@ static void auth_start_transport_stream_op_batch( grpc_client_security_context_destroy; } grpc_client_security_context* sec_ctx = - static_cast<grpc_client_security_context*>(batch->payload - ->context[GRPC_CONTEXT_SECURITY] - .value); + static_cast<grpc_client_security_context*>( + batch->payload->context[GRPC_CONTEXT_SECURITY].value); GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter"); sec_ctx->auth_context = GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter"); @@ -400,8 +400,8 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, /* initialize members */ chand->security_connector = - reinterpret_cast<grpc_channel_security_connector*>(GRPC_SECURITY_CONNECTOR_REF( - sc, "client_auth_filter")); + reinterpret_cast<grpc_channel_security_connector*>( + GRPC_SECURITY_CONNECTOR_REF(sc, "client_auth_filter")); chand->auth_context = GRPC_AUTH_CONTEXT_REF(auth_context, "client_auth_filter"); return GRPC_ERROR_NONE; diff --git a/src/core/lib/security/transport/lb_targets_info.cc b/src/core/lib/security/transport/lb_targets_info.cc index 84a72731c9..67a3c7449d 100644 --- a/src/core/lib/security/transport/lb_targets_info.cc +++ b/src/core/lib/security/transport/lb_targets_info.cc @@ -32,8 +32,9 @@ static void targets_info_destroy(void* p) { grpc_slice_hash_table_unref(static_cast<grpc_slice_hash_table*>(p)); } static int targets_info_cmp(void* a, void* b) { - return grpc_slice_hash_table_cmp(static_cast<const grpc_slice_hash_table*>(a), - static_cast<const grpc_slice_hash_table*>(b)); + return grpc_slice_hash_table_cmp( + static_cast<const grpc_slice_hash_table*>(a), + static_cast<const grpc_slice_hash_table*>(b)); } static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = { targets_info_copy, targets_info_destroy, targets_info_cmp}; @@ -51,7 +52,8 @@ grpc_slice_hash_table* grpc_lb_targets_info_find_in_args( grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP); if (targets_info_arg != nullptr) { GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER); - return static_cast<grpc_slice_hash_table*>(targets_info_arg->value.pointer.p); + return static_cast<grpc_slice_hash_table*>( + targets_info_arg->value.pointer.p); } return nullptr; } diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index a63dbc07c8..f72f8b6121 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -205,7 +205,8 @@ static void on_read(void* user_data, grpc_error* error) { ep->read_buffer, grpc_slice_split_head( &ep->read_staging_buffer, - static_cast<size_t>(cur - GRPC_SLICE_START_PTR(ep->read_staging_buffer)))); + static_cast<size_t>( + cur - GRPC_SLICE_START_PTR(ep->read_staging_buffer)))); } } @@ -324,8 +325,8 @@ static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices, &ep->output_buffer, grpc_slice_split_head( &ep->write_staging_buffer, - static_cast<size_t>(cur - - GRPC_SLICE_START_PTR(ep->write_staging_buffer)))); + static_cast<size_t>( + cur - GRPC_SLICE_START_PTR(ep->write_staging_buffer)))); } } } @@ -403,7 +404,8 @@ grpc_endpoint* grpc_secure_endpoint_create( grpc_endpoint* transport, grpc_slice* leftover_slices, size_t leftover_nslices) { size_t i; - secure_endpoint* ep = static_cast<secure_endpoint*>(gpr_malloc(sizeof(secure_endpoint))); + secure_endpoint* ep = + static_cast<secure_endpoint*>(gpr_malloc(sizeof(secure_endpoint))); ep->base.vtable = &vtable; ep->wrapped_ep = transport; ep->protector = protector; diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc index e9a2d23535..bd5da1bbd2 100644 --- a/src/core/lib/security/transport/security_connector.cc +++ b/src/core/lib/security/transport/security_connector.cc @@ -498,7 +498,8 @@ grpc_channel_security_connector* grpc_fake_channel_security_connector_create( grpc_call_credentials* request_metadata_creds, const char* target, const grpc_channel_args* args) { grpc_fake_channel_security_connector* c = - static_cast<grpc_fake_channel_security_connector*>(gpr_zalloc(sizeof(*c))); + static_cast<grpc_fake_channel_security_connector*>( + gpr_zalloc(sizeof(*c))); gpr_ref_init(&c->base.base.refcount, 1); c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; c->base.base.vtable = &fake_channel_vtable; @@ -518,8 +519,8 @@ grpc_channel_security_connector* grpc_fake_channel_security_connector_create( grpc_server_security_connector* grpc_fake_server_security_connector_create( grpc_server_credentials* server_creds) { grpc_server_security_connector* c = - static_cast<grpc_server_security_connector*>(gpr_zalloc( - sizeof(grpc_server_security_connector))); + static_cast<grpc_server_security_connector*>( + gpr_zalloc(sizeof(grpc_server_security_connector))); gpr_ref_init(&c->base.refcount, 1); c->base.vtable = &fake_server_vtable; c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; @@ -597,8 +598,8 @@ static void ssl_channel_add_handshakers(grpc_channel_security_connector* sc, static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) { GPR_ASSERT(num_alpn_protocols != nullptr); *num_alpn_protocols = grpc_chttp2_num_alpn_versions(); - const char** alpn_protocol_strings = - static_cast<const char**>(gpr_malloc(sizeof(const char*) * (*num_alpn_protocols))); + const char** alpn_protocol_strings = static_cast<const char**>( + gpr_malloc(sizeof(const char*) * (*num_alpn_protocols))); for (size_t i = 0; i < *num_alpn_protocols; i++) { alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i); } @@ -632,8 +633,8 @@ static bool try_replace_server_handshaker_factory( cert_pairs, config->num_key_cert_pairs, config->pem_root_certs, get_tsi_client_certificate_request_type( server_creds->config.client_certificate_request), - ssl_cipher_suites(), alpn_protocol_strings, static_cast<uint16_t>(num_alpn_protocols), - &new_handshaker_factory); + ssl_cipher_suites(), alpn_protocol_strings, + static_cast<uint16_t>(num_alpn_protocols), &new_handshaker_factory); gpr_free(cert_pairs); gpr_free((void*)alpn_protocol_strings); @@ -850,8 +851,8 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context( while (grpc_auth_property_iterator_next(&it) != nullptr) max_num_props++; if (max_num_props > 0) { - peer.properties = static_cast<tsi_peer_property*>(gpr_malloc(max_num_props * - sizeof(tsi_peer_property))); + peer.properties = static_cast<tsi_peer_property*>( + gpr_malloc(max_num_props * sizeof(tsi_peer_property))); it = grpc_auth_context_property_iterator(auth_context); while ((prop = grpc_auth_property_iterator_next(&it)) != nullptr) { if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) { @@ -963,7 +964,8 @@ const char* grpc_get_default_ssl_roots(void) { gpr_once_init(&once, init_default_pem_root_certs); return GRPC_SLICE_IS_EMPTY(default_pem_root_certs) ? nullptr - : reinterpret_cast<const char*>GRPC_SLICE_START_PTR(default_pem_root_certs); + : reinterpret_cast<const char*> + GRPC_SLICE_START_PTR(default_pem_root_certs); } grpc_security_status grpc_ssl_channel_security_connector_create( @@ -994,8 +996,8 @@ grpc_security_status grpc_ssl_channel_security_connector_create( pem_root_certs = config->pem_root_certs; } - c = static_cast<grpc_ssl_channel_security_connector*>(gpr_zalloc( - sizeof(grpc_ssl_channel_security_connector))); + c = static_cast<grpc_ssl_channel_security_connector*>( + gpr_zalloc(sizeof(grpc_ssl_channel_security_connector))); gpr_ref_init(&c->base.base.refcount, 1); c->base.base.vtable = &ssl_channel_vtable; @@ -1017,8 +1019,8 @@ grpc_security_status grpc_ssl_channel_security_connector_create( config->pem_key_cert_pair->cert_chain != nullptr; result = tsi_create_ssl_client_handshaker_factory( has_key_cert_pair ? config->pem_key_cert_pair : nullptr, pem_root_certs, - ssl_cipher_suites(), alpn_protocol_strings, static_cast<uint16_t>(num_alpn_protocols), - &c->client_handshaker_factory); + ssl_cipher_suites(), alpn_protocol_strings, + static_cast<uint16_t>(num_alpn_protocols), &c->client_handshaker_factory); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); @@ -1039,8 +1041,8 @@ static grpc_ssl_server_security_connector* grpc_ssl_server_security_connector_initialize( grpc_server_credentials* server_creds) { grpc_ssl_server_security_connector* c = - static_cast<grpc_ssl_server_security_connector*>(gpr_zalloc( - sizeof(grpc_ssl_server_security_connector))); + static_cast<grpc_ssl_server_security_connector*>( + gpr_zalloc(sizeof(grpc_ssl_server_security_connector))); gpr_ref_init(&c->base.base.refcount, 1); c->base.base.url_scheme = GRPC_SSL_URL_SCHEME; c->base.base.vtable = &ssl_server_vtable; @@ -1078,7 +1080,8 @@ grpc_security_status grpc_ssl_server_security_connector_create( get_tsi_client_certificate_request_type( server_credentials->config.client_certificate_request), ssl_cipher_suites(), alpn_protocol_strings, - static_cast<uint16_t>(num_alpn_protocols), &c->server_handshaker_factory); + static_cast<uint16_t>(num_alpn_protocols), + &c->server_handshaker_factory); gpr_free((void*)alpn_protocol_strings); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 2e7c3570b6..b37392ab81 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -68,8 +68,8 @@ typedef struct { static size_t move_read_buffer_into_handshake_buffer(security_handshaker* h) { size_t bytes_in_read_buffer = h->args->read_buffer->length; if (h->handshake_buffer_size < bytes_in_read_buffer) { - h->handshake_buffer = - static_cast<uint8_t*>(gpr_realloc(h->handshake_buffer, bytes_in_read_buffer)); + h->handshake_buffer = static_cast<uint8_t*>( + gpr_realloc(h->handshake_buffer, bytes_in_read_buffer)); h->handshake_buffer_size = bytes_in_read_buffer; } size_t offset = 0; @@ -408,15 +408,16 @@ static const grpc_handshaker_vtable security_handshaker_vtable = { static grpc_handshaker* security_handshaker_create( tsi_handshaker* handshaker, grpc_security_connector* connector) { - security_handshaker* h = - static_cast<security_handshaker*>(gpr_zalloc(sizeof(security_handshaker))); + security_handshaker* h = static_cast<security_handshaker*>( + gpr_zalloc(sizeof(security_handshaker))); grpc_handshaker_init(&security_handshaker_vtable, &h->base); h->handshaker = handshaker; h->connector = GRPC_SECURITY_CONNECTOR_REF(connector, "handshake"); gpr_mu_init(&h->mu); gpr_ref_init(&h->refs, 1); h->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE; - h->handshake_buffer = static_cast<uint8_t*>(gpr_malloc(h->handshake_buffer_size)); + h->handshake_buffer = + static_cast<uint8_t*>(gpr_malloc(h->handshake_buffer_size)); GRPC_CLOSURE_INIT(&h->on_handshake_data_sent_to_peer, on_handshake_data_sent_to_peer, h, grpc_schedule_on_exec_ctx); @@ -469,8 +470,8 @@ static void client_handshaker_factory_add_handshakers( grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) { grpc_channel_security_connector* security_connector = - reinterpret_cast<grpc_channel_security_connector*>(grpc_security_connector_find_in_args( - args)); + reinterpret_cast<grpc_channel_security_connector*>( + grpc_security_connector_find_in_args(args)); grpc_channel_security_connector_add_handshakers(security_connector, handshake_mgr); } @@ -479,8 +480,8 @@ static void server_handshaker_factory_add_handshakers( grpc_handshaker_factory* hf, const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) { grpc_server_security_connector* security_connector = - reinterpret_cast<grpc_server_security_connector*>(grpc_security_connector_find_in_args( - args)); + reinterpret_cast<grpc_server_security_connector*>( + grpc_security_connector_find_in_args(args)); grpc_server_security_connector_add_handshakers(security_connector, handshake_mgr); } |