grpc 1.9.1 → 1.10.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 +2654 -953
- data/etc/roots.pem +282 -683
- data/include/grpc/compression.h +9 -26
- data/include/grpc/grpc.h +10 -24
- data/include/grpc/grpc_security.h +7 -1
- data/include/grpc/impl/codegen/compression_types.h +5 -62
- data/include/grpc/impl/codegen/grpc_types.h +10 -6
- data/include/grpc/module.modulemap +1 -10
- data/include/grpc/support/alloc.h +3 -2
- data/include/grpc/support/log.h +1 -2
- data/{src/core/lib/gpr/thd_internal.h → include/grpc/support/thd_id.h} +23 -9
- data/src/boringssl/err_data.c +550 -496
- data/src/core/ext/census/grpc_context.cc +2 -1
- data/src/core/ext/filters/client_channel/backup_poller.cc +5 -4
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +7 -7
- data/src/core/ext/filters/client_channel/client_channel.cc +162 -172
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +4 -2
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +10 -10
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +18 -14
- data/src/core/ext/filters/client_channel/http_proxy.cc +3 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +21 -105
- data/src/core/ext/filters/client_channel/lb_policy.h +166 -170
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +41 -36
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1452 -1459
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +7 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +27 -27
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +279 -304
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +358 -330
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +30 -41
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +7 -14
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +8 -21
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +23 -27
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +58 -33
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +25 -12
- data/src/core/ext/filters/client_channel/parse_address.cc +10 -8
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver.cc +6 -52
- data/src/core/ext/filters/client_channel/resolver.h +98 -55
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +266 -237
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +31 -27
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +244 -207
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +161 -148
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +47 -31
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +126 -126
- data/src/core/ext/filters/client_channel/resolver_factory.h +33 -32
- data/src/core/ext/filters/client_channel/resolver_registry.cc +110 -90
- data/src/core/ext/filters/client_channel/resolver_registry.h +49 -36
- data/src/core/ext/filters/client_channel/retry_throttle.cc +29 -22
- data/src/core/ext/filters/client_channel/subchannel.cc +173 -173
- data/src/core/ext/filters/client_channel/subchannel.h +38 -45
- data/src/core/ext/filters/client_channel/subchannel_index.cc +44 -40
- data/src/core/ext/filters/client_channel/uri_parser.cc +3 -3
- data/src/core/ext/filters/deadline/deadline_filter.cc +27 -18
- data/src/core/ext/filters/http/client/http_client_filter.cc +26 -23
- data/src/core/ext/filters/http/http_filters_plugin.cc +3 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +78 -110
- data/src/core/ext/filters/http/server/http_server_filter.cc +29 -26
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +9 -11
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +2 -1
- data/src/core/ext/filters/max_age/max_age_filter.cc +14 -14
- data/src/core/ext/filters/message_size/message_size_filter.cc +20 -18
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -4
- data/src/core/ext/filters/workarounds/workaround_utils.cc +4 -4
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +2 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +10 -10
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +4 -4
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +11 -12
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +16 -13
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +36 -9
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +3 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +17 -14
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +139 -145
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +16 -14
- data/src/core/ext/transport/chttp2/transport/flow_control.h +8 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +35 -33
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +27 -25
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +12 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +16 -15
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +19 -19
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +11 -11
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +23 -22
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +35 -35
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +10 -7
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -1
- data/src/core/ext/transport/chttp2/transport/parsing.cc +35 -39
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +8 -7
- data/src/core/ext/transport/chttp2/transport/varint.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/writing.cc +18 -18
- data/src/core/ext/transport/inproc/inproc_transport.cc +43 -23
- data/src/core/lib/{gpr → avl}/avl.cc +61 -57
- data/{include/grpc/support → src/core/lib/avl}/avl.h +25 -35
- data/src/core/lib/backoff/backoff.cc +6 -5
- data/src/core/lib/channel/channel_args.cc +23 -109
- data/src/core/lib/channel/channel_args.h +5 -31
- data/src/core/lib/channel/channel_stack.cc +11 -8
- data/src/core/lib/channel/channel_stack_builder.cc +10 -7
- data/src/core/lib/channel/connected_channel.cc +18 -17
- data/src/core/lib/channel/handshaker.cc +8 -8
- data/src/core/lib/channel/handshaker_registry.cc +3 -2
- data/src/core/lib/compression/algorithm_metadata.h +13 -6
- data/src/core/lib/compression/compression.cc +72 -183
- data/src/core/lib/compression/compression_internal.cc +274 -0
- data/src/core/lib/compression/compression_internal.h +86 -0
- data/src/core/lib/compression/message_compress.cc +15 -15
- data/src/core/lib/compression/message_compress.h +4 -3
- data/src/core/lib/compression/stream_compression_gzip.cc +8 -8
- data/src/core/lib/compression/stream_compression_identity.cc +1 -1
- data/src/core/lib/debug/stats.cc +10 -8
- data/src/core/lib/debug/stats_data.cc +2 -1
- data/src/core/lib/debug/trace.cc +3 -3
- data/src/core/lib/gpr/alloc.cc +7 -11
- data/src/core/lib/gpr/arena.cc +34 -12
- data/src/core/lib/gpr/atm.cc +2 -1
- data/src/core/lib/gpr/cpu_linux.cc +3 -3
- data/src/core/lib/gpr/cpu_posix.cc +2 -1
- data/src/core/lib/gpr/env.h +1 -1
- data/src/core/lib/gpr/env_linux.cc +1 -1
- data/src/core/lib/gpr/env_windows.cc +4 -4
- data/src/core/lib/gpr/fork.cc +16 -2
- data/src/core/lib/gpr/host_port.cc +5 -4
- data/{include/grpc/support → src/core/lib/gpr}/host_port.h +5 -13
- data/src/core/lib/gpr/log.cc +5 -4
- data/src/core/lib/gpr/log_linux.cc +1 -1
- data/src/core/lib/gpr/mpscq.cc +1 -0
- data/src/core/lib/gpr/murmur_hash.cc +4 -4
- data/src/core/lib/gpr/string.cc +19 -16
- data/src/core/lib/gpr/string_posix.cc +3 -3
- data/src/core/lib/gpr/sync_posix.cc +5 -9
- data/src/core/lib/gpr/thd.cc +3 -3
- data/{include/grpc/support → src/core/lib/gpr}/thd.h +20 -28
- data/src/core/lib/gpr/thd_posix.cc +6 -4
- data/src/core/lib/gpr/thd_windows.cc +3 -1
- data/src/core/lib/gpr/time.cc +6 -4
- data/src/core/lib/gpr/time_posix.cc +2 -2
- data/{include/grpc/support → src/core/lib/gpr}/tls.h +6 -6
- data/{include/grpc/support → src/core/lib/gpr}/tls_gcc.h +3 -3
- data/{include/grpc/support → src/core/lib/gpr}/tls_msvc.h +3 -3
- data/src/core/lib/gpr/tls_pthread.cc +1 -1
- data/{include/grpc/support → src/core/lib/gpr}/tls_pthread.h +3 -3
- data/{include/grpc/support → src/core/lib/gpr}/useful.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/abstract.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/atomic.h +5 -5
- data/src/core/lib/{gpr++ → gprpp}/atomic_with_atm.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/atomic_with_std.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/debug_location.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/inlined_vector.h +44 -22
- data/src/core/lib/{gpr++ → gprpp}/manual_constructor.h +2 -2
- data/src/core/lib/{gpr++ → gprpp}/memory.h +14 -5
- data/src/core/lib/{gpr++ → gprpp}/orphanable.h +39 -14
- data/src/core/lib/{gpr++ → gprpp}/ref_counted.h +42 -10
- data/src/core/lib/{gpr++ → gprpp}/ref_counted_ptr.h +18 -8
- data/src/core/lib/http/format_request.cc +3 -3
- data/src/core/lib/http/httpcli.cc +6 -7
- data/src/core/lib/http/httpcli_security_connector.cc +10 -10
- data/src/core/lib/http/parser.cc +16 -12
- data/src/core/lib/iomgr/call_combiner.cc +12 -13
- data/src/core/lib/iomgr/closure.h +4 -6
- data/src/core/lib/iomgr/combiner.cc +10 -21
- data/src/core/lib/iomgr/error.cc +50 -55
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +41 -52
- data/src/core/lib/iomgr/ev_epollex_linux.cc +80 -28
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +23 -30
- data/src/core/lib/iomgr/ev_poll_posix.cc +52 -46
- data/src/core/lib/iomgr/ev_posix.cc +47 -6
- data/src/core/lib/iomgr/exec_ctx.cc +10 -10
- data/src/core/lib/iomgr/exec_ctx.h +1 -1
- data/src/core/lib/iomgr/executor.cc +16 -13
- data/src/core/lib/iomgr/fork_posix.cc +1 -3
- data/src/core/lib/iomgr/gethostname_host_name_max.cc +1 -1
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +2 -2
- data/src/core/lib/iomgr/iomgr_uv.cc +2 -0
- data/src/core/lib/iomgr/iomgr_uv.h +1 -1
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +5 -4
- data/src/core/lib/iomgr/load_file.cc +3 -3
- data/src/core/lib/iomgr/pollset_windows.cc +1 -1
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -9
- data/src/core/lib/iomgr/resolve_address_uv.cc +2 -2
- data/src/core/lib/iomgr/resolve_address_windows.cc +3 -2
- data/src/core/lib/iomgr/resource_quota.cc +36 -34
- data/src/core/lib/iomgr/sockaddr_utils.cc +39 -23
- data/src/core/lib/iomgr/socket_factory_posix.cc +5 -5
- data/src/core/lib/iomgr/socket_mutator.cc +7 -7
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +7 -4
- data/src/core/lib/iomgr/socket_utils_linux.cc +3 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +7 -6
- data/src/core/lib/iomgr/tcp_client_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_posix.cc +47 -55
- data/src/core/lib/iomgr/tcp_server_posix.cc +12 -10
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -5
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +4 -3
- data/src/core/lib/iomgr/tcp_windows.cc +1 -1
- data/src/core/lib/iomgr/timer_generic.cc +16 -14
- data/src/core/lib/iomgr/timer_heap.cc +8 -7
- data/src/core/lib/iomgr/timer_manager.cc +4 -3
- data/src/core/lib/iomgr/udp_server.cc +24 -16
- data/src/core/lib/iomgr/unix_sockets_posix.cc +15 -10
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +6 -5
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +1 -2
- data/src/core/lib/json/json.cc +1 -1
- data/src/core/lib/json/json_reader.cc +8 -6
- data/src/core/lib/json/json_string.cc +19 -18
- data/src/core/lib/json/json_writer.cc +10 -8
- data/src/core/lib/profiling/basic_timers.cc +1 -1
- data/src/core/lib/profiling/timers.h +3 -20
- data/src/core/lib/security/context/security_context.cc +16 -14
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +17 -14
- data/src/core/lib/security/credentials/credentials.cc +9 -8
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +12 -13
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +7 -4
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +5 -3
- data/src/core/lib/security/credentials/jwt/json_token.cc +4 -3
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -7
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +21 -18
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +23 -18
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +11 -7
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +22 -21
- data/src/core/lib/security/{transport → security_connector}/security_connector.cc +46 -43
- data/src/core/lib/security/{transport → security_connector}/security_connector.h +3 -3
- data/src/core/lib/security/transport/client_auth_filter.cc +32 -34
- data/src/core/lib/security/transport/lb_targets_info.cc +7 -5
- data/src/core/lib/security/transport/secure_endpoint.cc +21 -21
- data/src/core/lib/security/transport/security_handshaker.cc +19 -18
- data/src/core/lib/security/transport/security_handshaker.h +1 -1
- data/src/core/lib/security/transport/server_auth_filter.cc +21 -21
- data/src/core/lib/slice/b64.cc +19 -16
- data/src/core/lib/slice/percent_encoding.cc +5 -5
- data/src/core/lib/slice/slice.cc +35 -33
- data/src/core/lib/slice/slice_buffer.cc +16 -14
- data/src/core/lib/slice/slice_hash_table.cc +3 -2
- data/src/core/lib/slice/slice_intern.cc +21 -25
- data/src/core/lib/slice/slice_string_helpers.cc +45 -9
- data/src/core/lib/slice/slice_string_helpers.h +6 -0
- data/src/core/lib/surface/byte_buffer.cc +2 -2
- data/src/core/lib/surface/byte_buffer_reader.cc +6 -3
- data/src/core/lib/surface/call.cc +171 -260
- data/src/core/lib/surface/call_test_only.h +1 -13
- data/src/core/lib/surface/channel.cc +20 -43
- data/src/core/lib/surface/channel_init.cc +7 -7
- data/src/core/lib/surface/channel_ping.cc +2 -2
- data/src/core/lib/surface/completion_queue.cc +69 -75
- data/src/core/lib/surface/init.cc +4 -5
- data/src/core/lib/surface/init_secure.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +1 -1
- data/src/core/lib/surface/server.cc +64 -59
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +6 -5
- data/src/core/lib/transport/byte_stream.cc +23 -14
- data/src/core/lib/transport/byte_stream.h +1 -1
- data/src/core/lib/transport/connectivity_state.cc +9 -13
- data/src/core/lib/transport/error_utils.cc +10 -7
- data/src/core/lib/transport/metadata.cc +27 -26
- data/src/core/lib/transport/metadata.h +1 -1
- data/src/core/lib/transport/pid_controller.cc +2 -1
- data/src/core/lib/transport/service_config.cc +5 -5
- data/src/core/lib/transport/static_metadata.cc +225 -222
- data/src/core/lib/transport/static_metadata.h +77 -76
- data/src/core/lib/transport/timeout_encoding.cc +3 -2
- data/src/core/lib/transport/transport.cc +6 -5
- data/src/core/lib/transport/transport_op_string.cc +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -4
- data/src/core/tsi/alts_transport_security.cc +61 -0
- data/src/core/tsi/{gts_transport_security.h → alts_transport_security.h} +16 -8
- data/src/core/tsi/fake_transport_security.cc +59 -43
- data/src/core/tsi/ssl_transport_security.cc +122 -107
- data/src/core/tsi/transport_security.cc +3 -3
- data/src/core/tsi/transport_security_adapter.cc +16 -10
- data/src/ruby/bin/apis/pubsub_demo.rb +1 -1
- data/src/ruby/ext/grpc/rb_channel.c +3 -4
- data/src/ruby/ext/grpc/rb_compression_options.c +13 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -76
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -120
- data/src/ruby/ext/grpc/rb_server.c +52 -28
- data/src/ruby/lib/grpc/generic/rpc_server.rb +7 -4
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +1 -1
- data/src/ruby/pb/test/server.rb +1 -1
- data/src/ruby/spec/client_server_spec.rb +4 -2
- data/src/ruby/spec/generic/active_call_spec.rb +2 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +32 -8
- data/src/ruby/spec/server_spec.rb +26 -7
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +7 -2
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +15 -0
- data/third_party/boringssl/crypto/asn1/a_gentm.c +1 -1
- data/third_party/boringssl/crypto/asn1/a_print.c +0 -28
- data/third_party/boringssl/crypto/asn1/a_strnid.c +3 -0
- data/third_party/boringssl/crypto/asn1/a_time.c +17 -9
- data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -1
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -49
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +1 -1
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +9 -9
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +0 -6
- data/third_party/boringssl/crypto/asn1/time_support.c +5 -5
- data/third_party/boringssl/crypto/base64/base64.c +65 -43
- data/third_party/boringssl/crypto/bio/bio.c +134 -110
- data/third_party/boringssl/crypto/bio/bio_mem.c +9 -9
- data/third_party/boringssl/crypto/bio/connect.c +17 -17
- data/third_party/boringssl/crypto/bio/fd.c +2 -1
- data/third_party/boringssl/crypto/bio/file.c +14 -14
- data/third_party/boringssl/crypto/bio/hexdump.c +15 -16
- data/third_party/boringssl/crypto/bio/internal.h +14 -14
- data/third_party/boringssl/crypto/bio/pair.c +45 -45
- data/third_party/boringssl/crypto/bio/printf.c +6 -10
- data/third_party/boringssl/crypto/{bn → bn_extra}/bn_asn1.c +9 -9
- data/third_party/boringssl/crypto/{bn → bn_extra}/convert.c +18 -223
- data/third_party/boringssl/crypto/buf/buf.c +20 -44
- data/third_party/boringssl/crypto/bytestring/ber.c +35 -35
- data/third_party/boringssl/crypto/bytestring/cbb.c +24 -24
- data/third_party/boringssl/crypto/bytestring/cbs.c +33 -37
- data/third_party/boringssl/crypto/bytestring/internal.h +38 -38
- data/third_party/boringssl/crypto/chacha/chacha.c +7 -7
- data/third_party/boringssl/crypto/{asn1/t_bitst.c → cipher_extra/cipher_extra.c} +49 -38
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/derive_key.c +0 -2
- data/third_party/boringssl/crypto/cipher_extra/e_aesctrhmac.c +281 -0
- data/third_party/boringssl/crypto/cipher_extra/e_aesgcmsiv.c +867 -0
- data/third_party/boringssl/crypto/cipher_extra/e_chacha20poly1305.c +326 -0
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_null.c +0 -1
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_rc2.c +22 -10
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_rc4.c +0 -0
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_ssl3.c +120 -64
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_tls.c +220 -141
- data/third_party/boringssl/crypto/{asn1/x_bignum.c → cipher_extra/internal.h} +61 -86
- data/third_party/boringssl/crypto/cipher_extra/tls_cbc.c +482 -0
- data/third_party/boringssl/crypto/cmac/cmac.c +20 -20
- data/third_party/boringssl/crypto/conf/conf.c +32 -20
- data/third_party/boringssl/crypto/conf/internal.h +3 -3
- data/third_party/boringssl/crypto/cpu-aarch64-linux.c +5 -5
- data/third_party/boringssl/crypto/cpu-arm-linux.c +44 -41
- data/third_party/boringssl/crypto/cpu-intel.c +68 -43
- data/third_party/boringssl/crypto/cpu-ppc64le.c +5 -7
- data/third_party/boringssl/crypto/crypto.c +54 -32
- data/third_party/boringssl/crypto/curve25519/curve25519.c +269 -269
- data/third_party/boringssl/crypto/curve25519/internal.h +28 -8
- data/third_party/boringssl/crypto/curve25519/spake25519.c +180 -106
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +9 -9
- data/third_party/boringssl/crypto/dh/check.c +33 -34
- data/third_party/boringssl/crypto/dh/dh.c +72 -36
- data/third_party/boringssl/crypto/dh/dh_asn1.c +1 -1
- data/third_party/boringssl/crypto/dh/params.c +1 -161
- data/third_party/boringssl/crypto/digest_extra/digest_extra.c +240 -0
- data/third_party/boringssl/crypto/dsa/dsa.c +127 -87
- data/third_party/boringssl/crypto/dsa/dsa_asn1.c +1 -1
- data/third_party/boringssl/crypto/{ec → ec_extra}/ec_asn1.c +83 -70
- data/third_party/boringssl/crypto/ecdh/ecdh.c +1 -1
- data/third_party/boringssl/crypto/{ecdsa → ecdsa_extra}/ecdsa_asn1.c +86 -31
- data/third_party/boringssl/crypto/engine/engine.c +6 -6
- data/third_party/boringssl/crypto/err/err.c +197 -106
- data/third_party/boringssl/crypto/err/internal.h +58 -0
- data/third_party/boringssl/crypto/evp/digestsign.c +86 -14
- data/third_party/boringssl/crypto/evp/evp.c +6 -11
- data/third_party/boringssl/crypto/evp/evp_asn1.c +17 -17
- data/third_party/boringssl/crypto/evp/evp_ctx.c +15 -11
- data/third_party/boringssl/crypto/evp/internal.h +66 -51
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +11 -11
- data/third_party/boringssl/crypto/evp/p_ec.c +10 -8
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +11 -12
- data/third_party/boringssl/crypto/evp/p_ed25519.c +71 -0
- data/third_party/boringssl/crypto/evp/p_ed25519_asn1.c +190 -0
- data/third_party/boringssl/crypto/evp/p_rsa.c +50 -95
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +28 -18
- data/third_party/boringssl/crypto/evp/pbkdf.c +49 -56
- data/third_party/boringssl/crypto/evp/print.c +5 -36
- data/third_party/boringssl/crypto/evp/scrypt.c +209 -0
- data/third_party/boringssl/crypto/ex_data.c +15 -45
- data/third_party/boringssl/crypto/fipsmodule/aes/internal.h +100 -0
- data/third_party/boringssl/crypto/fipsmodule/bcm.c +679 -0
- data/third_party/boringssl/crypto/{bn → fipsmodule/bn}/internal.h +40 -27
- data/third_party/boringssl/crypto/{bn → fipsmodule/bn}/rsaz_exp.h +0 -0
- data/third_party/boringssl/crypto/{cipher → fipsmodule/cipher}/internal.h +34 -67
- data/third_party/boringssl/crypto/fipsmodule/delocate.h +88 -0
- data/third_party/boringssl/crypto/{des → fipsmodule/des}/internal.h +18 -4
- data/third_party/boringssl/crypto/{digest → fipsmodule/digest}/internal.h +18 -18
- data/third_party/boringssl/crypto/{digest → fipsmodule/digest}/md32_common.h +58 -64
- data/third_party/boringssl/crypto/{ec → fipsmodule/ec}/internal.h +58 -52
- data/third_party/boringssl/crypto/{ec → fipsmodule/ec}/p256-x86_64-table.h +11 -11
- data/third_party/boringssl/crypto/{ec → fipsmodule/ec}/p256-x86_64.h +32 -32
- data/third_party/boringssl/crypto/{rand/internal.h → fipsmodule/is_fips.c} +10 -15
- data/third_party/boringssl/crypto/{modes → fipsmodule/modes}/internal.h +112 -119
- data/third_party/boringssl/crypto/fipsmodule/rand/internal.h +92 -0
- data/third_party/boringssl/crypto/{rsa → fipsmodule/rsa}/internal.h +36 -49
- data/third_party/boringssl/crypto/hkdf/hkdf.c +6 -6
- data/third_party/boringssl/crypto/internal.h +301 -233
- data/third_party/boringssl/crypto/lhash/lhash.c +26 -45
- data/third_party/boringssl/crypto/mem.c +76 -33
- data/third_party/boringssl/crypto/obj/obj.c +44 -28
- data/third_party/boringssl/crypto/obj/obj_dat.h +102 -34
- data/third_party/boringssl/crypto/obj/obj_xref.c +6 -6
- data/third_party/boringssl/crypto/pem/pem_info.c +3 -5
- data/third_party/boringssl/crypto/pem/pem_lib.c +1 -6
- data/third_party/boringssl/crypto/pem/pem_pk8.c +1 -0
- data/third_party/boringssl/crypto/pem/pem_pkey.c +1 -1
- data/third_party/boringssl/crypto/pem/pem_xaux.c +0 -2
- data/third_party/boringssl/crypto/pkcs7/internal.h +49 -0
- data/third_party/boringssl/crypto/pkcs7/pkcs7.c +166 -0
- data/third_party/boringssl/crypto/{x509/pkcs7.c → pkcs7/pkcs7_x509.c} +27 -147
- data/third_party/boringssl/crypto/pkcs8/internal.h +34 -16
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +120 -39
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +144 -857
- data/third_party/boringssl/crypto/pkcs8/pkcs8_x509.c +789 -0
- data/third_party/boringssl/crypto/poly1305/internal.h +4 -3
- data/third_party/boringssl/crypto/poly1305/poly1305.c +14 -14
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +11 -11
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +41 -41
- data/third_party/boringssl/crypto/pool/internal.h +2 -2
- data/third_party/boringssl/crypto/pool/pool.c +15 -15
- data/third_party/boringssl/crypto/{rand → rand_extra}/deterministic.c +7 -7
- data/third_party/boringssl/crypto/rand_extra/forkunsafe.c +46 -0
- data/third_party/boringssl/crypto/{rand → rand_extra}/fuchsia.c +7 -7
- data/third_party/boringssl/crypto/rand_extra/rand_extra.c +70 -0
- data/third_party/boringssl/crypto/{rand → rand_extra}/windows.c +5 -5
- data/third_party/boringssl/crypto/refcount_c11.c +2 -2
- data/third_party/boringssl/crypto/refcount_lock.c +1 -1
- data/third_party/boringssl/crypto/{rsa → rsa_extra}/rsa_asn1.c +12 -120
- data/third_party/boringssl/crypto/stack/stack.c +13 -13
- data/third_party/boringssl/crypto/thread_none.c +1 -1
- data/third_party/boringssl/crypto/thread_pthread.c +1 -1
- data/third_party/boringssl/crypto/thread_win.c +40 -40
- data/third_party/boringssl/crypto/x509/a_sign.c +5 -12
- data/third_party/boringssl/crypto/x509/a_verify.c +6 -18
- data/third_party/boringssl/crypto/x509/algorithm.c +22 -6
- data/third_party/boringssl/crypto/x509/asn1_gen.c +30 -7
- data/third_party/boringssl/crypto/x509/by_dir.c +2 -2
- data/third_party/boringssl/crypto/x509/by_file.c +2 -2
- data/third_party/boringssl/crypto/x509/rsa_pss.c +5 -5
- data/third_party/boringssl/crypto/x509/t_x509.c +2 -1
- data/third_party/boringssl/crypto/x509/x509_def.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_lu.c +35 -4
- data/third_party/boringssl/crypto/x509/x509_set.c +10 -0
- data/third_party/boringssl/crypto/x509/x509_vfy.c +20 -17
- data/third_party/boringssl/crypto/x509/x_name.c +13 -16
- data/third_party/boringssl/crypto/x509/x_x509.c +3 -3
- data/third_party/boringssl/crypto/x509/x_x509a.c +0 -7
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +8 -0
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
- data/third_party/boringssl/crypto/x509v3/pcy_lib.c +0 -9
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +1 -1
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +25 -15
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +21 -11
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +9 -3
- data/third_party/boringssl/crypto/x509v3/v3_info.c +22 -14
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +27 -11
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +0 -33
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +4 -4
- data/third_party/boringssl/include/openssl/aead.h +280 -191
- data/third_party/boringssl/include/openssl/aes.h +50 -50
- data/third_party/boringssl/include/openssl/arm_arch.h +12 -12
- data/third_party/boringssl/include/openssl/asn1.h +14 -77
- data/third_party/boringssl/include/openssl/asn1t.h +11 -15
- data/third_party/boringssl/include/openssl/base.h +78 -51
- data/third_party/boringssl/include/openssl/base64.h +68 -68
- data/third_party/boringssl/include/openssl/bio.h +472 -406
- data/third_party/boringssl/include/openssl/blowfish.h +1 -1
- data/third_party/boringssl/include/openssl/bn.h +454 -435
- data/third_party/boringssl/include/openssl/buf.h +27 -27
- data/third_party/boringssl/include/openssl/bytestring.h +282 -267
- data/third_party/boringssl/include/openssl/cast.h +2 -2
- data/third_party/boringssl/include/openssl/chacha.h +5 -5
- data/third_party/boringssl/include/openssl/cipher.h +209 -200
- data/third_party/boringssl/include/openssl/cmac.h +27 -27
- data/third_party/boringssl/include/openssl/conf.h +49 -46
- data/third_party/boringssl/include/openssl/cpu.h +60 -45
- data/third_party/boringssl/include/openssl/crypto.h +59 -35
- data/third_party/boringssl/include/openssl/curve25519.h +97 -92
- data/third_party/boringssl/include/openssl/des.h +25 -25
- data/third_party/boringssl/include/openssl/dh.h +98 -97
- data/third_party/boringssl/include/openssl/digest.h +143 -114
- data/third_party/boringssl/include/openssl/dsa.h +217 -202
- data/third_party/boringssl/include/openssl/ec.h +132 -131
- data/third_party/boringssl/include/openssl/ec_key.h +132 -128
- data/third_party/boringssl/include/openssl/ecdh.h +9 -9
- data/third_party/boringssl/include/openssl/ecdsa.h +66 -66
- data/third_party/boringssl/include/openssl/engine.h +38 -38
- data/third_party/boringssl/include/openssl/err.h +189 -219
- data/third_party/boringssl/include/openssl/evp.h +473 -397
- data/third_party/boringssl/include/openssl/ex_data.h +46 -56
- data/third_party/boringssl/include/openssl/hkdf.h +17 -17
- data/third_party/boringssl/include/openssl/hmac.h +55 -43
- data/third_party/boringssl/include/openssl/is_boringssl.h +16 -0
- data/third_party/boringssl/include/openssl/lhash.h +67 -67
- data/third_party/boringssl/include/openssl/lhash_macros.h +4 -4
- data/third_party/boringssl/include/openssl/md4.h +14 -14
- data/third_party/boringssl/include/openssl/md5.h +14 -14
- data/third_party/boringssl/include/openssl/mem.h +39 -33
- data/third_party/boringssl/include/openssl/nid.h +43 -0
- data/third_party/boringssl/include/openssl/obj.h +93 -87
- data/third_party/boringssl/include/openssl/opensslconf.h +8 -1
- data/third_party/boringssl/include/openssl/pem.h +2 -122
- data/third_party/boringssl/include/openssl/pkcs7.h +68 -2
- data/third_party/boringssl/include/openssl/pkcs8.h +81 -66
- data/third_party/boringssl/include/openssl/poly1305.h +11 -11
- data/third_party/boringssl/include/openssl/pool.h +29 -25
- data/third_party/boringssl/include/openssl/rand.h +48 -45
- data/third_party/boringssl/include/openssl/rc4.h +9 -9
- data/third_party/boringssl/include/openssl/ripemd.h +13 -13
- data/third_party/boringssl/include/openssl/rsa.h +371 -340
- data/third_party/boringssl/include/openssl/sha.h +71 -71
- data/third_party/boringssl/include/openssl/span.h +191 -0
- data/third_party/boringssl/include/openssl/ssl.h +2639 -2519
- data/third_party/boringssl/include/openssl/ssl3.h +39 -122
- data/third_party/boringssl/include/openssl/stack.h +355 -164
- data/third_party/boringssl/include/openssl/thread.h +43 -43
- data/third_party/boringssl/include/openssl/tls1.h +60 -63
- data/third_party/boringssl/include/openssl/type_check.h +10 -14
- data/third_party/boringssl/include/openssl/x509.h +41 -116
- data/third_party/boringssl/include/openssl/x509_vfy.h +17 -25
- data/third_party/boringssl/include/openssl/x509v3.h +27 -21
- data/third_party/boringssl/ssl/{bio_ssl.c → bio_ssl.cc} +9 -5
- data/third_party/boringssl/ssl/{custom_extensions.c → custom_extensions.cc} +19 -12
- data/third_party/boringssl/ssl/{d1_both.c → d1_both.cc} +224 -193
- data/third_party/boringssl/ssl/{d1_lib.c → d1_lib.cc} +86 -79
- data/third_party/boringssl/ssl/{d1_pkt.c → d1_pkt.cc} +55 -87
- data/third_party/boringssl/ssl/{d1_srtp.c → d1_srtp.cc} +12 -16
- data/third_party/boringssl/ssl/{dtls_method.c → dtls_method.cc} +33 -50
- data/third_party/boringssl/ssl/{dtls_record.c → dtls_record.cc} +76 -64
- data/third_party/boringssl/ssl/handshake.cc +547 -0
- data/third_party/boringssl/ssl/handshake_client.cc +1828 -0
- data/third_party/boringssl/ssl/handshake_server.cc +1672 -0
- data/third_party/boringssl/ssl/internal.h +2027 -1280
- data/third_party/boringssl/ssl/s3_both.cc +603 -0
- data/third_party/boringssl/ssl/{s3_lib.c → s3_lib.cc} +22 -10
- data/third_party/boringssl/ssl/{s3_pkt.c → s3_pkt.cc} +171 -75
- data/third_party/boringssl/ssl/ssl_aead_ctx.cc +415 -0
- data/third_party/boringssl/ssl/{ssl_asn1.c → ssl_asn1.cc} +257 -261
- data/third_party/boringssl/ssl/{ssl_buffer.c → ssl_buffer.cc} +81 -97
- data/third_party/boringssl/ssl/{ssl_cert.c → ssl_cert.cc} +304 -414
- data/third_party/boringssl/ssl/{ssl_cipher.c → ssl_cipher.cc} +427 -505
- data/third_party/boringssl/ssl/{ssl_file.c → ssl_file.cc} +24 -16
- data/third_party/boringssl/ssl/ssl_key_share.cc +245 -0
- data/third_party/boringssl/ssl/{ssl_lib.c → ssl_lib.cc} +665 -828
- data/third_party/boringssl/ssl/ssl_privkey.cc +518 -0
- data/third_party/boringssl/ssl/{ssl_session.c → ssl_session.cc} +596 -471
- data/third_party/boringssl/ssl/{ssl_stat.c → ssl_stat.cc} +5 -224
- data/third_party/boringssl/ssl/{ssl_transcript.c → ssl_transcript.cc} +117 -140
- data/third_party/boringssl/ssl/ssl_versions.cc +439 -0
- data/third_party/boringssl/ssl/{ssl_x509.c → ssl_x509.cc} +751 -267
- data/third_party/boringssl/ssl/{t1_enc.c → t1_enc.cc} +120 -161
- data/third_party/boringssl/ssl/{t1_lib.c → t1_lib.cc} +859 -966
- data/third_party/boringssl/ssl/{tls13_both.c → tls13_both.cc} +202 -284
- data/third_party/boringssl/ssl/tls13_client.cc +842 -0
- data/third_party/boringssl/ssl/{tls13_enc.c → tls13_enc.cc} +108 -90
- data/third_party/boringssl/ssl/tls13_server.cc +967 -0
- data/third_party/boringssl/ssl/{tls_method.c → tls_method.cc} +94 -73
- data/third_party/boringssl/ssl/tls_record.cc +675 -0
- metadata +117 -168
- data/include/grpc/support/cmdline.h +0 -88
- data/include/grpc/support/subprocess.h +0 -44
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -29
- data/src/core/ext/filters/client_channel/resolver_factory.cc +0 -40
- data/src/core/lib/gpr/cmdline.cc +0 -330
- data/src/core/lib/gpr/subprocess_posix.cc +0 -99
- data/src/core/lib/gpr/subprocess_windows.cc +0 -126
- data/src/core/lib/surface/alarm.cc +0 -137
- data/src/core/lib/surface/alarm_internal.h +0 -40
- data/src/core/tsi/gts_transport_security.cc +0 -40
- data/third_party/boringssl/crypto/aes/aes.c +0 -1142
- data/third_party/boringssl/crypto/aes/internal.h +0 -87
- data/third_party/boringssl/crypto/aes/key_wrap.c +0 -138
- data/third_party/boringssl/crypto/aes/mode_wrappers.c +0 -112
- data/third_party/boringssl/crypto/asn1/x_long.c +0 -200
- data/third_party/boringssl/crypto/bn/add.c +0 -377
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +0 -532
- data/third_party/boringssl/crypto/bn/bn.c +0 -365
- data/third_party/boringssl/crypto/bn/cmp.c +0 -239
- data/third_party/boringssl/crypto/bn/ctx.c +0 -313
- data/third_party/boringssl/crypto/bn/div.c +0 -728
- data/third_party/boringssl/crypto/bn/exponentiation.c +0 -1240
- data/third_party/boringssl/crypto/bn/gcd.c +0 -635
- data/third_party/boringssl/crypto/bn/generic.c +0 -707
- data/third_party/boringssl/crypto/bn/kronecker.c +0 -176
- data/third_party/boringssl/crypto/bn/montgomery.c +0 -409
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +0 -207
- data/third_party/boringssl/crypto/bn/mul.c +0 -871
- data/third_party/boringssl/crypto/bn/prime.c +0 -861
- data/third_party/boringssl/crypto/bn/random.c +0 -343
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -254
- data/third_party/boringssl/crypto/bn/shift.c +0 -307
- data/third_party/boringssl/crypto/bn/sqrt.c +0 -506
- data/third_party/boringssl/crypto/cipher/aead.c +0 -156
- data/third_party/boringssl/crypto/cipher/cipher.c +0 -657
- data/third_party/boringssl/crypto/cipher/e_aes.c +0 -1771
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +0 -276
- data/third_party/boringssl/crypto/cipher/e_des.c +0 -205
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +0 -482
- data/third_party/boringssl/crypto/des/des.c +0 -771
- data/third_party/boringssl/crypto/digest/digest.c +0 -251
- data/third_party/boringssl/crypto/digest/digests.c +0 -358
- data/third_party/boringssl/crypto/ec/ec.c +0 -847
- data/third_party/boringssl/crypto/ec/ec_key.c +0 -479
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +0 -303
- data/third_party/boringssl/crypto/ec/oct.c +0 -416
- data/third_party/boringssl/crypto/ec/p224-64.c +0 -1143
- data/third_party/boringssl/crypto/ec/p256-64.c +0 -1701
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +0 -561
- data/third_party/boringssl/crypto/ec/simple.c +0 -1118
- data/third_party/boringssl/crypto/ec/util-64.c +0 -109
- data/third_party/boringssl/crypto/ec/wnaf.c +0 -458
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +0 -479
- data/third_party/boringssl/crypto/hmac/hmac.c +0 -215
- data/third_party/boringssl/crypto/md4/md4.c +0 -236
- data/third_party/boringssl/crypto/md5/md5.c +0 -285
- data/third_party/boringssl/crypto/modes/cbc.c +0 -212
- data/third_party/boringssl/crypto/modes/cfb.c +0 -230
- data/third_party/boringssl/crypto/modes/ctr.c +0 -219
- data/third_party/boringssl/crypto/modes/gcm.c +0 -1071
- data/third_party/boringssl/crypto/modes/ofb.c +0 -95
- data/third_party/boringssl/crypto/modes/polyval.c +0 -94
- data/third_party/boringssl/crypto/pkcs8/p8_pkey.c +0 -85
- data/third_party/boringssl/crypto/rand/rand.c +0 -244
- data/third_party/boringssl/crypto/rand/urandom.c +0 -335
- data/third_party/boringssl/crypto/rsa/blinding.c +0 -265
- data/third_party/boringssl/crypto/rsa/padding.c +0 -708
- data/third_party/boringssl/crypto/rsa/rsa.c +0 -830
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +0 -1100
- data/third_party/boringssl/crypto/sha/sha1-altivec.c +0 -346
- data/third_party/boringssl/crypto/sha/sha1.c +0 -355
- data/third_party/boringssl/crypto/sha/sha256.c +0 -329
- data/third_party/boringssl/crypto/sha/sha512.c +0 -609
- data/third_party/boringssl/crypto/x509/x509type.c +0 -126
- data/third_party/boringssl/include/openssl/stack_macros.h +0 -3987
- data/third_party/boringssl/ssl/handshake_client.c +0 -1883
- data/third_party/boringssl/ssl/handshake_server.c +0 -1950
- data/third_party/boringssl/ssl/s3_both.c +0 -895
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +0 -335
- data/third_party/boringssl/ssl/ssl_ecdh.c +0 -465
- data/third_party/boringssl/ssl/ssl_privkey.c +0 -683
- data/third_party/boringssl/ssl/ssl_privkey_cc.cc +0 -76
- data/third_party/boringssl/ssl/tls13_client.c +0 -712
- data/third_party/boringssl/ssl/tls13_server.c +0 -680
- data/third_party/boringssl/ssl/tls_record.c +0 -556
@@ -17,6 +17,8 @@
|
|
17
17
|
#include <assert.h>
|
18
18
|
#include <string.h>
|
19
19
|
|
20
|
+
#include <utility>
|
21
|
+
|
20
22
|
#include <openssl/aead.h>
|
21
23
|
#include <openssl/bytestring.h>
|
22
24
|
#include <openssl/digest.h>
|
@@ -28,27 +30,41 @@
|
|
28
30
|
#include "internal.h"
|
29
31
|
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
namespace bssl {
|
34
|
+
|
35
|
+
static int init_key_schedule(SSL_HANDSHAKE *hs, uint16_t version,
|
36
|
+
const SSL_CIPHER *cipher) {
|
37
|
+
if (!hs->transcript.InitHash(version, cipher)) {
|
34
38
|
return 0;
|
35
39
|
}
|
36
40
|
|
41
|
+
hs->hash_len = hs->transcript.DigestLen();
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
/* Initialize the secret to the zero key. */
|
43
|
+
// Initialize the secret to the zero key.
|
41
44
|
OPENSSL_memset(hs->secret, 0, hs->hash_len);
|
42
45
|
|
43
|
-
SSL_TRANSCRIPT_free_buffer(&hs->transcript);
|
44
46
|
return 1;
|
45
47
|
}
|
46
48
|
|
49
|
+
int tls13_init_key_schedule(SSL_HANDSHAKE *hs) {
|
50
|
+
if (!init_key_schedule(hs, ssl3_protocol_version(hs->ssl), hs->new_cipher)) {
|
51
|
+
return 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
hs->transcript.FreeBuffer();
|
55
|
+
return 1;
|
56
|
+
}
|
57
|
+
|
58
|
+
int tls13_init_early_key_schedule(SSL_HANDSHAKE *hs) {
|
59
|
+
SSL *const ssl = hs->ssl;
|
60
|
+
return init_key_schedule(hs, ssl_session_protocol_version(ssl->session),
|
61
|
+
ssl->session->cipher);
|
62
|
+
}
|
63
|
+
|
47
64
|
int tls13_advance_key_schedule(SSL_HANDSHAKE *hs, const uint8_t *in,
|
48
65
|
size_t len) {
|
49
|
-
return HKDF_extract(hs->secret, &hs->hash_len,
|
50
|
-
|
51
|
-
hs->hash_len);
|
66
|
+
return HKDF_extract(hs->secret, &hs->hash_len, hs->transcript.Digest(), in,
|
67
|
+
len, hs->secret, hs->hash_len);
|
52
68
|
}
|
53
69
|
|
54
70
|
static int hkdf_expand_label(uint8_t *out, const EVP_MD *digest,
|
@@ -57,20 +73,20 @@ static int hkdf_expand_label(uint8_t *out, const EVP_MD *digest,
|
|
57
73
|
const uint8_t *hash, size_t hash_len, size_t len) {
|
58
74
|
static const char kTLS13LabelVersion[] = "TLS 1.3, ";
|
59
75
|
|
60
|
-
|
76
|
+
ScopedCBB cbb;
|
77
|
+
CBB child;
|
61
78
|
uint8_t *hkdf_label;
|
62
79
|
size_t hkdf_label_len;
|
63
|
-
if (!CBB_init(
|
64
|
-
|
65
|
-
!CBB_add_u16(
|
66
|
-
!CBB_add_u8_length_prefixed(
|
80
|
+
if (!CBB_init(cbb.get(), 2 + 1 + strlen(kTLS13LabelVersion) + label_len + 1 +
|
81
|
+
hash_len) ||
|
82
|
+
!CBB_add_u16(cbb.get(), len) ||
|
83
|
+
!CBB_add_u8_length_prefixed(cbb.get(), &child) ||
|
67
84
|
!CBB_add_bytes(&child, (const uint8_t *)kTLS13LabelVersion,
|
68
85
|
strlen(kTLS13LabelVersion)) ||
|
69
86
|
!CBB_add_bytes(&child, label, label_len) ||
|
70
|
-
!CBB_add_u8_length_prefixed(
|
87
|
+
!CBB_add_u8_length_prefixed(cbb.get(), &child) ||
|
71
88
|
!CBB_add_bytes(&child, hash, hash_len) ||
|
72
|
-
!CBB_finish(
|
73
|
-
CBB_cleanup(&cbb);
|
89
|
+
!CBB_finish(cbb.get(), &hkdf_label, &hkdf_label_len)) {
|
74
90
|
return 0;
|
75
91
|
}
|
76
92
|
|
@@ -80,19 +96,18 @@ static int hkdf_expand_label(uint8_t *out, const EVP_MD *digest,
|
|
80
96
|
return ret;
|
81
97
|
}
|
82
98
|
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
// derive_secret derives a secret of length |len| and writes the result in |out|
|
100
|
+
// with the given label and the current base secret and most recently-saved
|
101
|
+
// handshake context. It returns one on success and zero on error.
|
86
102
|
static int derive_secret(SSL_HANDSHAKE *hs, uint8_t *out, size_t len,
|
87
103
|
const uint8_t *label, size_t label_len) {
|
88
104
|
uint8_t context_hash[EVP_MAX_MD_SIZE];
|
89
105
|
size_t context_hash_len;
|
90
|
-
if (!
|
91
|
-
&context_hash_len)) {
|
106
|
+
if (!hs->transcript.GetHash(context_hash, &context_hash_len)) {
|
92
107
|
return 0;
|
93
108
|
}
|
94
109
|
|
95
|
-
return hkdf_expand_label(out,
|
110
|
+
return hkdf_expand_label(out, hs->transcript.Digest(), hs->secret,
|
96
111
|
hs->hash_len, label, label_len, context_hash,
|
97
112
|
context_hash_len, len);
|
98
113
|
}
|
@@ -100,24 +115,25 @@ static int derive_secret(SSL_HANDSHAKE *hs, uint8_t *out, size_t len,
|
|
100
115
|
int tls13_set_traffic_key(SSL *ssl, enum evp_aead_direction_t direction,
|
101
116
|
const uint8_t *traffic_secret,
|
102
117
|
size_t traffic_secret_len) {
|
118
|
+
const SSL_SESSION *session = SSL_get_session(ssl);
|
119
|
+
uint16_t version = ssl_session_protocol_version(session);
|
120
|
+
|
103
121
|
if (traffic_secret_len > 0xff) {
|
104
122
|
OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
|
105
123
|
return 0;
|
106
124
|
}
|
107
125
|
|
108
|
-
|
126
|
+
// Look up cipher suite properties.
|
109
127
|
const EVP_AEAD *aead;
|
110
128
|
size_t discard;
|
111
|
-
if (!ssl_cipher_get_evp_aead(&aead, &discard, &discard,
|
112
|
-
|
113
|
-
ssl3_protocol_version(ssl))) {
|
129
|
+
if (!ssl_cipher_get_evp_aead(&aead, &discard, &discard, session->cipher,
|
130
|
+
version, SSL_is_dtls(ssl))) {
|
114
131
|
return 0;
|
115
132
|
}
|
116
133
|
|
117
|
-
const EVP_MD *digest =
|
118
|
-
SSL_get_session(ssl)->cipher->algorithm_prf, ssl3_protocol_version(ssl));
|
134
|
+
const EVP_MD *digest = ssl_session_get_digest(session);
|
119
135
|
|
120
|
-
|
136
|
+
// Derive the key.
|
121
137
|
size_t key_len = EVP_AEAD_key_length(aead);
|
122
138
|
uint8_t key[EVP_AEAD_MAX_KEY_LENGTH];
|
123
139
|
if (!hkdf_expand_label(key, digest, traffic_secret, traffic_secret_len,
|
@@ -125,7 +141,7 @@ int tls13_set_traffic_key(SSL *ssl, enum evp_aead_direction_t direction,
|
|
125
141
|
return 0;
|
126
142
|
}
|
127
143
|
|
128
|
-
|
144
|
+
// Derive the IV.
|
129
145
|
size_t iv_len = EVP_AEAD_nonce_length(aead);
|
130
146
|
uint8_t iv[EVP_AEAD_MAX_NONCE_LENGTH];
|
131
147
|
if (!hkdf_expand_label(iv, digest, traffic_secret, traffic_secret_len,
|
@@ -133,24 +149,25 @@ int tls13_set_traffic_key(SSL *ssl, enum evp_aead_direction_t direction,
|
|
133
149
|
return 0;
|
134
150
|
}
|
135
151
|
|
136
|
-
|
137
|
-
direction,
|
138
|
-
|
139
|
-
|
152
|
+
UniquePtr<SSLAEADContext> traffic_aead =
|
153
|
+
SSLAEADContext::Create(direction, session->ssl_version, SSL_is_dtls(ssl),
|
154
|
+
session->cipher, MakeConstSpan(key, key_len),
|
155
|
+
Span<const uint8_t>(), MakeConstSpan(iv, iv_len));
|
156
|
+
if (!traffic_aead) {
|
140
157
|
return 0;
|
141
158
|
}
|
142
159
|
|
143
160
|
if (direction == evp_aead_open) {
|
144
|
-
if (!ssl->method->set_read_state(ssl, traffic_aead)) {
|
161
|
+
if (!ssl->method->set_read_state(ssl, std::move(traffic_aead))) {
|
145
162
|
return 0;
|
146
163
|
}
|
147
164
|
} else {
|
148
|
-
if (!ssl->method->set_write_state(ssl, traffic_aead)) {
|
165
|
+
if (!ssl->method->set_write_state(ssl, std::move(traffic_aead))) {
|
149
166
|
return 0;
|
150
167
|
}
|
151
168
|
}
|
152
169
|
|
153
|
-
|
170
|
+
// Save the traffic secret.
|
154
171
|
if (direction == evp_aead_open) {
|
155
172
|
OPENSSL_memmove(ssl->s3->read_traffic_secret, traffic_secret,
|
156
173
|
traffic_secret_len);
|
@@ -164,6 +181,11 @@ int tls13_set_traffic_key(SSL *ssl, enum evp_aead_direction_t direction,
|
|
164
181
|
return 1;
|
165
182
|
}
|
166
183
|
|
184
|
+
static const char kTLS13LabelExporter[] = "exporter master secret";
|
185
|
+
static const char kTLS13LabelEarlyExporter[] = "early exporter master secret";
|
186
|
+
|
187
|
+
static const char kTLS13LabelClientEarlyTraffic[] =
|
188
|
+
"client early traffic secret";
|
167
189
|
static const char kTLS13LabelClientHandshakeTraffic[] =
|
168
190
|
"client handshake traffic secret";
|
169
191
|
static const char kTLS13LabelServerHandshakeTraffic[] =
|
@@ -173,6 +195,18 @@ static const char kTLS13LabelClientApplicationTraffic[] =
|
|
173
195
|
static const char kTLS13LabelServerApplicationTraffic[] =
|
174
196
|
"server application traffic secret";
|
175
197
|
|
198
|
+
int tls13_derive_early_secrets(SSL_HANDSHAKE *hs) {
|
199
|
+
SSL *const ssl = hs->ssl;
|
200
|
+
return derive_secret(hs, hs->early_traffic_secret, hs->hash_len,
|
201
|
+
(const uint8_t *)kTLS13LabelClientEarlyTraffic,
|
202
|
+
strlen(kTLS13LabelClientEarlyTraffic)) &&
|
203
|
+
ssl_log_secret(ssl, "CLIENT_EARLY_TRAFFIC_SECRET",
|
204
|
+
hs->early_traffic_secret, hs->hash_len) &&
|
205
|
+
derive_secret(hs, ssl->s3->early_exporter_secret, hs->hash_len,
|
206
|
+
(const uint8_t *)kTLS13LabelEarlyExporter,
|
207
|
+
strlen(kTLS13LabelEarlyExporter));
|
208
|
+
}
|
209
|
+
|
176
210
|
int tls13_derive_handshake_secrets(SSL_HANDSHAKE *hs) {
|
177
211
|
SSL *const ssl = hs->ssl;
|
178
212
|
return derive_secret(hs, hs->client_handshake_secret, hs->hash_len,
|
@@ -187,8 +221,6 @@ int tls13_derive_handshake_secrets(SSL_HANDSHAKE *hs) {
|
|
187
221
|
hs->server_handshake_secret, hs->hash_len);
|
188
222
|
}
|
189
223
|
|
190
|
-
static const char kTLS13LabelExporter[] = "exporter master secret";
|
191
|
-
|
192
224
|
int tls13_derive_application_secrets(SSL_HANDSHAKE *hs) {
|
193
225
|
SSL *const ssl = hs->ssl;
|
194
226
|
ssl->s3->exporter_secret_len = hs->hash_len;
|
@@ -204,16 +236,15 @@ int tls13_derive_application_secrets(SSL_HANDSHAKE *hs) {
|
|
204
236
|
hs->server_traffic_secret_0, hs->hash_len) &&
|
205
237
|
derive_secret(hs, ssl->s3->exporter_secret, hs->hash_len,
|
206
238
|
(const uint8_t *)kTLS13LabelExporter,
|
207
|
-
strlen(kTLS13LabelExporter))
|
239
|
+
strlen(kTLS13LabelExporter)) &&
|
240
|
+
ssl_log_secret(ssl, "EXPORTER_SECRET", ssl->s3->exporter_secret,
|
241
|
+
hs->hash_len);
|
208
242
|
}
|
209
243
|
|
210
244
|
static const char kTLS13LabelApplicationTraffic[] =
|
211
245
|
"application traffic secret";
|
212
246
|
|
213
247
|
int tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction) {
|
214
|
-
const EVP_MD *digest = ssl_get_handshake_digest(
|
215
|
-
SSL_get_session(ssl)->cipher->algorithm_prf, ssl3_protocol_version(ssl));
|
216
|
-
|
217
248
|
uint8_t *secret;
|
218
249
|
size_t secret_len;
|
219
250
|
if (direction == evp_aead_open) {
|
@@ -224,6 +255,7 @@ int tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction) {
|
|
224
255
|
secret_len = ssl->s3->write_traffic_secret_len;
|
225
256
|
}
|
226
257
|
|
258
|
+
const EVP_MD *digest = ssl_session_get_digest(SSL_get_session(ssl));
|
227
259
|
if (!hkdf_expand_label(secret, digest, secret, secret_len,
|
228
260
|
(const uint8_t *)kTLS13LabelApplicationTraffic,
|
229
261
|
strlen(kTLS13LabelApplicationTraffic), NULL, 0,
|
@@ -250,8 +282,8 @@ int tls13_derive_resumption_secret(SSL_HANDSHAKE *hs) {
|
|
250
282
|
|
251
283
|
static const char kTLS13LabelFinished[] = "finished";
|
252
284
|
|
253
|
-
|
254
|
-
|
285
|
+
// tls13_verify_data sets |out| to be the HMAC of |context| using a derived
|
286
|
+
// Finished key for both Finished messages and the PSK binder.
|
255
287
|
static int tls13_verify_data(const EVP_MD *digest, uint8_t *out,
|
256
288
|
size_t *out_len, const uint8_t *secret,
|
257
289
|
size_t hash_len, uint8_t *context,
|
@@ -270,22 +302,18 @@ static int tls13_verify_data(const EVP_MD *digest, uint8_t *out,
|
|
270
302
|
|
271
303
|
int tls13_finished_mac(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len,
|
272
304
|
int is_server) {
|
273
|
-
SSL *const ssl = hs->ssl;
|
274
|
-
|
275
305
|
const uint8_t *traffic_secret;
|
276
|
-
if (is_server
|
277
|
-
traffic_secret =
|
306
|
+
if (is_server) {
|
307
|
+
traffic_secret = hs->server_handshake_secret;
|
278
308
|
} else {
|
279
|
-
traffic_secret =
|
309
|
+
traffic_secret = hs->client_handshake_secret;
|
280
310
|
}
|
281
311
|
|
282
312
|
uint8_t context_hash[EVP_MAX_MD_SIZE];
|
283
313
|
size_t context_hash_len;
|
284
|
-
if (!
|
285
|
-
|
286
|
-
|
287
|
-
traffic_secret, hs->hash_len, context_hash,
|
288
|
-
context_hash_len)) {
|
314
|
+
if (!hs->transcript.GetHash(context_hash, &context_hash_len) ||
|
315
|
+
!tls13_verify_data(hs->transcript.Digest(), out, out_len, traffic_secret,
|
316
|
+
hs->hash_len, context_hash, context_hash_len)) {
|
289
317
|
return 0;
|
290
318
|
}
|
291
319
|
return 1;
|
@@ -295,15 +323,14 @@ int tls13_export_keying_material(SSL *ssl, uint8_t *out, size_t out_len,
|
|
295
323
|
const char *label, size_t label_len,
|
296
324
|
const uint8_t *context, size_t context_len,
|
297
325
|
int use_context) {
|
298
|
-
const EVP_MD *digest = ssl_get_handshake_digest(
|
299
|
-
SSL_get_session(ssl)->cipher->algorithm_prf, ssl3_protocol_version(ssl));
|
300
|
-
|
301
326
|
const uint8_t *hash = NULL;
|
302
327
|
size_t hash_len = 0;
|
303
328
|
if (use_context) {
|
304
329
|
hash = context;
|
305
330
|
hash_len = context_len;
|
306
331
|
}
|
332
|
+
|
333
|
+
const EVP_MD *digest = ssl_session_get_digest(SSL_get_session(ssl));
|
307
334
|
return hkdf_expand_label(out, digest, ssl->s3->exporter_secret,
|
308
335
|
ssl->s3->exporter_secret_len, (const uint8_t *)label,
|
309
336
|
label_len, hash, hash_len, out_len);
|
@@ -343,11 +370,7 @@ static int tls13_psk_binder(uint8_t *out, const EVP_MD *digest, uint8_t *psk,
|
|
343
370
|
|
344
371
|
int tls13_write_psk_binder(SSL_HANDSHAKE *hs, uint8_t *msg, size_t len) {
|
345
372
|
SSL *const ssl = hs->ssl;
|
346
|
-
const EVP_MD *digest =
|
347
|
-
if (digest == NULL) {
|
348
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
349
|
-
return 0;
|
350
|
-
}
|
373
|
+
const EVP_MD *digest = ssl_session_get_digest(ssl->session);
|
351
374
|
size_t hash_len = EVP_MD_size(digest);
|
352
375
|
|
353
376
|
if (len < hash_len + 3) {
|
@@ -355,21 +378,17 @@ int tls13_write_psk_binder(SSL_HANDSHAKE *hs, uint8_t *msg, size_t len) {
|
|
355
378
|
return 0;
|
356
379
|
}
|
357
380
|
|
358
|
-
|
359
|
-
EVP_MD_CTX_init(&ctx);
|
381
|
+
ScopedEVP_MD_CTX ctx;
|
360
382
|
uint8_t context[EVP_MAX_MD_SIZE];
|
361
383
|
unsigned context_len;
|
362
|
-
if (!EVP_DigestInit_ex(
|
363
|
-
!EVP_DigestUpdate(
|
364
|
-
hs->transcript.
|
365
|
-
!EVP_DigestUpdate(
|
366
|
-
!EVP_DigestFinal_ex(
|
367
|
-
EVP_MD_CTX_cleanup(&ctx);
|
384
|
+
if (!EVP_DigestInit_ex(ctx.get(), digest, NULL) ||
|
385
|
+
!EVP_DigestUpdate(ctx.get(), hs->transcript.buffer_data(),
|
386
|
+
hs->transcript.buffer_len()) ||
|
387
|
+
!EVP_DigestUpdate(ctx.get(), msg, len - hash_len - 3) ||
|
388
|
+
!EVP_DigestFinal_ex(ctx.get(), context, &context_len)) {
|
368
389
|
return 0;
|
369
390
|
}
|
370
391
|
|
371
|
-
EVP_MD_CTX_cleanup(&ctx);
|
372
|
-
|
373
392
|
uint8_t verify_data[EVP_MAX_MD_SIZE] = {0};
|
374
393
|
if (!tls13_psk_binder(verify_data, digest, ssl->session->master_key,
|
375
394
|
ssl->session->master_key_length, context, context_len,
|
@@ -382,34 +401,31 @@ int tls13_write_psk_binder(SSL_HANDSHAKE *hs, uint8_t *msg, size_t len) {
|
|
382
401
|
}
|
383
402
|
|
384
403
|
int tls13_verify_psk_binder(SSL_HANDSHAKE *hs, SSL_SESSION *session,
|
385
|
-
CBS *binders) {
|
386
|
-
size_t hash_len =
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
CBS message;
|
391
|
-
hs->ssl->method->get_current_message(hs->ssl, &message);
|
392
|
-
if (CBS_len(&message) < CBS_len(binders) + 2) {
|
404
|
+
const SSLMessage &msg, CBS *binders) {
|
405
|
+
size_t hash_len = hs->transcript.DigestLen();
|
406
|
+
|
407
|
+
// The message must be large enough to exclude the binders.
|
408
|
+
if (CBS_len(&msg.raw) < CBS_len(binders) + 2) {
|
393
409
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
394
410
|
return 0;
|
395
411
|
}
|
396
412
|
|
397
|
-
|
398
|
-
|
413
|
+
// Hash a ClientHello prefix up to the binders. This includes the header. For
|
414
|
+
// now, this assumes we only ever verify PSK binders on initial
|
415
|
+
// ClientHellos.
|
399
416
|
uint8_t context[EVP_MAX_MD_SIZE];
|
400
417
|
unsigned context_len;
|
401
|
-
if (!EVP_Digest(CBS_data(&
|
402
|
-
context, &context_len,
|
403
|
-
NULL)) {
|
418
|
+
if (!EVP_Digest(CBS_data(&msg.raw), CBS_len(&msg.raw) - CBS_len(binders) - 2,
|
419
|
+
context, &context_len, hs->transcript.Digest(), NULL)) {
|
404
420
|
return 0;
|
405
421
|
}
|
406
422
|
|
407
423
|
uint8_t verify_data[EVP_MAX_MD_SIZE] = {0};
|
408
424
|
CBS binder;
|
409
|
-
if (!tls13_psk_binder(verify_data,
|
425
|
+
if (!tls13_psk_binder(verify_data, hs->transcript.Digest(),
|
410
426
|
session->master_key, session->master_key_length,
|
411
427
|
context, context_len, hash_len) ||
|
412
|
-
|
428
|
+
// We only consider the first PSK, so compare against the first binder.
|
413
429
|
!CBS_get_u8_length_prefixed(binders, &binder)) {
|
414
430
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
415
431
|
return 0;
|
@@ -428,3 +444,5 @@ int tls13_verify_psk_binder(SSL_HANDSHAKE *hs, SSL_SESSION *session,
|
|
428
444
|
|
429
445
|
return 1;
|
430
446
|
}
|
447
|
+
|
448
|
+
} // namespace bssl
|
@@ -0,0 +1,967 @@
|
|
1
|
+
/* Copyright (c) 2016, Google Inc.
|
2
|
+
*
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
6
|
+
*
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
+
|
15
|
+
// Per C99, various stdint.h macros are unavailable in C++ unless some macros
|
16
|
+
// are defined. C++11 overruled this decision, but older Android NDKs still
|
17
|
+
// require it.
|
18
|
+
#if !defined(__STDC_LIMIT_MACROS)
|
19
|
+
#define __STDC_LIMIT_MACROS
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#include <openssl/ssl.h>
|
23
|
+
|
24
|
+
#include <assert.h>
|
25
|
+
#include <string.h>
|
26
|
+
|
27
|
+
#include <openssl/aead.h>
|
28
|
+
#include <openssl/bytestring.h>
|
29
|
+
#include <openssl/digest.h>
|
30
|
+
#include <openssl/err.h>
|
31
|
+
#include <openssl/mem.h>
|
32
|
+
#include <openssl/rand.h>
|
33
|
+
#include <openssl/stack.h>
|
34
|
+
|
35
|
+
#include "../crypto/internal.h"
|
36
|
+
#include "internal.h"
|
37
|
+
|
38
|
+
|
39
|
+
namespace bssl {
|
40
|
+
|
41
|
+
enum server_hs_state_t {
|
42
|
+
state_select_parameters = 0,
|
43
|
+
state_select_session,
|
44
|
+
state_send_hello_retry_request,
|
45
|
+
state_read_second_client_hello,
|
46
|
+
state_send_server_hello,
|
47
|
+
state_send_server_certificate_verify,
|
48
|
+
state_send_server_finished,
|
49
|
+
state_read_second_client_flight,
|
50
|
+
state_process_change_cipher_spec,
|
51
|
+
state_process_end_of_early_data,
|
52
|
+
state_read_client_certificate,
|
53
|
+
state_read_client_certificate_verify,
|
54
|
+
state_read_channel_id,
|
55
|
+
state_read_client_finished,
|
56
|
+
state_send_new_session_ticket,
|
57
|
+
state_done,
|
58
|
+
};
|
59
|
+
|
60
|
+
static const uint8_t kZeroes[EVP_MAX_MD_SIZE] = {0};
|
61
|
+
|
62
|
+
static int resolve_ecdhe_secret(SSL_HANDSHAKE *hs, bool *out_need_retry,
|
63
|
+
SSL_CLIENT_HELLO *client_hello) {
|
64
|
+
SSL *const ssl = hs->ssl;
|
65
|
+
*out_need_retry = false;
|
66
|
+
|
67
|
+
// We only support connections that include an ECDHE key exchange.
|
68
|
+
CBS key_share;
|
69
|
+
if (!ssl_client_hello_get_extension(client_hello, &key_share,
|
70
|
+
TLSEXT_TYPE_key_share)) {
|
71
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_KEY_SHARE);
|
72
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_MISSING_EXTENSION);
|
73
|
+
return 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
bool found_key_share;
|
77
|
+
Array<uint8_t> dhe_secret;
|
78
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
79
|
+
if (!ssl_ext_key_share_parse_clienthello(hs, &found_key_share, &dhe_secret,
|
80
|
+
&alert, &key_share)) {
|
81
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
|
82
|
+
return 0;
|
83
|
+
}
|
84
|
+
|
85
|
+
if (!found_key_share) {
|
86
|
+
*out_need_retry = true;
|
87
|
+
return 0;
|
88
|
+
}
|
89
|
+
|
90
|
+
return tls13_advance_key_schedule(hs, dhe_secret.data(), dhe_secret.size());
|
91
|
+
}
|
92
|
+
|
93
|
+
static int ssl_ext_supported_versions_add_serverhello(SSL_HANDSHAKE *hs,
|
94
|
+
CBB *out) {
|
95
|
+
CBB contents;
|
96
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_supported_versions) ||
|
97
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
98
|
+
!CBB_add_u16(&contents, hs->ssl->version) ||
|
99
|
+
!CBB_flush(out)) {
|
100
|
+
return 0;
|
101
|
+
}
|
102
|
+
|
103
|
+
return 1;
|
104
|
+
}
|
105
|
+
|
106
|
+
static const SSL_CIPHER *choose_tls13_cipher(
|
107
|
+
const SSL *ssl, const SSL_CLIENT_HELLO *client_hello) {
|
108
|
+
if (client_hello->cipher_suites_len % 2 != 0) {
|
109
|
+
return NULL;
|
110
|
+
}
|
111
|
+
|
112
|
+
CBS cipher_suites;
|
113
|
+
CBS_init(&cipher_suites, client_hello->cipher_suites,
|
114
|
+
client_hello->cipher_suites_len);
|
115
|
+
|
116
|
+
const int aes_is_fine = EVP_has_aes_hardware();
|
117
|
+
const uint16_t version = ssl3_protocol_version(ssl);
|
118
|
+
|
119
|
+
const SSL_CIPHER *best = NULL;
|
120
|
+
while (CBS_len(&cipher_suites) > 0) {
|
121
|
+
uint16_t cipher_suite;
|
122
|
+
if (!CBS_get_u16(&cipher_suites, &cipher_suite)) {
|
123
|
+
return NULL;
|
124
|
+
}
|
125
|
+
|
126
|
+
// Limit to TLS 1.3 ciphers we know about.
|
127
|
+
const SSL_CIPHER *candidate = SSL_get_cipher_by_value(cipher_suite);
|
128
|
+
if (candidate == NULL ||
|
129
|
+
SSL_CIPHER_get_min_version(candidate) > version ||
|
130
|
+
SSL_CIPHER_get_max_version(candidate) < version) {
|
131
|
+
continue;
|
132
|
+
}
|
133
|
+
|
134
|
+
// TLS 1.3 removes legacy ciphers, so honor the client order, but prefer
|
135
|
+
// ChaCha20 if we do not have AES hardware.
|
136
|
+
if (aes_is_fine) {
|
137
|
+
return candidate;
|
138
|
+
}
|
139
|
+
|
140
|
+
if (candidate->algorithm_enc == SSL_CHACHA20POLY1305) {
|
141
|
+
return candidate;
|
142
|
+
}
|
143
|
+
|
144
|
+
if (best == NULL) {
|
145
|
+
best = candidate;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
return best;
|
150
|
+
}
|
151
|
+
|
152
|
+
static int add_new_session_tickets(SSL_HANDSHAKE *hs) {
|
153
|
+
SSL *const ssl = hs->ssl;
|
154
|
+
// TLS 1.3 recommends single-use tickets, so issue multiple tickets in case
|
155
|
+
// the client makes several connections before getting a renewal.
|
156
|
+
static const int kNumTickets = 2;
|
157
|
+
|
158
|
+
// Rebase the session timestamp so that it is measured from ticket
|
159
|
+
// issuance.
|
160
|
+
ssl_session_rebase_time(ssl, hs->new_session.get());
|
161
|
+
|
162
|
+
for (int i = 0; i < kNumTickets; i++) {
|
163
|
+
if (!RAND_bytes((uint8_t *)&hs->new_session->ticket_age_add, 4)) {
|
164
|
+
return 0;
|
165
|
+
}
|
166
|
+
hs->new_session->ticket_age_add_valid = 1;
|
167
|
+
|
168
|
+
if (ssl->cert->enable_early_data) {
|
169
|
+
hs->new_session->ticket_max_early_data = kMaxEarlyDataAccepted;
|
170
|
+
}
|
171
|
+
|
172
|
+
ScopedCBB cbb;
|
173
|
+
CBB body, ticket, extensions;
|
174
|
+
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
175
|
+
SSL3_MT_NEW_SESSION_TICKET) ||
|
176
|
+
!CBB_add_u32(&body, hs->new_session->timeout) ||
|
177
|
+
!CBB_add_u32(&body, hs->new_session->ticket_age_add) ||
|
178
|
+
!CBB_add_u16_length_prefixed(&body, &ticket) ||
|
179
|
+
!ssl_encrypt_ticket(ssl, &ticket, hs->new_session.get()) ||
|
180
|
+
!CBB_add_u16_length_prefixed(&body, &extensions)) {
|
181
|
+
return 0;
|
182
|
+
}
|
183
|
+
|
184
|
+
if (ssl->cert->enable_early_data) {
|
185
|
+
CBB early_data_info;
|
186
|
+
if (!CBB_add_u16(&extensions, TLSEXT_TYPE_ticket_early_data_info) ||
|
187
|
+
!CBB_add_u16_length_prefixed(&extensions, &early_data_info) ||
|
188
|
+
!CBB_add_u32(&early_data_info,
|
189
|
+
hs->new_session->ticket_max_early_data) ||
|
190
|
+
!CBB_flush(&extensions)) {
|
191
|
+
return 0;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
// Add a fake extension. See draft-davidben-tls-grease-01.
|
196
|
+
if (!CBB_add_u16(&extensions,
|
197
|
+
ssl_get_grease_value(ssl, ssl_grease_ticket_extension)) ||
|
198
|
+
!CBB_add_u16(&extensions, 0 /* empty */)) {
|
199
|
+
return 0;
|
200
|
+
}
|
201
|
+
|
202
|
+
if (!ssl_add_message_cbb(ssl, cbb.get())) {
|
203
|
+
return 0;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
return 1;
|
208
|
+
}
|
209
|
+
|
210
|
+
static enum ssl_hs_wait_t do_select_parameters(SSL_HANDSHAKE *hs) {
|
211
|
+
// At this point, most ClientHello extensions have already been processed by
|
212
|
+
// the common handshake logic. Resolve the remaining non-PSK parameters.
|
213
|
+
SSL *const ssl = hs->ssl;
|
214
|
+
SSLMessage msg;
|
215
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
216
|
+
return ssl_hs_read_message;
|
217
|
+
}
|
218
|
+
SSL_CLIENT_HELLO client_hello;
|
219
|
+
if (!ssl_client_hello_init(ssl, &client_hello, msg)) {
|
220
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CLIENTHELLO_PARSE_FAILED);
|
221
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
222
|
+
return ssl_hs_error;
|
223
|
+
}
|
224
|
+
|
225
|
+
OPENSSL_memcpy(hs->session_id, client_hello.session_id,
|
226
|
+
client_hello.session_id_len);
|
227
|
+
hs->session_id_len = client_hello.session_id_len;
|
228
|
+
|
229
|
+
// Negotiate the cipher suite.
|
230
|
+
hs->new_cipher = choose_tls13_cipher(ssl, &client_hello);
|
231
|
+
if (hs->new_cipher == NULL) {
|
232
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_SHARED_CIPHER);
|
233
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
234
|
+
return ssl_hs_error;
|
235
|
+
}
|
236
|
+
|
237
|
+
// HTTP/2 negotiation depends on the cipher suite, so ALPN negotiation was
|
238
|
+
// deferred. Complete it now.
|
239
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
240
|
+
if (!ssl_negotiate_alpn(hs, &alert, &client_hello)) {
|
241
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
|
242
|
+
return ssl_hs_error;
|
243
|
+
}
|
244
|
+
|
245
|
+
// The PRF hash is now known. Set up the key schedule and hash the
|
246
|
+
// ClientHello.
|
247
|
+
if (!tls13_init_key_schedule(hs) ||
|
248
|
+
!ssl_hash_message(hs, msg)) {
|
249
|
+
return ssl_hs_error;
|
250
|
+
}
|
251
|
+
|
252
|
+
hs->tls13_state = state_select_session;
|
253
|
+
return ssl_hs_ok;
|
254
|
+
}
|
255
|
+
|
256
|
+
static enum ssl_ticket_aead_result_t select_session(
|
257
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert, UniquePtr<SSL_SESSION> *out_session,
|
258
|
+
int32_t *out_ticket_age_skew, const SSLMessage &msg,
|
259
|
+
const SSL_CLIENT_HELLO *client_hello) {
|
260
|
+
SSL *const ssl = hs->ssl;
|
261
|
+
*out_session = NULL;
|
262
|
+
|
263
|
+
// Decode the ticket if we agreed on a PSK key exchange mode.
|
264
|
+
CBS pre_shared_key;
|
265
|
+
if (!hs->accept_psk_mode ||
|
266
|
+
!ssl_client_hello_get_extension(client_hello, &pre_shared_key,
|
267
|
+
TLSEXT_TYPE_pre_shared_key)) {
|
268
|
+
return ssl_ticket_aead_ignore_ticket;
|
269
|
+
}
|
270
|
+
|
271
|
+
// Verify that the pre_shared_key extension is the last extension in
|
272
|
+
// ClientHello.
|
273
|
+
if (CBS_data(&pre_shared_key) + CBS_len(&pre_shared_key) !=
|
274
|
+
client_hello->extensions + client_hello->extensions_len) {
|
275
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_PRE_SHARED_KEY_MUST_BE_LAST);
|
276
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
277
|
+
return ssl_ticket_aead_error;
|
278
|
+
}
|
279
|
+
|
280
|
+
CBS ticket, binders;
|
281
|
+
uint32_t client_ticket_age;
|
282
|
+
if (!ssl_ext_pre_shared_key_parse_clienthello(hs, &ticket, &binders,
|
283
|
+
&client_ticket_age, out_alert,
|
284
|
+
&pre_shared_key)) {
|
285
|
+
return ssl_ticket_aead_error;
|
286
|
+
}
|
287
|
+
|
288
|
+
// TLS 1.3 session tickets are renewed separately as part of the
|
289
|
+
// NewSessionTicket.
|
290
|
+
bool unused_renew;
|
291
|
+
UniquePtr<SSL_SESSION> session;
|
292
|
+
enum ssl_ticket_aead_result_t ret =
|
293
|
+
ssl_process_ticket(ssl, &session, &unused_renew, CBS_data(&ticket),
|
294
|
+
CBS_len(&ticket), NULL, 0);
|
295
|
+
switch (ret) {
|
296
|
+
case ssl_ticket_aead_success:
|
297
|
+
break;
|
298
|
+
case ssl_ticket_aead_error:
|
299
|
+
*out_alert = SSL_AD_INTERNAL_ERROR;
|
300
|
+
return ret;
|
301
|
+
default:
|
302
|
+
return ret;
|
303
|
+
}
|
304
|
+
|
305
|
+
if (!ssl_session_is_resumable(hs, session.get()) ||
|
306
|
+
// Historically, some TLS 1.3 tickets were missing ticket_age_add.
|
307
|
+
!session->ticket_age_add_valid) {
|
308
|
+
return ssl_ticket_aead_ignore_ticket;
|
309
|
+
}
|
310
|
+
|
311
|
+
// Recover the client ticket age and convert to seconds.
|
312
|
+
client_ticket_age -= session->ticket_age_add;
|
313
|
+
client_ticket_age /= 1000;
|
314
|
+
|
315
|
+
struct OPENSSL_timeval now;
|
316
|
+
ssl_get_current_time(ssl, &now);
|
317
|
+
|
318
|
+
// Compute the server ticket age in seconds.
|
319
|
+
assert(now.tv_sec >= session->time);
|
320
|
+
uint64_t server_ticket_age = now.tv_sec - session->time;
|
321
|
+
|
322
|
+
// To avoid overflowing |hs->ticket_age_skew|, we will not resume
|
323
|
+
// 68-year-old sessions.
|
324
|
+
if (server_ticket_age > INT32_MAX) {
|
325
|
+
return ssl_ticket_aead_ignore_ticket;
|
326
|
+
}
|
327
|
+
|
328
|
+
// TODO(davidben,svaldez): Measure this value to decide on tolerance. For
|
329
|
+
// now, accept all values. https://crbug.com/boringssl/113.
|
330
|
+
*out_ticket_age_skew =
|
331
|
+
(int32_t)client_ticket_age - (int32_t)server_ticket_age;
|
332
|
+
|
333
|
+
// Check the PSK binder.
|
334
|
+
if (!tls13_verify_psk_binder(hs, session.get(), msg, &binders)) {
|
335
|
+
*out_alert = SSL_AD_DECRYPT_ERROR;
|
336
|
+
return ssl_ticket_aead_error;
|
337
|
+
}
|
338
|
+
|
339
|
+
*out_session = std::move(session);
|
340
|
+
return ssl_ticket_aead_success;
|
341
|
+
}
|
342
|
+
|
343
|
+
static enum ssl_hs_wait_t do_select_session(SSL_HANDSHAKE *hs) {
|
344
|
+
SSL *const ssl = hs->ssl;
|
345
|
+
SSLMessage msg;
|
346
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
347
|
+
return ssl_hs_read_message;
|
348
|
+
}
|
349
|
+
SSL_CLIENT_HELLO client_hello;
|
350
|
+
if (!ssl_client_hello_init(ssl, &client_hello, msg)) {
|
351
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CLIENTHELLO_PARSE_FAILED);
|
352
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
353
|
+
return ssl_hs_error;
|
354
|
+
}
|
355
|
+
|
356
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
357
|
+
UniquePtr<SSL_SESSION> session;
|
358
|
+
switch (select_session(hs, &alert, &session, &ssl->s3->ticket_age_skew, msg,
|
359
|
+
&client_hello)) {
|
360
|
+
case ssl_ticket_aead_ignore_ticket:
|
361
|
+
assert(!session);
|
362
|
+
if (!ssl_get_new_session(hs, 1 /* server */)) {
|
363
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
364
|
+
return ssl_hs_error;
|
365
|
+
}
|
366
|
+
break;
|
367
|
+
|
368
|
+
case ssl_ticket_aead_success:
|
369
|
+
// Carry over authentication information from the previous handshake into
|
370
|
+
// a fresh session.
|
371
|
+
hs->new_session =
|
372
|
+
SSL_SESSION_dup(session.get(), SSL_SESSION_DUP_AUTH_ONLY);
|
373
|
+
|
374
|
+
if (// Early data must be acceptable for this ticket.
|
375
|
+
ssl->cert->enable_early_data &&
|
376
|
+
session->ticket_max_early_data != 0 &&
|
377
|
+
// The client must have offered early data.
|
378
|
+
hs->early_data_offered &&
|
379
|
+
// Channel ID is incompatible with 0-RTT.
|
380
|
+
!ssl->s3->tlsext_channel_id_valid &&
|
381
|
+
// Custom extensions is incompatible with 0-RTT.
|
382
|
+
hs->custom_extensions.received == 0 &&
|
383
|
+
// The negotiated ALPN must match the one in the ticket.
|
384
|
+
ssl->s3->alpn_selected_len == session->early_alpn_len &&
|
385
|
+
OPENSSL_memcmp(ssl->s3->alpn_selected, session->early_alpn,
|
386
|
+
ssl->s3->alpn_selected_len) == 0) {
|
387
|
+
ssl->early_data_accepted = 1;
|
388
|
+
}
|
389
|
+
|
390
|
+
if (hs->new_session == NULL) {
|
391
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
392
|
+
return ssl_hs_error;
|
393
|
+
}
|
394
|
+
|
395
|
+
ssl->s3->session_reused = true;
|
396
|
+
|
397
|
+
// Resumption incorporates fresh key material, so refresh the timeout.
|
398
|
+
ssl_session_renew_timeout(ssl, hs->new_session.get(),
|
399
|
+
ssl->session_ctx->session_psk_dhe_timeout);
|
400
|
+
break;
|
401
|
+
|
402
|
+
case ssl_ticket_aead_error:
|
403
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
|
404
|
+
return ssl_hs_error;
|
405
|
+
|
406
|
+
case ssl_ticket_aead_retry:
|
407
|
+
hs->tls13_state = state_select_session;
|
408
|
+
return ssl_hs_pending_ticket;
|
409
|
+
}
|
410
|
+
|
411
|
+
// Record connection properties in the new session.
|
412
|
+
hs->new_session->cipher = hs->new_cipher;
|
413
|
+
|
414
|
+
// Store the initial negotiated ALPN in the session.
|
415
|
+
if (ssl->s3->alpn_selected != NULL) {
|
416
|
+
hs->new_session->early_alpn = (uint8_t *)BUF_memdup(
|
417
|
+
ssl->s3->alpn_selected, ssl->s3->alpn_selected_len);
|
418
|
+
if (hs->new_session->early_alpn == NULL) {
|
419
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
420
|
+
return ssl_hs_error;
|
421
|
+
}
|
422
|
+
hs->new_session->early_alpn_len = ssl->s3->alpn_selected_len;
|
423
|
+
}
|
424
|
+
|
425
|
+
if (ssl->ctx->dos_protection_cb != NULL &&
|
426
|
+
ssl->ctx->dos_protection_cb(&client_hello) == 0) {
|
427
|
+
// Connection rejected for DOS reasons.
|
428
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_REJECTED);
|
429
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
430
|
+
return ssl_hs_error;
|
431
|
+
}
|
432
|
+
|
433
|
+
// Incorporate the PSK into the running secret.
|
434
|
+
if (ssl->s3->session_reused) {
|
435
|
+
if (!tls13_advance_key_schedule(hs, hs->new_session->master_key,
|
436
|
+
hs->new_session->master_key_length)) {
|
437
|
+
return ssl_hs_error;
|
438
|
+
}
|
439
|
+
} else if (!tls13_advance_key_schedule(hs, kZeroes, hs->hash_len)) {
|
440
|
+
return ssl_hs_error;
|
441
|
+
}
|
442
|
+
|
443
|
+
if (ssl->early_data_accepted) {
|
444
|
+
if (!tls13_derive_early_secrets(hs)) {
|
445
|
+
return ssl_hs_error;
|
446
|
+
}
|
447
|
+
} else if (hs->early_data_offered) {
|
448
|
+
ssl->s3->skip_early_data = true;
|
449
|
+
}
|
450
|
+
|
451
|
+
// Resolve ECDHE and incorporate it into the secret.
|
452
|
+
bool need_retry;
|
453
|
+
if (!resolve_ecdhe_secret(hs, &need_retry, &client_hello)) {
|
454
|
+
if (need_retry) {
|
455
|
+
ssl->early_data_accepted = 0;
|
456
|
+
ssl->s3->skip_early_data = true;
|
457
|
+
ssl->method->next_message(ssl);
|
458
|
+
hs->tls13_state = state_send_hello_retry_request;
|
459
|
+
return ssl_hs_ok;
|
460
|
+
}
|
461
|
+
return ssl_hs_error;
|
462
|
+
}
|
463
|
+
|
464
|
+
ssl->method->next_message(ssl);
|
465
|
+
hs->tls13_state = state_send_server_hello;
|
466
|
+
return ssl_hs_ok;
|
467
|
+
}
|
468
|
+
|
469
|
+
static enum ssl_hs_wait_t do_send_hello_retry_request(SSL_HANDSHAKE *hs) {
|
470
|
+
SSL *const ssl = hs->ssl;
|
471
|
+
ScopedCBB cbb;
|
472
|
+
CBB body, extensions;
|
473
|
+
uint16_t group_id;
|
474
|
+
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
475
|
+
SSL3_MT_HELLO_RETRY_REQUEST) ||
|
476
|
+
!CBB_add_u16(&body, ssl->version) ||
|
477
|
+
!tls1_get_shared_group(hs, &group_id) ||
|
478
|
+
!CBB_add_u16_length_prefixed(&body, &extensions) ||
|
479
|
+
!CBB_add_u16(&extensions, TLSEXT_TYPE_key_share) ||
|
480
|
+
!CBB_add_u16(&extensions, 2 /* length */) ||
|
481
|
+
!CBB_add_u16(&extensions, group_id) ||
|
482
|
+
!ssl_add_message_cbb(ssl, cbb.get())) {
|
483
|
+
return ssl_hs_error;
|
484
|
+
}
|
485
|
+
|
486
|
+
hs->tls13_state = state_read_second_client_hello;
|
487
|
+
return ssl_hs_flush;
|
488
|
+
}
|
489
|
+
|
490
|
+
static enum ssl_hs_wait_t do_read_second_client_hello(SSL_HANDSHAKE *hs) {
|
491
|
+
SSL *const ssl = hs->ssl;
|
492
|
+
SSLMessage msg;
|
493
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
494
|
+
return ssl_hs_read_message;
|
495
|
+
}
|
496
|
+
if (!ssl_check_message_type(ssl, msg, SSL3_MT_CLIENT_HELLO)) {
|
497
|
+
return ssl_hs_error;
|
498
|
+
}
|
499
|
+
SSL_CLIENT_HELLO client_hello;
|
500
|
+
if (!ssl_client_hello_init(ssl, &client_hello, msg)) {
|
501
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CLIENTHELLO_PARSE_FAILED);
|
502
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
503
|
+
return ssl_hs_error;
|
504
|
+
}
|
505
|
+
|
506
|
+
bool need_retry;
|
507
|
+
if (!resolve_ecdhe_secret(hs, &need_retry, &client_hello)) {
|
508
|
+
if (need_retry) {
|
509
|
+
// Only send one HelloRetryRequest.
|
510
|
+
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
511
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_CURVE);
|
512
|
+
}
|
513
|
+
return ssl_hs_error;
|
514
|
+
}
|
515
|
+
|
516
|
+
if (!ssl_hash_message(hs, msg)) {
|
517
|
+
return ssl_hs_error;
|
518
|
+
}
|
519
|
+
|
520
|
+
ssl->method->next_message(ssl);
|
521
|
+
hs->tls13_state = state_send_server_hello;
|
522
|
+
return ssl_hs_ok;
|
523
|
+
}
|
524
|
+
|
525
|
+
static enum ssl_hs_wait_t do_send_server_hello(SSL_HANDSHAKE *hs) {
|
526
|
+
SSL *const ssl = hs->ssl;
|
527
|
+
|
528
|
+
uint16_t version = ssl->version;
|
529
|
+
if (ssl_is_resumption_experiment(ssl->version)) {
|
530
|
+
version = TLS1_2_VERSION;
|
531
|
+
}
|
532
|
+
|
533
|
+
// Send a ServerHello.
|
534
|
+
ScopedCBB cbb;
|
535
|
+
CBB body, extensions, session_id;
|
536
|
+
if (!ssl->method->init_message(ssl, cbb.get(), &body, SSL3_MT_SERVER_HELLO) ||
|
537
|
+
!CBB_add_u16(&body, version) ||
|
538
|
+
!RAND_bytes(ssl->s3->server_random, sizeof(ssl->s3->server_random)) ||
|
539
|
+
!CBB_add_bytes(&body, ssl->s3->server_random, SSL3_RANDOM_SIZE) ||
|
540
|
+
(ssl_is_resumption_experiment(ssl->version) &&
|
541
|
+
(!CBB_add_u8_length_prefixed(&body, &session_id) ||
|
542
|
+
!CBB_add_bytes(&session_id, hs->session_id, hs->session_id_len))) ||
|
543
|
+
!CBB_add_u16(&body, ssl_cipher_get_value(hs->new_cipher)) ||
|
544
|
+
(ssl_is_resumption_experiment(ssl->version) && !CBB_add_u8(&body, 0)) ||
|
545
|
+
!CBB_add_u16_length_prefixed(&body, &extensions) ||
|
546
|
+
!ssl_ext_pre_shared_key_add_serverhello(hs, &extensions) ||
|
547
|
+
!ssl_ext_key_share_add_serverhello(hs, &extensions) ||
|
548
|
+
(ssl_is_resumption_experiment(ssl->version) &&
|
549
|
+
!ssl_ext_supported_versions_add_serverhello(hs, &extensions)) ||
|
550
|
+
!ssl_add_message_cbb(ssl, cbb.get())) {
|
551
|
+
return ssl_hs_error;
|
552
|
+
}
|
553
|
+
|
554
|
+
if (ssl_is_resumption_experiment(ssl->version) &&
|
555
|
+
!ssl3_add_change_cipher_spec(ssl)) {
|
556
|
+
return ssl_hs_error;
|
557
|
+
}
|
558
|
+
|
559
|
+
// Derive and enable the handshake traffic secrets.
|
560
|
+
if (!tls13_derive_handshake_secrets(hs) ||
|
561
|
+
!tls13_set_traffic_key(ssl, evp_aead_seal, hs->server_handshake_secret,
|
562
|
+
hs->hash_len)) {
|
563
|
+
return ssl_hs_error;
|
564
|
+
}
|
565
|
+
|
566
|
+
// Send EncryptedExtensions.
|
567
|
+
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
568
|
+
SSL3_MT_ENCRYPTED_EXTENSIONS) ||
|
569
|
+
!ssl_add_serverhello_tlsext(hs, &body) ||
|
570
|
+
!ssl_add_message_cbb(ssl, cbb.get())) {
|
571
|
+
return ssl_hs_error;
|
572
|
+
}
|
573
|
+
|
574
|
+
if (!ssl->s3->session_reused) {
|
575
|
+
// Determine whether to request a client certificate.
|
576
|
+
hs->cert_request = !!(ssl->verify_mode & SSL_VERIFY_PEER);
|
577
|
+
// Only request a certificate if Channel ID isn't negotiated.
|
578
|
+
if ((ssl->verify_mode & SSL_VERIFY_PEER_IF_NO_OBC) &&
|
579
|
+
ssl->s3->tlsext_channel_id_valid) {
|
580
|
+
hs->cert_request = false;
|
581
|
+
}
|
582
|
+
}
|
583
|
+
|
584
|
+
// Send a CertificateRequest, if necessary.
|
585
|
+
if (hs->cert_request) {
|
586
|
+
CBB sigalgs_cbb;
|
587
|
+
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
588
|
+
SSL3_MT_CERTIFICATE_REQUEST) ||
|
589
|
+
!CBB_add_u8(&body, 0 /* no certificate_request_context. */) ||
|
590
|
+
!CBB_add_u16_length_prefixed(&body, &sigalgs_cbb) ||
|
591
|
+
!tls12_add_verify_sigalgs(ssl, &sigalgs_cbb) ||
|
592
|
+
!ssl_add_client_CA_list(ssl, &body) ||
|
593
|
+
!CBB_add_u16(&body, 0 /* empty certificate_extensions. */) ||
|
594
|
+
!ssl_add_message_cbb(ssl, cbb.get())) {
|
595
|
+
return ssl_hs_error;
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
// Send the server Certificate message, if necessary.
|
600
|
+
if (!ssl->s3->session_reused) {
|
601
|
+
if (!ssl_has_certificate(ssl)) {
|
602
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CERTIFICATE_SET);
|
603
|
+
return ssl_hs_error;
|
604
|
+
}
|
605
|
+
|
606
|
+
if (!tls13_add_certificate(hs)) {
|
607
|
+
return ssl_hs_error;
|
608
|
+
}
|
609
|
+
|
610
|
+
hs->tls13_state = state_send_server_certificate_verify;
|
611
|
+
return ssl_hs_ok;
|
612
|
+
}
|
613
|
+
|
614
|
+
hs->tls13_state = state_send_server_finished;
|
615
|
+
return ssl_hs_ok;
|
616
|
+
}
|
617
|
+
|
618
|
+
static enum ssl_hs_wait_t do_send_server_certificate_verify(SSL_HANDSHAKE *hs) {
|
619
|
+
switch (tls13_add_certificate_verify(hs)) {
|
620
|
+
case ssl_private_key_success:
|
621
|
+
hs->tls13_state = state_send_server_finished;
|
622
|
+
return ssl_hs_ok;
|
623
|
+
|
624
|
+
case ssl_private_key_retry:
|
625
|
+
hs->tls13_state = state_send_server_certificate_verify;
|
626
|
+
return ssl_hs_private_key_operation;
|
627
|
+
|
628
|
+
case ssl_private_key_failure:
|
629
|
+
return ssl_hs_error;
|
630
|
+
}
|
631
|
+
|
632
|
+
assert(0);
|
633
|
+
return ssl_hs_error;
|
634
|
+
}
|
635
|
+
|
636
|
+
static enum ssl_hs_wait_t do_send_server_finished(SSL_HANDSHAKE *hs) {
|
637
|
+
SSL *const ssl = hs->ssl;
|
638
|
+
if (!tls13_add_finished(hs) ||
|
639
|
+
// Update the secret to the master secret and derive traffic keys.
|
640
|
+
!tls13_advance_key_schedule(hs, kZeroes, hs->hash_len) ||
|
641
|
+
!tls13_derive_application_secrets(hs) ||
|
642
|
+
!tls13_set_traffic_key(ssl, evp_aead_seal, hs->server_traffic_secret_0,
|
643
|
+
hs->hash_len)) {
|
644
|
+
return ssl_hs_error;
|
645
|
+
}
|
646
|
+
|
647
|
+
if (ssl->early_data_accepted) {
|
648
|
+
// If accepting 0-RTT, we send tickets half-RTT. This gets the tickets on
|
649
|
+
// the wire sooner and also avoids triggering a write on |SSL_read| when
|
650
|
+
// processing the client Finished. This requires computing the client
|
651
|
+
// Finished early. See draft-ietf-tls-tls13-18, section 4.5.1.
|
652
|
+
size_t finished_len;
|
653
|
+
if (!tls13_finished_mac(hs, hs->expected_client_finished, &finished_len,
|
654
|
+
0 /* client */)) {
|
655
|
+
return ssl_hs_error;
|
656
|
+
}
|
657
|
+
|
658
|
+
if (finished_len != hs->hash_len) {
|
659
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
660
|
+
return ssl_hs_error;
|
661
|
+
}
|
662
|
+
|
663
|
+
// Feed the predicted Finished into the transcript. This allows us to derive
|
664
|
+
// the resumption secret early and send half-RTT tickets.
|
665
|
+
//
|
666
|
+
// TODO(davidben): This will need to be updated for DTLS 1.3.
|
667
|
+
assert(!SSL_is_dtls(hs->ssl));
|
668
|
+
assert(hs->hash_len <= 0xff);
|
669
|
+
uint8_t header[4] = {SSL3_MT_FINISHED, 0, 0,
|
670
|
+
static_cast<uint8_t>(hs->hash_len)};
|
671
|
+
if (!hs->transcript.Update(header, sizeof(header)) ||
|
672
|
+
!hs->transcript.Update(hs->expected_client_finished, hs->hash_len) ||
|
673
|
+
!tls13_derive_resumption_secret(hs) ||
|
674
|
+
!add_new_session_tickets(hs)) {
|
675
|
+
return ssl_hs_error;
|
676
|
+
}
|
677
|
+
}
|
678
|
+
|
679
|
+
hs->tls13_state = state_read_second_client_flight;
|
680
|
+
return ssl_hs_flush;
|
681
|
+
}
|
682
|
+
|
683
|
+
static enum ssl_hs_wait_t do_read_second_client_flight(SSL_HANDSHAKE *hs) {
|
684
|
+
SSL *const ssl = hs->ssl;
|
685
|
+
if (ssl->early_data_accepted) {
|
686
|
+
if (!tls13_set_traffic_key(ssl, evp_aead_open, hs->early_traffic_secret,
|
687
|
+
hs->hash_len)) {
|
688
|
+
return ssl_hs_error;
|
689
|
+
}
|
690
|
+
hs->can_early_write = true;
|
691
|
+
hs->can_early_read = true;
|
692
|
+
hs->in_early_data = true;
|
693
|
+
hs->tls13_state = state_process_end_of_early_data;
|
694
|
+
return ssl_hs_read_end_of_early_data;
|
695
|
+
}
|
696
|
+
hs->tls13_state = state_process_end_of_early_data;
|
697
|
+
return ssl_hs_ok;
|
698
|
+
}
|
699
|
+
|
700
|
+
static enum ssl_hs_wait_t do_process_end_of_early_data(SSL_HANDSHAKE *hs) {
|
701
|
+
hs->tls13_state = state_process_change_cipher_spec;
|
702
|
+
// If early data was accepted, the ChangeCipherSpec message will be in the
|
703
|
+
// discarded early data.
|
704
|
+
if (hs->early_data_offered && !hs->ssl->early_data_accepted) {
|
705
|
+
return ssl_hs_ok;
|
706
|
+
}
|
707
|
+
return ssl_is_resumption_client_ccs_experiment(hs->ssl->version)
|
708
|
+
? ssl_hs_read_change_cipher_spec
|
709
|
+
: ssl_hs_ok;
|
710
|
+
}
|
711
|
+
|
712
|
+
static enum ssl_hs_wait_t do_process_change_cipher_spec(SSL_HANDSHAKE *hs) {
|
713
|
+
SSL *const ssl = hs->ssl;
|
714
|
+
if (!tls13_set_traffic_key(ssl, evp_aead_open, hs->client_handshake_secret,
|
715
|
+
hs->hash_len)) {
|
716
|
+
return ssl_hs_error;
|
717
|
+
}
|
718
|
+
hs->tls13_state = ssl->early_data_accepted ? state_read_client_finished
|
719
|
+
: state_read_client_certificate;
|
720
|
+
return ssl_hs_ok;
|
721
|
+
}
|
722
|
+
|
723
|
+
static enum ssl_hs_wait_t do_read_client_certificate(SSL_HANDSHAKE *hs) {
|
724
|
+
SSL *const ssl = hs->ssl;
|
725
|
+
if (!hs->cert_request) {
|
726
|
+
// OpenSSL returns X509_V_OK when no certificates are requested. This is
|
727
|
+
// classed by them as a bug, but it's assumed by at least NGINX.
|
728
|
+
hs->new_session->verify_result = X509_V_OK;
|
729
|
+
|
730
|
+
// Skip this state.
|
731
|
+
hs->tls13_state = state_read_channel_id;
|
732
|
+
return ssl_hs_ok;
|
733
|
+
}
|
734
|
+
|
735
|
+
const int allow_anonymous =
|
736
|
+
(ssl->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) == 0;
|
737
|
+
SSLMessage msg;
|
738
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
739
|
+
return ssl_hs_read_message;
|
740
|
+
}
|
741
|
+
if (!ssl_check_message_type(ssl, msg, SSL3_MT_CERTIFICATE) ||
|
742
|
+
!tls13_process_certificate(hs, msg, allow_anonymous) ||
|
743
|
+
!ssl_hash_message(hs, msg)) {
|
744
|
+
return ssl_hs_error;
|
745
|
+
}
|
746
|
+
|
747
|
+
ssl->method->next_message(ssl);
|
748
|
+
hs->tls13_state = state_read_client_certificate_verify;
|
749
|
+
return ssl_hs_ok;
|
750
|
+
}
|
751
|
+
|
752
|
+
static enum ssl_hs_wait_t do_read_client_certificate_verify(
|
753
|
+
SSL_HANDSHAKE *hs) {
|
754
|
+
SSL *const ssl = hs->ssl;
|
755
|
+
if (sk_CRYPTO_BUFFER_num(hs->new_session->certs) == 0) {
|
756
|
+
// Skip this state.
|
757
|
+
hs->tls13_state = state_read_channel_id;
|
758
|
+
return ssl_hs_ok;
|
759
|
+
}
|
760
|
+
|
761
|
+
SSLMessage msg;
|
762
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
763
|
+
return ssl_hs_read_message;
|
764
|
+
}
|
765
|
+
|
766
|
+
switch (ssl_verify_peer_cert(hs)) {
|
767
|
+
case ssl_verify_ok:
|
768
|
+
break;
|
769
|
+
case ssl_verify_invalid:
|
770
|
+
return ssl_hs_error;
|
771
|
+
case ssl_verify_retry:
|
772
|
+
hs->tls13_state = state_read_client_certificate_verify;
|
773
|
+
return ssl_hs_certificate_verify;
|
774
|
+
}
|
775
|
+
|
776
|
+
if (!ssl_check_message_type(ssl, msg, SSL3_MT_CERTIFICATE_VERIFY) ||
|
777
|
+
!tls13_process_certificate_verify(hs, msg) ||
|
778
|
+
!ssl_hash_message(hs, msg)) {
|
779
|
+
return ssl_hs_error;
|
780
|
+
}
|
781
|
+
|
782
|
+
ssl->method->next_message(ssl);
|
783
|
+
hs->tls13_state = state_read_channel_id;
|
784
|
+
return ssl_hs_ok;
|
785
|
+
}
|
786
|
+
|
787
|
+
static enum ssl_hs_wait_t do_read_channel_id(SSL_HANDSHAKE *hs) {
|
788
|
+
SSL *const ssl = hs->ssl;
|
789
|
+
if (!ssl->s3->tlsext_channel_id_valid) {
|
790
|
+
hs->tls13_state = state_read_client_finished;
|
791
|
+
return ssl_hs_ok;
|
792
|
+
}
|
793
|
+
|
794
|
+
SSLMessage msg;
|
795
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
796
|
+
return ssl_hs_read_message;
|
797
|
+
}
|
798
|
+
if (!ssl_check_message_type(ssl, msg, SSL3_MT_CHANNEL_ID) ||
|
799
|
+
!tls1_verify_channel_id(hs, msg) ||
|
800
|
+
!ssl_hash_message(hs, msg)) {
|
801
|
+
return ssl_hs_error;
|
802
|
+
}
|
803
|
+
|
804
|
+
ssl->method->next_message(ssl);
|
805
|
+
hs->tls13_state = state_read_client_finished;
|
806
|
+
return ssl_hs_ok;
|
807
|
+
}
|
808
|
+
|
809
|
+
static enum ssl_hs_wait_t do_read_client_finished(SSL_HANDSHAKE *hs) {
|
810
|
+
SSL *const ssl = hs->ssl;
|
811
|
+
SSLMessage msg;
|
812
|
+
if (!ssl->method->get_message(ssl, &msg)) {
|
813
|
+
return ssl_hs_read_message;
|
814
|
+
}
|
815
|
+
if (!ssl_check_message_type(ssl, msg, SSL3_MT_FINISHED) ||
|
816
|
+
// If early data was accepted, we've already computed the client Finished
|
817
|
+
// and derived the resumption secret.
|
818
|
+
!tls13_process_finished(hs, msg, ssl->early_data_accepted) ||
|
819
|
+
// evp_aead_seal keys have already been switched.
|
820
|
+
!tls13_set_traffic_key(ssl, evp_aead_open, hs->client_traffic_secret_0,
|
821
|
+
hs->hash_len)) {
|
822
|
+
return ssl_hs_error;
|
823
|
+
}
|
824
|
+
|
825
|
+
if (!ssl->early_data_accepted) {
|
826
|
+
if (!ssl_hash_message(hs, msg) ||
|
827
|
+
!tls13_derive_resumption_secret(hs)) {
|
828
|
+
return ssl_hs_error;
|
829
|
+
}
|
830
|
+
|
831
|
+
// We send post-handshake tickets as part of the handshake in 1-RTT.
|
832
|
+
hs->tls13_state = state_send_new_session_ticket;
|
833
|
+
} else {
|
834
|
+
// We already sent half-RTT tickets.
|
835
|
+
hs->tls13_state = state_done;
|
836
|
+
}
|
837
|
+
|
838
|
+
ssl->method->next_message(ssl);
|
839
|
+
return ssl_hs_ok;
|
840
|
+
}
|
841
|
+
|
842
|
+
static enum ssl_hs_wait_t do_send_new_session_ticket(SSL_HANDSHAKE *hs) {
|
843
|
+
// If the client doesn't accept resumption with PSK_DHE_KE, don't send a
|
844
|
+
// session ticket.
|
845
|
+
if (!hs->accept_psk_mode) {
|
846
|
+
hs->tls13_state = state_done;
|
847
|
+
return ssl_hs_ok;
|
848
|
+
}
|
849
|
+
|
850
|
+
if (!add_new_session_tickets(hs)) {
|
851
|
+
return ssl_hs_error;
|
852
|
+
}
|
853
|
+
|
854
|
+
hs->tls13_state = state_done;
|
855
|
+
return ssl_hs_flush;
|
856
|
+
}
|
857
|
+
|
858
|
+
enum ssl_hs_wait_t tls13_server_handshake(SSL_HANDSHAKE *hs) {
|
859
|
+
while (hs->tls13_state != state_done) {
|
860
|
+
enum ssl_hs_wait_t ret = ssl_hs_error;
|
861
|
+
enum server_hs_state_t state =
|
862
|
+
static_cast<enum server_hs_state_t>(hs->tls13_state);
|
863
|
+
switch (state) {
|
864
|
+
case state_select_parameters:
|
865
|
+
ret = do_select_parameters(hs);
|
866
|
+
break;
|
867
|
+
case state_select_session:
|
868
|
+
ret = do_select_session(hs);
|
869
|
+
break;
|
870
|
+
case state_send_hello_retry_request:
|
871
|
+
ret = do_send_hello_retry_request(hs);
|
872
|
+
break;
|
873
|
+
case state_read_second_client_hello:
|
874
|
+
ret = do_read_second_client_hello(hs);
|
875
|
+
break;
|
876
|
+
case state_send_server_hello:
|
877
|
+
ret = do_send_server_hello(hs);
|
878
|
+
break;
|
879
|
+
case state_send_server_certificate_verify:
|
880
|
+
ret = do_send_server_certificate_verify(hs);
|
881
|
+
break;
|
882
|
+
case state_send_server_finished:
|
883
|
+
ret = do_send_server_finished(hs);
|
884
|
+
break;
|
885
|
+
case state_read_second_client_flight:
|
886
|
+
ret = do_read_second_client_flight(hs);
|
887
|
+
break;
|
888
|
+
case state_process_end_of_early_data:
|
889
|
+
ret = do_process_end_of_early_data(hs);
|
890
|
+
break;
|
891
|
+
case state_process_change_cipher_spec:
|
892
|
+
ret = do_process_change_cipher_spec(hs);
|
893
|
+
break;
|
894
|
+
case state_read_client_certificate:
|
895
|
+
ret = do_read_client_certificate(hs);
|
896
|
+
break;
|
897
|
+
case state_read_client_certificate_verify:
|
898
|
+
ret = do_read_client_certificate_verify(hs);
|
899
|
+
break;
|
900
|
+
case state_read_channel_id:
|
901
|
+
ret = do_read_channel_id(hs);
|
902
|
+
break;
|
903
|
+
case state_read_client_finished:
|
904
|
+
ret = do_read_client_finished(hs);
|
905
|
+
break;
|
906
|
+
case state_send_new_session_ticket:
|
907
|
+
ret = do_send_new_session_ticket(hs);
|
908
|
+
break;
|
909
|
+
case state_done:
|
910
|
+
ret = ssl_hs_ok;
|
911
|
+
break;
|
912
|
+
}
|
913
|
+
|
914
|
+
if (hs->tls13_state != state) {
|
915
|
+
ssl_do_info_callback(hs->ssl, SSL_CB_ACCEPT_LOOP, 1);
|
916
|
+
}
|
917
|
+
|
918
|
+
if (ret != ssl_hs_ok) {
|
919
|
+
return ret;
|
920
|
+
}
|
921
|
+
}
|
922
|
+
|
923
|
+
return ssl_hs_ok;
|
924
|
+
}
|
925
|
+
|
926
|
+
const char *tls13_server_handshake_state(SSL_HANDSHAKE *hs) {
|
927
|
+
enum server_hs_state_t state =
|
928
|
+
static_cast<enum server_hs_state_t>(hs->tls13_state);
|
929
|
+
switch (state) {
|
930
|
+
case state_select_parameters:
|
931
|
+
return "TLS 1.3 server select_parameters";
|
932
|
+
case state_select_session:
|
933
|
+
return "TLS 1.3 server select_session";
|
934
|
+
case state_send_hello_retry_request:
|
935
|
+
return "TLS 1.3 server send_hello_retry_request";
|
936
|
+
case state_read_second_client_hello:
|
937
|
+
return "TLS 1.3 server read_second_client_hello";
|
938
|
+
case state_send_server_hello:
|
939
|
+
return "TLS 1.3 server send_server_hello";
|
940
|
+
case state_send_server_certificate_verify:
|
941
|
+
return "TLS 1.3 server send_server_certificate_verify";
|
942
|
+
case state_send_server_finished:
|
943
|
+
return "TLS 1.3 server send_server_finished";
|
944
|
+
case state_read_second_client_flight:
|
945
|
+
return "TLS 1.3 server read_second_client_flight";
|
946
|
+
case state_process_change_cipher_spec:
|
947
|
+
return "TLS 1.3 server process_change_cipher_spec";
|
948
|
+
case state_process_end_of_early_data:
|
949
|
+
return "TLS 1.3 server process_end_of_early_data";
|
950
|
+
case state_read_client_certificate:
|
951
|
+
return "TLS 1.3 server read_client_certificate";
|
952
|
+
case state_read_client_certificate_verify:
|
953
|
+
return "TLS 1.3 server read_client_certificate_verify";
|
954
|
+
case state_read_channel_id:
|
955
|
+
return "TLS 1.3 server read_channel_id";
|
956
|
+
case state_read_client_finished:
|
957
|
+
return "TLS 1.3 server read_client_finished";
|
958
|
+
case state_send_new_session_ticket:
|
959
|
+
return "TLS 1.3 server send_new_session_ticket";
|
960
|
+
case state_done:
|
961
|
+
return "TLS 1.3 server done";
|
962
|
+
}
|
963
|
+
|
964
|
+
return "TLS 1.3 server unknown";
|
965
|
+
}
|
966
|
+
|
967
|
+
} // namespace bssl
|