grpc 1.10.0 → 1.11.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +2098 -501
- data/include/grpc/byte_buffer.h +2 -0
- data/include/grpc/byte_buffer_reader.h +2 -0
- data/include/grpc/census.h +2 -0
- data/include/grpc/fork.h +2 -0
- data/include/grpc/grpc.h +10 -0
- data/include/grpc/grpc_cronet.h +2 -0
- data/include/grpc/grpc_posix.h +2 -1
- data/include/grpc/grpc_security.h +21 -0
- data/include/grpc/grpc_security_constants.h +1 -0
- data/include/grpc/impl/codegen/byte_buffer.h +2 -0
- data/include/grpc/impl/codegen/grpc_types.h +24 -0
- data/include/grpc/impl/codegen/slice.h +1 -1
- data/include/grpc/impl/codegen/sync.h +1 -0
- data/include/grpc/impl/codegen/sync_custom.h +2 -0
- data/include/grpc/impl/codegen/sync_generic.h +2 -0
- data/include/grpc/impl/codegen/sync_posix.h +2 -0
- data/include/grpc/impl/codegen/sync_windows.h +2 -0
- data/include/grpc/slice.h +2 -0
- data/include/grpc/slice_buffer.h +2 -0
- data/include/grpc/status.h +2 -0
- data/include/grpc/support/alloc.h +2 -2
- data/include/grpc/support/atm.h +2 -0
- data/include/grpc/support/atm_gcc_atomic.h +2 -0
- data/include/grpc/support/atm_gcc_sync.h +2 -0
- data/include/grpc/support/atm_windows.h +2 -0
- data/include/grpc/support/log.h +1 -1
- data/include/grpc/support/sync.h +2 -0
- data/include/grpc/support/sync_custom.h +2 -0
- data/include/grpc/support/sync_generic.h +2 -0
- data/include/grpc/support/sync_posix.h +2 -0
- data/include/grpc/support/sync_windows.h +2 -0
- data/include/grpc/support/time.h +2 -0
- data/src/boringssl/err_data.c +444 -438
- data/src/core/ext/census/grpc_context.cc +2 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +13 -8
- data/src/core/ext/filters/client_channel/backup_poller.h +3 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +1988 -433
- data/src/core/ext/filters/client_channel/client_channel.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +2 -27
- data/src/core/ext/filters/client_channel/connector.cc +2 -0
- data/src/core/ext/filters/client_channel/connector.h +2 -0
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -0
- data/src/core/ext/filters/client_channel/http_proxy.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +96 -78
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +9 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +70 -62
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +4 -2
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -2
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +3 -1
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +2 -1
- data/src/core/ext/filters/client_channel/method_params.cc +178 -0
- data/src/core/ext/filters/client_channel/method_params.h +74 -0
- data/src/core/ext/filters/client_channel/parse_address.cc +17 -13
- data/src/core/ext/filters/client_channel/parse_address.h +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -0
- data/src/core/ext/filters/client_channel/resolver.cc +2 -0
- data/src/core/ext/filters/client_channel/resolver.h +6 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +24 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +55 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +8 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +30 -3
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +2 -0
- data/src/core/ext/filters/client_channel/resolver_registry.cc +2 -0
- data/src/core/ext/filters/client_channel/resolver_registry.h +2 -0
- data/src/core/ext/filters/client_channel/retry_throttle.cc +102 -120
- data/src/core/ext/filters/client_channel/retry_throttle.h +52 -25
- data/src/core/ext/filters/client_channel/subchannel.cc +14 -4
- data/src/core/ext/filters/client_channel/subchannel.h +10 -1
- data/src/core/ext/filters/client_channel/subchannel_index.cc +2 -0
- data/src/core/ext/filters/client_channel/subchannel_index.h +2 -0
- data/src/core/ext/filters/client_channel/uri_parser.cc +2 -1
- data/src/core/ext/filters/client_channel/uri_parser.h +2 -1
- data/src/core/ext/filters/deadline/deadline_filter.cc +2 -1
- data/src/core/ext/filters/deadline/deadline_filter.h +2 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +27 -25
- data/src/core/ext/filters/http/client/http_client_filter.h +2 -0
- data/src/core/ext/filters/http/client_authority_filter.cc +156 -0
- data/src/core/ext/filters/http/client_authority_filter.h +34 -0
- data/src/core/ext/filters/http/http_filters_plugin.cc +2 -0
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +21 -22
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +2 -0
- data/src/core/ext/filters/http/server/http_server_filter.cc +11 -8
- data/src/core/ext/filters/http/server/http_server_filter.h +2 -0
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +2 -0
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +2 -0
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +2 -0
- data/src/core/ext/filters/max_age/max_age_filter.cc +2 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +2 -0
- data/src/core/ext/filters/message_size/message_size_filter.cc +52 -49
- data/src/core/ext/filters/message_size/message_size_filter.h +2 -0
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +5 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +2 -0
- data/src/core/ext/filters/workarounds/workaround_utils.cc +2 -0
- data/src/core/ext/filters/workarounds/workaround_utils.h +2 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +3 -1
- data/src/core/ext/transport/chttp2/alpn/alpn.h +2 -0
- data/src/core/ext/transport/chttp2/client/authority.cc +42 -0
- data/src/core/ext/transport/chttp2/client/authority.h +36 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +2 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +10 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +37 -25
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +2 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +3 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +2 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +3 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +2 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +152 -182
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +2 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +15 -19
- data/src/core/ext/transport/chttp2/transport/frame_data.h +7 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -1
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +2 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +60 -24
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -4
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/varint.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +10 -6
- data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +20 -23
- data/src/core/ext/transport/inproc/inproc_transport.h +2 -0
- data/src/core/lib/avl/avl.cc +2 -0
- data/src/core/lib/avl/avl.h +2 -0
- data/src/core/lib/backoff/backoff.cc +2 -0
- data/src/core/lib/backoff/backoff.h +2 -0
- data/src/core/lib/channel/channel_args.h +2 -0
- data/src/core/lib/channel/channel_stack.cc +3 -1
- data/src/core/lib/channel/channel_stack.h +2 -0
- data/src/core/lib/channel/channel_stack_builder.cc +2 -0
- data/src/core/lib/channel/channel_stack_builder.h +2 -0
- data/src/core/lib/channel/channel_trace.cc +239 -0
- data/src/core/lib/channel/channel_trace.h +133 -0
- data/src/core/lib/channel/channel_trace_registry.cc +80 -0
- data/src/core/lib/channel/channel_trace_registry.h +43 -0
- data/src/core/lib/channel/connected_channel.cc +2 -0
- data/src/core/lib/channel/connected_channel.h +2 -0
- data/src/core/lib/channel/handshaker.cc +2 -0
- data/src/core/lib/channel/handshaker.h +2 -0
- data/src/core/lib/channel/handshaker_factory.cc +2 -0
- data/src/core/lib/channel/handshaker_factory.h +2 -1
- data/src/core/lib/channel/handshaker_registry.cc +2 -0
- data/src/core/lib/channel/handshaker_registry.h +2 -1
- data/src/core/lib/channel/status_util.cc +100 -0
- data/src/core/lib/channel/status_util.h +58 -0
- data/src/core/lib/compression/algorithm_metadata.h +2 -0
- data/src/core/lib/compression/compression.cc +2 -0
- data/src/core/lib/compression/compression_internal.cc +2 -0
- data/src/core/lib/compression/compression_internal.h +2 -0
- data/src/core/lib/compression/message_compress.cc +2 -0
- data/src/core/lib/compression/message_compress.h +2 -0
- data/src/core/lib/compression/stream_compression.cc +2 -0
- data/src/core/lib/compression/stream_compression.h +2 -0
- data/src/core/lib/compression/stream_compression_gzip.cc +2 -0
- data/src/core/lib/compression/stream_compression_gzip.h +2 -0
- data/src/core/lib/compression/stream_compression_identity.cc +2 -1
- data/src/core/lib/compression/stream_compression_identity.h +2 -0
- data/src/core/lib/debug/stats.cc +2 -0
- data/src/core/lib/debug/stats.h +2 -0
- data/src/core/lib/debug/stats_data.cc +3 -1
- data/src/core/lib/debug/stats_data.h +2 -0
- data/src/core/lib/debug/trace.cc +2 -0
- data/src/core/lib/debug/trace.h +2 -1
- data/src/core/lib/gpr/alloc.cc +2 -1
- data/src/core/lib/gpr/arena.cc +47 -0
- data/src/core/lib/gpr/arena.h +2 -0
- data/src/core/lib/gpr/atm.cc +2 -0
- data/src/core/lib/gpr/cpu_linux.cc +5 -1
- data/src/core/lib/gpr/cpu_posix.cc +1 -1
- data/src/core/lib/gpr/env.h +2 -0
- data/src/core/lib/gpr/fork.cc +2 -0
- data/src/core/lib/gpr/host_port.cc +2 -0
- data/src/core/lib/gpr/log.cc +2 -1
- data/src/core/lib/gpr/log_linux.cc +1 -0
- data/src/core/lib/gpr/mpscq.cc +2 -0
- data/src/core/lib/gpr/mpscq.h +2 -0
- data/src/core/lib/gpr/murmur_hash.cc +2 -0
- data/src/core/lib/gpr/spinlock.h +2 -0
- data/src/core/lib/gpr/string.cc +2 -1
- data/src/core/lib/gpr/string.h +2 -2
- data/src/core/lib/gpr/sync.cc +2 -0
- data/src/core/lib/gpr/time.cc +2 -0
- data/src/core/lib/gpr/time_posix.cc +1 -0
- data/src/core/lib/gpr/time_precise.cc +2 -0
- data/src/core/lib/gpr/time_precise.h +2 -0
- data/src/core/lib/gpr/tls_gcc.h +2 -0
- data/src/core/lib/gpr/tls_msvc.h +2 -0
- data/src/core/lib/gpr/tls_pthread.h +2 -0
- data/src/core/lib/gpr/tmpfile.h +2 -0
- data/src/core/lib/gprpp/atomic_with_atm.h +2 -0
- data/src/core/lib/gprpp/atomic_with_std.h +2 -0
- data/src/core/lib/gprpp/inlined_vector.h +2 -0
- data/src/core/lib/gprpp/manual_constructor.h +3 -1
- data/src/core/lib/gprpp/memory.h +5 -3
- data/src/core/lib/gprpp/orphanable.h +3 -0
- data/src/core/lib/gprpp/ref_counted.h +4 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +3 -0
- data/src/core/lib/gprpp/thd.h +135 -0
- data/src/core/lib/gprpp/thd_posix.cc +209 -0
- data/src/core/lib/gprpp/thd_windows.cc +162 -0
- data/src/core/lib/http/format_request.cc +2 -0
- data/src/core/lib/http/format_request.h +2 -0
- data/src/core/lib/http/httpcli.cc +2 -0
- data/src/core/lib/http/httpcli.h +2 -0
- data/src/core/lib/http/httpcli_security_connector.cc +16 -7
- data/src/core/lib/http/parser.cc +2 -0
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/call_combiner.cc +2 -0
- data/src/core/lib/iomgr/call_combiner.h +2 -1
- data/src/core/lib/iomgr/combiner.cc +2 -0
- data/src/core/lib/iomgr/combiner.h +2 -0
- data/src/core/lib/iomgr/endpoint.cc +4 -0
- data/src/core/lib/iomgr/endpoint.h +2 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -0
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -0
- data/src/core/lib/iomgr/endpoint_pair_uv.cc +2 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +7 -4
- data/src/core/lib/iomgr/error.h +2 -0
- data/src/core/lib/iomgr/error_internal.h +2 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.h +2 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +4 -18
- data/src/core/lib/iomgr/ev_epollex_linux.h +2 -0
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +2 -0
- data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -0
- data/src/core/lib/iomgr/ev_poll_posix.cc +61 -31
- data/src/core/lib/iomgr/ev_poll_posix.h +2 -0
- data/src/core/lib/iomgr/ev_posix.cc +35 -19
- data/src/core/lib/iomgr/ev_posix.h +2 -0
- data/src/core/lib/iomgr/ev_windows.cc +2 -0
- data/src/core/lib/iomgr/exec_ctx.cc +3 -1
- data/src/core/lib/iomgr/exec_ctx.h +21 -9
- data/src/core/lib/iomgr/executor.cc +13 -11
- data/src/core/lib/iomgr/executor.h +2 -0
- data/src/core/lib/iomgr/fork_posix.cc +4 -2
- data/src/core/lib/iomgr/fork_windows.cc +2 -0
- data/src/core/lib/iomgr/gethostname_fallback.cc +2 -0
- data/src/core/lib/iomgr/gethostname_host_name_max.cc +2 -0
- data/src/core/lib/iomgr/gethostname_sysconf.cc +2 -0
- data/src/core/lib/iomgr/iocp_windows.cc +3 -1
- data/src/core/lib/iomgr/iocp_windows.h +3 -0
- data/src/core/lib/iomgr/iomgr.cc +2 -1
- data/src/core/lib/iomgr/iomgr.h +2 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +63 -0
- data/src/core/lib/iomgr/iomgr_custom.h +47 -0
- data/src/core/lib/iomgr/iomgr_internal.cc +43 -0
- data/src/core/lib/iomgr/iomgr_internal.h +14 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +30 -3
- data/src/core/lib/iomgr/iomgr_posix.h +2 -0
- data/src/core/lib/iomgr/iomgr_uv.cc +17 -20
- data/src/core/lib/iomgr/iomgr_windows.cc +29 -3
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +2 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.h +2 -0
- data/src/core/lib/iomgr/load_file.cc +2 -0
- data/src/core/lib/iomgr/load_file.h +2 -0
- data/src/core/lib/iomgr/lockfree_event.cc +2 -0
- data/src/core/lib/iomgr/lockfree_event.h +14 -1
- data/src/core/lib/iomgr/nameser.h +2 -0
- data/src/core/lib/iomgr/network_status_tracker.cc +3 -1
- data/src/core/lib/iomgr/network_status_tracker.h +2 -0
- data/src/core/lib/iomgr/polling_entity.cc +2 -0
- data/src/core/lib/iomgr/polling_entity.h +2 -0
- data/src/core/lib/iomgr/pollset.cc +56 -0
- data/src/core/lib/iomgr/pollset.h +19 -0
- data/src/core/lib/iomgr/pollset_custom.cc +106 -0
- data/src/core/lib/iomgr/{timer_generic.h → pollset_custom.h} +15 -17
- data/src/core/lib/iomgr/pollset_set.cc +55 -0
- data/src/core/lib/iomgr/pollset_set.h +13 -0
- data/src/core/lib/iomgr/pollset_set_custom.cc +48 -0
- data/src/core/lib/iomgr/{pollset_uv.h → pollset_set_custom.h} +6 -7
- data/src/core/lib/iomgr/pollset_set_windows.cc +17 -10
- data/src/core/lib/iomgr/pollset_set_windows.h +2 -0
- data/src/core/lib/iomgr/pollset_uv.cc +42 -105
- data/src/core/lib/iomgr/pollset_windows.cc +20 -12
- data/src/core/lib/iomgr/pollset_windows.h +2 -0
- data/src/core/lib/iomgr/port.h +10 -19
- data/src/core/lib/iomgr/resolve_address.cc +50 -0
- data/src/core/lib/iomgr/resolve_address.h +39 -10
- data/src/core/lib/iomgr/resolve_address_custom.cc +187 -0
- data/src/core/lib/iomgr/resolve_address_custom.h +43 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -22
- data/src/core/lib/iomgr/resolve_address_windows.cc +10 -22
- data/src/core/lib/iomgr/resource_quota.cc +2 -0
- data/src/core/lib/iomgr/resource_quota.h +3 -5
- data/src/core/lib/iomgr/sockaddr.h +3 -11
- data/src/core/lib/iomgr/sockaddr_custom.h +54 -0
- data/src/core/lib/iomgr/sockaddr_posix.h +26 -0
- data/src/core/lib/iomgr/sockaddr_utils.cc +91 -71
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/sockaddr_windows.h +21 -0
- data/src/core/lib/iomgr/socket_factory_posix.cc +2 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +2 -0
- data/src/core/lib/iomgr/socket_mutator.cc +2 -0
- data/src/core/lib/iomgr/socket_mutator.h +2 -0
- data/src/core/lib/iomgr/socket_utils.h +11 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +15 -6
- data/src/core/lib/iomgr/socket_utils_linux.cc +4 -4
- data/src/core/lib/iomgr/socket_utils_posix.cc +3 -2
- data/src/core/lib/iomgr/socket_utils_posix.h +2 -0
- data/src/core/lib/iomgr/socket_utils_uv.cc +13 -2
- data/src/core/lib/iomgr/socket_utils_windows.cc +10 -0
- data/src/core/lib/iomgr/socket_windows.cc +2 -0
- data/src/core/lib/iomgr/socket_windows.h +2 -1
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +2 -0
- data/src/core/lib/iomgr/tcp_client.cc +36 -0
- data/src/core/lib/iomgr/tcp_client.h +13 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +151 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +11 -24
- data/src/core/lib/iomgr/tcp_client_posix.h +2 -0
- data/src/core/lib/iomgr/tcp_client_windows.cc +10 -23
- data/src/core/lib/iomgr/tcp_custom.cc +365 -0
- data/src/core/lib/iomgr/tcp_custom.h +81 -0
- data/src/core/lib/iomgr/tcp_posix.cc +3 -1
- data/src/core/lib/iomgr/tcp_posix.h +2 -0
- data/src/core/lib/iomgr/tcp_server.cc +73 -0
- data/src/core/lib/iomgr/tcp_server.h +24 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +472 -0
- data/src/core/lib/iomgr/tcp_server_posix.cc +41 -23
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -7
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +8 -6
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +2 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +43 -21
- data/src/core/lib/iomgr/tcp_uv.cc +308 -314
- data/src/core/lib/iomgr/tcp_windows.cc +3 -1
- data/src/core/lib/iomgr/tcp_windows.h +2 -0
- data/src/core/lib/iomgr/time_averaged_stats.cc +2 -0
- data/src/core/lib/iomgr/timer.cc +45 -0
- data/src/core/lib/iomgr/timer.h +36 -15
- data/src/core/lib/iomgr/timer_custom.cc +93 -0
- data/src/core/lib/iomgr/timer_custom.h +43 -0
- data/src/core/lib/iomgr/timer_generic.cc +12 -10
- data/src/core/lib/iomgr/timer_heap.cc +2 -4
- data/src/core/lib/iomgr/timer_heap.h +2 -0
- data/src/core/lib/iomgr/timer_manager.cc +12 -20
- data/src/core/lib/iomgr/timer_manager.h +2 -0
- data/src/core/lib/iomgr/timer_uv.cc +15 -49
- data/src/core/lib/iomgr/udp_server.cc +271 -230
- data/src/core/lib/iomgr/udp_server.h +44 -20
- data/src/core/lib/iomgr/unix_sockets_posix.cc +10 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -0
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +3 -1
- data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -0
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +2 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.h +2 -0
- data/src/core/lib/json/json.cc +38 -0
- data/src/core/lib/json/json.h +22 -1
- data/src/core/lib/json/json_reader.cc +2 -2
- data/src/core/lib/json/json_reader.h +1 -0
- data/src/core/lib/json/json_string.cc +2 -0
- data/src/core/lib/json/json_writer.cc +2 -2
- data/src/core/lib/json/json_writer.h +2 -0
- data/src/core/lib/profiling/basic_timers.cc +11 -9
- data/src/core/lib/profiling/timers.h +6 -3
- data/src/core/lib/security/context/security_context.cc +2 -0
- data/src/core/lib/security/context/security_context.h +2 -0
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +119 -0
- data/src/core/lib/security/credentials/alts/alts_credentials.h +102 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +72 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment.h +57 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +67 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +33 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +114 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +126 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc +46 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +112 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +58 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +2 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -0
- data/src/core/lib/security/credentials/credentials.cc +2 -0
- data/src/core/lib/security/credentials/credentials.h +2 -0
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -3
- data/src/core/lib/security/credentials/fake/fake_credentials.h +5 -0
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +2 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +2 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +11 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -0
- data/src/core/lib/security/security_connector/alts_security_connector.cc +287 -0
- data/src/core/lib/security/security_connector/alts_security_connector.h +69 -0
- data/src/core/lib/security/security_connector/security_connector.cc +174 -74
- data/src/core/lib/security/security_connector/security_connector.h +41 -7
- data/src/core/lib/security/transport/auth_filters.h +2 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +14 -28
- data/src/core/lib/security/transport/secure_endpoint.cc +2 -0
- data/src/core/lib/security/transport/secure_endpoint.h +2 -0
- data/src/core/lib/security/transport/security_handshaker.cc +2 -0
- data/src/core/lib/security/transport/security_handshaker.h +2 -1
- data/src/core/lib/security/transport/server_auth_filter.cc +2 -0
- data/src/core/lib/security/transport/target_authority_table.cc +75 -0
- data/src/core/lib/security/transport/{lb_targets_info.h → target_authority_table.h} +16 -8
- data/src/core/lib/security/transport/tsi_error.cc +2 -0
- data/src/core/lib/security/transport/tsi_error.h +2 -0
- data/src/core/lib/security/util/json_util.cc +2 -0
- data/src/core/lib/security/util/json_util.h +2 -0
- data/src/core/lib/slice/b64.cc +2 -0
- data/src/core/lib/slice/b64.h +2 -0
- data/src/core/lib/slice/percent_encoding.cc +2 -0
- data/src/core/lib/slice/percent_encoding.h +2 -0
- data/src/core/lib/slice/slice.cc +2 -0
- data/src/core/lib/slice/slice_buffer.cc +3 -1
- data/src/core/lib/slice/slice_hash_table.h +178 -45
- data/src/core/lib/slice/slice_intern.cc +2 -0
- data/src/core/lib/slice/slice_internal.h +2 -2
- data/src/core/lib/slice/slice_string_helpers.cc +2 -0
- data/src/core/lib/slice/slice_string_helpers.h +2 -1
- data/src/core/lib/slice/slice_weak_hash_table.h +105 -0
- data/src/core/lib/surface/api_trace.cc +3 -1
- data/src/core/lib/surface/api_trace.h +2 -0
- data/src/core/lib/surface/byte_buffer.cc +3 -0
- data/src/core/lib/surface/byte_buffer_reader.cc +3 -0
- data/src/core/lib/surface/call.cc +46 -80
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_details.cc +2 -0
- data/src/core/lib/surface/call_log_batch.cc +2 -0
- data/src/core/lib/surface/call_test_only.h +2 -0
- data/src/core/lib/surface/channel.cc +72 -41
- data/src/core/lib/surface/channel.h +2 -0
- data/src/core/lib/surface/channel_init.cc +2 -0
- data/src/core/lib/surface/channel_init.h +2 -0
- data/src/core/lib/surface/channel_ping.cc +2 -0
- data/src/core/lib/surface/channel_stack_type.cc +3 -2
- data/src/core/lib/surface/channel_stack_type.h +2 -0
- data/src/core/lib/surface/completion_queue.h +2 -0
- data/src/core/lib/surface/completion_queue_factory.cc +3 -1
- data/src/core/lib/surface/completion_queue_factory.h +2 -0
- data/src/core/lib/surface/event_string.cc +2 -0
- data/src/core/lib/surface/event_string.h +2 -0
- data/src/core/lib/surface/init.cc +5 -2
- data/src/core/lib/surface/init_secure.cc +5 -2
- data/src/core/lib/surface/lame_client.cc +7 -5
- data/src/core/lib/surface/lame_client.h +2 -0
- data/src/core/lib/surface/metadata_array.cc +2 -0
- data/src/core/lib/surface/server.cc +2 -0
- data/src/core/lib/surface/server.h +2 -0
- data/src/core/lib/surface/validate_metadata.cc +2 -1
- data/src/core/lib/surface/validate_metadata.h +2 -0
- data/src/core/lib/surface/version.cc +4 -2
- data/src/core/lib/transport/bdp_estimator.cc +2 -0
- data/src/core/lib/transport/byte_stream.cc +94 -116
- data/src/core/lib/transport/byte_stream.h +111 -78
- data/src/core/lib/transport/connectivity_state.cc +2 -0
- data/src/core/lib/transport/connectivity_state.h +3 -1
- data/src/core/lib/transport/error_utils.cc +2 -0
- data/src/core/lib/transport/error_utils.h +2 -0
- data/src/core/lib/transport/metadata.cc +2 -0
- data/src/core/lib/transport/metadata.h +3 -1
- data/src/core/lib/transport/metadata_batch.cc +26 -0
- data/src/core/lib/transport/metadata_batch.h +12 -1
- data/src/core/lib/transport/pid_controller.cc +2 -0
- data/src/core/lib/transport/pid_controller.h +2 -0
- data/src/core/lib/transport/service_config.cc +21 -175
- data/src/core/lib/transport/service_config.h +223 -35
- data/src/core/lib/transport/static_metadata.cc +310 -294
- data/src/core/lib/transport/static_metadata.h +96 -82
- data/src/core/lib/transport/status_conversion.cc +2 -0
- data/src/core/lib/transport/status_conversion.h +3 -0
- data/src/core/lib/transport/status_metadata.cc +54 -0
- data/src/core/lib/{iomgr/timer_uv.h → transport/status_metadata.h} +10 -12
- data/src/core/lib/transport/timeout_encoding.cc +2 -1
- data/src/core/lib/transport/timeout_encoding.h +2 -0
- data/src/core/lib/transport/transport.cc +3 -1
- data/src/core/lib/transport/transport.h +33 -7
- data/src/core/lib/transport/transport_impl.h +2 -0
- data/src/core/lib/transport/transport_op_string.cc +10 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +10 -4
- data/src/core/tsi/alts/crypt/aes_gcm.cc +687 -0
- data/src/core/tsi/alts/crypt/gsec.cc +189 -0
- data/src/core/tsi/alts/crypt/gsec.h +454 -0
- data/src/core/tsi/alts/frame_protector/alts_counter.cc +118 -0
- data/src/core/tsi/alts/frame_protector/alts_counter.h +98 -0
- data/src/core/tsi/alts/frame_protector/alts_crypter.cc +66 -0
- data/src/core/tsi/alts/frame_protector/alts_crypter.h +255 -0
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +407 -0
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +55 -0
- data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc +114 -0
- data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +114 -0
- data/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc +105 -0
- data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +103 -0
- data/src/core/tsi/alts/frame_protector/frame_handler.cc +218 -0
- data/src/core/tsi/alts/frame_protector/frame_handler.h +236 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +316 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +137 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc +520 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h +323 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc +143 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +149 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_event.cc +73 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_event.h +93 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +483 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +83 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +52 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +58 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +52 -0
- data/src/core/tsi/alts/handshaker/altscontext.pb.c +48 -0
- data/src/core/tsi/alts/handshaker/altscontext.pb.h +64 -0
- data/src/core/tsi/alts/handshaker/handshaker.pb.c +123 -0
- data/src/core/tsi/alts/handshaker/handshaker.pb.h +255 -0
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +50 -0
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +78 -0
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +196 -0
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +163 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +180 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +52 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +144 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +49 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +91 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +174 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +100 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +476 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +199 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +296 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +52 -0
- data/src/core/tsi/alts_transport_security.cc +3 -1
- data/src/core/tsi/alts_transport_security.h +4 -2
- data/src/core/tsi/fake_transport_security.cc +2 -1
- data/src/core/tsi/fake_transport_security.h +2 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +73 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +58 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +211 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +93 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +76 -0
- data/src/core/tsi/ssl_transport_security.cc +266 -62
- data/src/core/tsi/ssl_transport_security.h +128 -6
- data/src/core/tsi/ssl_types.h +2 -0
- data/src/core/tsi/transport_security.cc +2 -0
- data/src/core/tsi/transport_security.h +2 -0
- data/src/core/tsi/transport_security_adapter.cc +2 -0
- data/src/core/tsi/transport_security_adapter.h +2 -0
- data/src/core/tsi/transport_security_grpc.cc +2 -0
- data/src/core/tsi/transport_security_grpc.h +2 -0
- data/src/core/tsi/transport_security_interface.h +2 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -2
- data/src/ruby/ext/grpc/rb_call.c +1 -13
- data/src/ruby/ext/grpc/rb_channel.c +6 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +1 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -8
- data/src/ruby/lib/grpc/generic/client_stub.rb +6 -10
- data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +133 -0
- data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +54 -0
- data/src/ruby/spec/pb/package_with_underscore/data.proto +23 -0
- data/src/ruby/spec/pb/package_with_underscore/service.proto +23 -0
- data/third_party/address_sorting/address_sorting.c +369 -0
- data/third_party/address_sorting/address_sorting_internal.h +70 -0
- data/third_party/address_sorting/address_sorting_posix.c +97 -0
- data/third_party/address_sorting/address_sorting_windows.c +55 -0
- data/third_party/address_sorting/include/address_sorting/address_sorting.h +110 -0
- data/third_party/boringssl/crypto/asn1/a_enum.c +20 -9
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +3 -0
- data/third_party/boringssl/crypto/asn1/a_int.c +19 -8
- data/third_party/boringssl/crypto/asn1/a_object.c +0 -128
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +3 -0
- data/third_party/boringssl/crypto/asn1/tasn_fre.c +2 -4
- data/third_party/boringssl/crypto/asn1/tasn_new.c +3 -2
- data/third_party/boringssl/crypto/bn_extra/bn_asn1.c +0 -16
- data/third_party/boringssl/crypto/buf/buf.c +14 -0
- data/third_party/boringssl/crypto/bytestring/cbb.c +93 -0
- data/third_party/boringssl/crypto/conf/conf.c +2 -2
- data/third_party/boringssl/crypto/cpu-intel.c +17 -17
- data/third_party/boringssl/crypto/crypto.c +16 -4
- data/third_party/boringssl/crypto/curve25519/spake25519.c +11 -11
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +1 -1
- data/third_party/boringssl/crypto/dsa/dsa.c +9 -21
- data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +2 -2
- data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -8
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +2 -23
- data/third_party/boringssl/crypto/ex_data.c +0 -1
- data/third_party/boringssl/crypto/fipsmodule/bn/add.c +7 -11
- data/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c +19 -16
- data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +15 -0
- data/third_party/boringssl/crypto/fipsmodule/bn/div.c +53 -46
- data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +242 -85
- data/third_party/boringssl/crypto/fipsmodule/bn/generic.c +42 -47
- data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +176 -34
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +118 -65
- data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +94 -61
- data/third_party/boringssl/crypto/fipsmodule/bn/random.c +79 -63
- data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +26 -28
- data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +2 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +250 -149
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +0 -27
- data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +54 -20
- data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +3 -3
- data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +7 -41
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-64.c +6 -40
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +17 -122
- data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +3 -64
- data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +27 -9
- data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +203 -205
- data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +14 -15
- data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +12 -8
- data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +4 -3
- data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +25 -36
- data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +10 -0
- data/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +0 -4
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +2 -0
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +9 -19
- data/third_party/boringssl/crypto/lhash/lhash.c +19 -0
- data/third_party/boringssl/crypto/obj/obj.c +29 -69
- data/third_party/boringssl/crypto/pem/pem_lib.c +2 -2
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +4 -55
- data/third_party/boringssl/crypto/rsa_extra/rsa_asn1.c +3 -22
- data/third_party/boringssl/crypto/x509/by_dir.c +1 -3
- data/third_party/boringssl/crypto/x509/by_file.c +0 -1
- data/third_party/boringssl/crypto/x509/x509_lu.c +0 -1
- data/third_party/boringssl/crypto/x509/x509_obj.c +1 -3
- data/third_party/boringssl/crypto/x509/x509_txt.c +0 -6
- data/third_party/boringssl/crypto/x509/x509_vfy.c +0 -1
- data/third_party/boringssl/crypto/x509/x509_vpm.c +0 -1
- data/third_party/boringssl/crypto/x509/x_algor.c +2 -2
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +3 -4
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -0
- data/third_party/boringssl/crypto/x509v3/v3_info.c +1 -2
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +15 -7
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +41 -2
- data/third_party/boringssl/include/openssl/asn1.h +0 -1
- data/third_party/boringssl/include/openssl/base.h +1 -1
- data/third_party/boringssl/include/openssl/bio.h +5 -2
- data/third_party/boringssl/include/openssl/bn.h +2 -17
- data/third_party/boringssl/include/openssl/buf.h +4 -0
- data/third_party/boringssl/include/openssl/bytestring.h +11 -0
- data/third_party/boringssl/include/openssl/chacha.h +5 -1
- data/third_party/boringssl/include/openssl/cipher.h +10 -0
- data/third_party/boringssl/include/openssl/conf.h +4 -8
- data/third_party/boringssl/include/openssl/dsa.h +2 -18
- data/third_party/boringssl/include/openssl/ec.h +5 -5
- data/third_party/boringssl/include/openssl/ecdsa.h +10 -28
- data/third_party/boringssl/include/openssl/evp.h +0 -4
- data/third_party/boringssl/include/openssl/lhash.h +1 -18
- data/third_party/boringssl/include/openssl/obj.h +1 -0
- data/third_party/boringssl/include/openssl/rsa.h +3 -4
- data/third_party/boringssl/include/openssl/ssl.h +35 -54
- data/third_party/boringssl/include/openssl/ssl3.h +2 -0
- data/third_party/boringssl/include/openssl/stack.h +1 -1
- data/third_party/boringssl/include/openssl/tls1.h +1 -16
- data/third_party/boringssl/include/openssl/x509.h +3 -2
- data/third_party/boringssl/include/openssl/x509_vfy.h +0 -2
- data/third_party/boringssl/include/openssl/x509v3.h +1 -0
- data/third_party/boringssl/ssl/custom_extensions.cc +1 -1
- data/third_party/boringssl/ssl/d1_both.cc +120 -129
- data/third_party/boringssl/ssl/d1_lib.cc +23 -21
- data/third_party/boringssl/ssl/d1_pkt.cc +39 -143
- data/third_party/boringssl/ssl/dtls_method.cc +16 -23
- data/third_party/boringssl/ssl/dtls_record.cc +11 -4
- data/third_party/boringssl/ssl/handshake.cc +109 -40
- data/third_party/boringssl/ssl/handshake_client.cc +104 -96
- data/third_party/boringssl/ssl/handshake_server.cc +62 -72
- data/third_party/boringssl/ssl/internal.h +397 -318
- data/third_party/boringssl/ssl/s3_both.cc +173 -191
- data/third_party/boringssl/ssl/s3_lib.cc +26 -34
- data/third_party/boringssl/ssl/s3_pkt.cc +105 -247
- data/third_party/boringssl/ssl/ssl_asn1.cc +22 -22
- data/third_party/boringssl/ssl/ssl_buffer.cc +98 -108
- data/third_party/boringssl/ssl/ssl_cert.cc +12 -1
- data/third_party/boringssl/ssl/ssl_cipher.cc +23 -28
- data/third_party/boringssl/ssl/ssl_key_share.cc +11 -6
- data/third_party/boringssl/ssl/ssl_lib.cc +190 -113
- data/third_party/boringssl/ssl/ssl_privkey.cc +76 -106
- data/third_party/boringssl/ssl/ssl_session.cc +3 -3
- data/third_party/boringssl/ssl/ssl_stat.cc +3 -3
- data/third_party/boringssl/ssl/ssl_transcript.cc +38 -22
- data/third_party/boringssl/ssl/ssl_versions.cc +64 -31
- data/third_party/boringssl/ssl/t1_enc.cc +137 -154
- data/third_party/boringssl/ssl/t1_lib.cc +463 -478
- data/third_party/boringssl/ssl/tls13_both.cc +57 -58
- data/third_party/boringssl/ssl/tls13_client.cc +256 -121
- data/third_party/boringssl/ssl/tls13_enc.cc +187 -72
- data/third_party/boringssl/ssl/tls13_server.cc +187 -86
- data/third_party/boringssl/ssl/tls_method.cc +20 -30
- data/third_party/boringssl/ssl/tls_record.cc +77 -40
- data/third_party/boringssl/third_party/fiat/curve25519.c +5062 -0
- data/third_party/boringssl/{crypto/curve25519 → third_party/fiat}/internal.h +40 -27
- data/third_party/nanopb/pb.h +1 -1
- metadata +147 -45
- data/src/core/lib/gpr/thd.cc +0 -49
- data/src/core/lib/gpr/thd.h +0 -71
- data/src/core/lib/gpr/thd_posix.cc +0 -154
- data/src/core/lib/gpr/thd_windows.cc +0 -107
- data/src/core/lib/iomgr/iomgr_uv.h +0 -37
- data/src/core/lib/iomgr/pollset_set_uv.cc +0 -43
- data/src/core/lib/iomgr/resolve_address_uv.cc +0 -284
- data/src/core/lib/iomgr/tcp_client_uv.cc +0 -175
- data/src/core/lib/iomgr/tcp_server_uv.cc +0 -471
- data/src/core/lib/iomgr/tcp_uv.h +0 -51
- data/src/core/lib/security/transport/lb_targets_info.cc +0 -59
- data/src/core/lib/slice/slice_hash_table.cc +0 -145
- data/third_party/boringssl/crypto/curve25519/curve25519.c +0 -4938
@@ -0,0 +1,149 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H
|
20
|
+
#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H
|
21
|
+
|
22
|
+
#include <grpc/support/port_platform.h>
|
23
|
+
|
24
|
+
#include "third_party/nanopb/pb_decode.h"
|
25
|
+
#include "third_party/nanopb/pb_encode.h"
|
26
|
+
|
27
|
+
#include <grpc/slice.h>
|
28
|
+
#include <grpc/slice_buffer.h>
|
29
|
+
#include <grpc/support/alloc.h>
|
30
|
+
#include <grpc/support/log.h>
|
31
|
+
|
32
|
+
#include "src/core/tsi/alts/handshaker/handshaker.pb.h"
|
33
|
+
|
34
|
+
/**
|
35
|
+
* An implementation of utility functions used to serialize/
|
36
|
+
* de-serialize ALTS handshake requests/responses. All APIs in the header
|
37
|
+
* are thread-compatible.
|
38
|
+
*/
|
39
|
+
|
40
|
+
/* Renaming of message/field structs generated by nanopb compiler. */
|
41
|
+
typedef grpc_gcp_HandshakeProtocol grpc_gcp_handshake_protocol;
|
42
|
+
typedef grpc_gcp_NetworkProtocol grpc_gcp_network_protocol;
|
43
|
+
typedef grpc_gcp_Identity grpc_gcp_identity;
|
44
|
+
typedef grpc_gcp_NextHandshakeMessageReq grpc_gcp_next_handshake_message_req;
|
45
|
+
typedef grpc_gcp_ServerHandshakeParameters grpc_gcp_server_handshake_parameters;
|
46
|
+
typedef grpc_gcp_Endpoint grpc_gcp_endpoint;
|
47
|
+
typedef grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry
|
48
|
+
grpc_gcp_handshake_parameters_entry;
|
49
|
+
typedef grpc_gcp_StartClientHandshakeReq grpc_gcp_start_client_handshake_req;
|
50
|
+
typedef grpc_gcp_StartServerHandshakeReq grpc_gcp_start_server_handshake_req;
|
51
|
+
typedef grpc_gcp_HandshakerReq grpc_gcp_handshaker_req;
|
52
|
+
typedef grpc_gcp_HandshakerResult grpc_gcp_handshaker_result;
|
53
|
+
typedef grpc_gcp_HandshakerStatus grpc_gcp_handshaker_status;
|
54
|
+
typedef grpc_gcp_HandshakerResp grpc_gcp_handshaker_resp;
|
55
|
+
|
56
|
+
typedef enum {
|
57
|
+
CLIENT_START_REQ = 0, /* StartClientHandshakeReq. */
|
58
|
+
SERVER_START_REQ = 1, /* StartServerHandshakeReq. */
|
59
|
+
NEXT_REQ = 2, /* NextHandshakeMessageReq. */
|
60
|
+
} grpc_gcp_handshaker_req_type;
|
61
|
+
|
62
|
+
/**
|
63
|
+
* A struct representing a repeated field. The struct is used to organize all
|
64
|
+
* instances of a specific repeated field into a linked list, which then will
|
65
|
+
* be used at encode/decode phase. For instance at the encode phase, the encode
|
66
|
+
* function will iterate through the list, encode each field, and then output
|
67
|
+
* the result to the stream.
|
68
|
+
*/
|
69
|
+
typedef struct repeated_field_ {
|
70
|
+
struct repeated_field_* next;
|
71
|
+
const void* data;
|
72
|
+
} repeated_field;
|
73
|
+
|
74
|
+
/**
|
75
|
+
* This method adds a repeated field to the head of repeated field list.
|
76
|
+
*
|
77
|
+
* - head: a head of repeated field list.
|
78
|
+
* - field: a repeated field to be added to the list.
|
79
|
+
*/
|
80
|
+
void add_repeated_field(repeated_field** head, const void* field);
|
81
|
+
|
82
|
+
/**
|
83
|
+
* This method destroys a repeated field list that consists of string type
|
84
|
+
* fields.
|
85
|
+
*
|
86
|
+
* - head: a head of repeated field list.
|
87
|
+
*/
|
88
|
+
void destroy_repeated_field_list_string(repeated_field* head);
|
89
|
+
|
90
|
+
/**
|
91
|
+
* This method destroys a repeated field list that consists of
|
92
|
+
* grpc_gcp_identity type fields.
|
93
|
+
*
|
94
|
+
* - head: a head of repeated field list.
|
95
|
+
*/
|
96
|
+
void destroy_repeated_field_list_identity(repeated_field* head);
|
97
|
+
|
98
|
+
/**
|
99
|
+
* This method creates a grpc_slice instance by copying a data buffer. It is
|
100
|
+
* similar to grpc_slice_from_copied_buffer() except that it returns an instance
|
101
|
+
* allocated from the heap.
|
102
|
+
*
|
103
|
+
* - data: a data buffer to be copied to grpc_slice instance.
|
104
|
+
* - size: size of data buffer.
|
105
|
+
*/
|
106
|
+
grpc_slice* create_slice(const char* data, size_t size);
|
107
|
+
|
108
|
+
/* This method destroys a grpc_slice instance. */
|
109
|
+
void destroy_slice(grpc_slice* slice);
|
110
|
+
|
111
|
+
/**
|
112
|
+
* The following encode/decode functions will be assigned to encode/decode
|
113
|
+
* function pointers of pb_callback_t struct (defined in
|
114
|
+
* //third_party/nanopb/pb.h), that represent a repeated field with a dynamic
|
115
|
+
* length (e.g., a string type or repeated field).
|
116
|
+
*/
|
117
|
+
|
118
|
+
/* This method is an encode callback function for a string or byte array. */
|
119
|
+
bool encode_string_or_bytes_cb(pb_ostream_t* stream, const pb_field_t* field,
|
120
|
+
void* const* arg);
|
121
|
+
|
122
|
+
/**
|
123
|
+
* This method is an encode callback function for a repeated grpc_gcp_identity
|
124
|
+
* field.
|
125
|
+
*/
|
126
|
+
bool encode_repeated_identity_cb(pb_ostream_t* stream, const pb_field_t* field,
|
127
|
+
void* const* arg);
|
128
|
+
|
129
|
+
/* This method is an encode callback function for a repeated string field. */
|
130
|
+
bool encode_repeated_string_cb(pb_ostream_t* stream, const pb_field_t* field,
|
131
|
+
void* const* arg);
|
132
|
+
|
133
|
+
/**
|
134
|
+
* This method is a decode callback function for a string or byte array field.
|
135
|
+
*/
|
136
|
+
bool decode_string_or_bytes_cb(pb_istream_t* stream, const pb_field_t* field,
|
137
|
+
void** arg);
|
138
|
+
/**
|
139
|
+
* This method is a decode callback function for a repeated grpc_gcp_identity
|
140
|
+
* field.
|
141
|
+
*/
|
142
|
+
bool decode_repeated_identity_cb(pb_istream_t* stream, const pb_field_t* field,
|
143
|
+
void** arg);
|
144
|
+
|
145
|
+
/* This method is a decode callback function for a repeated string field. */
|
146
|
+
bool decode_repeated_string_cb(pb_istream_t* stream, const pb_field_t* field,
|
147
|
+
void** arg);
|
148
|
+
|
149
|
+
#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H */
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#include "src/core/tsi/alts/handshaker/alts_tsi_event.h"
|
22
|
+
|
23
|
+
#include <grpc/grpc.h>
|
24
|
+
#include <grpc/support/alloc.h>
|
25
|
+
#include <grpc/support/log.h>
|
26
|
+
|
27
|
+
tsi_result alts_tsi_event_create(alts_tsi_handshaker* handshaker,
|
28
|
+
tsi_handshaker_on_next_done_cb cb,
|
29
|
+
void* user_data,
|
30
|
+
grpc_alts_credentials_options* options,
|
31
|
+
grpc_slice target_name,
|
32
|
+
alts_tsi_event** event) {
|
33
|
+
if (event == nullptr || handshaker == nullptr || cb == nullptr) {
|
34
|
+
gpr_log(GPR_ERROR, "Invalid arguments to alts_tsi_event_create()");
|
35
|
+
return TSI_INVALID_ARGUMENT;
|
36
|
+
}
|
37
|
+
alts_tsi_event* e = static_cast<alts_tsi_event*>(gpr_zalloc(sizeof(*e)));
|
38
|
+
e->handshaker = handshaker;
|
39
|
+
e->cb = cb;
|
40
|
+
e->user_data = user_data;
|
41
|
+
e->options = grpc_alts_credentials_options_copy(options);
|
42
|
+
e->target_name = grpc_slice_copy(target_name);
|
43
|
+
grpc_metadata_array_init(&e->initial_metadata);
|
44
|
+
grpc_metadata_array_init(&e->trailing_metadata);
|
45
|
+
*event = e;
|
46
|
+
return TSI_OK;
|
47
|
+
}
|
48
|
+
|
49
|
+
void alts_tsi_event_dispatch_to_handshaker(alts_tsi_event* event, bool is_ok) {
|
50
|
+
if (event == nullptr) {
|
51
|
+
gpr_log(
|
52
|
+
GPR_ERROR,
|
53
|
+
"ALTS TSI event is nullptr in alts_tsi_event_dispatch_to_handshaker()");
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
alts_tsi_handshaker_handle_response(event->handshaker, event->recv_buffer,
|
57
|
+
event->status, &event->details, event->cb,
|
58
|
+
event->user_data, is_ok);
|
59
|
+
}
|
60
|
+
|
61
|
+
void alts_tsi_event_destroy(alts_tsi_event* event) {
|
62
|
+
if (event == nullptr) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
grpc_byte_buffer_destroy(event->send_buffer);
|
66
|
+
grpc_byte_buffer_destroy(event->recv_buffer);
|
67
|
+
grpc_metadata_array_destroy(&event->initial_metadata);
|
68
|
+
grpc_metadata_array_destroy(&event->trailing_metadata);
|
69
|
+
grpc_slice_unref(event->details);
|
70
|
+
grpc_slice_unref(event->target_name);
|
71
|
+
grpc_alts_credentials_options_destroy(event->options);
|
72
|
+
gpr_free(event);
|
73
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_EVENT_H
|
20
|
+
#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_EVENT_H
|
21
|
+
|
22
|
+
#include <grpc/support/port_platform.h>
|
23
|
+
|
24
|
+
#include <grpc/byte_buffer.h>
|
25
|
+
#include <grpc/byte_buffer_reader.h>
|
26
|
+
|
27
|
+
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h"
|
28
|
+
#include "src/core/tsi/transport_security_interface.h"
|
29
|
+
|
30
|
+
/**
|
31
|
+
* A ALTS TSI event interface. In asynchronous implementation of
|
32
|
+
* tsi_handshaker_next(), the function will exit after scheduling a handshaker
|
33
|
+
* request to ALTS handshaker service without waiting for response to return.
|
34
|
+
* The event is used to link the scheduled handshaker request with the
|
35
|
+
* corresponding response so that enough context information can be inferred
|
36
|
+
* from it to handle the response. All APIs in the header are thread-compatible.
|
37
|
+
*/
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Main struct for ALTS TSI event. It retains ownership on send_buffer and
|
41
|
+
* recv_buffer, but not on handshaker.
|
42
|
+
*/
|
43
|
+
typedef struct alts_tsi_event {
|
44
|
+
alts_tsi_handshaker* handshaker;
|
45
|
+
grpc_byte_buffer* send_buffer;
|
46
|
+
grpc_byte_buffer* recv_buffer;
|
47
|
+
grpc_status_code status;
|
48
|
+
grpc_slice details;
|
49
|
+
grpc_metadata_array initial_metadata;
|
50
|
+
grpc_metadata_array trailing_metadata;
|
51
|
+
tsi_handshaker_on_next_done_cb cb;
|
52
|
+
void* user_data;
|
53
|
+
grpc_alts_credentials_options* options;
|
54
|
+
grpc_slice target_name;
|
55
|
+
} alts_tsi_event;
|
56
|
+
|
57
|
+
/**
|
58
|
+
* This method creates a ALTS TSI event.
|
59
|
+
*
|
60
|
+
* - handshaker: ALTS TSI handshaker instance associated with the event to be
|
61
|
+
* created. The created event does not own the handshaker instance.
|
62
|
+
* - cb: callback function to be called when handling data received from ALTS
|
63
|
+
* handshaker service.
|
64
|
+
* - user_data: argument to callback function.
|
65
|
+
* - options: ALTS credentials options.
|
66
|
+
* - target_name: name of endpoint used for secure naming check.
|
67
|
+
* - event: address of ALTS TSI event instance to be returned from the method.
|
68
|
+
*
|
69
|
+
* It returns TSI_OK on success and an error status code on failure.
|
70
|
+
*/
|
71
|
+
tsi_result alts_tsi_event_create(alts_tsi_handshaker* handshaker,
|
72
|
+
tsi_handshaker_on_next_done_cb cb,
|
73
|
+
void* user_data,
|
74
|
+
grpc_alts_credentials_options* options,
|
75
|
+
grpc_slice target_name,
|
76
|
+
alts_tsi_event** event);
|
77
|
+
|
78
|
+
/**
|
79
|
+
* This method dispatches a ALTS TSI event received from the handshaker service,
|
80
|
+
* and a boolean flag indicating if the event is valid to read to ALTS TSI
|
81
|
+
* handshaker to process. It is called by TSI thread.
|
82
|
+
*
|
83
|
+
* - event: ALTS TSI event instance.
|
84
|
+
* - is_ok: a boolean value indicating if the event is valid to read.
|
85
|
+
*/
|
86
|
+
void alts_tsi_event_dispatch_to_handshaker(alts_tsi_event* event, bool is_ok);
|
87
|
+
|
88
|
+
/**
|
89
|
+
* This method destroys the ALTS TSI event.
|
90
|
+
*/
|
91
|
+
void alts_tsi_event_destroy(alts_tsi_event* event);
|
92
|
+
|
93
|
+
#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_EVENT_H */
|
@@ -0,0 +1,483 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h"
|
22
|
+
|
23
|
+
#include <stdio.h>
|
24
|
+
#include <stdlib.h>
|
25
|
+
#include <string.h>
|
26
|
+
|
27
|
+
#include <grpc/support/alloc.h>
|
28
|
+
#include <grpc/support/log.h>
|
29
|
+
#include <grpc/support/sync.h>
|
30
|
+
#include <grpc/support/thd_id.h>
|
31
|
+
|
32
|
+
#include "src/core/lib/gpr/host_port.h"
|
33
|
+
#include "src/core/lib/gprpp/thd.h"
|
34
|
+
#include "src/core/tsi/alts/frame_protector/alts_frame_protector.h"
|
35
|
+
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
|
36
|
+
#include "src/core/tsi/alts/handshaker/alts_tsi_utils.h"
|
37
|
+
#include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h"
|
38
|
+
#include "src/core/tsi/alts_transport_security.h"
|
39
|
+
|
40
|
+
#define TSI_ALTS_INITIAL_BUFFER_SIZE 256
|
41
|
+
|
42
|
+
static alts_shared_resource* kSharedResource = alts_get_shared_resource();
|
43
|
+
|
44
|
+
/* Main struct for ALTS TSI handshaker. */
|
45
|
+
typedef struct alts_tsi_handshaker {
|
46
|
+
tsi_handshaker base;
|
47
|
+
alts_handshaker_client* client;
|
48
|
+
grpc_slice recv_bytes;
|
49
|
+
grpc_slice target_name;
|
50
|
+
unsigned char* buffer;
|
51
|
+
size_t buffer_size;
|
52
|
+
bool is_client;
|
53
|
+
bool has_sent_start_message;
|
54
|
+
grpc_alts_credentials_options* options;
|
55
|
+
} alts_tsi_handshaker;
|
56
|
+
|
57
|
+
/* Main struct for ALTS TSI handshaker result. */
|
58
|
+
typedef struct alts_tsi_handshaker_result {
|
59
|
+
tsi_handshaker_result base;
|
60
|
+
char* peer_identity;
|
61
|
+
char* key_data;
|
62
|
+
unsigned char* unused_bytes;
|
63
|
+
size_t unused_bytes_size;
|
64
|
+
grpc_slice rpc_versions;
|
65
|
+
bool is_client;
|
66
|
+
} alts_tsi_handshaker_result;
|
67
|
+
|
68
|
+
static tsi_result handshaker_result_extract_peer(
|
69
|
+
const tsi_handshaker_result* self, tsi_peer* peer) {
|
70
|
+
if (self == nullptr || peer == nullptr) {
|
71
|
+
gpr_log(GPR_ERROR, "Invalid argument to handshaker_result_extract_peer()");
|
72
|
+
return TSI_INVALID_ARGUMENT;
|
73
|
+
}
|
74
|
+
alts_tsi_handshaker_result* result =
|
75
|
+
reinterpret_cast<alts_tsi_handshaker_result*>(
|
76
|
+
const_cast<tsi_handshaker_result*>(self));
|
77
|
+
GPR_ASSERT(kTsiAltsNumOfPeerProperties == 3);
|
78
|
+
tsi_result ok = tsi_construct_peer(kTsiAltsNumOfPeerProperties, peer);
|
79
|
+
int index = 0;
|
80
|
+
if (ok != TSI_OK) {
|
81
|
+
gpr_log(GPR_ERROR, "Failed to construct tsi peer");
|
82
|
+
return ok;
|
83
|
+
}
|
84
|
+
GPR_ASSERT(&peer->properties[index] != nullptr);
|
85
|
+
ok = tsi_construct_string_peer_property_from_cstring(
|
86
|
+
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_ALTS_CERTIFICATE_TYPE,
|
87
|
+
&peer->properties[index]);
|
88
|
+
if (ok != TSI_OK) {
|
89
|
+
tsi_peer_destruct(peer);
|
90
|
+
gpr_log(GPR_ERROR, "Failed to set tsi peer property");
|
91
|
+
return ok;
|
92
|
+
}
|
93
|
+
index++;
|
94
|
+
GPR_ASSERT(&peer->properties[index] != nullptr);
|
95
|
+
ok = tsi_construct_string_peer_property_from_cstring(
|
96
|
+
TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY, result->peer_identity,
|
97
|
+
&peer->properties[index]);
|
98
|
+
if (ok != TSI_OK) {
|
99
|
+
tsi_peer_destruct(peer);
|
100
|
+
gpr_log(GPR_ERROR, "Failed to set tsi peer property");
|
101
|
+
}
|
102
|
+
index++;
|
103
|
+
GPR_ASSERT(&peer->properties[index] != nullptr);
|
104
|
+
ok = tsi_construct_string_peer_property(
|
105
|
+
TSI_ALTS_RPC_VERSIONS,
|
106
|
+
reinterpret_cast<char*>(GRPC_SLICE_START_PTR(result->rpc_versions)),
|
107
|
+
GRPC_SLICE_LENGTH(result->rpc_versions), &peer->properties[2]);
|
108
|
+
if (ok != TSI_OK) {
|
109
|
+
tsi_peer_destruct(peer);
|
110
|
+
gpr_log(GPR_ERROR, "Failed to set tsi peer property");
|
111
|
+
}
|
112
|
+
GPR_ASSERT(++index == kTsiAltsNumOfPeerProperties);
|
113
|
+
return ok;
|
114
|
+
}
|
115
|
+
|
116
|
+
static tsi_result handshaker_result_create_zero_copy_grpc_protector(
|
117
|
+
const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
|
118
|
+
tsi_zero_copy_grpc_protector** protector) {
|
119
|
+
if (self == nullptr || protector == nullptr) {
|
120
|
+
gpr_log(GPR_ERROR,
|
121
|
+
"Invalid arguments to create_zero_copy_grpc_protector()");
|
122
|
+
return TSI_INVALID_ARGUMENT;
|
123
|
+
}
|
124
|
+
alts_tsi_handshaker_result* result =
|
125
|
+
reinterpret_cast<alts_tsi_handshaker_result*>(
|
126
|
+
const_cast<tsi_handshaker_result*>(self));
|
127
|
+
tsi_result ok = alts_zero_copy_grpc_protector_create(
|
128
|
+
reinterpret_cast<const uint8_t*>(result->key_data),
|
129
|
+
kAltsAes128GcmRekeyKeyLength, /*is_rekey=*/true, result->is_client,
|
130
|
+
/*is_integrity_only=*/false, max_output_protected_frame_size, protector);
|
131
|
+
if (ok != TSI_OK) {
|
132
|
+
gpr_log(GPR_ERROR, "Failed to create zero-copy grpc protector");
|
133
|
+
}
|
134
|
+
return ok;
|
135
|
+
}
|
136
|
+
|
137
|
+
static tsi_result handshaker_result_create_frame_protector(
|
138
|
+
const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
|
139
|
+
tsi_frame_protector** protector) {
|
140
|
+
if (self == nullptr || protector == nullptr) {
|
141
|
+
gpr_log(GPR_ERROR,
|
142
|
+
"Invalid arguments to handshaker_result_create_frame_protector()");
|
143
|
+
return TSI_INVALID_ARGUMENT;
|
144
|
+
}
|
145
|
+
alts_tsi_handshaker_result* result =
|
146
|
+
reinterpret_cast<alts_tsi_handshaker_result*>(
|
147
|
+
const_cast<tsi_handshaker_result*>(self));
|
148
|
+
tsi_result ok = alts_create_frame_protector(
|
149
|
+
reinterpret_cast<const uint8_t*>(result->key_data),
|
150
|
+
kAltsAes128GcmRekeyKeyLength, result->is_client, /*is_rekey=*/true,
|
151
|
+
max_output_protected_frame_size, protector);
|
152
|
+
if (ok != TSI_OK) {
|
153
|
+
gpr_log(GPR_ERROR, "Failed to create frame protector");
|
154
|
+
}
|
155
|
+
return ok;
|
156
|
+
}
|
157
|
+
|
158
|
+
static tsi_result handshaker_result_get_unused_bytes(
|
159
|
+
const tsi_handshaker_result* self, const unsigned char** bytes,
|
160
|
+
size_t* bytes_size) {
|
161
|
+
if (self == nullptr || bytes == nullptr || bytes_size == nullptr) {
|
162
|
+
gpr_log(GPR_ERROR,
|
163
|
+
"Invalid arguments to handshaker_result_get_unused_bytes()");
|
164
|
+
return TSI_INVALID_ARGUMENT;
|
165
|
+
}
|
166
|
+
alts_tsi_handshaker_result* result =
|
167
|
+
reinterpret_cast<alts_tsi_handshaker_result*>(
|
168
|
+
const_cast<tsi_handshaker_result*>(self));
|
169
|
+
*bytes = result->unused_bytes;
|
170
|
+
*bytes_size = result->unused_bytes_size;
|
171
|
+
return TSI_OK;
|
172
|
+
}
|
173
|
+
|
174
|
+
static void handshaker_result_destroy(tsi_handshaker_result* self) {
|
175
|
+
if (self == nullptr) {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
alts_tsi_handshaker_result* result =
|
179
|
+
reinterpret_cast<alts_tsi_handshaker_result*>(
|
180
|
+
const_cast<tsi_handshaker_result*>(self));
|
181
|
+
gpr_free(result->peer_identity);
|
182
|
+
gpr_free(result->key_data);
|
183
|
+
gpr_free(result->unused_bytes);
|
184
|
+
grpc_slice_unref(result->rpc_versions);
|
185
|
+
gpr_free(result);
|
186
|
+
}
|
187
|
+
|
188
|
+
static const tsi_handshaker_result_vtable result_vtable = {
|
189
|
+
handshaker_result_extract_peer,
|
190
|
+
handshaker_result_create_zero_copy_grpc_protector,
|
191
|
+
handshaker_result_create_frame_protector,
|
192
|
+
handshaker_result_get_unused_bytes, handshaker_result_destroy};
|
193
|
+
|
194
|
+
static tsi_result create_handshaker_result(grpc_gcp_handshaker_resp* resp,
|
195
|
+
bool is_client,
|
196
|
+
tsi_handshaker_result** self) {
|
197
|
+
if (self == nullptr || resp == nullptr) {
|
198
|
+
gpr_log(GPR_ERROR, "Invalid arguments to create_handshaker_result()");
|
199
|
+
return TSI_INVALID_ARGUMENT;
|
200
|
+
}
|
201
|
+
grpc_slice* key = static_cast<grpc_slice*>(resp->result.key_data.arg);
|
202
|
+
GPR_ASSERT(key != nullptr);
|
203
|
+
grpc_slice* identity =
|
204
|
+
static_cast<grpc_slice*>(resp->result.peer_identity.service_account.arg);
|
205
|
+
if (identity == nullptr) {
|
206
|
+
gpr_log(GPR_ERROR, "Invalid service account");
|
207
|
+
return TSI_FAILED_PRECONDITION;
|
208
|
+
}
|
209
|
+
if (GRPC_SLICE_LENGTH(*key) < kAltsAes128GcmRekeyKeyLength) {
|
210
|
+
gpr_log(GPR_ERROR, "Bad key length");
|
211
|
+
return TSI_FAILED_PRECONDITION;
|
212
|
+
}
|
213
|
+
alts_tsi_handshaker_result* result =
|
214
|
+
static_cast<alts_tsi_handshaker_result*>(gpr_zalloc(sizeof(*result)));
|
215
|
+
result->key_data =
|
216
|
+
static_cast<char*>(gpr_zalloc(kAltsAes128GcmRekeyKeyLength));
|
217
|
+
memcpy(result->key_data, GRPC_SLICE_START_PTR(*key),
|
218
|
+
kAltsAes128GcmRekeyKeyLength);
|
219
|
+
result->peer_identity = grpc_slice_to_c_string(*identity);
|
220
|
+
if (!resp->result.has_peer_rpc_versions) {
|
221
|
+
gpr_log(GPR_ERROR, "Peer does not set RPC protocol versions.");
|
222
|
+
return TSI_FAILED_PRECONDITION;
|
223
|
+
}
|
224
|
+
if (!grpc_gcp_rpc_protocol_versions_encode(&resp->result.peer_rpc_versions,
|
225
|
+
&result->rpc_versions)) {
|
226
|
+
gpr_log(GPR_ERROR, "Failed to serialize peer's RPC protocol versions.");
|
227
|
+
return TSI_FAILED_PRECONDITION;
|
228
|
+
}
|
229
|
+
result->is_client = is_client;
|
230
|
+
result->base.vtable = &result_vtable;
|
231
|
+
*self = &result->base;
|
232
|
+
return TSI_OK;
|
233
|
+
}
|
234
|
+
|
235
|
+
static tsi_result handshaker_next(
|
236
|
+
tsi_handshaker* self, const unsigned char* received_bytes,
|
237
|
+
size_t received_bytes_size, const unsigned char** bytes_to_send,
|
238
|
+
size_t* bytes_to_send_size, tsi_handshaker_result** result,
|
239
|
+
tsi_handshaker_on_next_done_cb cb, void* user_data) {
|
240
|
+
if (self == nullptr || cb == nullptr) {
|
241
|
+
gpr_log(GPR_ERROR, "Invalid arguments to handshaker_next()");
|
242
|
+
return TSI_INVALID_ARGUMENT;
|
243
|
+
}
|
244
|
+
alts_tsi_handshaker* handshaker =
|
245
|
+
reinterpret_cast<alts_tsi_handshaker*>(self);
|
246
|
+
tsi_result ok = TSI_OK;
|
247
|
+
alts_tsi_event* event = nullptr;
|
248
|
+
ok = alts_tsi_event_create(handshaker, cb, user_data, handshaker->options,
|
249
|
+
handshaker->target_name, &event);
|
250
|
+
if (ok != TSI_OK) {
|
251
|
+
gpr_log(GPR_ERROR, "Failed to create ALTS TSI event");
|
252
|
+
return ok;
|
253
|
+
}
|
254
|
+
grpc_slice slice = (received_bytes == nullptr || received_bytes_size == 0)
|
255
|
+
? grpc_empty_slice()
|
256
|
+
: grpc_slice_from_copied_buffer(
|
257
|
+
reinterpret_cast<const char*>(received_bytes),
|
258
|
+
received_bytes_size);
|
259
|
+
if (!handshaker->has_sent_start_message) {
|
260
|
+
ok = handshaker->is_client
|
261
|
+
? alts_handshaker_client_start_client(handshaker->client, event)
|
262
|
+
: alts_handshaker_client_start_server(handshaker->client, event,
|
263
|
+
&slice);
|
264
|
+
handshaker->has_sent_start_message = true;
|
265
|
+
} else {
|
266
|
+
if (!GRPC_SLICE_IS_EMPTY(handshaker->recv_bytes)) {
|
267
|
+
grpc_slice_unref(handshaker->recv_bytes);
|
268
|
+
}
|
269
|
+
handshaker->recv_bytes = grpc_slice_ref(slice);
|
270
|
+
ok = alts_handshaker_client_next(handshaker->client, event, &slice);
|
271
|
+
}
|
272
|
+
grpc_slice_unref(slice);
|
273
|
+
if (ok != TSI_OK) {
|
274
|
+
gpr_log(GPR_ERROR, "Failed to schedule ALTS handshaker requests");
|
275
|
+
return ok;
|
276
|
+
}
|
277
|
+
return TSI_ASYNC;
|
278
|
+
}
|
279
|
+
|
280
|
+
static void handshaker_destroy(tsi_handshaker* self) {
|
281
|
+
if (self == nullptr) {
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
alts_tsi_handshaker* handshaker =
|
285
|
+
reinterpret_cast<alts_tsi_handshaker*>(self);
|
286
|
+
alts_handshaker_client_destroy(handshaker->client);
|
287
|
+
grpc_slice_unref(handshaker->recv_bytes);
|
288
|
+
grpc_slice_unref(handshaker->target_name);
|
289
|
+
grpc_alts_credentials_options_destroy(handshaker->options);
|
290
|
+
gpr_free(handshaker->buffer);
|
291
|
+
gpr_free(handshaker);
|
292
|
+
}
|
293
|
+
|
294
|
+
static const tsi_handshaker_vtable handshaker_vtable = {
|
295
|
+
nullptr, nullptr, nullptr, nullptr, nullptr, handshaker_destroy,
|
296
|
+
handshaker_next};
|
297
|
+
|
298
|
+
static void thread_worker(void* arg) {
|
299
|
+
while (true) {
|
300
|
+
grpc_event event = grpc_completion_queue_next(
|
301
|
+
kSharedResource->cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
|
302
|
+
GPR_ASSERT(event.type != GRPC_QUEUE_TIMEOUT);
|
303
|
+
if (event.type == GRPC_QUEUE_SHUTDOWN) {
|
304
|
+
/* signal alts_tsi_shutdown() to destroy completion queue. */
|
305
|
+
grpc_tsi_alts_signal_for_cq_destroy();
|
306
|
+
break;
|
307
|
+
}
|
308
|
+
/* event.type == GRPC_OP_COMPLETE. */
|
309
|
+
alts_tsi_event* alts_event = static_cast<alts_tsi_event*>(event.tag);
|
310
|
+
alts_tsi_event_dispatch_to_handshaker(alts_event, event.success);
|
311
|
+
alts_tsi_event_destroy(alts_event);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
static void init_shared_resources(const char* handshaker_service_url) {
|
316
|
+
GPR_ASSERT(handshaker_service_url != nullptr);
|
317
|
+
gpr_mu_lock(&kSharedResource->mu);
|
318
|
+
if (kSharedResource->channel == nullptr) {
|
319
|
+
gpr_cv_init(&kSharedResource->cv);
|
320
|
+
kSharedResource->channel =
|
321
|
+
grpc_insecure_channel_create(handshaker_service_url, nullptr, nullptr);
|
322
|
+
kSharedResource->cq = grpc_completion_queue_create_for_next(nullptr);
|
323
|
+
kSharedResource->thread =
|
324
|
+
grpc_core::Thread("alts_tsi_handshaker", &thread_worker, nullptr);
|
325
|
+
kSharedResource->thread.Start();
|
326
|
+
}
|
327
|
+
gpr_mu_unlock(&kSharedResource->mu);
|
328
|
+
}
|
329
|
+
|
330
|
+
tsi_result alts_tsi_handshaker_create(
|
331
|
+
const grpc_alts_credentials_options* options, const char* target_name,
|
332
|
+
const char* handshaker_service_url, bool is_client, tsi_handshaker** self) {
|
333
|
+
if (handshaker_service_url == nullptr || self == nullptr ||
|
334
|
+
options == nullptr || (is_client && target_name == nullptr)) {
|
335
|
+
gpr_log(GPR_ERROR, "Invalid arguments to alts_tsi_handshaker_create()");
|
336
|
+
return TSI_INVALID_ARGUMENT;
|
337
|
+
}
|
338
|
+
init_shared_resources(handshaker_service_url);
|
339
|
+
alts_handshaker_client* client = alts_grpc_handshaker_client_create(
|
340
|
+
kSharedResource->channel, kSharedResource->cq, handshaker_service_url);
|
341
|
+
if (client == nullptr) {
|
342
|
+
gpr_log(GPR_ERROR, "Failed to create ALTS handshaker client");
|
343
|
+
return TSI_FAILED_PRECONDITION;
|
344
|
+
}
|
345
|
+
alts_tsi_handshaker* handshaker =
|
346
|
+
static_cast<alts_tsi_handshaker*>(gpr_zalloc(sizeof(*handshaker)));
|
347
|
+
handshaker->client = client;
|
348
|
+
handshaker->buffer_size = TSI_ALTS_INITIAL_BUFFER_SIZE;
|
349
|
+
handshaker->buffer =
|
350
|
+
static_cast<unsigned char*>(gpr_zalloc(handshaker->buffer_size));
|
351
|
+
handshaker->is_client = is_client;
|
352
|
+
handshaker->has_sent_start_message = false;
|
353
|
+
handshaker->target_name = target_name == nullptr
|
354
|
+
? grpc_empty_slice()
|
355
|
+
: grpc_slice_from_static_string(target_name);
|
356
|
+
handshaker->options = grpc_alts_credentials_options_copy(options);
|
357
|
+
handshaker->base.vtable = &handshaker_vtable;
|
358
|
+
*self = &handshaker->base;
|
359
|
+
return TSI_OK;
|
360
|
+
}
|
361
|
+
|
362
|
+
static bool is_handshake_finished_properly(grpc_gcp_handshaker_resp* resp) {
|
363
|
+
GPR_ASSERT(resp != nullptr);
|
364
|
+
if (resp->has_result) {
|
365
|
+
return true;
|
366
|
+
}
|
367
|
+
return false;
|
368
|
+
}
|
369
|
+
|
370
|
+
static void set_unused_bytes(tsi_handshaker_result* self,
|
371
|
+
grpc_slice* recv_bytes, size_t bytes_consumed) {
|
372
|
+
GPR_ASSERT(recv_bytes != nullptr && self != nullptr);
|
373
|
+
if (GRPC_SLICE_LENGTH(*recv_bytes) == bytes_consumed) {
|
374
|
+
return;
|
375
|
+
}
|
376
|
+
alts_tsi_handshaker_result* result =
|
377
|
+
reinterpret_cast<alts_tsi_handshaker_result*>(self);
|
378
|
+
result->unused_bytes_size = GRPC_SLICE_LENGTH(*recv_bytes) - bytes_consumed;
|
379
|
+
result->unused_bytes =
|
380
|
+
static_cast<unsigned char*>(gpr_zalloc(result->unused_bytes_size));
|
381
|
+
memcpy(result->unused_bytes,
|
382
|
+
GRPC_SLICE_START_PTR(*recv_bytes) + bytes_consumed,
|
383
|
+
result->unused_bytes_size);
|
384
|
+
}
|
385
|
+
|
386
|
+
void alts_tsi_handshaker_handle_response(alts_tsi_handshaker* handshaker,
|
387
|
+
grpc_byte_buffer* recv_buffer,
|
388
|
+
grpc_status_code status,
|
389
|
+
grpc_slice* details,
|
390
|
+
tsi_handshaker_on_next_done_cb cb,
|
391
|
+
void* user_data, bool is_ok) {
|
392
|
+
/* Invalid input check. */
|
393
|
+
if (cb == nullptr) {
|
394
|
+
gpr_log(GPR_ERROR,
|
395
|
+
"cb is nullptr in alts_tsi_handshaker_handle_response()");
|
396
|
+
return;
|
397
|
+
}
|
398
|
+
if (handshaker == nullptr || recv_buffer == nullptr) {
|
399
|
+
gpr_log(GPR_ERROR,
|
400
|
+
"Invalid arguments to alts_tsi_handshaker_handle_response()");
|
401
|
+
cb(TSI_INTERNAL_ERROR, user_data, nullptr, 0, nullptr);
|
402
|
+
return;
|
403
|
+
}
|
404
|
+
/* Failed grpc call check. */
|
405
|
+
if (!is_ok || status != GRPC_STATUS_OK) {
|
406
|
+
gpr_log(GPR_ERROR, "grpc call made to handshaker service failed");
|
407
|
+
if (details != nullptr) {
|
408
|
+
char* error_details = grpc_slice_to_c_string(*details);
|
409
|
+
gpr_log(GPR_ERROR, "error details:%s", error_details);
|
410
|
+
gpr_free(error_details);
|
411
|
+
}
|
412
|
+
cb(TSI_INTERNAL_ERROR, user_data, nullptr, 0, nullptr);
|
413
|
+
return;
|
414
|
+
}
|
415
|
+
grpc_gcp_handshaker_resp* resp =
|
416
|
+
alts_tsi_utils_deserialize_response(recv_buffer);
|
417
|
+
/* Invalid handshaker response check. */
|
418
|
+
if (resp == nullptr) {
|
419
|
+
gpr_log(GPR_ERROR, "alts_tsi_utils_deserialize_response() failed");
|
420
|
+
cb(TSI_DATA_CORRUPTED, user_data, nullptr, 0, nullptr);
|
421
|
+
return;
|
422
|
+
}
|
423
|
+
grpc_slice* slice = static_cast<grpc_slice*>(resp->out_frames.arg);
|
424
|
+
unsigned char* bytes_to_send = nullptr;
|
425
|
+
size_t bytes_to_send_size = 0;
|
426
|
+
if (slice != nullptr) {
|
427
|
+
bytes_to_send_size = GRPC_SLICE_LENGTH(*slice);
|
428
|
+
while (bytes_to_send_size > handshaker->buffer_size) {
|
429
|
+
handshaker->buffer_size *= 2;
|
430
|
+
handshaker->buffer = static_cast<unsigned char*>(
|
431
|
+
gpr_realloc(handshaker->buffer, handshaker->buffer_size));
|
432
|
+
}
|
433
|
+
memcpy(handshaker->buffer, GRPC_SLICE_START_PTR(*slice),
|
434
|
+
bytes_to_send_size);
|
435
|
+
bytes_to_send = handshaker->buffer;
|
436
|
+
}
|
437
|
+
tsi_handshaker_result* result = nullptr;
|
438
|
+
if (is_handshake_finished_properly(resp)) {
|
439
|
+
create_handshaker_result(resp, handshaker->is_client, &result);
|
440
|
+
set_unused_bytes(result, &handshaker->recv_bytes, resp->bytes_consumed);
|
441
|
+
}
|
442
|
+
grpc_status_code code = static_cast<grpc_status_code>(resp->status.code);
|
443
|
+
grpc_gcp_handshaker_resp_destroy(resp);
|
444
|
+
cb(alts_tsi_utils_convert_to_tsi_result(code), user_data, bytes_to_send,
|
445
|
+
bytes_to_send_size, result);
|
446
|
+
}
|
447
|
+
|
448
|
+
namespace grpc_core {
|
449
|
+
namespace internal {
|
450
|
+
|
451
|
+
bool alts_tsi_handshaker_get_has_sent_start_message_for_testing(
|
452
|
+
alts_tsi_handshaker* handshaker) {
|
453
|
+
GPR_ASSERT(handshaker != nullptr);
|
454
|
+
return handshaker->has_sent_start_message;
|
455
|
+
}
|
456
|
+
|
457
|
+
bool alts_tsi_handshaker_get_is_client_for_testing(
|
458
|
+
alts_tsi_handshaker* handshaker) {
|
459
|
+
GPR_ASSERT(handshaker != nullptr);
|
460
|
+
return handshaker->is_client;
|
461
|
+
}
|
462
|
+
|
463
|
+
void alts_tsi_handshaker_set_recv_bytes_for_testing(
|
464
|
+
alts_tsi_handshaker* handshaker, grpc_slice* slice) {
|
465
|
+
GPR_ASSERT(handshaker != nullptr && slice != nullptr);
|
466
|
+
handshaker->recv_bytes = grpc_slice_ref(*slice);
|
467
|
+
}
|
468
|
+
|
469
|
+
grpc_slice alts_tsi_handshaker_get_recv_bytes_for_testing(
|
470
|
+
alts_tsi_handshaker* handshaker) {
|
471
|
+
GPR_ASSERT(handshaker != nullptr);
|
472
|
+
return handshaker->recv_bytes;
|
473
|
+
}
|
474
|
+
|
475
|
+
void alts_tsi_handshaker_set_client_for_testing(
|
476
|
+
alts_tsi_handshaker* handshaker, alts_handshaker_client* client) {
|
477
|
+
GPR_ASSERT(handshaker != nullptr && client != nullptr);
|
478
|
+
alts_handshaker_client_destroy(handshaker->client);
|
479
|
+
handshaker->client = client;
|
480
|
+
}
|
481
|
+
|
482
|
+
} // namespace internal
|
483
|
+
} // namespace grpc_core
|