grpc 1.37.1 → 1.40.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 +112 -59
- data/include/grpc/event_engine/README.md +38 -0
- data/include/grpc/event_engine/endpoint_config.h +48 -0
- data/include/grpc/event_engine/event_engine.h +330 -0
- data/include/grpc/event_engine/port.h +41 -0
- data/include/grpc/event_engine/slice_allocator.h +66 -0
- data/include/grpc/grpc.h +11 -4
- data/include/grpc/grpc_security.h +32 -0
- data/include/grpc/grpc_security_constants.h +15 -0
- data/include/grpc/impl/codegen/grpc_types.h +44 -19
- data/include/grpc/impl/codegen/port_platform.h +46 -0
- data/include/grpc/module.modulemap +14 -14
- data/src/core/ext/filters/client_channel/backup_poller.cc +3 -3
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +177 -202
- data/src/core/ext/filters/client_channel/client_channel.cc +975 -3282
- data/src/core/ext/filters/client_channel/client_channel.h +513 -55
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -1
- data/src/core/ext/filters/client_channel/config_selector.h +20 -7
- data/src/core/ext/filters/client_channel/connector.h +1 -1
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -10
- data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +28 -27
- data/src/core/ext/filters/client_channel/health/health_check_client.h +30 -29
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +24 -21
- data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +53 -51
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +14 -23
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +10 -17
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +17 -20
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +53 -65
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +36 -44
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +33 -55
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +151 -163
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -16
- data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +24 -18
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +14 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +33 -24
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +18 -12
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +20 -28
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -5
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +20 -13
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +158 -102
- data/src/core/ext/filters/client_channel/resolver.h +2 -2
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +32 -239
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +20 -49
- data/src/core/ext/filters/client_channel/retry_filter.cc +2598 -0
- data/src/core/ext/filters/client_channel/retry_filter.h +30 -0
- data/src/core/ext/filters/client_channel/retry_service_config.cc +316 -0
- data/src/core/ext/filters/client_channel/retry_service_config.h +96 -0
- data/src/core/ext/filters/client_channel/server_address.cc +1 -1
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +7 -6
- data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +5 -4
- data/src/core/ext/filters/client_channel/service_config_parser.cc +6 -6
- data/src/core/ext/filters/client_channel/service_config_parser.h +7 -4
- data/src/core/ext/filters/client_channel/subchannel.cc +17 -16
- data/src/core/ext/filters/client_channel/subchannel.h +7 -6
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +17 -16
- data/src/core/ext/filters/deadline/deadline_filter.cc +10 -10
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +19 -18
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +5 -5
- data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +33 -23
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +23 -22
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +21 -21
- data/src/core/ext/filters/http/server/http_server_filter.cc +27 -23
- data/src/core/ext/filters/max_age/max_age_filter.cc +12 -10
- data/src/core/ext/filters/message_size/message_size_filter.cc +14 -11
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -3
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +7 -7
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +3 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +49 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -4
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +5 -4
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +66 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +141 -126
- data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/context_list.h +4 -4
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/flow_control.h +9 -9
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +12 -12
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -10
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +15 -16
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +7 -7
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +11 -10
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +4 -6
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +652 -736
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +195 -74
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +4 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +33 -28
- data/src/core/ext/transport/chttp2/transport/parsing.cc +129 -106
- data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +7 -3
- data/src/core/ext/transport/inproc/inproc_transport.cc +72 -60
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
- data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
- data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
- data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
- data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
- data/src/core/ext/xds/certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/certificate_provider_store.h +3 -3
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +3 -3
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +2 -2
- data/src/core/ext/xds/xds_api.cc +665 -317
- data/src/core/ext/xds/xds_api.h +52 -14
- data/src/core/ext/xds/xds_bootstrap.cc +101 -160
- data/src/core/ext/xds/xds_bootstrap.h +19 -24
- data/src/core/ext/xds/xds_certificate_provider.cc +4 -4
- data/src/core/ext/xds/xds_certificate_provider.h +4 -4
- data/src/core/ext/xds/xds_channel_args.h +5 -2
- data/src/core/ext/xds/xds_client.cc +370 -215
- data/src/core/ext/xds/xds_client.h +38 -28
- data/src/core/ext/xds/xds_client_stats.h +3 -2
- data/src/core/ext/xds/xds_http_filters.cc +3 -2
- data/src/core/ext/xds/xds_http_filters.h +3 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +34 -20
- data/src/core/lib/{iomgr → address_utils}/parse_address.cc +17 -17
- data/src/core/lib/{iomgr → address_utils}/parse_address.h +7 -7
- data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.cc +16 -20
- data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.h +16 -11
- data/src/core/lib/channel/call_tracer.h +85 -0
- data/src/core/lib/channel/channel_stack.cc +10 -9
- data/src/core/lib/channel/channel_stack.h +11 -10
- data/src/core/lib/channel/channel_stack_builder.cc +2 -2
- data/src/core/lib/channel/channel_stack_builder.h +1 -1
- data/src/core/lib/channel/channelz.cc +21 -13
- data/src/core/lib/channel/channelz.h +3 -0
- data/src/core/lib/channel/connected_channel.cc +4 -4
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/handshaker.cc +7 -6
- data/src/core/lib/channel/handshaker.h +5 -5
- data/src/core/lib/channel/status_util.h +4 -0
- data/src/core/lib/compression/stream_compression.h +1 -1
- data/src/core/lib/compression/stream_compression_gzip.h +1 -1
- data/src/core/lib/compression/stream_compression_identity.h +1 -1
- data/src/core/lib/debug/stats.h +1 -1
- data/src/core/lib/event_engine/endpoint_config.cc +46 -0
- data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
- data/src/core/lib/event_engine/event_engine.cc +50 -0
- data/src/core/lib/event_engine/sockaddr.cc +40 -0
- data/src/core/lib/event_engine/sockaddr.h +44 -0
- data/src/core/lib/gpr/murmur_hash.cc +4 -2
- data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
- data/src/core/lib/gprpp/manual_constructor.h +1 -1
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +28 -14
- data/src/core/lib/gprpp/status_helper.cc +407 -0
- data/src/core/lib/gprpp/status_helper.h +183 -0
- data/src/core/lib/gprpp/sync.h +2 -30
- data/src/core/lib/http/httpcli.cc +11 -11
- data/src/core/lib/http/httpcli_security_connector.cc +11 -7
- data/src/core/lib/http/parser.cc +16 -16
- data/src/core/lib/http/parser.h +4 -4
- data/src/core/lib/iomgr/buffer_list.cc +8 -10
- data/src/core/lib/iomgr/buffer_list.h +4 -5
- data/src/core/lib/iomgr/call_combiner.cc +15 -12
- data/src/core/lib/iomgr/call_combiner.h +12 -14
- data/src/core/lib/iomgr/cfstream_handle.cc +3 -3
- data/src/core/lib/iomgr/cfstream_handle.h +1 -1
- data/src/core/lib/iomgr/closure.h +7 -6
- data/src/core/lib/iomgr/combiner.cc +14 -12
- data/src/core/lib/iomgr/combiner.h +2 -2
- data/src/core/lib/iomgr/endpoint.cc +1 -1
- data/src/core/lib/iomgr/endpoint.h +2 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +11 -13
- data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
- data/src/core/lib/iomgr/error.cc +168 -61
- data/src/core/lib/iomgr/error.h +217 -106
- data/src/core/lib/iomgr/error_cfstream.cc +3 -2
- data/src/core/lib/iomgr/error_cfstream.h +2 -2
- data/src/core/lib/iomgr/error_internal.h +5 -1
- data/src/core/lib/iomgr/ev_apple.cc +5 -5
- data/src/core/lib/iomgr/ev_apple.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -19
- data/src/core/lib/iomgr/ev_epollex_linux.cc +48 -45
- data/src/core/lib/iomgr/ev_poll_posix.cc +26 -23
- data/src/core/lib/iomgr/ev_posix.cc +9 -8
- data/src/core/lib/iomgr/ev_posix.h +9 -9
- data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
- data/src/core/lib/iomgr/event_engine/closure.h +33 -0
- data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
- data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
- data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
- data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
- data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
- data/src/core/lib/iomgr/event_engine/pollset.h +25 -0
- data/src/core/lib/iomgr/event_engine/promise.h +51 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
- data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
- data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
- data/src/core/lib/iomgr/exec_ctx.cc +12 -4
- data/src/core/lib/iomgr/exec_ctx.h +4 -5
- data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
- data/src/core/lib/iomgr/executor/threadpool.h +2 -2
- data/src/core/lib/iomgr/executor.cc +8 -8
- data/src/core/lib/iomgr/executor.h +2 -2
- data/src/core/lib/iomgr/iomgr.cc +2 -2
- data/src/core/lib/iomgr/iomgr.h +1 -1
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +2 -2
- data/src/core/lib/iomgr/iomgr_internal.h +3 -3
- data/src/core/lib/iomgr/iomgr_posix.cc +3 -1
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +42 -12
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -1
- data/src/core/lib/iomgr/load_file.cc +4 -4
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/lockfree_event.cc +5 -5
- data/src/core/lib/iomgr/lockfree_event.h +1 -1
- data/src/core/lib/iomgr/pollset.cc +5 -5
- data/src/core/lib/iomgr/pollset.h +9 -9
- data/src/core/lib/iomgr/pollset_custom.cc +7 -7
- data/src/core/lib/iomgr/pollset_custom.h +3 -1
- data/src/core/lib/iomgr/pollset_uv.cc +3 -1
- data/src/core/lib/iomgr/pollset_uv.h +5 -1
- data/src/core/lib/iomgr/pollset_windows.cc +5 -5
- data/src/core/lib/iomgr/port.h +7 -5
- data/src/core/lib/iomgr/python_util.h +2 -2
- data/src/core/lib/iomgr/resolve_address.cc +8 -4
- data/src/core/lib/iomgr/resolve_address.h +12 -6
- data/src/core/lib/iomgr/resolve_address_custom.cc +10 -9
- data/src/core/lib/iomgr/resolve_address_custom.h +3 -3
- data/src/core/lib/iomgr/resolve_address_posix.cc +3 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -4
- data/src/core/lib/iomgr/resource_quota.cc +13 -10
- data/src/core/lib/iomgr/sockaddr.h +1 -0
- data/src/core/lib/iomgr/socket_mutator.cc +15 -2
- data/src/core/lib/iomgr/socket_mutator.h +26 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +24 -22
- data/src/core/lib/iomgr/socket_utils_posix.h +20 -20
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +4 -4
- data/src/core/lib/iomgr/tcp_client_custom.cc +5 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +22 -19
- data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +7 -5
- data/src/core/lib/iomgr/tcp_custom.cc +14 -16
- data/src/core/lib/iomgr/tcp_custom.h +13 -12
- data/src/core/lib/iomgr/tcp_posix.cc +78 -73
- data/src/core/lib/iomgr/tcp_posix.h +8 -0
- data/src/core/lib/iomgr/tcp_server.cc +6 -6
- data/src/core/lib/iomgr/tcp_server.h +12 -11
- data/src/core/lib/iomgr/tcp_server_custom.cc +26 -25
- data/src/core/lib/iomgr/tcp_server_posix.cc +29 -21
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +21 -18
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +9 -9
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +26 -25
- data/src/core/lib/iomgr/tcp_uv.cc +25 -23
- data/src/core/lib/iomgr/tcp_windows.cc +13 -13
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer.h +6 -1
- data/src/core/lib/iomgr/timer_custom.cc +2 -1
- data/src/core/lib/iomgr/timer_custom.h +1 -1
- data/src/core/lib/iomgr/timer_generic.cc +6 -6
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/udp_server.cc +21 -20
- data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -3
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -2
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +10 -7
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -3
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +4 -4
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +3 -3
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -6
- data/src/core/lib/iomgr/work_serializer.h +17 -1
- data/src/core/lib/json/json.h +1 -1
- data/src/core/lib/json/json_reader.cc +5 -6
- data/src/core/lib/matchers/matchers.cc +46 -58
- data/src/core/lib/matchers/matchers.h +30 -29
- data/src/core/lib/security/authorization/authorization_engine.h +44 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
- data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
- data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
- data/src/core/lib/security/authorization/evaluate_args.h +91 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
- data/src/core/lib/security/credentials/credentials.h +2 -2
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +17 -13
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -11
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +2 -1
- data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +15 -12
- data/src/core/lib/security/credentials/external/external_account_credentials.h +9 -8
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +5 -4
- data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -3
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +8 -8
- data/src/core/lib/security/credentials/external/url_external_account_credentials.h +9 -7
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -2
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +12 -10
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -2
- data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/json_token.cc +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +3 -3
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +7 -5
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +21 -19
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +5 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +8 -7
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +9 -9
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +68 -13
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +4 -0
- data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
- data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +3 -3
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -3
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -3
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +2 -2
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +12 -2
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +22 -9
- data/src/core/lib/security/security_connector/security_connector.h +9 -4
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +16 -6
- data/src/core/lib/security/security_connector/ssl_utils.cc +27 -4
- data/src/core/lib/security/security_connector/ssl_utils.h +4 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +60 -76
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +66 -48
- data/src/core/lib/security/transport/client_auth_filter.cc +18 -10
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
- data/src/core/lib/security/transport/security_handshaker.cc +45 -36
- data/src/core/lib/security/transport/server_auth_filter.cc +17 -18
- data/src/core/lib/security/transport/tsi_error.cc +2 -1
- data/src/core/lib/security/transport/tsi_error.h +2 -1
- data/src/core/lib/security/util/json_util.cc +2 -2
- data/src/core/lib/security/util/json_util.h +1 -1
- data/src/core/lib/slice/slice_internal.h +1 -0
- data/src/core/lib/surface/call.cc +72 -52
- data/src/core/lib/surface/call.h +13 -2
- data/src/core/lib/surface/channel.cc +6 -6
- data/src/core/lib/surface/channel.h +3 -2
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +68 -69
- data/src/core/lib/surface/completion_queue.h +3 -2
- data/src/core/lib/surface/completion_queue_factory.cc +1 -2
- data/src/core/lib/surface/init.cc +1 -3
- data/src/core/lib/surface/init.h +10 -1
- data/src/core/lib/surface/lame_client.cc +11 -11
- data/src/core/lib/surface/lame_client.h +1 -1
- data/src/core/lib/surface/server.cc +31 -23
- data/src/core/lib/surface/server.h +19 -18
- data/src/core/lib/surface/validate_metadata.cc +7 -7
- data/src/core/lib/surface/validate_metadata.h +3 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +5 -5
- data/src/core/lib/transport/byte_stream.h +8 -8
- data/src/core/lib/transport/connectivity_state.cc +1 -1
- data/src/core/lib/transport/error_utils.cc +21 -10
- data/src/core/lib/transport/error_utils.h +11 -5
- data/src/core/lib/transport/metadata_batch.cc +37 -37
- data/src/core/lib/transport/metadata_batch.h +19 -18
- data/src/core/lib/transport/transport.cc +4 -3
- data/src/core/lib/transport/transport.h +6 -4
- data/src/core/lib/transport/transport_op_string.cc +6 -6
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/crypt/gsec.h +6 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +5 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +7 -6
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +2 -1
- data/src/core/tsi/ssl_transport_security.cc +32 -14
- data/src/core/tsi/ssl_transport_security.h +3 -4
- data/src/ruby/bin/math_services_pb.rb +1 -1
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +11 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +6 -6
- data/third_party/abseil-cpp/absl/algorithm/container.h +3 -3
- data/third_party/abseil-cpp/absl/base/attributes.h +24 -4
- data/third_party/abseil-cpp/absl/base/call_once.h +2 -9
- data/third_party/abseil-cpp/absl/base/config.h +37 -9
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +24 -10
- data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +4 -1
- data/third_party/abseil-cpp/absl/base/internal/endian.h +61 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +2 -3
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +34 -32
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +16 -6
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +11 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +14 -5
- data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +2 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +3 -3
- data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +2 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +11 -11
- data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +5 -5
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -1
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +5 -2
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +43 -42
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +111 -7
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +0 -76
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -3
- data/third_party/abseil-cpp/absl/base/log_severity.h +4 -4
- data/third_party/abseil-cpp/absl/base/macros.h +11 -0
- data/third_party/abseil-cpp/absl/base/optimization.h +10 -7
- data/third_party/abseil-cpp/absl/base/options.h +1 -1
- data/third_party/abseil-cpp/absl/base/port.h +0 -1
- data/third_party/abseil-cpp/absl/base/thread_annotations.h +1 -1
- data/third_party/abseil-cpp/absl/container/fixed_array.h +2 -2
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +5 -3
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +5 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +2 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +2 -1
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +141 -66
- data/third_party/abseil-cpp/absl/container/internal/layout.h +4 -4
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -1
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +136 -136
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +16 -12
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +5 -2
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +3 -12
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +6 -1
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +3 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +2 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +2 -2
- data/third_party/abseil-cpp/absl/hash/internal/city.cc +15 -12
- data/third_party/abseil-cpp/absl/hash/internal/city.h +1 -19
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +25 -10
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -37
- data/third_party/abseil-cpp/absl/hash/internal/wyhash.cc +111 -0
- data/third_party/abseil-cpp/absl/hash/internal/wyhash.h +48 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +16 -2
- data/third_party/abseil-cpp/absl/numeric/bits.h +177 -0
- data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -3
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +358 -0
- data/third_party/abseil-cpp/absl/numeric/internal/representation.h +55 -0
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -7
- data/third_party/abseil-cpp/absl/status/status.cc +29 -22
- data/third_party/abseil-cpp/absl/status/status.h +81 -20
- data/third_party/abseil-cpp/absl/status/statusor.h +3 -3
- data/third_party/abseil-cpp/absl/strings/charconv.cc +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +326 -371
- data/third_party/abseil-cpp/absl/strings/cord.h +182 -64
- data/third_party/abseil-cpp/absl/strings/escaping.cc +4 -4
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +6 -6
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +83 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +387 -17
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +146 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +897 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +589 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +114 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +15 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +19 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +36 -18
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +15 -40
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +64 -0
- data/third_party/abseil-cpp/absl/strings/match.cc +6 -3
- data/third_party/abseil-cpp/absl/strings/match.h +16 -6
- data/third_party/abseil-cpp/absl/strings/numbers.cc +132 -4
- data/third_party/abseil-cpp/absl/strings/numbers.h +10 -10
- data/third_party/abseil-cpp/absl/strings/str_join.h +1 -1
- data/third_party/abseil-cpp/absl/strings/str_split.h +38 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +154 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -1
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +4 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -65
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -6
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +71 -59
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +79 -62
- data/third_party/abseil-cpp/absl/time/clock.cc +146 -130
- data/third_party/abseil-cpp/absl/time/clock.h +2 -2
- data/third_party/abseil-cpp/absl/time/duration.cc +3 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +7 -11
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +7 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +4 -4
- data/third_party/abseil-cpp/absl/time/time.cc +4 -3
- data/third_party/abseil-cpp/absl/time/time.h +26 -24
- data/third_party/abseil-cpp/absl/types/internal/variant.h +1 -1
- data/third_party/abseil-cpp/absl/types/variant.h +9 -4
- data/third_party/boringssl-with-bazel/err_data.c +483 -461
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +9 -7
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +18 -8
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +1 -88
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -3
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +119 -273
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +87 -80
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +11 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +25 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +10 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -160
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +104 -93
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +52 -65
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +52 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +33 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +17 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +1 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +26 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +79 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +14 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +61 -75
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +80 -103
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +40 -49
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +367 -315
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +65 -0
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -0
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +95 -48
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +0 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +120 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +19 -25
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +3 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +42 -89
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +9 -16
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +21 -17
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +7 -25
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +25 -22
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +120 -41
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +47 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +0 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +24 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +5 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +33 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +3 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +20 -49
- data/third_party/boringssl-with-bazel/src/{crypto/x509/x509_r2x.c → include/openssl/evp_errors.h} +41 -58
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +24 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +25 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +9 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +2 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +283 -85
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +13 -19
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +445 -152
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +2 -1
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +7 -2
- data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +1133 -0
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +298 -22
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +66 -30
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +154 -24
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +414 -135
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +9 -3
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -6
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +23 -26
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +51 -60
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +664 -702
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +65 -7
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +213 -118
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +4 -2
- data/third_party/xxhash/xxhash.h +77 -195
- metadata +116 -51
- data/src/core/lib/gpr/arena.h +0 -47
- data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +0 -88
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +0 -88
- data/third_party/abseil-cpp/absl/base/internal/bits.h +0 -219
- data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +0 -249
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +0 -29
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -246
- data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -203,6 +203,7 @@ enum ssl_private_key_result_t ssl_private_key_sign(
|
|
203
203
|
SSL *const ssl = hs->ssl;
|
204
204
|
const SSL_PRIVATE_KEY_METHOD *key_method = hs->config->cert->key_method;
|
205
205
|
EVP_PKEY *privatekey = hs->config->cert->privatekey.get();
|
206
|
+
assert(!hs->can_release_private_key);
|
206
207
|
if (ssl_signing_with_dc(hs)) {
|
207
208
|
key_method = hs->config->cert->dc_key_method;
|
208
209
|
privatekey = hs->config->cert->dc_privatekey.get();
|
@@ -254,6 +255,7 @@ enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
|
|
254
255
|
size_t max_out,
|
255
256
|
Span<const uint8_t> in) {
|
256
257
|
SSL *const ssl = hs->ssl;
|
258
|
+
assert(!hs->can_release_private_key);
|
257
259
|
if (hs->config->cert->key_method != NULL) {
|
258
260
|
enum ssl_private_key_result_t ret;
|
259
261
|
if (hs->pending_private_key_op) {
|
@@ -350,19 +350,19 @@ const EVP_MD *ssl_session_get_digest(const SSL_SESSION *session) {
|
|
350
350
|
session->cipher);
|
351
351
|
}
|
352
352
|
|
353
|
-
|
353
|
+
bool ssl_get_new_session(SSL_HANDSHAKE *hs) {
|
354
354
|
SSL *const ssl = hs->ssl;
|
355
355
|
if (ssl->mode & SSL_MODE_NO_SESSION_CREATION) {
|
356
356
|
OPENSSL_PUT_ERROR(SSL, SSL_R_SESSION_MAY_NOT_BE_CREATED);
|
357
|
-
return
|
357
|
+
return false;
|
358
358
|
}
|
359
359
|
|
360
360
|
UniquePtr<SSL_SESSION> session = ssl_session_new(ssl->ctx->x509_method);
|
361
361
|
if (session == NULL) {
|
362
|
-
return
|
362
|
+
return false;
|
363
363
|
}
|
364
364
|
|
365
|
-
session->is_server =
|
365
|
+
session->is_server = ssl->server;
|
366
366
|
session->ssl_version = ssl->version;
|
367
367
|
session->is_quic = ssl->quic_method != nullptr;
|
368
368
|
|
@@ -384,24 +384,9 @@ int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server) {
|
|
384
384
|
session->auth_timeout = ssl->session_ctx->session_timeout;
|
385
385
|
}
|
386
386
|
|
387
|
-
if (is_server) {
|
388
|
-
if (hs->ticket_expected || version >= TLS1_3_VERSION) {
|
389
|
-
// Don't set session IDs for sessions resumed with tickets. This will keep
|
390
|
-
// them out of the session cache.
|
391
|
-
session->session_id_length = 0;
|
392
|
-
} else {
|
393
|
-
session->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
|
394
|
-
if (!RAND_bytes(session->session_id, session->session_id_length)) {
|
395
|
-
return 0;
|
396
|
-
}
|
397
|
-
}
|
398
|
-
} else {
|
399
|
-
session->session_id_length = 0;
|
400
|
-
}
|
401
|
-
|
402
387
|
if (hs->config->cert->sid_ctx_length > sizeof(session->sid_ctx)) {
|
403
388
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
404
|
-
return
|
389
|
+
return false;
|
405
390
|
}
|
406
391
|
OPENSSL_memcpy(session->sid_ctx, hs->config->cert->sid_ctx,
|
407
392
|
hs->config->cert->sid_ctx_length);
|
@@ -413,7 +398,7 @@ int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server) {
|
|
413
398
|
|
414
399
|
hs->new_session = std::move(session);
|
415
400
|
ssl_set_session(ssl, NULL);
|
416
|
-
return
|
401
|
+
return true;
|
417
402
|
}
|
418
403
|
|
419
404
|
int ssl_ctx_rotate_ticket_encryption_key(SSL_CTX *ctx) {
|
@@ -1019,7 +1004,8 @@ int SSL_SESSION_should_be_single_use(const SSL_SESSION *session) {
|
|
1019
1004
|
}
|
1020
1005
|
|
1021
1006
|
int SSL_SESSION_is_resumable(const SSL_SESSION *session) {
|
1022
|
-
return !session->not_resumable
|
1007
|
+
return !session->not_resumable &&
|
1008
|
+
(session->session_id_length != 0 || !session->ticket.empty());
|
1023
1009
|
}
|
1024
1010
|
|
1025
1011
|
int SSL_SESSION_has_ticket(const SSL_SESSION *session) {
|
@@ -1298,12 +1284,3 @@ void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type,
|
|
1298
1284
|
int value) {
|
1299
1285
|
return ctx->info_callback;
|
1300
1286
|
}
|
1301
|
-
|
1302
|
-
void SSL_CTX_set_channel_id_cb(SSL_CTX *ctx,
|
1303
|
-
void (*cb)(SSL *ssl, EVP_PKEY **pkey)) {
|
1304
|
-
ctx->channel_id_cb = cb;
|
1305
|
-
}
|
1306
|
-
|
1307
|
-
void (*SSL_CTX_get_channel_id_cb(SSL_CTX *ctx))(SSL *ssl, EVP_PKEY **pkey) {
|
1308
|
-
return ctx->channel_id_cb;
|
1309
|
-
}
|
@@ -206,7 +206,8 @@ bool SSLTranscript::UpdateForHelloRetryRequest() {
|
|
206
206
|
return true;
|
207
207
|
}
|
208
208
|
|
209
|
-
bool SSLTranscript::CopyToHashContext(EVP_MD_CTX *ctx,
|
209
|
+
bool SSLTranscript::CopyToHashContext(EVP_MD_CTX *ctx,
|
210
|
+
const EVP_MD *digest) const {
|
210
211
|
const EVP_MD *transcript_digest = Digest();
|
211
212
|
if (transcript_digest != nullptr &&
|
212
213
|
EVP_MD_type(transcript_digest) == EVP_MD_type(digest)) {
|
@@ -237,7 +238,7 @@ bool SSLTranscript::Update(Span<const uint8_t> in) {
|
|
237
238
|
return true;
|
238
239
|
}
|
239
240
|
|
240
|
-
bool SSLTranscript::GetHash(uint8_t *out, size_t *out_len) {
|
241
|
+
bool SSLTranscript::GetHash(uint8_t *out, size_t *out_len) const {
|
241
242
|
ScopedEVP_MD_CTX ctx;
|
242
243
|
unsigned len;
|
243
244
|
if (!EVP_MD_CTX_copy_ex(ctx.get(), hash_.get()) ||
|
@@ -250,7 +251,7 @@ bool SSLTranscript::GetHash(uint8_t *out, size_t *out_len) {
|
|
250
251
|
|
251
252
|
bool SSLTranscript::GetFinishedMAC(uint8_t *out, size_t *out_len,
|
252
253
|
const SSL_SESSION *session,
|
253
|
-
bool from_server) {
|
254
|
+
bool from_server) const {
|
254
255
|
static const char kClientLabel[] = "client finished";
|
255
256
|
static const char kServerLabel[] = "server finished";
|
256
257
|
auto label = from_server
|
@@ -260,8 +260,8 @@ uint16_t ssl_protocol_version(const SSL *ssl) {
|
|
260
260
|
return version;
|
261
261
|
}
|
262
262
|
|
263
|
-
bool ssl_supports_version(SSL_HANDSHAKE *hs, uint16_t version) {
|
264
|
-
SSL *const ssl = hs->ssl;
|
263
|
+
bool ssl_supports_version(const SSL_HANDSHAKE *hs, uint16_t version) {
|
264
|
+
const SSL *const ssl = hs->ssl;
|
265
265
|
uint16_t protocol_version;
|
266
266
|
if (!ssl_method_supports_version(ssl->method, version) ||
|
267
267
|
!ssl_protocol_version_from_wire(&protocol_version, version) ||
|
@@ -273,9 +273,13 @@ bool ssl_supports_version(SSL_HANDSHAKE *hs, uint16_t version) {
|
|
273
273
|
return true;
|
274
274
|
}
|
275
275
|
|
276
|
-
bool ssl_add_supported_versions(SSL_HANDSHAKE *hs, CBB *cbb
|
276
|
+
bool ssl_add_supported_versions(const SSL_HANDSHAKE *hs, CBB *cbb,
|
277
|
+
uint16_t extra_min_version) {
|
277
278
|
for (uint16_t version : get_method_versions(hs->ssl->method)) {
|
279
|
+
uint16_t protocol_version;
|
278
280
|
if (ssl_supports_version(hs, version) &&
|
281
|
+
ssl_protocol_version_from_wire(&protocol_version, version) &&
|
282
|
+
protocol_version >= extra_min_version && //
|
279
283
|
!CBB_add_u16(cbb, version)) {
|
280
284
|
return false;
|
281
285
|
}
|
@@ -124,11 +124,11 @@
|
|
124
124
|
#include <openssl/err.h>
|
125
125
|
#include <openssl/evp.h>
|
126
126
|
#include <openssl/hmac.h>
|
127
|
+
#include <openssl/hpke.h>
|
127
128
|
#include <openssl/mem.h>
|
128
129
|
#include <openssl/nid.h>
|
129
130
|
#include <openssl/rand.h>
|
130
131
|
|
131
|
-
#include "../crypto/hpke/internal.h"
|
132
132
|
#include "../crypto/internal.h"
|
133
133
|
#include "internal.h"
|
134
134
|
|
@@ -209,11 +209,11 @@ static bool is_post_quantum_group(uint16_t id) {
|
|
209
209
|
}
|
210
210
|
|
211
211
|
bool ssl_client_hello_init(const SSL *ssl, SSL_CLIENT_HELLO *out,
|
212
|
-
const
|
212
|
+
Span<const uint8_t> body) {
|
213
213
|
OPENSSL_memset(out, 0, sizeof(*out));
|
214
214
|
out->ssl = const_cast<SSL *>(ssl);
|
215
|
-
out->client_hello =
|
216
|
-
out->client_hello_len =
|
215
|
+
out->client_hello = body.data();
|
216
|
+
out->client_hello_len = body.size();
|
217
217
|
|
218
218
|
CBS client_hello, random, session_id;
|
219
219
|
CBS_init(&client_hello, out->client_hello, out->client_hello_len);
|
@@ -405,6 +405,11 @@ bool tls1_check_group_id(const SSL_HANDSHAKE *hs, uint16_t group_id) {
|
|
405
405
|
return false;
|
406
406
|
}
|
407
407
|
|
408
|
+
// We internally assume zero is never allocated as a group ID.
|
409
|
+
if (group_id == 0) {
|
410
|
+
return false;
|
411
|
+
}
|
412
|
+
|
408
413
|
for (uint16_t supported : tls1_get_grouplist(hs)) {
|
409
414
|
if (supported == group_id) {
|
410
415
|
return true;
|
@@ -488,9 +493,7 @@ bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
488
493
|
return false;
|
489
494
|
}
|
490
495
|
|
491
|
-
// tls_extension represents a TLS extension that is handled internally.
|
492
|
-
// |init| function is called for each handshake, before any other functions of
|
493
|
-
// the extension. Then the add and parse callbacks are called as needed.
|
496
|
+
// tls_extension represents a TLS extension that is handled internally.
|
494
497
|
//
|
495
498
|
// The parse callbacks receive a |CBS| that contains the contents of the
|
496
499
|
// extension (i.e. not including the type and length bytes). If an extension is
|
@@ -500,14 +503,27 @@ bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
500
503
|
// The add callbacks receive a |CBB| to which the extension can be appended but
|
501
504
|
// the function is responsible for appending the type and length bytes too.
|
502
505
|
//
|
506
|
+
// |add_clienthello| may be called multiple times and must not mutate |hs|. It
|
507
|
+
// is additionally passed two output |CBB|s. If the extension is the same
|
508
|
+
// independent of the value of |type|, the callback may write to
|
509
|
+
// |out_compressible| instead of |out|. When serializing the ClientHelloInner,
|
510
|
+
// all compressible extensions will be made continguous and replaced with
|
511
|
+
// ech_outer_extensions when encrypted. When serializing the ClientHelloOuter
|
512
|
+
// or not offering ECH, |out| will be equal to |out_compressible|, so writing to
|
513
|
+
// |out_compressible| still works.
|
514
|
+
//
|
515
|
+
// Note the |parse_serverhello| and |add_serverhello| callbacks refer to the
|
516
|
+
// TLS 1.2 ServerHello. In TLS 1.3, these callbacks act on EncryptedExtensions,
|
517
|
+
// with ServerHello extensions handled elsewhere in the handshake.
|
518
|
+
//
|
503
519
|
// All callbacks return true for success and false for error. If a parse
|
504
520
|
// function returns zero then a fatal alert with value |*out_alert| will be
|
505
521
|
// sent. If |*out_alert| isn't set, then a |decode_error| alert will be sent.
|
506
522
|
struct tls_extension {
|
507
523
|
uint16_t value;
|
508
|
-
void (*init)(SSL_HANDSHAKE *hs);
|
509
524
|
|
510
|
-
bool (*add_clienthello)(SSL_HANDSHAKE *hs, CBB *out
|
525
|
+
bool (*add_clienthello)(const SSL_HANDSHAKE *hs, CBB *out,
|
526
|
+
CBB *out_compressible, ssl_client_hello_type_t type);
|
511
527
|
bool (*parse_serverhello)(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
512
528
|
CBS *contents);
|
513
529
|
|
@@ -542,10 +558,21 @@ static bool dont_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
542
558
|
//
|
543
559
|
// https://tools.ietf.org/html/rfc6066#section-3.
|
544
560
|
|
545
|
-
static bool ext_sni_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
546
|
-
|
547
|
-
|
548
|
-
|
561
|
+
static bool ext_sni_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
562
|
+
CBB *out_compressible,
|
563
|
+
ssl_client_hello_type_t type) {
|
564
|
+
const SSL *const ssl = hs->ssl;
|
565
|
+
// If offering ECH, send the public name instead of the configured name.
|
566
|
+
Span<const uint8_t> hostname;
|
567
|
+
if (type == ssl_client_hello_outer) {
|
568
|
+
hostname = hs->selected_ech_config->public_name;
|
569
|
+
} else {
|
570
|
+
if (ssl->hostname == nullptr) {
|
571
|
+
return true;
|
572
|
+
}
|
573
|
+
hostname =
|
574
|
+
MakeConstSpan(reinterpret_cast<const uint8_t *>(ssl->hostname.get()),
|
575
|
+
strlen(ssl->hostname.get()));
|
549
576
|
}
|
550
577
|
|
551
578
|
CBB contents, server_name_list, name;
|
@@ -554,8 +581,7 @@ static bool ext_sni_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
554
581
|
!CBB_add_u16_length_prefixed(&contents, &server_name_list) ||
|
555
582
|
!CBB_add_u8(&server_name_list, TLSEXT_NAMETYPE_host_name) ||
|
556
583
|
!CBB_add_u16_length_prefixed(&server_name_list, &name) ||
|
557
|
-
!CBB_add_bytes(&name, (
|
558
|
-
strlen(ssl->hostname.get())) ||
|
584
|
+
!CBB_add_bytes(&name, hostname.data(), hostname.size()) ||
|
559
585
|
!CBB_flush(out)) {
|
560
586
|
return false;
|
561
587
|
}
|
@@ -591,150 +617,59 @@ static bool ext_sni_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
591
617
|
}
|
592
618
|
|
593
619
|
|
594
|
-
// Encrypted
|
620
|
+
// Encrypted ClientHello (ECH)
|
595
621
|
//
|
596
|
-
// https://tools.ietf.org/html/draft-ietf-tls-esni-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
RAND_bytes(reinterpret_cast<uint8_t *>(&value), sizeof(value));
|
603
|
-
return value % (max - min + 1) + min;
|
604
|
-
}
|
605
|
-
|
606
|
-
static bool ext_ech_add_clienthello_grease(SSL_HANDSHAKE *hs, CBB *out) {
|
607
|
-
// If we are responding to the server's HelloRetryRequest, we repeat the bytes
|
608
|
-
// of the first ECH GREASE extension.
|
609
|
-
if (hs->ssl->s3->used_hello_retry_request) {
|
610
|
-
CBB ech_body;
|
611
|
-
if (!CBB_add_u16(out, TLSEXT_TYPE_encrypted_client_hello) ||
|
612
|
-
!CBB_add_u16_length_prefixed(out, &ech_body) ||
|
613
|
-
!CBB_add_bytes(&ech_body, hs->ech_grease.data(),
|
614
|
-
hs->ech_grease.size()) ||
|
615
|
-
!CBB_flush(out)) {
|
616
|
-
return false;
|
617
|
-
}
|
622
|
+
// https://tools.ietf.org/html/draft-ietf-tls-esni-10
|
623
|
+
|
624
|
+
static bool ext_ech_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
625
|
+
CBB *out_compressible,
|
626
|
+
ssl_client_hello_type_t type) {
|
627
|
+
if (type == ssl_client_hello_inner || hs->ech_client_bytes.empty()) {
|
618
628
|
return true;
|
619
629
|
}
|
620
630
|
|
621
|
-
|
622
|
-
const uint16_t aead_id = EVP_has_aes_hardware()
|
623
|
-
? EVP_HPKE_AEAD_AES_GCM_128
|
624
|
-
: EVP_HPKE_AEAD_CHACHA20POLY1305;
|
625
|
-
const EVP_AEAD *aead = EVP_HPKE_get_aead(aead_id);
|
626
|
-
assert(aead != nullptr);
|
627
|
-
|
628
|
-
uint8_t ech_config_id[8];
|
629
|
-
RAND_bytes(ech_config_id, sizeof(ech_config_id));
|
630
|
-
|
631
|
-
uint8_t ech_enc[X25519_PUBLIC_VALUE_LEN];
|
632
|
-
uint8_t private_key_unused[X25519_PRIVATE_KEY_LEN];
|
633
|
-
X25519_keypair(ech_enc, private_key_unused);
|
634
|
-
|
635
|
-
// To determine a plausible length for the payload, we first estimate the size
|
636
|
-
// of a typical EncodedClientHelloInner, with an expected use of
|
637
|
-
// outer_extensions. To limit the size, we only consider initial ClientHellos
|
638
|
-
// that do not offer resumption.
|
639
|
-
//
|
640
|
-
// Field/Extension Size
|
641
|
-
// ---------------------------------------------------------------------
|
642
|
-
// version 2
|
643
|
-
// random 32
|
644
|
-
// legacy_session_id 1
|
645
|
-
// - Has a U8 length prefix, but body is
|
646
|
-
// always empty string in inner CH.
|
647
|
-
// cipher_suites 2 (length prefix)
|
648
|
-
// - Only includes TLS 1.3 ciphers (3). 6
|
649
|
-
// - Maybe also include a GREASE suite. 2
|
650
|
-
// legacy_compression_methods 2 (length prefix)
|
651
|
-
// - Always has "null" compression method. 1
|
652
|
-
// extensions: 2 (length prefix)
|
653
|
-
// - encrypted_client_hello (empty). 4 (id + length prefix)
|
654
|
-
// - supported_versions. 4 (id + length prefix)
|
655
|
-
// - U8 length prefix 1
|
656
|
-
// - U16 protocol version (TLS 1.3) 2
|
657
|
-
// - outer_extensions. 4 (id + length prefix)
|
658
|
-
// - U8 length prefix 1
|
659
|
-
// - N extension IDs (2 bytes each):
|
660
|
-
// - key_share 2
|
661
|
-
// - sigalgs 2
|
662
|
-
// - sct 2
|
663
|
-
// - alpn 2
|
664
|
-
// - supported_groups. 2
|
665
|
-
// - status_request. 2
|
666
|
-
// - psk_key_exchange_modes. 2
|
667
|
-
// - compress_certificate. 2
|
668
|
-
//
|
669
|
-
// The server_name extension has an overhead of 9 bytes, plus up to an
|
670
|
-
// estimated 100 bytes of hostname. Rounding up to a multiple of 32 yields a
|
671
|
-
// range of 96 to 192. Note that this estimate does not fully capture
|
672
|
-
// optional extensions like GREASE, but the rounding gives some leeway.
|
673
|
-
|
674
|
-
uint8_t payload[EVP_AEAD_MAX_OVERHEAD + 192];
|
675
|
-
const size_t payload_len =
|
676
|
-
EVP_AEAD_max_overhead(aead) + 32 * random_size(96 / 32, 192 / 32);
|
677
|
-
assert(payload_len <= sizeof(payload));
|
678
|
-
RAND_bytes(payload, payload_len);
|
679
|
-
|
680
|
-
// Inside the TLS extension contents, write a serialized ClientEncryptedCH.
|
681
|
-
CBB ech_body, config_id_cbb, enc_cbb, payload_cbb;
|
631
|
+
CBB ech_body;
|
682
632
|
if (!CBB_add_u16(out, TLSEXT_TYPE_encrypted_client_hello) ||
|
683
633
|
!CBB_add_u16_length_prefixed(out, &ech_body) ||
|
684
|
-
!
|
685
|
-
|
686
|
-
!
|
687
|
-
!CBB_add_bytes(&config_id_cbb, ech_config_id, sizeof(ech_config_id)) ||
|
688
|
-
!CBB_add_u16_length_prefixed(&ech_body, &enc_cbb) ||
|
689
|
-
!CBB_add_bytes(&enc_cbb, ech_enc, OPENSSL_ARRAY_SIZE(ech_enc)) ||
|
690
|
-
!CBB_add_u16_length_prefixed(&ech_body, &payload_cbb) ||
|
691
|
-
!CBB_add_bytes(&payload_cbb, payload, payload_len) || //
|
692
|
-
!CBB_flush(&ech_body)) {
|
693
|
-
return false;
|
694
|
-
}
|
695
|
-
// Save the bytes of the newly-generated extension in case the server sends
|
696
|
-
// a HelloRetryRequest.
|
697
|
-
if (!hs->ech_grease.CopyFrom(
|
698
|
-
MakeConstSpan(CBB_data(&ech_body), CBB_len(&ech_body)))) {
|
634
|
+
!CBB_add_bytes(&ech_body, hs->ech_client_bytes.data(),
|
635
|
+
hs->ech_client_bytes.size()) ||
|
636
|
+
!CBB_flush(out)) {
|
699
637
|
return false;
|
700
638
|
}
|
701
|
-
return CBB_flush(out);
|
702
|
-
}
|
703
|
-
|
704
|
-
static bool ext_ech_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
705
|
-
if (hs->max_version < TLS1_3_VERSION) {
|
706
|
-
return true;
|
707
|
-
}
|
708
|
-
if (hs->config->ech_grease_enabled) {
|
709
|
-
return ext_ech_add_clienthello_grease(hs, out);
|
710
|
-
}
|
711
|
-
// Nothing to do, since we don't yet implement the non-GREASE parts of ECH.
|
712
639
|
return true;
|
713
640
|
}
|
714
641
|
|
715
642
|
static bool ext_ech_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
716
643
|
CBS *contents) {
|
644
|
+
SSL *const ssl = hs->ssl;
|
717
645
|
if (contents == NULL) {
|
718
646
|
return true;
|
719
647
|
}
|
720
648
|
|
721
|
-
//
|
722
|
-
|
723
|
-
if (
|
724
|
-
|
725
|
-
|
726
|
-
*out_alert = SSL_AD_DECODE_ERROR;
|
649
|
+
// The ECH extension may not be sent in TLS 1.2 ServerHello, only TLS 1.3
|
650
|
+
// EncryptedExtension.
|
651
|
+
if (ssl_protocol_version(ssl) < TLS1_3_VERSION) {
|
652
|
+
*out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
|
653
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
|
727
654
|
return false;
|
728
655
|
}
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
656
|
+
|
657
|
+
// The server may only send retry configs in response to ClientHelloOuter (or
|
658
|
+
// ECH GREASE), not ClientHelloInner. The unsolicited extension rule checks
|
659
|
+
// this implicitly because the ClientHelloInner has no encrypted_client_hello
|
660
|
+
// extension.
|
661
|
+
//
|
662
|
+
// TODO(https://crbug.com/boringssl/275): If
|
663
|
+
// https://github.com/tlswg/draft-ietf-tls-esni/pull/422 is merged, a later
|
664
|
+
// draft will fold encrypted_client_hello and ech_is_inner together. Then this
|
665
|
+
// assert should become a runtime check.
|
666
|
+
assert(!ssl->s3->ech_accept);
|
667
|
+
|
668
|
+
// TODO(https://crbug.com/boringssl/275): When the implementing the
|
669
|
+
// ClientHelloOuter flow, save the retry configs.
|
670
|
+
if (!ssl_is_valid_ech_config_list(*contents)) {
|
671
|
+
*out_alert = SSL_AD_DECODE_ERROR;
|
672
|
+
return false;
|
738
673
|
}
|
739
674
|
return true;
|
740
675
|
}
|
@@ -748,7 +683,43 @@ static bool ext_ech_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
748
683
|
return true;
|
749
684
|
}
|
750
685
|
|
751
|
-
static bool
|
686
|
+
static bool ext_ech_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
687
|
+
SSL *const ssl = hs->ssl;
|
688
|
+
if (ssl_protocol_version(ssl) < TLS1_3_VERSION || //
|
689
|
+
ssl->s3->ech_accept || //
|
690
|
+
hs->ech_keys == nullptr) {
|
691
|
+
return true;
|
692
|
+
}
|
693
|
+
|
694
|
+
// Write the list of retry configs to |out|. Note |SSL_CTX_set1_ech_keys|
|
695
|
+
// ensures |ech_keys| contains at least one retry config.
|
696
|
+
CBB body, retry_configs;
|
697
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_encrypted_client_hello) ||
|
698
|
+
!CBB_add_u16_length_prefixed(out, &body) ||
|
699
|
+
!CBB_add_u16_length_prefixed(&body, &retry_configs)) {
|
700
|
+
return false;
|
701
|
+
}
|
702
|
+
for (const auto &config : hs->ech_keys->configs) {
|
703
|
+
if (!config->is_retry_config()) {
|
704
|
+
continue;
|
705
|
+
}
|
706
|
+
if (!CBB_add_bytes(&retry_configs, config->ech_config().raw.data(),
|
707
|
+
config->ech_config().raw.size())) {
|
708
|
+
return false;
|
709
|
+
}
|
710
|
+
}
|
711
|
+
return CBB_flush(out);
|
712
|
+
}
|
713
|
+
|
714
|
+
static bool ext_ech_is_inner_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
715
|
+
CBB *out_compressible,
|
716
|
+
ssl_client_hello_type_t type) {
|
717
|
+
if (type == ssl_client_hello_inner) {
|
718
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_ech_is_inner) ||
|
719
|
+
!CBB_add_u16(out, 0 /* empty extension */)) {
|
720
|
+
return false;
|
721
|
+
}
|
722
|
+
}
|
752
723
|
return true;
|
753
724
|
}
|
754
725
|
|
@@ -771,10 +742,13 @@ static bool ext_ech_is_inner_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
771
742
|
//
|
772
743
|
// https://tools.ietf.org/html/rfc5746
|
773
744
|
|
774
|
-
static bool ext_ri_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
775
|
-
|
745
|
+
static bool ext_ri_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
746
|
+
CBB *out_compressible,
|
747
|
+
ssl_client_hello_type_t type) {
|
748
|
+
const SSL *const ssl = hs->ssl;
|
776
749
|
// Renegotiation indication is not necessary in TLS 1.3.
|
777
|
-
if (hs->min_version >= TLS1_3_VERSION
|
750
|
+
if (hs->min_version >= TLS1_3_VERSION ||
|
751
|
+
type == ssl_client_hello_inner) {
|
778
752
|
return true;
|
779
753
|
}
|
780
754
|
|
@@ -936,9 +910,11 @@ static bool ext_ri_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
936
910
|
//
|
937
911
|
// https://tools.ietf.org/html/rfc7627
|
938
912
|
|
939
|
-
static bool ext_ems_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
913
|
+
static bool ext_ems_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
914
|
+
CBB *out_compressible,
|
915
|
+
ssl_client_hello_type_t type) {
|
940
916
|
// Extended master secret is not necessary in TLS 1.3.
|
941
|
-
if (hs->min_version >= TLS1_3_VERSION) {
|
917
|
+
if (hs->min_version >= TLS1_3_VERSION || type == ssl_client_hello_inner) {
|
942
918
|
return true;
|
943
919
|
}
|
944
920
|
|
@@ -1011,10 +987,12 @@ static bool ext_ems_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1011
987
|
//
|
1012
988
|
// https://tools.ietf.org/html/rfc5077
|
1013
989
|
|
1014
|
-
static bool ext_ticket_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1015
|
-
|
990
|
+
static bool ext_ticket_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
991
|
+
CBB *out_compressible,
|
992
|
+
ssl_client_hello_type_t type) {
|
993
|
+
const SSL *const ssl = hs->ssl;
|
1016
994
|
// TLS 1.3 uses a different ticket extension.
|
1017
|
-
if (hs->min_version >= TLS1_3_VERSION ||
|
995
|
+
if (hs->min_version >= TLS1_3_VERSION || type == ssl_client_hello_inner ||
|
1018
996
|
SSL_get_options(ssl) & SSL_OP_NO_TICKET) {
|
1019
997
|
return true;
|
1020
998
|
}
|
@@ -1089,17 +1067,19 @@ static bool ext_ticket_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1089
1067
|
//
|
1090
1068
|
// https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
|
1091
1069
|
|
1092
|
-
static bool ext_sigalgs_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1070
|
+
static bool ext_sigalgs_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1071
|
+
CBB *out_compressible,
|
1072
|
+
ssl_client_hello_type_t type) {
|
1093
1073
|
if (hs->max_version < TLS1_2_VERSION) {
|
1094
1074
|
return true;
|
1095
1075
|
}
|
1096
1076
|
|
1097
1077
|
CBB contents, sigalgs_cbb;
|
1098
|
-
if (!CBB_add_u16(
|
1099
|
-
!CBB_add_u16_length_prefixed(
|
1078
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_signature_algorithms) ||
|
1079
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
1100
1080
|
!CBB_add_u16_length_prefixed(&contents, &sigalgs_cbb) ||
|
1101
1081
|
!tls12_add_verify_sigalgs(hs, &sigalgs_cbb) ||
|
1102
|
-
!CBB_flush(
|
1082
|
+
!CBB_flush(out_compressible)) {
|
1103
1083
|
return false;
|
1104
1084
|
}
|
1105
1085
|
|
@@ -1128,18 +1108,20 @@ static bool ext_sigalgs_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1128
1108
|
//
|
1129
1109
|
// https://tools.ietf.org/html/rfc6066#section-8
|
1130
1110
|
|
1131
|
-
static bool ext_ocsp_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1111
|
+
static bool ext_ocsp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1112
|
+
CBB *out_compressible,
|
1113
|
+
ssl_client_hello_type_t type) {
|
1132
1114
|
if (!hs->config->ocsp_stapling_enabled) {
|
1133
1115
|
return true;
|
1134
1116
|
}
|
1135
1117
|
|
1136
1118
|
CBB contents;
|
1137
|
-
if (!CBB_add_u16(
|
1138
|
-
!CBB_add_u16_length_prefixed(
|
1119
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_status_request) ||
|
1120
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
1139
1121
|
!CBB_add_u8(&contents, TLSEXT_STATUSTYPE_ocsp) ||
|
1140
1122
|
!CBB_add_u16(&contents, 0 /* empty responder ID list */) ||
|
1141
1123
|
!CBB_add_u16(&contents, 0 /* empty request extensions */) ||
|
1142
|
-
!CBB_flush(
|
1124
|
+
!CBB_flush(out_compressible)) {
|
1143
1125
|
return false;
|
1144
1126
|
}
|
1145
1127
|
|
@@ -1210,11 +1192,16 @@ static bool ext_ocsp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1210
1192
|
//
|
1211
1193
|
// https://htmlpreview.github.io/?https://github.com/agl/technotes/blob/master/nextprotoneg.html
|
1212
1194
|
|
1213
|
-
static bool ext_npn_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1195
|
+
static bool ext_npn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1196
|
+
CBB *out_compressible,
|
1197
|
+
ssl_client_hello_type_t type) {
|
1198
|
+
const SSL *const ssl = hs->ssl;
|
1199
|
+
if (ssl->ctx->next_proto_select_cb == NULL ||
|
1200
|
+
// Do not allow NPN to change on renegotiation.
|
1201
|
+
ssl->s3->initial_handshake_complete ||
|
1202
|
+
// NPN is not defined in DTLS or TLS 1.3.
|
1203
|
+
SSL_is_dtls(ssl) || hs->min_version >= TLS1_3_VERSION ||
|
1204
|
+
type == ssl_client_hello_inner) {
|
1218
1205
|
return true;
|
1219
1206
|
}
|
1220
1207
|
|
@@ -1333,13 +1320,15 @@ static bool ext_npn_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1333
1320
|
//
|
1334
1321
|
// https://tools.ietf.org/html/rfc6962#section-3.3.1
|
1335
1322
|
|
1336
|
-
static bool ext_sct_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1323
|
+
static bool ext_sct_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1324
|
+
CBB *out_compressible,
|
1325
|
+
ssl_client_hello_type_t type) {
|
1337
1326
|
if (!hs->config->signed_cert_timestamps_enabled) {
|
1338
1327
|
return true;
|
1339
1328
|
}
|
1340
1329
|
|
1341
|
-
if (!CBB_add_u16(
|
1342
|
-
!CBB_add_u16(
|
1330
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_certificate_timestamp) ||
|
1331
|
+
!CBB_add_u16(out_compressible, 0 /* length */)) {
|
1343
1332
|
return false;
|
1344
1333
|
}
|
1345
1334
|
|
@@ -1424,8 +1413,10 @@ static bool ext_sct_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1424
1413
|
//
|
1425
1414
|
// https://tools.ietf.org/html/rfc7301
|
1426
1415
|
|
1427
|
-
static bool ext_alpn_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1428
|
-
|
1416
|
+
static bool ext_alpn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1417
|
+
CBB *out_compressible,
|
1418
|
+
ssl_client_hello_type_t type) {
|
1419
|
+
const SSL *const ssl = hs->ssl;
|
1429
1420
|
if (hs->config->alpn_client_proto_list.empty() && ssl->quic_method) {
|
1430
1421
|
// ALPN MUST be used with QUIC.
|
1431
1422
|
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_APPLICATION_PROTOCOL);
|
@@ -1438,12 +1429,13 @@ static bool ext_alpn_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1438
1429
|
}
|
1439
1430
|
|
1440
1431
|
CBB contents, proto_list;
|
1441
|
-
if (!CBB_add_u16(
|
1442
|
-
|
1432
|
+
if (!CBB_add_u16(out_compressible,
|
1433
|
+
TLSEXT_TYPE_application_layer_protocol_negotiation) ||
|
1434
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
1443
1435
|
!CBB_add_u16_length_prefixed(&contents, &proto_list) ||
|
1444
1436
|
!CBB_add_bytes(&proto_list, hs->config->alpn_client_proto_list.data(),
|
1445
1437
|
hs->config->alpn_client_proto_list.size()) ||
|
1446
|
-
!CBB_flush(
|
1438
|
+
!CBB_flush(out_compressible)) {
|
1447
1439
|
return false;
|
1448
1440
|
}
|
1449
1441
|
|
@@ -1499,6 +1491,22 @@ static bool ext_alpn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1499
1491
|
return true;
|
1500
1492
|
}
|
1501
1493
|
|
1494
|
+
bool ssl_is_valid_alpn_list(Span<const uint8_t> in) {
|
1495
|
+
CBS protocol_name_list = in;
|
1496
|
+
if (CBS_len(&protocol_name_list) == 0) {
|
1497
|
+
return false;
|
1498
|
+
}
|
1499
|
+
while (CBS_len(&protocol_name_list) > 0) {
|
1500
|
+
CBS protocol_name;
|
1501
|
+
if (!CBS_get_u8_length_prefixed(&protocol_name_list, &protocol_name) ||
|
1502
|
+
// Empty protocol names are forbidden.
|
1503
|
+
CBS_len(&protocol_name) == 0) {
|
1504
|
+
return false;
|
1505
|
+
}
|
1506
|
+
}
|
1507
|
+
return true;
|
1508
|
+
}
|
1509
|
+
|
1502
1510
|
bool ssl_is_alpn_protocol_allowed(const SSL_HANDSHAKE *hs,
|
1503
1511
|
Span<const uint8_t> protocol) {
|
1504
1512
|
if (hs->config->alpn_client_proto_list.empty()) {
|
@@ -1551,25 +1559,12 @@ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1551
1559
|
CBS protocol_name_list;
|
1552
1560
|
if (!CBS_get_u16_length_prefixed(&contents, &protocol_name_list) ||
|
1553
1561
|
CBS_len(&contents) != 0 ||
|
1554
|
-
|
1562
|
+
!ssl_is_valid_alpn_list(protocol_name_list)) {
|
1555
1563
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PARSE_TLSEXT);
|
1556
1564
|
*out_alert = SSL_AD_DECODE_ERROR;
|
1557
1565
|
return false;
|
1558
1566
|
}
|
1559
1567
|
|
1560
|
-
// Validate the protocol list.
|
1561
|
-
CBS protocol_name_list_copy = protocol_name_list;
|
1562
|
-
while (CBS_len(&protocol_name_list_copy) > 0) {
|
1563
|
-
CBS protocol_name;
|
1564
|
-
if (!CBS_get_u8_length_prefixed(&protocol_name_list_copy, &protocol_name) ||
|
1565
|
-
// Empty protocol names are forbidden.
|
1566
|
-
CBS_len(&protocol_name) == 0) {
|
1567
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_PARSE_TLSEXT);
|
1568
|
-
*out_alert = SSL_AD_DECODE_ERROR;
|
1569
|
-
return false;
|
1570
|
-
}
|
1571
|
-
}
|
1572
|
-
|
1573
1568
|
const uint8_t *selected;
|
1574
1569
|
uint8_t selected_len;
|
1575
1570
|
int ret = ssl->ctx->alpn_select_cb(
|
@@ -1635,18 +1630,16 @@ static bool ext_alpn_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1635
1630
|
//
|
1636
1631
|
// https://tools.ietf.org/html/draft-balfanz-tls-channelid-01
|
1637
1632
|
|
1638
|
-
static
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
SSL *const ssl = hs->ssl;
|
1644
|
-
if (!hs->config->channel_id_enabled || SSL_is_dtls(ssl)) {
|
1633
|
+
static bool ext_channel_id_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1634
|
+
CBB *out_compressible,
|
1635
|
+
ssl_client_hello_type_t type) {
|
1636
|
+
const SSL *const ssl = hs->ssl;
|
1637
|
+
if (!hs->config->channel_id_private || SSL_is_dtls(ssl)) {
|
1645
1638
|
return true;
|
1646
1639
|
}
|
1647
1640
|
|
1648
|
-
if (!CBB_add_u16(
|
1649
|
-
!CBB_add_u16(
|
1641
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_channel_id) ||
|
1642
|
+
!CBB_add_u16(out_compressible, 0 /* length */)) {
|
1650
1643
|
return false;
|
1651
1644
|
}
|
1652
1645
|
|
@@ -1656,19 +1649,18 @@ static bool ext_channel_id_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1656
1649
|
static bool ext_channel_id_parse_serverhello(SSL_HANDSHAKE *hs,
|
1657
1650
|
uint8_t *out_alert,
|
1658
1651
|
CBS *contents) {
|
1659
|
-
SSL *const ssl = hs->ssl;
|
1660
1652
|
if (contents == NULL) {
|
1661
1653
|
return true;
|
1662
1654
|
}
|
1663
1655
|
|
1664
|
-
assert(!SSL_is_dtls(ssl));
|
1665
|
-
assert(hs->config->
|
1656
|
+
assert(!SSL_is_dtls(hs->ssl));
|
1657
|
+
assert(hs->config->channel_id_private);
|
1666
1658
|
|
1667
1659
|
if (CBS_len(contents) != 0) {
|
1668
1660
|
return false;
|
1669
1661
|
}
|
1670
1662
|
|
1671
|
-
|
1663
|
+
hs->channel_id_negotiated = true;
|
1672
1664
|
return true;
|
1673
1665
|
}
|
1674
1666
|
|
@@ -1684,13 +1676,12 @@ static bool ext_channel_id_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
1684
1676
|
return false;
|
1685
1677
|
}
|
1686
1678
|
|
1687
|
-
|
1679
|
+
hs->channel_id_negotiated = true;
|
1688
1680
|
return true;
|
1689
1681
|
}
|
1690
1682
|
|
1691
1683
|
static bool ext_channel_id_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
1692
|
-
|
1693
|
-
if (!ssl->s3->channel_id_valid) {
|
1684
|
+
if (!hs->channel_id_negotiated) {
|
1694
1685
|
return true;
|
1695
1686
|
}
|
1696
1687
|
|
@@ -1707,22 +1698,21 @@ static bool ext_channel_id_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1707
1698
|
//
|
1708
1699
|
// https://tools.ietf.org/html/rfc5764
|
1709
1700
|
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
SSL *const ssl = hs->ssl;
|
1717
|
-
STACK_OF(SRTP_PROTECTION_PROFILE) *profiles = SSL_get_srtp_profiles(ssl);
|
1701
|
+
static bool ext_srtp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1702
|
+
CBB *out_compressible,
|
1703
|
+
ssl_client_hello_type_t type) {
|
1704
|
+
const SSL *const ssl = hs->ssl;
|
1705
|
+
const STACK_OF(SRTP_PROTECTION_PROFILE) *profiles =
|
1706
|
+
SSL_get_srtp_profiles(ssl);
|
1718
1707
|
if (profiles == NULL ||
|
1719
|
-
sk_SRTP_PROTECTION_PROFILE_num(profiles) == 0
|
1708
|
+
sk_SRTP_PROTECTION_PROFILE_num(profiles) == 0 ||
|
1709
|
+
!SSL_is_dtls(ssl)) {
|
1720
1710
|
return true;
|
1721
1711
|
}
|
1722
1712
|
|
1723
1713
|
CBB contents, profile_ids;
|
1724
|
-
if (!CBB_add_u16(
|
1725
|
-
!CBB_add_u16_length_prefixed(
|
1714
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_srtp) ||
|
1715
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
1726
1716
|
!CBB_add_u16_length_prefixed(&contents, &profile_ids)) {
|
1727
1717
|
return false;
|
1728
1718
|
}
|
@@ -1734,7 +1724,7 @@ static bool ext_srtp_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1734
1724
|
}
|
1735
1725
|
|
1736
1726
|
if (!CBB_add_u8(&contents, 0 /* empty use_mki value */) ||
|
1737
|
-
!CBB_flush(
|
1727
|
+
!CBB_flush(out_compressible)) {
|
1738
1728
|
return false;
|
1739
1729
|
}
|
1740
1730
|
|
@@ -1752,6 +1742,7 @@ static bool ext_srtp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1752
1742
|
// single uint16_t profile ID, then followed by a u8-prefixed srtp_mki field.
|
1753
1743
|
//
|
1754
1744
|
// See https://tools.ietf.org/html/rfc5764#section-4.1.1
|
1745
|
+
assert(SSL_is_dtls(ssl));
|
1755
1746
|
CBS profile_ids, srtp_mki;
|
1756
1747
|
uint16_t profile_id;
|
1757
1748
|
if (!CBS_get_u16_length_prefixed(contents, &profile_ids) ||
|
@@ -1770,11 +1761,8 @@ static bool ext_srtp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1770
1761
|
return false;
|
1771
1762
|
}
|
1772
1763
|
|
1773
|
-
|
1774
|
-
|
1775
|
-
// Check to see if the server gave us something we support (and presumably
|
1776
|
-
// offered).
|
1777
|
-
for (const SRTP_PROTECTION_PROFILE *profile : profiles) {
|
1764
|
+
// Check to see if the server gave us something we support and offered.
|
1765
|
+
for (const SRTP_PROTECTION_PROFILE *profile : SSL_get_srtp_profiles(ssl)) {
|
1778
1766
|
if (profile->id == profile_id) {
|
1779
1767
|
ssl->s3->srtp_profile = profile;
|
1780
1768
|
return true;
|
@@ -1789,7 +1777,8 @@ static bool ext_srtp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1789
1777
|
static bool ext_srtp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
1790
1778
|
CBS *contents) {
|
1791
1779
|
SSL *const ssl = hs->ssl;
|
1792
|
-
|
1780
|
+
// DTLS-SRTP is only defined for DTLS.
|
1781
|
+
if (contents == NULL || !SSL_is_dtls(ssl)) {
|
1793
1782
|
return true;
|
1794
1783
|
}
|
1795
1784
|
|
@@ -1833,6 +1822,7 @@ static bool ext_srtp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1833
1822
|
return true;
|
1834
1823
|
}
|
1835
1824
|
|
1825
|
+
assert(SSL_is_dtls(ssl));
|
1836
1826
|
CBB contents, profile_ids;
|
1837
1827
|
if (!CBB_add_u16(out, TLSEXT_TYPE_srtp) ||
|
1838
1828
|
!CBB_add_u16_length_prefixed(out, &contents) ||
|
@@ -1851,7 +1841,7 @@ static bool ext_srtp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1851
1841
|
//
|
1852
1842
|
// https://tools.ietf.org/html/rfc4492#section-5.1.2
|
1853
1843
|
|
1854
|
-
static bool ext_ec_point_add_extension(SSL_HANDSHAKE *hs, CBB *out) {
|
1844
|
+
static bool ext_ec_point_add_extension(const SSL_HANDSHAKE *hs, CBB *out) {
|
1855
1845
|
CBB contents, formats;
|
1856
1846
|
if (!CBB_add_u16(out, TLSEXT_TYPE_ec_point_formats) ||
|
1857
1847
|
!CBB_add_u16_length_prefixed(out, &contents) ||
|
@@ -1864,9 +1854,11 @@ static bool ext_ec_point_add_extension(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1864
1854
|
return true;
|
1865
1855
|
}
|
1866
1856
|
|
1867
|
-
static bool ext_ec_point_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
1857
|
+
static bool ext_ec_point_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
1858
|
+
CBB *out_compressible,
|
1859
|
+
ssl_client_hello_type_t type) {
|
1868
1860
|
// The point format extension is unnecessary in TLS 1.3.
|
1869
|
-
if (hs->min_version >= TLS1_3_VERSION) {
|
1861
|
+
if (hs->min_version >= TLS1_3_VERSION || type == ssl_client_hello_inner) {
|
1870
1862
|
return true;
|
1871
1863
|
}
|
1872
1864
|
|
@@ -1932,10 +1924,37 @@ static bool ext_ec_point_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1932
1924
|
//
|
1933
1925
|
// https://tools.ietf.org/html/rfc8446#section-4.2.11
|
1934
1926
|
|
1935
|
-
static
|
1936
|
-
|
1927
|
+
static bool should_offer_psk(const SSL_HANDSHAKE *hs,
|
1928
|
+
ssl_client_hello_type_t type) {
|
1929
|
+
const SSL *const ssl = hs->ssl;
|
1937
1930
|
if (hs->max_version < TLS1_3_VERSION || ssl->session == nullptr ||
|
1938
|
-
ssl_session_protocol_version(ssl->session.get()) < TLS1_3_VERSION
|
1931
|
+
ssl_session_protocol_version(ssl->session.get()) < TLS1_3_VERSION ||
|
1932
|
+
// The ClientHelloOuter cannot include the PSK extension.
|
1933
|
+
//
|
1934
|
+
// TODO(https://crbug.com/boringssl/275): draft-ietf-tls-esni-10 mandates
|
1935
|
+
// this, but it risks breaking the ClientHelloOuter flow on 0-RTT reject.
|
1936
|
+
// Later drafts will recommend including a placeholder one, at which point
|
1937
|
+
// we will need to synthesize a ticket. See
|
1938
|
+
// https://github.com/tlswg/draft-ietf-tls-esni/issues/408
|
1939
|
+
type == ssl_client_hello_outer) {
|
1940
|
+
return false;
|
1941
|
+
}
|
1942
|
+
|
1943
|
+
// Per RFC 8446 section 4.1.4, skip offering the session if the selected
|
1944
|
+
// cipher in HelloRetryRequest does not match. This avoids performing the
|
1945
|
+
// transcript hash transformation for multiple hashes.
|
1946
|
+
if (ssl->s3->used_hello_retry_request &&
|
1947
|
+
ssl->session->cipher->algorithm_prf != hs->new_cipher->algorithm_prf) {
|
1948
|
+
return false;
|
1949
|
+
}
|
1950
|
+
|
1951
|
+
return true;
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
static size_t ext_pre_shared_key_clienthello_length(
|
1955
|
+
const SSL_HANDSHAKE *hs, ssl_client_hello_type_t type) {
|
1956
|
+
const SSL *const ssl = hs->ssl;
|
1957
|
+
if (!should_offer_psk(hs, type)) {
|
1939
1958
|
return 0;
|
1940
1959
|
}
|
1941
1960
|
|
@@ -1943,19 +1962,12 @@ static size_t ext_pre_shared_key_clienthello_length(SSL_HANDSHAKE *hs) {
|
|
1943
1962
|
return 15 + ssl->session->ticket.size() + binder_len;
|
1944
1963
|
}
|
1945
1964
|
|
1946
|
-
static bool ext_pre_shared_key_add_clienthello(SSL_HANDSHAKE *hs,
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
}
|
1953
|
-
|
1954
|
-
// Per RFC 8446 section 4.1.4, skip offering the session if the selected
|
1955
|
-
// cipher in HelloRetryRequest does not match. This avoids performing the
|
1956
|
-
// transcript hash transformation for multiple hashes.
|
1957
|
-
if (ssl->s3 && ssl->s3->used_hello_retry_request &&
|
1958
|
-
ssl->session->cipher->algorithm_prf != hs->new_cipher->algorithm_prf) {
|
1965
|
+
static bool ext_pre_shared_key_add_clienthello(const SSL_HANDSHAKE *hs,
|
1966
|
+
CBB *out, bool *out_needs_binder,
|
1967
|
+
ssl_client_hello_type_t type) {
|
1968
|
+
const SSL *const ssl = hs->ssl;
|
1969
|
+
*out_needs_binder = false;
|
1970
|
+
if (!should_offer_psk(hs, type)) {
|
1959
1971
|
return true;
|
1960
1972
|
}
|
1961
1973
|
|
@@ -1983,7 +1995,7 @@ static bool ext_pre_shared_key_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1983
1995
|
return false;
|
1984
1996
|
}
|
1985
1997
|
|
1986
|
-
|
1998
|
+
*out_needs_binder = true;
|
1987
1999
|
return CBB_flush(out);
|
1988
2000
|
}
|
1989
2001
|
|
@@ -2096,21 +2108,22 @@ bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2096
2108
|
//
|
2097
2109
|
// https://tools.ietf.org/html/rfc8446#section-4.2.9
|
2098
2110
|
|
2099
|
-
static bool ext_psk_key_exchange_modes_add_clienthello(
|
2100
|
-
|
2111
|
+
static bool ext_psk_key_exchange_modes_add_clienthello(
|
2112
|
+
const SSL_HANDSHAKE *hs, CBB *out, CBB *out_compressible,
|
2113
|
+
ssl_client_hello_type_t type) {
|
2101
2114
|
if (hs->max_version < TLS1_3_VERSION) {
|
2102
2115
|
return true;
|
2103
2116
|
}
|
2104
2117
|
|
2105
2118
|
CBB contents, ke_modes;
|
2106
|
-
if (!CBB_add_u16(
|
2107
|
-
!CBB_add_u16_length_prefixed(
|
2119
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_psk_key_exchange_modes) ||
|
2120
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
2108
2121
|
!CBB_add_u8_length_prefixed(&contents, &ke_modes) ||
|
2109
2122
|
!CBB_add_u8(&ke_modes, SSL_PSK_DHE_KE)) {
|
2110
2123
|
return false;
|
2111
2124
|
}
|
2112
2125
|
|
2113
|
-
return CBB_flush(
|
2126
|
+
return CBB_flush(out_compressible);
|
2114
2127
|
}
|
2115
2128
|
|
2116
2129
|
static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
|
@@ -2140,23 +2153,10 @@ static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
2140
2153
|
//
|
2141
2154
|
// https://tools.ietf.org/html/rfc8446#section-4.2.10
|
2142
2155
|
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
const SSL_HANDSHAKE *hs, Span<const uint8_t> *out_settings,
|
2148
|
-
Span<const uint8_t> protocol) {
|
2149
|
-
for (const ALPSConfig &config : hs->config->alps_configs) {
|
2150
|
-
if (protocol == config.protocol) {
|
2151
|
-
*out_settings = config.settings;
|
2152
|
-
return true;
|
2153
|
-
}
|
2154
|
-
}
|
2155
|
-
return false;
|
2156
|
-
}
|
2157
|
-
|
2158
|
-
static bool ext_early_data_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
2159
|
-
SSL *const ssl = hs->ssl;
|
2156
|
+
static bool ext_early_data_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
2157
|
+
CBB *out_compressible,
|
2158
|
+
ssl_client_hello_type_t type) {
|
2159
|
+
const SSL *const ssl = hs->ssl;
|
2160
2160
|
// The second ClientHello never offers early data, and we must have already
|
2161
2161
|
// filled in |early_data_reason| by this point.
|
2162
2162
|
if (ssl->s3->used_hello_retry_request) {
|
@@ -2164,56 +2164,20 @@ static bool ext_early_data_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2164
2164
|
return true;
|
2165
2165
|
}
|
2166
2166
|
|
2167
|
-
if (!
|
2168
|
-
ssl->s3->early_data_reason = ssl_early_data_disabled;
|
2169
|
-
return true;
|
2170
|
-
}
|
2171
|
-
|
2172
|
-
if (hs->max_version < TLS1_3_VERSION) {
|
2173
|
-
// We discard inapplicable sessions, so this is redundant with the session
|
2174
|
-
// checks below, but we check give a more useful reason.
|
2175
|
-
ssl->s3->early_data_reason = ssl_early_data_protocol_version;
|
2176
|
-
return true;
|
2177
|
-
}
|
2178
|
-
|
2179
|
-
if (ssl->session == nullptr) {
|
2180
|
-
ssl->s3->early_data_reason = ssl_early_data_no_session_offered;
|
2181
|
-
return true;
|
2182
|
-
}
|
2183
|
-
|
2184
|
-
if (ssl_session_protocol_version(ssl->session.get()) < TLS1_3_VERSION ||
|
2185
|
-
ssl->session->ticket_max_early_data == 0) {
|
2186
|
-
ssl->s3->early_data_reason = ssl_early_data_unsupported_for_session;
|
2167
|
+
if (!hs->early_data_offered) {
|
2187
2168
|
return true;
|
2188
2169
|
}
|
2189
2170
|
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
if (ssl->session->has_application_settings) {
|
2201
|
-
Span<const uint8_t> settings;
|
2202
|
-
if (!ssl_get_local_application_settings(hs, &settings,
|
2203
|
-
ssl->session->early_alpn) ||
|
2204
|
-
settings != ssl->session->local_application_settings) {
|
2205
|
-
ssl->s3->early_data_reason = ssl_early_data_alps_mismatch;
|
2206
|
-
return true;
|
2207
|
-
}
|
2208
|
-
}
|
2209
|
-
}
|
2210
|
-
|
2211
|
-
// |early_data_reason| will be filled in later when the server responds.
|
2212
|
-
hs->early_data_offered = true;
|
2213
|
-
|
2214
|
-
if (!CBB_add_u16(out, TLSEXT_TYPE_early_data) ||
|
2215
|
-
!CBB_add_u16(out, 0) ||
|
2216
|
-
!CBB_flush(out)) {
|
2171
|
+
// If offering ECH, the extension only applies to ClientHelloInner, but we
|
2172
|
+
// send the extension in both ClientHellos. This ensures that, if the server
|
2173
|
+
// handshakes with ClientHelloOuter, it can skip past early data. See
|
2174
|
+
// https://github.com/tlswg/draft-ietf-tls-esni/pull/415
|
2175
|
+
//
|
2176
|
+
// TODO(https://crbug.com/boringssl/275): Replace this with a reference to the
|
2177
|
+
// right section in the next draft.
|
2178
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_early_data) ||
|
2179
|
+
!CBB_add_u16(out_compressible, 0) ||
|
2180
|
+
!CBB_flush(out_compressible)) {
|
2217
2181
|
return false;
|
2218
2182
|
}
|
2219
2183
|
|
@@ -2294,43 +2258,33 @@ static bool ext_early_data_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2294
2258
|
//
|
2295
2259
|
// https://tools.ietf.org/html/rfc8446#section-4.2.8
|
2296
2260
|
|
2297
|
-
|
2261
|
+
bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id) {
|
2298
2262
|
SSL *const ssl = hs->ssl;
|
2263
|
+
hs->key_shares[0].reset();
|
2264
|
+
hs->key_shares[1].reset();
|
2265
|
+
hs->key_share_bytes.Reset();
|
2266
|
+
|
2299
2267
|
if (hs->max_version < TLS1_3_VERSION) {
|
2300
2268
|
return true;
|
2301
2269
|
}
|
2302
2270
|
|
2303
|
-
|
2304
|
-
if (!
|
2305
|
-
!CBB_add_u16_length_prefixed(out, &contents) ||
|
2306
|
-
!CBB_add_u16_length_prefixed(&contents, &kse_bytes)) {
|
2271
|
+
bssl::ScopedCBB cbb;
|
2272
|
+
if (!CBB_init(cbb.get(), 64)) {
|
2307
2273
|
return false;
|
2308
2274
|
}
|
2309
2275
|
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
if (group_id == 0 &&
|
2316
|
-
!CBB_add_bytes(&kse_bytes, hs->key_share_bytes.data(),
|
2317
|
-
hs->key_share_bytes.size())) {
|
2318
|
-
return false;
|
2319
|
-
}
|
2320
|
-
hs->key_share_bytes.Reset();
|
2321
|
-
if (group_id == 0) {
|
2322
|
-
return CBB_flush(out);
|
2323
|
-
}
|
2324
|
-
} else {
|
2325
|
-
// Add a fake group. See draft-davidben-tls-grease-01.
|
2326
|
-
if (ssl->ctx->grease_enabled &&
|
2327
|
-
(!CBB_add_u16(&kse_bytes,
|
2328
|
-
ssl_get_grease_value(hs, ssl_grease_group)) ||
|
2329
|
-
!CBB_add_u16(&kse_bytes, 1 /* length */) ||
|
2330
|
-
!CBB_add_u8(&kse_bytes, 0 /* one byte key share */))) {
|
2276
|
+
if (override_group_id == 0 && ssl->ctx->grease_enabled) {
|
2277
|
+
// Add a fake group. See RFC 8701.
|
2278
|
+
if (!CBB_add_u16(cbb.get(), ssl_get_grease_value(hs, ssl_grease_group)) ||
|
2279
|
+
!CBB_add_u16(cbb.get(), 1 /* length */) ||
|
2280
|
+
!CBB_add_u8(cbb.get(), 0 /* one byte key share */)) {
|
2331
2281
|
return false;
|
2332
2282
|
}
|
2283
|
+
}
|
2333
2284
|
|
2285
|
+
uint16_t group_id = override_group_id;
|
2286
|
+
uint16_t second_group_id = 0;
|
2287
|
+
if (override_group_id == 0) {
|
2334
2288
|
// Predict the most preferred group.
|
2335
2289
|
Span<const uint16_t> groups = tls1_get_grouplist(hs);
|
2336
2290
|
if (groups.empty()) {
|
@@ -2350,34 +2304,45 @@ static bool ext_key_share_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2350
2304
|
|
2351
2305
|
CBB key_exchange;
|
2352
2306
|
hs->key_shares[0] = SSLKeyShare::Create(group_id);
|
2353
|
-
if (!hs->key_shares[0] ||
|
2354
|
-
!CBB_add_u16(
|
2355
|
-
!CBB_add_u16_length_prefixed(
|
2356
|
-
!hs->key_shares[0]->Offer(&key_exchange)
|
2357
|
-
!CBB_flush(&kse_bytes)) {
|
2307
|
+
if (!hs->key_shares[0] || //
|
2308
|
+
!CBB_add_u16(cbb.get(), group_id) ||
|
2309
|
+
!CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) ||
|
2310
|
+
!hs->key_shares[0]->Offer(&key_exchange)) {
|
2358
2311
|
return false;
|
2359
2312
|
}
|
2360
2313
|
|
2361
2314
|
if (second_group_id != 0) {
|
2362
2315
|
hs->key_shares[1] = SSLKeyShare::Create(second_group_id);
|
2363
|
-
if (!hs->key_shares[1] ||
|
2364
|
-
!CBB_add_u16(
|
2365
|
-
!CBB_add_u16_length_prefixed(
|
2366
|
-
!hs->key_shares[1]->Offer(&key_exchange)
|
2367
|
-
!CBB_flush(&kse_bytes)) {
|
2316
|
+
if (!hs->key_shares[1] || //
|
2317
|
+
!CBB_add_u16(cbb.get(), second_group_id) ||
|
2318
|
+
!CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) ||
|
2319
|
+
!hs->key_shares[1]->Offer(&key_exchange)) {
|
2368
2320
|
return false;
|
2369
2321
|
}
|
2370
2322
|
}
|
2371
2323
|
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2324
|
+
return CBBFinishArray(cbb.get(), &hs->key_share_bytes);
|
2325
|
+
}
|
2326
|
+
|
2327
|
+
static bool ext_key_share_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
2328
|
+
CBB *out_compressible,
|
2329
|
+
ssl_client_hello_type_t type) {
|
2330
|
+
if (hs->max_version < TLS1_3_VERSION) {
|
2331
|
+
return true;
|
2332
|
+
}
|
2333
|
+
|
2334
|
+
assert(!hs->key_share_bytes.empty());
|
2335
|
+
CBB contents, kse_bytes;
|
2336
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_key_share) ||
|
2337
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
2338
|
+
!CBB_add_u16_length_prefixed(&contents, &kse_bytes) ||
|
2339
|
+
!CBB_add_bytes(&kse_bytes, hs->key_share_bytes.data(),
|
2340
|
+
hs->key_share_bytes.size()) ||
|
2341
|
+
!CBB_flush(out_compressible)) {
|
2377
2342
|
return false;
|
2378
2343
|
}
|
2379
2344
|
|
2380
|
-
return
|
2345
|
+
return true;
|
2381
2346
|
}
|
2382
2347
|
|
2383
2348
|
bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
|
@@ -2415,25 +2380,29 @@ bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
2415
2380
|
}
|
2416
2381
|
|
2417
2382
|
bool ssl_ext_key_share_parse_clienthello(SSL_HANDSHAKE *hs, bool *out_found,
|
2418
|
-
|
2419
|
-
uint8_t *out_alert,
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2383
|
+
Span<const uint8_t> *out_peer_key,
|
2384
|
+
uint8_t *out_alert,
|
2385
|
+
const SSL_CLIENT_HELLO *client_hello) {
|
2386
|
+
// We only support connections that include an ECDHE key exchange.
|
2387
|
+
CBS contents;
|
2388
|
+
if (!ssl_client_hello_get_extension(client_hello, &contents,
|
2389
|
+
TLSEXT_TYPE_key_share)) {
|
2390
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_KEY_SHARE);
|
2391
|
+
*out_alert = SSL_AD_MISSING_EXTENSION;
|
2425
2392
|
return false;
|
2426
2393
|
}
|
2427
2394
|
|
2428
|
-
|
2429
|
-
|
2395
|
+
CBS key_shares;
|
2396
|
+
if (!CBS_get_u16_length_prefixed(&contents, &key_shares) ||
|
2397
|
+
CBS_len(&contents) != 0) {
|
2430
2398
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
2431
2399
|
return false;
|
2432
2400
|
}
|
2433
2401
|
|
2434
2402
|
// Find the corresponding key share.
|
2403
|
+
const uint16_t group_id = hs->new_session->group_id;
|
2435
2404
|
CBS peer_key;
|
2436
|
-
CBS_init(&peer_key,
|
2405
|
+
CBS_init(&peer_key, nullptr, 0);
|
2437
2406
|
while (CBS_len(&key_shares) > 0) {
|
2438
2407
|
uint16_t id;
|
2439
2408
|
CBS peer_key_tmp;
|
@@ -2456,47 +2425,24 @@ bool ssl_ext_key_share_parse_clienthello(SSL_HANDSHAKE *hs, bool *out_found,
|
|
2456
2425
|
}
|
2457
2426
|
}
|
2458
2427
|
|
2459
|
-
if (
|
2460
|
-
*
|
2461
|
-
out_secret->Reset();
|
2462
|
-
return true;
|
2428
|
+
if (out_peer_key != nullptr) {
|
2429
|
+
*out_peer_key = peer_key;
|
2463
2430
|
}
|
2464
|
-
|
2465
|
-
// Compute the DH secret.
|
2466
|
-
Array<uint8_t> secret;
|
2467
|
-
ScopedCBB public_key;
|
2468
|
-
UniquePtr<SSLKeyShare> key_share = SSLKeyShare::Create(group_id);
|
2469
|
-
if (!key_share ||
|
2470
|
-
!CBB_init(public_key.get(), 32) ||
|
2471
|
-
!key_share->Accept(public_key.get(), &secret, out_alert, peer_key) ||
|
2472
|
-
!CBBFinishArray(public_key.get(), &hs->ecdh_public_key)) {
|
2473
|
-
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
2474
|
-
return false;
|
2475
|
-
}
|
2476
|
-
|
2477
|
-
*out_secret = std::move(secret);
|
2478
|
-
*out_found = true;
|
2431
|
+
*out_found = CBS_len(&peer_key) != 0;
|
2479
2432
|
return true;
|
2480
2433
|
}
|
2481
2434
|
|
2482
|
-
bool ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out
|
2483
|
-
bool dry_run) {
|
2484
|
-
uint16_t group_id;
|
2435
|
+
bool ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
2485
2436
|
CBB kse_bytes, public_key;
|
2486
|
-
if (!
|
2487
|
-
!CBB_add_u16(out, TLSEXT_TYPE_key_share) ||
|
2437
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_key_share) ||
|
2488
2438
|
!CBB_add_u16_length_prefixed(out, &kse_bytes) ||
|
2489
|
-
!CBB_add_u16(&kse_bytes, group_id) ||
|
2439
|
+
!CBB_add_u16(&kse_bytes, hs->new_session->group_id) ||
|
2490
2440
|
!CBB_add_u16_length_prefixed(&kse_bytes, &public_key) ||
|
2491
2441
|
!CBB_add_bytes(&public_key, hs->ecdh_public_key.data(),
|
2492
2442
|
hs->ecdh_public_key.size()) ||
|
2493
2443
|
!CBB_flush(out)) {
|
2494
2444
|
return false;
|
2495
2445
|
}
|
2496
|
-
if (!dry_run) {
|
2497
|
-
hs->ecdh_public_key.Reset();
|
2498
|
-
hs->new_session->group_id = group_id;
|
2499
|
-
}
|
2500
2446
|
return true;
|
2501
2447
|
}
|
2502
2448
|
|
@@ -2505,12 +2451,20 @@ bool ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out,
|
|
2505
2451
|
//
|
2506
2452
|
// https://tools.ietf.org/html/rfc8446#section-4.2.1
|
2507
2453
|
|
2508
|
-
static bool ext_supported_versions_add_clienthello(
|
2509
|
-
|
2454
|
+
static bool ext_supported_versions_add_clienthello(
|
2455
|
+
const SSL_HANDSHAKE *hs, CBB *out, CBB *out_compressible,
|
2456
|
+
ssl_client_hello_type_t type) {
|
2457
|
+
const SSL *const ssl = hs->ssl;
|
2510
2458
|
if (hs->max_version <= TLS1_2_VERSION) {
|
2511
2459
|
return true;
|
2512
2460
|
}
|
2513
2461
|
|
2462
|
+
// supported_versions is compressible in ECH if ClientHelloOuter already
|
2463
|
+
// requires TLS 1.3. Otherwise the extensions differ in the older versions.
|
2464
|
+
if (hs->min_version >= TLS1_3_VERSION) {
|
2465
|
+
out = out_compressible;
|
2466
|
+
}
|
2467
|
+
|
2514
2468
|
CBB contents, versions;
|
2515
2469
|
if (!CBB_add_u16(out, TLSEXT_TYPE_supported_versions) ||
|
2516
2470
|
!CBB_add_u16_length_prefixed(out, &contents) ||
|
@@ -2518,13 +2472,16 @@ static bool ext_supported_versions_add_clienthello(SSL_HANDSHAKE *hs, CBB *out)
|
|
2518
2472
|
return false;
|
2519
2473
|
}
|
2520
2474
|
|
2521
|
-
// Add a fake version. See
|
2475
|
+
// Add a fake version. See RFC 8701.
|
2522
2476
|
if (ssl->ctx->grease_enabled &&
|
2523
2477
|
!CBB_add_u16(&versions, ssl_get_grease_value(hs, ssl_grease_version))) {
|
2524
2478
|
return false;
|
2525
2479
|
}
|
2526
2480
|
|
2527
|
-
|
2481
|
+
// Encrypted ClientHellos requires TLS 1.3 or later.
|
2482
|
+
uint16_t extra_min_version =
|
2483
|
+
type == ssl_client_hello_inner ? TLS1_3_VERSION : 0;
|
2484
|
+
if (!ssl_add_supported_versions(hs, &versions, extra_min_version) ||
|
2528
2485
|
!CBB_flush(out)) {
|
2529
2486
|
return false;
|
2530
2487
|
}
|
@@ -2537,22 +2494,22 @@ static bool ext_supported_versions_add_clienthello(SSL_HANDSHAKE *hs, CBB *out)
|
|
2537
2494
|
//
|
2538
2495
|
// https://tools.ietf.org/html/rfc8446#section-4.2.2
|
2539
2496
|
|
2540
|
-
static bool ext_cookie_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
2497
|
+
static bool ext_cookie_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
2498
|
+
CBB *out_compressible,
|
2499
|
+
ssl_client_hello_type_t type) {
|
2541
2500
|
if (hs->cookie.empty()) {
|
2542
2501
|
return true;
|
2543
2502
|
}
|
2544
2503
|
|
2545
2504
|
CBB contents, cookie;
|
2546
|
-
if (!CBB_add_u16(
|
2547
|
-
!CBB_add_u16_length_prefixed(
|
2505
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_cookie) ||
|
2506
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
2548
2507
|
!CBB_add_u16_length_prefixed(&contents, &cookie) ||
|
2549
2508
|
!CBB_add_bytes(&cookie, hs->cookie.data(), hs->cookie.size()) ||
|
2550
|
-
!CBB_flush(
|
2509
|
+
!CBB_flush(out_compressible)) {
|
2551
2510
|
return false;
|
2552
2511
|
}
|
2553
2512
|
|
2554
|
-
// The cookie is no longer needed in memory.
|
2555
|
-
hs->cookie.Reset();
|
2556
2513
|
return true;
|
2557
2514
|
}
|
2558
2515
|
|
@@ -2562,16 +2519,19 @@ static bool ext_cookie_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2562
2519
|
// https://tools.ietf.org/html/rfc4492#section-5.1.1
|
2563
2520
|
// https://tools.ietf.org/html/rfc8446#section-4.2.7
|
2564
2521
|
|
2565
|
-
static bool ext_supported_groups_add_clienthello(SSL_HANDSHAKE *hs,
|
2566
|
-
|
2522
|
+
static bool ext_supported_groups_add_clienthello(const SSL_HANDSHAKE *hs,
|
2523
|
+
CBB *out,
|
2524
|
+
CBB *out_compressible,
|
2525
|
+
ssl_client_hello_type_t type) {
|
2526
|
+
const SSL *const ssl = hs->ssl;
|
2567
2527
|
CBB contents, groups_bytes;
|
2568
|
-
if (!CBB_add_u16(
|
2569
|
-
!CBB_add_u16_length_prefixed(
|
2528
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_supported_groups) ||
|
2529
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
2570
2530
|
!CBB_add_u16_length_prefixed(&contents, &groups_bytes)) {
|
2571
2531
|
return false;
|
2572
2532
|
}
|
2573
2533
|
|
2574
|
-
// Add a fake group. See
|
2534
|
+
// Add a fake group. See RFC 8701.
|
2575
2535
|
if (ssl->ctx->grease_enabled &&
|
2576
2536
|
!CBB_add_u16(&groups_bytes,
|
2577
2537
|
ssl_get_grease_value(hs, ssl_grease_group))) {
|
@@ -2588,7 +2548,7 @@ static bool ext_supported_groups_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2588
2548
|
}
|
2589
2549
|
}
|
2590
2550
|
|
2591
|
-
return CBB_flush(
|
2551
|
+
return CBB_flush(out_compressible);
|
2592
2552
|
}
|
2593
2553
|
|
2594
2554
|
static bool ext_supported_groups_parse_serverhello(SSL_HANDSHAKE *hs,
|
@@ -2640,158 +2600,11 @@ static bool ext_supported_groups_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
2640
2600
|
return true;
|
2641
2601
|
}
|
2642
2602
|
|
2643
|
-
// Token Binding
|
2644
|
-
//
|
2645
|
-
// https://tools.ietf.org/html/draft-ietf-tokbind-negotiation-10
|
2646
|
-
|
2647
|
-
// The Token Binding version number currently matches the draft number of
|
2648
|
-
// draft-ietf-tokbind-protocol, and when published as an RFC it will be 0x0100.
|
2649
|
-
// Since there are no wire changes to the protocol from draft 13 through the
|
2650
|
-
// current draft (16), this implementation supports all versions in that range.
|
2651
|
-
static uint16_t kTokenBindingMaxVersion = 16;
|
2652
|
-
static uint16_t kTokenBindingMinVersion = 13;
|
2653
|
-
|
2654
|
-
static bool ext_token_binding_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
2655
|
-
SSL *const ssl = hs->ssl;
|
2656
|
-
if (hs->config->token_binding_params.empty() || SSL_is_dtls(ssl)) {
|
2657
|
-
return true;
|
2658
|
-
}
|
2659
|
-
|
2660
|
-
CBB contents, params;
|
2661
|
-
if (!CBB_add_u16(out, TLSEXT_TYPE_token_binding) ||
|
2662
|
-
!CBB_add_u16_length_prefixed(out, &contents) ||
|
2663
|
-
!CBB_add_u16(&contents, kTokenBindingMaxVersion) ||
|
2664
|
-
!CBB_add_u8_length_prefixed(&contents, ¶ms) ||
|
2665
|
-
!CBB_add_bytes(¶ms, hs->config->token_binding_params.data(),
|
2666
|
-
hs->config->token_binding_params.size()) ||
|
2667
|
-
!CBB_flush(out)) {
|
2668
|
-
return false;
|
2669
|
-
}
|
2670
|
-
|
2671
|
-
return true;
|
2672
|
-
}
|
2673
|
-
|
2674
|
-
static bool ext_token_binding_parse_serverhello(SSL_HANDSHAKE *hs,
|
2675
|
-
uint8_t *out_alert,
|
2676
|
-
CBS *contents) {
|
2677
|
-
SSL *const ssl = hs->ssl;
|
2678
|
-
if (contents == nullptr) {
|
2679
|
-
return true;
|
2680
|
-
}
|
2681
|
-
|
2682
|
-
CBS params_list;
|
2683
|
-
uint16_t version;
|
2684
|
-
uint8_t param;
|
2685
|
-
if (!CBS_get_u16(contents, &version) ||
|
2686
|
-
!CBS_get_u8_length_prefixed(contents, ¶ms_list) ||
|
2687
|
-
!CBS_get_u8(¶ms_list, ¶m) ||
|
2688
|
-
CBS_len(¶ms_list) > 0 ||
|
2689
|
-
CBS_len(contents) > 0) {
|
2690
|
-
*out_alert = SSL_AD_DECODE_ERROR;
|
2691
|
-
return false;
|
2692
|
-
}
|
2693
|
-
|
2694
|
-
// The server-negotiated version must be less than or equal to our version.
|
2695
|
-
if (version > kTokenBindingMaxVersion) {
|
2696
|
-
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
2697
|
-
return false;
|
2698
|
-
}
|
2699
|
-
|
2700
|
-
// If the server-selected version is less than what we support, then Token
|
2701
|
-
// Binding wasn't negotiated (but the extension was parsed successfully).
|
2702
|
-
if (version < kTokenBindingMinVersion) {
|
2703
|
-
return true;
|
2704
|
-
}
|
2705
|
-
|
2706
|
-
for (uint8_t config_param : hs->config->token_binding_params) {
|
2707
|
-
if (param == config_param) {
|
2708
|
-
ssl->s3->negotiated_token_binding_param = param;
|
2709
|
-
ssl->s3->token_binding_negotiated = true;
|
2710
|
-
return true;
|
2711
|
-
}
|
2712
|
-
}
|
2713
|
-
|
2714
|
-
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
2715
|
-
return false;
|
2716
|
-
}
|
2717
|
-
|
2718
|
-
// select_tb_param looks for the first token binding param in
|
2719
|
-
// |hs->ssl->token_binding_params| that is also in |params| and puts it in
|
2720
|
-
// |hs->ssl->negotiated_token_binding_param|. It returns true if a token binding
|
2721
|
-
// param is found, and false otherwise.
|
2722
|
-
static bool select_tb_param(SSL_HANDSHAKE *hs,
|
2723
|
-
Span<const uint8_t> peer_params) {
|
2724
|
-
for (uint8_t tb_param : hs->config->token_binding_params) {
|
2725
|
-
for (uint8_t peer_param : peer_params) {
|
2726
|
-
if (tb_param == peer_param) {
|
2727
|
-
hs->ssl->s3->negotiated_token_binding_param = tb_param;
|
2728
|
-
return true;
|
2729
|
-
}
|
2730
|
-
}
|
2731
|
-
}
|
2732
|
-
return false;
|
2733
|
-
}
|
2734
|
-
|
2735
|
-
static bool ext_token_binding_parse_clienthello(SSL_HANDSHAKE *hs,
|
2736
|
-
uint8_t *out_alert,
|
2737
|
-
CBS *contents) {
|
2738
|
-
SSL *const ssl = hs->ssl;
|
2739
|
-
if (contents == nullptr || hs->config->token_binding_params.empty()) {
|
2740
|
-
return true;
|
2741
|
-
}
|
2742
|
-
|
2743
|
-
CBS params;
|
2744
|
-
uint16_t version;
|
2745
|
-
if (!CBS_get_u16(contents, &version) ||
|
2746
|
-
!CBS_get_u8_length_prefixed(contents, ¶ms) ||
|
2747
|
-
CBS_len(¶ms) == 0 ||
|
2748
|
-
CBS_len(contents) > 0) {
|
2749
|
-
*out_alert = SSL_AD_DECODE_ERROR;
|
2750
|
-
return false;
|
2751
|
-
}
|
2752
|
-
|
2753
|
-
// If the client-selected version is less than what we support, then Token
|
2754
|
-
// Binding wasn't negotiated (but the extension was parsed successfully).
|
2755
|
-
if (version < kTokenBindingMinVersion) {
|
2756
|
-
return true;
|
2757
|
-
}
|
2758
|
-
|
2759
|
-
// If the client-selected version is higher than we support, use our max
|
2760
|
-
// version. Otherwise, use the client's version.
|
2761
|
-
hs->negotiated_token_binding_version =
|
2762
|
-
std::min(version, kTokenBindingMaxVersion);
|
2763
|
-
if (!select_tb_param(hs, params)) {
|
2764
|
-
return true;
|
2765
|
-
}
|
2766
|
-
|
2767
|
-
ssl->s3->token_binding_negotiated = true;
|
2768
|
-
return true;
|
2769
|
-
}
|
2770
|
-
|
2771
|
-
static bool ext_token_binding_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
2772
|
-
SSL *const ssl = hs->ssl;
|
2773
|
-
|
2774
|
-
if (!ssl->s3->token_binding_negotiated) {
|
2775
|
-
return true;
|
2776
|
-
}
|
2777
|
-
|
2778
|
-
CBB contents, params;
|
2779
|
-
if (!CBB_add_u16(out, TLSEXT_TYPE_token_binding) ||
|
2780
|
-
!CBB_add_u16_length_prefixed(out, &contents) ||
|
2781
|
-
!CBB_add_u16(&contents, hs->negotiated_token_binding_version) ||
|
2782
|
-
!CBB_add_u8_length_prefixed(&contents, ¶ms) ||
|
2783
|
-
!CBB_add_u8(¶ms, ssl->s3->negotiated_token_binding_param) ||
|
2784
|
-
!CBB_flush(out)) {
|
2785
|
-
return false;
|
2786
|
-
}
|
2787
|
-
|
2788
|
-
return true;
|
2789
|
-
}
|
2790
2603
|
|
2791
2604
|
// QUIC Transport Parameters
|
2792
2605
|
|
2793
2606
|
static bool ext_quic_transport_params_add_clienthello_impl(
|
2794
|
-
SSL_HANDSHAKE *hs, CBB *out, bool use_legacy_codepoint) {
|
2607
|
+
const SSL_HANDSHAKE *hs, CBB *out, bool use_legacy_codepoint) {
|
2795
2608
|
if (hs->config->quic_transport_params.empty() && !hs->ssl->quic_method) {
|
2796
2609
|
return true;
|
2797
2610
|
}
|
@@ -2808,7 +2621,7 @@ static bool ext_quic_transport_params_add_clienthello_impl(
|
|
2808
2621
|
return true;
|
2809
2622
|
}
|
2810
2623
|
|
2811
|
-
uint16_t extension_type =
|
2624
|
+
uint16_t extension_type = TLSEXT_TYPE_quic_transport_parameters;
|
2812
2625
|
if (hs->config->quic_use_legacy_codepoint) {
|
2813
2626
|
extension_type = TLSEXT_TYPE_quic_transport_parameters_legacy;
|
2814
2627
|
}
|
@@ -2824,16 +2637,18 @@ static bool ext_quic_transport_params_add_clienthello_impl(
|
|
2824
2637
|
return true;
|
2825
2638
|
}
|
2826
2639
|
|
2827
|
-
static bool ext_quic_transport_params_add_clienthello(
|
2828
|
-
|
2640
|
+
static bool ext_quic_transport_params_add_clienthello(
|
2641
|
+
const SSL_HANDSHAKE *hs, CBB *out, CBB *out_compressible,
|
2642
|
+
ssl_client_hello_type_t type) {
|
2829
2643
|
return ext_quic_transport_params_add_clienthello_impl(
|
2830
|
-
hs,
|
2644
|
+
hs, out_compressible, /*use_legacy_codepoint=*/false);
|
2831
2645
|
}
|
2832
2646
|
|
2833
|
-
static bool ext_quic_transport_params_add_clienthello_legacy(
|
2834
|
-
|
2647
|
+
static bool ext_quic_transport_params_add_clienthello_legacy(
|
2648
|
+
const SSL_HANDSHAKE *hs, CBB *out, CBB *out_compressible,
|
2649
|
+
ssl_client_hello_type_t type) {
|
2835
2650
|
return ext_quic_transport_params_add_clienthello_impl(
|
2836
|
-
hs,
|
2651
|
+
hs, out_compressible, /*use_legacy_codepoint=*/true);
|
2837
2652
|
}
|
2838
2653
|
|
2839
2654
|
static bool ext_quic_transport_params_parse_serverhello_impl(
|
@@ -2944,7 +2759,7 @@ static bool ext_quic_transport_params_add_serverhello_impl(
|
|
2944
2759
|
return true;
|
2945
2760
|
}
|
2946
2761
|
|
2947
|
-
uint16_t extension_type =
|
2762
|
+
uint16_t extension_type = TLSEXT_TYPE_quic_transport_parameters;
|
2948
2763
|
if (hs->config->quic_use_legacy_codepoint) {
|
2949
2764
|
extension_type = TLSEXT_TYPE_quic_transport_parameters_legacy;
|
2950
2765
|
}
|
@@ -2977,8 +2792,9 @@ static bool ext_quic_transport_params_add_serverhello_legacy(SSL_HANDSHAKE *hs,
|
|
2977
2792
|
//
|
2978
2793
|
// https://tools.ietf.org/html/draft-ietf-tls-subcerts
|
2979
2794
|
|
2980
|
-
static bool ext_delegated_credential_add_clienthello(
|
2981
|
-
|
2795
|
+
static bool ext_delegated_credential_add_clienthello(
|
2796
|
+
const SSL_HANDSHAKE *hs, CBB *out, CBB *out_compressible,
|
2797
|
+
ssl_client_hello_type_t type) {
|
2982
2798
|
return true;
|
2983
2799
|
}
|
2984
2800
|
|
@@ -3007,7 +2823,9 @@ static bool ext_delegated_credential_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
3007
2823
|
|
3008
2824
|
// Certificate compression
|
3009
2825
|
|
3010
|
-
static bool cert_compression_add_clienthello(SSL_HANDSHAKE *hs, CBB *out
|
2826
|
+
static bool cert_compression_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
2827
|
+
CBB *out_compressible,
|
2828
|
+
ssl_client_hello_type_t type) {
|
3011
2829
|
bool first = true;
|
3012
2830
|
CBB contents, algs;
|
3013
2831
|
|
@@ -3016,9 +2834,10 @@ static bool cert_compression_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
3016
2834
|
continue;
|
3017
2835
|
}
|
3018
2836
|
|
3019
|
-
if (first &&
|
3020
|
-
|
3021
|
-
|
2837
|
+
if (first &&
|
2838
|
+
(!CBB_add_u16(out_compressible, TLSEXT_TYPE_cert_compression) ||
|
2839
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
2840
|
+
!CBB_add_u8_length_prefixed(&contents, &algs))) {
|
3022
2841
|
return false;
|
3023
2842
|
}
|
3024
2843
|
first = false;
|
@@ -3027,7 +2846,7 @@ static bool cert_compression_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
3027
2846
|
}
|
3028
2847
|
}
|
3029
2848
|
|
3030
|
-
return first || CBB_flush(
|
2849
|
+
return first || CBB_flush(out_compressible);
|
3031
2850
|
}
|
3032
2851
|
|
3033
2852
|
static bool cert_compression_parse_serverhello(SSL_HANDSHAKE *hs,
|
@@ -3113,8 +2932,22 @@ static bool cert_compression_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
3113
2932
|
//
|
3114
2933
|
// https://tools.ietf.org/html/draft-vvv-tls-alps-01
|
3115
2934
|
|
3116
|
-
|
3117
|
-
|
2935
|
+
bool ssl_get_local_application_settings(const SSL_HANDSHAKE *hs,
|
2936
|
+
Span<const uint8_t> *out_settings,
|
2937
|
+
Span<const uint8_t> protocol) {
|
2938
|
+
for (const ALPSConfig &config : hs->config->alps_configs) {
|
2939
|
+
if (protocol == config.protocol) {
|
2940
|
+
*out_settings = config.settings;
|
2941
|
+
return true;
|
2942
|
+
}
|
2943
|
+
}
|
2944
|
+
return false;
|
2945
|
+
}
|
2946
|
+
|
2947
|
+
static bool ext_alps_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
2948
|
+
CBB *out_compressible,
|
2949
|
+
ssl_client_hello_type_t type) {
|
2950
|
+
const SSL *const ssl = hs->ssl;
|
3118
2951
|
if (// ALPS requires TLS 1.3.
|
3119
2952
|
hs->max_version < TLS1_3_VERSION ||
|
3120
2953
|
// Do not offer ALPS without ALPN.
|
@@ -3127,8 +2960,8 @@ static bool ext_alps_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
3127
2960
|
}
|
3128
2961
|
|
3129
2962
|
CBB contents, proto_list, proto;
|
3130
|
-
if (!CBB_add_u16(
|
3131
|
-
!CBB_add_u16_length_prefixed(
|
2963
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_application_settings) ||
|
2964
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
3132
2965
|
!CBB_add_u16_length_prefixed(&contents, &proto_list)) {
|
3133
2966
|
return false;
|
3134
2967
|
}
|
@@ -3141,7 +2974,7 @@ static bool ext_alps_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
3141
2974
|
}
|
3142
2975
|
}
|
3143
2976
|
|
3144
|
-
return CBB_flush(
|
2977
|
+
return CBB_flush(out_compressible);
|
3145
2978
|
}
|
3146
2979
|
|
3147
2980
|
static bool ext_alps_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
@@ -3252,7 +3085,6 @@ bool ssl_negotiate_alps(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
3252
3085
|
static const struct tls_extension kExtensions[] = {
|
3253
3086
|
{
|
3254
3087
|
TLSEXT_TYPE_server_name,
|
3255
|
-
NULL,
|
3256
3088
|
ext_sni_add_clienthello,
|
3257
3089
|
ext_sni_parse_serverhello,
|
3258
3090
|
ext_sni_parse_clienthello,
|
@@ -3260,15 +3092,13 @@ static const struct tls_extension kExtensions[] = {
|
|
3260
3092
|
},
|
3261
3093
|
{
|
3262
3094
|
TLSEXT_TYPE_encrypted_client_hello,
|
3263
|
-
NULL,
|
3264
3095
|
ext_ech_add_clienthello,
|
3265
3096
|
ext_ech_parse_serverhello,
|
3266
3097
|
ext_ech_parse_clienthello,
|
3267
|
-
|
3098
|
+
ext_ech_add_serverhello,
|
3268
3099
|
},
|
3269
3100
|
{
|
3270
3101
|
TLSEXT_TYPE_ech_is_inner,
|
3271
|
-
NULL,
|
3272
3102
|
ext_ech_is_inner_add_clienthello,
|
3273
3103
|
forbid_parse_serverhello,
|
3274
3104
|
ext_ech_is_inner_parse_clienthello,
|
@@ -3276,7 +3106,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3276
3106
|
},
|
3277
3107
|
{
|
3278
3108
|
TLSEXT_TYPE_extended_master_secret,
|
3279
|
-
NULL,
|
3280
3109
|
ext_ems_add_clienthello,
|
3281
3110
|
ext_ems_parse_serverhello,
|
3282
3111
|
ext_ems_parse_clienthello,
|
@@ -3284,7 +3113,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3284
3113
|
},
|
3285
3114
|
{
|
3286
3115
|
TLSEXT_TYPE_renegotiate,
|
3287
|
-
NULL,
|
3288
3116
|
ext_ri_add_clienthello,
|
3289
3117
|
ext_ri_parse_serverhello,
|
3290
3118
|
ext_ri_parse_clienthello,
|
@@ -3292,7 +3120,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3292
3120
|
},
|
3293
3121
|
{
|
3294
3122
|
TLSEXT_TYPE_supported_groups,
|
3295
|
-
NULL,
|
3296
3123
|
ext_supported_groups_add_clienthello,
|
3297
3124
|
ext_supported_groups_parse_serverhello,
|
3298
3125
|
ext_supported_groups_parse_clienthello,
|
@@ -3300,7 +3127,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3300
3127
|
},
|
3301
3128
|
{
|
3302
3129
|
TLSEXT_TYPE_ec_point_formats,
|
3303
|
-
NULL,
|
3304
3130
|
ext_ec_point_add_clienthello,
|
3305
3131
|
ext_ec_point_parse_serverhello,
|
3306
3132
|
ext_ec_point_parse_clienthello,
|
@@ -3308,7 +3134,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3308
3134
|
},
|
3309
3135
|
{
|
3310
3136
|
TLSEXT_TYPE_session_ticket,
|
3311
|
-
NULL,
|
3312
3137
|
ext_ticket_add_clienthello,
|
3313
3138
|
ext_ticket_parse_serverhello,
|
3314
3139
|
// Ticket extension client parsing is handled in ssl_session.c
|
@@ -3317,7 +3142,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3317
3142
|
},
|
3318
3143
|
{
|
3319
3144
|
TLSEXT_TYPE_application_layer_protocol_negotiation,
|
3320
|
-
NULL,
|
3321
3145
|
ext_alpn_add_clienthello,
|
3322
3146
|
ext_alpn_parse_serverhello,
|
3323
3147
|
// ALPN is negotiated late in |ssl_negotiate_alpn|.
|
@@ -3326,7 +3150,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3326
3150
|
},
|
3327
3151
|
{
|
3328
3152
|
TLSEXT_TYPE_status_request,
|
3329
|
-
NULL,
|
3330
3153
|
ext_ocsp_add_clienthello,
|
3331
3154
|
ext_ocsp_parse_serverhello,
|
3332
3155
|
ext_ocsp_parse_clienthello,
|
@@ -3334,7 +3157,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3334
3157
|
},
|
3335
3158
|
{
|
3336
3159
|
TLSEXT_TYPE_signature_algorithms,
|
3337
|
-
NULL,
|
3338
3160
|
ext_sigalgs_add_clienthello,
|
3339
3161
|
forbid_parse_serverhello,
|
3340
3162
|
ext_sigalgs_parse_clienthello,
|
@@ -3342,7 +3164,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3342
3164
|
},
|
3343
3165
|
{
|
3344
3166
|
TLSEXT_TYPE_next_proto_neg,
|
3345
|
-
NULL,
|
3346
3167
|
ext_npn_add_clienthello,
|
3347
3168
|
ext_npn_parse_serverhello,
|
3348
3169
|
ext_npn_parse_clienthello,
|
@@ -3350,7 +3171,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3350
3171
|
},
|
3351
3172
|
{
|
3352
3173
|
TLSEXT_TYPE_certificate_timestamp,
|
3353
|
-
NULL,
|
3354
3174
|
ext_sct_add_clienthello,
|
3355
3175
|
ext_sct_parse_serverhello,
|
3356
3176
|
ext_sct_parse_clienthello,
|
@@ -3358,7 +3178,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3358
3178
|
},
|
3359
3179
|
{
|
3360
3180
|
TLSEXT_TYPE_channel_id,
|
3361
|
-
ext_channel_id_init,
|
3362
3181
|
ext_channel_id_add_clienthello,
|
3363
3182
|
ext_channel_id_parse_serverhello,
|
3364
3183
|
ext_channel_id_parse_clienthello,
|
@@ -3366,7 +3185,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3366
3185
|
},
|
3367
3186
|
{
|
3368
3187
|
TLSEXT_TYPE_srtp,
|
3369
|
-
ext_srtp_init,
|
3370
3188
|
ext_srtp_add_clienthello,
|
3371
3189
|
ext_srtp_parse_serverhello,
|
3372
3190
|
ext_srtp_parse_clienthello,
|
@@ -3374,7 +3192,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3374
3192
|
},
|
3375
3193
|
{
|
3376
3194
|
TLSEXT_TYPE_key_share,
|
3377
|
-
NULL,
|
3378
3195
|
ext_key_share_add_clienthello,
|
3379
3196
|
forbid_parse_serverhello,
|
3380
3197
|
ignore_parse_clienthello,
|
@@ -3382,7 +3199,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3382
3199
|
},
|
3383
3200
|
{
|
3384
3201
|
TLSEXT_TYPE_psk_key_exchange_modes,
|
3385
|
-
NULL,
|
3386
3202
|
ext_psk_key_exchange_modes_add_clienthello,
|
3387
3203
|
forbid_parse_serverhello,
|
3388
3204
|
ext_psk_key_exchange_modes_parse_clienthello,
|
@@ -3390,7 +3206,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3390
3206
|
},
|
3391
3207
|
{
|
3392
3208
|
TLSEXT_TYPE_early_data,
|
3393
|
-
NULL,
|
3394
3209
|
ext_early_data_add_clienthello,
|
3395
3210
|
ext_early_data_parse_serverhello,
|
3396
3211
|
ext_early_data_parse_clienthello,
|
@@ -3398,7 +3213,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3398
3213
|
},
|
3399
3214
|
{
|
3400
3215
|
TLSEXT_TYPE_supported_versions,
|
3401
|
-
NULL,
|
3402
3216
|
ext_supported_versions_add_clienthello,
|
3403
3217
|
forbid_parse_serverhello,
|
3404
3218
|
ignore_parse_clienthello,
|
@@ -3406,15 +3220,13 @@ static const struct tls_extension kExtensions[] = {
|
|
3406
3220
|
},
|
3407
3221
|
{
|
3408
3222
|
TLSEXT_TYPE_cookie,
|
3409
|
-
NULL,
|
3410
3223
|
ext_cookie_add_clienthello,
|
3411
3224
|
forbid_parse_serverhello,
|
3412
3225
|
ignore_parse_clienthello,
|
3413
3226
|
dont_add_serverhello,
|
3414
3227
|
},
|
3415
3228
|
{
|
3416
|
-
|
3417
|
-
NULL,
|
3229
|
+
TLSEXT_TYPE_quic_transport_parameters,
|
3418
3230
|
ext_quic_transport_params_add_clienthello,
|
3419
3231
|
ext_quic_transport_params_parse_serverhello,
|
3420
3232
|
ext_quic_transport_params_parse_clienthello,
|
@@ -3422,23 +3234,13 @@ static const struct tls_extension kExtensions[] = {
|
|
3422
3234
|
},
|
3423
3235
|
{
|
3424
3236
|
TLSEXT_TYPE_quic_transport_parameters_legacy,
|
3425
|
-
NULL,
|
3426
3237
|
ext_quic_transport_params_add_clienthello_legacy,
|
3427
3238
|
ext_quic_transport_params_parse_serverhello_legacy,
|
3428
3239
|
ext_quic_transport_params_parse_clienthello_legacy,
|
3429
3240
|
ext_quic_transport_params_add_serverhello_legacy,
|
3430
3241
|
},
|
3431
|
-
{
|
3432
|
-
TLSEXT_TYPE_token_binding,
|
3433
|
-
NULL,
|
3434
|
-
ext_token_binding_add_clienthello,
|
3435
|
-
ext_token_binding_parse_serverhello,
|
3436
|
-
ext_token_binding_parse_clienthello,
|
3437
|
-
ext_token_binding_add_serverhello,
|
3438
|
-
},
|
3439
3242
|
{
|
3440
3243
|
TLSEXT_TYPE_cert_compression,
|
3441
|
-
NULL,
|
3442
3244
|
cert_compression_add_clienthello,
|
3443
3245
|
cert_compression_parse_serverhello,
|
3444
3246
|
cert_compression_parse_clienthello,
|
@@ -3446,7 +3248,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3446
3248
|
},
|
3447
3249
|
{
|
3448
3250
|
TLSEXT_TYPE_delegated_credential,
|
3449
|
-
NULL,
|
3450
3251
|
ext_delegated_credential_add_clienthello,
|
3451
3252
|
forbid_parse_serverhello,
|
3452
3253
|
ext_delegated_credential_parse_clienthello,
|
@@ -3454,7 +3255,6 @@ static const struct tls_extension kExtensions[] = {
|
|
3454
3255
|
},
|
3455
3256
|
{
|
3456
3257
|
TLSEXT_TYPE_application_settings,
|
3457
|
-
NULL,
|
3458
3258
|
ext_alps_add_clienthello,
|
3459
3259
|
ext_alps_parse_serverhello,
|
3460
3260
|
// ALPS is negotiated late in |ssl_negotiate_alpn|.
|
@@ -3472,6 +3272,30 @@ static_assert(kNumExtensions <=
|
|
3472
3272
|
sizeof(((SSL_HANDSHAKE *)NULL)->extensions.received) * 8,
|
3473
3273
|
"too many extensions for received bitset");
|
3474
3274
|
|
3275
|
+
bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs) {
|
3276
|
+
if (!hs->config->permute_extensions) {
|
3277
|
+
return true;
|
3278
|
+
}
|
3279
|
+
|
3280
|
+
static_assert(kNumExtensions <= UINT8_MAX,
|
3281
|
+
"extensions_permutation type is too small");
|
3282
|
+
uint32_t seeds[kNumExtensions - 1];
|
3283
|
+
Array<uint8_t> permutation;
|
3284
|
+
if (!RAND_bytes(reinterpret_cast<uint8_t *>(seeds), sizeof(seeds)) ||
|
3285
|
+
!permutation.Init(kNumExtensions)) {
|
3286
|
+
return false;
|
3287
|
+
}
|
3288
|
+
for (size_t i = 0; i < kNumExtensions; i++) {
|
3289
|
+
permutation[i] = i;
|
3290
|
+
}
|
3291
|
+
for (size_t i = kNumExtensions - 1; i > 0; i--) {
|
3292
|
+
// Set element |i| to a randomly-selected element 0 <= j <= i.
|
3293
|
+
std::swap(permutation[i], permutation[seeds[i - 1] % (i + 1)]);
|
3294
|
+
}
|
3295
|
+
hs->extension_permutation = std::move(permutation);
|
3296
|
+
return true;
|
3297
|
+
}
|
3298
|
+
|
3475
3299
|
static const struct tls_extension *tls_extension_find(uint32_t *out_index,
|
3476
3300
|
uint16_t value) {
|
3477
3301
|
unsigned i;
|
@@ -3485,47 +3309,205 @@ static const struct tls_extension *tls_extension_find(uint32_t *out_index,
|
|
3485
3309
|
return NULL;
|
3486
3310
|
}
|
3487
3311
|
|
3488
|
-
bool
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3312
|
+
static bool add_padding_extension(CBB *cbb, uint16_t ext, size_t len) {
|
3313
|
+
CBB child;
|
3314
|
+
uint8_t *ptr;
|
3315
|
+
if (!CBB_add_u16(cbb, ext) || //
|
3316
|
+
!CBB_add_u16_length_prefixed(cbb, &child) ||
|
3317
|
+
!CBB_add_space(&child, &ptr, len)) {
|
3493
3318
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
3494
3319
|
return false;
|
3495
3320
|
}
|
3321
|
+
OPENSSL_memset(ptr, 0, len);
|
3322
|
+
return CBB_flush(cbb);
|
3323
|
+
}
|
3496
3324
|
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
3505
|
-
|
3325
|
+
static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
|
3326
|
+
CBB *out_encoded,
|
3327
|
+
bool *out_needs_psk_binder) {
|
3328
|
+
// When writing ClientHelloInner, we construct the real and encoded
|
3329
|
+
// ClientHellos concurrently, to handle compression. Uncompressed extensions
|
3330
|
+
// are written to |extensions| and copied to |extensions_encoded|. Compressed
|
3331
|
+
// extensions are buffered in |compressed| and written to the end. (ECH can
|
3332
|
+
// only compress continguous extensions.)
|
3333
|
+
SSL *const ssl = hs->ssl;
|
3334
|
+
bssl::ScopedCBB compressed, outer_extensions;
|
3335
|
+
CBB extensions, extensions_encoded;
|
3336
|
+
if (!CBB_add_u16_length_prefixed(out, &extensions) ||
|
3337
|
+
!CBB_add_u16_length_prefixed(out_encoded, &extensions_encoded) ||
|
3338
|
+
!CBB_init(compressed.get(), 64) ||
|
3339
|
+
!CBB_init(outer_extensions.get(), 64)) {
|
3340
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
3341
|
+
return false;
|
3506
3342
|
}
|
3507
3343
|
|
3508
|
-
|
3344
|
+
hs->inner_extensions_sent = 0;
|
3345
|
+
|
3509
3346
|
if (ssl->ctx->grease_enabled) {
|
3510
|
-
// Add a fake empty extension. See
|
3511
|
-
|
3512
|
-
|
3513
|
-
|
3514
|
-
|
3347
|
+
// Add a fake empty extension. See RFC 8701. This always matches
|
3348
|
+
// |ssl_add_clienthello_tlsext|, so compress it.
|
3349
|
+
uint16_t grease_ext = ssl_get_grease_value(hs, ssl_grease_extension1);
|
3350
|
+
if (!add_padding_extension(compressed.get(), grease_ext, 0) ||
|
3351
|
+
!CBB_add_u16(outer_extensions.get(), grease_ext)) {
|
3515
3352
|
return false;
|
3516
3353
|
}
|
3517
3354
|
}
|
3518
3355
|
|
3519
|
-
|
3520
|
-
|
3356
|
+
for (size_t unpermuted = 0; unpermuted < kNumExtensions; unpermuted++) {
|
3357
|
+
size_t i = hs->extension_permutation.empty()
|
3358
|
+
? unpermuted
|
3359
|
+
: hs->extension_permutation[unpermuted];
|
3521
3360
|
const size_t len_before = CBB_len(&extensions);
|
3522
|
-
|
3361
|
+
const size_t len_compressed_before = CBB_len(compressed.get());
|
3362
|
+
if (!kExtensions[i].add_clienthello(hs, &extensions, compressed.get(),
|
3363
|
+
ssl_client_hello_inner)) {
|
3523
3364
|
OPENSSL_PUT_ERROR(SSL, SSL_R_ERROR_ADDING_EXTENSION);
|
3524
3365
|
ERR_add_error_dataf("extension %u", (unsigned)kExtensions[i].value);
|
3525
3366
|
return false;
|
3526
3367
|
}
|
3527
3368
|
|
3528
3369
|
const size_t bytes_written = CBB_len(&extensions) - len_before;
|
3370
|
+
const size_t bytes_written_compressed =
|
3371
|
+
CBB_len(compressed.get()) - len_compressed_before;
|
3372
|
+
// The callback may write to at most one output.
|
3373
|
+
assert(bytes_written == 0 || bytes_written_compressed == 0);
|
3374
|
+
if (bytes_written != 0 || bytes_written_compressed != 0) {
|
3375
|
+
hs->inner_extensions_sent |= (1u << i);
|
3376
|
+
}
|
3377
|
+
// If compressed, update the running ech_outer_extensions extension.
|
3378
|
+
if (bytes_written_compressed != 0 &&
|
3379
|
+
!CBB_add_u16(outer_extensions.get(), kExtensions[i].value)) {
|
3380
|
+
return false;
|
3381
|
+
}
|
3382
|
+
}
|
3383
|
+
|
3384
|
+
if (ssl->ctx->grease_enabled) {
|
3385
|
+
// Add a fake non-empty extension. See RFC 8701. This always matches
|
3386
|
+
// |ssl_add_clienthello_tlsext|, so compress it.
|
3387
|
+
uint16_t grease_ext = ssl_get_grease_value(hs, ssl_grease_extension2);
|
3388
|
+
if (!add_padding_extension(compressed.get(), grease_ext, 1) ||
|
3389
|
+
!CBB_add_u16(outer_extensions.get(), grease_ext)) {
|
3390
|
+
return false;
|
3391
|
+
}
|
3392
|
+
}
|
3393
|
+
|
3394
|
+
// Pad the server name. See draft-ietf-tls-esni-10, section 6.1.2.
|
3395
|
+
// TODO(https://crbug.com/boringssl/275): Ideally we'd pad the whole thing to
|
3396
|
+
// reduce the output range. See
|
3397
|
+
// https://github.com/tlswg/draft-ietf-tls-esni/issues/433
|
3398
|
+
size_t padding_len = 0;
|
3399
|
+
size_t maximum_name_length = hs->selected_ech_config->maximum_name_length;
|
3400
|
+
if (ssl->hostname) {
|
3401
|
+
size_t hostname_len = strlen(ssl->hostname.get());
|
3402
|
+
if (hostname_len <= maximum_name_length) {
|
3403
|
+
padding_len = maximum_name_length - hostname_len;
|
3404
|
+
} else {
|
3405
|
+
// If the server underestimated the maximum size, pad to a multiple of 32.
|
3406
|
+
padding_len = 31 - (hostname_len - 1) % 32;
|
3407
|
+
// If the input is close to |maximum_name_length|, pad to the next
|
3408
|
+
// multiple for at least 32 bytes of length ambiguity.
|
3409
|
+
if (hostname_len + padding_len < maximum_name_length + 32) {
|
3410
|
+
padding_len += 32;
|
3411
|
+
}
|
3412
|
+
}
|
3413
|
+
} else {
|
3414
|
+
// No SNI. Pad up to |maximum_name_length|, including server_name extension
|
3415
|
+
// overhead.
|
3416
|
+
padding_len = 9 + maximum_name_length;
|
3417
|
+
}
|
3418
|
+
if (!add_padding_extension(&extensions, TLSEXT_TYPE_padding, padding_len)) {
|
3419
|
+
return false;
|
3420
|
+
}
|
3421
|
+
|
3422
|
+
// Uncompressed extensions are encoded as-is.
|
3423
|
+
if (!CBB_add_bytes(&extensions_encoded, CBB_data(&extensions),
|
3424
|
+
CBB_len(&extensions))) {
|
3425
|
+
return false;
|
3426
|
+
}
|
3427
|
+
|
3428
|
+
// Flush all the compressed extensions.
|
3429
|
+
if (CBB_len(compressed.get()) != 0) {
|
3430
|
+
CBB extension, child;
|
3431
|
+
// Copy them as-is in the real ClientHelloInner.
|
3432
|
+
if (!CBB_add_bytes(&extensions, CBB_data(compressed.get()),
|
3433
|
+
CBB_len(compressed.get())) ||
|
3434
|
+
// Replace with ech_outer_extensions in the encoded form.
|
3435
|
+
!CBB_add_u16(&extensions_encoded, TLSEXT_TYPE_ech_outer_extensions) ||
|
3436
|
+
!CBB_add_u16_length_prefixed(&extensions_encoded, &extension) ||
|
3437
|
+
!CBB_add_u8_length_prefixed(&extension, &child) ||
|
3438
|
+
!CBB_add_bytes(&child, CBB_data(outer_extensions.get()),
|
3439
|
+
CBB_len(outer_extensions.get())) ||
|
3440
|
+
!CBB_flush(&extensions_encoded)) {
|
3441
|
+
return false;
|
3442
|
+
}
|
3443
|
+
}
|
3444
|
+
|
3445
|
+
// The PSK extension must be last. It is never compressed. Note, if there is a
|
3446
|
+
// binder, the caller will need to update both ClientHelloInner and
|
3447
|
+
// EncodedClientHelloInner after computing it.
|
3448
|
+
const size_t len_before = CBB_len(&extensions);
|
3449
|
+
if (!ext_pre_shared_key_add_clienthello(hs, &extensions, out_needs_psk_binder,
|
3450
|
+
ssl_client_hello_inner) ||
|
3451
|
+
!CBB_add_bytes(&extensions_encoded, CBB_data(&extensions) + len_before,
|
3452
|
+
CBB_len(&extensions) - len_before) ||
|
3453
|
+
!CBB_flush(out) || //
|
3454
|
+
!CBB_flush(out_encoded)) {
|
3455
|
+
return false;
|
3456
|
+
}
|
3457
|
+
|
3458
|
+
return true;
|
3459
|
+
}
|
3460
|
+
|
3461
|
+
bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
|
3462
|
+
bool *out_needs_psk_binder,
|
3463
|
+
ssl_client_hello_type_t type, size_t header_len,
|
3464
|
+
size_t omit_ech_len) {
|
3465
|
+
*out_needs_psk_binder = false;
|
3466
|
+
|
3467
|
+
if (type == ssl_client_hello_inner) {
|
3468
|
+
return ssl_add_clienthello_tlsext_inner(hs, out, out_encoded,
|
3469
|
+
out_needs_psk_binder);
|
3470
|
+
}
|
3471
|
+
|
3472
|
+
assert(out_encoded == nullptr); // Only ClientHelloInner needs two outputs.
|
3473
|
+
SSL *const ssl = hs->ssl;
|
3474
|
+
CBB extensions;
|
3475
|
+
if (!CBB_add_u16_length_prefixed(out, &extensions)) {
|
3476
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
3477
|
+
return false;
|
3478
|
+
}
|
3479
|
+
|
3480
|
+
// Note we may send multiple ClientHellos for DTLS HelloVerifyRequest and TLS
|
3481
|
+
// 1.3 HelloRetryRequest. For the latter, the extensions may change, so it is
|
3482
|
+
// important to reset this value.
|
3483
|
+
hs->extensions.sent = 0;
|
3484
|
+
|
3485
|
+
// Add a fake empty extension. See RFC 8701.
|
3486
|
+
if (ssl->ctx->grease_enabled &&
|
3487
|
+
!add_padding_extension(
|
3488
|
+
&extensions, ssl_get_grease_value(hs, ssl_grease_extension1), 0)) {
|
3489
|
+
return false;
|
3490
|
+
}
|
3491
|
+
|
3492
|
+
bool last_was_empty = false;
|
3493
|
+
for (size_t unpermuted = 0; unpermuted < kNumExtensions; unpermuted++) {
|
3494
|
+
size_t i = hs->extension_permutation.empty()
|
3495
|
+
? unpermuted
|
3496
|
+
: hs->extension_permutation[unpermuted];
|
3497
|
+
size_t bytes_written;
|
3498
|
+
if (omit_ech_len != 0 &&
|
3499
|
+
kExtensions[i].value == TLSEXT_TYPE_encrypted_client_hello) {
|
3500
|
+
bytes_written = omit_ech_len;
|
3501
|
+
} else {
|
3502
|
+
const size_t len_before = CBB_len(&extensions);
|
3503
|
+
if (!kExtensions[i].add_clienthello(hs, &extensions, &extensions, type)) {
|
3504
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_ERROR_ADDING_EXTENSION);
|
3505
|
+
ERR_add_error_dataf("extension %u", (unsigned)kExtensions[i].value);
|
3506
|
+
return false;
|
3507
|
+
}
|
3508
|
+
|
3509
|
+
bytes_written = CBB_len(&extensions) - len_before;
|
3510
|
+
}
|
3529
3511
|
if (bytes_written != 0) {
|
3530
3512
|
hs->extensions.sent |= (1u << i);
|
3531
3513
|
}
|
@@ -3535,29 +3517,22 @@ bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out,
|
|
3535
3517
|
}
|
3536
3518
|
|
3537
3519
|
if (ssl->ctx->grease_enabled) {
|
3538
|
-
// Add a fake non-empty extension. See
|
3539
|
-
|
3540
|
-
|
3541
|
-
// The two fake extensions must not have the same value. GREASE values are
|
3542
|
-
// of the form 0x1a1a, 0x2a2a, 0x3a3a, etc., so XOR to generate a different
|
3543
|
-
// one.
|
3544
|
-
if (grease_ext1 == grease_ext2) {
|
3545
|
-
grease_ext2 ^= 0x1010;
|
3546
|
-
}
|
3547
|
-
|
3548
|
-
if (!CBB_add_u16(&extensions, grease_ext2) ||
|
3549
|
-
!CBB_add_u16(&extensions, 1 /* one byte length */) ||
|
3550
|
-
!CBB_add_u8(&extensions, 0 /* single zero byte as contents */)) {
|
3551
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
3520
|
+
// Add a fake non-empty extension. See RFC 8701.
|
3521
|
+
if (!add_padding_extension(
|
3522
|
+
&extensions, ssl_get_grease_value(hs, ssl_grease_extension2), 1)) {
|
3552
3523
|
return false;
|
3553
3524
|
}
|
3554
|
-
|
3555
3525
|
last_was_empty = false;
|
3556
3526
|
}
|
3557
3527
|
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3528
|
+
// In cleartext ClientHellos, we add the padding extension to work around
|
3529
|
+
// bugs. We also apply this padding to ClientHelloOuter, to keep the wire
|
3530
|
+
// images aligned.
|
3531
|
+
size_t psk_extension_len = ext_pre_shared_key_clienthello_length(hs, type);
|
3532
|
+
if (!SSL_is_dtls(ssl) && !ssl->quic_method &&
|
3533
|
+
!ssl->s3->used_hello_retry_request) {
|
3534
|
+
header_len += SSL3_HM_HEADER_LENGTH + 2 + CBB_len(&extensions) +
|
3535
|
+
omit_ech_len + psk_extension_len;
|
3561
3536
|
size_t padding_len = 0;
|
3562
3537
|
|
3563
3538
|
// The final extension must be non-empty. WebSphere Application
|
@@ -3591,24 +3566,21 @@ bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out,
|
|
3591
3566
|
}
|
3592
3567
|
}
|
3593
3568
|
|
3594
|
-
if (padding_len != 0
|
3595
|
-
|
3596
|
-
|
3597
|
-
!CBB_add_u16(&extensions, padding_len) ||
|
3598
|
-
!CBB_add_space(&extensions, &padding_bytes, padding_len)) {
|
3599
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
3600
|
-
return false;
|
3601
|
-
}
|
3602
|
-
|
3603
|
-
OPENSSL_memset(padding_bytes, 0, padding_len);
|
3569
|
+
if (padding_len != 0 &&
|
3570
|
+
!add_padding_extension(&extensions, TLSEXT_TYPE_padding, padding_len)) {
|
3571
|
+
return false;
|
3604
3572
|
}
|
3605
3573
|
}
|
3606
3574
|
|
3607
3575
|
// The PSK extension must be last, including after the padding.
|
3608
|
-
|
3576
|
+
const size_t len_before = CBB_len(&extensions);
|
3577
|
+
if (!ext_pre_shared_key_add_clienthello(hs, &extensions, out_needs_psk_binder,
|
3578
|
+
type)) {
|
3609
3579
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
3610
3580
|
return false;
|
3611
3581
|
}
|
3582
|
+
assert(psk_extension_len == CBB_len(&extensions) - len_before);
|
3583
|
+
(void)len_before; // |assert| is omitted in release builds.
|
3612
3584
|
|
3613
3585
|
// Discard empty extensions blocks.
|
3614
3586
|
if (CBB_len(&extensions) == 0) {
|
@@ -3654,12 +3626,6 @@ err:
|
|
3654
3626
|
static bool ssl_scan_clienthello_tlsext(SSL_HANDSHAKE *hs,
|
3655
3627
|
const SSL_CLIENT_HELLO *client_hello,
|
3656
3628
|
int *out_alert) {
|
3657
|
-
for (size_t i = 0; i < kNumExtensions; i++) {
|
3658
|
-
if (kExtensions[i].init != NULL) {
|
3659
|
-
kExtensions[i].init(hs);
|
3660
|
-
}
|
3661
|
-
}
|
3662
|
-
|
3663
3629
|
hs->extensions.received = 0;
|
3664
3630
|
CBS extensions;
|
3665
3631
|
CBS_init(&extensions, client_hello->extensions, client_hello->extensions_len);
|
@@ -3820,18 +3786,8 @@ static bool ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, CBS *cbs,
|
|
3820
3786
|
|
3821
3787
|
static bool ssl_check_clienthello_tlsext(SSL_HANDSHAKE *hs) {
|
3822
3788
|
SSL *const ssl = hs->ssl;
|
3823
|
-
|
3824
|
-
if (ssl->s3->token_binding_negotiated &&
|
3825
|
-
!(SSL_get_secure_renegotiation_support(ssl) &&
|
3826
|
-
SSL_get_extms_support(ssl))) {
|
3827
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_NEGOTIATED_TB_WITHOUT_EMS_OR_RI);
|
3828
|
-
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNSUPPORTED_EXTENSION);
|
3829
|
-
return false;
|
3830
|
-
}
|
3831
|
-
|
3832
3789
|
int ret = SSL_TLSEXT_ERR_NOACK;
|
3833
3790
|
int al = SSL_AD_UNRECOGNIZED_NAME;
|
3834
|
-
|
3835
3791
|
if (ssl->ctx->servername_callback != 0) {
|
3836
3792
|
ret = ssl->ctx->servername_callback(ssl, &al, ssl->ctx->servername_arg);
|
3837
3793
|
} else if (ssl->session_ctx->servername_callback != 0) {
|
@@ -4046,6 +4002,7 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
4046
4002
|
SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
|
4047
4003
|
bool *out_renew_ticket, Span<const uint8_t> ticket,
|
4048
4004
|
Span<const uint8_t> session_id) {
|
4005
|
+
SSL *const ssl = hs->ssl;
|
4049
4006
|
*out_renew_ticket = false;
|
4050
4007
|
out_session->reset();
|
4051
4008
|
|
@@ -4054,9 +4011,21 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
4054
4011
|
return ssl_ticket_aead_ignore_ticket;
|
4055
4012
|
}
|
4056
4013
|
|
4014
|
+
// Tickets in TLS 1.3 are tied into pre-shared keys (PSKs), unlike in TLS 1.2
|
4015
|
+
// where that concept doesn't exist. The |decrypted_psk| and |ignore_psk|
|
4016
|
+
// hints only apply to PSKs. We check the version to determine which this is.
|
4017
|
+
const bool is_psk = ssl_protocol_version(ssl) >= TLS1_3_VERSION;
|
4018
|
+
|
4057
4019
|
Array<uint8_t> plaintext;
|
4058
4020
|
enum ssl_ticket_aead_result_t result;
|
4059
|
-
|
4021
|
+
SSL_HANDSHAKE_HINTS *const hints = hs->hints.get();
|
4022
|
+
if (is_psk && hints && !hs->hints_requested &&
|
4023
|
+
!hints->decrypted_psk.empty()) {
|
4024
|
+
result = plaintext.CopyFrom(hints->decrypted_psk) ? ssl_ticket_aead_success
|
4025
|
+
: ssl_ticket_aead_error;
|
4026
|
+
} else if (is_psk && hints && !hs->hints_requested && hints->ignore_psk) {
|
4027
|
+
result = ssl_ticket_aead_ignore_ticket;
|
4028
|
+
} else if (ssl->session_ctx->ticket_aead_method != NULL) {
|
4060
4029
|
result = ssl_decrypt_ticket_with_method(hs, &plaintext, out_renew_ticket,
|
4061
4030
|
ticket);
|
4062
4031
|
} else {
|
@@ -4065,9 +4034,8 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
4065
4034
|
// length should be well under the minimum size for the session material and
|
4066
4035
|
// HMAC.
|
4067
4036
|
if (ticket.size() < SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH) {
|
4068
|
-
|
4069
|
-
}
|
4070
|
-
if (hs->ssl->session_ctx->ticket_key_cb != NULL) {
|
4037
|
+
result = ssl_ticket_aead_ignore_ticket;
|
4038
|
+
} else if (ssl->session_ctx->ticket_key_cb != NULL) {
|
4071
4039
|
result =
|
4072
4040
|
ssl_decrypt_ticket_with_cb(hs, &plaintext, out_renew_ticket, ticket);
|
4073
4041
|
} else {
|
@@ -4075,22 +4043,33 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
4075
4043
|
}
|
4076
4044
|
}
|
4077
4045
|
|
4046
|
+
if (is_psk && hints && hs->hints_requested) {
|
4047
|
+
if (result == ssl_ticket_aead_ignore_ticket) {
|
4048
|
+
hints->ignore_psk = true;
|
4049
|
+
} else if (result == ssl_ticket_aead_success &&
|
4050
|
+
!hints->decrypted_psk.CopyFrom(plaintext)) {
|
4051
|
+
return ssl_ticket_aead_error;
|
4052
|
+
}
|
4053
|
+
}
|
4054
|
+
|
4078
4055
|
if (result != ssl_ticket_aead_success) {
|
4079
4056
|
return result;
|
4080
4057
|
}
|
4081
4058
|
|
4082
4059
|
// Decode the session.
|
4083
4060
|
UniquePtr<SSL_SESSION> session(SSL_SESSION_from_bytes(
|
4084
|
-
plaintext.data(), plaintext.size(),
|
4061
|
+
plaintext.data(), plaintext.size(), ssl->ctx.get()));
|
4085
4062
|
if (!session) {
|
4086
4063
|
ERR_clear_error(); // Don't leave an error on the queue.
|
4087
4064
|
return ssl_ticket_aead_ignore_ticket;
|
4088
4065
|
}
|
4089
4066
|
|
4090
|
-
//
|
4091
|
-
//
|
4092
|
-
|
4093
|
-
|
4067
|
+
// Envoy's tests expect the session to have a session ID that matches the
|
4068
|
+
// placeholder used by the client. It's unclear whether this is a good idea,
|
4069
|
+
// but we maintain it for now.
|
4070
|
+
SHA256(ticket.data(), ticket.size(), session->session_id);
|
4071
|
+
// Other consumers may expect a non-empty session ID to indicate resumption.
|
4072
|
+
session->session_id_length = SHA256_DIGEST_LENGTH;
|
4094
4073
|
|
4095
4074
|
*out_session = std::move(session);
|
4096
4075
|
return ssl_ticket_aead_success;
|
@@ -4238,11 +4217,11 @@ bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg) {
|
|
4238
4217
|
if (!sig_ok) {
|
4239
4218
|
OPENSSL_PUT_ERROR(SSL, SSL_R_CHANNEL_ID_SIGNATURE_INVALID);
|
4240
4219
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECRYPT_ERROR);
|
4241
|
-
ssl->s3->channel_id_valid = false;
|
4242
4220
|
return false;
|
4243
4221
|
}
|
4244
4222
|
|
4245
4223
|
OPENSSL_memcpy(ssl->s3->channel_id, p, 64);
|
4224
|
+
ssl->s3->channel_id_valid = true;
|
4246
4225
|
return true;
|
4247
4226
|
}
|
4248
4227
|
|
@@ -4353,23 +4332,6 @@ bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs) {
|
|
4353
4332
|
return true;
|
4354
4333
|
}
|
4355
4334
|
|
4356
|
-
bool ssl_do_channel_id_callback(SSL_HANDSHAKE *hs) {
|
4357
|
-
if (hs->config->channel_id_private != NULL ||
|
4358
|
-
hs->ssl->ctx->channel_id_cb == NULL) {
|
4359
|
-
return true;
|
4360
|
-
}
|
4361
|
-
|
4362
|
-
EVP_PKEY *key = NULL;
|
4363
|
-
hs->ssl->ctx->channel_id_cb(hs->ssl, &key);
|
4364
|
-
if (key == NULL) {
|
4365
|
-
// The caller should try again later.
|
4366
|
-
return true;
|
4367
|
-
}
|
4368
|
-
|
4369
|
-
UniquePtr<EVP_PKEY> free_key(key);
|
4370
|
-
return SSL_set1_tls_channel_id(hs->ssl, key);
|
4371
|
-
}
|
4372
|
-
|
4373
4335
|
bool ssl_is_sct_list_valid(const CBS *contents) {
|
4374
4336
|
// Shallow parse the SCT list for sanity. By the RFC
|
4375
4337
|
// (https://tools.ietf.org/html/rfc6962#section-3.3) neither the list nor any
|