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
@@ -57,8 +57,10 @@
|
|
57
57
|
#include <openssl/bn.h>
|
58
58
|
|
59
59
|
#include <openssl/mem.h>
|
60
|
+
#include <openssl/type_check.h>
|
60
61
|
|
61
62
|
#include "internal.h"
|
63
|
+
#include "../../internal.h"
|
62
64
|
|
63
65
|
|
64
66
|
int BN_ucmp(const BIGNUM *a, const BIGNUM *b) {
|
@@ -174,6 +176,19 @@ int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl) {
|
|
174
176
|
return bn_cmp_words(a, b, cl);
|
175
177
|
}
|
176
178
|
|
179
|
+
int bn_less_than_words(const BN_ULONG *a, const BN_ULONG *b, size_t len) {
|
180
|
+
OPENSSL_COMPILE_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
|
181
|
+
crypto_word_t_too_small);
|
182
|
+
int ret = 0;
|
183
|
+
// Process the words in little-endian order.
|
184
|
+
for (size_t i = 0; i < len; i++) {
|
185
|
+
crypto_word_t eq = constant_time_eq_w(a[i], b[i]);
|
186
|
+
crypto_word_t lt = constant_time_lt_w(a[i], b[i]);
|
187
|
+
ret = constant_time_select_int(eq, ret, constant_time_select_int(lt, 1, 0));
|
188
|
+
}
|
189
|
+
return ret;
|
190
|
+
}
|
191
|
+
|
177
192
|
int BN_abs_is_word(const BIGNUM *bn, BN_ULONG w) {
|
178
193
|
switch (bn->top) {
|
179
194
|
case 1:
|
@@ -128,7 +128,7 @@ static BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) {
|
|
128
128
|
}
|
129
129
|
|
130
130
|
ret = q << BN_BITS4;
|
131
|
-
h = (
|
131
|
+
h = (h << BN_BITS4) | (l >> BN_BITS4);
|
132
132
|
l = (l & BN_MASK2l) << BN_BITS4;
|
133
133
|
}
|
134
134
|
|
@@ -178,28 +178,33 @@ static inline void bn_div_rem_words(BN_ULONG *quotient_out, BN_ULONG *rem_out,
|
|
178
178
|
#endif
|
179
179
|
}
|
180
180
|
|
181
|
-
// BN_div computes
|
182
|
-
//
|
181
|
+
// BN_div computes "quotient := numerator / divisor", rounding towards zero,
|
182
|
+
// and sets up |rem| such that "quotient * divisor + rem = numerator" holds.
|
183
|
+
//
|
183
184
|
// Thus:
|
184
|
-
//
|
185
|
-
//
|
186
|
-
//
|
185
|
+
//
|
186
|
+
// quotient->neg == numerator->neg ^ divisor->neg
|
187
|
+
// (unless the result is zero)
|
188
|
+
// rem->neg == numerator->neg
|
189
|
+
// (unless the remainder is zero)
|
190
|
+
//
|
191
|
+
// If |quotient| or |rem| is NULL, the respective value is not returned.
|
187
192
|
//
|
188
193
|
// This was specifically designed to contain fewer branches that may leak
|
189
194
|
// sensitive information; see "New Branch Prediction Vulnerabilities in OpenSSL
|
190
195
|
// and Necessary Software Countermeasures" by Onur Acıçmez, Shay Gueron, and
|
191
196
|
// Jean-Pierre Seifert.
|
192
|
-
int BN_div(BIGNUM *
|
193
|
-
BN_CTX *ctx) {
|
194
|
-
int norm_shift,
|
195
|
-
BIGNUM
|
197
|
+
int BN_div(BIGNUM *quotient, BIGNUM *rem, const BIGNUM *numerator,
|
198
|
+
const BIGNUM *divisor, BN_CTX *ctx) {
|
199
|
+
int norm_shift, loop;
|
200
|
+
BIGNUM wnum;
|
196
201
|
BN_ULONG *resp, *wnump;
|
197
202
|
BN_ULONG d0, d1;
|
198
203
|
int num_n, div_n;
|
199
204
|
|
200
205
|
// Invalid zero-padding would have particularly bad consequences
|
201
206
|
// so don't just rely on bn_check_top() here
|
202
|
-
if ((
|
207
|
+
if ((numerator->top > 0 && numerator->d[numerator->top - 1] == 0) ||
|
203
208
|
(divisor->top > 0 && divisor->d[divisor->top - 1] == 0)) {
|
204
209
|
OPENSSL_PUT_ERROR(BN, BN_R_NOT_INITIALIZED);
|
205
210
|
return 0;
|
@@ -211,26 +216,27 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
211
216
|
}
|
212
217
|
|
213
218
|
BN_CTX_start(ctx);
|
214
|
-
tmp = BN_CTX_get(ctx);
|
215
|
-
snum = BN_CTX_get(ctx);
|
216
|
-
sdiv = BN_CTX_get(ctx);
|
217
|
-
|
219
|
+
BIGNUM *tmp = BN_CTX_get(ctx);
|
220
|
+
BIGNUM *snum = BN_CTX_get(ctx);
|
221
|
+
BIGNUM *sdiv = BN_CTX_get(ctx);
|
222
|
+
BIGNUM *res = NULL;
|
223
|
+
if (quotient == NULL) {
|
218
224
|
res = BN_CTX_get(ctx);
|
219
225
|
} else {
|
220
|
-
res =
|
226
|
+
res = quotient;
|
221
227
|
}
|
222
|
-
if (sdiv == NULL || res == NULL
|
228
|
+
if (sdiv == NULL || res == NULL) {
|
223
229
|
goto err;
|
224
230
|
}
|
225
231
|
|
226
232
|
// First we normalise the numbers
|
227
|
-
norm_shift = BN_BITS2 - (
|
228
|
-
if (!
|
233
|
+
norm_shift = BN_BITS2 - (BN_num_bits(divisor) % BN_BITS2);
|
234
|
+
if (!BN_lshift(sdiv, divisor, norm_shift)) {
|
229
235
|
goto err;
|
230
236
|
}
|
231
237
|
sdiv->neg = 0;
|
232
238
|
norm_shift += BN_BITS2;
|
233
|
-
if (!
|
239
|
+
if (!BN_lshift(snum, numerator, norm_shift)) {
|
234
240
|
goto err;
|
235
241
|
}
|
236
242
|
snum->neg = 0;
|
@@ -242,7 +248,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
242
248
|
if (!bn_wexpand(snum, sdiv->top + 2)) {
|
243
249
|
goto err;
|
244
250
|
}
|
245
|
-
for (i = snum->top; i < sdiv->top + 2; i++) {
|
251
|
+
for (int i = snum->top; i < sdiv->top + 2; i++) {
|
246
252
|
snum->d[i] = 0;
|
247
253
|
}
|
248
254
|
snum->top = sdiv->top + 2;
|
@@ -275,15 +281,15 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
275
281
|
wnump = &(snum->d[num_n - 1]);
|
276
282
|
|
277
283
|
// Setup to 'res'
|
278
|
-
res->neg = (
|
279
|
-
if (!bn_wexpand(res,
|
284
|
+
res->neg = (numerator->neg ^ divisor->neg);
|
285
|
+
if (!bn_wexpand(res, loop + 1)) {
|
280
286
|
goto err;
|
281
287
|
}
|
282
288
|
res->top = loop - 1;
|
283
289
|
resp = &(res->d[loop - 1]);
|
284
290
|
|
285
291
|
// space for temp
|
286
|
-
if (!bn_wexpand(tmp,
|
292
|
+
if (!bn_wexpand(tmp, div_n + 1)) {
|
287
293
|
goto err;
|
288
294
|
}
|
289
295
|
|
@@ -295,11 +301,11 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
295
301
|
resp--;
|
296
302
|
}
|
297
303
|
|
298
|
-
for (i = 0; i < loop - 1; i++, wnump--, resp--) {
|
304
|
+
for (int i = 0; i < loop - 1; i++, wnump--, resp--) {
|
299
305
|
BN_ULONG q, l0;
|
300
306
|
// the first part of the loop uses the top two words of snum and sdiv to
|
301
307
|
// calculate a BN_ULONG q such that | wnum - sdiv * q | < sdiv
|
302
|
-
BN_ULONG n0, n1,
|
308
|
+
BN_ULONG n0, n1, rm = 0;
|
303
309
|
|
304
310
|
n0 = wnump[0];
|
305
311
|
n1 = wnump[-1];
|
@@ -307,18 +313,18 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
307
313
|
q = BN_MASK2;
|
308
314
|
} else {
|
309
315
|
// n0 < d0
|
310
|
-
bn_div_rem_words(&q, &
|
316
|
+
bn_div_rem_words(&q, &rm, n0, n1, d0);
|
311
317
|
|
312
318
|
#ifdef BN_ULLONG
|
313
319
|
BN_ULLONG t2 = (BN_ULLONG)d1 * q;
|
314
320
|
for (;;) {
|
315
|
-
if (t2 <= ((((BN_ULLONG)
|
321
|
+
if (t2 <= ((((BN_ULLONG)rm) << BN_BITS2) | wnump[-2])) {
|
316
322
|
break;
|
317
323
|
}
|
318
324
|
q--;
|
319
|
-
|
320
|
-
if (
|
321
|
-
break; // don't let
|
325
|
+
rm += d0;
|
326
|
+
if (rm < d0) {
|
327
|
+
break; // don't let rm overflow
|
322
328
|
}
|
323
329
|
t2 -= d1;
|
324
330
|
}
|
@@ -326,13 +332,14 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
326
332
|
BN_ULONG t2l, t2h;
|
327
333
|
BN_UMULT_LOHI(t2l, t2h, d1, q);
|
328
334
|
for (;;) {
|
329
|
-
if (
|
335
|
+
if (t2h < rm ||
|
336
|
+
(t2h == rm && t2l <= wnump[-2])) {
|
330
337
|
break;
|
331
338
|
}
|
332
339
|
q--;
|
333
|
-
|
334
|
-
if (
|
335
|
-
break; // don't let
|
340
|
+
rm += d0;
|
341
|
+
if (rm < d0) {
|
342
|
+
break; // don't let rm overflow
|
336
343
|
}
|
337
344
|
if (t2l < d1) {
|
338
345
|
t2h--;
|
@@ -363,18 +370,21 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
|
363
370
|
// store part of the result
|
364
371
|
*resp = q;
|
365
372
|
}
|
373
|
+
|
366
374
|
bn_correct_top(snum);
|
367
|
-
|
368
|
-
|
369
|
-
//
|
370
|
-
|
371
|
-
|
375
|
+
|
376
|
+
if (rem != NULL) {
|
377
|
+
// Keep a copy of the neg flag in numerator because if |rem| == |numerator|
|
378
|
+
// |BN_rshift| will overwrite it.
|
379
|
+
int neg = numerator->neg;
|
380
|
+
if (!BN_rshift(rem, snum, norm_shift)) {
|
372
381
|
goto err;
|
373
382
|
}
|
374
|
-
if (!BN_is_zero(
|
375
|
-
|
383
|
+
if (!BN_is_zero(rem)) {
|
384
|
+
rem->neg = neg;
|
376
385
|
}
|
377
386
|
}
|
387
|
+
|
378
388
|
bn_correct_top(res);
|
379
389
|
BN_CTX_end(ctx);
|
380
390
|
return 1;
|
@@ -569,8 +579,6 @@ BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w) {
|
|
569
579
|
BN_ULONG ret = 0;
|
570
580
|
int i, j;
|
571
581
|
|
572
|
-
w &= BN_MASK2;
|
573
|
-
|
574
582
|
if (!w) {
|
575
583
|
// actually this an error (division by zero)
|
576
584
|
return (BN_ULONG) - 1;
|
@@ -592,7 +600,7 @@ BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w) {
|
|
592
600
|
BN_ULONG d;
|
593
601
|
BN_ULONG unused_rem;
|
594
602
|
bn_div_rem_words(&d, &unused_rem, ret, l, w);
|
595
|
-
ret =
|
603
|
+
ret = l - (d * w);
|
596
604
|
a->d[i] = d;
|
597
605
|
}
|
598
606
|
|
@@ -634,7 +642,6 @@ BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w) {
|
|
634
642
|
}
|
635
643
|
#endif
|
636
644
|
|
637
|
-
w &= BN_MASK2;
|
638
645
|
for (i = a->top - 1; i >= 0; i--) {
|
639
646
|
#ifndef BN_ULLONG
|
640
647
|
ret = ((ret << BN_BITS4) | ((a->d[i] >> BN_BITS4) & BN_MASK2l)) % w;
|
@@ -188,9 +188,6 @@ err:
|
|
188
188
|
return ret;
|
189
189
|
}
|
190
190
|
|
191
|
-
// maximum precomputation table size for *variable* sliding windows
|
192
|
-
#define TABLE_SIZE 32
|
193
|
-
|
194
191
|
typedef struct bn_recp_ctx_st {
|
195
192
|
BIGNUM N; // the divisor
|
196
193
|
BIGNUM Nr; // the reciprocal
|
@@ -393,8 +390,8 @@ err:
|
|
393
390
|
return ret;
|
394
391
|
}
|
395
392
|
|
396
|
-
// BN_window_bits_for_exponent_size
|
397
|
-
//
|
393
|
+
// BN_window_bits_for_exponent_size returns sliding window size for mod_exp with
|
394
|
+
// a |b| bit exponent.
|
398
395
|
//
|
399
396
|
// For window size 'w' (w >= 2) and a random 'b' bits exponent, the number of
|
400
397
|
// multiplications is a constant plus on average
|
@@ -416,11 +413,35 @@ err:
|
|
416
413
|
//
|
417
414
|
// (with draws in between). Very small exponents are often selected
|
418
415
|
// with low Hamming weight, so we use w = 1 for b <= 23.
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
416
|
+
static int BN_window_bits_for_exponent_size(int b) {
|
417
|
+
if (b > 671) {
|
418
|
+
return 6;
|
419
|
+
}
|
420
|
+
if (b > 239) {
|
421
|
+
return 5;
|
422
|
+
}
|
423
|
+
if (b > 79) {
|
424
|
+
return 4;
|
425
|
+
}
|
426
|
+
if (b > 23) {
|
427
|
+
return 3;
|
428
|
+
}
|
429
|
+
return 1;
|
430
|
+
}
|
431
|
+
|
432
|
+
// TABLE_SIZE is the maximum precomputation table size for *variable* sliding
|
433
|
+
// windows. This must be 2^(max_window - 1), where max_window is the largest
|
434
|
+
// value returned from |BN_window_bits_for_exponent_size|.
|
435
|
+
#define TABLE_SIZE 32
|
436
|
+
|
437
|
+
// TABLE_BITS_SMALL is the smallest value returned from
|
438
|
+
// |BN_window_bits_for_exponent_size| when |b| is at most |BN_BITS2| *
|
439
|
+
// |BN_SMALL_MAX_WORDS| words.
|
440
|
+
#define TABLE_BITS_SMALL 5
|
441
|
+
|
442
|
+
// TABLE_SIZE_SMALL is the same as |TABLE_SIZE|, but when |b| is at most
|
443
|
+
// |BN_BITS2| * |BN_SMALL_MAX_WORDS|.
|
444
|
+
#define TABLE_SIZE_SMALL (1 << (TABLE_BITS_SMALL - 1))
|
424
445
|
|
425
446
|
static int mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
426
447
|
const BIGNUM *m, BN_CTX *ctx) {
|
@@ -501,7 +522,7 @@ static int mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
|
501
522
|
int wvalue; // The 'value' of the window
|
502
523
|
int wend; // The bottom bit of the window
|
503
524
|
|
504
|
-
if (BN_is_bit_set(p, wstart)
|
525
|
+
if (!BN_is_bit_set(p, wstart)) {
|
505
526
|
if (!start) {
|
506
527
|
if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)) {
|
507
528
|
goto err;
|
@@ -573,19 +594,11 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
|
|
573
594
|
|
574
595
|
int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
575
596
|
const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont) {
|
576
|
-
int i, j, bits, ret = 0, wstart, window;
|
577
|
-
int start = 1;
|
578
|
-
BIGNUM *d, *r;
|
579
|
-
const BIGNUM *aa;
|
580
|
-
// Table of variables obtained from 'ctx'
|
581
|
-
BIGNUM *val[TABLE_SIZE];
|
582
|
-
BN_MONT_CTX *new_mont = NULL;
|
583
|
-
|
584
597
|
if (!BN_is_odd(m)) {
|
585
598
|
OPENSSL_PUT_ERROR(BN, BN_R_CALLED_WITH_EVEN_MODULUS);
|
586
599
|
return 0;
|
587
600
|
}
|
588
|
-
bits = BN_num_bits(p);
|
601
|
+
int bits = BN_num_bits(p);
|
589
602
|
if (bits == 0) {
|
590
603
|
// x**0 mod 1 is still zero.
|
591
604
|
if (BN_is_one(m)) {
|
@@ -595,9 +608,13 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
595
608
|
return BN_one(rr);
|
596
609
|
}
|
597
610
|
|
611
|
+
int ret = 0;
|
612
|
+
BIGNUM *val[TABLE_SIZE];
|
613
|
+
BN_MONT_CTX *new_mont = NULL;
|
614
|
+
|
598
615
|
BN_CTX_start(ctx);
|
599
|
-
d = BN_CTX_get(ctx);
|
600
|
-
r = BN_CTX_get(ctx);
|
616
|
+
BIGNUM *d = BN_CTX_get(ctx);
|
617
|
+
BIGNUM *r = BN_CTX_get(ctx);
|
601
618
|
val[0] = BN_CTX_get(ctx);
|
602
619
|
if (!d || !r || !val[0]) {
|
603
620
|
goto err;
|
@@ -612,6 +629,7 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
612
629
|
mont = new_mont;
|
613
630
|
}
|
614
631
|
|
632
|
+
const BIGNUM *aa;
|
615
633
|
if (a->neg || BN_ucmp(a, m) >= 0) {
|
616
634
|
if (!BN_nnmod(val[0], a, m, ctx)) {
|
617
635
|
goto err;
|
@@ -626,53 +644,52 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
626
644
|
ret = 1;
|
627
645
|
goto err;
|
628
646
|
}
|
647
|
+
|
648
|
+
// We exponentiate by looking at sliding windows of the exponent and
|
649
|
+
// precomputing powers of |aa|. Windows may be shifted so they always end on a
|
650
|
+
// set bit, so only precompute odd powers. We compute val[i] = aa^(2*i + 1)
|
651
|
+
// for i = 0 to 2^(window-1), all in Montgomery form.
|
652
|
+
int window = BN_window_bits_for_exponent_size(bits);
|
629
653
|
if (!BN_to_montgomery(val[0], aa, mont, ctx)) {
|
630
|
-
goto err;
|
654
|
+
goto err;
|
631
655
|
}
|
632
|
-
|
633
|
-
window = BN_window_bits_for_exponent_size(bits);
|
634
656
|
if (window > 1) {
|
635
657
|
if (!BN_mod_mul_montgomery(d, val[0], val[0], mont, ctx)) {
|
636
|
-
goto err;
|
658
|
+
goto err;
|
637
659
|
}
|
638
|
-
|
639
|
-
|
640
|
-
if (
|
660
|
+
for (int i = 1; i < 1 << (window - 1); i++) {
|
661
|
+
val[i] = BN_CTX_get(ctx);
|
662
|
+
if (val[i] == NULL ||
|
641
663
|
!BN_mod_mul_montgomery(val[i], val[i - 1], d, mont, ctx)) {
|
642
664
|
goto err;
|
643
665
|
}
|
644
666
|
}
|
645
667
|
}
|
646
668
|
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
j = m->top; // borrow j
|
653
|
-
if (m->d[j - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {
|
654
|
-
if (!bn_wexpand(r, j)) {
|
669
|
+
// Set |r| to one in Montgomery form. If the high bit of |m| is set, |m| is
|
670
|
+
// close to R and we subtract rather than perform Montgomery reduction.
|
671
|
+
if (m->d[m->top - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {
|
672
|
+
if (!bn_wexpand(r, m->top)) {
|
655
673
|
goto err;
|
656
674
|
}
|
657
|
-
// 2^(top*BN_BITS2) - m
|
658
|
-
r->d[0] =
|
659
|
-
for (i = 1; i <
|
660
|
-
r->d[i] =
|
675
|
+
// r = 2^(top*BN_BITS2) - m
|
676
|
+
r->d[0] = 0 - m->d[0];
|
677
|
+
for (int i = 1; i < m->top; i++) {
|
678
|
+
r->d[i] = ~m->d[i];
|
661
679
|
}
|
662
|
-
r->top =
|
663
|
-
//
|
664
|
-
//
|
680
|
+
r->top = m->top;
|
681
|
+
// The upper words will be zero if the corresponding words of |m| were
|
682
|
+
// 0xfff[...], so call |bn_correct_top|.
|
665
683
|
bn_correct_top(r);
|
666
684
|
} else if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) {
|
667
685
|
goto err;
|
668
686
|
}
|
669
687
|
|
688
|
+
int r_is_one = 1;
|
689
|
+
int wstart = bits - 1; // The top bit of the window.
|
670
690
|
for (;;) {
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
if (BN_is_bit_set(p, wstart) == 0) {
|
675
|
-
if (!start && !BN_mod_mul_montgomery(r, r, r, mont, ctx)) {
|
691
|
+
if (!BN_is_bit_set(p, wstart)) {
|
692
|
+
if (!r_is_one && !BN_mod_mul_montgomery(r, r, r, mont, ctx)) {
|
676
693
|
goto err;
|
677
694
|
}
|
678
695
|
if (wstart == 0) {
|
@@ -682,44 +699,37 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
682
699
|
continue;
|
683
700
|
}
|
684
701
|
|
685
|
-
// We now have wstart on a
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
wend = 0;
|
690
|
-
for (i = 1; i < window; i++) {
|
691
|
-
if (wstart - i < 0) {
|
692
|
-
break;
|
693
|
-
}
|
702
|
+
// We now have wstart on a set bit. Find the largest window we can use.
|
703
|
+
int wvalue = 1;
|
704
|
+
int wsize = 0;
|
705
|
+
for (int i = 1; i < window && i <= wstart; i++) {
|
694
706
|
if (BN_is_bit_set(p, wstart - i)) {
|
695
|
-
wvalue <<= (i -
|
707
|
+
wvalue <<= (i - wsize);
|
696
708
|
wvalue |= 1;
|
697
|
-
|
709
|
+
wsize = i;
|
698
710
|
}
|
699
711
|
}
|
700
712
|
|
701
|
-
//
|
702
|
-
|
703
|
-
|
704
|
-
if (!start) {
|
705
|
-
for (i = 0; i < j; i++) {
|
713
|
+
// Shift |r| to the end of the window.
|
714
|
+
if (!r_is_one) {
|
715
|
+
for (int i = 0; i < wsize + 1; i++) {
|
706
716
|
if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) {
|
707
717
|
goto err;
|
708
718
|
}
|
709
719
|
}
|
710
720
|
}
|
711
721
|
|
712
|
-
|
722
|
+
assert(wvalue & 1);
|
723
|
+
assert(wvalue < (1 << window));
|
713
724
|
if (!BN_mod_mul_montgomery(r, r, val[wvalue >> 1], mont, ctx)) {
|
714
725
|
goto err;
|
715
726
|
}
|
716
727
|
|
717
|
-
|
718
|
-
wstart
|
719
|
-
start = 0;
|
720
|
-
if (wstart < 0) {
|
728
|
+
r_is_one = 0;
|
729
|
+
if (wstart == wsize) {
|
721
730
|
break;
|
722
731
|
}
|
732
|
+
wstart -= wsize + 1;
|
723
733
|
}
|
724
734
|
|
725
735
|
if (!BN_from_montgomery(rr, r, mont, ctx)) {
|
@@ -733,12 +743,160 @@ err:
|
|
733
743
|
return ret;
|
734
744
|
}
|
735
745
|
|
736
|
-
|
746
|
+
int bn_mod_exp_mont_small(BN_ULONG *r, size_t num_r, const BN_ULONG *a,
|
747
|
+
size_t num_a, const BN_ULONG *p, size_t num_p,
|
748
|
+
const BN_MONT_CTX *mont) {
|
749
|
+
const BN_ULONG *n = mont->N.d;
|
750
|
+
size_t num_n = mont->N.top;
|
751
|
+
if (num_n != num_a || num_n != num_r || num_n > BN_SMALL_MAX_WORDS) {
|
752
|
+
OPENSSL_PUT_ERROR(BN, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
753
|
+
return 0;
|
754
|
+
}
|
755
|
+
if (!BN_is_odd(&mont->N)) {
|
756
|
+
OPENSSL_PUT_ERROR(BN, BN_R_CALLED_WITH_EVEN_MODULUS);
|
757
|
+
return 0;
|
758
|
+
}
|
759
|
+
unsigned bits = 0;
|
760
|
+
if (num_p != 0) {
|
761
|
+
bits = BN_num_bits_word(p[num_p - 1]) + (num_p - 1) * BN_BITS2;
|
762
|
+
}
|
763
|
+
if (bits == 0) {
|
764
|
+
OPENSSL_memset(r, 0, num_r * sizeof(BN_ULONG));
|
765
|
+
if (!BN_is_one(&mont->N)) {
|
766
|
+
r[0] = 1;
|
767
|
+
}
|
768
|
+
return 1;
|
769
|
+
}
|
770
|
+
|
771
|
+
// We exponentiate by looking at sliding windows of the exponent and
|
772
|
+
// precomputing powers of |a|. Windows may be shifted so they always end on a
|
773
|
+
// set bit, so only precompute odd powers. We compute val[i] = a^(2*i + 1) for
|
774
|
+
// i = 0 to 2^(window-1), all in Montgomery form.
|
775
|
+
unsigned window = BN_window_bits_for_exponent_size(bits);
|
776
|
+
if (window > TABLE_BITS_SMALL) {
|
777
|
+
window = TABLE_BITS_SMALL; // Tolerate excessively large |p|.
|
778
|
+
}
|
779
|
+
int ret = 0;
|
780
|
+
BN_ULONG val[TABLE_SIZE_SMALL][BN_SMALL_MAX_WORDS];
|
781
|
+
OPENSSL_memcpy(val[0], a, num_n * sizeof(BN_ULONG));
|
782
|
+
if (window > 1) {
|
783
|
+
BN_ULONG d[BN_SMALL_MAX_WORDS];
|
784
|
+
if (!bn_mod_mul_montgomery_small(d, num_n, val[0], num_n, val[0], num_n,
|
785
|
+
mont)) {
|
786
|
+
goto err;
|
787
|
+
}
|
788
|
+
for (unsigned i = 1; i < 1u << (window - 1); i++) {
|
789
|
+
if (!bn_mod_mul_montgomery_small(val[i], num_n, val[i - 1], num_n, d,
|
790
|
+
num_n, mont)) {
|
791
|
+
goto err;
|
792
|
+
}
|
793
|
+
}
|
794
|
+
}
|
795
|
+
|
796
|
+
// Set |r| to one in Montgomery form. If the high bit of |m| is set, |m| is
|
797
|
+
// close to R and we subtract rather than perform Montgomery reduction.
|
798
|
+
if (n[num_n - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {
|
799
|
+
// r = 2^(top*BN_BITS2) - m
|
800
|
+
r[0] = 0 - n[0];
|
801
|
+
for (size_t i = 1; i < num_n; i++) {
|
802
|
+
r[i] = ~n[i];
|
803
|
+
}
|
804
|
+
} else if (!bn_from_montgomery_small(r, num_r, mont->RR.d, mont->RR.top,
|
805
|
+
mont)) {
|
806
|
+
goto err;
|
807
|
+
}
|
808
|
+
|
809
|
+
int r_is_one = 1;
|
810
|
+
unsigned wstart = bits - 1; // The top bit of the window.
|
811
|
+
for (;;) {
|
812
|
+
if (!bn_is_bit_set_words(p, num_p, wstart)) {
|
813
|
+
if (!r_is_one &&
|
814
|
+
!bn_mod_mul_montgomery_small(r, num_r, r, num_r, r, num_r, mont)) {
|
815
|
+
goto err;
|
816
|
+
}
|
817
|
+
if (wstart == 0) {
|
818
|
+
break;
|
819
|
+
}
|
820
|
+
wstart--;
|
821
|
+
continue;
|
822
|
+
}
|
823
|
+
|
824
|
+
// We now have wstart on a set bit. Find the largest window we can use.
|
825
|
+
unsigned wvalue = 1;
|
826
|
+
unsigned wsize = 0;
|
827
|
+
for (unsigned i = 1; i < window && i <= wstart; i++) {
|
828
|
+
if (bn_is_bit_set_words(p, num_p, wstart - i)) {
|
829
|
+
wvalue <<= (i - wsize);
|
830
|
+
wvalue |= 1;
|
831
|
+
wsize = i;
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
835
|
+
// Shift |r| to the end of the window.
|
836
|
+
if (!r_is_one) {
|
837
|
+
for (unsigned i = 0; i < wsize + 1; i++) {
|
838
|
+
if (!bn_mod_mul_montgomery_small(r, num_r, r, num_r, r, num_r, mont)) {
|
839
|
+
goto err;
|
840
|
+
}
|
841
|
+
}
|
842
|
+
}
|
843
|
+
|
844
|
+
assert(wvalue & 1);
|
845
|
+
assert(wvalue < (1u << window));
|
846
|
+
if (!bn_mod_mul_montgomery_small(r, num_r, r, num_r, val[wvalue >> 1],
|
847
|
+
num_n, mont)) {
|
848
|
+
goto err;
|
849
|
+
}
|
850
|
+
|
851
|
+
r_is_one = 0;
|
852
|
+
if (wstart == wsize) {
|
853
|
+
break;
|
854
|
+
}
|
855
|
+
wstart -= wsize + 1;
|
856
|
+
}
|
857
|
+
|
858
|
+
ret = 1;
|
859
|
+
|
860
|
+
err:
|
861
|
+
OPENSSL_cleanse(val, sizeof(val));
|
862
|
+
return ret;
|
863
|
+
}
|
864
|
+
|
865
|
+
int bn_mod_inverse_prime_mont_small(BN_ULONG *r, size_t num_r,
|
866
|
+
const BN_ULONG *a, size_t num_a,
|
867
|
+
const BN_MONT_CTX *mont) {
|
868
|
+
const BN_ULONG *p = mont->N.d;
|
869
|
+
size_t num_p = mont->N.top;
|
870
|
+
if (num_p > BN_SMALL_MAX_WORDS || num_p == 0) {
|
871
|
+
OPENSSL_PUT_ERROR(BN, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
872
|
+
return 0;
|
873
|
+
}
|
874
|
+
|
875
|
+
// Per Fermat's Little Theorem, a^-1 = a^(p-2) (mod p) for p prime.
|
876
|
+
BN_ULONG p_minus_two[BN_SMALL_MAX_WORDS];
|
877
|
+
OPENSSL_memcpy(p_minus_two, p, num_p * sizeof(BN_ULONG));
|
878
|
+
if (p_minus_two[0] >= 2) {
|
879
|
+
p_minus_two[0] -= 2;
|
880
|
+
} else {
|
881
|
+
p_minus_two[0] -= 2;
|
882
|
+
for (size_t i = 1; i < num_p; i++) {
|
883
|
+
if (p_minus_two[i]-- != 0) {
|
884
|
+
break;
|
885
|
+
}
|
886
|
+
}
|
887
|
+
}
|
888
|
+
|
889
|
+
return bn_mod_exp_mont_small(r, num_r, a, num_a, p_minus_two, num_p, mont);
|
890
|
+
}
|
891
|
+
|
892
|
+
|
893
|
+
// |BN_mod_exp_mont_consttime| stores the precomputed powers in a specific
|
737
894
|
// layout so that accessing any of these table values shows the same access
|
738
895
|
// pattern as far as cache lines are concerned. The following functions are
|
739
896
|
// used to transfer a BIGNUM from/to that table.
|
740
|
-
|
741
|
-
|
897
|
+
|
898
|
+
static void copy_to_prebuf(const BIGNUM *b, int top, unsigned char *buf,
|
899
|
+
int idx, int window) {
|
742
900
|
int i, j;
|
743
901
|
const int width = 1 << window;
|
744
902
|
BN_ULONG *table = (BN_ULONG *) buf;
|
@@ -750,8 +908,6 @@ static int copy_to_prebuf(const BIGNUM *b, int top, unsigned char *buf, int idx,
|
|
750
908
|
for (i = 0, j = idx; i < top; i++, j += width) {
|
751
909
|
table[j] = b->d[i];
|
752
910
|
}
|
753
|
-
|
754
|
-
return 1;
|
755
911
|
}
|
756
912
|
|
757
913
|
static int copy_from_prebuf(BIGNUM *b, int top, unsigned char *buf, int idx,
|
@@ -963,9 +1119,9 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
963
1119
|
// by Shay Gueron's suggestion
|
964
1120
|
if (m->d[top - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {
|
965
1121
|
// 2^(top*BN_BITS2) - m
|
966
|
-
tmp.d[0] =
|
1122
|
+
tmp.d[0] = 0 - m->d[0];
|
967
1123
|
for (i = 1; i < top; i++) {
|
968
|
-
tmp.d[i] =
|
1124
|
+
tmp.d[i] = ~m->d[i];
|
969
1125
|
}
|
970
1126
|
tmp.top = top;
|
971
1127
|
} else if (!BN_to_montgomery(&tmp, BN_value_one(), mont, ctx)) {
|
@@ -1103,26 +1259,27 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
1103
1259
|
} else
|
1104
1260
|
#endif
|
1105
1261
|
{
|
1106
|
-
|
1107
|
-
|
1108
|
-
goto err;
|
1109
|
-
}
|
1262
|
+
copy_to_prebuf(&tmp, top, powerbuf, 0, window);
|
1263
|
+
copy_to_prebuf(&am, top, powerbuf, 1, window);
|
1110
1264
|
|
1111
1265
|
// If the window size is greater than 1, then calculate
|
1112
1266
|
// val[i=2..2^winsize-1]. Powers are computed as a*a^(i-1)
|
1113
1267
|
// (even powers could instead be computed as (a^(i/2))^2
|
1114
1268
|
// to use the slight performance advantage of sqr over mul).
|
1115
1269
|
if (window > 1) {
|
1116
|
-
if (!BN_mod_mul_montgomery(&tmp, &am, &am, mont, ctx)
|
1117
|
-
!copy_to_prebuf(&tmp, top, powerbuf, 2, window)) {
|
1270
|
+
if (!BN_mod_mul_montgomery(&tmp, &am, &am, mont, ctx)) {
|
1118
1271
|
goto err;
|
1119
1272
|
}
|
1273
|
+
|
1274
|
+
copy_to_prebuf(&tmp, top, powerbuf, 2, window);
|
1275
|
+
|
1120
1276
|
for (i = 3; i < numPowers; i++) {
|
1121
1277
|
// Calculate a^i = a^(i-1) * a
|
1122
|
-
if (!BN_mod_mul_montgomery(&tmp, &am, &tmp, mont, ctx)
|
1123
|
-
!copy_to_prebuf(&tmp, top, powerbuf, i, window)) {
|
1278
|
+
if (!BN_mod_mul_montgomery(&tmp, &am, &tmp, mont, ctx)) {
|
1124
1279
|
goto err;
|
1125
1280
|
}
|
1281
|
+
|
1282
|
+
copy_to_prebuf(&tmp, top, powerbuf, i, window);
|
1126
1283
|
}
|
1127
1284
|
}
|
1128
1285
|
|