grpc 1.4.5 → 1.6.0.pre1
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 +1235 -1100
- data/etc/roots.pem +0 -412
- data/include/grpc/byte_buffer.h +10 -25
- data/include/grpc/byte_buffer_reader.h +10 -25
- data/include/grpc/census.h +10 -25
- data/include/grpc/compression.h +10 -25
- data/include/grpc/grpc.h +15 -26
- data/include/grpc/grpc_cronet.h +10 -25
- data/include/grpc/grpc_posix.h +10 -25
- data/include/grpc/grpc_security.h +10 -25
- data/include/grpc/grpc_security_constants.h +10 -25
- data/include/grpc/impl/codegen/atm.h +11 -25
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +10 -25
- data/include/grpc/impl/codegen/atm_gcc_sync.h +10 -25
- data/include/grpc/impl/codegen/atm_windows.h +10 -25
- data/include/grpc/impl/codegen/byte_buffer_reader.h +11 -26
- data/include/grpc/impl/codegen/compression_types.h +12 -27
- data/include/grpc/impl/codegen/connectivity_state.h +10 -25
- data/include/grpc/impl/codegen/exec_ctx_fwd.h +10 -25
- data/include/grpc/impl/codegen/gpr_slice.h +10 -25
- data/include/grpc/impl/codegen/gpr_types.h +10 -25
- data/include/grpc/impl/codegen/grpc_types.h +42 -43
- data/include/grpc/impl/codegen/port_platform.h +10 -25
- data/include/grpc/impl/codegen/propagation_bits.h +10 -25
- data/include/grpc/impl/codegen/slice.h +13 -28
- data/include/grpc/impl/codegen/status.h +10 -25
- data/include/grpc/impl/codegen/sync.h +10 -25
- data/include/grpc/impl/codegen/sync_generic.h +10 -25
- data/include/grpc/impl/codegen/sync_posix.h +10 -25
- data/include/grpc/impl/codegen/sync_windows.h +10 -25
- data/include/grpc/load_reporting.h +10 -25
- data/include/grpc/slice.h +10 -25
- data/include/grpc/slice_buffer.h +10 -25
- data/include/grpc/status.h +10 -25
- data/include/grpc/support/alloc.h +10 -25
- data/include/grpc/support/atm.h +10 -25
- data/include/grpc/support/atm_gcc_atomic.h +10 -25
- data/include/grpc/support/atm_gcc_sync.h +10 -25
- data/include/grpc/support/atm_windows.h +10 -25
- data/include/grpc/support/avl.h +46 -49
- data/include/grpc/support/cmdline.h +10 -25
- data/include/grpc/support/cpu.h +10 -25
- data/include/grpc/support/histogram.h +10 -25
- data/include/grpc/support/host_port.h +10 -25
- data/include/grpc/support/log.h +10 -25
- data/include/grpc/support/log_windows.h +10 -25
- data/include/grpc/support/port_platform.h +10 -25
- data/include/grpc/support/string_util.h +10 -25
- data/include/grpc/support/subprocess.h +10 -25
- data/include/grpc/support/sync.h +10 -25
- data/include/grpc/support/sync_generic.h +10 -25
- data/include/grpc/support/sync_posix.h +10 -25
- data/include/grpc/support/sync_windows.h +10 -25
- data/include/grpc/support/thd.h +10 -25
- data/include/grpc/support/time.h +10 -25
- data/include/grpc/support/tls.h +10 -25
- data/include/grpc/support/tls_gcc.h +10 -25
- data/include/grpc/support/tls_msvc.h +10 -25
- data/include/grpc/support/tls_pthread.h +10 -25
- data/include/grpc/support/useful.h +10 -25
- data/include/grpc/support/workaround_list.h +11 -26
- data/src/boringssl/err_data.c +277 -259
- data/src/core/ext/census/aggregation.h +10 -25
- data/src/core/ext/census/base_resources.c +10 -25
- data/src/core/ext/census/base_resources.h +10 -25
- data/src/core/ext/census/census_interface.h +10 -25
- data/src/core/ext/census/census_rpc_stats.h +10 -25
- data/src/core/ext/census/context.c +10 -25
- data/src/core/ext/census/gen/census.pb.c +10 -25
- data/src/core/ext/census/gen/census.pb.h +10 -25
- data/src/core/ext/census/gen/trace_context.pb.c +10 -25
- data/src/core/ext/census/gen/trace_context.pb.h +10 -25
- data/src/core/ext/census/grpc_context.c +10 -25
- data/src/core/ext/census/grpc_filter.c +11 -26
- data/src/core/ext/census/grpc_filter.h +10 -25
- data/src/core/ext/census/grpc_plugin.c +10 -25
- data/src/core/ext/census/initialize.c +10 -25
- data/src/core/ext/census/intrusive_hash_map.c +10 -25
- data/src/core/ext/census/intrusive_hash_map.h +10 -25
- data/src/core/ext/census/intrusive_hash_map_internal.h +10 -25
- data/src/core/ext/census/mlog.c +10 -25
- data/src/core/ext/census/mlog.h +10 -25
- data/src/core/ext/census/operation.c +10 -25
- data/src/core/ext/census/placeholders.c +10 -25
- data/src/core/ext/census/resource.c +10 -25
- data/src/core/ext/census/resource.h +10 -25
- data/src/core/ext/census/rpc_metric_id.h +10 -25
- data/src/core/ext/census/trace_context.c +10 -25
- data/src/core/ext/census/trace_context.h +10 -25
- data/src/core/ext/census/trace_label.h +10 -25
- data/src/core/ext/census/trace_propagation.h +10 -25
- data/src/core/ext/census/trace_status.h +10 -25
- data/src/core/ext/census/trace_string.h +10 -25
- data/src/core/ext/census/tracing.c +10 -26
- data/src/core/ext/census/tracing.h +10 -25
- data/src/core/ext/filters/client_channel/channel_connectivity.c +20 -33
- data/src/core/ext/filters/client_channel/client_channel.c +617 -520
- data/src/core/ext/filters/client_channel/client_channel.h +15 -28
- data/src/core/ext/filters/client_channel/client_channel_factory.c +13 -31
- data/src/core/ext/filters/client_channel/client_channel_factory.h +10 -25
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +16 -29
- data/src/core/ext/filters/client_channel/connector.c +10 -25
- data/src/core/ext/filters/client_channel/connector.h +10 -25
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +15 -30
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -25
- data/src/core/ext/filters/client_channel/http_proxy.c +112 -38
- data/src/core/ext/filters/client_channel/http_proxy.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy.c +32 -36
- data/src/core/ext/filters/client_channel/lb_policy.h +24 -27
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +14 -30
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +464 -279
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +15 -28
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c +40 -48
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +65 -49
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +31 -31
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +11 -26
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +13 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +27 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +373 -136
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +504 -279
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +12 -31
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +12 -27
- data/src/core/ext/filters/client_channel/lb_policy_registry.c +10 -25
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -25
- data/src/core/ext/filters/client_channel/parse_address.c +10 -25
- data/src/core/ext/filters/client_channel/parse_address.h +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper.c +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper.h +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +10 -25
- data/src/core/ext/filters/client_channel/resolver.c +33 -38
- data/src/core/ext/filters/client_channel/resolver.h +19 -30
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +153 -50
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +14 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +33 -30
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +326 -116
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +35 -36
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +19 -34
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +254 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +60 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +16 -28
- data/src/core/ext/filters/client_channel/resolver_factory.c +10 -25
- data/src/core/ext/filters/client_channel/resolver_factory.h +10 -25
- data/src/core/ext/filters/client_channel/resolver_registry.c +10 -25
- data/src/core/ext/filters/client_channel/resolver_registry.h +10 -25
- data/src/core/ext/filters/client_channel/retry_throttle.c +23 -34
- data/src/core/ext/filters/client_channel/retry_throttle.h +10 -25
- data/src/core/ext/filters/client_channel/subchannel.c +33 -55
- data/src/core/ext/filters/client_channel/subchannel.h +16 -26
- data/src/core/ext/filters/client_channel/subchannel_index.c +55 -92
- data/src/core/ext/filters/client_channel/subchannel_index.h +26 -29
- data/src/core/ext/filters/client_channel/uri_parser.c +10 -25
- data/src/core/ext/filters/client_channel/uri_parser.h +10 -25
- data/src/core/ext/filters/deadline/deadline_filter.c +30 -45
- data/src/core/ext/filters/deadline/deadline_filter.h +10 -25
- data/src/core/ext/filters/http/client/http_client_filter.c +255 -294
- data/src/core/ext/filters/http/client/http_client_filter.h +10 -25
- data/src/core/ext/filters/http/http_filters_plugin.c +11 -26
- data/src/core/ext/filters/http/message_compress/message_compress_filter.c +133 -105
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +10 -25
- data/src/core/ext/filters/http/server/http_server_filter.c +17 -32
- data/src/core/ext/filters/http/server/http_server_filter.h +10 -25
- data/src/core/ext/filters/load_reporting/load_reporting.c +11 -30
- data/src/core/ext/filters/load_reporting/load_reporting.h +10 -25
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +11 -26
- data/src/core/ext/filters/load_reporting/load_reporting_filter.h +10 -25
- data/src/core/ext/filters/max_age/max_age_filter.c +28 -43
- data/src/core/ext/filters/max_age/max_age_filter.h +10 -25
- data/src/core/ext/filters/message_size/message_size_filter.c +24 -37
- data/src/core/ext/filters/message_size/message_size_filter.h +10 -25
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +16 -31
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +10 -25
- data/src/core/ext/filters/workarounds/workaround_utils.c +12 -26
- data/src/core/ext/filters/workarounds/workaround_utils.h +11 -26
- data/src/core/ext/transport/chttp2/alpn/alpn.c +10 -25
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -25
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +13 -28
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +10 -25
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +13 -30
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +12 -29
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +13 -30
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +11 -26
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +10 -25
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +10 -25
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +10 -25
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +11 -25
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +10 -25
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +15 -27
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +421 -443
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -25
- data/src/core/ext/transport/chttp2/transport/flow_control.c +500 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_data.c +20 -28
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +11 -26
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +11 -26
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +16 -29
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -33
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +18 -31
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +12 -25
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +15 -30
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -25
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +10 -25
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -25
- data/src/core/ext/transport/chttp2/transport/huffsyms.c +10 -25
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +10 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +10 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +10 -25
- data/src/core/ext/transport/chttp2/transport/internal.h +191 -179
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -102
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +26 -28
- data/src/core/ext/transport/chttp2/transport/stream_map.c +10 -25
- data/src/core/ext/transport/chttp2/transport/stream_map.h +10 -25
- data/src/core/ext/transport/chttp2/transport/varint.c +14 -25
- data/src/core/ext/transport/chttp2/transport/varint.h +10 -25
- data/src/core/ext/transport/chttp2/transport/writing.c +164 -106
- data/src/core/ext/transport/inproc/inproc_plugin.c +29 -0
- data/src/core/ext/transport/inproc/inproc_transport.c +1303 -0
- data/src/core/ext/transport/inproc/inproc_transport.h +41 -0
- data/src/core/lib/channel/channel_args.c +52 -27
- data/src/core/lib/channel/channel_args.h +18 -27
- data/src/core/lib/channel/channel_stack.c +11 -26
- data/src/core/lib/channel/channel_stack.h +12 -27
- data/src/core/lib/channel/channel_stack_builder.c +11 -26
- data/src/core/lib/channel/channel_stack_builder.h +10 -25
- data/src/core/lib/channel/connected_channel.c +10 -25
- data/src/core/lib/channel/connected_channel.h +10 -25
- data/src/core/lib/channel/context.h +10 -25
- data/src/core/lib/channel/handshaker.c +14 -29
- data/src/core/lib/channel/handshaker.h +10 -25
- data/src/core/lib/channel/handshaker_factory.c +10 -25
- data/src/core/lib/channel/handshaker_factory.h +10 -25
- data/src/core/lib/channel/handshaker_registry.c +10 -25
- data/src/core/lib/channel/handshaker_registry.h +10 -25
- data/src/core/lib/compression/algorithm_metadata.h +10 -25
- data/src/core/lib/compression/compression.c +10 -25
- data/src/core/lib/compression/message_compress.c +10 -25
- data/src/core/lib/compression/message_compress.h +10 -25
- data/src/core/lib/compression/stream_compression.c +191 -0
- data/src/core/lib/compression/stream_compression.h +90 -0
- data/src/core/lib/debug/trace.c +28 -29
- data/src/core/lib/debug/trace.h +16 -30
- data/src/core/lib/http/format_request.c +10 -25
- data/src/core/lib/http/format_request.h +10 -25
- data/src/core/lib/http/httpcli.c +19 -35
- data/src/core/lib/http/httpcli.h +10 -25
- data/src/core/lib/http/httpcli_security_connector.c +17 -30
- data/src/core/lib/http/parser.c +11 -26
- data/src/core/lib/http/parser.h +10 -25
- data/src/core/lib/iomgr/closure.c +62 -25
- data/src/core/lib/iomgr/closure.h +81 -26
- data/src/core/lib/iomgr/combiner.c +103 -200
- data/src/core/lib/iomgr/combiner.h +14 -32
- data/src/core/lib/iomgr/endpoint.c +10 -29
- data/src/core/lib/iomgr/endpoint.h +10 -29
- data/src/core/lib/iomgr/endpoint_pair.h +10 -25
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -25
- data/src/core/lib/iomgr/endpoint_pair_uv.c +10 -25
- data/src/core/lib/iomgr/endpoint_pair_windows.c +10 -25
- data/src/core/lib/iomgr/error.c +45 -46
- data/src/core/lib/iomgr/error.h +21 -34
- data/src/core/lib/iomgr/error_internal.h +10 -25
- data/src/core/lib/iomgr/ev_epoll1_linux.c +279 -179
- data/src/core/lib/iomgr/ev_epoll1_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +75 -264
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +44 -199
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epollex_linux.c +184 -247
- data/src/core/lib/iomgr/ev_epollex_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epollsig_linux.c +116 -323
- data/src/core/lib/iomgr/ev_epollsig_linux.h +10 -25
- data/src/core/lib/iomgr/ev_poll_posix.c +328 -184
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -25
- data/src/core/lib/iomgr/ev_posix.c +25 -56
- data/src/core/lib/iomgr/ev_posix.h +15 -44
- data/src/core/lib/iomgr/ev_windows.c +11 -26
- data/src/core/lib/iomgr/exec_ctx.c +36 -45
- data/src/core/lib/iomgr/exec_ctx.h +10 -25
- data/src/core/lib/iomgr/executor.c +152 -127
- data/src/core/lib/iomgr/executor.h +18 -26
- data/src/core/lib/iomgr/gethostname.h +26 -0
- data/src/core/lib/iomgr/gethostname_fallback.c +27 -0
- data/src/core/lib/iomgr/gethostname_host_name_max.c +37 -0
- data/src/core/lib/iomgr/gethostname_sysconf.c +37 -0
- data/src/core/lib/iomgr/iocp_windows.c +10 -25
- data/src/core/lib/iomgr/iocp_windows.h +10 -25
- data/src/core/lib/iomgr/iomgr.c +17 -28
- data/src/core/lib/iomgr/iomgr.h +12 -27
- data/src/core/lib/iomgr/iomgr_internal.h +10 -25
- data/src/core/lib/iomgr/iomgr_posix.c +11 -26
- data/src/core/lib/iomgr/iomgr_posix.h +10 -25
- data/src/core/lib/iomgr/iomgr_uv.c +19 -26
- data/src/core/lib/iomgr/iomgr_uv.h +37 -0
- data/src/core/lib/iomgr/iomgr_windows.c +10 -25
- data/src/core/lib/iomgr/is_epollexclusive_available.c +10 -25
- data/src/core/lib/iomgr/is_epollexclusive_available.h +10 -25
- data/src/core/lib/iomgr/load_file.c +10 -25
- data/src/core/lib/iomgr/load_file.h +10 -25
- data/src/core/lib/iomgr/lockfree_event.c +22 -35
- data/src/core/lib/iomgr/lockfree_event.h +13 -27
- data/src/core/lib/iomgr/nameser.h +104 -0
- data/src/core/lib/iomgr/network_status_tracker.c +10 -25
- data/src/core/lib/iomgr/network_status_tracker.h +10 -25
- data/src/core/lib/iomgr/polling_entity.c +10 -25
- data/src/core/lib/iomgr/polling_entity.h +14 -34
- data/src/core/lib/iomgr/pollset.h +14 -25
- data/src/core/lib/iomgr/pollset_set.h +10 -25
- data/src/core/lib/iomgr/pollset_set_uv.c +10 -25
- data/src/core/lib/iomgr/pollset_set_windows.c +10 -25
- data/src/core/lib/iomgr/pollset_set_windows.h +10 -25
- data/src/core/lib/iomgr/pollset_uv.c +25 -26
- data/src/core/lib/iomgr/pollset_uv.h +10 -25
- data/src/core/lib/iomgr/pollset_windows.c +17 -27
- data/src/core/lib/iomgr/pollset_windows.h +10 -25
- data/src/core/lib/iomgr/port.h +24 -25
- data/src/core/lib/iomgr/resolve_address.h +10 -25
- data/src/core/lib/iomgr/resolve_address_posix.c +13 -28
- data/src/core/lib/iomgr/resolve_address_uv.c +31 -35
- data/src/core/lib/iomgr/resolve_address_windows.c +13 -28
- data/src/core/lib/iomgr/resource_quota.c +52 -67
- data/src/core/lib/iomgr/resource_quota.h +10 -25
- data/src/core/lib/iomgr/sockaddr.h +10 -25
- data/src/core/lib/iomgr/sockaddr_posix.h +10 -25
- data/src/core/lib/iomgr/sockaddr_utils.c +15 -25
- data/src/core/lib/iomgr/sockaddr_utils.h +12 -25
- data/src/core/lib/iomgr/sockaddr_windows.h +10 -25
- data/src/core/lib/iomgr/socket_factory_posix.c +13 -31
- data/src/core/lib/iomgr/socket_factory_posix.h +10 -25
- data/src/core/lib/iomgr/socket_mutator.c +14 -31
- data/src/core/lib/iomgr/socket_mutator.h +10 -25
- data/src/core/lib/iomgr/socket_utils.h +10 -25
- data/src/core/lib/iomgr/socket_utils_common_posix.c +10 -25
- data/src/core/lib/iomgr/socket_utils_linux.c +10 -25
- data/src/core/lib/iomgr/socket_utils_posix.c +10 -25
- data/src/core/lib/iomgr/socket_utils_posix.h +10 -25
- data/src/core/lib/iomgr/socket_utils_uv.c +10 -25
- data/src/core/lib/iomgr/socket_utils_windows.c +10 -25
- data/src/core/lib/iomgr/socket_windows.c +12 -27
- data/src/core/lib/iomgr/socket_windows.h +10 -25
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +10 -25
- data/src/core/lib/iomgr/tcp_client.h +10 -25
- data/src/core/lib/iomgr/tcp_client_posix.c +21 -34
- data/src/core/lib/iomgr/tcp_client_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_client_uv.c +18 -27
- data/src/core/lib/iomgr/tcp_client_windows.c +14 -29
- data/src/core/lib/iomgr/tcp_posix.c +36 -55
- data/src/core/lib/iomgr/tcp_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_server.h +10 -25
- data/src/core/lib/iomgr/tcp_server_posix.c +16 -31
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +11 -26
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +10 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +10 -25
- data/src/core/lib/iomgr/tcp_server_uv.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +14 -29
- data/src/core/lib/iomgr/tcp_uv.c +41 -45
- data/src/core/lib/iomgr/tcp_uv.h +10 -25
- data/src/core/lib/iomgr/tcp_windows.c +39 -53
- data/src/core/lib/iomgr/tcp_windows.h +10 -25
- data/src/core/lib/iomgr/time_averaged_stats.c +10 -25
- data/src/core/lib/iomgr/time_averaged_stats.h +10 -25
- data/src/core/lib/iomgr/timer.h +18 -27
- data/src/core/lib/iomgr/timer_generic.c +91 -87
- data/src/core/lib/iomgr/timer_generic.h +10 -25
- data/src/core/lib/iomgr/timer_heap.c +10 -25
- data/src/core/lib/iomgr/timer_heap.h +10 -25
- data/src/core/lib/iomgr/timer_manager.c +178 -100
- data/src/core/lib/iomgr/timer_manager.h +10 -25
- data/src/core/lib/iomgr/timer_uv.c +23 -33
- data/src/core/lib/iomgr/timer_uv.h +10 -25
- data/src/core/lib/iomgr/udp_server.c +17 -32
- data/src/core/lib/iomgr/udp_server.h +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix.c +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix.h +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_cv.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_cv.h +13 -28
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_nospecial.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +10 -25
- data/src/core/lib/iomgr/wakeup_fd_posix.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_posix.h +10 -25
- data/src/core/lib/json/json.c +10 -25
- data/src/core/lib/json/json.h +10 -25
- data/src/core/lib/json/json_common.h +10 -25
- data/src/core/lib/json/json_reader.c +11 -25
- data/src/core/lib/json/json_reader.h +10 -25
- data/src/core/lib/json/json_string.c +10 -25
- data/src/core/lib/json/json_writer.c +10 -25
- data/src/core/lib/json/json_writer.h +10 -25
- data/src/core/lib/profiling/basic_timers.c +10 -25
- data/src/core/lib/profiling/stap_timers.c +10 -25
- data/src/core/lib/profiling/timers.h +10 -25
- data/src/core/lib/security/context/security_context.c +32 -40
- data/src/core/lib/security/context/security_context.h +15 -26
- data/src/core/lib/security/credentials/composite/composite_credentials.c +76 -81
- data/src/core/lib/security/credentials/composite/composite_credentials.h +10 -25
- data/src/core/lib/security/credentials/credentials.c +29 -49
- data/src/core/lib/security/credentials/credentials.h +48 -61
- data/src/core/lib/security/credentials/credentials_metadata.c +34 -78
- data/src/core/lib/security/credentials/fake/fake_credentials.c +33 -56
- data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -27
- data/src/core/lib/security/credentials/google_default/credentials_generic.c +10 -25
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +12 -27
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +10 -25
- data/src/core/lib/security/credentials/iam/iam_credentials.c +40 -40
- data/src/core/lib/security/credentials/iam/iam_credentials.h +11 -26
- data/src/core/lib/security/credentials/jwt/json_token.c +10 -25
- data/src/core/lib/security/credentials/jwt/json_token.h +10 -25
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +45 -48
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -26
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +53 -33
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +10 -25
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +155 -87
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +24 -28
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +118 -82
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +24 -27
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +13 -32
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -25
- data/src/core/lib/security/transport/auth_filters.h +10 -25
- data/src/core/lib/security/transport/client_auth_filter.c +217 -112
- data/src/core/lib/security/transport/lb_targets_info.c +16 -32
- data/src/core/lib/security/transport/lb_targets_info.h +10 -25
- data/src/core/lib/security/transport/secure_endpoint.c +29 -43
- data/src/core/lib/security/transport/secure_endpoint.h +10 -25
- data/src/core/lib/security/transport/security_connector.c +80 -61
- data/src/core/lib/security/transport/security_connector.h +35 -35
- data/src/core/lib/security/transport/security_handshaker.c +18 -33
- data/src/core/lib/security/transport/security_handshaker.h +10 -25
- data/src/core/lib/security/transport/server_auth_filter.c +62 -116
- data/src/core/lib/security/transport/tsi_error.c +10 -25
- data/src/core/lib/security/transport/tsi_error.h +10 -25
- data/src/core/lib/security/util/json_util.c +10 -25
- data/src/core/lib/security/util/json_util.h +10 -25
- data/src/core/lib/slice/b64.c +10 -25
- data/src/core/lib/slice/b64.h +10 -25
- data/src/core/lib/slice/percent_encoding.c +10 -25
- data/src/core/lib/slice/percent_encoding.h +10 -25
- data/src/core/lib/slice/slice.c +10 -25
- data/src/core/lib/slice/slice_buffer.c +10 -25
- data/src/core/lib/slice/slice_hash_table.c +48 -26
- data/src/core/lib/slice/slice_hash_table.h +26 -28
- data/src/core/lib/slice/slice_intern.c +10 -25
- data/src/core/lib/slice/slice_internal.h +10 -25
- data/src/core/lib/slice/slice_string_helpers.c +10 -25
- data/src/core/lib/slice/slice_string_helpers.h +10 -25
- data/src/core/lib/support/alloc.c +10 -25
- data/src/core/lib/support/arena.c +12 -27
- data/src/core/lib/support/arena.h +10 -25
- data/src/core/lib/support/atm.c +17 -32
- data/src/core/lib/support/atomic.h +10 -25
- data/src/core/lib/support/atomic_with_atm.h +10 -25
- data/src/core/lib/support/atomic_with_std.h +10 -25
- data/src/core/lib/support/avl.c +101 -101
- data/src/core/lib/support/backoff.c +10 -25
- data/src/core/lib/support/backoff.h +10 -25
- data/src/core/lib/support/block_annotate.h +10 -25
- data/src/core/lib/support/cmdline.c +10 -25
- data/src/core/lib/support/cpu_iphone.c +10 -25
- data/src/core/lib/support/cpu_linux.c +10 -25
- data/src/core/lib/support/cpu_posix.c +10 -25
- data/src/core/lib/support/cpu_windows.c +10 -25
- data/src/core/lib/support/env.h +16 -25
- data/src/core/lib/support/env_linux.c +30 -37
- data/src/core/lib/support/env_posix.c +15 -25
- data/src/core/lib/support/env_windows.c +15 -25
- data/src/core/lib/support/histogram.c +10 -25
- data/src/core/lib/support/host_port.c +10 -25
- data/src/core/lib/support/log.c +20 -29
- data/src/core/lib/support/log_android.c +10 -25
- data/src/core/lib/support/log_linux.c +13 -26
- data/src/core/lib/support/log_posix.c +10 -25
- data/src/core/lib/support/log_windows.c +10 -25
- data/src/core/lib/support/memory.h +10 -25
- data/src/core/lib/support/mpscq.c +11 -49
- data/src/core/lib/support/mpscq.h +11 -50
- data/src/core/lib/support/murmur_hash.c +12 -25
- data/src/core/lib/support/murmur_hash.h +10 -25
- data/src/core/lib/support/spinlock.h +10 -25
- data/src/core/lib/support/stack_lockfree.c +10 -25
- data/src/core/lib/support/stack_lockfree.h +10 -25
- data/src/core/lib/support/string.c +10 -25
- data/src/core/lib/support/string.h +10 -25
- data/src/core/lib/support/string_posix.c +10 -25
- data/src/core/lib/support/string_util_windows.c +10 -25
- data/src/core/lib/support/string_windows.c +10 -25
- data/src/core/lib/support/string_windows.h +10 -25
- data/src/core/lib/support/subprocess_posix.c +10 -25
- data/src/core/lib/support/subprocess_windows.c +10 -25
- data/src/core/lib/support/sync.c +10 -25
- data/src/core/lib/support/sync_posix.c +10 -25
- data/src/core/lib/support/sync_windows.c +10 -25
- data/src/core/lib/support/thd.c +10 -25
- data/src/core/lib/support/thd_internal.h +10 -25
- data/src/core/lib/support/thd_posix.c +10 -25
- data/src/core/lib/support/thd_windows.c +10 -25
- data/src/core/lib/support/time.c +10 -25
- data/src/core/lib/support/time_posix.c +10 -25
- data/src/core/lib/support/time_precise.c +18 -33
- data/src/core/lib/support/time_precise.h +10 -25
- data/src/core/lib/support/time_windows.c +10 -25
- data/src/core/lib/support/tls_pthread.c +10 -25
- data/src/core/lib/support/tmpfile.h +10 -25
- data/src/core/lib/support/tmpfile_msys.c +10 -25
- data/src/core/lib/support/tmpfile_posix.c +10 -25
- data/src/core/lib/support/tmpfile_windows.c +10 -25
- data/src/core/lib/support/wrap_memcpy.c +10 -25
- data/src/core/lib/surface/alarm.c +78 -35
- data/src/core/lib/surface/alarm_internal.h +40 -0
- data/src/core/lib/surface/api_trace.c +11 -26
- data/src/core/lib/surface/api_trace.h +10 -25
- data/src/core/lib/surface/byte_buffer.c +10 -25
- data/src/core/lib/surface/byte_buffer_reader.c +10 -25
- data/src/core/lib/surface/call.c +64 -84
- data/src/core/lib/surface/call.h +11 -26
- data/src/core/lib/surface/call_details.c +10 -25
- data/src/core/lib/surface/call_log_batch.c +10 -25
- data/src/core/lib/surface/call_test_only.h +10 -25
- data/src/core/lib/surface/channel.c +11 -26
- data/src/core/lib/surface/channel.h +11 -26
- data/src/core/lib/surface/channel_init.c +10 -25
- data/src/core/lib/surface/channel_init.h +10 -25
- data/src/core/lib/surface/channel_ping.c +12 -27
- data/src/core/lib/surface/channel_stack_type.c +10 -25
- data/src/core/lib/surface/channel_stack_type.h +10 -25
- data/src/core/lib/surface/completion_queue.c +442 -331
- data/src/core/lib/surface/completion_queue.h +16 -33
- data/src/core/lib/surface/completion_queue_factory.c +10 -25
- data/src/core/lib/surface/completion_queue_factory.h +10 -25
- data/src/core/lib/surface/event_string.c +10 -25
- data/src/core/lib/surface/event_string.h +10 -25
- data/src/core/lib/surface/init.c +38 -47
- data/src/core/lib/surface/init.h +10 -25
- data/src/core/lib/surface/init_secure.c +20 -27
- data/src/core/lib/surface/lame_client.cc +14 -29
- data/src/core/lib/surface/lame_client.h +10 -25
- data/src/core/lib/surface/metadata_array.c +10 -25
- data/src/core/lib/surface/server.c +128 -81
- data/src/core/lib/surface/server.h +10 -25
- data/src/core/lib/surface/validate_metadata.c +10 -25
- data/src/core/lib/surface/validate_metadata.h +10 -25
- data/src/core/lib/surface/version.c +11 -26
- data/src/core/lib/transport/bdp_estimator.c +19 -29
- data/src/core/lib/transport/bdp_estimator.h +16 -29
- data/src/core/lib/transport/byte_stream.c +127 -36
- data/src/core/lib/transport/byte_stream.h +88 -46
- data/src/core/lib/transport/connectivity_state.c +17 -31
- data/src/core/lib/transport/connectivity_state.h +10 -25
- data/src/core/lib/transport/error_utils.c +10 -25
- data/src/core/lib/transport/error_utils.h +10 -25
- data/src/core/lib/transport/http2_errors.h +10 -25
- data/src/core/lib/transport/metadata.c +87 -85
- data/src/core/lib/transport/metadata.h +15 -28
- data/src/core/lib/transport/metadata_batch.c +10 -25
- data/src/core/lib/transport/metadata_batch.h +10 -25
- data/src/core/lib/transport/pid_controller.c +10 -25
- data/src/core/lib/transport/pid_controller.h +10 -25
- data/src/core/lib/transport/service_config.c +11 -26
- data/src/core/lib/transport/service_config.h +10 -25
- data/src/core/lib/transport/static_metadata.c +12 -26
- data/src/core/lib/transport/static_metadata.h +10 -25
- data/src/core/lib/transport/status_conversion.c +10 -25
- data/src/core/lib/transport/status_conversion.h +10 -25
- data/src/core/lib/transport/timeout_encoding.c +10 -25
- data/src/core/lib/transport/timeout_encoding.h +10 -25
- data/src/core/lib/transport/transport.c +60 -53
- data/src/core/lib/transport/transport.h +36 -34
- data/src/core/lib/transport/transport_impl.h +10 -25
- data/src/core/lib/transport/transport_op_string.c +10 -28
- data/src/core/plugin_registry/grpc_plugin_registry.c +22 -25
- data/src/core/tsi/fake_transport_security.c +199 -94
- data/src/core/tsi/fake_transport_security.h +11 -26
- data/src/core/tsi/gts_transport_security.c +40 -0
- data/src/core/tsi/gts_transport_security.h +37 -0
- data/src/core/tsi/ssl_transport_security.c +13 -32
- data/src/core/tsi/ssl_transport_security.h +10 -25
- data/src/core/tsi/ssl_types.h +10 -25
- data/src/core/tsi/transport_security.c +48 -78
- data/src/core/tsi/transport_security.h +18 -27
- data/src/core/tsi/transport_security_adapter.c +17 -29
- data/src/core/tsi/transport_security_adapter.h +10 -25
- data/src/core/tsi/transport_security_grpc.c +64 -0
- data/src/core/tsi/transport_security_grpc.h +80 -0
- data/src/core/tsi/transport_security_interface.h +21 -27
- data/src/ruby/bin/apis/google/protobuf/empty.rb +10 -25
- data/src/ruby/bin/apis/pubsub_demo.rb +10 -25
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +10 -25
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +10 -25
- data/src/ruby/bin/math_client.rb +10 -25
- data/src/ruby/bin/math_server.rb +10 -25
- data/src/ruby/bin/math_services_pb.rb +10 -25
- data/src/ruby/bin/noproto_client.rb +10 -25
- data/src/ruby/bin/noproto_server.rb +10 -25
- data/src/ruby/ext/grpc/extconf.rb +10 -25
- data/src/ruby/ext/grpc/rb_byte_buffer.c +10 -25
- data/src/ruby/ext/grpc/rb_byte_buffer.h +10 -25
- data/src/ruby/ext/grpc/rb_call.c +44 -25
- data/src/ruby/ext/grpc/rb_call.h +10 -25
- data/src/ruby/ext/grpc/rb_call_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_call_credentials.h +10 -25
- data/src/ruby/ext/grpc/rb_channel.c +10 -25
- data/src/ruby/ext/grpc/rb_channel.h +10 -25
- data/src/ruby/ext/grpc/rb_channel_args.c +10 -25
- data/src/ruby/ext/grpc/rb_channel_args.h +10 -25
- data/src/ruby/ext/grpc/rb_channel_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_channel_credentials.h +10 -25
- data/src/ruby/ext/grpc/rb_completion_queue.c +10 -25
- data/src/ruby/ext/grpc/rb_completion_queue.h +10 -25
- data/src/ruby/ext/grpc/rb_compression_options.c +10 -25
- data/src/ruby/ext/grpc/rb_compression_options.h +10 -25
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -25
- data/src/ruby/ext/grpc/rb_event_thread.h +10 -25
- data/src/ruby/ext/grpc/rb_grpc.c +10 -25
- data/src/ruby/ext/grpc/rb_grpc.h +10 -25
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -25
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +16 -31
- data/src/ruby/ext/grpc/rb_loader.c +10 -25
- data/src/ruby/ext/grpc/rb_loader.h +10 -25
- data/src/ruby/ext/grpc/rb_server.c +10 -25
- data/src/ruby/ext/grpc/rb_server.h +10 -25
- data/src/ruby/ext/grpc/rb_server_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_server_credentials.h +10 -25
- data/src/ruby/lib/grpc.rb +10 -25
- data/src/ruby/lib/grpc/core/time_consts.rb +10 -25
- data/src/ruby/lib/grpc/errors.rb +16 -30
- data/src/ruby/lib/grpc/generic/active_call.rb +25 -27
- data/src/ruby/lib/grpc/generic/bidi_call.rb +17 -27
- data/src/ruby/lib/grpc/generic/client_stub.rb +10 -25
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +10 -25
- data/src/ruby/lib/grpc/generic/rpc_server.rb +10 -25
- data/src/ruby/lib/grpc/generic/service.rb +10 -25
- data/src/ruby/lib/grpc/grpc.rb +10 -25
- data/src/ruby/lib/grpc/logconfig.rb +10 -25
- data/src/ruby/lib/grpc/notifier.rb +10 -25
- data/src/ruby/lib/grpc/version.rb +11 -26
- data/src/ruby/pb/generate_proto_ruby.sh +10 -25
- data/src/ruby/pb/grpc/health/checker.rb +10 -25
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +10 -25
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +10 -25
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +10 -25
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +10 -25
- data/src/ruby/pb/test/client.rb +10 -25
- data/src/ruby/pb/test/server.rb +10 -25
- data/src/ruby/spec/call_credentials_spec.rb +10 -25
- data/src/ruby/spec/call_spec.rb +43 -25
- data/src/ruby/spec/channel_connection_spec.rb +10 -25
- data/src/ruby/spec/channel_credentials_spec.rb +11 -26
- data/src/ruby/spec/channel_spec.rb +10 -25
- data/src/ruby/spec/client_auth_spec.rb +10 -25
- data/src/ruby/spec/client_server_spec.rb +66 -25
- data/src/ruby/spec/compression_options_spec.rb +10 -25
- data/src/ruby/spec/error_sanity_spec.rb +10 -25
- data/src/ruby/spec/generic/active_call_spec.rb +10 -25
- data/src/ruby/spec/generic/client_stub_spec.rb +146 -35
- data/src/ruby/spec/generic/rpc_desc_spec.rb +10 -25
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +10 -25
- data/src/ruby/spec/generic/rpc_server_spec.rb +124 -34
- data/src/ruby/spec/generic/service_spec.rb +10 -25
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +10 -25
- data/src/ruby/spec/pb/health/checker_spec.rb +10 -25
- data/src/ruby/spec/server_credentials_spec.rb +10 -25
- data/src/ruby/spec/server_spec.rb +10 -25
- data/src/ruby/spec/spec_helper.rb +10 -25
- data/src/ruby/spec/time_consts_spec.rb +10 -25
- data/third_party/boringssl/crypto/aes/key_wrap.c +138 -0
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +6 -3
- data/third_party/boringssl/crypto/asn1/a_enum.c +4 -1
- data/third_party/boringssl/crypto/asn1/a_gentm.c +20 -15
- data/third_party/boringssl/crypto/asn1/a_int.c +7 -4
- data/third_party/boringssl/crypto/asn1/a_object.c +5 -2
- data/third_party/boringssl/crypto/asn1/a_time.c +0 -1
- data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -2
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -2
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +35 -0
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +3 -1
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +6 -3
- data/third_party/boringssl/crypto/asn1/tasn_new.c +12 -7
- data/third_party/boringssl/crypto/asn1/tasn_utl.c +22 -8
- data/third_party/boringssl/crypto/{time_support.c → asn1/time_support.c} +1 -1
- data/third_party/boringssl/crypto/asn1/x_long.c +5 -2
- data/third_party/boringssl/crypto/base64/base64.c +7 -5
- data/third_party/boringssl/crypto/bio/bio.c +24 -10
- data/third_party/boringssl/crypto/bio/bio_mem.c +12 -10
- data/third_party/boringssl/crypto/bio/connect.c +7 -18
- data/third_party/boringssl/crypto/bio/fd.c +3 -6
- data/third_party/boringssl/crypto/bio/file.c +6 -6
- data/third_party/boringssl/crypto/bio/hexdump.c +4 -2
- data/third_party/boringssl/crypto/bio/pair.c +30 -344
- data/third_party/boringssl/crypto/bio/socket.c +6 -7
- data/third_party/boringssl/crypto/bio/socket_helper.c +4 -3
- data/third_party/boringssl/crypto/bn/add.c +1 -1
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +11 -10
- data/third_party/boringssl/crypto/bn/bn.c +6 -20
- data/third_party/boringssl/crypto/bn/cmp.c +14 -0
- data/third_party/boringssl/crypto/bn/convert.c +73 -2
- data/third_party/boringssl/crypto/bn/ctx.c +3 -1
- data/third_party/boringssl/crypto/bn/div.c +108 -51
- data/third_party/boringssl/crypto/bn/exponentiation.c +15 -33
- data/third_party/boringssl/crypto/bn/gcd.c +29 -22
- data/third_party/boringssl/crypto/bn/generic.c +71 -67
- data/third_party/boringssl/crypto/bn/internal.h +19 -6
- data/third_party/boringssl/crypto/bn/kronecker.c +1 -0
- data/third_party/boringssl/crypto/bn/montgomery.c +9 -10
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +47 -0
- data/third_party/boringssl/crypto/bn/mul.c +11 -9
- data/third_party/boringssl/crypto/bn/random.c +6 -3
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -65
- data/third_party/boringssl/crypto/bn/rsaz_exp.h +0 -3
- data/third_party/boringssl/crypto/bn/shift.c +9 -1
- data/third_party/boringssl/crypto/bn/sqrt.c +3 -1
- data/third_party/boringssl/crypto/buf/buf.c +6 -4
- data/third_party/boringssl/crypto/bytestring/asn1_compat.c +2 -1
- data/third_party/boringssl/crypto/bytestring/ber.c +2 -1
- data/third_party/boringssl/crypto/bytestring/cbb.c +9 -7
- data/third_party/boringssl/crypto/bytestring/cbs.c +54 -2
- data/third_party/boringssl/crypto/chacha/chacha.c +1 -1
- data/third_party/boringssl/crypto/cipher/aead.c +3 -3
- data/third_party/boringssl/crypto/cipher/cipher.c +18 -13
- data/third_party/boringssl/crypto/cipher/e_aes.c +335 -281
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +113 -137
- data/third_party/boringssl/crypto/cipher/e_null.c +2 -1
- data/third_party/boringssl/crypto/cipher/e_rc2.c +54 -49
- data/third_party/boringssl/crypto/cipher/e_ssl3.c +4 -3
- data/third_party/boringssl/crypto/cipher/e_tls.c +5 -5
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +41 -112
- data/third_party/boringssl/crypto/cmac/cmac.c +6 -4
- data/third_party/boringssl/crypto/conf/conf.c +6 -3
- data/third_party/boringssl/crypto/cpu-arm-linux.c +2 -2
- data/third_party/boringssl/crypto/curve25519/curve25519.c +28 -34
- data/third_party/boringssl/crypto/curve25519/spake25519.c +7 -6
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +2 -1
- data/third_party/boringssl/crypto/des/des.c +1 -1
- data/third_party/boringssl/crypto/des/internal.h +58 -46
- data/third_party/boringssl/crypto/dh/dh.c +4 -8
- data/third_party/boringssl/crypto/digest/digest.c +5 -2
- data/third_party/boringssl/crypto/digest/digests.c +70 -33
- data/third_party/boringssl/crypto/digest/md32_common.h +39 -27
- data/third_party/boringssl/crypto/dsa/dsa.c +11 -19
- data/third_party/boringssl/crypto/ec/ec.c +1 -1
- data/third_party/boringssl/crypto/ec/ec_asn1.c +3 -2
- data/third_party/boringssl/crypto/ec/ec_key.c +1 -1
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +6 -11
- data/third_party/boringssl/crypto/ec/oct.c +2 -14
- data/third_party/boringssl/crypto/ec/p224-64.c +78 -122
- data/third_party/boringssl/crypto/ec/p256-64.c +93 -133
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +48 -61
- data/third_party/boringssl/crypto/ec/p256-x86_64.h +113 -0
- data/third_party/boringssl/crypto/ec/simple.c +2 -1
- data/third_party/boringssl/crypto/ec/wnaf.c +52 -43
- data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -2
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +17 -16
- data/third_party/boringssl/crypto/engine/engine.c +3 -1
- data/third_party/boringssl/crypto/err/err.c +5 -5
- data/third_party/boringssl/crypto/evp/evp.c +1 -1
- data/third_party/boringssl/crypto/evp/evp_asn1.c +1 -1
- data/third_party/boringssl/crypto/evp/evp_ctx.c +23 -29
- data/third_party/boringssl/crypto/evp/p_ec.c +2 -1
- data/third_party/boringssl/crypto/evp/p_rsa.c +9 -3
- data/third_party/boringssl/crypto/evp/pbkdf.c +3 -1
- data/third_party/boringssl/crypto/hkdf/hkdf.c +3 -1
- data/third_party/boringssl/crypto/hmac/hmac.c +4 -2
- data/third_party/boringssl/crypto/internal.h +81 -0
- data/third_party/boringssl/crypto/lhash/lhash.c +7 -13
- data/third_party/boringssl/crypto/md4/md4.c +20 -18
- data/third_party/boringssl/crypto/md5/md5.c +31 -21
- data/third_party/boringssl/crypto/mem.c +4 -10
- data/third_party/boringssl/crypto/modes/cbc.c +2 -6
- data/third_party/boringssl/crypto/modes/cfb.c +2 -2
- data/third_party/boringssl/crypto/modes/ctr.c +1 -1
- data/third_party/boringssl/crypto/modes/gcm.c +117 -334
- data/third_party/boringssl/crypto/modes/internal.h +107 -84
- data/third_party/boringssl/crypto/modes/ofb.c +3 -3
- data/third_party/boringssl/crypto/modes/polyval.c +94 -0
- data/third_party/boringssl/crypto/obj/obj.c +13 -8
- data/third_party/boringssl/crypto/obj/obj_dat.h +6109 -5187
- data/third_party/boringssl/crypto/obj/obj_xref.c +55 -57
- data/third_party/boringssl/crypto/pem/pem_lib.c +6 -3
- data/third_party/boringssl/crypto/pkcs8/internal.h +27 -8
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +137 -352
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +371 -364
- data/third_party/boringssl/crypto/poly1305/poly1305.c +12 -18
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +2 -2
- data/third_party/boringssl/crypto/{newhope/reduce.c → pool/internal.h} +24 -21
- data/third_party/boringssl/crypto/pool/pool.c +200 -0
- data/third_party/boringssl/crypto/rand/deterministic.c +6 -5
- data/third_party/boringssl/crypto/rand/fuchsia.c +43 -0
- data/third_party/boringssl/crypto/rand/rand.c +7 -7
- data/third_party/boringssl/crypto/rand/urandom.c +136 -22
- data/third_party/boringssl/crypto/rand/windows.c +2 -2
- data/third_party/boringssl/crypto/rsa/blinding.c +2 -1
- data/third_party/boringssl/crypto/rsa/padding.c +11 -11
- data/third_party/boringssl/crypto/rsa/rsa.c +4 -4
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +7 -1
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +41 -80
- data/third_party/boringssl/crypto/sha/sha1-altivec.c +346 -0
- data/third_party/boringssl/crypto/sha/sha1.c +60 -42
- data/third_party/boringssl/crypto/sha/sha256.c +4 -2
- data/third_party/boringssl/crypto/sha/sha512.c +9 -7
- data/third_party/boringssl/crypto/stack/stack.c +10 -7
- data/third_party/boringssl/crypto/thread_pthread.c +2 -2
- data/third_party/boringssl/crypto/thread_win.c +2 -2
- data/third_party/boringssl/crypto/x509/a_verify.c +1 -1
- data/third_party/boringssl/crypto/x509/asn1_gen.c +1 -1
- data/third_party/boringssl/crypto/x509/by_dir.c +1 -1
- data/third_party/boringssl/crypto/x509/t_x509.c +78 -38
- data/third_party/boringssl/crypto/x509/x509_cmp.c +8 -5
- data/third_party/boringssl/crypto/x509/x509_lu.c +6 -1
- data/third_party/boringssl/crypto/x509/x509_obj.c +4 -1
- data/third_party/boringssl/crypto/x509/x509_vfy.c +42 -8
- data/third_party/boringssl/crypto/x509/x509_vpm.c +8 -6
- data/third_party/boringssl/crypto/x509/x509name.c +4 -1
- data/third_party/boringssl/crypto/x509/x_crl.c +4 -2
- data/third_party/boringssl/crypto/x509/x_name.c +23 -13
- data/third_party/boringssl/crypto/x509/x_pkey.c +4 -1
- data/third_party/boringssl/crypto/x509/x_x509.c +42 -3
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +1 -1
- data/third_party/boringssl/crypto/x509v3/v3_ia5.c +4 -1
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +4 -1
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +6 -3
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +13 -21
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +19 -33
- data/third_party/boringssl/include/openssl/aead.h +9 -20
- data/third_party/boringssl/include/openssl/aes.h +21 -9
- data/third_party/boringssl/include/openssl/asn1.h +9 -1
- data/third_party/boringssl/include/openssl/base.h +33 -6
- data/third_party/boringssl/include/openssl/bio.h +10 -103
- data/third_party/boringssl/include/openssl/bn.h +58 -42
- data/third_party/boringssl/include/openssl/bytestring.h +17 -0
- data/third_party/boringssl/include/openssl/cipher.h +4 -3
- data/third_party/boringssl/include/openssl/conf.h +4 -1
- data/third_party/boringssl/include/openssl/curve25519.h +13 -0
- data/third_party/boringssl/include/openssl/digest.h +5 -3
- data/third_party/boringssl/include/openssl/dsa.h +5 -5
- data/third_party/boringssl/include/openssl/ec.h +2 -2
- data/third_party/boringssl/include/openssl/ecdh.h +3 -4
- data/third_party/boringssl/include/openssl/ecdsa.h +10 -10
- data/third_party/boringssl/include/openssl/err.h +5 -5
- data/third_party/boringssl/include/openssl/evp.h +11 -7
- data/third_party/boringssl/include/openssl/lhash.h +2 -3
- data/third_party/boringssl/include/openssl/lhash_macros.h +56 -14
- data/third_party/boringssl/include/openssl/nid.h +2949 -2916
- data/third_party/boringssl/include/openssl/obj.h +1 -1
- data/third_party/boringssl/include/openssl/pkcs8.h +21 -42
- data/third_party/boringssl/include/openssl/pool.h +87 -0
- data/third_party/boringssl/include/openssl/rand.h +1 -1
- data/third_party/boringssl/include/openssl/rsa.h +4 -2
- data/third_party/boringssl/include/openssl/sha.h +0 -4
- data/third_party/boringssl/include/openssl/ssl.h +327 -662
- data/third_party/boringssl/include/openssl/ssl3.h +1 -21
- data/third_party/boringssl/include/openssl/stack.h +1 -0
- data/third_party/boringssl/include/openssl/stack_macros.h +85 -0
- data/third_party/boringssl/include/openssl/tls1.h +23 -52
- data/third_party/boringssl/include/openssl/type_check.h +4 -0
- data/third_party/boringssl/include/openssl/x509.h +10 -59
- data/third_party/boringssl/include/openssl/x509_vfy.h +7 -1
- data/third_party/boringssl/include/openssl/x509v3.h +4 -4
- data/third_party/boringssl/ssl/bio_ssl.c +175 -0
- data/third_party/boringssl/ssl/custom_extensions.c +24 -21
- data/third_party/boringssl/ssl/d1_both.c +259 -289
- data/third_party/boringssl/ssl/d1_lib.c +8 -20
- data/third_party/boringssl/ssl/d1_pkt.c +6 -15
- data/third_party/boringssl/ssl/dtls_method.c +22 -8
- data/third_party/boringssl/ssl/dtls_record.c +27 -2
- data/third_party/boringssl/ssl/handshake_client.c +460 -579
- data/third_party/boringssl/ssl/handshake_server.c +662 -644
- data/third_party/boringssl/ssl/internal.h +1009 -375
- data/third_party/boringssl/ssl/s3_both.c +312 -162
- data/third_party/boringssl/ssl/s3_lib.c +12 -128
- data/third_party/boringssl/ssl/s3_pkt.c +22 -30
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +28 -22
- data/third_party/boringssl/ssl/ssl_asn1.c +210 -114
- data/third_party/boringssl/ssl/ssl_buffer.c +2 -1
- data/third_party/boringssl/ssl/ssl_cert.c +417 -219
- data/third_party/boringssl/ssl/ssl_cipher.c +191 -393
- data/third_party/boringssl/ssl/ssl_ecdh.c +19 -164
- data/third_party/boringssl/ssl/ssl_file.c +0 -11
- data/third_party/boringssl/ssl/ssl_lib.c +325 -652
- data/third_party/boringssl/ssl/{ssl_rsa.c → ssl_privkey.c} +21 -131
- data/third_party/boringssl/ssl/ssl_privkey_cc.cc +76 -0
- data/third_party/boringssl/ssl/ssl_session.c +206 -95
- data/third_party/boringssl/ssl/ssl_stat.c +18 -84
- data/third_party/boringssl/ssl/{s3_enc.c → ssl_transcript.c} +150 -157
- data/third_party/boringssl/ssl/ssl_x509.c +815 -0
- data/third_party/boringssl/ssl/t1_enc.c +188 -174
- data/third_party/boringssl/ssl/t1_lib.c +1064 -764
- data/third_party/boringssl/ssl/tls13_both.c +290 -96
- data/third_party/boringssl/ssl/tls13_client.c +344 -314
- data/third_party/boringssl/ssl/tls13_enc.c +239 -200
- data/third_party/boringssl/ssl/tls13_server.c +374 -366
- data/third_party/boringssl/ssl/tls_method.c +40 -5
- data/third_party/boringssl/ssl/tls_record.c +166 -71
- metadata +39 -25
- data/src/core/lib/iomgr/workqueue.h +0 -87
- data/src/core/lib/iomgr/workqueue_uv.c +0 -65
- data/src/core/lib/iomgr/workqueue_uv.h +0 -37
- data/src/core/lib/iomgr/workqueue_windows.c +0 -63
- data/src/core/lib/iomgr/workqueue_windows.h +0 -37
- data/third_party/boringssl/crypto/bio/buffer.c +0 -496
- data/third_party/boringssl/crypto/newhope/error_correction.c +0 -131
- data/third_party/boringssl/crypto/newhope/internal.h +0 -71
- data/third_party/boringssl/crypto/newhope/newhope.c +0 -174
- data/third_party/boringssl/crypto/newhope/ntt.c +0 -148
- data/third_party/boringssl/crypto/newhope/poly.c +0 -183
- data/third_party/boringssl/crypto/newhope/precomp.c +0 -306
- data/third_party/boringssl/crypto/obj/obj_xref.h +0 -96
- data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +0 -151
- data/third_party/boringssl/include/openssl/newhope.h +0 -158
- data/third_party/boringssl/include/openssl/time_support.h +0 -91
@@ -171,184 +171,178 @@
|
|
171
171
|
#include "../crypto/internal.h"
|
172
172
|
|
173
173
|
|
174
|
-
static int
|
175
|
-
static int
|
176
|
-
static int
|
177
|
-
static int
|
178
|
-
static int
|
179
|
-
static int
|
180
|
-
static int
|
181
|
-
static int
|
182
|
-
static int
|
183
|
-
static int
|
184
|
-
static int
|
185
|
-
static int
|
186
|
-
static int
|
187
|
-
|
188
|
-
int
|
174
|
+
static int ssl3_process_client_hello(SSL_HANDSHAKE *hs);
|
175
|
+
static int ssl3_select_certificate(SSL_HANDSHAKE *hs);
|
176
|
+
static int ssl3_select_parameters(SSL_HANDSHAKE *hs);
|
177
|
+
static int ssl3_send_server_hello(SSL_HANDSHAKE *hs);
|
178
|
+
static int ssl3_send_server_certificate(SSL_HANDSHAKE *hs);
|
179
|
+
static int ssl3_send_certificate_status(SSL_HANDSHAKE *hs);
|
180
|
+
static int ssl3_send_server_key_exchange(SSL_HANDSHAKE *hs);
|
181
|
+
static int ssl3_send_certificate_request(SSL_HANDSHAKE *hs);
|
182
|
+
static int ssl3_send_server_hello_done(SSL_HANDSHAKE *hs);
|
183
|
+
static int ssl3_get_client_certificate(SSL_HANDSHAKE *hs);
|
184
|
+
static int ssl3_get_client_key_exchange(SSL_HANDSHAKE *hs);
|
185
|
+
static int ssl3_get_cert_verify(SSL_HANDSHAKE *hs);
|
186
|
+
static int ssl3_get_next_proto(SSL_HANDSHAKE *hs);
|
187
|
+
static int ssl3_get_channel_id(SSL_HANDSHAKE *hs);
|
188
|
+
static int ssl3_send_new_session_ticket(SSL_HANDSHAKE *hs);
|
189
|
+
|
190
|
+
static struct CRYPTO_STATIC_MUTEX g_v2clienthello_lock =
|
191
|
+
CRYPTO_STATIC_MUTEX_INIT;
|
192
|
+
static uint64_t g_v2clienthello_count = 0;
|
193
|
+
|
194
|
+
uint64_t SSL_get_v2clienthello_count(void) {
|
195
|
+
CRYPTO_STATIC_MUTEX_lock_read(&g_v2clienthello_lock);
|
196
|
+
uint64_t ret = g_v2clienthello_count;
|
197
|
+
CRYPTO_STATIC_MUTEX_unlock_read(&g_v2clienthello_lock);
|
198
|
+
return ret;
|
199
|
+
}
|
200
|
+
|
201
|
+
int ssl3_accept(SSL_HANDSHAKE *hs) {
|
202
|
+
SSL *const ssl = hs->ssl;
|
189
203
|
uint32_t alg_a;
|
190
204
|
int ret = -1;
|
191
|
-
int state, skip = 0;
|
192
205
|
|
193
206
|
assert(ssl->handshake_func == ssl3_accept);
|
194
207
|
assert(ssl->server);
|
195
208
|
|
196
209
|
for (;;) {
|
197
|
-
state =
|
210
|
+
int state = hs->state;
|
198
211
|
|
199
|
-
switch (
|
212
|
+
switch (hs->state) {
|
200
213
|
case SSL_ST_INIT:
|
201
|
-
ssl->state = SSL_ST_ACCEPT;
|
202
|
-
skip = 1;
|
203
|
-
break;
|
204
|
-
|
205
|
-
case SSL_ST_ACCEPT:
|
206
214
|
ssl_do_info_callback(ssl, SSL_CB_HANDSHAKE_START, 1);
|
215
|
+
hs->state = SSL3_ST_SR_CLNT_HELLO_A;
|
216
|
+
break;
|
207
217
|
|
208
|
-
|
209
|
-
|
210
|
-
|
218
|
+
case SSL3_ST_SR_CLNT_HELLO_A:
|
219
|
+
ret = ssl->method->ssl_get_message(ssl);
|
220
|
+
if (ret <= 0) {
|
211
221
|
goto end;
|
212
222
|
}
|
223
|
+
hs->state = SSL3_ST_SR_CLNT_HELLO_B;
|
224
|
+
break;
|
213
225
|
|
214
|
-
|
215
|
-
|
216
|
-
if (
|
217
|
-
ret = -1;
|
226
|
+
case SSL3_ST_SR_CLNT_HELLO_B:
|
227
|
+
ret = ssl3_process_client_hello(hs);
|
228
|
+
if (ret <= 0) {
|
218
229
|
goto end;
|
219
230
|
}
|
231
|
+
hs->state = SSL3_ST_SR_CLNT_HELLO_C;
|
232
|
+
break;
|
220
233
|
|
221
|
-
|
222
|
-
|
223
|
-
|
234
|
+
case SSL3_ST_SR_CLNT_HELLO_C:
|
235
|
+
ret = ssl3_select_certificate(hs);
|
236
|
+
if (ret <= 0) {
|
224
237
|
goto end;
|
225
238
|
}
|
226
|
-
|
227
|
-
|
239
|
+
if (hs->state != SSL_ST_TLS13) {
|
240
|
+
hs->state = SSL3_ST_SR_CLNT_HELLO_D;
|
241
|
+
}
|
228
242
|
break;
|
229
243
|
|
230
|
-
case SSL3_ST_SR_CLNT_HELLO_A:
|
231
|
-
case SSL3_ST_SR_CLNT_HELLO_B:
|
232
|
-
case SSL3_ST_SR_CLNT_HELLO_C:
|
233
244
|
case SSL3_ST_SR_CLNT_HELLO_D:
|
234
|
-
ret =
|
235
|
-
if (ssl->state == SSL_ST_TLS13) {
|
236
|
-
break;
|
237
|
-
}
|
245
|
+
ret = ssl3_select_parameters(hs);
|
238
246
|
if (ret <= 0) {
|
239
247
|
goto end;
|
240
248
|
}
|
241
249
|
ssl->method->received_flight(ssl);
|
242
|
-
|
250
|
+
hs->state = SSL3_ST_SW_SRVR_HELLO_A;
|
243
251
|
break;
|
244
252
|
|
245
253
|
case SSL3_ST_SW_SRVR_HELLO_A:
|
246
|
-
|
247
|
-
ret = ssl3_send_server_hello(ssl);
|
254
|
+
ret = ssl3_send_server_hello(hs);
|
248
255
|
if (ret <= 0) {
|
249
256
|
goto end;
|
250
257
|
}
|
251
258
|
if (ssl->session != NULL) {
|
252
|
-
|
259
|
+
hs->state = SSL3_ST_SW_SESSION_TICKET_A;
|
253
260
|
} else {
|
254
|
-
|
261
|
+
hs->state = SSL3_ST_SW_CERT_A;
|
255
262
|
}
|
256
263
|
break;
|
257
264
|
|
258
265
|
case SSL3_ST_SW_CERT_A:
|
259
|
-
|
260
|
-
|
261
|
-
ret = ssl3_send_server_certificate(ssl);
|
266
|
+
if (ssl_cipher_uses_certificate_auth(hs->new_cipher)) {
|
267
|
+
ret = ssl3_send_server_certificate(hs);
|
262
268
|
if (ret <= 0) {
|
263
269
|
goto end;
|
264
270
|
}
|
265
|
-
} else {
|
266
|
-
skip = 1;
|
267
271
|
}
|
268
|
-
|
272
|
+
hs->state = SSL3_ST_SW_CERT_STATUS_A;
|
269
273
|
break;
|
270
274
|
|
271
275
|
case SSL3_ST_SW_CERT_STATUS_A:
|
272
|
-
|
273
|
-
|
274
|
-
ret = ssl3_send_certificate_status(ssl);
|
276
|
+
if (hs->certificate_status_expected) {
|
277
|
+
ret = ssl3_send_certificate_status(hs);
|
275
278
|
if (ret <= 0) {
|
276
279
|
goto end;
|
277
280
|
}
|
278
|
-
} else {
|
279
|
-
skip = 1;
|
280
281
|
}
|
281
|
-
|
282
|
+
hs->state = SSL3_ST_SW_KEY_EXCH_A;
|
282
283
|
break;
|
283
284
|
|
284
285
|
case SSL3_ST_SW_KEY_EXCH_A:
|
285
286
|
case SSL3_ST_SW_KEY_EXCH_B:
|
286
|
-
|
287
|
-
alg_a = ssl->s3->tmp.new_cipher->algorithm_auth;
|
287
|
+
alg_a = hs->new_cipher->algorithm_auth;
|
288
288
|
|
289
289
|
/* PSK ciphers send ServerKeyExchange if there is an identity hint. */
|
290
|
-
if (ssl_cipher_requires_server_key_exchange(
|
290
|
+
if (ssl_cipher_requires_server_key_exchange(hs->new_cipher) ||
|
291
291
|
((alg_a & SSL_aPSK) && ssl->psk_identity_hint)) {
|
292
|
-
ret = ssl3_send_server_key_exchange(
|
292
|
+
ret = ssl3_send_server_key_exchange(hs);
|
293
293
|
if (ret <= 0) {
|
294
294
|
goto end;
|
295
295
|
}
|
296
|
-
} else {
|
297
|
-
skip = 1;
|
298
296
|
}
|
299
297
|
|
300
|
-
|
298
|
+
hs->state = SSL3_ST_SW_CERT_REQ_A;
|
301
299
|
break;
|
302
300
|
|
303
301
|
case SSL3_ST_SW_CERT_REQ_A:
|
304
|
-
|
305
|
-
|
306
|
-
ret = ssl3_send_certificate_request(ssl);
|
302
|
+
if (hs->cert_request) {
|
303
|
+
ret = ssl3_send_certificate_request(hs);
|
307
304
|
if (ret <= 0) {
|
308
305
|
goto end;
|
309
306
|
}
|
310
|
-
} else {
|
311
|
-
skip = 1;
|
312
307
|
}
|
313
|
-
|
308
|
+
hs->state = SSL3_ST_SW_SRVR_DONE_A;
|
314
309
|
break;
|
315
310
|
|
316
311
|
case SSL3_ST_SW_SRVR_DONE_A:
|
317
|
-
|
318
|
-
ret = ssl3_send_server_hello_done(ssl);
|
312
|
+
ret = ssl3_send_server_hello_done(hs);
|
319
313
|
if (ret <= 0) {
|
320
314
|
goto end;
|
321
315
|
}
|
322
|
-
|
323
|
-
|
316
|
+
hs->next_state = SSL3_ST_SR_CERT_A;
|
317
|
+
hs->state = SSL3_ST_SW_FLUSH;
|
324
318
|
break;
|
325
319
|
|
326
320
|
case SSL3_ST_SR_CERT_A:
|
327
|
-
if (
|
328
|
-
ret = ssl3_get_client_certificate(
|
321
|
+
if (hs->cert_request) {
|
322
|
+
ret = ssl3_get_client_certificate(hs);
|
329
323
|
if (ret <= 0) {
|
330
324
|
goto end;
|
331
325
|
}
|
332
326
|
}
|
333
|
-
|
327
|
+
hs->state = SSL3_ST_SR_KEY_EXCH_A;
|
334
328
|
break;
|
335
329
|
|
336
330
|
case SSL3_ST_SR_KEY_EXCH_A:
|
337
331
|
case SSL3_ST_SR_KEY_EXCH_B:
|
338
|
-
ret = ssl3_get_client_key_exchange(
|
332
|
+
ret = ssl3_get_client_key_exchange(hs);
|
339
333
|
if (ret <= 0) {
|
340
334
|
goto end;
|
341
335
|
}
|
342
|
-
|
336
|
+
hs->state = SSL3_ST_SR_CERT_VRFY_A;
|
343
337
|
break;
|
344
338
|
|
345
339
|
case SSL3_ST_SR_CERT_VRFY_A:
|
346
|
-
ret = ssl3_get_cert_verify(
|
340
|
+
ret = ssl3_get_cert_verify(hs);
|
347
341
|
if (ret <= 0) {
|
348
342
|
goto end;
|
349
343
|
}
|
350
344
|
|
351
|
-
|
345
|
+
hs->state = SSL3_ST_SR_CHANGE;
|
352
346
|
break;
|
353
347
|
|
354
348
|
case SSL3_ST_SR_CHANGE:
|
@@ -357,56 +351,52 @@ int ssl3_accept(SSL *ssl) {
|
|
357
351
|
goto end;
|
358
352
|
}
|
359
353
|
|
360
|
-
if (!tls1_change_cipher_state(
|
354
|
+
if (!tls1_change_cipher_state(hs, SSL3_CHANGE_CIPHER_SERVER_READ)) {
|
361
355
|
ret = -1;
|
362
356
|
goto end;
|
363
357
|
}
|
364
358
|
|
365
|
-
|
359
|
+
hs->state = SSL3_ST_SR_NEXT_PROTO_A;
|
366
360
|
break;
|
367
361
|
|
368
362
|
case SSL3_ST_SR_NEXT_PROTO_A:
|
369
|
-
if (
|
370
|
-
ret = ssl3_get_next_proto(
|
363
|
+
if (hs->next_proto_neg_seen) {
|
364
|
+
ret = ssl3_get_next_proto(hs);
|
371
365
|
if (ret <= 0) {
|
372
366
|
goto end;
|
373
367
|
}
|
374
|
-
} else {
|
375
|
-
skip = 1;
|
376
368
|
}
|
377
|
-
|
369
|
+
hs->state = SSL3_ST_SR_CHANNEL_ID_A;
|
378
370
|
break;
|
379
371
|
|
380
372
|
case SSL3_ST_SR_CHANNEL_ID_A:
|
381
373
|
if (ssl->s3->tlsext_channel_id_valid) {
|
382
|
-
ret = ssl3_get_channel_id(
|
374
|
+
ret = ssl3_get_channel_id(hs);
|
383
375
|
if (ret <= 0) {
|
384
376
|
goto end;
|
385
377
|
}
|
386
|
-
} else {
|
387
|
-
skip = 1;
|
388
378
|
}
|
389
|
-
|
379
|
+
hs->state = SSL3_ST_SR_FINISHED_A;
|
390
380
|
break;
|
391
381
|
|
392
382
|
case SSL3_ST_SR_FINISHED_A:
|
393
|
-
ret = ssl3_get_finished(
|
383
|
+
ret = ssl3_get_finished(hs);
|
394
384
|
if (ret <= 0) {
|
395
385
|
goto end;
|
396
386
|
}
|
397
387
|
|
398
388
|
ssl->method->received_flight(ssl);
|
399
389
|
if (ssl->session != NULL) {
|
400
|
-
|
390
|
+
hs->state = SSL_ST_OK;
|
401
391
|
} else {
|
402
|
-
|
392
|
+
hs->state = SSL3_ST_SW_SESSION_TICKET_A;
|
403
393
|
}
|
404
394
|
|
405
395
|
/* If this is a full handshake with ChannelID then record the handshake
|
406
|
-
* hashes in |
|
396
|
+
* hashes in |hs->new_session| in case we need them to verify a
|
407
397
|
* ChannelID signature on a resumption of this session in the future. */
|
408
398
|
if (ssl->session == NULL && ssl->s3->tlsext_channel_id_valid) {
|
409
|
-
ret = tls1_record_handshake_hashes_for_channel_id(
|
399
|
+
ret = tls1_record_handshake_hashes_for_channel_id(hs);
|
410
400
|
if (ret <= 0) {
|
411
401
|
goto end;
|
412
402
|
}
|
@@ -414,80 +404,68 @@ int ssl3_accept(SSL *ssl) {
|
|
414
404
|
break;
|
415
405
|
|
416
406
|
case SSL3_ST_SW_SESSION_TICKET_A:
|
417
|
-
|
418
|
-
|
419
|
-
ret = ssl3_send_new_session_ticket(ssl);
|
407
|
+
if (hs->ticket_expected) {
|
408
|
+
ret = ssl3_send_new_session_ticket(hs);
|
420
409
|
if (ret <= 0) {
|
421
410
|
goto end;
|
422
411
|
}
|
423
|
-
} else {
|
424
|
-
skip = 1;
|
425
412
|
}
|
426
|
-
|
413
|
+
hs->state = SSL3_ST_SW_CHANGE;
|
427
414
|
break;
|
428
415
|
|
429
416
|
case SSL3_ST_SW_CHANGE:
|
430
|
-
|
431
|
-
|
432
|
-
goto end;
|
433
|
-
}
|
434
|
-
ssl->state = SSL3_ST_SW_FINISHED_A;
|
435
|
-
|
436
|
-
if (!tls1_change_cipher_state(ssl, SSL3_CHANGE_CIPHER_SERVER_WRITE)) {
|
417
|
+
if (!ssl->method->add_change_cipher_spec(ssl) ||
|
418
|
+
!tls1_change_cipher_state(hs, SSL3_CHANGE_CIPHER_SERVER_WRITE)) {
|
437
419
|
ret = -1;
|
438
420
|
goto end;
|
439
421
|
}
|
422
|
+
|
423
|
+
hs->state = SSL3_ST_SW_FINISHED_A;
|
440
424
|
break;
|
441
425
|
|
442
426
|
case SSL3_ST_SW_FINISHED_A:
|
443
|
-
|
444
|
-
ret = ssl3_send_finished(ssl, SSL3_ST_SW_FINISHED_A,
|
445
|
-
SSL3_ST_SW_FINISHED_B);
|
427
|
+
ret = ssl3_send_finished(hs);
|
446
428
|
if (ret <= 0) {
|
447
429
|
goto end;
|
448
430
|
}
|
449
|
-
|
431
|
+
hs->state = SSL3_ST_SW_FLUSH;
|
450
432
|
if (ssl->session != NULL) {
|
451
|
-
|
433
|
+
hs->next_state = SSL3_ST_SR_CHANGE;
|
452
434
|
} else {
|
453
|
-
|
435
|
+
hs->next_state = SSL_ST_OK;
|
454
436
|
}
|
455
437
|
break;
|
456
438
|
|
457
439
|
case SSL3_ST_SW_FLUSH:
|
458
|
-
|
459
|
-
|
460
|
-
ret = -1;
|
440
|
+
ret = ssl->method->flush_flight(ssl);
|
441
|
+
if (ret <= 0) {
|
461
442
|
goto end;
|
462
443
|
}
|
463
444
|
|
464
|
-
|
465
|
-
if (
|
445
|
+
hs->state = hs->next_state;
|
446
|
+
if (hs->state != SSL_ST_OK) {
|
466
447
|
ssl->method->expect_flight(ssl);
|
467
448
|
}
|
468
449
|
break;
|
469
450
|
|
470
451
|
case SSL_ST_TLS13:
|
471
|
-
ret = tls13_handshake(
|
452
|
+
ret = tls13_handshake(hs);
|
472
453
|
if (ret <= 0) {
|
473
454
|
goto end;
|
474
455
|
}
|
475
|
-
|
456
|
+
hs->state = SSL_ST_OK;
|
476
457
|
break;
|
477
458
|
|
478
459
|
case SSL_ST_OK:
|
479
|
-
/* Clean a few things up. */
|
480
|
-
ssl3_cleanup_key_block(ssl);
|
481
460
|
ssl->method->release_current_message(ssl, 1 /* free_buffer */);
|
482
461
|
|
483
462
|
/* If we aren't retaining peer certificates then we can discard it
|
484
463
|
* now. */
|
485
|
-
if (
|
486
|
-
ssl->
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
ssl->s3->new_session->cert_chain = NULL;
|
464
|
+
if (hs->new_session != NULL &&
|
465
|
+
ssl->retain_only_sha256_of_client_certs) {
|
466
|
+
sk_CRYPTO_BUFFER_pop_free(hs->new_session->certs, CRYPTO_BUFFER_free);
|
467
|
+
hs->new_session->certs = NULL;
|
468
|
+
ssl->ctx->x509_method->session_clear(hs->new_session);
|
491
469
|
}
|
492
470
|
|
493
471
|
SSL_SESSION_free(ssl->s3->established_session);
|
@@ -495,23 +473,21 @@ int ssl3_accept(SSL *ssl) {
|
|
495
473
|
SSL_SESSION_up_ref(ssl->session);
|
496
474
|
ssl->s3->established_session = ssl->session;
|
497
475
|
} else {
|
498
|
-
ssl->s3->established_session =
|
476
|
+
ssl->s3->established_session = hs->new_session;
|
499
477
|
ssl->s3->established_session->not_resumable = 0;
|
500
|
-
|
478
|
+
hs->new_session = NULL;
|
501
479
|
}
|
502
480
|
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
481
|
+
if (hs->v2_clienthello) {
|
482
|
+
CRYPTO_STATIC_MUTEX_lock_write(&g_v2clienthello_lock);
|
483
|
+
g_v2clienthello_count++;
|
484
|
+
CRYPTO_STATIC_MUTEX_unlock_write(&g_v2clienthello_lock);
|
485
|
+
}
|
508
486
|
|
509
487
|
ssl->s3->initial_handshake_complete = 1;
|
510
|
-
|
511
|
-
ssl_update_cache(ssl, SSL_SESS_CACHE_SERVER);
|
488
|
+
ssl_update_cache(hs, SSL_SESS_CACHE_SERVER);
|
512
489
|
|
513
490
|
ssl_do_info_callback(ssl, SSL_CB_HANDSHAKE_DONE, 1);
|
514
|
-
|
515
491
|
ret = 1;
|
516
492
|
goto end;
|
517
493
|
|
@@ -521,13 +497,9 @@ int ssl3_accept(SSL *ssl) {
|
|
521
497
|
goto end;
|
522
498
|
}
|
523
499
|
|
524
|
-
if (
|
525
|
-
int new_state = ssl->state;
|
526
|
-
ssl->state = state;
|
500
|
+
if (hs->state != state) {
|
527
501
|
ssl_do_info_callback(ssl, SSL_CB_ACCEPT_LOOP, 1);
|
528
|
-
ssl->state = new_state;
|
529
502
|
}
|
530
|
-
skip = 0;
|
531
503
|
}
|
532
504
|
|
533
505
|
end:
|
@@ -535,8 +507,8 @@ end:
|
|
535
507
|
return ret;
|
536
508
|
}
|
537
509
|
|
538
|
-
int ssl_client_cipher_list_contains_cipher(
|
539
|
-
|
510
|
+
int ssl_client_cipher_list_contains_cipher(const SSL_CLIENT_HELLO *client_hello,
|
511
|
+
uint16_t id) {
|
540
512
|
CBS cipher_suites;
|
541
513
|
CBS_init(&cipher_suites, client_hello->cipher_suites,
|
542
514
|
client_hello->cipher_suites_len);
|
@@ -555,9 +527,10 @@ int ssl_client_cipher_list_contains_cipher(
|
|
555
527
|
return 0;
|
556
528
|
}
|
557
529
|
|
558
|
-
static int negotiate_version(
|
559
|
-
|
560
|
-
|
530
|
+
static int negotiate_version(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
531
|
+
const SSL_CLIENT_HELLO *client_hello) {
|
532
|
+
SSL *const ssl = hs->ssl;
|
533
|
+
assert(!ssl->s3->have_version);
|
561
534
|
uint16_t min_version, max_version;
|
562
535
|
if (!ssl_get_version_range(ssl, &min_version, &max_version)) {
|
563
536
|
*out_alert = SSL_AD_PROTOCOL_VERSION;
|
@@ -567,8 +540,8 @@ static int negotiate_version(
|
|
567
540
|
uint16_t version = 0;
|
568
541
|
/* Check supported_versions extension if it is present. */
|
569
542
|
CBS supported_versions;
|
570
|
-
if (
|
571
|
-
|
543
|
+
if (ssl_client_hello_get_extension(client_hello, &supported_versions,
|
544
|
+
TLSEXT_TYPE_supported_versions)) {
|
572
545
|
CBS versions;
|
573
546
|
if (!CBS_get_u8_length_prefixed(&supported_versions, &versions) ||
|
574
547
|
CBS_len(&supported_versions) != 0 ||
|
@@ -578,6 +551,9 @@ static int negotiate_version(
|
|
578
551
|
return 0;
|
579
552
|
}
|
580
553
|
|
554
|
+
/* Choose the newest commonly-supported version advertised by the client.
|
555
|
+
* The client orders the versions according to its preferences, but we're
|
556
|
+
* not required to honor the client's preferences. */
|
581
557
|
int found_version = 0;
|
582
558
|
while (CBS_len(&versions) != 0) {
|
583
559
|
uint16_t ext_version;
|
@@ -590,10 +566,10 @@ static int negotiate_version(
|
|
590
566
|
continue;
|
591
567
|
}
|
592
568
|
if (min_version <= ext_version &&
|
593
|
-
ext_version <= max_version
|
569
|
+
ext_version <= max_version &&
|
570
|
+
(!found_version || version < ext_version)) {
|
594
571
|
version = ext_version;
|
595
572
|
found_version = 1;
|
596
|
-
break;
|
597
573
|
}
|
598
574
|
}
|
599
575
|
|
@@ -644,10 +620,8 @@ static int negotiate_version(
|
|
644
620
|
return 0;
|
645
621
|
}
|
646
622
|
|
647
|
-
|
623
|
+
hs->client_version = client_hello->version;
|
648
624
|
ssl->version = ssl->method->version_to_wire(version);
|
649
|
-
ssl->s3->enc_method = ssl3_get_enc_method(version);
|
650
|
-
assert(ssl->s3->enc_method != NULL);
|
651
625
|
|
652
626
|
/* At this point, the connection's version is known and |ssl->version| is
|
653
627
|
* fixed. Begin enforcing the record-layer version. */
|
@@ -661,235 +635,397 @@ unsupported_protocol:
|
|
661
635
|
return 0;
|
662
636
|
}
|
663
637
|
|
664
|
-
static
|
665
|
-
|
666
|
-
|
638
|
+
static STACK_OF(SSL_CIPHER) *
|
639
|
+
ssl_parse_client_cipher_list(const SSL_CLIENT_HELLO *client_hello) {
|
640
|
+
CBS cipher_suites;
|
641
|
+
CBS_init(&cipher_suites, client_hello->cipher_suites,
|
642
|
+
client_hello->cipher_suites_len);
|
643
|
+
|
644
|
+
STACK_OF(SSL_CIPHER) *sk = sk_SSL_CIPHER_new_null();
|
645
|
+
if (sk == NULL) {
|
646
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
|
647
|
+
goto err;
|
648
|
+
}
|
667
649
|
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
650
|
+
while (CBS_len(&cipher_suites) > 0) {
|
651
|
+
uint16_t cipher_suite;
|
652
|
+
|
653
|
+
if (!CBS_get_u16(&cipher_suites, &cipher_suite)) {
|
654
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);
|
655
|
+
goto err;
|
674
656
|
}
|
675
657
|
|
676
|
-
|
658
|
+
const SSL_CIPHER *c = SSL_get_cipher_by_value(cipher_suite);
|
659
|
+
if (c != NULL && !sk_SSL_CIPHER_push(sk, c)) {
|
660
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
|
661
|
+
goto err;
|
662
|
+
}
|
677
663
|
}
|
678
664
|
|
679
|
-
|
680
|
-
if (!ssl_early_callback_init(ssl, &client_hello, ssl->init_msg,
|
681
|
-
ssl->init_num)) {
|
682
|
-
al = SSL_AD_DECODE_ERROR;
|
683
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
684
|
-
goto f_err;
|
685
|
-
}
|
665
|
+
return sk;
|
686
666
|
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
667
|
+
err:
|
668
|
+
sk_SSL_CIPHER_free(sk);
|
669
|
+
return NULL;
|
670
|
+
}
|
691
671
|
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
672
|
+
/* ssl_get_compatible_server_ciphers determines the key exchange and
|
673
|
+
* authentication cipher suite masks compatible with the server configuration
|
674
|
+
* and current ClientHello parameters of |hs|. It sets |*out_mask_k| to the key
|
675
|
+
* exchange mask and |*out_mask_a| to the authentication mask. */
|
676
|
+
static void ssl_get_compatible_server_ciphers(SSL_HANDSHAKE *hs,
|
677
|
+
uint32_t *out_mask_k,
|
678
|
+
uint32_t *out_mask_a) {
|
679
|
+
SSL *const ssl = hs->ssl;
|
680
|
+
if (ssl3_protocol_version(ssl) >= TLS1_3_VERSION) {
|
681
|
+
*out_mask_k = SSL_kGENERIC;
|
682
|
+
*out_mask_a = SSL_aGENERIC;
|
683
|
+
return;
|
684
|
+
}
|
698
685
|
|
699
|
-
|
700
|
-
|
701
|
-
al = SSL_AD_HANDSHAKE_FAILURE;
|
702
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_REJECTED);
|
703
|
-
goto f_err;
|
686
|
+
uint32_t mask_k = 0;
|
687
|
+
uint32_t mask_a = 0;
|
704
688
|
|
705
|
-
|
706
|
-
|
707
|
-
|
689
|
+
if (ssl_has_certificate(ssl)) {
|
690
|
+
int type = ssl_private_key_type(ssl);
|
691
|
+
if (type == NID_rsaEncryption) {
|
692
|
+
mask_k |= SSL_kRSA;
|
693
|
+
mask_a |= SSL_aRSA;
|
694
|
+
} else if (ssl_is_ecdsa_key_type(type)) {
|
695
|
+
mask_a |= SSL_aECDSA;
|
708
696
|
}
|
709
697
|
}
|
710
698
|
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
goto f_err;
|
715
|
-
}
|
699
|
+
if (ssl->cert->dh_tmp != NULL || ssl->cert->dh_tmp_cb != NULL) {
|
700
|
+
mask_k |= SSL_kDHE;
|
701
|
+
}
|
716
702
|
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
703
|
+
/* Check for a shared group to consider ECDHE ciphers. */
|
704
|
+
uint16_t unused;
|
705
|
+
if (tls1_get_shared_group(hs, &unused)) {
|
706
|
+
mask_k |= SSL_kECDHE;
|
721
707
|
}
|
722
708
|
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
709
|
+
/* PSK requires a server callback. */
|
710
|
+
if (ssl->psk_server_callback != NULL) {
|
711
|
+
mask_k |= SSL_kPSK;
|
712
|
+
mask_a |= SSL_aPSK;
|
713
|
+
}
|
714
|
+
|
715
|
+
*out_mask_k = mask_k;
|
716
|
+
*out_mask_a = mask_a;
|
717
|
+
}
|
718
|
+
|
719
|
+
static const SSL_CIPHER *ssl3_choose_cipher(
|
720
|
+
SSL_HANDSHAKE *hs, const SSL_CLIENT_HELLO *client_hello,
|
721
|
+
const struct ssl_cipher_preference_list_st *server_pref) {
|
722
|
+
SSL *const ssl = hs->ssl;
|
723
|
+
const SSL_CIPHER *c, *ret = NULL;
|
724
|
+
STACK_OF(SSL_CIPHER) *srvr = server_pref->ciphers, *prio, *allow;
|
725
|
+
int ok;
|
726
|
+
size_t cipher_index;
|
727
|
+
uint32_t alg_k, alg_a, mask_k, mask_a;
|
728
|
+
/* in_group_flags will either be NULL, or will point to an array of bytes
|
729
|
+
* which indicate equal-preference groups in the |prio| stack. See the
|
730
|
+
* comment about |in_group_flags| in the |ssl_cipher_preference_list_st|
|
731
|
+
* struct. */
|
732
|
+
const uint8_t *in_group_flags;
|
733
|
+
/* group_min contains the minimal index so far found in a group, or -1 if no
|
734
|
+
* such value exists yet. */
|
735
|
+
int group_min = -1;
|
736
|
+
|
737
|
+
STACK_OF(SSL_CIPHER) *clnt = ssl_parse_client_cipher_list(client_hello);
|
738
|
+
if (clnt == NULL) {
|
739
|
+
return NULL;
|
740
|
+
}
|
741
|
+
|
742
|
+
if (ssl->options & SSL_OP_CIPHER_SERVER_PREFERENCE) {
|
743
|
+
prio = srvr;
|
744
|
+
in_group_flags = server_pref->in_group_flags;
|
745
|
+
allow = clnt;
|
746
|
+
} else {
|
747
|
+
prio = clnt;
|
748
|
+
in_group_flags = NULL;
|
749
|
+
allow = srvr;
|
750
|
+
}
|
751
|
+
|
752
|
+
ssl_get_compatible_server_ciphers(hs, &mask_k, &mask_a);
|
753
|
+
|
754
|
+
for (size_t i = 0; i < sk_SSL_CIPHER_num(prio); i++) {
|
755
|
+
c = sk_SSL_CIPHER_value(prio, i);
|
756
|
+
|
757
|
+
ok = 1;
|
758
|
+
|
759
|
+
/* Check the TLS version. */
|
760
|
+
if (SSL_CIPHER_get_min_version(c) > ssl3_protocol_version(ssl) ||
|
761
|
+
SSL_CIPHER_get_max_version(c) < ssl3_protocol_version(ssl)) {
|
762
|
+
ok = 0;
|
728
763
|
}
|
729
|
-
memcpy(ssl->s3->client_random, client_hello.random,
|
730
|
-
client_hello.random_len);
|
731
764
|
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
765
|
+
alg_k = c->algorithm_mkey;
|
766
|
+
alg_a = c->algorithm_auth;
|
767
|
+
|
768
|
+
ok = ok && (alg_k & mask_k) && (alg_a & mask_a);
|
769
|
+
|
770
|
+
if (ok && sk_SSL_CIPHER_find(allow, &cipher_index, c)) {
|
771
|
+
if (in_group_flags != NULL && in_group_flags[i] == 1) {
|
772
|
+
/* This element of |prio| is in a group. Update the minimum index found
|
773
|
+
* so far and continue looking. */
|
774
|
+
if (group_min == -1 || (size_t)group_min > cipher_index) {
|
775
|
+
group_min = cipher_index;
|
776
|
+
}
|
777
|
+
} else {
|
778
|
+
if (group_min != -1 && (size_t)group_min < cipher_index) {
|
779
|
+
cipher_index = group_min;
|
780
|
+
}
|
781
|
+
ret = sk_SSL_CIPHER_value(allow, cipher_index);
|
737
782
|
break;
|
738
|
-
case ssl_session_error:
|
739
|
-
goto err;
|
740
|
-
case ssl_session_retry:
|
741
|
-
ssl->rwstate = SSL_PENDING_SESSION;
|
742
|
-
goto err;
|
743
|
-
}
|
744
|
-
ssl->tlsext_ticket_expected = send_new_ticket;
|
745
|
-
|
746
|
-
/* The EMS state is needed when making the resumption decision, but
|
747
|
-
* extensions are not normally parsed until later. This detects the EMS
|
748
|
-
* extension for the resumption decision and it's checked against the result
|
749
|
-
* of the normal parse later in this function. */
|
750
|
-
CBS ems;
|
751
|
-
int have_extended_master_secret =
|
752
|
-
ssl->version != SSL3_VERSION &&
|
753
|
-
ssl_early_callback_get_extension(&client_hello, &ems,
|
754
|
-
TLSEXT_TYPE_extended_master_secret) &&
|
755
|
-
CBS_len(&ems) == 0;
|
756
|
-
|
757
|
-
int has_session = 0;
|
758
|
-
if (session != NULL) {
|
759
|
-
if (session->extended_master_secret &&
|
760
|
-
!have_extended_master_secret) {
|
761
|
-
/* A ClientHello without EMS that attempts to resume a session with EMS
|
762
|
-
* is fatal to the connection. */
|
763
|
-
al = SSL_AD_HANDSHAKE_FAILURE;
|
764
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION);
|
765
|
-
goto f_err;
|
766
783
|
}
|
784
|
+
}
|
767
785
|
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
* didn't use it, then negotiate a new session. */
|
774
|
-
have_extended_master_secret == session->extended_master_secret;
|
786
|
+
if (in_group_flags != NULL && in_group_flags[i] == 0 && group_min != -1) {
|
787
|
+
/* We are about to leave a group, but we found a match in it, so that's
|
788
|
+
* our answer. */
|
789
|
+
ret = sk_SSL_CIPHER_value(allow, group_min);
|
790
|
+
break;
|
775
791
|
}
|
792
|
+
}
|
776
793
|
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
session = NULL;
|
781
|
-
ssl->s3->session_reused = 1;
|
782
|
-
} else {
|
783
|
-
ssl_set_session(ssl, NULL);
|
784
|
-
if (!ssl_get_new_session(ssl, 1 /* server */)) {
|
785
|
-
goto err;
|
786
|
-
}
|
794
|
+
sk_SSL_CIPHER_free(clnt);
|
795
|
+
return ret;
|
796
|
+
}
|
787
797
|
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
798
|
+
static int ssl3_process_client_hello(SSL_HANDSHAKE *hs) {
|
799
|
+
SSL *const ssl = hs->ssl;
|
800
|
+
if (!ssl_check_message_type(ssl, SSL3_MT_CLIENT_HELLO)) {
|
801
|
+
return -1;
|
802
|
+
}
|
793
803
|
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
804
|
+
SSL_CLIENT_HELLO client_hello;
|
805
|
+
if (!ssl_client_hello_init(ssl, &client_hello, ssl->init_msg,
|
806
|
+
ssl->init_num)) {
|
807
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
808
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
809
|
+
return -1;
|
810
|
+
}
|
811
|
+
|
812
|
+
/* Run the early callback. */
|
813
|
+
if (ssl->ctx->select_certificate_cb != NULL) {
|
814
|
+
switch (ssl->ctx->select_certificate_cb(&client_hello)) {
|
815
|
+
case 0:
|
816
|
+
ssl->rwstate = SSL_CERTIFICATE_SELECTION_PENDING;
|
817
|
+
return -1;
|
818
|
+
|
819
|
+
case -1:
|
820
|
+
/* Connection rejected. */
|
821
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_REJECTED);
|
822
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
823
|
+
return -1;
|
824
|
+
|
825
|
+
default:
|
826
|
+
/* fallthrough */;
|
800
827
|
}
|
828
|
+
}
|
801
829
|
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
830
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
831
|
+
if (!negotiate_version(hs, &alert, &client_hello)) {
|
832
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
|
833
|
+
return -1;
|
834
|
+
}
|
835
|
+
|
836
|
+
/* Load the client random. */
|
837
|
+
if (client_hello.random_len != SSL3_RANDOM_SIZE) {
|
838
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
839
|
+
return -1;
|
840
|
+
}
|
841
|
+
OPENSSL_memcpy(ssl->s3->client_random, client_hello.random,
|
842
|
+
client_hello.random_len);
|
843
|
+
|
844
|
+
/* Only null compression is supported. TLS 1.3 further requires the peer
|
845
|
+
* advertise no other compression. */
|
846
|
+
if (OPENSSL_memchr(client_hello.compression_methods, 0,
|
847
|
+
client_hello.compression_methods_len) == NULL ||
|
848
|
+
(ssl3_protocol_version(ssl) >= TLS1_3_VERSION &&
|
849
|
+
client_hello.compression_methods_len != 1)) {
|
850
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_COMPRESSION_LIST);
|
851
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
852
|
+
return -1;
|
853
|
+
}
|
854
|
+
|
855
|
+
/* TLS extensions. */
|
856
|
+
if (!ssl_parse_clienthello_tlsext(hs, &client_hello)) {
|
857
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_PARSE_TLSEXT);
|
858
|
+
return -1;
|
859
|
+
}
|
860
|
+
|
861
|
+
return 1;
|
862
|
+
}
|
863
|
+
|
864
|
+
static int ssl3_select_certificate(SSL_HANDSHAKE *hs) {
|
865
|
+
SSL *const ssl = hs->ssl;
|
866
|
+
/* Call |cert_cb| to update server certificates if required. */
|
867
|
+
if (ssl->cert->cert_cb != NULL) {
|
868
|
+
int rv = ssl->cert->cert_cb(ssl, ssl->cert->cert_cb_arg);
|
869
|
+
if (rv == 0) {
|
870
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CERT_CB_ERROR);
|
871
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
872
|
+
return -1;
|
873
|
+
}
|
874
|
+
if (rv < 0) {
|
875
|
+
ssl->rwstate = SSL_X509_LOOKUP;
|
876
|
+
return -1;
|
808
877
|
}
|
878
|
+
}
|
879
|
+
|
880
|
+
if (!ssl_auto_chain_if_needed(ssl)) {
|
881
|
+
return -1;
|
882
|
+
}
|
883
|
+
|
884
|
+
if (ssl3_protocol_version(ssl) >= TLS1_3_VERSION) {
|
885
|
+
/* Jump to the TLS 1.3 state machine. */
|
886
|
+
hs->state = SSL_ST_TLS13;
|
887
|
+
hs->do_tls13_handshake = tls13_server_handshake;
|
888
|
+
return 1;
|
889
|
+
}
|
890
|
+
|
891
|
+
SSL_CLIENT_HELLO client_hello;
|
892
|
+
if (!ssl_client_hello_init(ssl, &client_hello, ssl->init_msg,
|
893
|
+
ssl->init_num)) {
|
894
|
+
return -1;
|
895
|
+
}
|
896
|
+
|
897
|
+
/* Negotiate the cipher suite. This must be done after |cert_cb| so the
|
898
|
+
* certificate is finalized. */
|
899
|
+
hs->new_cipher =
|
900
|
+
ssl3_choose_cipher(hs, &client_hello, ssl_get_cipher_preferences(ssl));
|
901
|
+
if (hs->new_cipher == NULL) {
|
902
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_SHARED_CIPHER);
|
903
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
904
|
+
return -1;
|
905
|
+
}
|
906
|
+
|
907
|
+
return 1;
|
908
|
+
}
|
809
909
|
|
810
|
-
|
811
|
-
|
812
|
-
|
910
|
+
static int ssl3_select_parameters(SSL_HANDSHAKE *hs) {
|
911
|
+
SSL *const ssl = hs->ssl;
|
912
|
+
uint8_t al = SSL_AD_INTERNAL_ERROR;
|
913
|
+
int ret = -1;
|
914
|
+
SSL_SESSION *session = NULL;
|
915
|
+
|
916
|
+
SSL_CLIENT_HELLO client_hello;
|
917
|
+
if (!ssl_client_hello_init(ssl, &client_hello, ssl->init_msg,
|
918
|
+
ssl->init_num)) {
|
919
|
+
return -1;
|
920
|
+
}
|
921
|
+
|
922
|
+
/* Determine whether we are doing session resumption. */
|
923
|
+
int tickets_supported = 0, renew_ticket = 0;
|
924
|
+
switch (ssl_get_prev_session(ssl, &session, &tickets_supported, &renew_ticket,
|
925
|
+
&client_hello)) {
|
926
|
+
case ssl_session_success:
|
927
|
+
break;
|
928
|
+
case ssl_session_error:
|
813
929
|
goto err;
|
814
|
-
|
930
|
+
case ssl_session_retry:
|
931
|
+
ssl->rwstate = SSL_PENDING_SESSION;
|
932
|
+
goto err;
|
933
|
+
}
|
815
934
|
|
816
|
-
|
817
|
-
|
818
|
-
|
935
|
+
if (session != NULL) {
|
936
|
+
if (session->extended_master_secret && !hs->extended_master_secret) {
|
937
|
+
/* A ClientHello without EMS that attempts to resume a session with EMS
|
938
|
+
* is fatal to the connection. */
|
939
|
+
al = SSL_AD_HANDSHAKE_FAILURE;
|
940
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION);
|
819
941
|
goto f_err;
|
820
942
|
}
|
821
943
|
|
822
|
-
|
944
|
+
if (!ssl_session_is_resumable(hs, session) ||
|
945
|
+
/* If the client offers the EMS extension, but the previous session
|
946
|
+
* didn't use it, then negotiate a new session. */
|
947
|
+
hs->extended_master_secret != session->extended_master_secret) {
|
948
|
+
SSL_SESSION_free(session);
|
949
|
+
session = NULL;
|
950
|
+
}
|
823
951
|
}
|
824
952
|
|
825
|
-
|
826
|
-
|
827
|
-
|
953
|
+
if (session != NULL) {
|
954
|
+
/* Use the old session. */
|
955
|
+
hs->ticket_expected = renew_ticket;
|
956
|
+
ssl->session = session;
|
957
|
+
session = NULL;
|
958
|
+
ssl->s3->session_reused = 1;
|
959
|
+
} else {
|
960
|
+
hs->ticket_expected = tickets_supported;
|
961
|
+
ssl_set_session(ssl, NULL);
|
962
|
+
if (!ssl_get_new_session(hs, 1 /* server */)) {
|
963
|
+
goto err;
|
964
|
+
}
|
828
965
|
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
&client_hello, (uint16_t)ssl->session->cipher->id)) {
|
833
|
-
al = SSL_AD_ILLEGAL_PARAMETER;
|
834
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_REQUIRED_CIPHER_MISSING);
|
835
|
-
goto f_err;
|
966
|
+
/* Clear the session ID if we want the session to be single-use. */
|
967
|
+
if (!(ssl->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER)) {
|
968
|
+
hs->new_session->session_id_length = 0;
|
836
969
|
}
|
970
|
+
}
|
837
971
|
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
972
|
+
if (ssl->ctx->dos_protection_cb != NULL &&
|
973
|
+
ssl->ctx->dos_protection_cb(&client_hello) == 0) {
|
974
|
+
/* Connection rejected for DOS reasons. */
|
975
|
+
al = SSL_AD_INTERNAL_ERROR;
|
976
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_REJECTED);
|
977
|
+
goto f_err;
|
978
|
+
}
|
979
|
+
|
980
|
+
if (ssl->session == NULL) {
|
981
|
+
hs->new_session->cipher = hs->new_cipher;
|
982
|
+
|
983
|
+
/* On new sessions, stash the SNI value in the session. */
|
984
|
+
if (hs->hostname != NULL) {
|
985
|
+
OPENSSL_free(hs->new_session->tlsext_hostname);
|
986
|
+
hs->new_session->tlsext_hostname = BUF_strdup(hs->hostname);
|
987
|
+
if (hs->new_session->tlsext_hostname == NULL) {
|
845
988
|
al = SSL_AD_INTERNAL_ERROR;
|
846
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_CERT_CB_ERROR);
|
847
989
|
goto f_err;
|
848
990
|
}
|
849
|
-
if (rv < 0) {
|
850
|
-
ssl->rwstate = SSL_X509_LOOKUP;
|
851
|
-
goto err;
|
852
|
-
}
|
853
991
|
}
|
854
992
|
|
855
|
-
const SSL_CIPHER *c =
|
856
|
-
ssl3_choose_cipher(ssl, &client_hello, ssl_get_cipher_preferences(ssl));
|
857
|
-
if (c == NULL) {
|
858
|
-
al = SSL_AD_HANDSHAKE_FAILURE;
|
859
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_SHARED_CIPHER);
|
860
|
-
goto f_err;
|
861
|
-
}
|
862
|
-
|
863
|
-
ssl->s3->new_session->cipher = c;
|
864
|
-
ssl->s3->tmp.new_cipher = c;
|
865
|
-
|
866
993
|
/* Determine whether to request a client certificate. */
|
867
|
-
|
994
|
+
hs->cert_request = !!(ssl->verify_mode & SSL_VERIFY_PEER);
|
868
995
|
/* Only request a certificate if Channel ID isn't negotiated. */
|
869
996
|
if ((ssl->verify_mode & SSL_VERIFY_PEER_IF_NO_OBC) &&
|
870
997
|
ssl->s3->tlsext_channel_id_valid) {
|
871
|
-
|
998
|
+
hs->cert_request = 0;
|
872
999
|
}
|
873
1000
|
/* CertificateRequest may only be sent in certificate-based ciphers. */
|
874
|
-
if (!ssl_cipher_uses_certificate_auth(
|
875
|
-
|
1001
|
+
if (!ssl_cipher_uses_certificate_auth(hs->new_cipher)) {
|
1002
|
+
hs->cert_request = 0;
|
876
1003
|
}
|
877
1004
|
|
878
|
-
if (!
|
1005
|
+
if (!hs->cert_request) {
|
879
1006
|
/* OpenSSL returns X509_V_OK when no certificates are requested. This is
|
880
1007
|
* classed by them as a bug, but it's assumed by at least NGINX. */
|
881
|
-
|
1008
|
+
hs->new_session->verify_result = X509_V_OK;
|
882
1009
|
}
|
883
1010
|
}
|
884
1011
|
|
885
|
-
/*
|
886
|
-
|
1012
|
+
/* HTTP/2 negotiation depends on the cipher suite, so ALPN negotiation was
|
1013
|
+
* deferred. Complete it now. */
|
1014
|
+
if (!ssl_negotiate_alpn(hs, &al, &client_hello)) {
|
1015
|
+
goto f_err;
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
/* Now that all parameters are known, initialize the handshake hash and hash
|
1019
|
+
* the ClientHello. */
|
1020
|
+
if (!SSL_TRANSCRIPT_init_hash(&hs->transcript, ssl3_protocol_version(ssl),
|
1021
|
+
hs->new_cipher->algorithm_prf) ||
|
1022
|
+
!ssl_hash_current_message(hs)) {
|
887
1023
|
goto f_err;
|
888
1024
|
}
|
889
1025
|
|
890
1026
|
/* Release the handshake buffer if client authentication isn't required. */
|
891
|
-
if (!
|
892
|
-
|
1027
|
+
if (!hs->cert_request) {
|
1028
|
+
SSL_TRANSCRIPT_free_buffer(&hs->transcript);
|
893
1029
|
}
|
894
1030
|
|
895
1031
|
ret = 1;
|
@@ -904,17 +1040,13 @@ err:
|
|
904
1040
|
return ret;
|
905
1041
|
}
|
906
1042
|
|
907
|
-
static int ssl3_send_server_hello(
|
908
|
-
|
909
|
-
return ssl->method->write_message(ssl);
|
910
|
-
}
|
911
|
-
|
912
|
-
assert(ssl->state == SSL3_ST_SW_SRVR_HELLO_A);
|
1043
|
+
static int ssl3_send_server_hello(SSL_HANDSHAKE *hs) {
|
1044
|
+
SSL *const ssl = hs->ssl;
|
913
1045
|
|
914
1046
|
/* We only accept ChannelIDs on connections with ECDHE in order to avoid a
|
915
1047
|
* known attack while we fix ChannelID itself. */
|
916
1048
|
if (ssl->s3->tlsext_channel_id_valid &&
|
917
|
-
(
|
1049
|
+
(hs->new_cipher->algorithm_mkey & SSL_kECDHE) == 0) {
|
918
1050
|
ssl->s3->tlsext_channel_id_valid = 0;
|
919
1051
|
}
|
920
1052
|
|
@@ -939,7 +1071,7 @@ static int ssl3_send_server_hello(SSL *ssl) {
|
|
939
1071
|
/* TODO(davidben): Implement the TLS 1.1 and 1.2 downgrade sentinels once TLS
|
940
1072
|
* 1.3 is finalized and we are not implementing a draft version. */
|
941
1073
|
|
942
|
-
const SSL_SESSION *session =
|
1074
|
+
const SSL_SESSION *session = hs->new_session;
|
943
1075
|
if (ssl->session != NULL) {
|
944
1076
|
session = ssl->session;
|
945
1077
|
}
|
@@ -951,70 +1083,59 @@ static int ssl3_send_server_hello(SSL *ssl) {
|
|
951
1083
|
!CBB_add_u8_length_prefixed(&body, &session_id) ||
|
952
1084
|
!CBB_add_bytes(&session_id, session->session_id,
|
953
1085
|
session->session_id_length) ||
|
954
|
-
!CBB_add_u16(&body, ssl_cipher_get_value(
|
1086
|
+
!CBB_add_u16(&body, ssl_cipher_get_value(hs->new_cipher)) ||
|
955
1087
|
!CBB_add_u8(&body, 0 /* no compression */) ||
|
956
|
-
!ssl_add_serverhello_tlsext(
|
957
|
-
!
|
1088
|
+
!ssl_add_serverhello_tlsext(hs, &body) ||
|
1089
|
+
!ssl_add_message_cbb(ssl, &cbb)) {
|
958
1090
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
959
1091
|
CBB_cleanup(&cbb);
|
960
1092
|
return -1;
|
961
1093
|
}
|
962
1094
|
|
963
|
-
|
964
|
-
return ssl->method->write_message(ssl);
|
1095
|
+
return 1;
|
965
1096
|
}
|
966
1097
|
|
967
|
-
static int ssl3_send_server_certificate(
|
968
|
-
|
969
|
-
return ssl->method->write_message(ssl);
|
970
|
-
}
|
971
|
-
|
1098
|
+
static int ssl3_send_server_certificate(SSL_HANDSHAKE *hs) {
|
1099
|
+
SSL *const ssl = hs->ssl;
|
972
1100
|
if (!ssl_has_certificate(ssl)) {
|
973
1101
|
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CERTIFICATE_SET);
|
974
|
-
return
|
1102
|
+
return -1;
|
975
1103
|
}
|
976
1104
|
|
977
1105
|
if (!ssl3_output_cert_chain(ssl)) {
|
978
|
-
return
|
1106
|
+
return -1;
|
979
1107
|
}
|
980
|
-
|
981
|
-
return ssl->method->write_message(ssl);
|
1108
|
+
return 1;
|
982
1109
|
}
|
983
1110
|
|
984
|
-
static int ssl3_send_certificate_status(
|
985
|
-
|
986
|
-
return ssl->method->write_message(ssl);
|
987
|
-
}
|
988
|
-
|
1111
|
+
static int ssl3_send_certificate_status(SSL_HANDSHAKE *hs) {
|
1112
|
+
SSL *const ssl = hs->ssl;
|
989
1113
|
CBB cbb, body, ocsp_response;
|
990
1114
|
if (!ssl->method->init_message(ssl, &cbb, &body,
|
991
1115
|
SSL3_MT_CERTIFICATE_STATUS) ||
|
992
1116
|
!CBB_add_u8(&body, TLSEXT_STATUSTYPE_ocsp) ||
|
993
1117
|
!CBB_add_u24_length_prefixed(&body, &ocsp_response) ||
|
994
|
-
!CBB_add_bytes(&ocsp_response,
|
995
|
-
ssl->
|
996
|
-
|
1118
|
+
!CBB_add_bytes(&ocsp_response,
|
1119
|
+
CRYPTO_BUFFER_data(ssl->cert->ocsp_response),
|
1120
|
+
CRYPTO_BUFFER_len(ssl->cert->ocsp_response)) ||
|
1121
|
+
!ssl_add_message_cbb(ssl, &cbb)) {
|
997
1122
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
998
1123
|
CBB_cleanup(&cbb);
|
999
1124
|
return -1;
|
1000
1125
|
}
|
1001
1126
|
|
1002
|
-
|
1003
|
-
return ssl->method->write_message(ssl);
|
1127
|
+
return 1;
|
1004
1128
|
}
|
1005
1129
|
|
1006
|
-
static int ssl3_send_server_key_exchange(
|
1007
|
-
|
1008
|
-
return ssl->method->write_message(ssl);
|
1009
|
-
}
|
1010
|
-
|
1130
|
+
static int ssl3_send_server_key_exchange(SSL_HANDSHAKE *hs) {
|
1131
|
+
SSL *const ssl = hs->ssl;
|
1011
1132
|
CBB cbb, child;
|
1012
1133
|
CBB_zero(&cbb);
|
1013
1134
|
|
1014
1135
|
/* Put together the parameters. */
|
1015
|
-
if (
|
1016
|
-
uint32_t alg_k =
|
1017
|
-
uint32_t alg_a =
|
1136
|
+
if (hs->state == SSL3_ST_SW_KEY_EXCH_A) {
|
1137
|
+
uint32_t alg_k = hs->new_cipher->algorithm_mkey;
|
1138
|
+
uint32_t alg_a = hs->new_cipher->algorithm_auth;
|
1018
1139
|
|
1019
1140
|
/* Pre-allocate enough room to comfortably fit an ECDHE public key. */
|
1020
1141
|
if (!CBB_init(&cbb, 128)) {
|
@@ -1043,7 +1164,6 @@ static int ssl3_send_server_key_exchange(SSL *ssl) {
|
|
1043
1164
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
1044
1165
|
goto err;
|
1045
1166
|
}
|
1046
|
-
ssl->s3->new_session->key_exchange_info = DH_num_bits(params);
|
1047
1167
|
|
1048
1168
|
/* Set up DH, generate a key, and emit the public half. */
|
1049
1169
|
DH *dh = DHparams_dup(params);
|
@@ -1051,64 +1171,52 @@ static int ssl3_send_server_key_exchange(SSL *ssl) {
|
|
1051
1171
|
goto err;
|
1052
1172
|
}
|
1053
1173
|
|
1054
|
-
SSL_ECDH_CTX_init_for_dhe(&
|
1174
|
+
SSL_ECDH_CTX_init_for_dhe(&hs->ecdh_ctx, dh);
|
1055
1175
|
if (!CBB_add_u16_length_prefixed(&cbb, &child) ||
|
1056
1176
|
!BN_bn2cbb_padded(&child, BN_num_bytes(params->p), params->p) ||
|
1057
1177
|
!CBB_add_u16_length_prefixed(&cbb, &child) ||
|
1058
1178
|
!BN_bn2cbb_padded(&child, BN_num_bytes(params->g), params->g) ||
|
1059
1179
|
!CBB_add_u16_length_prefixed(&cbb, &child) ||
|
1060
|
-
!SSL_ECDH_CTX_offer(&
|
1180
|
+
!SSL_ECDH_CTX_offer(&hs->ecdh_ctx, &child)) {
|
1061
1181
|
goto err;
|
1062
1182
|
}
|
1063
1183
|
} else if (alg_k & SSL_kECDHE) {
|
1064
1184
|
/* Determine the group to use. */
|
1065
1185
|
uint16_t group_id;
|
1066
|
-
if (!tls1_get_shared_group(
|
1186
|
+
if (!tls1_get_shared_group(hs, &group_id)) {
|
1067
1187
|
OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_TMP_ECDH_KEY);
|
1068
1188
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
1069
1189
|
goto err;
|
1070
1190
|
}
|
1071
|
-
|
1191
|
+
hs->new_session->group_id = group_id;
|
1072
1192
|
|
1073
1193
|
/* Set up ECDH, generate a key, and emit the public half. */
|
1074
|
-
if (!SSL_ECDH_CTX_init(&
|
1194
|
+
if (!SSL_ECDH_CTX_init(&hs->ecdh_ctx, group_id) ||
|
1075
1195
|
!CBB_add_u8(&cbb, NAMED_CURVE_TYPE) ||
|
1076
1196
|
!CBB_add_u16(&cbb, group_id) ||
|
1077
1197
|
!CBB_add_u8_length_prefixed(&cbb, &child) ||
|
1078
|
-
!SSL_ECDH_CTX_offer(&
|
1079
|
-
goto err;
|
1080
|
-
}
|
1081
|
-
} else if (alg_k & SSL_kCECPQ1) {
|
1082
|
-
SSL_ECDH_CTX_init_for_cecpq1(&ssl->s3->tmp.ecdh_ctx);
|
1083
|
-
if (!CBB_add_u16_length_prefixed(&cbb, &child) ||
|
1084
|
-
!SSL_ECDH_CTX_offer(&ssl->s3->tmp.ecdh_ctx, &child)) {
|
1198
|
+
!SSL_ECDH_CTX_offer(&hs->ecdh_ctx, &child)) {
|
1085
1199
|
goto err;
|
1086
1200
|
}
|
1087
1201
|
} else {
|
1088
1202
|
assert(alg_k & SSL_kPSK);
|
1089
1203
|
}
|
1090
1204
|
|
1091
|
-
|
1092
|
-
if (!CBB_finish(&cbb, &ssl->s3->tmp.server_params, &len) ||
|
1093
|
-
len > 0xffffffffu) {
|
1094
|
-
OPENSSL_free(ssl->s3->tmp.server_params);
|
1095
|
-
ssl->s3->tmp.server_params = NULL;
|
1205
|
+
if (!CBB_finish(&cbb, &hs->server_params, &hs->server_params_len)) {
|
1096
1206
|
goto err;
|
1097
1207
|
}
|
1098
|
-
ssl->s3->tmp.server_params_len = (uint32_t)len;
|
1099
1208
|
}
|
1100
1209
|
|
1101
1210
|
/* Assemble the message. */
|
1102
1211
|
CBB body;
|
1103
1212
|
if (!ssl->method->init_message(ssl, &cbb, &body,
|
1104
1213
|
SSL3_MT_SERVER_KEY_EXCHANGE) ||
|
1105
|
-
!CBB_add_bytes(&body,
|
1106
|
-
ssl->s3->tmp.server_params_len)) {
|
1214
|
+
!CBB_add_bytes(&body, hs->server_params, hs->server_params_len)) {
|
1107
1215
|
goto err;
|
1108
1216
|
}
|
1109
1217
|
|
1110
1218
|
/* Add a signature. */
|
1111
|
-
if (ssl_cipher_uses_certificate_auth(
|
1219
|
+
if (ssl_cipher_uses_certificate_auth(hs->new_cipher)) {
|
1112
1220
|
if (!ssl_has_private_key(ssl)) {
|
1113
1221
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
1114
1222
|
goto err;
|
@@ -1116,7 +1224,7 @@ static int ssl3_send_server_key_exchange(SSL *ssl) {
|
|
1116
1224
|
|
1117
1225
|
/* Determine the signature algorithm. */
|
1118
1226
|
uint16_t signature_algorithm;
|
1119
|
-
if (!tls1_choose_signature_algorithm(
|
1227
|
+
if (!tls1_choose_signature_algorithm(hs, &signature_algorithm)) {
|
1120
1228
|
goto err;
|
1121
1229
|
}
|
1122
1230
|
if (ssl3_protocol_version(ssl) >= TLS1_2_VERSION) {
|
@@ -1137,16 +1245,18 @@ static int ssl3_send_server_key_exchange(SSL *ssl) {
|
|
1137
1245
|
|
1138
1246
|
size_t sig_len;
|
1139
1247
|
enum ssl_private_key_result_t sign_result;
|
1140
|
-
if (
|
1248
|
+
if (hs->state == SSL3_ST_SW_KEY_EXCH_A) {
|
1141
1249
|
CBB transcript;
|
1142
1250
|
uint8_t *transcript_data;
|
1143
1251
|
size_t transcript_len;
|
1144
1252
|
if (!CBB_init(&transcript,
|
1145
|
-
2*SSL3_RANDOM_SIZE +
|
1146
|
-
!CBB_add_bytes(&transcript, ssl->s3->client_random,
|
1147
|
-
|
1148
|
-
!CBB_add_bytes(&transcript, ssl->s3->
|
1149
|
-
|
1253
|
+
2 * SSL3_RANDOM_SIZE + hs->server_params_len) ||
|
1254
|
+
!CBB_add_bytes(&transcript, ssl->s3->client_random,
|
1255
|
+
SSL3_RANDOM_SIZE) ||
|
1256
|
+
!CBB_add_bytes(&transcript, ssl->s3->server_random,
|
1257
|
+
SSL3_RANDOM_SIZE) ||
|
1258
|
+
!CBB_add_bytes(&transcript, hs->server_params,
|
1259
|
+
hs->server_params_len) ||
|
1150
1260
|
!CBB_finish(&transcript, &transcript_data, &transcript_len)) {
|
1151
1261
|
CBB_cleanup(&transcript);
|
1152
1262
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
@@ -1159,7 +1269,7 @@ static int ssl3_send_server_key_exchange(SSL *ssl) {
|
|
1159
1269
|
transcript_len);
|
1160
1270
|
OPENSSL_free(transcript_data);
|
1161
1271
|
} else {
|
1162
|
-
assert(
|
1272
|
+
assert(hs->state == SSL3_ST_SW_KEY_EXCH_B);
|
1163
1273
|
sign_result = ssl_private_key_complete(ssl, ptr, &sig_len, max_sig_len);
|
1164
1274
|
}
|
1165
1275
|
|
@@ -1173,21 +1283,20 @@ static int ssl3_send_server_key_exchange(SSL *ssl) {
|
|
1173
1283
|
goto err;
|
1174
1284
|
case ssl_private_key_retry:
|
1175
1285
|
ssl->rwstate = SSL_PRIVATE_KEY_OPERATION;
|
1176
|
-
|
1286
|
+
hs->state = SSL3_ST_SW_KEY_EXCH_B;
|
1177
1287
|
goto err;
|
1178
1288
|
}
|
1179
1289
|
}
|
1180
1290
|
|
1181
|
-
if (!
|
1291
|
+
if (!ssl_add_message_cbb(ssl, &cbb)) {
|
1182
1292
|
goto err;
|
1183
1293
|
}
|
1184
1294
|
|
1185
|
-
OPENSSL_free(
|
1186
|
-
|
1187
|
-
|
1295
|
+
OPENSSL_free(hs->server_params);
|
1296
|
+
hs->server_params = NULL;
|
1297
|
+
hs->server_params_len = 0;
|
1188
1298
|
|
1189
|
-
|
1190
|
-
return ssl->method->write_message(ssl);
|
1299
|
+
return 1;
|
1191
1300
|
|
1192
1301
|
err:
|
1193
1302
|
CBB_cleanup(&cbb);
|
@@ -1199,8 +1308,8 @@ static int add_cert_types(SSL *ssl, CBB *cbb) {
|
|
1199
1308
|
int have_rsa_sign = 0;
|
1200
1309
|
int have_ecdsa_sign = 0;
|
1201
1310
|
const uint16_t *sig_algs;
|
1202
|
-
size_t
|
1203
|
-
for (size_t i = 0; i <
|
1311
|
+
size_t num_sig_algs = tls12_get_verify_sigalgs(ssl, &sig_algs);
|
1312
|
+
for (size_t i = 0; i < num_sig_algs; i++) {
|
1204
1313
|
switch (sig_algs[i]) {
|
1205
1314
|
case SSL_SIGN_RSA_PKCS1_SHA512:
|
1206
1315
|
case SSL_SIGN_RSA_PKCS1_SHA384:
|
@@ -1232,11 +1341,8 @@ static int add_cert_types(SSL *ssl, CBB *cbb) {
|
|
1232
1341
|
return 1;
|
1233
1342
|
}
|
1234
1343
|
|
1235
|
-
static int ssl3_send_certificate_request(
|
1236
|
-
|
1237
|
-
return ssl->method->write_message(ssl);
|
1238
|
-
}
|
1239
|
-
|
1344
|
+
static int ssl3_send_certificate_request(SSL_HANDSHAKE *hs) {
|
1345
|
+
SSL *const ssl = hs->ssl;
|
1240
1346
|
CBB cbb, body, cert_types, sigalgs_cbb;
|
1241
1347
|
if (!ssl->method->init_message(ssl, &cbb, &body,
|
1242
1348
|
SSL3_MT_CERTIFICATE_REQUEST) ||
|
@@ -1247,7 +1353,7 @@ static int ssl3_send_certificate_request(SSL *ssl) {
|
|
1247
1353
|
|
1248
1354
|
if (ssl3_protocol_version(ssl) >= TLS1_2_VERSION) {
|
1249
1355
|
const uint16_t *sigalgs;
|
1250
|
-
size_t num_sigalgs =
|
1356
|
+
size_t num_sigalgs = tls12_get_verify_sigalgs(ssl, &sigalgs);
|
1251
1357
|
if (!CBB_add_u16_length_prefixed(&body, &sigalgs_cbb)) {
|
1252
1358
|
goto err;
|
1253
1359
|
}
|
@@ -1260,12 +1366,11 @@ static int ssl3_send_certificate_request(SSL *ssl) {
|
|
1260
1366
|
}
|
1261
1367
|
|
1262
1368
|
if (!ssl_add_client_CA_list(ssl, &body) ||
|
1263
|
-
!
|
1369
|
+
!ssl_add_message_cbb(ssl, &cbb)) {
|
1264
1370
|
goto err;
|
1265
1371
|
}
|
1266
1372
|
|
1267
|
-
|
1268
|
-
return ssl->method->write_message(ssl);
|
1373
|
+
return 1;
|
1269
1374
|
|
1270
1375
|
err:
|
1271
1376
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
@@ -1273,27 +1378,24 @@ err:
|
|
1273
1378
|
return -1;
|
1274
1379
|
}
|
1275
1380
|
|
1276
|
-
static int ssl3_send_server_hello_done(
|
1277
|
-
|
1278
|
-
return ssl->method->write_message(ssl);
|
1279
|
-
}
|
1280
|
-
|
1381
|
+
static int ssl3_send_server_hello_done(SSL_HANDSHAKE *hs) {
|
1382
|
+
SSL *const ssl = hs->ssl;
|
1281
1383
|
CBB cbb, body;
|
1282
1384
|
if (!ssl->method->init_message(ssl, &cbb, &body, SSL3_MT_SERVER_HELLO_DONE) ||
|
1283
|
-
!
|
1385
|
+
!ssl_add_message_cbb(ssl, &cbb)) {
|
1284
1386
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
1285
1387
|
CBB_cleanup(&cbb);
|
1286
1388
|
return -1;
|
1287
1389
|
}
|
1288
1390
|
|
1289
|
-
|
1290
|
-
return ssl->method->write_message(ssl);
|
1391
|
+
return 1;
|
1291
1392
|
}
|
1292
1393
|
|
1293
|
-
static int ssl3_get_client_certificate(
|
1294
|
-
|
1394
|
+
static int ssl3_get_client_certificate(SSL_HANDSHAKE *hs) {
|
1395
|
+
SSL *const ssl = hs->ssl;
|
1396
|
+
assert(hs->cert_request);
|
1295
1397
|
|
1296
|
-
int msg_ret = ssl->method->ssl_get_message(ssl
|
1398
|
+
int msg_ret = ssl->method->ssl_get_message(ssl);
|
1297
1399
|
if (msg_ret <= 0) {
|
1298
1400
|
return msg_ret;
|
1299
1401
|
}
|
@@ -1311,7 +1413,7 @@ static int ssl3_get_client_certificate(SSL *ssl) {
|
|
1311
1413
|
|
1312
1414
|
/* OpenSSL returns X509_V_OK when no certificates are received. This is
|
1313
1415
|
* classed by them as a bug, but it's assumed by at least NGINX. */
|
1314
|
-
|
1416
|
+
hs->new_session->verify_result = X509_V_OK;
|
1315
1417
|
ssl->s3->tmp.reuse_message = 1;
|
1316
1418
|
return 1;
|
1317
1419
|
}
|
@@ -1321,75 +1423,73 @@ static int ssl3_get_client_certificate(SSL *ssl) {
|
|
1321
1423
|
return -1;
|
1322
1424
|
}
|
1323
1425
|
|
1426
|
+
if (!ssl_hash_current_message(hs)) {
|
1427
|
+
return -1;
|
1428
|
+
}
|
1429
|
+
|
1324
1430
|
CBS certificate_msg;
|
1325
1431
|
CBS_init(&certificate_msg, ssl->init_msg, ssl->init_num);
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1432
|
+
|
1433
|
+
sk_CRYPTO_BUFFER_pop_free(hs->new_session->certs, CRYPTO_BUFFER_free);
|
1434
|
+
EVP_PKEY_free(hs->peer_pubkey);
|
1435
|
+
hs->peer_pubkey = NULL;
|
1436
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
1437
|
+
hs->new_session->certs = ssl_parse_cert_chain(
|
1438
|
+
&alert, &hs->peer_pubkey,
|
1439
|
+
ssl->retain_only_sha256_of_client_certs ? hs->new_session->peer_sha256
|
1440
|
+
: NULL,
|
1441
|
+
&certificate_msg, ssl->ctx->pool);
|
1442
|
+
if (hs->new_session->certs == NULL) {
|
1333
1443
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
|
1334
|
-
|
1444
|
+
return -1;
|
1335
1445
|
}
|
1336
1446
|
|
1337
|
-
if (CBS_len(&certificate_msg) != 0
|
1447
|
+
if (CBS_len(&certificate_msg) != 0 ||
|
1448
|
+
!ssl->ctx->x509_method->session_cache_objects(hs->new_session)) {
|
1338
1449
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
1339
1450
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
1340
|
-
|
1451
|
+
return -1;
|
1341
1452
|
}
|
1342
1453
|
|
1343
|
-
if (
|
1454
|
+
if (sk_CRYPTO_BUFFER_num(hs->new_session->certs) == 0) {
|
1344
1455
|
/* No client certificate so the handshake buffer may be discarded. */
|
1345
|
-
|
1456
|
+
SSL_TRANSCRIPT_free_buffer(&hs->transcript);
|
1346
1457
|
|
1347
1458
|
/* In SSL 3.0, sending no certificate is signaled by omitting the
|
1348
1459
|
* Certificate message. */
|
1349
1460
|
if (ssl->version == SSL3_VERSION) {
|
1350
1461
|
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CERTIFICATES_RETURNED);
|
1351
1462
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
1352
|
-
|
1463
|
+
return -1;
|
1353
1464
|
}
|
1354
1465
|
|
1355
1466
|
if (ssl->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) {
|
1356
1467
|
/* Fail for TLS only if we required a certificate */
|
1357
1468
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE);
|
1358
1469
|
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
1359
|
-
|
1470
|
+
return -1;
|
1360
1471
|
}
|
1361
1472
|
|
1362
1473
|
/* OpenSSL returns X509_V_OK when no certificates are received. This is
|
1363
1474
|
* classed by them as a bug, but it's assumed by at least NGINX. */
|
1364
|
-
|
1365
|
-
|
1366
|
-
/* The hash would have been filled in. */
|
1367
|
-
if (ssl->ctx->retain_only_sha256_of_client_certs) {
|
1368
|
-
ssl->s3->new_session->peer_sha256_valid = 1;
|
1369
|
-
}
|
1370
|
-
|
1371
|
-
if (!ssl_verify_cert_chain(ssl, &ssl->s3->new_session->verify_result,
|
1372
|
-
chain)) {
|
1373
|
-
goto err;
|
1374
|
-
}
|
1475
|
+
hs->new_session->verify_result = X509_V_OK;
|
1476
|
+
return 1;
|
1375
1477
|
}
|
1376
1478
|
|
1377
|
-
|
1378
|
-
ssl->
|
1379
|
-
|
1380
|
-
|
1381
|
-
ssl->s3->new_session->cert_chain = chain;
|
1382
|
-
/* Inconsistency alert: cert_chain does *not* include the peer's own
|
1383
|
-
* certificate, while we do include it in s3_clnt.c */
|
1479
|
+
/* The hash will have been filled in. */
|
1480
|
+
if (ssl->retain_only_sha256_of_client_certs) {
|
1481
|
+
hs->new_session->peer_sha256_valid = 1;
|
1482
|
+
}
|
1384
1483
|
|
1484
|
+
if (!ssl_verify_cert_chain(ssl, &hs->new_session->verify_result,
|
1485
|
+
hs->new_session->x509_chain)) {
|
1486
|
+
return -1;
|
1487
|
+
}
|
1385
1488
|
return 1;
|
1386
|
-
|
1387
|
-
err:
|
1388
|
-
sk_X509_pop_free(chain, X509_free);
|
1389
|
-
return -1;
|
1390
1489
|
}
|
1391
1490
|
|
1392
|
-
static int ssl3_get_client_key_exchange(
|
1491
|
+
static int ssl3_get_client_key_exchange(SSL_HANDSHAKE *hs) {
|
1492
|
+
SSL *const ssl = hs->ssl;
|
1393
1493
|
int al;
|
1394
1494
|
CBS client_key_exchange;
|
1395
1495
|
uint32_t alg_k;
|
@@ -1401,17 +1501,21 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1401
1501
|
unsigned psk_len = 0;
|
1402
1502
|
uint8_t psk[PSK_MAX_PSK_LEN];
|
1403
1503
|
|
1404
|
-
if (
|
1405
|
-
int ret = ssl->method->ssl_get_message(ssl
|
1406
|
-
ssl_hash_message);
|
1504
|
+
if (hs->state == SSL3_ST_SR_KEY_EXCH_A) {
|
1505
|
+
int ret = ssl->method->ssl_get_message(ssl);
|
1407
1506
|
if (ret <= 0) {
|
1408
1507
|
return ret;
|
1409
1508
|
}
|
1509
|
+
|
1510
|
+
if (!ssl_check_message_type(ssl, SSL3_MT_CLIENT_KEY_EXCHANGE) ||
|
1511
|
+
!ssl_hash_current_message(hs)) {
|
1512
|
+
return -1;
|
1513
|
+
}
|
1410
1514
|
}
|
1411
1515
|
|
1412
1516
|
CBS_init(&client_key_exchange, ssl->init_msg, ssl->init_num);
|
1413
|
-
alg_k =
|
1414
|
-
alg_a =
|
1517
|
+
alg_k = hs->new_cipher->algorithm_mkey;
|
1518
|
+
alg_a = hs->new_cipher->algorithm_auth;
|
1415
1519
|
|
1416
1520
|
/* If using a PSK key exchange, prepare the pre-shared key. */
|
1417
1521
|
if (alg_a & SSL_aPSK) {
|
@@ -1439,15 +1543,15 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1439
1543
|
goto f_err;
|
1440
1544
|
}
|
1441
1545
|
|
1442
|
-
if (!CBS_strdup(&psk_identity, &
|
1546
|
+
if (!CBS_strdup(&psk_identity, &hs->new_session->psk_identity)) {
|
1443
1547
|
al = SSL_AD_INTERNAL_ERROR;
|
1444
1548
|
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
|
1445
1549
|
goto f_err;
|
1446
1550
|
}
|
1447
1551
|
|
1448
1552
|
/* Look up the key for the identity. */
|
1449
|
-
psk_len = ssl->psk_server_callback(ssl,
|
1450
|
-
|
1553
|
+
psk_len = ssl->psk_server_callback(ssl, hs->new_session->psk_identity, psk,
|
1554
|
+
sizeof(psk));
|
1451
1555
|
if (psk_len > PSK_MAX_PSK_LEN) {
|
1452
1556
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
1453
1557
|
al = SSL_AD_INTERNAL_ERROR;
|
@@ -1473,7 +1577,7 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1473
1577
|
|
1474
1578
|
enum ssl_private_key_result_t decrypt_result;
|
1475
1579
|
size_t decrypt_len;
|
1476
|
-
if (
|
1580
|
+
if (hs->state == SSL3_ST_SR_KEY_EXCH_A) {
|
1477
1581
|
if (!ssl_has_private_key(ssl) ||
|
1478
1582
|
ssl_private_key_type(ssl) != NID_rsaEncryption) {
|
1479
1583
|
al = SSL_AD_HANDSHAKE_FAILURE;
|
@@ -1501,7 +1605,7 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1501
1605
|
CBS_data(&encrypted_premaster_secret),
|
1502
1606
|
CBS_len(&encrypted_premaster_secret));
|
1503
1607
|
} else {
|
1504
|
-
assert(
|
1608
|
+
assert(hs->state == SSL3_ST_SR_KEY_EXCH_B);
|
1505
1609
|
/* Complete async decrypt. */
|
1506
1610
|
decrypt_result =
|
1507
1611
|
ssl_private_key_complete(ssl, decrypt_buf, &decrypt_len, rsa_size);
|
@@ -1514,7 +1618,7 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1514
1618
|
goto err;
|
1515
1619
|
case ssl_private_key_retry:
|
1516
1620
|
ssl->rwstate = SSL_PRIVATE_KEY_OPERATION;
|
1517
|
-
|
1621
|
+
hs->state = SSL3_ST_SR_KEY_EXCH_B;
|
1518
1622
|
goto err;
|
1519
1623
|
}
|
1520
1624
|
|
@@ -1556,9 +1660,9 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1556
1660
|
/* The premaster secret must begin with |client_version|. This too must be
|
1557
1661
|
* checked in constant time (http://eprint.iacr.org/2003/052/). */
|
1558
1662
|
good &= constant_time_eq_8(decrypt_buf[padding_len],
|
1559
|
-
(unsigned)(
|
1663
|
+
(unsigned)(hs->client_version >> 8));
|
1560
1664
|
good &= constant_time_eq_8(decrypt_buf[padding_len + 1],
|
1561
|
-
(unsigned)(
|
1665
|
+
(unsigned)(hs->client_version & 0xff));
|
1562
1666
|
|
1563
1667
|
/* Select, in constant time, either the decrypted premaster or the random
|
1564
1668
|
* premaster based on |good|. */
|
@@ -1569,11 +1673,10 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1569
1673
|
|
1570
1674
|
OPENSSL_free(decrypt_buf);
|
1571
1675
|
decrypt_buf = NULL;
|
1572
|
-
} else if (alg_k & (SSL_kECDHE|SSL_kDHE
|
1676
|
+
} else if (alg_k & (SSL_kECDHE|SSL_kDHE)) {
|
1573
1677
|
/* Parse the ClientKeyExchange. */
|
1574
1678
|
CBS peer_key;
|
1575
|
-
if (!SSL_ECDH_CTX_get_key(&
|
1576
|
-
&peer_key) ||
|
1679
|
+
if (!SSL_ECDH_CTX_get_key(&hs->ecdh_ctx, &client_key_exchange, &peer_key) ||
|
1577
1680
|
CBS_len(&client_key_exchange) != 0) {
|
1578
1681
|
al = SSL_AD_DECODE_ERROR;
|
1579
1682
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
@@ -1581,8 +1684,8 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1581
1684
|
}
|
1582
1685
|
|
1583
1686
|
/* Compute the premaster. */
|
1584
|
-
uint8_t alert;
|
1585
|
-
if (!SSL_ECDH_CTX_finish(&
|
1687
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
1688
|
+
if (!SSL_ECDH_CTX_finish(&hs->ecdh_ctx, &premaster_secret,
|
1586
1689
|
&premaster_secret_len, &alert, CBS_data(&peer_key),
|
1587
1690
|
CBS_len(&peer_key))) {
|
1588
1691
|
al = alert;
|
@@ -1590,7 +1693,7 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1590
1693
|
}
|
1591
1694
|
|
1592
1695
|
/* The key exchange state may now be discarded. */
|
1593
|
-
SSL_ECDH_CTX_cleanup(&
|
1696
|
+
SSL_ECDH_CTX_cleanup(&hs->ecdh_ctx);
|
1594
1697
|
} else if (alg_k & SSL_kPSK) {
|
1595
1698
|
/* For plain PSK, other_secret is a block of 0s with the same length as the
|
1596
1699
|
* pre-shared key. */
|
@@ -1600,7 +1703,7 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1600
1703
|
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
|
1601
1704
|
goto err;
|
1602
1705
|
}
|
1603
|
-
|
1706
|
+
OPENSSL_memset(premaster_secret, 0, premaster_secret_len);
|
1604
1707
|
} else {
|
1605
1708
|
al = SSL_AD_HANDSHAKE_FAILURE;
|
1606
1709
|
OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CIPHER_TYPE);
|
@@ -1633,14 +1736,12 @@ static int ssl3_get_client_key_exchange(SSL *ssl) {
|
|
1633
1736
|
}
|
1634
1737
|
|
1635
1738
|
/* Compute the master secret */
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
if (ssl->s3->new_session->master_key_length == 0) {
|
1739
|
+
hs->new_session->master_key_length = tls1_generate_master_secret(
|
1740
|
+
hs, hs->new_session->master_key, premaster_secret, premaster_secret_len);
|
1741
|
+
if (hs->new_session->master_key_length == 0) {
|
1640
1742
|
goto err;
|
1641
1743
|
}
|
1642
|
-
|
1643
|
-
ssl->s3->tmp.extended_master_secret;
|
1744
|
+
hs->new_session->extended_master_secret = hs->extended_master_secret;
|
1644
1745
|
|
1645
1746
|
OPENSSL_cleanse(premaster_secret, premaster_secret_len);
|
1646
1747
|
OPENSSL_free(premaster_secret);
|
@@ -1658,30 +1759,26 @@ err:
|
|
1658
1759
|
return -1;
|
1659
1760
|
}
|
1660
1761
|
|
1661
|
-
static int ssl3_get_cert_verify(
|
1662
|
-
|
1762
|
+
static int ssl3_get_cert_verify(SSL_HANDSHAKE *hs) {
|
1763
|
+
SSL *const ssl = hs->ssl;
|
1764
|
+
int al;
|
1663
1765
|
CBS certificate_verify, signature;
|
1664
|
-
X509 *peer = ssl->s3->new_session->peer;
|
1665
|
-
EVP_PKEY *pkey = NULL;
|
1666
1766
|
|
1667
1767
|
/* Only RSA and ECDSA client certificates are supported, so a
|
1668
1768
|
* CertificateVerify is required if and only if there's a client certificate.
|
1669
1769
|
* */
|
1670
|
-
if (
|
1671
|
-
|
1770
|
+
if (hs->peer_pubkey == NULL) {
|
1771
|
+
SSL_TRANSCRIPT_free_buffer(&hs->transcript);
|
1672
1772
|
return 1;
|
1673
1773
|
}
|
1674
1774
|
|
1675
|
-
int msg_ret = ssl->method->ssl_get_message(ssl
|
1676
|
-
ssl_dont_hash_message);
|
1775
|
+
int msg_ret = ssl->method->ssl_get_message(ssl);
|
1677
1776
|
if (msg_ret <= 0) {
|
1678
1777
|
return msg_ret;
|
1679
1778
|
}
|
1680
1779
|
|
1681
|
-
|
1682
|
-
|
1683
|
-
if (pkey == NULL) {
|
1684
|
-
goto err;
|
1780
|
+
if (!ssl_check_message_type(ssl, SSL3_MT_CERTIFICATE_VERIFY)) {
|
1781
|
+
return -1;
|
1685
1782
|
}
|
1686
1783
|
|
1687
1784
|
CBS_init(&certificate_verify, ssl->init_msg, ssl->init_num);
|
@@ -1697,10 +1794,10 @@ static int ssl3_get_cert_verify(SSL *ssl) {
|
|
1697
1794
|
if (!tls12_check_peer_sigalg(ssl, &al, signature_algorithm)) {
|
1698
1795
|
goto f_err;
|
1699
1796
|
}
|
1700
|
-
|
1701
|
-
} else if (
|
1797
|
+
hs->new_session->peer_signature_algorithm = signature_algorithm;
|
1798
|
+
} else if (hs->peer_pubkey->type == EVP_PKEY_RSA) {
|
1702
1799
|
signature_algorithm = SSL_SIGN_RSA_PKCS1_MD5_SHA1;
|
1703
|
-
} else if (
|
1800
|
+
} else if (hs->peer_pubkey->type == EVP_PKEY_EC) {
|
1704
1801
|
signature_algorithm = SSL_SIGN_ECDSA_SHA1;
|
1705
1802
|
} else {
|
1706
1803
|
al = SSL_AD_UNSUPPORTED_CERTIFICATE;
|
@@ -1720,26 +1817,25 @@ static int ssl3_get_cert_verify(SSL *ssl) {
|
|
1720
1817
|
/* The SSL3 construction for CertificateVerify does not decompose into a
|
1721
1818
|
* single final digest and signature, and must be special-cased. */
|
1722
1819
|
if (ssl3_protocol_version(ssl) == SSL3_VERSION) {
|
1723
|
-
const EVP_MD *md;
|
1724
1820
|
uint8_t digest[EVP_MAX_MD_SIZE];
|
1725
1821
|
size_t digest_len;
|
1726
|
-
if (!
|
1727
|
-
|
1822
|
+
if (!SSL_TRANSCRIPT_ssl3_cert_verify_hash(&hs->transcript, digest,
|
1823
|
+
&digest_len, hs->new_session,
|
1824
|
+
signature_algorithm)) {
|
1728
1825
|
goto err;
|
1729
1826
|
}
|
1730
1827
|
|
1731
|
-
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(
|
1828
|
+
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(hs->peer_pubkey, NULL);
|
1732
1829
|
sig_ok = pctx != NULL &&
|
1733
1830
|
EVP_PKEY_verify_init(pctx) &&
|
1734
|
-
EVP_PKEY_CTX_set_signature_md(pctx, md) &&
|
1735
1831
|
EVP_PKEY_verify(pctx, CBS_data(&signature), CBS_len(&signature),
|
1736
1832
|
digest, digest_len);
|
1737
1833
|
EVP_PKEY_CTX_free(pctx);
|
1738
1834
|
} else {
|
1739
1835
|
sig_ok = ssl_public_key_verify(
|
1740
1836
|
ssl, CBS_data(&signature), CBS_len(&signature), signature_algorithm,
|
1741
|
-
|
1742
|
-
|
1837
|
+
hs->peer_pubkey, (const uint8_t *)hs->transcript.buffer->data,
|
1838
|
+
hs->transcript.buffer->length);
|
1743
1839
|
}
|
1744
1840
|
|
1745
1841
|
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE)
|
@@ -1754,33 +1850,33 @@ static int ssl3_get_cert_verify(SSL *ssl) {
|
|
1754
1850
|
|
1755
1851
|
/* The handshake buffer is no longer necessary, and we may hash the current
|
1756
1852
|
* message.*/
|
1757
|
-
|
1758
|
-
if (!
|
1853
|
+
SSL_TRANSCRIPT_free_buffer(&hs->transcript);
|
1854
|
+
if (!ssl_hash_current_message(hs)) {
|
1759
1855
|
goto err;
|
1760
1856
|
}
|
1761
1857
|
|
1762
|
-
|
1763
|
-
|
1764
|
-
if (0) {
|
1765
|
-
f_err:
|
1766
|
-
ssl3_send_alert(ssl, SSL3_AL_FATAL, al);
|
1767
|
-
}
|
1858
|
+
return 1;
|
1768
1859
|
|
1860
|
+
f_err:
|
1861
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, al);
|
1769
1862
|
err:
|
1770
|
-
|
1771
|
-
|
1772
|
-
return ret;
|
1863
|
+
return 0;
|
1773
1864
|
}
|
1774
1865
|
|
1775
1866
|
/* ssl3_get_next_proto reads a Next Protocol Negotiation handshake message. It
|
1776
1867
|
* sets the next_proto member in s if found */
|
1777
|
-
static int ssl3_get_next_proto(
|
1778
|
-
|
1779
|
-
|
1868
|
+
static int ssl3_get_next_proto(SSL_HANDSHAKE *hs) {
|
1869
|
+
SSL *const ssl = hs->ssl;
|
1870
|
+
int ret = ssl->method->ssl_get_message(ssl);
|
1780
1871
|
if (ret <= 0) {
|
1781
1872
|
return ret;
|
1782
1873
|
}
|
1783
1874
|
|
1875
|
+
if (!ssl_check_message_type(ssl, SSL3_MT_NEXT_PROTO) ||
|
1876
|
+
!ssl_hash_current_message(hs)) {
|
1877
|
+
return -1;
|
1878
|
+
}
|
1879
|
+
|
1784
1880
|
CBS next_protocol, selected_protocol, padding;
|
1785
1881
|
CBS_init(&next_protocol, ssl->init_msg, ssl->init_num);
|
1786
1882
|
if (!CBS_get_u8_length_prefixed(&next_protocol, &selected_protocol) ||
|
@@ -1800,133 +1896,55 @@ static int ssl3_get_next_proto(SSL *ssl) {
|
|
1800
1896
|
}
|
1801
1897
|
|
1802
1898
|
/* ssl3_get_channel_id reads and verifies a ClientID handshake message. */
|
1803
|
-
static int ssl3_get_channel_id(
|
1804
|
-
|
1805
|
-
|
1806
|
-
size_t channel_id_hash_len;
|
1807
|
-
const uint8_t *p;
|
1808
|
-
uint16_t extension_type;
|
1809
|
-
EC_GROUP *p256 = NULL;
|
1810
|
-
EC_KEY *key = NULL;
|
1811
|
-
EC_POINT *point = NULL;
|
1812
|
-
ECDSA_SIG sig;
|
1813
|
-
BIGNUM x, y;
|
1814
|
-
CBS encrypted_extensions, extension;
|
1815
|
-
|
1816
|
-
int msg_ret = ssl->method->ssl_get_message(ssl, SSL3_MT_CHANNEL_ID,
|
1817
|
-
ssl_dont_hash_message);
|
1899
|
+
static int ssl3_get_channel_id(SSL_HANDSHAKE *hs) {
|
1900
|
+
SSL *const ssl = hs->ssl;
|
1901
|
+
int msg_ret = ssl->method->ssl_get_message(ssl);
|
1818
1902
|
if (msg_ret <= 0) {
|
1819
1903
|
return msg_ret;
|
1820
1904
|
}
|
1821
1905
|
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1906
|
+
if (!ssl_check_message_type(ssl, SSL3_MT_CHANNEL_ID) ||
|
1907
|
+
!tls1_verify_channel_id(hs) ||
|
1908
|
+
!ssl_hash_current_message(hs)) {
|
1825
1909
|
return -1;
|
1826
1910
|
}
|
1827
|
-
|
1828
|
-
|
1829
|
-
if (!ssl->method->hash_current_message(ssl)) {
|
1830
|
-
return -1;
|
1831
|
-
}
|
1832
|
-
|
1833
|
-
CBS_init(&encrypted_extensions, ssl->init_msg, ssl->init_num);
|
1834
|
-
|
1835
|
-
/* EncryptedExtensions could include multiple extensions, but the only
|
1836
|
-
* extension that could be negotiated is Channel ID, so there can only be one
|
1837
|
-
* entry. */
|
1838
|
-
if (!CBS_get_u16(&encrypted_extensions, &extension_type) ||
|
1839
|
-
!CBS_get_u16_length_prefixed(&encrypted_extensions, &extension) ||
|
1840
|
-
CBS_len(&encrypted_extensions) != 0 ||
|
1841
|
-
extension_type != TLSEXT_TYPE_channel_id ||
|
1842
|
-
CBS_len(&extension) != TLSEXT_CHANNEL_ID_SIZE) {
|
1843
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
1844
|
-
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
1845
|
-
return -1;
|
1846
|
-
}
|
1847
|
-
|
1848
|
-
p256 = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
|
1849
|
-
if (!p256) {
|
1850
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_P256_SUPPORT);
|
1851
|
-
return -1;
|
1852
|
-
}
|
1853
|
-
|
1854
|
-
BN_init(&x);
|
1855
|
-
BN_init(&y);
|
1856
|
-
sig.r = BN_new();
|
1857
|
-
sig.s = BN_new();
|
1858
|
-
if (sig.r == NULL || sig.s == NULL) {
|
1859
|
-
goto err;
|
1860
|
-
}
|
1861
|
-
|
1862
|
-
p = CBS_data(&extension);
|
1863
|
-
if (BN_bin2bn(p + 0, 32, &x) == NULL ||
|
1864
|
-
BN_bin2bn(p + 32, 32, &y) == NULL ||
|
1865
|
-
BN_bin2bn(p + 64, 32, sig.r) == NULL ||
|
1866
|
-
BN_bin2bn(p + 96, 32, sig.s) == NULL) {
|
1867
|
-
goto err;
|
1868
|
-
}
|
1869
|
-
|
1870
|
-
point = EC_POINT_new(p256);
|
1871
|
-
if (!point ||
|
1872
|
-
!EC_POINT_set_affine_coordinates_GFp(p256, point, &x, &y, NULL)) {
|
1873
|
-
goto err;
|
1874
|
-
}
|
1875
|
-
|
1876
|
-
key = EC_KEY_new();
|
1877
|
-
if (!key || !EC_KEY_set_group(key, p256) ||
|
1878
|
-
!EC_KEY_set_public_key(key, point)) {
|
1879
|
-
goto err;
|
1880
|
-
}
|
1881
|
-
|
1882
|
-
/* We stored the handshake hash in |tlsext_channel_id| the first time that we
|
1883
|
-
* were called. */
|
1884
|
-
int sig_ok = ECDSA_do_verify(channel_id_hash, channel_id_hash_len, &sig, key);
|
1885
|
-
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE)
|
1886
|
-
sig_ok = 1;
|
1887
|
-
#endif
|
1888
|
-
if (!sig_ok) {
|
1889
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_CHANNEL_ID_SIGNATURE_INVALID);
|
1890
|
-
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECRYPT_ERROR);
|
1891
|
-
ssl->s3->tlsext_channel_id_valid = 0;
|
1892
|
-
goto err;
|
1893
|
-
}
|
1894
|
-
|
1895
|
-
memcpy(ssl->s3->tlsext_channel_id, p, 64);
|
1896
|
-
ret = 1;
|
1897
|
-
|
1898
|
-
err:
|
1899
|
-
BN_free(&x);
|
1900
|
-
BN_free(&y);
|
1901
|
-
BN_free(sig.r);
|
1902
|
-
BN_free(sig.s);
|
1903
|
-
EC_KEY_free(key);
|
1904
|
-
EC_POINT_free(point);
|
1905
|
-
EC_GROUP_free(p256);
|
1906
|
-
return ret;
|
1911
|
+
return 1;
|
1907
1912
|
}
|
1908
1913
|
|
1909
|
-
static int ssl3_send_new_session_ticket(
|
1910
|
-
|
1911
|
-
|
1914
|
+
static int ssl3_send_new_session_ticket(SSL_HANDSHAKE *hs) {
|
1915
|
+
SSL *const ssl = hs->ssl;
|
1916
|
+
const SSL_SESSION *session;
|
1917
|
+
SSL_SESSION *session_copy = NULL;
|
1918
|
+
if (ssl->session == NULL) {
|
1919
|
+
/* Fix the timeout to measure from the ticket issuance time. */
|
1920
|
+
ssl_session_rebase_time(ssl, hs->new_session);
|
1921
|
+
session = hs->new_session;
|
1922
|
+
} else {
|
1923
|
+
/* We are renewing an existing session. Duplicate the session to adjust the
|
1924
|
+
* timeout. */
|
1925
|
+
session_copy = SSL_SESSION_dup(ssl->session, SSL_SESSION_INCLUDE_NONAUTH);
|
1926
|
+
if (session_copy == NULL) {
|
1927
|
+
return -1;
|
1928
|
+
}
|
1929
|
+
|
1930
|
+
ssl_session_rebase_time(ssl, session_copy);
|
1931
|
+
session = session_copy;
|
1912
1932
|
}
|
1913
1933
|
|
1914
1934
|
CBB cbb, body, ticket;
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
return 0;
|
1935
|
+
int ok =
|
1936
|
+
ssl->method->init_message(ssl, &cbb, &body, SSL3_MT_NEW_SESSION_TICKET) &&
|
1937
|
+
CBB_add_u32(&body, session->timeout) &&
|
1938
|
+
CBB_add_u16_length_prefixed(&body, &ticket) &&
|
1939
|
+
ssl_encrypt_ticket(ssl, &ticket, session) &&
|
1940
|
+
ssl_add_message_cbb(ssl, &cbb);
|
1941
|
+
|
1942
|
+
SSL_SESSION_free(session_copy);
|
1943
|
+
CBB_cleanup(&cbb);
|
1944
|
+
|
1945
|
+
if (!ok) {
|
1946
|
+
return -1;
|
1928
1947
|
}
|
1929
1948
|
|
1930
|
-
|
1931
|
-
return ssl->method->write_message(ssl);
|
1949
|
+
return 1;
|
1932
1950
|
}
|