grpc 1.84.0 → 1.85.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +40 -27
- data/include/grpc/event_engine/memory_allocator.h +1 -0
- data/include/grpc/grpc.h +3 -0
- data/include/grpc/grpc_security_constants.h +2 -0
- data/include/grpc/impl/channel_arg_names.h +4 -0
- data/src/core/call/call_filters.h +10 -10
- data/src/core/{lib/security/authorization → call}/evaluate_args.cc +22 -1
- data/src/core/{lib/security/authorization → call}/evaluate_args.h +19 -5
- data/src/core/call/filter_fusion.h +15 -15
- data/src/core/call/interception_chain.h +3 -3
- data/src/core/call/metadata_batch.cc +1 -0
- data/src/core/call/metadata_batch.h +45 -33
- data/src/core/call/parsed_metadata.h +3 -3
- data/src/core/call/request_buffer.cc +6 -6
- data/src/core/call/request_buffer.h +1 -1
- data/src/core/channelz/channel_trace.cc +5 -5
- data/src/core/channelz/channel_trace.h +1 -1
- data/src/core/channelz/channelz.cc +9 -9
- data/src/core/channelz/channelz.h +12 -12
- data/src/core/channelz/channelz_registry.cc +10 -10
- data/src/core/channelz/ztrace_collector.h +5 -5
- data/src/core/client_channel/client_channel.cc +4 -4
- data/src/core/client_channel/client_channel_filter.cc +14 -14
- data/src/core/client_channel/global_subchannel_pool.cc +4 -4
- data/src/core/client_channel/subchannel.cc +24 -23
- data/src/core/client_channel/subchannel_stream_client.cc +5 -5
- data/src/core/credentials/call/external/aws_external_account_credentials.cc +7 -7
- data/src/core/credentials/call/external/aws_request_signer.cc +16 -0
- data/src/core/credentials/call/external/external_account_credentials.cc +4 -4
- data/src/core/credentials/call/regional_access_boundary_fetcher.cc +9 -9
- data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +4 -4
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -3
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +1 -1
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +9 -9
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +1 -1
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +6 -6
- data/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc +3 -3
- data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +4 -4
- data/src/core/credentials/transport/tls/ssl_utils.cc +10 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +10 -10
- data/src/core/credentials/transport/tls/tls_security_connector.h +6 -6
- data/src/core/credentials/transport/tls/tls_utils.h +9 -0
- data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +1 -1
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +1 -1
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +2 -2
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +1 -1
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +15 -0
- data/src/core/ext/filters/rbac/rbac_filter.h +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +5 -5
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +30 -21
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +5 -11
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +14 -11
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -4
- data/src/core/ext/transport/chttp2/transport/frame.h +9 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +12 -9
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -2
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +16 -18
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +2 -1
- data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +277 -189
- data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +40 -17
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +12 -24
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +3 -29
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/read_context.h +96 -3
- data/src/core/ext/transport/chttp2/transport/reclaimer.cc +32 -0
- data/src/core/ext/transport/chttp2/transport/reclaimer.h +64 -0
- data/src/core/ext/transport/chttp2/transport/security_frame.h +8 -8
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +17 -9
- data/src/core/ext/transport/chttp2/transport/write_cycle.h +23 -3
- data/src/core/ext/transport/inproc/inproc_transport.cc +5 -5
- data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb.h +137 -73
- data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb_minitable.c +45 -25
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb.h +6 -6
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.c +4 -4
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb.h +46 -26
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.c +17 -14
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.c +3 -3
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/grpc/health/v1/health.upb.h +329 -0
- data/src/core/ext/upb-gen/grpc/health/v1/health.upb_minitable.c +128 -0
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/health/v1/health.upb_minitable.h +8 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.c +3 -3
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb.h +185 -23
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.c +20 -12
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb.h +58 -42
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.c +17 -12
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.h +5 -5
- data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +567 -549
- data/src/core/ext/upbdefs-gen/grpc/lookup/v1/rls_config.upbdefs.c +182 -0
- data/src/core/ext/upbdefs-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upbdefs.h +14 -14
- data/src/core/filter/ext_proc/ext_proc_filter.cc +1603 -46
- data/src/core/filter/ext_proc/ext_proc_filter.h +55 -22
- data/src/core/filter/ext_proc/ext_proc_messages.cc +106 -51
- data/src/core/filter/ext_proc/ext_proc_messages.h +36 -9
- data/src/core/handshaker/handshaker.cc +4 -4
- data/src/core/handshaker/http_connect/http_connect_client_handshaker.cc +3 -3
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +10 -10
- data/src/core/handshaker/security/secure_endpoint.cc +13 -13
- data/src/core/handshaker/security/security_handshaker.cc +6 -6
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +4 -4
- data/src/core/lib/channel/channel_args.cc +20 -0
- data/src/core/lib/channel/channel_args.h +17 -17
- data/src/core/lib/channel/promise_based_filter.cc +2 -2
- data/src/core/lib/channel/promise_based_filter.h +66 -27
- data/src/core/lib/debug/trace_flags.cc +2 -0
- data/src/core/lib/debug/trace_flags.h +1 -0
- data/src/core/lib/event_engine/ares_resolver.cc +14 -14
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +7 -7
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +4 -4
- data/src/core/lib/event_engine/default_event_engine.cc +5 -5
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +9 -9
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +16 -14
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +6 -6
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +3 -3
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +7 -7
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +17 -17
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/timer.cc +5 -5
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +5 -5
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +1 -1
- data/src/core/lib/event_engine/thread_pool/thread_count.cc +1 -1
- data/src/core/lib/event_engine/thread_pool/thread_count.h +3 -3
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +50 -21
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +3 -3
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +3 -3
- data/src/core/lib/event_engine/windows/windows_engine.cc +15 -15
- data/src/core/lib/event_engine/windows/windows_listener.cc +6 -6
- data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +6 -6
- data/src/core/lib/experiments/experiments.cc +48 -0
- data/src/core/lib/experiments/experiments.h +24 -0
- data/src/core/lib/iomgr/buffer_list.cc +3 -3
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/combiner.cc +0 -1
- data/src/core/lib/iomgr/ev_apple.cc +4 -4
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_posix.cc +7 -7
- data/src/core/lib/promise/activity.cc +1 -1
- data/src/core/lib/promise/activity.h +1 -1
- data/src/core/lib/promise/arena_promise.h +7 -7
- data/src/core/lib/promise/detail/promise_factory.h +8 -8
- data/src/core/lib/promise/detail/promise_like.h +4 -4
- data/src/core/lib/promise/inter_activity_latch.h +6 -6
- data/src/core/lib/promise/inter_activity_pipe.h +1 -1
- data/src/core/lib/promise/observable.h +3 -3
- data/src/core/lib/promise/party.cc +1 -1
- data/src/core/lib/promise/try_seq.h +2 -2
- data/src/core/lib/resource_quota/arena.h +3 -3
- data/src/core/lib/resource_quota/memory_quota.cc +16 -16
- data/src/core/lib/resource_quota/memory_quota.h +1 -1
- data/src/core/lib/resource_quota/thread_quota.cc +3 -3
- data/src/core/lib/security/authorization/audit_logging.cc +5 -5
- data/src/core/lib/security/authorization/authorization_engine.h +1 -1
- data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -1
- data/src/core/lib/security/authorization/grpc_server_authz_filter.h +1 -1
- data/src/core/lib/security/authorization/matchers.h +1 -1
- data/src/core/lib/surface/call.cc +8 -7
- data/src/core/lib/surface/call.h +3 -3
- data/src/core/lib/surface/call_utils.h +4 -0
- data/src/core/lib/surface/channel.cc +1 -1
- data/src/core/lib/surface/channel.h +1 -1
- data/src/core/lib/surface/channel_init.cc +1 -1
- data/src/core/lib/surface/init.cc +7 -7
- data/src/core/lib/surface/lame_client.cc +1 -1
- data/src/core/lib/surface/legacy_channel.cc +2 -2
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/transport_framing_endpoint_extension.h +3 -3
- data/src/core/load_balancing/autosharding/autosharding.cc +931 -0
- data/src/core/load_balancing/autosharding/autosharding.h +78 -0
- data/src/core/load_balancing/grpclb/grpclb_client_stats.cc +2 -2
- data/src/core/load_balancing/grpclb/load_balancer_api.cc +1 -1
- data/src/core/load_balancing/grpclb/load_balancer_api.h +3 -1
- data/src/core/load_balancing/health_check_client.cc +7 -7
- data/src/core/load_balancing/lb_policy.cc +1 -1
- data/src/core/load_balancing/oob_backend_metric.cc +5 -5
- data/src/core/load_balancing/outlier_detection/outlier_detection.cc +2 -2
- data/src/core/load_balancing/ring_hash/ring_hash.cc +109 -37
- data/src/core/load_balancing/rls/rls.cc +23 -17
- data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +10 -10
- data/src/core/load_balancing/xds/cds.cc +6 -5
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +2 -2
- data/src/core/load_balancing/xds/xds_override_host.cc +10 -10
- data/src/core/mitigation_engine/mitigation_engine.h +28 -4
- data/src/core/plugin_registry/grpc_plugin_registry.cc +2 -0
- data/src/core/resolver/dns/dns_resolver.cc +7 -7
- data/src/core/resolver/fake/fake_resolver.cc +5 -5
- data/src/core/resolver/google_c2p/google_c2p_resolver.cc +38 -30
- data/src/core/server/server.cc +30 -30
- data/src/core/server/server.h +4 -3
- data/src/core/server/server_config_selector_filter.cc +3 -3
- data/src/core/server/xds_server_config_fetcher_legacy.cc +15 -15
- data/src/core/telemetry/default_tcp_tracer.cc +1 -1
- data/src/core/telemetry/instrument.cc +30 -16
- data/src/core/telemetry/instrument.h +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +4 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +2 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +5 -5
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +3 -3
- data/src/core/tsi/ssl_transport_security.cc +46 -13
- data/src/core/tsi/ssl_transport_security.h +7 -0
- data/src/core/tsi/ssl_transport_security_utils.cc +16 -6
- data/src/core/util/event_log.cc +3 -3
- data/src/core/util/http_client/httpcli.cc +5 -5
- data/src/core/util/http_client/httpcli.h +1 -1
- data/src/core/util/json/json_object_loader.cc +7 -0
- data/src/core/util/json/json_object_loader.h +17 -2
- data/src/core/util/latent_see.cc +123 -36
- data/src/core/util/latent_see.h +14 -1
- data/src/core/util/mpscq.cc +1 -1
- data/src/core/util/notification.h +4 -4
- data/src/core/util/sync.h +20 -6
- data/src/core/util/table.h +20 -22
- data/src/core/util/work_serializer.cc +2 -2
- data/src/core/xds/grpc/blackboard.cc +4 -3
- data/src/core/xds/grpc/certificate_provider_store.cc +2 -2
- data/src/core/xds/grpc/streaming_call_promise_wrapper.cc +181 -0
- data/src/core/xds/grpc/streaming_call_promise_wrapper.h +213 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +2 -2
- data/src/core/xds/grpc/xds_client_grpc.cc +8 -8
- data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +2 -2
- data/src/core/xds/grpc/xds_endpoint.cc +1 -1
- data/src/core/xds/grpc/xds_endpoint_parser.cc +11 -0
- data/src/core/xds/grpc/xds_grpc_service_parser.cc +12 -10
- data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +17 -14
- data/src/core/xds/grpc/xds_matcher.h +2 -2
- data/src/core/xds/grpc/xds_transport_grpc.cc +125 -85
- data/src/core/xds/grpc/xds_transport_grpc.h +19 -4
- data/src/core/xds/xds_client/lrs_client.cc +22 -19
- data/src/core/xds/xds_client/xds_client.cc +19 -16
- data/src/core/xds/xds_client/xds_transport.h +49 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/generate_proto_ruby.sh +1 -1
- data/third_party/abseil-cpp/absl/algorithm/algorithm.h +34 -2
- data/third_party/abseil-cpp/absl/algorithm/container.h +345 -147
- data/third_party/abseil-cpp/absl/base/attributes.h +67 -44
- data/third_party/abseil-cpp/absl/base/call_once.h +1 -0
- data/third_party/abseil-cpp/absl/base/casts.cc +61 -0
- data/third_party/abseil-cpp/absl/base/casts.h +135 -2
- data/third_party/abseil-cpp/absl/base/config.h +63 -41
- data/third_party/abseil-cpp/absl/base/fast_type_id.h +30 -2
- data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +1 -1
- data/third_party/abseil-cpp/absl/base/internal/hardening.h +136 -0
- data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +6 -2
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +39 -4
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +6 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +77 -15
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +3 -4
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +26 -24
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +74 -29
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -11
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +52 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +5 -1
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +5 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +1 -1
- data/third_party/abseil-cpp/absl/base/macros.h +76 -37
- data/third_party/abseil-cpp/absl/base/nullability.h +5 -5
- data/third_party/abseil-cpp/absl/base/optimization.h +4 -5
- data/third_party/abseil-cpp/absl/base/options.h +46 -18
- data/third_party/abseil-cpp/absl/base/policy_checks.h +5 -5
- data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.cc → throw_delegate.cc} +9 -7
- data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.h → throw_delegate.h} +4 -14
- data/third_party/abseil-cpp/absl/cleanup/cleanup.h +7 -2
- data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -2
- data/third_party/abseil-cpp/absl/container/btree_map.h +60 -10
- data/third_party/abseil-cpp/absl/container/btree_set.h +61 -15
- data/third_party/abseil-cpp/absl/container/fixed_array.h +19 -21
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +49 -27
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +50 -26
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +42 -36
- data/third_party/abseil-cpp/absl/container/internal/btree.h +32 -24
- data/third_party/abseil-cpp/absl/container/internal/btree_container.h +30 -22
- data/third_party/abseil-cpp/absl/container/internal/common.h +57 -5
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +40 -36
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +119 -39
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +14 -2
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +14 -22
- data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +52 -52
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +7 -7
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +7 -7
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +32 -40
- data/third_party/abseil-cpp/absl/container/internal/layout.h +13 -13
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +95 -72
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +633 -365
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1016 -749
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +0 -1
- data/third_party/abseil-cpp/absl/container/node_hash_map.h +58 -35
- data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +23 -6
- data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.h +7 -1
- data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -6
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +41 -0
- data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +0 -16
- data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_arm_combined.cc +5 -0
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +304 -188
- data/third_party/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +4 -2
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +2 -2
- data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.h +8 -0
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +4 -4
- data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +15 -1
- data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h +7 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +12 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +6 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +13 -11
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +14 -7
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +3 -2
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +6 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +14 -8
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +48 -38
- data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +4 -0
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +63 -118
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +7 -47
- data/third_party/abseil-cpp/absl/debugging/symbolize.cc +20 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +83 -149
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +4 -17
- data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +4 -4
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +2 -4
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +8 -6
- data/third_party/abseil-cpp/absl/flags/declare.h +9 -0
- data/third_party/abseil-cpp/absl/flags/flag.h +2 -1
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +1 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +19 -18
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +33 -34
- data/third_party/abseil-cpp/absl/flags/internal/program_name.cc +2 -2
- data/third_party/abseil-cpp/absl/flags/marshalling.cc +1 -16
- data/third_party/abseil-cpp/absl/flags/marshalling.h +2 -28
- data/third_party/abseil-cpp/absl/flags/reflection.cc +11 -7
- data/third_party/abseil-cpp/absl/flags/usage_config.cc +2 -2
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +22 -19
- data/third_party/abseil-cpp/absl/functional/bind_front.h +7 -1
- data/third_party/abseil-cpp/absl/functional/function_ref.h +125 -20
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +43 -31
- data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +4 -4
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +44 -6
- data/third_party/abseil-cpp/absl/hash/hash.h +1 -1
- data/third_party/abseil-cpp/absl/hash/internal/city.cc +39 -51
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +379 -14
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +457 -353
- data/third_party/abseil-cpp/absl/log/absl_vlog_is_on.h +0 -2
- data/third_party/abseil-cpp/absl/log/internal/check_impl.h +2 -1
- data/third_party/abseil-cpp/absl/log/internal/check_op.cc +4 -0
- data/third_party/abseil-cpp/absl/log/internal/check_op.h +128 -50
- data/third_party/abseil-cpp/absl/log/internal/conditions.h +38 -35
- data/third_party/abseil-cpp/absl/log/internal/log_impl.h +108 -110
- data/third_party/abseil-cpp/absl/log/internal/log_message.cc +10 -6
- data/third_party/abseil-cpp/absl/log/internal/log_message.h +19 -1
- data/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc +4 -4
- data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -1
- data/third_party/abseil-cpp/absl/log/internal/proto.cc +13 -0
- data/third_party/abseil-cpp/absl/log/internal/strip.h +30 -31
- data/third_party/abseil-cpp/absl/log/internal/structured_proto.cc +5 -5
- data/third_party/abseil-cpp/absl/log/internal/structured_proto.h +6 -5
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.cc +30 -30
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +0 -1
- data/third_party/abseil-cpp/absl/log/log.h +2 -2
- data/third_party/abseil-cpp/absl/log/log_entry.cc +263 -0
- data/third_party/abseil-cpp/absl/log/log_entry.h +2 -0
- data/third_party/abseil-cpp/absl/log/vlog_is_on.h +0 -2
- data/third_party/abseil-cpp/absl/memory/memory.h +55 -5
- data/third_party/abseil-cpp/absl/meta/type_traits.h +161 -56
- data/third_party/abseil-cpp/absl/numeric/int128.h +41 -21
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +16 -22
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +5 -7
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +32 -4
- data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +9 -9
- data/third_party/abseil-cpp/absl/random/beta_distribution.h +2 -2
- data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +26 -53
- data/third_party/abseil-cpp/absl/random/discrete_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/distributions.h +17 -17
- data/third_party/abseil-cpp/absl/random/exponential_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +8 -21
- data/third_party/abseil-cpp/absl/random/internal/entropy_pool.cc +2 -2
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +2 -2
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +2 -2
- data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +6 -6
- data/third_party/abseil-cpp/absl/random/internal/platform.h +0 -13
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +6 -6
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +2 -2
- data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +6 -5
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +5 -31
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +2 -1
- data/third_party/abseil-cpp/absl/random/internal/traits.h +21 -0
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +23 -23
- data/third_party/abseil-cpp/absl/random/mocking_access.h +74 -0
- data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +63 -18
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +30 -4
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +225 -63
- data/third_party/abseil-cpp/absl/status/status.cc +66 -70
- data/third_party/abseil-cpp/absl/status/status.h +254 -23
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +3 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +117 -137
- data/third_party/abseil-cpp/absl/strings/ascii.h +10 -6
- data/third_party/abseil-cpp/absl/strings/cord.cc +41 -17
- data/third_party/abseil-cpp/absl/strings/cord.h +26 -17
- data/third_party/abseil-cpp/absl/strings/cord_buffer.h +4 -2
- data/third_party/abseil-cpp/absl/strings/escaping.cc +305 -125
- data/third_party/abseil-cpp/absl/strings/escaping.h +12 -2
- data/third_party/abseil-cpp/absl/strings/internal/append_and_overwrite.h +93 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +2 -2
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +6 -6
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +27 -21
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +11 -19
- data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +6 -0
- data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +1 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +0 -141
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +2 -24
- data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +31 -36
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +39 -39
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -22
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +2 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +2 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +921 -231
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +18 -16
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +16 -12
- data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.h +12 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +477 -8
- data/third_party/abseil-cpp/absl/strings/numbers.h +29 -12
- data/third_party/abseil-cpp/absl/strings/resize_and_overwrite.h +198 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +96 -91
- data/third_party/abseil-cpp/absl/strings/str_cat.h +53 -13
- data/third_party/abseil-cpp/absl/strings/str_split.h +14 -9
- data/third_party/abseil-cpp/absl/strings/string_view.h +10 -716
- data/third_party/abseil-cpp/absl/strings/substitute.cc +24 -24
- data/third_party/abseil-cpp/absl/strings/substitute.h +2 -2
- data/third_party/abseil-cpp/absl/synchronization/barrier.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +24 -3
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +30 -33
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +5 -0
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +41 -29
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +199 -94
- data/third_party/abseil-cpp/absl/synchronization/notification.cc +5 -5
- data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
- data/third_party/abseil-cpp/absl/time/clock.cc +29 -30
- data/third_party/abseil-cpp/absl/time/clock.h +3 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +2 -2
- data/third_party/abseil-cpp/absl/time/format.cc +3 -10
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +12 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +131 -91
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +6 -103
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +185 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.h +37 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +10 -15
- data/third_party/abseil-cpp/absl/time/time.cc +4 -4
- data/third_party/abseil-cpp/absl/time/time.h +14 -13
- data/third_party/abseil-cpp/absl/types/compare.h +64 -63
- data/third_party/abseil-cpp/absl/types/internal/span.h +6 -6
- data/third_party/abseil-cpp/absl/types/optional.h +31 -4
- data/third_party/abseil-cpp/absl/types/optional_ref.h +295 -0
- data/third_party/{boringssl-with-bazel/crypto/x509/x_val.cc → abseil-cpp/absl/types/source_location.cc} +4 -14
- data/third_party/abseil-cpp/absl/types/source_location.h +172 -0
- data/third_party/abseil-cpp/absl/types/span.h +67 -38
- data/third_party/abseil-cpp/absl/types/variant.h +75 -18
- data/third_party/abseil-cpp/absl/utility/utility.h +112 -16
- data/third_party/boringssl-with-bazel/crypto/aes/aes.cc +3 -0
- data/third_party/boringssl-with-bazel/crypto/armv8_feature_parsing.h +67 -0
- data/third_party/boringssl-with-bazel/crypto/asn1/a_bitstr.cc +143 -105
- data/third_party/boringssl-with-bazel/crypto/asn1/a_bool.cc +5 -8
- data/third_party/boringssl-with-bazel/crypto/asn1/a_d2i_fp.cc +3 -3
- data/third_party/boringssl-with-bazel/crypto/asn1/a_dup.cc +6 -6
- data/third_party/boringssl-with-bazel/crypto/asn1/a_gentm.cc +33 -12
- data/third_party/boringssl-with-bazel/crypto/asn1/a_i2d_fp.cc +7 -6
- data/third_party/boringssl-with-bazel/crypto/asn1/a_int.cc +80 -52
- data/third_party/boringssl-with-bazel/crypto/asn1/a_mbstr.cc +7 -4
- data/third_party/boringssl-with-bazel/crypto/asn1/a_object.cc +70 -72
- data/third_party/boringssl-with-bazel/crypto/asn1/a_strex.cc +38 -42
- data/third_party/boringssl-with-bazel/crypto/asn1/a_strnid.cc +41 -39
- data/third_party/boringssl-with-bazel/crypto/asn1/a_time.cc +59 -35
- data/third_party/boringssl-with-bazel/crypto/asn1/a_type.cc +275 -15
- data/third_party/boringssl-with-bazel/crypto/asn1/a_utctm.cc +32 -13
- data/third_party/boringssl-with-bazel/crypto/asn1/asn1_lib.cc +128 -30
- data/third_party/boringssl-with-bazel/crypto/asn1/asn_pack.cc +10 -10
- data/third_party/boringssl-with-bazel/crypto/asn1/f_int.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/asn1/f_string.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/asn1/internal.h +261 -115
- data/third_party/boringssl-with-bazel/crypto/asn1/posix_time.cc +8 -5
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_dec.cc +373 -725
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_enc.cc +211 -526
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_fre.cc +22 -19
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_new.cc +26 -24
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_typ.cc +19 -5
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_utl.cc +47 -51
- data/third_party/boringssl-with-bazel/crypto/base64/base64.cc +14 -15
- data/third_party/boringssl-with-bazel/crypto/bcm_support.h +7 -29
- data/third_party/boringssl-with-bazel/crypto/bio/bio.cc +234 -176
- data/third_party/boringssl-with-bazel/crypto/bio/bio_mem.cc +72 -86
- data/third_party/boringssl-with-bazel/crypto/bio/connect.cc +153 -199
- data/third_party/boringssl-with-bazel/crypto/bio/errno.cc +3 -1
- data/third_party/boringssl-with-bazel/crypto/bio/fd.cc +56 -55
- data/third_party/boringssl-with-bazel/crypto/bio/file.cc +70 -78
- data/third_party/boringssl-with-bazel/crypto/bio/hexdump.cc +6 -4
- data/third_party/boringssl-with-bazel/crypto/bio/internal.h +69 -17
- data/third_party/boringssl-with-bazel/crypto/bio/pair.cc +117 -136
- data/third_party/boringssl-with-bazel/crypto/bio/printf.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/bio/socket.cc +116 -50
- data/third_party/boringssl-with-bazel/crypto/bio/socket_helper.cc +53 -5
- data/third_party/boringssl-with-bazel/crypto/blake2/blake2.cc +9 -5
- data/third_party/boringssl-with-bazel/crypto/bn/bn_asn1.cc +2 -2
- data/third_party/boringssl-with-bazel/crypto/bn/convert.cc +56 -70
- data/third_party/boringssl-with-bazel/crypto/bn/div.cc +102 -0
- data/third_party/boringssl-with-bazel/crypto/bn/exponentiation.cc +26 -42
- data/third_party/boringssl-with-bazel/crypto/bn/sqrt.cc +93 -0
- data/third_party/boringssl-with-bazel/crypto/buf/buf.cc +6 -5
- data/third_party/boringssl-with-bazel/crypto/bytestring/asn1_compat.cc +6 -5
- data/third_party/boringssl-with-bazel/crypto/bytestring/ber.cc +22 -20
- data/third_party/boringssl-with-bazel/crypto/bytestring/cbb.cc +119 -59
- data/third_party/boringssl-with-bazel/crypto/bytestring/cbs.cc +115 -31
- data/third_party/boringssl-with-bazel/crypto/bytestring/internal.h +79 -24
- data/third_party/boringssl-with-bazel/crypto/bytestring/unicode.cc +2 -2
- data/third_party/boringssl-with-bazel/crypto/chacha/chacha.cc +5 -3
- data/third_party/boringssl-with-bazel/crypto/chacha/internal.h +23 -22
- data/third_party/boringssl-with-bazel/crypto/cipher/derive_key.cc +14 -18
- data/third_party/boringssl-with-bazel/crypto/cipher/e_aesctrhmac.cc +73 -58
- data/third_party/boringssl-with-bazel/crypto/cipher/e_aeseax.cc +132 -70
- data/third_party/boringssl-with-bazel/crypto/cipher/e_aesgcmsiv.cc +390 -249
- data/third_party/boringssl-with-bazel/crypto/cipher/e_chacha20poly1305.cc +200 -137
- data/third_party/boringssl-with-bazel/crypto/cipher/e_des.cc +45 -29
- data/third_party/boringssl-with-bazel/crypto/cipher/e_null.cc +9 -5
- data/third_party/boringssl-with-bazel/crypto/cipher/e_rc2.cc +43 -28
- data/third_party/boringssl-with-bazel/crypto/cipher/e_rc4.cc +7 -5
- data/third_party/boringssl-with-bazel/crypto/cipher/e_tls.cc +250 -237
- data/third_party/boringssl-with-bazel/crypto/cipher/get_cipher.cc +12 -12
- data/third_party/boringssl-with-bazel/crypto/cipher/internal.h +59 -59
- data/third_party/boringssl-with-bazel/crypto/cipher/tls_cbc.cc +111 -111
- data/third_party/boringssl-with-bazel/crypto/cms/cms.cc +48 -42
- data/third_party/boringssl-with-bazel/crypto/conf/conf.cc +69 -63
- data/third_party/boringssl-with-bazel/crypto/conf/internal.h +11 -12
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_apple.cc +8 -5
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_fuchsia.cc +6 -1
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_linux.cc +7 -1
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_openbsd.cc +7 -21
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_sysreg.cc +15 -41
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_win.cc +16 -3
- data/third_party/boringssl-with-bazel/crypto/cpu_arm_freebsd.cc +4 -2
- data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.cc +54 -31
- data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.h +79 -101
- data/third_party/boringssl-with-bazel/crypto/cpu_intel.cc +51 -45
- data/third_party/boringssl-with-bazel/crypto/crypto.cc +26 -55
- data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519.cc +28 -25
- data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519_tables.h +6 -6
- data/third_party/boringssl-with-bazel/crypto/curve25519/internal.h +14 -15
- data/third_party/boringssl-with-bazel/crypto/curve25519/spake25519.cc +23 -20
- data/third_party/boringssl-with-bazel/crypto/des/des.cc +27 -19
- data/third_party/boringssl-with-bazel/crypto/des/internal.h +4 -9
- data/third_party/boringssl-with-bazel/crypto/dh/dh_asn1.cc +34 -49
- data/third_party/boringssl-with-bazel/crypto/dh/params.cc +44 -41
- data/third_party/boringssl-with-bazel/crypto/digest/digest_extra.cc +87 -40
- data/third_party/boringssl-with-bazel/crypto/dsa/dsa.cc +237 -260
- data/third_party/boringssl-with-bazel/crypto/dsa/dsa_asn1.cc +100 -173
- data/third_party/boringssl-with-bazel/crypto/dsa/internal.h +23 -21
- data/third_party/boringssl-with-bazel/crypto/ec/ec_asn1.cc +181 -209
- data/third_party/boringssl-with-bazel/crypto/ec/ec_derive.cc +26 -28
- data/third_party/boringssl-with-bazel/crypto/ec/hash_to_curve.cc +265 -174
- data/third_party/boringssl-with-bazel/crypto/ec/internal.h +54 -18
- data/third_party/boringssl-with-bazel/crypto/ecdh/ecdh.cc +7 -5
- data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_asn1.cc +50 -70
- data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_p1363.cc +54 -0
- data/third_party/boringssl-with-bazel/crypto/engine/engine.cc +7 -7
- data/third_party/boringssl-with-bazel/crypto/err/err.cc +116 -105
- data/third_party/boringssl-with-bazel/crypto/err/internal.h +8 -21
- data/third_party/boringssl-with-bazel/crypto/evp/evp.cc +238 -166
- data/third_party/boringssl-with-bazel/crypto/evp/evp_asn1.cc +202 -234
- data/third_party/boringssl-with-bazel/crypto/evp/evp_ctx.cc +260 -159
- data/third_party/boringssl-with-bazel/crypto/evp/evp_kem.cc +82 -0
- data/third_party/boringssl-with-bazel/crypto/evp/internal.h +292 -137
- data/third_party/boringssl-with-bazel/crypto/evp/p_dh.cc +198 -25
- data/third_party/boringssl-with-bazel/crypto/evp/p_dsa.cc +333 -0
- data/third_party/boringssl-with-bazel/crypto/evp/p_ec.cc +427 -42
- data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519.cc +270 -14
- data/third_party/boringssl-with-bazel/crypto/evp/p_hkdf.cc +70 -102
- data/third_party/boringssl-with-bazel/crypto/evp/p_mldsa.cc +549 -0
- data/third_party/boringssl-with-bazel/crypto/evp/p_mlkem.cc +485 -0
- data/third_party/boringssl-with-bazel/crypto/evp/p_rsa.cc +666 -158
- data/third_party/boringssl-with-bazel/crypto/evp/p_x25519.cc +290 -28
- data/third_party/boringssl-with-bazel/crypto/evp/p_xwing.cc +273 -0
- data/third_party/boringssl-with-bazel/crypto/evp/pbkdf.cc +14 -7
- data/third_party/boringssl-with-bazel/crypto/evp/print.cc +34 -89
- data/third_party/boringssl-with-bazel/crypto/evp/scrypt.cc +23 -21
- data/third_party/boringssl-with-bazel/crypto/evp/sign.cc +23 -42
- data/third_party/boringssl-with-bazel/crypto/ex_data.cc +40 -41
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes.cc.inc +34 -28
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes_nohw.cc.inc +119 -121
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cbc.cc.inc +16 -14
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cfb.cc.inc +12 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ctr.cc.inc +7 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm.cc.inc +39 -29
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm_nohw.cc.inc +15 -13
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/internal.h +193 -177
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/key_wrap.cc.inc +5 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/mode_wrappers.cc.inc +7 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ofb.cc.inc +7 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm.cc +24 -19
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm_interface.h +512 -384
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/add.cc.inc +7 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +63 -44
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bn.cc.inc +40 -37
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bytes.cc.inc +27 -22
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/cmp.cc.inc +9 -7
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/ctx.cc.inc +62 -126
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div.cc.inc +92 -167
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div_extra.cc.inc +15 -12
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/exponentiation.cc.inc +96 -93
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd.cc.inc +73 -92
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd_extra.cc.inc +59 -71
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/generic.cc.inc +54 -57
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/internal.h +333 -255
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/jacobi.cc.inc +12 -19
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery.cc.inc +80 -95
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery_inv.cc.inc +53 -96
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/mul.cc.inc +58 -419
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/prime.cc.inc +164 -213
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/random.cc.inc +27 -26
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.cc.inc +12 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.h +47 -49
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/shift.cc.inc +14 -17
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/sqrt.cc.inc +19 -108
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/aead.cc.inc +427 -105
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/cipher.cc.inc +412 -212
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aes.cc.inc +230 -225
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aesccm.cc.inc +115 -84
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/internal.h +374 -27
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cmac/cmac.cc.inc +28 -23
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/delocate.h +36 -40
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/check.cc.inc +68 -78
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/dh.cc.inc +154 -196
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/internal.h +24 -24
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digest.cc.inc +40 -69
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digests.cc.inc +13 -7
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/internal.h +13 -11
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/md32_common.h +86 -81
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digestsign/digestsign.cc.inc +38 -34
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec.cc.inc +187 -196
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_key.cc.inc +196 -154
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_montgomery.cc.inc +65 -125
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/felem.cc.inc +85 -22
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/internal.h +281 -287
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/oct.cc.inc +23 -22
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256.cc.inc +514 -573
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256_internal.h +193 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/scalar.cc.inc +44 -39
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple.cc.inc +58 -90
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple_mul.cc.inc +39 -34
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/util.cc.inc +6 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/wnaf.cc.inc +23 -20
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdh/ecdh.cc.inc +6 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +47 -37
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/internal.h +5 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/internal.h +38 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/jitter.cc.inc +463 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/sha512.cc.inc +329 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/hkdf/hkdf.cc.inc +8 -6
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/hmac/hmac.cc.inc +19 -16
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/internal.h +41 -15
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/keccak.cc.inc +172 -44
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/fips_known_values.inc +5 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/mldsa.cc.inc +1632 -766
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/fips_known_values.inc +5 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/mlkem.cc.inc +740 -436
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/android_entropy_client.cc.inc +82 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/ctrdrbg.cc.inc +240 -53
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/internal.h +41 -26
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/rand.cc.inc +221 -218
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/internal.h +64 -67
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/padding.cc.inc +49 -57
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa.cc.inc +247 -234
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa_impl.cc.inc +392 -692
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/fips.cc.inc +10 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/self_check.cc.inc +479 -449
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/internal.h +34 -11
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/service_indicator.cc.inc +46 -43
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/internal.h +61 -70
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha1.cc.inc +27 -13
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha256.cc.inc +46 -30
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha512.cc.inc +47 -47
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/address.h +98 -73
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.cc.inc +108 -98
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.h +14 -24
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.cc.inc +94 -91
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.h +19 -31
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/params.h +156 -56
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/slhdsa.cc.inc +318 -132
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.cc.inc +234 -81
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.h +20 -34
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.cc.inc +97 -96
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.h +10 -20
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/internal.h +2 -16
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/kdf.cc.inc +26 -26
- data/third_party/boringssl-with-bazel/crypto/fuzzer_mode.cc +5 -5
- data/third_party/boringssl-with-bazel/crypto/hpke/hpke.cc +461 -97
- data/third_party/boringssl-with-bazel/crypto/hrss/hrss.cc +153 -149
- data/third_party/boringssl-with-bazel/crypto/hrss/internal.h +9 -13
- data/third_party/boringssl-with-bazel/crypto/internal.h +531 -394
- data/third_party/boringssl-with-bazel/crypto/kyber/internal.h +117 -12
- data/third_party/boringssl-with-bazel/crypto/kyber/kyber.cc +59 -58
- data/third_party/boringssl-with-bazel/crypto/lhash/internal.h +38 -37
- data/third_party/boringssl-with-bazel/crypto/lhash/lhash.cc +68 -65
- data/third_party/boringssl-with-bazel/crypto/md4/md4.cc +19 -6
- data/third_party/boringssl-with-bazel/crypto/md5/internal.h +6 -9
- data/third_party/boringssl-with-bazel/crypto/md5/md5.cc +18 -6
- data/third_party/boringssl-with-bazel/crypto/mem.cc +61 -65
- data/third_party/boringssl-with-bazel/crypto/mem_internal.h +671 -0
- data/third_party/boringssl-with-bazel/crypto/mldsa/mldsa.cc +238 -32
- data/third_party/boringssl-with-bazel/crypto/mlkem/mlkem.cc +21 -65
- data/third_party/boringssl-with-bazel/crypto/obj/obj.cc +132 -157
- data/third_party/boringssl-with-bazel/crypto/obj/obj_dat.h +79 -1
- data/third_party/boringssl-with-bazel/crypto/obj/obj_xref.cc +14 -11
- data/third_party/boringssl-with-bazel/crypto/params_internal.h +30 -0
- data/third_party/boringssl-with-bazel/crypto/pem/internal.h +20 -15
- data/third_party/boringssl-with-bazel/crypto/pem/pem_all.cc +20 -19
- data/third_party/boringssl-with-bazel/crypto/pem/pem_info.cc +72 -76
- data/third_party/boringssl-with-bazel/crypto/pem/pem_lib.cc +215 -217
- data/third_party/boringssl-with-bazel/crypto/pem/pem_oth.cc +6 -6
- data/third_party/boringssl-with-bazel/crypto/pem/pem_pk8.cc +13 -13
- data/third_party/boringssl-with-bazel/crypto/pem/pem_pkey.cc +11 -11
- data/third_party/boringssl-with-bazel/crypto/pkcs7/internal.h +12 -17
- data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7.cc +29 -27
- data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7_x509.cc +55 -49
- data/third_party/boringssl-with-bazel/crypto/pkcs8/internal.h +21 -26
- data/third_party/boringssl-with-bazel/crypto/pkcs8/p5_pbev2.cc +33 -31
- data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8.cc +73 -81
- data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8_x509.cc +139 -138
- data/third_party/boringssl-with-bazel/crypto/poly1305/internal.h +3 -7
- data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305.cc +5 -4
- data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_arm.cc +43 -47
- data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_vec.cc +29 -26
- data/third_party/boringssl-with-bazel/crypto/pool/internal.h +64 -20
- data/third_party/boringssl-with-bazel/crypto/pool/pool.cc +177 -157
- data/third_party/boringssl-with-bazel/crypto/rand/deterministic.cc +9 -16
- data/third_party/boringssl-with-bazel/crypto/rand/fork_detect.cc +70 -42
- data/third_party/boringssl-with-bazel/crypto/rand/forkunsafe.cc +7 -7
- data/third_party/boringssl-with-bazel/crypto/rand/getentropy.cc +6 -13
- data/third_party/boringssl-with-bazel/crypto/rand/internal.h +16 -4
- data/third_party/boringssl-with-bazel/crypto/rand/ios.cc +4 -11
- data/third_party/boringssl-with-bazel/crypto/rand/rand.cc +11 -9
- data/third_party/boringssl-with-bazel/crypto/rand/trusty.cc +4 -11
- data/third_party/boringssl-with-bazel/crypto/rand/urandom.cc +16 -195
- data/third_party/boringssl-with-bazel/crypto/rand/windows.cc +12 -19
- data/third_party/boringssl-with-bazel/crypto/refcount.cc +7 -17
- data/third_party/boringssl-with-bazel/crypto/rsa/internal.h +22 -7
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_asn1.cc +199 -78
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_crypt.cc +49 -50
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_extra.cc +11 -0
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_print.cc +4 -6
- data/third_party/boringssl-with-bazel/crypto/sha/sha1.cc +3 -0
- data/third_party/boringssl-with-bazel/crypto/sha/sha256.cc +3 -1
- data/third_party/boringssl-with-bazel/crypto/sha/sha512.cc +6 -4
- data/third_party/boringssl-with-bazel/crypto/siphash/siphash.cc +2 -0
- data/third_party/boringssl-with-bazel/crypto/slhdsa/slhdsa.cc +43 -6
- data/third_party/boringssl-with-bazel/crypto/spake2plus/internal.h +31 -31
- data/third_party/boringssl-with-bazel/crypto/spake2plus/spake2plus.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/stack/stack.cc +89 -130
- data/third_party/boringssl-with-bazel/crypto/thread.cc +14 -14
- data/third_party/boringssl-with-bazel/crypto/thread_none.cc +10 -13
- data/third_party/boringssl-with-bazel/crypto/thread_pthread.cc +22 -35
- data/third_party/boringssl-with-bazel/crypto/thread_win.cc +29 -40
- data/third_party/boringssl-with-bazel/crypto/trust_token/internal.h +81 -88
- data/third_party/boringssl-with-bazel/crypto/trust_token/pmbtoken.cc +160 -144
- data/third_party/boringssl-with-bazel/crypto/trust_token/trust_token.cc +96 -80
- data/third_party/boringssl-with-bazel/crypto/trust_token/voprf.cc +90 -87
- data/third_party/boringssl-with-bazel/crypto/x509/a_digest.cc +5 -5
- data/third_party/boringssl-with-bazel/crypto/x509/a_sign.cc +51 -48
- data/third_party/boringssl-with-bazel/crypto/x509/a_verify.cc +30 -34
- data/third_party/boringssl-with-bazel/crypto/x509/algorithm.cc +47 -16
- data/third_party/boringssl-with-bazel/crypto/x509/asn1_gen.cc +41 -43
- data/third_party/boringssl-with-bazel/crypto/x509/by_dir.cc +183 -237
- data/third_party/boringssl-with-bazel/crypto/x509/by_file.cc +29 -30
- data/third_party/boringssl-with-bazel/crypto/x509/internal.h +276 -180
- data/third_party/boringssl-with-bazel/crypto/x509/name_print.cc +15 -13
- data/third_party/boringssl-with-bazel/crypto/x509/policy.cc +415 -525
- data/third_party/boringssl-with-bazel/crypto/x509/rsa_pss.cc +94 -271
- data/third_party/boringssl-with-bazel/crypto/x509/t_crl.cc +11 -8
- data/third_party/boringssl-with-bazel/crypto/x509/t_req.cc +26 -23
- data/third_party/boringssl-with-bazel/crypto/x509/t_x509.cc +26 -22
- data/third_party/boringssl-with-bazel/crypto/x509/t_x509a.cc +3 -1
- data/third_party/boringssl-with-bazel/crypto/x509/v3_akey.cc +69 -76
- data/third_party/boringssl-with-bazel/crypto/x509/v3_akeya.cc +2 -2
- data/third_party/boringssl-with-bazel/crypto/x509/v3_alt.cc +112 -69
- data/third_party/boringssl-with-bazel/crypto/x509/v3_bcons.cc +15 -14
- data/third_party/boringssl-with-bazel/crypto/x509/v3_bitst.cc +16 -18
- data/third_party/boringssl-with-bazel/crypto/x509/v3_conf.cc +62 -67
- data/third_party/boringssl-with-bazel/crypto/x509/v3_cpols.cc +143 -170
- data/third_party/boringssl-with-bazel/crypto/x509/v3_crld.cc +121 -165
- data/third_party/boringssl-with-bazel/crypto/x509/v3_enum.cc +13 -12
- data/third_party/boringssl-with-bazel/crypto/x509/v3_extku.cc +17 -34
- data/third_party/boringssl-with-bazel/crypto/x509/v3_genn.cc +20 -10
- data/third_party/boringssl-with-bazel/crypto/x509/v3_ia5.cc +22 -18
- data/third_party/boringssl-with-bazel/crypto/x509/v3_info.cc +45 -47
- data/third_party/boringssl-with-bazel/crypto/x509/v3_int.cc +35 -33
- data/third_party/boringssl-with-bazel/crypto/x509/v3_lib.cc +106 -61
- data/third_party/boringssl-with-bazel/crypto/x509/v3_ncons.cc +642 -358
- data/third_party/boringssl-with-bazel/crypto/x509/v3_ocsp.cc +25 -22
- data/third_party/boringssl-with-bazel/crypto/x509/v3_pcons.cc +15 -14
- data/third_party/boringssl-with-bazel/crypto/x509/v3_pmaps.cc +16 -15
- data/third_party/boringssl-with-bazel/crypto/x509/v3_prn.cc +6 -6
- data/third_party/boringssl-with-bazel/crypto/x509/v3_purp.cc +150 -137
- data/third_party/boringssl-with-bazel/crypto/x509/v3_skey.cc +23 -26
- data/third_party/boringssl-with-bazel/crypto/x509/v3_utl.cc +151 -178
- data/third_party/boringssl-with-bazel/crypto/x509/x509.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/x509/x509_att.cc +32 -30
- data/third_party/boringssl-with-bazel/crypto/x509/x509_cmp.cc +95 -88
- data/third_party/boringssl-with-bazel/crypto/x509/x509_d2.cc +9 -9
- data/third_party/boringssl-with-bazel/crypto/x509/x509_def.cc +6 -8
- data/third_party/boringssl-with-bazel/crypto/x509/x509_ext.cc +46 -24
- data/third_party/boringssl-with-bazel/crypto/x509/x509_lu.cc +211 -195
- data/third_party/boringssl-with-bazel/crypto/x509/x509_obj.cc +20 -16
- data/third_party/boringssl-with-bazel/crypto/x509/x509_req.cc +37 -46
- data/third_party/boringssl-with-bazel/crypto/x509/x509_set.cc +62 -90
- data/third_party/boringssl-with-bazel/crypto/x509/x509_trs.cc +18 -13
- data/third_party/boringssl-with-bazel/crypto/x509/x509_v3.cc +33 -33
- data/third_party/boringssl-with-bazel/crypto/x509/x509_vfy.cc +109 -110
- data/third_party/boringssl-with-bazel/crypto/x509/x509_vpm.cc +56 -47
- data/third_party/boringssl-with-bazel/crypto/x509/x509cset.cc +27 -40
- data/third_party/boringssl-with-bazel/crypto/x509/x509name.cc +77 -67
- data/third_party/boringssl-with-bazel/crypto/x509/x509rset.cc +5 -17
- data/third_party/boringssl-with-bazel/crypto/x509/x509spki.cc +13 -13
- data/third_party/boringssl-with-bazel/crypto/x509/x_algor.cc +131 -24
- data/third_party/boringssl-with-bazel/crypto/x509/x_all.cc +72 -39
- data/third_party/boringssl-with-bazel/crypto/x509/x_attrib.cc +10 -4
- data/third_party/boringssl-with-bazel/crypto/x509/x_crl.cc +77 -44
- data/third_party/boringssl-with-bazel/crypto/x509/x_exten.cc +6 -0
- data/third_party/boringssl-with-bazel/crypto/x509/x_name.cc +311 -383
- data/third_party/boringssl-with-bazel/crypto/x509/x_pubkey.cc +129 -82
- data/third_party/boringssl-with-bazel/crypto/x509/x_req.cc +11 -6
- data/third_party/boringssl-with-bazel/crypto/x509/x_sig.cc +4 -4
- data/third_party/boringssl-with-bazel/crypto/x509/x_spki.cc +11 -1
- data/third_party/boringssl-with-bazel/crypto/x509/x_x509.cc +285 -280
- data/third_party/boringssl-with-bazel/crypto/x509/x_x509a.cc +60 -60
- data/third_party/boringssl-with-bazel/crypto/xwing/xwing.cc +257 -0
- data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +301 -0
- data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +301 -0
- data/third_party/boringssl-with-bazel/gen/crypto/err_data.cc +526 -500
- data/third_party/boringssl-with-bazel/include/openssl/aead.h +286 -114
- data/third_party/boringssl-with-bazel/include/openssl/aes.h +43 -43
- data/third_party/boringssl-with-bazel/include/openssl/asm_base.h +29 -16
- data/third_party/boringssl-with-bazel/include/openssl/asn1.h +641 -631
- data/third_party/boringssl-with-bazel/include/openssl/asn1t.h +7 -9
- data/third_party/boringssl-with-bazel/include/openssl/base.h +34 -54
- data/third_party/boringssl-with-bazel/include/openssl/base64.h +30 -30
- data/third_party/boringssl-with-bazel/include/openssl/bio.h +373 -316
- data/third_party/boringssl-with-bazel/include/openssl/blake2.h +15 -11
- data/third_party/boringssl-with-bazel/include/openssl/blowfish.h +10 -3
- data/third_party/boringssl-with-bazel/include/openssl/bn.h +298 -306
- data/third_party/boringssl-with-bazel/include/openssl/buf.h +14 -14
- data/third_party/boringssl-with-bazel/include/openssl/bytestring.h +272 -207
- data/third_party/boringssl-with-bazel/include/openssl/cast.h +45 -8
- data/third_party/boringssl-with-bazel/include/openssl/chacha.h +3 -3
- data/third_party/boringssl-with-bazel/include/openssl/cipher.h +334 -152
- data/third_party/boringssl-with-bazel/include/openssl/cmac.h +13 -13
- data/third_party/boringssl-with-bazel/include/openssl/cms.h +35 -34
- data/third_party/boringssl-with-bazel/include/openssl/conf.h +15 -14
- data/third_party/boringssl-with-bazel/include/openssl/crypto.h +15 -13
- data/third_party/boringssl-with-bazel/include/openssl/ctrdrbg.h +49 -15
- data/third_party/boringssl-with-bazel/include/openssl/curve25519.h +24 -24
- data/third_party/boringssl-with-bazel/include/openssl/des.h +22 -16
- data/third_party/boringssl-with-bazel/include/openssl/dh.h +95 -95
- data/third_party/boringssl-with-bazel/include/openssl/digest.h +140 -71
- data/third_party/boringssl-with-bazel/include/openssl/dsa.h +101 -101
- data/third_party/boringssl-with-bazel/include/openssl/ec.h +143 -119
- data/third_party/boringssl-with-bazel/include/openssl/ec_key.h +97 -97
- data/third_party/boringssl-with-bazel/include/openssl/ecdh.h +9 -9
- data/third_party/boringssl-with-bazel/include/openssl/ecdsa.h +89 -46
- data/third_party/boringssl-with-bazel/include/openssl/engine.h +5 -5
- data/third_party/boringssl-with-bazel/include/openssl/err.h +73 -71
- data/third_party/boringssl-with-bazel/include/openssl/evp.h +824 -344
- data/third_party/boringssl-with-bazel/include/openssl/evp_errors.h +9 -2
- data/third_party/boringssl-with-bazel/include/openssl/ex_data.h +27 -32
- data/third_party/boringssl-with-bazel/include/openssl/hkdf.h +6 -6
- data/third_party/boringssl-with-bazel/include/openssl/hmac.h +31 -31
- data/third_party/boringssl-with-bazel/include/openssl/hpke.h +133 -117
- data/third_party/boringssl-with-bazel/include/openssl/hrss.h +14 -8
- data/third_party/boringssl-with-bazel/include/openssl/kdf.h +20 -19
- data/third_party/boringssl-with-bazel/include/openssl/lhash.h +4 -25
- data/third_party/boringssl-with-bazel/include/openssl/md4.h +14 -7
- data/third_party/boringssl-with-bazel/include/openssl/md5.h +7 -7
- data/third_party/boringssl-with-bazel/include/openssl/mem.h +38 -38
- data/third_party/boringssl-with-bazel/include/openssl/mldsa.h +380 -24
- data/third_party/boringssl-with-bazel/include/openssl/mlkem.h +43 -43
- data/third_party/boringssl-with-bazel/include/openssl/nid.h +1297 -2
- data/third_party/boringssl-with-bazel/include/openssl/obj.h +49 -49
- data/third_party/boringssl-with-bazel/include/openssl/opensslconf.h +30 -0
- data/third_party/boringssl-with-bazel/include/openssl/params.h +42 -0
- data/third_party/boringssl-with-bazel/include/openssl/pem.h +39 -30
- data/third_party/boringssl-with-bazel/include/openssl/pkcs7.h +40 -40
- data/third_party/boringssl-with-bazel/include/openssl/pkcs8.h +69 -63
- data/third_party/boringssl-with-bazel/include/openssl/poly1305.h +8 -5
- data/third_party/boringssl-with-bazel/include/openssl/pool.h +54 -25
- data/third_party/boringssl-with-bazel/include/openssl/posix_time.h +6 -6
- data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols.h +7866 -0
- data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_S.h +585 -0
- data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_c.h +305 -0
- data/third_party/boringssl-with-bazel/include/openssl/rand.h +18 -18
- data/third_party/boringssl-with-bazel/include/openssl/rc4.h +4 -4
- data/third_party/boringssl-with-bazel/include/openssl/ripemd.h +15 -10
- data/third_party/boringssl-with-bazel/include/openssl/rsa.h +272 -235
- data/third_party/boringssl-with-bazel/include/openssl/service_indicator.h +4 -81
- data/third_party/boringssl-with-bazel/include/openssl/sha.h +43 -166
- data/third_party/boringssl-with-bazel/include/openssl/sha2.h +201 -0
- data/third_party/boringssl-with-bazel/include/openssl/slhdsa.h +100 -48
- data/third_party/boringssl-with-bazel/include/openssl/span.h +190 -75
- data/third_party/boringssl-with-bazel/include/openssl/ssl.h +2168 -1567
- data/third_party/boringssl-with-bazel/include/openssl/ssl3.h +11 -69
- data/third_party/boringssl-with-bazel/include/openssl/stack.h +135 -80
- data/third_party/boringssl-with-bazel/include/openssl/target.h +13 -1
- data/third_party/boringssl-with-bazel/include/openssl/thread.h +0 -10
- data/third_party/boringssl-with-bazel/include/openssl/tls1.h +31 -310
- data/third_party/boringssl-with-bazel/include/openssl/tls_prf.h +47 -0
- data/third_party/boringssl-with-bazel/include/openssl/trust_token.h +97 -92
- data/third_party/boringssl-with-bazel/include/openssl/type_check.h +1 -1
- data/third_party/boringssl-with-bazel/include/openssl/x509.h +1805 -1857
- data/third_party/boringssl-with-bazel/include/openssl/x509v3.h +1 -1
- data/third_party/boringssl-with-bazel/include/openssl/xwing.h +115 -0
- data/third_party/boringssl-with-bazel/ssl/bio_ssl.cc +24 -19
- data/third_party/boringssl-with-bazel/ssl/d1_both.cc +59 -57
- data/third_party/boringssl-with-bazel/ssl/d1_lib.cc +53 -42
- data/third_party/boringssl-with-bazel/ssl/d1_pkt.cc +4 -4
- data/third_party/boringssl-with-bazel/ssl/d1_srtp.cc +2 -2
- data/third_party/boringssl-with-bazel/ssl/dtls_method.cc +10 -10
- data/third_party/boringssl-with-bazel/ssl/dtls_record.cc +6 -6
- data/third_party/boringssl-with-bazel/ssl/encrypted_client_hello.cc +61 -71
- data/third_party/boringssl-with-bazel/ssl/extensions.cc +967 -366
- data/third_party/boringssl-with-bazel/ssl/handoff.cc +77 -38
- data/third_party/boringssl-with-bazel/ssl/handshake.cc +63 -30
- data/third_party/boringssl-with-bazel/ssl/handshake_client.cc +129 -85
- data/third_party/boringssl-with-bazel/ssl/handshake_server.cc +116 -68
- data/third_party/boringssl-with-bazel/ssl/internal.h +983 -1207
- data/third_party/boringssl-with-bazel/ssl/s3_both.cc +34 -29
- data/third_party/boringssl-with-bazel/ssl/s3_lib.cc +4 -3
- data/third_party/boringssl-with-bazel/ssl/s3_pkt.cc +12 -12
- data/third_party/boringssl-with-bazel/ssl/ssl_aead_ctx.cc +5 -5
- data/third_party/boringssl-with-bazel/ssl/ssl_asn1.cc +114 -59
- data/third_party/boringssl-with-bazel/ssl/ssl_buffer.cc +17 -18
- data/third_party/boringssl-with-bazel/ssl/ssl_cert.cc +99 -61
- data/third_party/boringssl-with-bazel/ssl/ssl_cipher.cc +143 -134
- data/third_party/boringssl-with-bazel/ssl/ssl_credential.cc +188 -90
- data/third_party/boringssl-with-bazel/ssl/ssl_file.cc +132 -225
- data/third_party/boringssl-with-bazel/ssl/ssl_key_share.cc +79 -7
- data/third_party/boringssl-with-bazel/ssl/ssl_lib.cc +698 -302
- data/third_party/boringssl-with-bazel/ssl/ssl_privkey.cc +102 -45
- data/third_party/boringssl-with-bazel/ssl/ssl_session.cc +117 -102
- data/third_party/boringssl-with-bazel/ssl/ssl_transcript.cc +3 -3
- data/third_party/boringssl-with-bazel/ssl/ssl_versions.cc +24 -24
- data/third_party/boringssl-with-bazel/ssl/ssl_x509.cc +184 -170
- data/third_party/boringssl-with-bazel/ssl/t1_enc.cc +12 -10
- data/third_party/boringssl-with-bazel/ssl/tls13_both.cc +86 -54
- data/third_party/boringssl-with-bazel/ssl/tls13_client.cc +176 -90
- data/third_party/boringssl-with-bazel/ssl/tls13_enc.cc +166 -112
- data/third_party/boringssl-with-bazel/ssl/tls13_server.cc +188 -97
- data/third_party/boringssl-with-bazel/ssl/tls_method.cc +23 -23
- data/third_party/boringssl-with-bazel/ssl/tls_record.cc +17 -14
- data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_bareminimum.c.inc +47 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_platform.c.inc +137 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/curve25519_64_adx.h +37 -33
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_64.h +4 -93
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_64_msvc.h +4 -69
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_32.br.c.inc +71 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_64.br.c.inc +84 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_point.br.c.inc +166 -0
- metadata +77 -52
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +0 -240
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +0 -56
- data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb.h +0 -157
- data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb_minitable.c +0 -72
- data/src/core/ext/upbdefs-gen/src/proto/grpc/lookup/v1/rls_config.upbdefs.c +0 -181
- data/third_party/abseil-cpp/absl/base/internal/identity.h +0 -39
- data/third_party/abseil-cpp/absl/base/internal/nullability_deprecated.h +0 -106
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +0 -105
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +0 -50
- data/third_party/abseil-cpp/absl/strings/string_view.cc +0 -257
- data/third_party/boringssl-with-bazel/crypto/evp/p_dh_asn1.cc +0 -142
- data/third_party/boringssl-with-bazel/crypto/evp/p_dsa_asn1.cc +0 -279
- data/third_party/boringssl-with-bazel/crypto/evp/p_ec_asn1.cc +0 -286
- data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519_asn1.cc +0 -225
- data/third_party/boringssl-with-bazel/crypto/evp/p_rsa_asn1.cc +0 -198
- data/third_party/boringssl-with-bazel/crypto/evp/p_x25519_asn1.cc +0 -237
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p224-64.cc.inc +0 -1163
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.cc.inc +0 -741
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.h +0 -207
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/blinding.cc.inc +0 -147
- data/third_party/boringssl-with-bazel/crypto/rand/getrandom_fillin.h +0 -64
- data/third_party/boringssl-with-bazel/crypto/rand/passive.cc +0 -178
- data/third_party/boringssl-with-bazel/crypto/x509/ext_dat.h +0 -92
- data/third_party/boringssl-with-bazel/include/openssl/bcm_public.h +0 -82
- data/third_party/boringssl-with-bazel/include/openssl/experimental/kyber.h +0 -146
|
@@ -20,11 +20,14 @@
|
|
|
20
20
|
#include <string.h>
|
|
21
21
|
|
|
22
22
|
#include <algorithm>
|
|
23
|
+
#include <optional>
|
|
23
24
|
#include <utility>
|
|
25
|
+
#include <variant>
|
|
24
26
|
|
|
25
27
|
#include <openssl/aead.h>
|
|
26
28
|
#include <openssl/bytestring.h>
|
|
27
29
|
#include <openssl/chacha.h>
|
|
30
|
+
#include <openssl/cipher.h>
|
|
28
31
|
#include <openssl/curve25519.h>
|
|
29
32
|
#include <openssl/digest.h>
|
|
30
33
|
#include <openssl/err.h>
|
|
@@ -33,9 +36,12 @@
|
|
|
33
36
|
#include <openssl/hpke.h>
|
|
34
37
|
#include <openssl/mem.h>
|
|
35
38
|
#include <openssl/nid.h>
|
|
39
|
+
#include <openssl/pool.h>
|
|
36
40
|
#include <openssl/rand.h>
|
|
37
41
|
|
|
42
|
+
#include "../crypto/bytestring/internal.h"
|
|
38
43
|
#include "../crypto/internal.h"
|
|
44
|
+
#include "../crypto/mem_internal.h"
|
|
39
45
|
#include "../crypto/spake2plus/internal.h"
|
|
40
46
|
#include "internal.h"
|
|
41
47
|
|
|
@@ -102,6 +108,7 @@ static bool is_post_quantum_group(uint16_t id) {
|
|
|
102
108
|
switch (id) {
|
|
103
109
|
case SSL_GROUP_X25519_KYBER768_DRAFT00:
|
|
104
110
|
case SSL_GROUP_X25519_MLKEM768:
|
|
111
|
+
case SSL_GROUP_MLKEM1024:
|
|
105
112
|
return true;
|
|
106
113
|
default:
|
|
107
114
|
return false;
|
|
@@ -199,19 +206,6 @@ bool ssl_client_hello_get_extension(const SSL_CLIENT_HELLO *client_hello,
|
|
|
199
206
|
return false;
|
|
200
207
|
}
|
|
201
208
|
|
|
202
|
-
static const uint16_t kDefaultGroups[] = {
|
|
203
|
-
SSL_GROUP_X25519,
|
|
204
|
-
SSL_GROUP_SECP256R1,
|
|
205
|
-
SSL_GROUP_SECP384R1,
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
Span<const uint16_t> tls1_get_grouplist(const SSL_HANDSHAKE *hs) {
|
|
209
|
-
if (!hs->config->supported_group_list.empty()) {
|
|
210
|
-
return hs->config->supported_group_list;
|
|
211
|
-
}
|
|
212
|
-
return Span<const uint16_t>(kDefaultGroups);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
209
|
bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id) {
|
|
216
210
|
SSL *const ssl = hs->ssl;
|
|
217
211
|
assert(ssl->server);
|
|
@@ -222,33 +216,53 @@ bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id) {
|
|
|
222
216
|
//
|
|
223
217
|
// However, in the interests of compatibility, we will skip ECDH if the
|
|
224
218
|
// client didn't send an extension because we can't be sure that they'll
|
|
225
|
-
// support our favoured group. Thus we do not special-case an
|
|
226
|
-
//
|
|
219
|
+
// support our favoured group. Thus we do not special-case an empty
|
|
220
|
+
// `peer_supported_group_list`.
|
|
227
221
|
|
|
228
|
-
Span<const uint16_t> groups =
|
|
222
|
+
Span<const uint16_t> groups = hs->config->supported_group_list;
|
|
229
223
|
Span<const uint16_t> pref, supp;
|
|
224
|
+
Span<const uint32_t> pref_flags;
|
|
230
225
|
if (ssl->options & SSL_OP_CIPHER_SERVER_PREFERENCE) {
|
|
231
226
|
pref = groups;
|
|
227
|
+
pref_flags = hs->config->supported_group_list_flags;
|
|
232
228
|
supp = hs->peer_supported_group_list;
|
|
233
229
|
} else {
|
|
234
230
|
pref = hs->peer_supported_group_list;
|
|
235
231
|
supp = groups;
|
|
236
232
|
}
|
|
237
233
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
234
|
+
// Index within `supp` of the best matching group so far.
|
|
235
|
+
std::optional<size_t> best_match;
|
|
236
|
+
for (size_t i = 0u; i < pref.size(); ++i) {
|
|
237
|
+
uint16_t candidate_group = pref[i];
|
|
238
|
+
auto match_it = std::find(supp.begin(), supp.end(), candidate_group);
|
|
239
|
+
// Post-quantum key agreements don't fit in the u8-length-prefixed
|
|
240
|
+
// ECPoint field in TLS 1.2 and below.
|
|
241
|
+
if (ssl_protocol_version(ssl) < TLS1_3_VERSION &&
|
|
242
|
+
is_post_quantum_group(candidate_group)) {
|
|
243
|
+
match_it = supp.end();
|
|
244
|
+
}
|
|
245
|
+
if (match_it != supp.end()) {
|
|
246
|
+
size_t match_idx = match_it - supp.begin();
|
|
247
|
+
if (!best_match.has_value() || match_idx < *best_match) {
|
|
248
|
+
best_match = match_idx;
|
|
247
249
|
}
|
|
248
250
|
}
|
|
251
|
+
|
|
252
|
+
// If we found a match, stop at the current equipreference group.
|
|
253
|
+
bool equal_with_next =
|
|
254
|
+
!pref_flags.empty() &&
|
|
255
|
+
(pref_flags[i] & SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT);
|
|
256
|
+
if (!equal_with_next && best_match.has_value()) {
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
249
259
|
}
|
|
250
260
|
|
|
251
|
-
|
|
261
|
+
if (!best_match.has_value()) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
*out_group_id = supp[*best_match];
|
|
265
|
+
return true;
|
|
252
266
|
}
|
|
253
267
|
|
|
254
268
|
bool tls1_check_group_id(const SSL_HANDSHAKE *hs, uint16_t group_id) {
|
|
@@ -263,7 +277,7 @@ bool tls1_check_group_id(const SSL_HANDSHAKE *hs, uint16_t group_id) {
|
|
|
263
277
|
return false;
|
|
264
278
|
}
|
|
265
279
|
|
|
266
|
-
for (uint16_t supported :
|
|
280
|
+
for (uint16_t supported : hs->config->supported_group_list) {
|
|
267
281
|
if (supported == group_id) {
|
|
268
282
|
return true;
|
|
269
283
|
}
|
|
@@ -296,6 +310,11 @@ static const uint16_t kVerifySignatureAlgorithms[] = {
|
|
|
296
310
|
// algorithms for signing.
|
|
297
311
|
static const uint16_t kSignSignatureAlgorithms[] = {
|
|
298
312
|
// List our preferred algorithms first.
|
|
313
|
+
SSL_SIGN_ML_DSA_44,
|
|
314
|
+
SSL_SIGN_ML_DSA_65,
|
|
315
|
+
SSL_SIGN_ML_DSA_87,
|
|
316
|
+
|
|
317
|
+
// Classical signature algorithms.
|
|
299
318
|
SSL_SIGN_ED25519,
|
|
300
319
|
SSL_SIGN_ECDSA_SECP256R1_SHA256,
|
|
301
320
|
SSL_SIGN_RSA_PSS_RSAE_SHA256,
|
|
@@ -428,7 +447,7 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
|
|
|
428
447
|
return false;
|
|
429
448
|
}
|
|
430
449
|
|
|
431
|
-
// Check for unsolicited flags that fit in
|
|
450
|
+
// Check for unsolicited flags that fit in `SSLFlags`.
|
|
432
451
|
if ((*out & allowed_flags) != *out) {
|
|
433
452
|
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
|
|
434
453
|
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
@@ -440,30 +459,30 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
|
|
|
440
459
|
|
|
441
460
|
// tls_extension represents a TLS extension that is handled internally.
|
|
442
461
|
//
|
|
443
|
-
// The parse callbacks receive a
|
|
462
|
+
// The parse callbacks receive a `CBS` that contains the contents of the
|
|
444
463
|
// extension (i.e. not including the type and length bytes). If an extension is
|
|
445
464
|
// not received then the parse callbacks will be called with a NULL CBS so that
|
|
446
465
|
// they can do any processing needed to handle the absence of an extension.
|
|
447
466
|
//
|
|
448
|
-
// The add callbacks receive a
|
|
467
|
+
// The add callbacks receive a `CBB` to which the extension can be appended but
|
|
449
468
|
// the function is responsible for appending the type and length bytes too.
|
|
450
469
|
//
|
|
451
|
-
//
|
|
452
|
-
// is additionally passed two output
|
|
453
|
-
// independent of the value of
|
|
454
|
-
//
|
|
455
|
-
// all compressible extensions will be made
|
|
470
|
+
// `add_clienthello` may be called multiple times and must not mutate `hs`. It
|
|
471
|
+
// is additionally passed two output `CBB`s. If the extension is the same
|
|
472
|
+
// independent of the value of `type`, the callback may write to
|
|
473
|
+
// `out_compressible` instead of `out`. When serializing the ClientHelloInner,
|
|
474
|
+
// all compressible extensions will be made contiguous and replaced with
|
|
456
475
|
// ech_outer_extensions when encrypted. When serializing the ClientHelloOuter
|
|
457
|
-
// or not offering ECH,
|
|
458
|
-
//
|
|
476
|
+
// or not offering ECH, `out` will be equal to `out_compressible`, so writing to
|
|
477
|
+
// `out_compressible` still works.
|
|
459
478
|
//
|
|
460
|
-
// Note the
|
|
479
|
+
// Note the `parse_serverhello` and `add_serverhello` callbacks refer to the
|
|
461
480
|
// TLS 1.2 ServerHello. In TLS 1.3, these callbacks act on EncryptedExtensions,
|
|
462
481
|
// with ServerHello extensions handled elsewhere in the handshake.
|
|
463
482
|
//
|
|
464
483
|
// All callbacks return true for success and false for error. If a parse
|
|
465
|
-
// function returns zero then a fatal alert with value
|
|
466
|
-
// sent. If
|
|
484
|
+
// function returns zero then a fatal alert with value `*out_alert` will be
|
|
485
|
+
// sent. If `*out_alert` isn't set, then a `decode_error` alert will be sent.
|
|
467
486
|
struct tls_extension {
|
|
468
487
|
uint16_t value;
|
|
469
488
|
|
|
@@ -479,7 +498,7 @@ struct tls_extension {
|
|
|
479
498
|
|
|
480
499
|
static bool forbid_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
481
500
|
CBS *contents) {
|
|
482
|
-
if (contents !=
|
|
501
|
+
if (contents != nullptr) {
|
|
483
502
|
// Servers MUST NOT send this extension.
|
|
484
503
|
*out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
|
|
485
504
|
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
|
|
@@ -534,16 +553,18 @@ static bool ext_sni_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
534
553
|
CBS *contents) {
|
|
535
554
|
// The server may acknowledge SNI with an empty extension. We check the syntax
|
|
536
555
|
// but otherwise ignore this signal.
|
|
537
|
-
return contents ==
|
|
556
|
+
return contents == nullptr || CBS_len(contents) == 0;
|
|
538
557
|
}
|
|
539
558
|
|
|
540
559
|
static bool ext_sni_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
541
560
|
CBS *contents) {
|
|
542
|
-
// SNI has already been parsed earlier in the handshake. See
|
|
561
|
+
// SNI has already been parsed earlier in the handshake. See `extract_sni`.
|
|
543
562
|
return true;
|
|
544
563
|
}
|
|
545
564
|
|
|
546
565
|
static bool ext_sni_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
566
|
+
// RFC 6066 says "When resuming a session, the server MUST NOT include a
|
|
567
|
+
// server_name extension in the server hello."
|
|
547
568
|
if (hs->ssl->s3->session_reused || //
|
|
548
569
|
!hs->should_ack_sni) {
|
|
549
570
|
return true;
|
|
@@ -560,7 +581,7 @@ static bool ext_sni_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
|
560
581
|
|
|
561
582
|
// Encrypted ClientHello (ECH)
|
|
562
583
|
//
|
|
563
|
-
// https://
|
|
584
|
+
// https://www.rfc-editor.org/rfc/rfc9849.html
|
|
564
585
|
|
|
565
586
|
static bool ext_ech_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
566
587
|
CBB *out_compressible,
|
|
@@ -593,7 +614,7 @@ static bool ext_ech_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
593
614
|
static bool ext_ech_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
594
615
|
CBS *contents) {
|
|
595
616
|
SSL *const ssl = hs->ssl;
|
|
596
|
-
if (contents ==
|
|
617
|
+
if (contents == nullptr) {
|
|
597
618
|
return true;
|
|
598
619
|
}
|
|
599
620
|
|
|
@@ -651,8 +672,8 @@ static bool ext_ech_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
|
651
672
|
return true;
|
|
652
673
|
}
|
|
653
674
|
|
|
654
|
-
// Write the list of retry configs to
|
|
655
|
-
// ensures
|
|
675
|
+
// Write the list of retry configs to `out`. Note `SSL_CTX_set1_ech_keys`
|
|
676
|
+
// ensures `ech_keys` contains at least one retry config.
|
|
656
677
|
CBB body, retry_configs;
|
|
657
678
|
if (!CBB_add_u16(out, TLSEXT_TYPE_encrypted_client_hello) ||
|
|
658
679
|
!CBB_add_u16_length_prefixed(out, &body) ||
|
|
@@ -705,28 +726,34 @@ static bool ext_ri_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
705
726
|
static bool ext_ri_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
706
727
|
CBS *contents) {
|
|
707
728
|
SSL *const ssl = hs->ssl;
|
|
708
|
-
if (
|
|
709
|
-
|
|
710
|
-
|
|
729
|
+
if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
|
|
730
|
+
if (contents != nullptr) {
|
|
731
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
return true;
|
|
711
735
|
}
|
|
712
736
|
|
|
713
737
|
// Servers may not switch between omitting the extension and supporting it.
|
|
714
738
|
// See RFC 5746, sections 3.5 and 4.2.
|
|
715
739
|
if (ssl->s3->initial_handshake_complete &&
|
|
716
|
-
(contents !=
|
|
740
|
+
(contents != nullptr) != ssl->s3->send_connection_binding) {
|
|
717
741
|
*out_alert = SSL_AD_HANDSHAKE_FAILURE;
|
|
718
742
|
OPENSSL_PUT_ERROR(SSL, SSL_R_RENEGOTIATION_MISMATCH);
|
|
719
743
|
return false;
|
|
720
744
|
}
|
|
721
745
|
|
|
722
|
-
if (contents ==
|
|
746
|
+
if (contents == nullptr) {
|
|
723
747
|
// Strictly speaking, if we want to avoid an attack we should *always* see
|
|
724
748
|
// RI even on initial ServerHello because the client doesn't see any
|
|
725
749
|
// renegotiation during an attack. However this would mean we could not
|
|
726
|
-
// connect to any server which doesn't support RI.
|
|
727
|
-
//
|
|
728
|
-
|
|
729
|
-
|
|
750
|
+
// connect to any server which doesn't support RI. See RFC 5746,
|
|
751
|
+
// section 4.1.
|
|
752
|
+
if (!(ssl->options & SSL_OP_LEGACY_SERVER_CONNECT)) {
|
|
753
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
|
|
754
|
+
*out_alert = SSL_AD_HANDSHAKE_FAILURE;
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
730
757
|
return true;
|
|
731
758
|
}
|
|
732
759
|
|
|
@@ -786,7 +813,8 @@ static bool ext_ri_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
786
813
|
return true;
|
|
787
814
|
}
|
|
788
815
|
|
|
789
|
-
if (contents ==
|
|
816
|
+
if (contents == nullptr) {
|
|
817
|
+
// Permit clients to omit the extension. We never renegotiate as a server.
|
|
790
818
|
return true;
|
|
791
819
|
}
|
|
792
820
|
|
|
@@ -854,7 +882,7 @@ static bool ext_ems_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
854
882
|
CBS *contents) {
|
|
855
883
|
SSL *const ssl = hs->ssl;
|
|
856
884
|
|
|
857
|
-
if (contents !=
|
|
885
|
+
if (contents != nullptr) {
|
|
858
886
|
if (ssl_protocol_version(ssl) >= TLS1_3_VERSION || //
|
|
859
887
|
CBS_len(contents) != 0) {
|
|
860
888
|
return false;
|
|
@@ -881,7 +909,7 @@ static bool ext_ems_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
881
909
|
return true;
|
|
882
910
|
}
|
|
883
911
|
|
|
884
|
-
if (contents ==
|
|
912
|
+
if (contents == nullptr) {
|
|
885
913
|
return true;
|
|
886
914
|
}
|
|
887
915
|
|
|
@@ -946,7 +974,7 @@ static bool ext_ticket_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
946
974
|
static bool ext_ticket_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
947
975
|
CBS *contents) {
|
|
948
976
|
SSL *const ssl = hs->ssl;
|
|
949
|
-
if (contents ==
|
|
977
|
+
if (contents == nullptr) {
|
|
950
978
|
return true;
|
|
951
979
|
}
|
|
952
980
|
|
|
@@ -954,7 +982,7 @@ static bool ext_ticket_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
954
982
|
return false;
|
|
955
983
|
}
|
|
956
984
|
|
|
957
|
-
// If
|
|
985
|
+
// If `SSL_OP_NO_TICKET` is set then no extension will have been sent and
|
|
958
986
|
// this function should never be called, even if the server tries to send the
|
|
959
987
|
// extension.
|
|
960
988
|
assert((SSL_get_options(ssl) & SSL_OP_NO_TICKET) == 0);
|
|
@@ -972,7 +1000,7 @@ static bool ext_ticket_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
|
972
1000
|
return true;
|
|
973
1001
|
}
|
|
974
1002
|
|
|
975
|
-
// If
|
|
1003
|
+
// If `SSL_OP_NO_TICKET` is set, `ticket_expected` should never be true.
|
|
976
1004
|
assert((SSL_get_options(hs->ssl) & SSL_OP_NO_TICKET) == 0);
|
|
977
1005
|
|
|
978
1006
|
if (!CBB_add_u16(out, TLSEXT_TYPE_session_ticket) ||
|
|
@@ -994,8 +1022,8 @@ static bool ext_sigalgs_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
994
1022
|
if (hs->max_version < TLS1_2_VERSION) {
|
|
995
1023
|
return true;
|
|
996
1024
|
}
|
|
997
|
-
//
|
|
998
|
-
if (hs
|
|
1025
|
+
// Skip signature_algorithms if we wouldn't accept a certificate mode anyway.
|
|
1026
|
+
if (!ssl_accepts_server_certificate_auth(hs)) {
|
|
999
1027
|
return true;
|
|
1000
1028
|
}
|
|
1001
1029
|
|
|
@@ -1014,7 +1042,7 @@ static bool ext_sigalgs_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1014
1042
|
static bool ext_sigalgs_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1015
1043
|
CBS *contents) {
|
|
1016
1044
|
hs->peer_sigalgs.Reset();
|
|
1017
|
-
if (contents ==
|
|
1045
|
+
if (contents == nullptr) {
|
|
1018
1046
|
return true;
|
|
1019
1047
|
}
|
|
1020
1048
|
|
|
@@ -1056,7 +1084,7 @@ static bool ext_ocsp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1056
1084
|
static bool ext_ocsp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1057
1085
|
CBS *contents) {
|
|
1058
1086
|
SSL *const ssl = hs->ssl;
|
|
1059
|
-
if (contents ==
|
|
1087
|
+
if (contents == nullptr) {
|
|
1060
1088
|
return true;
|
|
1061
1089
|
}
|
|
1062
1090
|
|
|
@@ -1081,7 +1109,7 @@ static bool ext_ocsp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1081
1109
|
|
|
1082
1110
|
static bool ext_ocsp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1083
1111
|
CBS *contents) {
|
|
1084
|
-
if (contents ==
|
|
1112
|
+
if (contents == nullptr) {
|
|
1085
1113
|
return true;
|
|
1086
1114
|
}
|
|
1087
1115
|
|
|
@@ -1121,7 +1149,7 @@ static bool ext_npn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1121
1149
|
CBB *out_compressible,
|
|
1122
1150
|
ssl_client_hello_type_t type) {
|
|
1123
1151
|
const SSL *const ssl = hs->ssl;
|
|
1124
|
-
if (ssl->ctx->next_proto_select_cb ==
|
|
1152
|
+
if (ssl->ctx->next_proto_select_cb == nullptr ||
|
|
1125
1153
|
// Do not allow NPN to change on renegotiation.
|
|
1126
1154
|
ssl->s3->initial_handshake_complete ||
|
|
1127
1155
|
// NPN is not defined in DTLS or TLS 1.3.
|
|
@@ -1141,7 +1169,7 @@ static bool ext_npn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1141
1169
|
static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1142
1170
|
CBS *contents) {
|
|
1143
1171
|
SSL *const ssl = hs->ssl;
|
|
1144
|
-
if (contents ==
|
|
1172
|
+
if (contents == nullptr) {
|
|
1145
1173
|
return true;
|
|
1146
1174
|
}
|
|
1147
1175
|
|
|
@@ -1154,7 +1182,7 @@ static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1154
1182
|
// called.
|
|
1155
1183
|
assert(!ssl->s3->initial_handshake_complete);
|
|
1156
1184
|
assert(!SSL_is_dtls(ssl));
|
|
1157
|
-
assert(ssl->ctx->next_proto_select_cb !=
|
|
1185
|
+
assert(ssl->ctx->next_proto_select_cb != nullptr);
|
|
1158
1186
|
|
|
1159
1187
|
if (!ssl->s3->alpn_selected.empty()) {
|
|
1160
1188
|
// NPN and ALPN may not be negotiated in the same connection.
|
|
@@ -1174,7 +1202,7 @@ static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1174
1202
|
}
|
|
1175
1203
|
}
|
|
1176
1204
|
|
|
1177
|
-
//
|
|
1205
|
+
// `orig_len` fits in `unsigned` because TLS extensions use 16-bit lengths.
|
|
1178
1206
|
uint8_t *selected;
|
|
1179
1207
|
uint8_t selected_len;
|
|
1180
1208
|
if (ssl->ctx->next_proto_select_cb(
|
|
@@ -1197,13 +1225,13 @@ static bool ext_npn_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1197
1225
|
return true;
|
|
1198
1226
|
}
|
|
1199
1227
|
|
|
1200
|
-
if (contents !=
|
|
1228
|
+
if (contents != nullptr && CBS_len(contents) != 0) {
|
|
1201
1229
|
return false;
|
|
1202
1230
|
}
|
|
1203
1231
|
|
|
1204
|
-
if (contents ==
|
|
1205
|
-
ssl->s3->initial_handshake_complete ||
|
|
1206
|
-
ssl->ctx->next_protos_advertised_cb ==
|
|
1232
|
+
if (contents == nullptr || //
|
|
1233
|
+
ssl->s3->initial_handshake_complete || //
|
|
1234
|
+
ssl->ctx->next_protos_advertised_cb == nullptr || //
|
|
1207
1235
|
SSL_is_dtls(ssl)) {
|
|
1208
1236
|
return true;
|
|
1209
1237
|
}
|
|
@@ -1214,7 +1242,7 @@ static bool ext_npn_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1214
1242
|
|
|
1215
1243
|
static bool ext_npn_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1216
1244
|
SSL *const ssl = hs->ssl;
|
|
1217
|
-
//
|
|
1245
|
+
// `next_proto_neg_seen` might have been cleared when an ALPN extension was
|
|
1218
1246
|
// parsed.
|
|
1219
1247
|
if (!hs->next_proto_neg_seen) {
|
|
1220
1248
|
return true;
|
|
@@ -1264,7 +1292,7 @@ static bool ext_sct_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1264
1292
|
static bool ext_sct_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1265
1293
|
CBS *contents) {
|
|
1266
1294
|
SSL *const ssl = hs->ssl;
|
|
1267
|
-
if (contents ==
|
|
1295
|
+
if (contents == nullptr) {
|
|
1268
1296
|
return true;
|
|
1269
1297
|
}
|
|
1270
1298
|
|
|
@@ -1290,7 +1318,7 @@ static bool ext_sct_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1290
1318
|
// TODO(davidben): Enforce this anyway.
|
|
1291
1319
|
if (!ssl->s3->session_reused) {
|
|
1292
1320
|
hs->new_session->signed_cert_timestamp_list.reset(
|
|
1293
|
-
CRYPTO_BUFFER_new_from_CBS(contents, ssl->ctx->pool));
|
|
1321
|
+
CRYPTO_BUFFER_new_from_CBS(contents, ssl->ctx->pool.get()));
|
|
1294
1322
|
if (hs->new_session->signed_cert_timestamp_list == nullptr) {
|
|
1295
1323
|
*out_alert = SSL_AD_INTERNAL_ERROR;
|
|
1296
1324
|
return false;
|
|
@@ -1302,7 +1330,7 @@ static bool ext_sct_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1302
1330
|
|
|
1303
1331
|
static bool ext_sct_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1304
1332
|
CBS *contents) {
|
|
1305
|
-
if (contents ==
|
|
1333
|
+
if (contents == nullptr) {
|
|
1306
1334
|
return true;
|
|
1307
1335
|
}
|
|
1308
1336
|
|
|
@@ -1372,7 +1400,7 @@ static bool ext_alpn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1372
1400
|
static bool ext_alpn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1373
1401
|
CBS *contents) {
|
|
1374
1402
|
SSL *const ssl = hs->ssl;
|
|
1375
|
-
if (contents ==
|
|
1403
|
+
if (contents == nullptr) {
|
|
1376
1404
|
if (SSL_is_quic(ssl)) {
|
|
1377
1405
|
// ALPN is required when QUIC is used.
|
|
1378
1406
|
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_APPLICATION_PROTOCOL);
|
|
@@ -1469,7 +1497,7 @@ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1469
1497
|
const SSL_CLIENT_HELLO *client_hello) {
|
|
1470
1498
|
SSL *const ssl = hs->ssl;
|
|
1471
1499
|
CBS contents;
|
|
1472
|
-
if (ssl->ctx->alpn_select_cb ==
|
|
1500
|
+
if (ssl->ctx->alpn_select_cb == nullptr ||
|
|
1473
1501
|
!ssl_client_hello_get_extension(
|
|
1474
1502
|
client_hello, &contents,
|
|
1475
1503
|
TLSEXT_TYPE_application_layer_protocol_negotiation)) {
|
|
@@ -1495,7 +1523,7 @@ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1495
1523
|
return false;
|
|
1496
1524
|
}
|
|
1497
1525
|
|
|
1498
|
-
//
|
|
1526
|
+
// `protocol_name_list` fits in `unsigned` because TLS extensions use 16-bit
|
|
1499
1527
|
// lengths.
|
|
1500
1528
|
const uint8_t *selected;
|
|
1501
1529
|
uint8_t selected_len;
|
|
@@ -1571,8 +1599,8 @@ static bool ext_channel_id_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1571
1599
|
// are not authenticated for the name that can learn the Channel ID.
|
|
1572
1600
|
//
|
|
1573
1601
|
// We could alternatively offer the extension but sign with a random key.
|
|
1574
|
-
// For other extensions, we try to align
|
|
1575
|
-
//
|
|
1602
|
+
// For other extensions, we try to align `ssl_client_hello_outer` and
|
|
1603
|
+
// `ssl_client_hello_unencrypted`, to improve the effectiveness of ECH
|
|
1576
1604
|
// GREASE. However, Channel ID is deprecated and unlikely to be used with
|
|
1577
1605
|
// ECH, so do the simplest thing.
|
|
1578
1606
|
type == ssl_client_hello_outer) {
|
|
@@ -1590,7 +1618,7 @@ static bool ext_channel_id_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1590
1618
|
static bool ext_channel_id_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
1591
1619
|
uint8_t *out_alert,
|
|
1592
1620
|
CBS *contents) {
|
|
1593
|
-
if (contents ==
|
|
1621
|
+
if (contents == nullptr) {
|
|
1594
1622
|
return true;
|
|
1595
1623
|
}
|
|
1596
1624
|
|
|
@@ -1609,7 +1637,8 @@ static bool ext_channel_id_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
1609
1637
|
uint8_t *out_alert,
|
|
1610
1638
|
CBS *contents) {
|
|
1611
1639
|
SSL *const ssl = hs->ssl;
|
|
1612
|
-
if (contents ==
|
|
1640
|
+
if (contents == nullptr || !hs->config->channel_id_enabled ||
|
|
1641
|
+
SSL_is_dtls(ssl)) {
|
|
1613
1642
|
return true;
|
|
1614
1643
|
}
|
|
1615
1644
|
|
|
@@ -1645,7 +1674,7 @@ static bool ext_srtp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1645
1674
|
const SSL *const ssl = hs->ssl;
|
|
1646
1675
|
const STACK_OF(SRTP_PROTECTION_PROFILE) *profiles =
|
|
1647
1676
|
SSL_get_srtp_profiles(ssl);
|
|
1648
|
-
if (profiles ==
|
|
1677
|
+
if (profiles == nullptr || //
|
|
1649
1678
|
sk_SRTP_PROTECTION_PROFILE_num(profiles) == 0 || //
|
|
1650
1679
|
!SSL_is_dtls(ssl)) {
|
|
1651
1680
|
return true;
|
|
@@ -1675,7 +1704,7 @@ static bool ext_srtp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1675
1704
|
static bool ext_srtp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1676
1705
|
CBS *contents) {
|
|
1677
1706
|
SSL *const ssl = hs->ssl;
|
|
1678
|
-
if (contents ==
|
|
1707
|
+
if (contents == nullptr) {
|
|
1679
1708
|
return true;
|
|
1680
1709
|
}
|
|
1681
1710
|
|
|
@@ -1719,7 +1748,7 @@ static bool ext_srtp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1719
1748
|
CBS *contents) {
|
|
1720
1749
|
SSL *const ssl = hs->ssl;
|
|
1721
1750
|
// DTLS-SRTP is only defined for DTLS.
|
|
1722
|
-
if (contents ==
|
|
1751
|
+
if (contents == nullptr || !SSL_is_dtls(ssl)) {
|
|
1723
1752
|
return true;
|
|
1724
1753
|
}
|
|
1725
1754
|
|
|
@@ -1759,7 +1788,7 @@ static bool ext_srtp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1759
1788
|
|
|
1760
1789
|
static bool ext_srtp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
1761
1790
|
SSL *const ssl = hs->ssl;
|
|
1762
|
-
if (ssl->s3->srtp_profile ==
|
|
1791
|
+
if (ssl->s3->srtp_profile == nullptr) {
|
|
1763
1792
|
return true;
|
|
1764
1793
|
}
|
|
1765
1794
|
|
|
@@ -1807,7 +1836,7 @@ static bool ext_ec_point_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
1807
1836
|
|
|
1808
1837
|
static bool ext_ec_point_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
1809
1838
|
uint8_t *out_alert, CBS *contents) {
|
|
1810
|
-
if (contents ==
|
|
1839
|
+
if (contents == nullptr) {
|
|
1811
1840
|
return true;
|
|
1812
1841
|
}
|
|
1813
1842
|
|
|
@@ -1825,7 +1854,7 @@ static bool ext_ec_point_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
1825
1854
|
// point format.
|
|
1826
1855
|
if (OPENSSL_memchr(CBS_data(&ec_point_format_list),
|
|
1827
1856
|
TLSEXT_ECPOINTFORMAT_uncompressed,
|
|
1828
|
-
CBS_len(&ec_point_format_list)) ==
|
|
1857
|
+
CBS_len(&ec_point_format_list)) == nullptr) {
|
|
1829
1858
|
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
1830
1859
|
return false;
|
|
1831
1860
|
}
|
|
@@ -1864,174 +1893,320 @@ static bool ext_ec_point_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
|
1864
1893
|
//
|
|
1865
1894
|
// https://tools.ietf.org/html/rfc8446#section-4.2.11
|
|
1866
1895
|
|
|
1867
|
-
|
|
1868
|
-
ssl_client_hello_type_t type) {
|
|
1896
|
+
bool ssl_setup_pre_shared_keys(SSL_HANDSHAKE *hs) {
|
|
1869
1897
|
const SSL *const ssl = hs->ssl;
|
|
1870
|
-
if (hs->max_version < TLS1_3_VERSION
|
|
1871
|
-
|
|
1872
|
-
SSLSessionType::kPreSharedKey ||
|
|
1873
|
-
// TODO(https://crbug.com/boringssl/275): Should we synthesize a
|
|
1874
|
-
// placeholder PSK, at least when we offer early data? Otherwise
|
|
1875
|
-
// ClientHelloOuter will contain an early_data extension without a
|
|
1876
|
-
// pre_shared_key extension and potentially break the recovery flow.
|
|
1877
|
-
type == ssl_client_hello_outer) {
|
|
1878
|
-
return false;
|
|
1898
|
+
if (hs->max_version < TLS1_3_VERSION) {
|
|
1899
|
+
return true;
|
|
1879
1900
|
}
|
|
1880
1901
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
ssl->session->cipher->algorithm_prf != hs->new_cipher->algorithm_prf) {
|
|
1902
|
+
if (SSL_SESSION *session = ssl->session.get();
|
|
1903
|
+
session != nullptr &&
|
|
1904
|
+
ssl_session_get_type(session) == SSLSessionType::kPreSharedKey &&
|
|
1905
|
+
!hs->pre_shared_keys.Push(UpRef(session))) {
|
|
1886
1906
|
return false;
|
|
1887
1907
|
}
|
|
1888
1908
|
|
|
1909
|
+
const uint16_t epsk_protocol =
|
|
1910
|
+
SSL_is_dtls(ssl) ? DTLS1_3_VERSION : TLS1_3_VERSION;
|
|
1911
|
+
#if defined(TLS1_4_VERSION)
|
|
1912
|
+
#error "More imported PSKs may be needed when TLS 1.4 exists"
|
|
1913
|
+
#endif
|
|
1914
|
+
for (const auto &cred : hs->config->cert->credentials) {
|
|
1915
|
+
if (cred->type != SSLCredentialType::kPreSharedKey) {
|
|
1916
|
+
continue;
|
|
1917
|
+
}
|
|
1918
|
+
// We need SHA-256 and SHA-384 variants to cover supported cipher suites.
|
|
1919
|
+
for (const EVP_MD *md : {EVP_sha256(), EVP_sha384()}) {
|
|
1920
|
+
std::optional<SSLImportedPSK> psk =
|
|
1921
|
+
tls13_derive_imported_psk(hs, cred.get(), epsk_protocol, md);
|
|
1922
|
+
if (!psk || !hs->pre_shared_keys.Push(*std::move(psk))) {
|
|
1923
|
+
return false;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1889
1928
|
return true;
|
|
1890
1929
|
}
|
|
1891
1930
|
|
|
1931
|
+
static bool should_offer_psk(const SSL_HANDSHAKE *hs,
|
|
1932
|
+
ssl_client_hello_type_t type) {
|
|
1933
|
+
// TODO(https://crbug.com/boringssl/275): Should we synthesize a placeholder
|
|
1934
|
+
// PSK, at least when we offer early data? Otherwise ClientHelloOuter will
|
|
1935
|
+
// contain an early_data extension without a pre_shared_key extension and
|
|
1936
|
+
// potentially break the recovery flow.
|
|
1937
|
+
return hs->max_version >= TLS1_3_VERSION && !hs->pre_shared_keys.empty() &&
|
|
1938
|
+
type != ssl_client_hello_outer;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1892
1941
|
static size_t ext_pre_shared_key_clienthello_length(
|
|
1893
1942
|
const SSL_HANDSHAKE *hs, ssl_client_hello_type_t type) {
|
|
1894
|
-
const SSL *const ssl = hs->ssl;
|
|
1895
1943
|
if (!should_offer_psk(hs, type)) {
|
|
1896
1944
|
return 0;
|
|
1897
1945
|
}
|
|
1898
1946
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1947
|
+
// extension value, extension length, identities length, binders length.
|
|
1948
|
+
size_t ret = 2 + 2 + 2 + 2;
|
|
1949
|
+
for (const auto &psk : hs->pre_shared_keys) {
|
|
1950
|
+
// identity
|
|
1951
|
+
ret += 2 + ssl_pre_shared_key_identity(psk).size();
|
|
1952
|
+
// obfuscated_ticket_age
|
|
1953
|
+
ret += 4;
|
|
1954
|
+
// binder
|
|
1955
|
+
ret += 1 + EVP_MD_size(ssl_pre_shared_key_hash(psk));
|
|
1956
|
+
}
|
|
1957
|
+
return ret;
|
|
1901
1958
|
}
|
|
1902
1959
|
|
|
1960
|
+
// ext_pre_shared_key_add_clienthello writes a pre_shared_key extension to
|
|
1961
|
+
// `out_extensions` and flushes `out_client_hello`, invalidating
|
|
1962
|
+
// `out_extensions`. `out_extensions` must be a child of `out_client_hello`.
|
|
1963
|
+
//
|
|
1964
|
+
// This function differs from other `CBB` functions because it needs to
|
|
1965
|
+
// accommodate PSK binders. It must write the PSK extension, flush the `CBB` to
|
|
1966
|
+
// write out a length prefix, and then finally sample the whole ClientHello.
|
|
1903
1967
|
static bool ext_pre_shared_key_add_clienthello(const SSL_HANDSHAKE *hs,
|
|
1904
|
-
CBB *
|
|
1968
|
+
CBB *out_client_hello,
|
|
1969
|
+
CBB *out_extensions,
|
|
1970
|
+
size_t *out_psk_len,
|
|
1905
1971
|
ssl_client_hello_type_t type) {
|
|
1906
1972
|
const SSL *const ssl = hs->ssl;
|
|
1907
|
-
*out_needs_binder = false;
|
|
1908
1973
|
if (!should_offer_psk(hs, type)) {
|
|
1909
|
-
|
|
1974
|
+
*out_psk_len = 0;
|
|
1975
|
+
// Discard empty extensions blocks.
|
|
1976
|
+
if (CBB_len(out_extensions) == 0) {
|
|
1977
|
+
CBB_discard_child(out_client_hello);
|
|
1978
|
+
}
|
|
1979
|
+
return CBB_flush(out_client_hello);
|
|
1910
1980
|
}
|
|
1911
1981
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1982
|
+
const size_t len_before = CBB_len(out_extensions);
|
|
1983
|
+
CBB contents, identities, identity, binders, binder;
|
|
1984
|
+
if (!CBB_add_u16(out_extensions, TLSEXT_TYPE_pre_shared_key) ||
|
|
1985
|
+
!CBB_add_u16_length_prefixed(out_extensions, &contents) ||
|
|
1986
|
+
!CBB_add_u16_length_prefixed(&contents, &identities)) {
|
|
1987
|
+
return false;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
// Fill in the PSK identities.
|
|
1991
|
+
for (const auto &psk : hs->pre_shared_keys) {
|
|
1992
|
+
if (const auto *imported = std::get_if<SSLImportedPSK>(&psk);
|
|
1993
|
+
imported != nullptr) {
|
|
1994
|
+
if (!CBB_add_u16_length_prefixed(&identities, &identity) ||
|
|
1995
|
+
!CBB_add_bytes(&identity, imported->imported_identity.data(),
|
|
1996
|
+
imported->imported_identity.size()) ||
|
|
1997
|
+
!CBB_add_u32(&identities, 0 /* obfuscated_ticket_age */)) {
|
|
1998
|
+
return false;
|
|
1999
|
+
}
|
|
2000
|
+
} else {
|
|
2001
|
+
const SSL_SESSION *session = std::get<UniquePtr<SSL_SESSION>>(psk).get();
|
|
2002
|
+
// At most one PSK will be a session.
|
|
2003
|
+
assert(session == ssl->session.get());
|
|
2004
|
+
OPENSSL_timeval now = ssl_ctx_get_current_time(ssl->ctx.get());
|
|
2005
|
+
uint32_t ticket_age = 1000 * (now.tv_sec - session->time);
|
|
2006
|
+
uint32_t obfuscated_ticket_age = ticket_age + session->ticket_age_add;
|
|
2007
|
+
if (!CBB_add_u16_length_prefixed(&identities, &identity) ||
|
|
2008
|
+
!CBB_add_bytes(&identity, session->ticket.data(),
|
|
2009
|
+
session->ticket.size()) ||
|
|
2010
|
+
!CBB_add_u32(&identities, obfuscated_ticket_age)) {
|
|
2011
|
+
return false;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1915
2015
|
|
|
1916
|
-
// Fill in
|
|
2016
|
+
// Fill in placeholder zero binders of the appropriate length. They will be
|
|
1917
2017
|
// computed and filled in later after length prefixes are computed.
|
|
1918
|
-
|
|
2018
|
+
if (!CBB_add_u16_length_prefixed(&contents, &binders)) {
|
|
2019
|
+
return false;
|
|
2020
|
+
}
|
|
2021
|
+
for (const auto &psk : hs->pre_shared_keys) {
|
|
2022
|
+
size_t binder_len = EVP_MD_size(ssl_pre_shared_key_hash(psk));
|
|
2023
|
+
if (!CBB_add_u8_length_prefixed(&binders, &binder) ||
|
|
2024
|
+
!CBB_add_zeros(&binder, binder_len)) {
|
|
2025
|
+
return false;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
if (!CBB_flush(&binders)) {
|
|
2029
|
+
return false;
|
|
2030
|
+
}
|
|
2031
|
+
const size_t binders_len = CBB_len(&binders);
|
|
1919
2032
|
|
|
1920
|
-
|
|
1921
|
-
if (!
|
|
1922
|
-
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
1923
|
-
!CBB_add_u16_length_prefixed(&contents, &identity) ||
|
|
1924
|
-
!CBB_add_u16_length_prefixed(&identity, &ticket) ||
|
|
1925
|
-
!CBB_add_bytes(&ticket, ssl->session->ticket.data(),
|
|
1926
|
-
ssl->session->ticket.size()) ||
|
|
1927
|
-
!CBB_add_u32(&identity, obfuscated_ticket_age) ||
|
|
1928
|
-
!CBB_add_u16_length_prefixed(&contents, &binders) ||
|
|
1929
|
-
!CBB_add_u8_length_prefixed(&binders, &binder) ||
|
|
1930
|
-
!CBB_add_zeros(&binder, binder_len)) {
|
|
2033
|
+
// Finish the PSK extension and save the length.
|
|
2034
|
+
if (!CBB_flush(out_extensions)) {
|
|
1931
2035
|
return false;
|
|
1932
2036
|
}
|
|
2037
|
+
*out_psk_len = CBB_len(out_extensions) - len_before;
|
|
1933
2038
|
|
|
1934
|
-
|
|
1935
|
-
|
|
2039
|
+
// Fill in `out_extensions`'s length prefix.
|
|
2040
|
+
if (!CBB_flush(out_client_hello)) {
|
|
2041
|
+
return false;
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
// Fill in binders.
|
|
2045
|
+
const auto client_hello = CBBAsSpan(out_client_hello);
|
|
2046
|
+
auto remaining_binders_out = client_hello.last(binders_len);
|
|
2047
|
+
const auto &transcript =
|
|
2048
|
+
type == ssl_client_hello_inner ? hs->inner_transcript : hs->transcript;
|
|
2049
|
+
for (const auto &psk : hs->pre_shared_keys) {
|
|
2050
|
+
// Skip length prefix.
|
|
2051
|
+
remaining_binders_out = remaining_binders_out.subspan(1);
|
|
2052
|
+
size_t one_binder_len;
|
|
2053
|
+
if (!tls13_psk_binder(hs, remaining_binders_out, &one_binder_len, psk,
|
|
2054
|
+
transcript, client_hello,
|
|
2055
|
+
2 /* length */ + binders_len)) {
|
|
2056
|
+
return false;
|
|
2057
|
+
}
|
|
2058
|
+
remaining_binders_out = remaining_binders_out.subspan(one_binder_len);
|
|
2059
|
+
}
|
|
2060
|
+
assert(remaining_binders_out.empty());
|
|
2061
|
+
return true;
|
|
1936
2062
|
}
|
|
1937
2063
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
if (!CBS_get_u16(contents, &psk_id) || //
|
|
2064
|
+
const SSLPreSharedKey *ssl_ext_pre_shared_key_parse_serverhello(
|
|
2065
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert, CBS *contents) {
|
|
2066
|
+
uint16_t selected_identity;
|
|
2067
|
+
if (!CBS_get_u16(contents, &selected_identity) || //
|
|
1943
2068
|
CBS_len(contents) != 0) {
|
|
1944
2069
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
1945
2070
|
*out_alert = SSL_AD_DECODE_ERROR;
|
|
1946
|
-
return
|
|
2071
|
+
return nullptr;
|
|
1947
2072
|
}
|
|
1948
2073
|
|
|
1949
|
-
|
|
1950
|
-
if (psk_id != 0) {
|
|
2074
|
+
if (selected_identity >= hs->pre_shared_keys.size()) {
|
|
1951
2075
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_NOT_FOUND);
|
|
1952
2076
|
*out_alert = SSL_AD_UNKNOWN_PSK_IDENTITY;
|
|
1953
|
-
return
|
|
2077
|
+
return nullptr;
|
|
1954
2078
|
}
|
|
1955
2079
|
|
|
1956
|
-
return
|
|
2080
|
+
return &hs->pre_shared_keys[selected_identity];
|
|
1957
2081
|
}
|
|
1958
2082
|
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2083
|
+
std::optional<SSLOfferedPSK> SSLOfferedPSKs::Next() {
|
|
2084
|
+
if (CBS_len(&identities) == 0) {
|
|
2085
|
+
return std::nullopt;
|
|
2086
|
+
}
|
|
2087
|
+
SSLOfferedPSK psk;
|
|
2088
|
+
if (!CBS_get_u16_length_prefixed(&identities, &psk.identity) ||
|
|
2089
|
+
CBS_len(&psk.identity) == 0 ||
|
|
2090
|
+
!CBS_get_u32(&identities, &psk.obfuscated_ticket_age) ||
|
|
2091
|
+
!CBS_get_u8_length_prefixed(&binders, &psk.binder) ||
|
|
2092
|
+
CBS_len(&psk.binder) == 0) {
|
|
2093
|
+
// After a successful parse, this should never happen.
|
|
2094
|
+
return std::nullopt;
|
|
2095
|
+
}
|
|
2096
|
+
return psk;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
std::optional<SSLOfferedPSKs> ssl_ext_pre_shared_key_parse_clienthello(
|
|
2100
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert, const SSL_CLIENT_HELLO *client_hello,
|
|
2101
|
+
CBS *contents) {
|
|
1963
2102
|
// Verify that the pre_shared_key extension is the last extension in
|
|
1964
2103
|
// ClientHello.
|
|
1965
2104
|
if (CBS_data(contents) + CBS_len(contents) !=
|
|
1966
2105
|
client_hello->extensions + client_hello->extensions_len) {
|
|
1967
2106
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PRE_SHARED_KEY_MUST_BE_LAST);
|
|
1968
2107
|
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
1969
|
-
return
|
|
2108
|
+
return std::nullopt;
|
|
1970
2109
|
}
|
|
1971
2110
|
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
!CBS_get_u16_length_prefixed(contents, &binders) || //
|
|
1978
|
-
CBS_len(&binders) == 0 || //
|
|
2111
|
+
SSLOfferedPSKs psks;
|
|
2112
|
+
if (!CBS_get_u16_length_prefixed(contents, &psks.identities) ||
|
|
2113
|
+
!CBS_get_u16_length_prefixed(contents, &psks.binders) ||
|
|
2114
|
+
CBS_len(&psks.identities) == 0 || //
|
|
2115
|
+
CBS_len(&psks.binders) == 0 || //
|
|
1979
2116
|
CBS_len(contents) != 0) {
|
|
1980
2117
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
1981
2118
|
*out_alert = SSL_AD_DECODE_ERROR;
|
|
1982
|
-
return
|
|
2119
|
+
return std::nullopt;
|
|
1983
2120
|
}
|
|
1984
2121
|
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
while (CBS_len(&identities) != 0) {
|
|
1990
|
-
CBS unused_ticket;
|
|
1991
|
-
uint32_t unused_obfuscated_ticket_age;
|
|
1992
|
-
if (!CBS_get_u16_length_prefixed(&identities, &unused_ticket) ||
|
|
1993
|
-
!CBS_get_u32(&identities, &unused_obfuscated_ticket_age)) {
|
|
2122
|
+
// Check the syntax of the extension.
|
|
2123
|
+
SSLOfferedPSKs copy = psks;
|
|
2124
|
+
while (CBS_len(©.identities) != 0 && CBS_len(©.binders) != 0) {
|
|
2125
|
+
if (!copy.Next()) {
|
|
1994
2126
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
1995
2127
|
*out_alert = SSL_AD_DECODE_ERROR;
|
|
1996
|
-
return
|
|
2128
|
+
return std::nullopt;
|
|
1997
2129
|
}
|
|
2130
|
+
}
|
|
1998
2131
|
|
|
1999
|
-
|
|
2132
|
+
// We should have run out of identities and binders at the same time.
|
|
2133
|
+
if (CBS_len(©.identities) != 0 || CBS_len(©.binders) != 0) {
|
|
2134
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_BINDER_COUNT_MISMATCH);
|
|
2135
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
2136
|
+
return std::nullopt;
|
|
2000
2137
|
}
|
|
2001
2138
|
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
size_t num_binders = 0;
|
|
2005
|
-
while (CBS_len(&binders) != 0) {
|
|
2006
|
-
CBS binder;
|
|
2007
|
-
if (!CBS_get_u8_length_prefixed(&binders, &binder)) {
|
|
2008
|
-
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
2009
|
-
*out_alert = SSL_AD_DECODE_ERROR;
|
|
2010
|
-
return false;
|
|
2011
|
-
}
|
|
2139
|
+
return psks;
|
|
2140
|
+
}
|
|
2012
2141
|
|
|
2013
|
-
|
|
2142
|
+
bool ssl_verify_psk_binder(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
2143
|
+
const SSLPreSharedKey &psk,
|
|
2144
|
+
const SSL_CLIENT_HELLO &client_hello) {
|
|
2145
|
+
CBS pre_shared_key;
|
|
2146
|
+
if (!ssl_client_hello_get_extension(&client_hello, &pre_shared_key,
|
|
2147
|
+
TLSEXT_TYPE_pre_shared_key)) {
|
|
2148
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_EXTENSION);
|
|
2149
|
+
*out_alert = SSL_AD_MISSING_EXTENSION;
|
|
2150
|
+
return false;
|
|
2014
2151
|
}
|
|
2015
2152
|
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2153
|
+
std::optional<SSLOfferedPSKs> offered_psks =
|
|
2154
|
+
ssl_ext_pre_shared_key_parse_clienthello(hs, out_alert, &client_hello,
|
|
2155
|
+
&pre_shared_key);
|
|
2156
|
+
if (!offered_psks) {
|
|
2019
2157
|
return false;
|
|
2020
2158
|
}
|
|
2159
|
+
const size_t binders_len =
|
|
2160
|
+
2 /* length prefix */ + CBS_len(&offered_psks->binders);
|
|
2021
2161
|
|
|
2022
|
-
|
|
2162
|
+
Span<const uint8_t> identity = ssl_pre_shared_key_identity(psk);
|
|
2163
|
+
for (uint16_t index = 0; true; index++) {
|
|
2164
|
+
std::optional<SSLOfferedPSK> offered_psk = offered_psks->Next();
|
|
2165
|
+
if (!offered_psk) {
|
|
2166
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_NOT_FOUND);
|
|
2167
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
2168
|
+
return false;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
if (offered_psk->identity != identity) {
|
|
2172
|
+
continue;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
hs->selected_psk_index = index;
|
|
2176
|
+
uint8_t verify_data[EVP_MAX_MD_SIZE];
|
|
2177
|
+
size_t verify_data_len;
|
|
2178
|
+
if (!tls13_psk_binder(
|
|
2179
|
+
hs, verify_data, &verify_data_len, psk, hs->transcript,
|
|
2180
|
+
Span(client_hello.client_hello, client_hello.client_hello_len),
|
|
2181
|
+
binders_len)) {
|
|
2182
|
+
*out_alert = SSL_AD_INTERNAL_ERROR;
|
|
2183
|
+
return false;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
bool binder_ok = CBS_len(&offered_psk->binder) == verify_data_len &&
|
|
2187
|
+
CRYPTO_memcmp(CBS_data(&offered_psk->binder), verify_data,
|
|
2188
|
+
verify_data_len) == 0;
|
|
2189
|
+
if (CRYPTO_fuzzer_mode_enabled()) {
|
|
2190
|
+
binder_ok = true;
|
|
2191
|
+
}
|
|
2192
|
+
if (!binder_ok) {
|
|
2193
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DIGEST_CHECK_FAILED);
|
|
2194
|
+
*out_alert = SSL_AD_DECRYPT_ERROR;
|
|
2195
|
+
return false;
|
|
2196
|
+
}
|
|
2197
|
+
return true;
|
|
2198
|
+
}
|
|
2023
2199
|
}
|
|
2024
2200
|
|
|
2025
2201
|
bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2026
|
-
if (!hs->
|
|
2202
|
+
if (!hs->selected_psk_index.has_value()) {
|
|
2027
2203
|
return true;
|
|
2028
2204
|
}
|
|
2029
2205
|
|
|
2030
2206
|
CBB contents;
|
|
2031
|
-
if (!CBB_add_u16(out, TLSEXT_TYPE_pre_shared_key) ||
|
|
2032
|
-
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
2033
|
-
|
|
2034
|
-
!CBB_add_u16(&contents, 0) || //
|
|
2207
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_pre_shared_key) ||
|
|
2208
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
2209
|
+
!CBB_add_u16(&contents, *hs->selected_psk_index) || //
|
|
2035
2210
|
!CBB_flush(out)) {
|
|
2036
2211
|
return false;
|
|
2037
2212
|
}
|
|
@@ -2070,7 +2245,7 @@ static bool ext_psk_key_exchange_modes_add_clienthello(
|
|
|
2070
2245
|
static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
2071
2246
|
uint8_t *out_alert,
|
|
2072
2247
|
CBS *contents) {
|
|
2073
|
-
if (contents ==
|
|
2248
|
+
if (contents == nullptr) {
|
|
2074
2249
|
return true;
|
|
2075
2250
|
}
|
|
2076
2251
|
|
|
@@ -2084,7 +2259,7 @@ static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
2084
2259
|
|
|
2085
2260
|
// We only support tickets with PSK_DHE_KE.
|
|
2086
2261
|
hs->accept_psk_mode = OPENSSL_memchr(CBS_data(&ke_modes), SSL_PSK_DHE_KE,
|
|
2087
|
-
CBS_len(&ke_modes)) !=
|
|
2262
|
+
CBS_len(&ke_modes)) != nullptr;
|
|
2088
2263
|
|
|
2089
2264
|
return true;
|
|
2090
2265
|
}
|
|
@@ -2099,7 +2274,7 @@ static bool ext_early_data_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
2099
2274
|
ssl_client_hello_type_t type) {
|
|
2100
2275
|
const SSL *const ssl = hs->ssl;
|
|
2101
2276
|
// The second ClientHello never offers early data, and we must have already
|
|
2102
|
-
// filled in
|
|
2277
|
+
// filled in `early_data_reason` by this point.
|
|
2103
2278
|
if (ssl->s3->used_hello_retry_request) {
|
|
2104
2279
|
assert(ssl->s3->early_data_reason != ssl_early_data_unknown);
|
|
2105
2280
|
return true;
|
|
@@ -2112,7 +2287,7 @@ static bool ext_early_data_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
2112
2287
|
// If offering ECH, the extension only applies to ClientHelloInner, but we
|
|
2113
2288
|
// send the extension in both ClientHellos. This ensures that, if the server
|
|
2114
2289
|
// handshakes with ClientHelloOuter, it can skip past early data. See
|
|
2115
|
-
//
|
|
2290
|
+
// RFC 9849, section 6.1.
|
|
2116
2291
|
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_early_data) || //
|
|
2117
2292
|
!CBB_add_u16(out_compressible, 0) || //
|
|
2118
2293
|
!CBB_flush(out_compressible)) {
|
|
@@ -2126,13 +2301,13 @@ static bool ext_early_data_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
2126
2301
|
uint8_t *out_alert,
|
|
2127
2302
|
CBS *contents) {
|
|
2128
2303
|
SSL *const ssl = hs->ssl;
|
|
2129
|
-
if (contents ==
|
|
2304
|
+
if (contents == nullptr) {
|
|
2130
2305
|
if (hs->early_data_offered && !ssl->s3->used_hello_retry_request) {
|
|
2131
2306
|
ssl->s3->early_data_reason = ssl->s3->session_reused
|
|
2132
2307
|
? ssl_early_data_peer_declined
|
|
2133
2308
|
: ssl_early_data_session_not_resumed;
|
|
2134
2309
|
} else {
|
|
2135
|
-
// We already filled in
|
|
2310
|
+
// We already filled in `early_data_reason` when declining to offer 0-RTT
|
|
2136
2311
|
// or handling the implicit HelloRetryRequest reject.
|
|
2137
2312
|
assert(ssl->s3->early_data_reason != ssl_early_data_unknown);
|
|
2138
2313
|
}
|
|
@@ -2164,7 +2339,7 @@ static bool ext_early_data_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
2164
2339
|
uint8_t *out_alert,
|
|
2165
2340
|
CBS *contents) {
|
|
2166
2341
|
SSL *const ssl = hs->ssl;
|
|
2167
|
-
if (contents ==
|
|
2342
|
+
if (contents == nullptr || ssl_protocol_version(ssl) < TLS1_3_VERSION) {
|
|
2168
2343
|
return true;
|
|
2169
2344
|
}
|
|
2170
2345
|
|
|
@@ -2198,8 +2373,7 @@ static bool ext_early_data_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
|
2198
2373
|
|
|
2199
2374
|
bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id) {
|
|
2200
2375
|
SSL *const ssl = hs->ssl;
|
|
2201
|
-
hs->key_shares
|
|
2202
|
-
hs->key_shares[1].reset();
|
|
2376
|
+
hs->key_shares.clear();
|
|
2203
2377
|
hs->key_share_bytes.Reset();
|
|
2204
2378
|
|
|
2205
2379
|
// If offering a PAKE, do not set up key shares. We do not currently support
|
|
@@ -2208,57 +2382,89 @@ bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id) {
|
|
|
2208
2382
|
return true;
|
|
2209
2383
|
}
|
|
2210
2384
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2385
|
+
const Span<const uint16_t> supported_group_list =
|
|
2386
|
+
hs->config->supported_group_list;
|
|
2387
|
+
if (supported_group_list.empty()) {
|
|
2388
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_GROUPS_SPECIFIED);
|
|
2213
2389
|
return false;
|
|
2214
2390
|
}
|
|
2215
2391
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2392
|
+
std::optional<Span<const uint16_t>> selected_key_shares;
|
|
2393
|
+
|
|
2394
|
+
// This is used for HelloRetryRequest, where we have already been given the
|
|
2395
|
+
// correct group to use.
|
|
2396
|
+
if (override_group_id != 0) {
|
|
2397
|
+
assert(std::find(supported_group_list.begin(), supported_group_list.end(),
|
|
2398
|
+
override_group_id) != supported_group_list.end());
|
|
2399
|
+
selected_key_shares.emplace(&override_group_id, 1u);
|
|
2223
2400
|
}
|
|
2224
2401
|
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2402
|
+
// First try to predict the most preferred (by our preference order) group
|
|
2403
|
+
// that was hinted by the server.
|
|
2404
|
+
const auto &server_hint_list = ssl->config->server_supported_groups_hint;
|
|
2405
|
+
if (!selected_key_shares.has_value() && !server_hint_list.empty()) {
|
|
2406
|
+
for (const uint16_t &supported_group : supported_group_list) {
|
|
2407
|
+
if (std::find(server_hint_list.begin(), server_hint_list.end(),
|
|
2408
|
+
supported_group) != server_hint_list.end()) {
|
|
2409
|
+
selected_key_shares.emplace(&supported_group, 1u);
|
|
2410
|
+
break;
|
|
2411
|
+
}
|
|
2233
2412
|
}
|
|
2413
|
+
}
|
|
2234
2414
|
|
|
2235
|
-
|
|
2415
|
+
// Otherwise, try to use explicitly configured key shares from the caller.
|
|
2416
|
+
if (!selected_key_shares.has_value() &&
|
|
2417
|
+
ssl->config->client_key_share_selections.has_value()) {
|
|
2418
|
+
selected_key_shares.emplace(*ssl->config->client_key_share_selections);
|
|
2419
|
+
}
|
|
2236
2420
|
|
|
2421
|
+
// Run the default selection if we don't have anything better.
|
|
2422
|
+
InplaceVector<uint16_t, 2> default_key_shares;
|
|
2423
|
+
if (!selected_key_shares.has_value()) {
|
|
2424
|
+
// By default, predict the most preferred group.
|
|
2425
|
+
if (!default_key_shares.TryPushBack(supported_group_list[0])) {
|
|
2426
|
+
return false;
|
|
2427
|
+
}
|
|
2237
2428
|
// We'll try to include one post-quantum and one classical initial key
|
|
2238
2429
|
// share.
|
|
2239
|
-
for (size_t i = 1; i <
|
|
2240
|
-
if (is_post_quantum_group(
|
|
2241
|
-
|
|
2242
|
-
|
|
2430
|
+
for (size_t i = 1; i < supported_group_list.size(); i++) {
|
|
2431
|
+
if (is_post_quantum_group(default_key_shares[0]) ==
|
|
2432
|
+
is_post_quantum_group(supported_group_list[i])) {
|
|
2433
|
+
continue;
|
|
2243
2434
|
}
|
|
2435
|
+
if (!default_key_shares.TryPushBack(supported_group_list[i])) {
|
|
2436
|
+
return false;
|
|
2437
|
+
}
|
|
2438
|
+
assert(default_key_shares[1] != default_key_shares[0]);
|
|
2439
|
+
break;
|
|
2244
2440
|
}
|
|
2441
|
+
selected_key_shares.emplace(default_key_shares);
|
|
2245
2442
|
}
|
|
2246
2443
|
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
!CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) ||
|
|
2252
|
-
!hs->key_shares[0]->Generate(&key_exchange)) {
|
|
2444
|
+
assert(selected_key_shares.has_value());
|
|
2445
|
+
|
|
2446
|
+
bssl::ScopedCBB cbb;
|
|
2447
|
+
if (!CBB_init(cbb.get(), 64)) {
|
|
2253
2448
|
return false;
|
|
2254
2449
|
}
|
|
2255
2450
|
|
|
2256
|
-
if (
|
|
2257
|
-
|
|
2258
|
-
if (!hs
|
|
2259
|
-
!CBB_add_u16(cbb.get(),
|
|
2260
|
-
!
|
|
2261
|
-
|
|
2451
|
+
if (override_group_id == 0 && ssl->ctx->grease_enabled) {
|
|
2452
|
+
// Add a fake group. See RFC 8701.
|
|
2453
|
+
if (!CBB_add_u16(cbb.get(), ssl_get_grease_value(hs, ssl_grease_group)) ||
|
|
2454
|
+
!CBB_add_u16(cbb.get(), 1 /* length */) ||
|
|
2455
|
+
!CBB_add_u8(cbb.get(), 0 /* one byte key share */)) {
|
|
2456
|
+
return false;
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
CBB key_exchange;
|
|
2461
|
+
for (const uint16_t group_id : *selected_key_shares) {
|
|
2462
|
+
UniquePtr<SSLKeyShare> key_share = SSLKeyShare::Create(group_id);
|
|
2463
|
+
if (key_share == nullptr || //
|
|
2464
|
+
!CBB_add_u16(cbb.get(), group_id) || //
|
|
2465
|
+
!CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) || //
|
|
2466
|
+
!key_share->Generate(&key_exchange) || //
|
|
2467
|
+
!hs->key_shares.TryPushBack(std::move(key_share))) {
|
|
2262
2468
|
return false;
|
|
2263
2469
|
}
|
|
2264
2470
|
}
|
|
@@ -2275,7 +2481,12 @@ static bool ext_key_share_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
2275
2481
|
return true;
|
|
2276
2482
|
}
|
|
2277
2483
|
|
|
2278
|
-
|
|
2484
|
+
// The caller may explicitly configure empty key shares to request a
|
|
2485
|
+
// HelloRetryRequest.
|
|
2486
|
+
assert(!hs->key_share_bytes.empty() ||
|
|
2487
|
+
(hs->config->client_key_share_selections.has_value() &&
|
|
2488
|
+
hs->config->client_key_share_selections->empty()));
|
|
2489
|
+
|
|
2279
2490
|
CBB contents, kse_bytes;
|
|
2280
2491
|
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_key_share) ||
|
|
2281
2492
|
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
|
@@ -2292,13 +2503,9 @@ static bool ext_key_share_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
|
|
|
2292
2503
|
bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
2293
2504
|
Array<uint8_t> *out_secret,
|
|
2294
2505
|
uint8_t *out_alert, CBS *contents) {
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
|
2299
|
-
*out_alert = SSL_AD_INTERNAL_ERROR;
|
|
2300
|
-
return false;
|
|
2301
|
-
}
|
|
2506
|
+
// If we did not offer key shares, the extension should have been rejected
|
|
2507
|
+
// as unsolicited.
|
|
2508
|
+
assert(!hs->key_shares.empty());
|
|
2302
2509
|
|
|
2303
2510
|
CBS ciphertext;
|
|
2304
2511
|
uint16_t group_id;
|
|
@@ -2310,24 +2517,23 @@ bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
2310
2517
|
return false;
|
|
2311
2518
|
}
|
|
2312
2519
|
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2520
|
+
const auto key_share_it =
|
|
2521
|
+
std::find_if(hs->key_shares.begin(), hs->key_shares.end(),
|
|
2522
|
+
[group_id](const auto &key_share) {
|
|
2523
|
+
return key_share->GroupID() == group_id;
|
|
2524
|
+
});
|
|
2525
|
+
if (key_share_it == hs->key_shares.end()) {
|
|
2526
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
2527
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_CURVE);
|
|
2528
|
+
return false;
|
|
2321
2529
|
}
|
|
2322
|
-
|
|
2323
|
-
if (!key_share->Decap(out_secret, out_alert, ciphertext)) {
|
|
2530
|
+
if (!(*key_share_it)->Decap(out_secret, out_alert, ciphertext)) {
|
|
2324
2531
|
*out_alert = SSL_AD_INTERNAL_ERROR;
|
|
2325
2532
|
return false;
|
|
2326
2533
|
}
|
|
2327
2534
|
|
|
2328
2535
|
hs->new_session->group_id = group_id;
|
|
2329
|
-
hs->key_shares
|
|
2330
|
-
hs->key_shares[1].reset();
|
|
2536
|
+
hs->key_shares.clear();
|
|
2331
2537
|
return true;
|
|
2332
2538
|
}
|
|
2333
2539
|
|
|
@@ -2518,7 +2724,7 @@ static bool ext_supported_groups_add_clienthello(const SSL_HANDSHAKE *hs,
|
|
|
2518
2724
|
return false;
|
|
2519
2725
|
}
|
|
2520
2726
|
|
|
2521
|
-
for (uint16_t group :
|
|
2727
|
+
for (uint16_t group : hs->config->supported_group_list) {
|
|
2522
2728
|
if (is_post_quantum_group(group) && hs->max_version < TLS1_3_VERSION) {
|
|
2523
2729
|
continue;
|
|
2524
2730
|
}
|
|
@@ -2564,7 +2770,7 @@ static bool parse_u16_array(const CBS *cbs, Array<uint16_t> *out) {
|
|
|
2564
2770
|
static bool ext_supported_groups_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
2565
2771
|
uint8_t *out_alert,
|
|
2566
2772
|
CBS *contents) {
|
|
2567
|
-
if (contents ==
|
|
2773
|
+
if (contents == nullptr) {
|
|
2568
2774
|
return true;
|
|
2569
2775
|
}
|
|
2570
2776
|
|
|
@@ -2591,9 +2797,9 @@ static bool ext_certificate_authorities_add_clienthello(
|
|
|
2591
2797
|
if (ssl_has_CA_names(hs->config)) {
|
|
2592
2798
|
CBB ca_contents;
|
|
2593
2799
|
if (!CBB_add_u16(out_compressible,
|
|
2594
|
-
TLSEXT_TYPE_certificate_authorities) ||
|
|
2595
|
-
!CBB_add_u16_length_prefixed(out_compressible, &ca_contents) ||
|
|
2596
|
-
!ssl_add_CA_names(hs, &ca_contents) ||
|
|
2800
|
+
TLSEXT_TYPE_certificate_authorities) || //
|
|
2801
|
+
!CBB_add_u16_length_prefixed(out_compressible, &ca_contents) || //
|
|
2802
|
+
!ssl_add_CA_names(hs, &ca_contents) || //
|
|
2597
2803
|
!CBB_flush(out_compressible)) {
|
|
2598
2804
|
return false;
|
|
2599
2805
|
}
|
|
@@ -2604,7 +2810,7 @@ static bool ext_certificate_authorities_add_clienthello(
|
|
|
2604
2810
|
static bool ext_certificate_authorities_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
2605
2811
|
uint8_t *out_alert,
|
|
2606
2812
|
CBS *contents) {
|
|
2607
|
-
if (contents ==
|
|
2813
|
+
if (contents == nullptr) {
|
|
2608
2814
|
return true;
|
|
2609
2815
|
}
|
|
2610
2816
|
|
|
@@ -2613,13 +2819,115 @@ static bool ext_certificate_authorities_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
2613
2819
|
}
|
|
2614
2820
|
|
|
2615
2821
|
hs->ca_names = SSL_parse_CA_list(hs->ssl, out_alert, contents);
|
|
2616
|
-
if (!hs->ca_names)
|
|
2822
|
+
if (!hs->ca_names || sk_CRYPTO_BUFFER_num(hs->ca_names.get()) == 0 ||
|
|
2823
|
+
CBS_len(contents) != 0) {
|
|
2617
2824
|
return false;
|
|
2618
2825
|
}
|
|
2619
2826
|
|
|
2620
2827
|
return true;
|
|
2621
2828
|
}
|
|
2622
2829
|
|
|
2830
|
+
// Server Padding extension.
|
|
2831
|
+
//
|
|
2832
|
+
// Adds empty bytes to EncryptedExtensions for TLS 1.3 connections that request
|
|
2833
|
+
// it.
|
|
2834
|
+
|
|
2835
|
+
// Limit max padding to 16k.
|
|
2836
|
+
constexpr uint16_t kMaxServerPadding = 16 * 1024;
|
|
2837
|
+
|
|
2838
|
+
static bool ext_server_padding_add_clienthello(const SSL_HANDSHAKE *hs,
|
|
2839
|
+
CBB *out, CBB *out_compressible,
|
|
2840
|
+
ssl_client_hello_type_t type) {
|
|
2841
|
+
if (!hs->config->server_padding_request.has_value()) {
|
|
2842
|
+
return true;
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
CBB contents;
|
|
2846
|
+
if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_server_padding) ||
|
|
2847
|
+
!CBB_add_u16_length_prefixed(out_compressible, &contents) ||
|
|
2848
|
+
!CBB_add_u16(&contents, hs->config->server_padding_request.value()) ||
|
|
2849
|
+
!CBB_flush(out_compressible)) {
|
|
2850
|
+
return false;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
return true;
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
static bool ext_server_padding_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
2857
|
+
uint8_t *out_alert,
|
|
2858
|
+
CBS *contents) {
|
|
2859
|
+
if (contents == nullptr) {
|
|
2860
|
+
return true;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
if (ssl_protocol_version(hs->ssl) < TLS1_3_VERSION) {
|
|
2864
|
+
return true;
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
uint16_t padding_requested;
|
|
2868
|
+
if (!CBS_get_u16(contents, &padding_requested) || CBS_len(contents) != 0) {
|
|
2869
|
+
*out_alert = SSL_AD_DECODE_ERROR;
|
|
2870
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
2871
|
+
return false;
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
hs->client_requested_server_padding_size = padding_requested;
|
|
2875
|
+
return true;
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
static bool ext_server_padding_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2879
|
+
SSL *const ssl = hs->ssl;
|
|
2880
|
+
if (ssl_protocol_version(ssl) < TLS1_3_VERSION ||
|
|
2881
|
+
!hs->client_requested_server_padding_size ||
|
|
2882
|
+
!hs->config->server_padding_enabled) {
|
|
2883
|
+
return true;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
// The extension shouldn't be sent when resuming sessions.
|
|
2887
|
+
if (ssl->s3->session_reused) {
|
|
2888
|
+
return true;
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
// Limit max padding; if a client requests more than this, don't return any
|
|
2892
|
+
// padding.
|
|
2893
|
+
uint16_t padding_len = hs->client_requested_server_padding_size.value();
|
|
2894
|
+
if (padding_len > kMaxServerPadding) {
|
|
2895
|
+
return true;
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
CBB contents;
|
|
2899
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_server_padding) ||
|
|
2900
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
2901
|
+
!CBB_add_zeros(&contents, padding_len) || !CBB_flush(out)) {
|
|
2902
|
+
return false;
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
return true;
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
static bool ext_server_padding_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
2909
|
+
uint8_t *out_alert,
|
|
2910
|
+
CBS *contents) {
|
|
2911
|
+
if (contents == nullptr) {
|
|
2912
|
+
return true;
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
if (ssl_protocol_version(hs->ssl) < TLS1_3_VERSION ||
|
|
2916
|
+
!hs->config->server_padding_request) {
|
|
2917
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
|
|
2918
|
+
*out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
|
|
2919
|
+
return false;
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
if (hs->config->server_padding_request.value() != CBS_len(contents)) {
|
|
2923
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
2924
|
+
*out_alert = SSL_AD_DECODE_ERROR;
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
hs->ssl->s3->server_sent_requested_padding = true;
|
|
2929
|
+
return true;
|
|
2930
|
+
}
|
|
2623
2931
|
|
|
2624
2932
|
// Trust Anchor Identifiers
|
|
2625
2933
|
//
|
|
@@ -2665,7 +2973,8 @@ static bool ext_trust_anchors_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
2665
2973
|
|
|
2666
2974
|
CBS child;
|
|
2667
2975
|
if (!CBS_get_u16_length_prefixed(contents, &child) ||
|
|
2668
|
-
!ssl_is_valid_trust_anchor_list(child)
|
|
2976
|
+
!ssl_is_valid_trust_anchor_list(child) || //
|
|
2977
|
+
CBS_len(contents) != 0) {
|
|
2669
2978
|
*out_alert = SSL_AD_DECODE_ERROR;
|
|
2670
2979
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
2671
2980
|
return false;
|
|
@@ -2681,24 +2990,35 @@ static bool ext_trust_anchors_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
2681
2990
|
|
|
2682
2991
|
static bool ext_trust_anchors_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
2683
2992
|
SSL *const ssl = hs->ssl;
|
|
2684
|
-
|
|
2685
|
-
if (ssl_protocol_version(ssl) < TLS1_3_VERSION ||
|
|
2686
|
-
// Check if any credentials have trust anchor IDs.
|
|
2687
|
-
std::none_of(creds.begin(), creds.end(), [](const auto &cred) {
|
|
2688
|
-
return !cred->trust_anchor_id.empty();
|
|
2689
|
-
})) {
|
|
2993
|
+
if (ssl_protocol_version(ssl) < TLS1_3_VERSION) {
|
|
2690
2994
|
return true;
|
|
2691
2995
|
}
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2996
|
+
|
|
2997
|
+
const size_t old_len = CBB_len(out);
|
|
2998
|
+
CBB contents, list, child;
|
|
2999
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_trust_anchors) ||
|
|
3000
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
2695
3001
|
!CBB_add_u16_length_prefixed(&contents, &list)) {
|
|
2696
3002
|
return false;
|
|
2697
3003
|
}
|
|
2698
|
-
|
|
3004
|
+
|
|
3005
|
+
// Use the caller-provided list if they overrode it.
|
|
3006
|
+
if (!hs->config->cert->available_trust_anchors.empty()) {
|
|
3007
|
+
return CBB_add_bytes(&list,
|
|
3008
|
+
hs->config->cert->available_trust_anchors.data(),
|
|
3009
|
+
hs->config->cert->available_trust_anchors.size()) &&
|
|
3010
|
+
CBB_flush(out);
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
for (const auto &cred : hs->config->cert->credentials) {
|
|
2699
3014
|
if (!cred->trust_anchor_id.empty()) {
|
|
2700
|
-
|
|
2701
|
-
if (!
|
|
3015
|
+
uint16_t unused_sigalg;
|
|
3016
|
+
if (!ssl_check_tls13_credential_ignoring_issuer(
|
|
3017
|
+
hs, kAllCertTypes, cred.get(), &unused_sigalg)) {
|
|
3018
|
+
ERR_clear_error();
|
|
3019
|
+
continue;
|
|
3020
|
+
}
|
|
3021
|
+
if (!CBB_add_u8_length_prefixed(&list, &child) ||
|
|
2702
3022
|
!CBB_add_bytes(&child, cred->trust_anchor_id.data(),
|
|
2703
3023
|
cred->trust_anchor_id.size()) ||
|
|
2704
3024
|
!CBB_flush(&list)) {
|
|
@@ -2706,7 +3026,17 @@ static bool ext_trust_anchors_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
|
2706
3026
|
}
|
|
2707
3027
|
}
|
|
2708
3028
|
}
|
|
2709
|
-
|
|
3029
|
+
|
|
3030
|
+
bool empty = CBB_len(&list) == 0;
|
|
3031
|
+
if (!CBB_flush(out)) {
|
|
3032
|
+
return false;
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
// Don't send the extension if it would have been empty.
|
|
3036
|
+
if (empty) {
|
|
3037
|
+
CBB_discard(out, CBB_len(out) - old_len);
|
|
3038
|
+
}
|
|
3039
|
+
return true;
|
|
2710
3040
|
}
|
|
2711
3041
|
|
|
2712
3042
|
static bool ext_trust_anchors_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
@@ -2725,8 +3055,9 @@ static bool ext_trust_anchors_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
2725
3055
|
CBS child;
|
|
2726
3056
|
if (!CBS_get_u16_length_prefixed(contents, &child) ||
|
|
2727
3057
|
// The list of available trust anchors may not be empty.
|
|
2728
|
-
CBS_len(&child) == 0 ||
|
|
2729
|
-
!ssl_is_valid_trust_anchor_list(child)
|
|
3058
|
+
CBS_len(&child) == 0 || //
|
|
3059
|
+
!ssl_is_valid_trust_anchor_list(child) || //
|
|
3060
|
+
CBS_len(contents) != 0) {
|
|
2730
3061
|
*out_alert = SSL_AD_DECODE_ERROR;
|
|
2731
3062
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
2732
3063
|
return false;
|
|
@@ -2834,7 +3165,7 @@ static bool ext_quic_transport_params_parse_clienthello_impl(
|
|
|
2834
3165
|
if (hs->config->quic_transport_params.empty()) {
|
|
2835
3166
|
return true;
|
|
2836
3167
|
}
|
|
2837
|
-
// QUIC transport parameters must not be set if
|
|
3168
|
+
// QUIC transport parameters must not be set if `ssl` is not configured
|
|
2838
3169
|
// for QUIC.
|
|
2839
3170
|
OPENSSL_PUT_ERROR(SSL, SSL_R_QUIC_TRANSPORT_PARAMETERS_MISCONFIGURED);
|
|
2840
3171
|
*out_alert = SSL_AD_INTERNAL_ERROR;
|
|
@@ -3005,7 +3336,7 @@ static bool cert_compression_parse_clienthello(SSL_HANDSHAKE *hs,
|
|
|
3005
3336
|
return true;
|
|
3006
3337
|
}
|
|
3007
3338
|
|
|
3008
|
-
const
|
|
3339
|
+
const SSLContext *ctx = hs->ssl->ctx.get();
|
|
3009
3340
|
const size_t num_algs = ctx->cert_compression_algs.size();
|
|
3010
3341
|
|
|
3011
3342
|
CBS alg_ids;
|
|
@@ -3090,7 +3421,7 @@ bool ssl_setup_pake_shares(SSL_HANDSHAKE *hs) {
|
|
|
3090
3421
|
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CREDENTIAL_LIST);
|
|
3091
3422
|
return false;
|
|
3092
3423
|
}
|
|
3093
|
-
|
|
3424
|
+
SSLCredential *cred = creds[0].get();
|
|
3094
3425
|
assert(cred->type == SSLCredentialType::kSPAKE2PlusV1Client);
|
|
3095
3426
|
|
|
3096
3427
|
hs->pake_prover = MakeUnique<spake2plus::Prover>();
|
|
@@ -3175,7 +3506,7 @@ bool ssl_ext_pake_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
3175
3506
|
}
|
|
3176
3507
|
Span<const uint8_t> pake_msg_span = pake_msg;
|
|
3177
3508
|
|
|
3178
|
-
// Releasing the result of
|
|
3509
|
+
// Releasing the result of `ComputeConfirmation` lets the client confirm one
|
|
3179
3510
|
// PAKE guess. If all failures are used up, no more guesses are allowed.
|
|
3180
3511
|
if (!hs->credential->HasPAKEAttempts()) {
|
|
3181
3512
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PAKE_EXHAUSTED);
|
|
@@ -3187,7 +3518,7 @@ bool ssl_ext_pake_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
3187
3518
|
uint8_t prover_secret[spake2plus::kSecretSize];
|
|
3188
3519
|
if (!hs->pake_prover->ComputeConfirmation(
|
|
3189
3520
|
prover_confirm, prover_secret,
|
|
3190
|
-
pake_msg_span.
|
|
3521
|
+
pake_msg_span.first<spake2plus::kShareSize>(),
|
|
3191
3522
|
pake_msg_span.subspan(spake2plus::kShareSize))) {
|
|
3192
3523
|
// Record a failure before releasing the answer to the client.
|
|
3193
3524
|
hs->credential->ClaimPAKEAttempt();
|
|
@@ -3369,7 +3700,7 @@ static bool ext_alps_parse_serverhello_impl(SSL_HANDSHAKE *hs,
|
|
|
3369
3700
|
}
|
|
3370
3701
|
|
|
3371
3702
|
// Note extension callbacks may run in any order, so we defer checking
|
|
3372
|
-
// consistency with ALPN to
|
|
3703
|
+
// consistency with ALPN to `ssl_check_serverhello_tlsext`.
|
|
3373
3704
|
if (!hs->new_session->peer_application_settings.CopyFrom(*contents)) {
|
|
3374
3705
|
*out_alert = SSL_AD_INTERNAL_ERROR;
|
|
3375
3706
|
return false;
|
|
@@ -3489,6 +3820,249 @@ bool ssl_negotiate_alps(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
3489
3820
|
return true;
|
|
3490
3821
|
}
|
|
3491
3822
|
|
|
3823
|
+
// Client certificate type & Server certificate type
|
|
3824
|
+
//
|
|
3825
|
+
// https://www.rfc-editor.org/rfc/rfc7250.html#section-3
|
|
3826
|
+
|
|
3827
|
+
// parse_clienthello_cert_types_list returns a span containing the cert type
|
|
3828
|
+
// values from a client_certificate_type or server_certificate_type ClientHello
|
|
3829
|
+
// extension. Returns std::nullopt on error, or returns a nonempty span
|
|
3830
|
+
// containing the values. This rejects the invalid empty list and list
|
|
3831
|
+
// containing only the default X.509. This does not filter out unrecognized
|
|
3832
|
+
// values. We don't check for duplicates here, even though a list containing
|
|
3833
|
+
// duplicates should be considered invalid, to avoid quadratic behavior.
|
|
3834
|
+
static std::optional<Span<const uint8_t>> parse_clienthello_cert_types_list(
|
|
3835
|
+
uint8_t *out_alert, CBS *contents) {
|
|
3836
|
+
CBS cert_types;
|
|
3837
|
+
if (!CBS_get_u8_length_prefixed(contents, &cert_types) ||
|
|
3838
|
+
CBS_len(contents) != 0) {
|
|
3839
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
3840
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
3841
|
+
return std::nullopt;
|
|
3842
|
+
}
|
|
3843
|
+
Span<const uint8_t> cert_types_list(cert_types);
|
|
3844
|
+
// The client must omit the extension if the only type would be the default,
|
|
3845
|
+
// X.509.
|
|
3846
|
+
if (cert_types_list.empty() ||
|
|
3847
|
+
(cert_types_list.size() == 1 && cert_types_list[0] == kDefaultCertType)) {
|
|
3848
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
3849
|
+
*out_alert = SSL_AD_ILLEGAL_PARAMETER;
|
|
3850
|
+
return std::nullopt;
|
|
3851
|
+
}
|
|
3852
|
+
return cert_types_list;
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
void ssl_setup_client_certificate_type(SSL_HANDSHAKE *hs) {
|
|
3856
|
+
assert(!hs->ssl->server);
|
|
3857
|
+
hs->offered_client_cert_types.clear();
|
|
3858
|
+
InplaceVector<uint8_t, kNumCertTypes> available_cert_types;
|
|
3859
|
+
if (!hs->ssl->config->available_client_cert_types.empty()) {
|
|
3860
|
+
available_cert_types.CopyFrom(hs->ssl->config->available_client_cert_types);
|
|
3861
|
+
} else {
|
|
3862
|
+
// Compute the available cert types based on configured SSL_CREDENTIALs.
|
|
3863
|
+
const auto append_if_not_present = [&](uint8_t cert_type) {
|
|
3864
|
+
if (std::find(available_cert_types.begin(), available_cert_types.end(),
|
|
3865
|
+
cert_type) == available_cert_types.end()) {
|
|
3866
|
+
available_cert_types.PushBack(cert_type);
|
|
3867
|
+
}
|
|
3868
|
+
};
|
|
3869
|
+
for (const auto &credential : hs->config->cert->credentials) {
|
|
3870
|
+
if (std::optional<uint8_t> cert_type =
|
|
3871
|
+
ssl_credential_type_to_cert_type(credential->type);
|
|
3872
|
+
cert_type.has_value()) {
|
|
3873
|
+
append_if_not_present(*cert_type);
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
if (available_cert_types.empty() ||
|
|
3878
|
+
// Omit extension if the only type would be the default, X.509.
|
|
3879
|
+
(available_cert_types.size() == 1 &&
|
|
3880
|
+
available_cert_types[0] == kDefaultCertType)) {
|
|
3881
|
+
return;
|
|
3882
|
+
}
|
|
3883
|
+
hs->offered_client_cert_types = std::move(available_cert_types);
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
bool ssl_negotiate_client_certificate_type(
|
|
3887
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
3888
|
+
const SSL_CLIENT_HELLO *client_hello) {
|
|
3889
|
+
assert(hs->ssl->server);
|
|
3890
|
+
assert(!hs->config->accepted_peer_cert_types.empty());
|
|
3891
|
+
CBS contents;
|
|
3892
|
+
Span<const uint8_t> peer_available_client_cert_types;
|
|
3893
|
+
if (ssl_client_hello_get_extension(client_hello, &contents,
|
|
3894
|
+
TLSEXT_TYPE_client_cert_type)) {
|
|
3895
|
+
std::optional<Span<const uint8_t>> client_hello_client_cert_types =
|
|
3896
|
+
parse_clienthello_cert_types_list(out_alert, &contents);
|
|
3897
|
+
if (!client_hello_client_cert_types.has_value()) {
|
|
3898
|
+
return false;
|
|
3899
|
+
}
|
|
3900
|
+
peer_available_client_cert_types = *client_hello_client_cert_types;
|
|
3901
|
+
}
|
|
3902
|
+
if (!hs->cert_request) {
|
|
3903
|
+
return true;
|
|
3904
|
+
}
|
|
3905
|
+
// If the client didn't send the extension, assume the client supports X.509
|
|
3906
|
+
// only by default.
|
|
3907
|
+
if (peer_available_client_cert_types.empty()) {
|
|
3908
|
+
peer_available_client_cert_types =
|
|
3909
|
+
Span<const uint8_t>(&kDefaultCertType, 1u);
|
|
3910
|
+
}
|
|
3911
|
+
for (const uint8_t cert_type : hs->config->accepted_peer_cert_types) {
|
|
3912
|
+
if (std::find(peer_available_client_cert_types.begin(),
|
|
3913
|
+
peer_available_client_cert_types.end(),
|
|
3914
|
+
cert_type) == peer_available_client_cert_types.end()) {
|
|
3915
|
+
continue;
|
|
3916
|
+
}
|
|
3917
|
+
hs->peer_cert_type = cert_type;
|
|
3918
|
+
return true;
|
|
3919
|
+
}
|
|
3920
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CERTIFICATE);
|
|
3921
|
+
*out_alert = SSL_AD_UNSUPPORTED_CERTIFICATE;
|
|
3922
|
+
return false;
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
static bool ext_client_cert_type_add_clienthello(const SSL_HANDSHAKE *hs,
|
|
3926
|
+
CBB *out,
|
|
3927
|
+
CBB *out_compressible,
|
|
3928
|
+
ssl_client_hello_type_t type) {
|
|
3929
|
+
if (hs->offered_client_cert_types.empty()) {
|
|
3930
|
+
return true;
|
|
3931
|
+
}
|
|
3932
|
+
CBB contents, client_cert_types;
|
|
3933
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_client_cert_type) ||
|
|
3934
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
3935
|
+
!CBB_add_u8_length_prefixed(&contents, &client_cert_types) ||
|
|
3936
|
+
!CBB_add_bytes(&client_cert_types, hs->offered_client_cert_types.data(),
|
|
3937
|
+
hs->offered_client_cert_types.size()) ||
|
|
3938
|
+
!CBB_flush(out)) {
|
|
3939
|
+
return false;
|
|
3940
|
+
}
|
|
3941
|
+
return true;
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
static bool ext_client_cert_type_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
3945
|
+
uint8_t *out_alert,
|
|
3946
|
+
CBS *contents) {
|
|
3947
|
+
if (contents == nullptr) {
|
|
3948
|
+
return true;
|
|
3949
|
+
}
|
|
3950
|
+
uint8_t cert_type;
|
|
3951
|
+
if (!CBS_get_u8(contents, &cert_type) || CBS_len(contents) != 0) {
|
|
3952
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
3953
|
+
*out_alert = SSL_AD_DECODE_ERROR;
|
|
3954
|
+
return false;
|
|
3955
|
+
}
|
|
3956
|
+
// Reject if the server picked a cert type that we didn't offer in the
|
|
3957
|
+
// ClientHello.
|
|
3958
|
+
if (std::find(hs->offered_client_cert_types.begin(),
|
|
3959
|
+
hs->offered_client_cert_types.end(),
|
|
3960
|
+
cert_type) == hs->offered_client_cert_types.end()) {
|
|
3961
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CERTIFICATE);
|
|
3962
|
+
*out_alert = SSL_AD_UNSUPPORTED_CERTIFICATE;
|
|
3963
|
+
return false;
|
|
3964
|
+
}
|
|
3965
|
+
hs->client_cert_type = cert_type;
|
|
3966
|
+
return true;
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
static bool ext_client_cert_type_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
3970
|
+
// Only send client_certificate_type if we plan to send a CertificateRequest.
|
|
3971
|
+
if (!hs->cert_request) {
|
|
3972
|
+
return true;
|
|
3973
|
+
}
|
|
3974
|
+
CBB contents;
|
|
3975
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_client_cert_type) ||
|
|
3976
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
3977
|
+
!CBB_add_u8(&contents, hs->peer_cert_type) || //
|
|
3978
|
+
!CBB_flush(out)) {
|
|
3979
|
+
return false;
|
|
3980
|
+
}
|
|
3981
|
+
return true;
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
std::optional<Span<const uint8_t>> ssl_get_allowed_server_cert_types(
|
|
3985
|
+
const SSL_HANDSHAKE *hs, const SSL_CLIENT_HELLO *client_hello,
|
|
3986
|
+
uint8_t *out_alert) {
|
|
3987
|
+
assert(hs->ssl->server);
|
|
3988
|
+
std::optional<Span<const uint8_t>> clienthello_server_cert_types;
|
|
3989
|
+
CBS server_cert_types_ext;
|
|
3990
|
+
if (ssl_client_hello_get_extension(client_hello, &server_cert_types_ext,
|
|
3991
|
+
TLSEXT_TYPE_server_cert_type)) {
|
|
3992
|
+
clienthello_server_cert_types =
|
|
3993
|
+
parse_clienthello_cert_types_list(out_alert, &server_cert_types_ext);
|
|
3994
|
+
if (!clienthello_server_cert_types.has_value()) {
|
|
3995
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_ERROR_PARSING_EXTENSION);
|
|
3996
|
+
return std::nullopt;
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
// Allow X.509 certificates by default.
|
|
4000
|
+
return clienthello_server_cert_types.value_or(Span(&kDefaultCertType, 1u));
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
static bool ext_server_cert_type_add_clienthello(const SSL_HANDSHAKE *hs,
|
|
4004
|
+
CBB *out,
|
|
4005
|
+
CBB *out_compressible,
|
|
4006
|
+
ssl_client_hello_type_t type) {
|
|
4007
|
+
assert(!hs->config->accepted_peer_cert_types.empty());
|
|
4008
|
+
// Omit extension if the only type would be the default, X.509.
|
|
4009
|
+
if (hs->config->accepted_peer_cert_types.size() == 1 &&
|
|
4010
|
+
hs->config->accepted_peer_cert_types[0] == kDefaultCertType) {
|
|
4011
|
+
return true;
|
|
4012
|
+
}
|
|
4013
|
+
CBB contents, server_cert_types;
|
|
4014
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_server_cert_type) ||
|
|
4015
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
4016
|
+
!CBB_add_u8_length_prefixed(&contents, &server_cert_types) ||
|
|
4017
|
+
!CBB_add_bytes(&server_cert_types,
|
|
4018
|
+
hs->config->accepted_peer_cert_types.data(),
|
|
4019
|
+
hs->config->accepted_peer_cert_types.size()) ||
|
|
4020
|
+
!CBB_flush(out)) {
|
|
4021
|
+
return false;
|
|
4022
|
+
}
|
|
4023
|
+
return true;
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
static bool ext_server_cert_type_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
4027
|
+
uint8_t *out_alert,
|
|
4028
|
+
CBS *contents) {
|
|
4029
|
+
assert(!hs->config->accepted_peer_cert_types.empty());
|
|
4030
|
+
// Absence of an extension from the server implies the default, X.509.
|
|
4031
|
+
uint8_t cert_type = kDefaultCertType;
|
|
4032
|
+
if (contents != nullptr &&
|
|
4033
|
+
(!CBS_get_u8(contents, &cert_type) || CBS_len(contents) != 0)) {
|
|
4034
|
+
return false;
|
|
4035
|
+
}
|
|
4036
|
+
// Check that the server's chosen type is among the types we accept.
|
|
4037
|
+
if (std::find(hs->config->accepted_peer_cert_types.begin(),
|
|
4038
|
+
hs->config->accepted_peer_cert_types.end(),
|
|
4039
|
+
cert_type) == hs->config->accepted_peer_cert_types.end()) {
|
|
4040
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CERTIFICATE);
|
|
4041
|
+
*out_alert = SSL_AD_UNSUPPORTED_CERTIFICATE;
|
|
4042
|
+
return false;
|
|
4043
|
+
}
|
|
4044
|
+
hs->peer_cert_type = cert_type;
|
|
4045
|
+
return true;
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
static bool ext_server_cert_type_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
|
|
4049
|
+
if (hs->credential == nullptr) {
|
|
4050
|
+
return true;
|
|
4051
|
+
}
|
|
4052
|
+
const auto cert_type = ssl_credential_type_to_cert_type(hs->credential->type);
|
|
4053
|
+
if (!cert_type.has_value()) {
|
|
4054
|
+
return true;
|
|
4055
|
+
}
|
|
4056
|
+
CBB contents;
|
|
4057
|
+
if (!CBB_add_u16(out, TLSEXT_TYPE_server_cert_type) ||
|
|
4058
|
+
!CBB_add_u16_length_prefixed(out, &contents) ||
|
|
4059
|
+
!CBB_add_u8(&contents, *cert_type) || //
|
|
4060
|
+
!CBB_flush(out)) {
|
|
4061
|
+
return false;
|
|
4062
|
+
}
|
|
4063
|
+
return true;
|
|
4064
|
+
}
|
|
4065
|
+
|
|
3492
4066
|
// kExtensions contains all the supported extensions.
|
|
3493
4067
|
static const struct tls_extension kExtensions[] = {
|
|
3494
4068
|
{
|
|
@@ -3545,7 +4119,7 @@ static const struct tls_extension kExtensions[] = {
|
|
|
3545
4119
|
TLSEXT_TYPE_application_layer_protocol_negotiation,
|
|
3546
4120
|
ext_alpn_add_clienthello,
|
|
3547
4121
|
ext_alpn_parse_serverhello,
|
|
3548
|
-
// ALPN is negotiated late in
|
|
4122
|
+
// ALPN is negotiated late in `ssl_negotiate_alpn`.
|
|
3549
4123
|
ignore_parse_clienthello,
|
|
3550
4124
|
ext_alpn_add_serverhello,
|
|
3551
4125
|
},
|
|
@@ -3658,7 +4232,7 @@ static const struct tls_extension kExtensions[] = {
|
|
|
3658
4232
|
TLSEXT_TYPE_application_settings,
|
|
3659
4233
|
ext_alps_add_clienthello,
|
|
3660
4234
|
ext_alps_parse_serverhello,
|
|
3661
|
-
// ALPS is negotiated late in
|
|
4235
|
+
// ALPS is negotiated late in `ssl_negotiate_alpn`.
|
|
3662
4236
|
ignore_parse_clienthello,
|
|
3663
4237
|
ext_alps_add_serverhello,
|
|
3664
4238
|
},
|
|
@@ -3666,7 +4240,7 @@ static const struct tls_extension kExtensions[] = {
|
|
|
3666
4240
|
TLSEXT_TYPE_application_settings_old,
|
|
3667
4241
|
ext_alps_add_clienthello_old,
|
|
3668
4242
|
ext_alps_parse_serverhello_old,
|
|
3669
|
-
// ALPS is negotiated late in
|
|
4243
|
+
// ALPS is negotiated late in `ssl_negotiate_alpn`.
|
|
3670
4244
|
ignore_parse_clienthello,
|
|
3671
4245
|
ext_alps_add_serverhello_old,
|
|
3672
4246
|
},
|
|
@@ -3693,15 +4267,40 @@ static const struct tls_extension kExtensions[] = {
|
|
|
3693
4267
|
ext_trust_anchors_parse_clienthello,
|
|
3694
4268
|
ext_trust_anchors_add_serverhello,
|
|
3695
4269
|
},
|
|
4270
|
+
{
|
|
4271
|
+
TLSEXT_TYPE_client_cert_type,
|
|
4272
|
+
ext_client_cert_type_add_clienthello,
|
|
4273
|
+
ext_client_cert_type_parse_serverhello,
|
|
4274
|
+
// client_certificate_type is negotiated late in
|
|
4275
|
+
// `ssl_negotiate_client_cert_type`.
|
|
4276
|
+
ignore_parse_clienthello,
|
|
4277
|
+
ext_client_cert_type_add_serverhello,
|
|
4278
|
+
},
|
|
4279
|
+
{
|
|
4280
|
+
TLSEXT_TYPE_server_cert_type,
|
|
4281
|
+
ext_server_cert_type_add_clienthello,
|
|
4282
|
+
ext_server_cert_type_parse_serverhello,
|
|
4283
|
+
// The server_certificate_type list from the client is parsed later,
|
|
4284
|
+
// during credential selection.
|
|
4285
|
+
ignore_parse_clienthello,
|
|
4286
|
+
ext_server_cert_type_add_serverhello,
|
|
4287
|
+
},
|
|
4288
|
+
{
|
|
4289
|
+
TLSEXT_TYPE_server_padding,
|
|
4290
|
+
ext_server_padding_add_clienthello,
|
|
4291
|
+
ext_server_padding_parse_serverhello,
|
|
4292
|
+
ext_server_padding_parse_clienthello,
|
|
4293
|
+
ext_server_padding_add_serverhello,
|
|
4294
|
+
},
|
|
3696
4295
|
};
|
|
3697
4296
|
|
|
3698
4297
|
#define kNumExtensions (sizeof(kExtensions) / sizeof(struct tls_extension))
|
|
3699
4298
|
|
|
3700
4299
|
static_assert(kNumExtensions <=
|
|
3701
|
-
sizeof(((SSL_HANDSHAKE *)
|
|
4300
|
+
sizeof(((SSL_HANDSHAKE *)nullptr)->extensions.sent) * 8,
|
|
3702
4301
|
"too many extensions for sent bitset");
|
|
3703
4302
|
static_assert(kNumExtensions <=
|
|
3704
|
-
sizeof(((SSL_HANDSHAKE *)
|
|
4303
|
+
sizeof(((SSL_HANDSHAKE *)nullptr)->extensions.received) * 8,
|
|
3705
4304
|
"too many extensions for received bitset");
|
|
3706
4305
|
|
|
3707
4306
|
bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs) {
|
|
@@ -3721,7 +4320,7 @@ bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs) {
|
|
|
3721
4320
|
permutation[i] = i;
|
|
3722
4321
|
}
|
|
3723
4322
|
for (size_t i = kNumExtensions - 1; i > 0; i--) {
|
|
3724
|
-
// Set element
|
|
4323
|
+
// Set element `i` to a randomly-selected element 0 <= j <= i.
|
|
3725
4324
|
std::swap(permutation[i], permutation[seeds[i - 1] % (i + 1)]);
|
|
3726
4325
|
}
|
|
3727
4326
|
hs->extension_permutation = std::move(permutation);
|
|
@@ -3738,7 +4337,7 @@ static const struct tls_extension *tls_extension_find(uint32_t *out_index,
|
|
|
3738
4337
|
}
|
|
3739
4338
|
}
|
|
3740
4339
|
|
|
3741
|
-
return
|
|
4340
|
+
return nullptr;
|
|
3742
4341
|
}
|
|
3743
4342
|
|
|
3744
4343
|
static bool add_padding_extension(CBB *cbb, uint16_t ext, size_t len) {
|
|
@@ -3753,13 +4352,12 @@ static bool add_padding_extension(CBB *cbb, uint16_t ext, size_t len) {
|
|
|
3753
4352
|
}
|
|
3754
4353
|
|
|
3755
4354
|
static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
|
|
3756
|
-
CBB *out_encoded
|
|
3757
|
-
bool *out_needs_psk_binder) {
|
|
4355
|
+
CBB *out_encoded) {
|
|
3758
4356
|
// When writing ClientHelloInner, we construct the real and encoded
|
|
3759
4357
|
// ClientHellos concurrently, to handle compression. Uncompressed extensions
|
|
3760
|
-
// are written to
|
|
3761
|
-
// extensions are buffered in
|
|
3762
|
-
// only compress
|
|
4358
|
+
// are written to `extensions` and copied to `extensions_encoded`. Compressed
|
|
4359
|
+
// extensions are buffered in `compressed` and written to the end. (ECH can
|
|
4360
|
+
// only compress contiguous extensions.)
|
|
3763
4361
|
SSL *const ssl = hs->ssl;
|
|
3764
4362
|
bssl::ScopedCBB compressed, outer_extensions;
|
|
3765
4363
|
CBB extensions, extensions_encoded;
|
|
@@ -3775,7 +4373,7 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
|
|
|
3775
4373
|
|
|
3776
4374
|
if (ssl->ctx->grease_enabled) {
|
|
3777
4375
|
// Add a fake empty extension. See RFC 8701. This always matches
|
|
3778
|
-
//
|
|
4376
|
+
// `ssl_add_clienthello_tlsext`, so compress it.
|
|
3779
4377
|
uint16_t grease_ext = ssl_get_grease_value(hs, ssl_grease_extension1);
|
|
3780
4378
|
if (!add_padding_extension(compressed.get(), grease_ext, 0) ||
|
|
3781
4379
|
!CBB_add_u16(outer_extensions.get(), grease_ext)) {
|
|
@@ -3813,7 +4411,7 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
|
|
|
3813
4411
|
|
|
3814
4412
|
if (ssl->ctx->grease_enabled) {
|
|
3815
4413
|
// Add a fake non-empty extension. See RFC 8701. This always matches
|
|
3816
|
-
//
|
|
4414
|
+
// `ssl_add_clienthello_tlsext`, so compress it.
|
|
3817
4415
|
uint16_t grease_ext = ssl_get_grease_value(hs, ssl_grease_extension2);
|
|
3818
4416
|
if (!add_padding_extension(compressed.get(), grease_ext, 1) ||
|
|
3819
4417
|
!CBB_add_u16(outer_extensions.get(), grease_ext)) {
|
|
@@ -3844,15 +4442,16 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
|
|
|
3844
4442
|
}
|
|
3845
4443
|
}
|
|
3846
4444
|
|
|
3847
|
-
// The PSK extension must be last. It is never compressed.
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
4445
|
+
// The PSK extension must be last. It is never compressed.
|
|
4446
|
+
size_t psk_len;
|
|
4447
|
+
if (!ext_pre_shared_key_add_clienthello(hs, out, &extensions, &psk_len,
|
|
4448
|
+
ssl_client_hello_inner)) {
|
|
4449
|
+
return false;
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
// Copy the PSK extension to EncodedClientHelloInner.
|
|
4453
|
+
auto psk = CBBAsSpan(out).last(psk_len);
|
|
4454
|
+
if (!CBB_add_bytes(&extensions_encoded, psk.data(), psk.size()) ||
|
|
3856
4455
|
!CBB_flush(out_encoded)) {
|
|
3857
4456
|
return false;
|
|
3858
4457
|
}
|
|
@@ -3861,16 +4460,19 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
|
|
|
3861
4460
|
}
|
|
3862
4461
|
|
|
3863
4462
|
bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
4463
|
+
ssl_client_hello_type_t type) {
|
|
4464
|
+
// `out` must contain the start of a ClientHello, which means it must begin
|
|
4465
|
+
// with a TLS or DTLS version.
|
|
4466
|
+
assert(CBB_len(out) != 0 && (CBB_data(out)[0] == SSL3_VERSION_MAJOR ||
|
|
4467
|
+
CBB_data(out)[0] == DTLS1_VERSION_MAJOR));
|
|
3868
4468
|
|
|
3869
4469
|
if (type == ssl_client_hello_inner) {
|
|
3870
|
-
return ssl_add_clienthello_tlsext_inner(hs, out, out_encoded
|
|
3871
|
-
out_needs_psk_binder);
|
|
4470
|
+
return ssl_add_clienthello_tlsext_inner(hs, out, out_encoded);
|
|
3872
4471
|
}
|
|
3873
4472
|
|
|
4473
|
+
// Sample the length of the ClientHello thus far, including the message
|
|
4474
|
+
// header.
|
|
4475
|
+
size_t msg_len = SSL3_HM_HEADER_LENGTH + CBB_len(out);
|
|
3874
4476
|
assert(out_encoded == nullptr); // Only ClientHelloInner needs two outputs.
|
|
3875
4477
|
SSL *const ssl = hs->ssl;
|
|
3876
4478
|
CBB extensions;
|
|
@@ -3924,37 +4526,38 @@ bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
|
|
|
3924
4526
|
// In cleartext ClientHellos, we add the padding extension to work around
|
|
3925
4527
|
// bugs. We also apply this padding to ClientHelloOuter, to keep the wire
|
|
3926
4528
|
// images aligned.
|
|
3927
|
-
size_t
|
|
4529
|
+
size_t psk_len = ext_pre_shared_key_clienthello_length(hs, type);
|
|
3928
4530
|
if (!SSL_is_dtls(ssl) && !SSL_is_quic(ssl) &&
|
|
3929
4531
|
!ssl->s3->used_hello_retry_request) {
|
|
3930
|
-
|
|
3931
|
-
|
|
4532
|
+
msg_len += 2 /* length prefix */ + CBB_len(&extensions) + psk_len;
|
|
4533
|
+
// The length of the padding extension, excluding the four-byte extension
|
|
4534
|
+
// header.
|
|
3932
4535
|
size_t padding_len = 0;
|
|
3933
4536
|
|
|
3934
4537
|
// The final extension must be non-empty. WebSphere Application
|
|
3935
4538
|
// Server 7.0 is intolerant to the last extension being zero-length. See
|
|
3936
4539
|
// https://crbug.com/363583.
|
|
3937
|
-
if (last_was_empty &&
|
|
4540
|
+
if (last_was_empty && psk_len == 0) {
|
|
3938
4541
|
padding_len = 1;
|
|
3939
4542
|
// The addition of the padding extension may push us into the F5 bug.
|
|
3940
|
-
|
|
4543
|
+
msg_len += 4 + padding_len;
|
|
3941
4544
|
}
|
|
3942
4545
|
|
|
3943
4546
|
// Add padding to workaround bugs in F5 terminators. See RFC 7685.
|
|
3944
4547
|
//
|
|
3945
4548
|
// NB: because this code works out the length of all existing extensions
|
|
3946
4549
|
// it MUST always appear last (save for any PSK extension).
|
|
3947
|
-
if (
|
|
4550
|
+
if (msg_len > 0xff && msg_len < 0x200) {
|
|
3948
4551
|
// If our calculations already included a padding extension, remove that
|
|
3949
4552
|
// factor because we're about to change its length.
|
|
3950
4553
|
if (padding_len != 0) {
|
|
3951
|
-
|
|
4554
|
+
msg_len -= 4 + padding_len;
|
|
3952
4555
|
}
|
|
3953
|
-
padding_len = 0x200 -
|
|
3954
|
-
// Extensions take at least four bytes to encode.
|
|
3955
|
-
//
|
|
3956
|
-
//
|
|
3957
|
-
// https://crbug.com/363583.
|
|
4556
|
+
padding_len = 0x200 - msg_len;
|
|
4557
|
+
// Extensions take at least four bytes to encode. WebSphere Application
|
|
4558
|
+
// Server 7.0 is intolerant to the last extension being zero-length, so
|
|
4559
|
+
// always include at least one byte of data if including the extension.
|
|
4560
|
+
// See https://crbug.com/363583.
|
|
3958
4561
|
if (padding_len >= 4 + 1) {
|
|
3959
4562
|
padding_len -= 4;
|
|
3960
4563
|
} else {
|
|
@@ -3969,21 +4572,13 @@ bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
|
|
|
3969
4572
|
}
|
|
3970
4573
|
|
|
3971
4574
|
// The PSK extension must be last, including after the padding.
|
|
3972
|
-
|
|
3973
|
-
if (!ext_pre_shared_key_add_clienthello(hs, &extensions,
|
|
4575
|
+
size_t psk_len_actual;
|
|
4576
|
+
if (!ext_pre_shared_key_add_clienthello(hs, out, &extensions, &psk_len_actual,
|
|
3974
4577
|
type)) {
|
|
3975
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
|
3976
4578
|
return false;
|
|
3977
4579
|
}
|
|
3978
|
-
assert(
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
// Discard empty extensions blocks.
|
|
3982
|
-
if (CBB_len(&extensions) == 0) {
|
|
3983
|
-
CBB_discard_child(out);
|
|
3984
|
-
}
|
|
3985
|
-
|
|
3986
|
-
return CBB_flush(out);
|
|
4580
|
+
assert(psk_len_actual == psk_len);
|
|
4581
|
+
return true;
|
|
3987
4582
|
}
|
|
3988
4583
|
|
|
3989
4584
|
bool ssl_add_serverhello_tlsext(SSL_HANDSHAKE *hs, CBB *out) {
|
|
@@ -4039,7 +4634,7 @@ static bool ssl_scan_clienthello_tlsext(SSL_HANDSHAKE *hs,
|
|
|
4039
4634
|
unsigned ext_index;
|
|
4040
4635
|
const struct tls_extension *const ext =
|
|
4041
4636
|
tls_extension_find(&ext_index, type);
|
|
4042
|
-
if (ext ==
|
|
4637
|
+
if (ext == nullptr) {
|
|
4043
4638
|
continue;
|
|
4044
4639
|
}
|
|
4045
4640
|
|
|
@@ -4058,11 +4653,11 @@ static bool ssl_scan_clienthello_tlsext(SSL_HANDSHAKE *hs,
|
|
|
4058
4653
|
continue;
|
|
4059
4654
|
}
|
|
4060
4655
|
|
|
4061
|
-
CBS *contents =
|
|
4656
|
+
CBS *contents = nullptr, fake_contents;
|
|
4062
4657
|
static const uint8_t kFakeRenegotiateExtension[] = {0};
|
|
4063
4658
|
if (kExtensions[i].value == TLSEXT_TYPE_renegotiate &&
|
|
4064
|
-
ssl_client_cipher_list_contains_cipher(
|
|
4065
|
-
|
|
4659
|
+
ssl_client_cipher_list_contains_cipher(
|
|
4660
|
+
client_hello, SSL_CIPHER_EMPTY_RENEGOTIATION_INFO_SCSV)) {
|
|
4066
4661
|
// The renegotiation SCSV was received so pretend that we received a
|
|
4067
4662
|
// renegotiation extension.
|
|
4068
4663
|
CBS_init(&fake_contents, kFakeRenegotiateExtension,
|
|
@@ -4126,7 +4721,7 @@ static bool ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *cbs,
|
|
|
4126
4721
|
const struct tls_extension *const ext =
|
|
4127
4722
|
tls_extension_find(&ext_index, type);
|
|
4128
4723
|
|
|
4129
|
-
if (ext ==
|
|
4724
|
+
if (ext == nullptr) {
|
|
4130
4725
|
OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
|
|
4131
4726
|
ERR_add_error_dataf("extension %u", (unsigned)type);
|
|
4132
4727
|
*out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
|
|
@@ -4160,7 +4755,7 @@ static bool ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *cbs,
|
|
|
4160
4755
|
// Extension wasn't observed so call the callback with a NULL
|
|
4161
4756
|
// parameter.
|
|
4162
4757
|
uint8_t alert = SSL_AD_DECODE_ERROR;
|
|
4163
|
-
if (!kExtensions[i].parse_serverhello(hs, &alert,
|
|
4758
|
+
if (!kExtensions[i].parse_serverhello(hs, &alert, nullptr)) {
|
|
4164
4759
|
OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_EXTENSION);
|
|
4165
4760
|
ERR_add_error_dataf("extension %u", (unsigned)kExtensions[i].value);
|
|
4166
4761
|
*out_alert = alert;
|
|
@@ -4176,9 +4771,9 @@ static bool ssl_check_clienthello_tlsext(SSL_HANDSHAKE *hs) {
|
|
|
4176
4771
|
SSL *const ssl = hs->ssl;
|
|
4177
4772
|
int ret = SSL_TLSEXT_ERR_NOACK;
|
|
4178
4773
|
int al = SSL_AD_UNRECOGNIZED_NAME;
|
|
4179
|
-
if (ssl->ctx->servername_callback !=
|
|
4774
|
+
if (ssl->ctx->servername_callback != nullptr) {
|
|
4180
4775
|
ret = ssl->ctx->servername_callback(ssl, &al, ssl->ctx->servername_arg);
|
|
4181
|
-
} else if (ssl->session_ctx->servername_callback !=
|
|
4776
|
+
} else if (ssl->session_ctx->servername_callback != nullptr) {
|
|
4182
4777
|
ret = ssl->session_ctx->servername_callback(
|
|
4183
4778
|
ssl, &al, ssl->session_ctx->servername_arg);
|
|
4184
4779
|
}
|
|
@@ -4259,7 +4854,7 @@ static enum ssl_ticket_aead_result_t decrypt_ticket_with_cipher_ctx(
|
|
|
4259
4854
|
auto ticket_mac = ticket.last(mac_len);
|
|
4260
4855
|
ticket = ticket.first(ticket.size() - mac_len);
|
|
4261
4856
|
HMAC_Update(hmac_ctx, ticket.data(), ticket.size());
|
|
4262
|
-
HMAC_Final(hmac_ctx, mac,
|
|
4857
|
+
HMAC_Final(hmac_ctx, mac, nullptr);
|
|
4263
4858
|
assert(mac_len == ticket_mac.size());
|
|
4264
4859
|
bool mac_ok = CRYPTO_memcmp(mac, ticket_mac.data(), mac_len) == 0;
|
|
4265
4860
|
if (CRYPTO_fuzzer_mode_enabled()) {
|
|
@@ -4283,14 +4878,16 @@ static enum ssl_ticket_aead_result_t decrypt_ticket_with_cipher_ctx(
|
|
|
4283
4878
|
if (!plaintext.InitForOverwrite(ciphertext.size())) {
|
|
4284
4879
|
return ssl_ticket_aead_error;
|
|
4285
4880
|
}
|
|
4286
|
-
|
|
4287
|
-
if (!
|
|
4288
|
-
|
|
4289
|
-
|
|
4881
|
+
size_t len1, len2;
|
|
4882
|
+
if (!EVP_DecryptUpdate_ex(cipher_ctx, plaintext.data(), &len1,
|
|
4883
|
+
plaintext.size(), ciphertext.data(),
|
|
4884
|
+
(int)ciphertext.size()) ||
|
|
4885
|
+
!EVP_DecryptFinal_ex2(cipher_ctx, plaintext.data() + len1, &len2,
|
|
4886
|
+
plaintext.size() - len1)) {
|
|
4290
4887
|
ERR_clear_error();
|
|
4291
4888
|
return ssl_ticket_aead_ignore_ticket;
|
|
4292
4889
|
}
|
|
4293
|
-
plaintext.Shrink(
|
|
4890
|
+
plaintext.Shrink(len1 + len2);
|
|
4294
4891
|
}
|
|
4295
4892
|
|
|
4296
4893
|
*out = std::move(plaintext);
|
|
@@ -4303,11 +4900,11 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_cb(
|
|
|
4303
4900
|
assert(ticket.size() >= SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH);
|
|
4304
4901
|
ScopedEVP_CIPHER_CTX cipher_ctx;
|
|
4305
4902
|
ScopedHMAC_CTX hmac_ctx;
|
|
4306
|
-
auto name = ticket.
|
|
4903
|
+
auto name = ticket.first<SSL_TICKET_KEY_NAME_LEN>();
|
|
4307
4904
|
// The actual IV is shorter, but the length is determined by the callback's
|
|
4308
|
-
// chosen cipher. Instead we pass in
|
|
4905
|
+
// chosen cipher. Instead we pass in `EVP_MAX_IV_LENGTH` worth of IV to ensure
|
|
4309
4906
|
// the callback has enough.
|
|
4310
|
-
auto iv = ticket.subspan
|
|
4907
|
+
auto iv = ticket.subspan<SSL_TICKET_KEY_NAME_LEN, EVP_MAX_IV_LENGTH>();
|
|
4311
4908
|
int cb_ret = hs->ssl->session_ctx->ticket_key_cb(
|
|
4312
4909
|
hs->ssl, const_cast<uint8_t *>(name.data()),
|
|
4313
4910
|
const_cast<uint8_t *>(iv.data()), cipher_ctx.get(), hmac_ctx.get(),
|
|
@@ -4328,7 +4925,7 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_cb(
|
|
|
4328
4925
|
static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_ticket_keys(
|
|
4329
4926
|
SSL_HANDSHAKE *hs, Array<uint8_t> *out, Span<const uint8_t> ticket) {
|
|
4330
4927
|
assert(ticket.size() >= SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH);
|
|
4331
|
-
|
|
4928
|
+
SSLContext *ctx = hs->ssl->session_ctx.get();
|
|
4332
4929
|
|
|
4333
4930
|
// Rotate the ticket key if necessary.
|
|
4334
4931
|
if (!ssl_ctx_rotate_ticket_encryption_key(ctx)) {
|
|
@@ -4336,7 +4933,7 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_ticket_keys(
|
|
|
4336
4933
|
}
|
|
4337
4934
|
|
|
4338
4935
|
const EVP_CIPHER *cipher = EVP_aes_128_cbc();
|
|
4339
|
-
auto name = ticket.
|
|
4936
|
+
auto name = ticket.first<SSL_TICKET_KEY_NAME_LEN>();
|
|
4340
4937
|
auto iv =
|
|
4341
4938
|
ticket.subspan(SSL_TICKET_KEY_NAME_LEN, EVP_CIPHER_iv_length(cipher));
|
|
4342
4939
|
|
|
@@ -4354,8 +4951,8 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_ticket_keys(
|
|
|
4354
4951
|
return ssl_ticket_aead_ignore_ticket;
|
|
4355
4952
|
}
|
|
4356
4953
|
if (!HMAC_Init_ex(hmac_ctx.get(), key->hmac_key, sizeof(key->hmac_key),
|
|
4357
|
-
tlsext_tick_md(),
|
|
4358
|
-
!EVP_DecryptInit_ex(cipher_ctx.get(), cipher,
|
|
4954
|
+
tlsext_tick_md(), nullptr) ||
|
|
4955
|
+
!EVP_DecryptInit_ex(cipher_ctx.get(), cipher, nullptr, key->aes_key,
|
|
4359
4956
|
iv.data())) {
|
|
4360
4957
|
return ssl_ticket_aead_error;
|
|
4361
4958
|
}
|
|
@@ -4389,7 +4986,7 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_method(
|
|
|
4389
4986
|
enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
4390
4987
|
SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
|
|
4391
4988
|
bool *out_renew_ticket, Span<const uint8_t> ticket,
|
|
4392
|
-
Span<const uint8_t> session_id) {
|
|
4989
|
+
Span<const uint8_t> session_id, bool save_ticket) {
|
|
4393
4990
|
SSL *const ssl = hs->ssl;
|
|
4394
4991
|
*out_renew_ticket = false;
|
|
4395
4992
|
out_session->reset();
|
|
@@ -4400,7 +4997,7 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
|
4400
4997
|
}
|
|
4401
4998
|
|
|
4402
4999
|
// Tickets in TLS 1.3 are tied into pre-shared keys (PSKs), unlike in TLS 1.2
|
|
4403
|
-
// where that concept doesn't exist. The
|
|
5000
|
+
// where that concept doesn't exist. The `decrypted_psk` and `ignore_psk`
|
|
4404
5001
|
// hints only apply to PSKs. We check the version to determine which this is.
|
|
4405
5002
|
const bool is_psk = ssl_protocol_version(ssl) >= TLS1_3_VERSION;
|
|
4406
5003
|
|
|
@@ -4423,17 +5020,17 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
|
4423
5020
|
}
|
|
4424
5021
|
} else if (!is_psk && hints && !hs->hints_requested && hints->ignore_ticket) {
|
|
4425
5022
|
result = ssl_ticket_aead_ignore_ticket;
|
|
4426
|
-
} else if (ssl->session_ctx->ticket_aead_method !=
|
|
5023
|
+
} else if (ssl->session_ctx->ticket_aead_method != nullptr) {
|
|
4427
5024
|
result = ssl_decrypt_ticket_with_method(hs, &plaintext, out_renew_ticket,
|
|
4428
5025
|
ticket);
|
|
4429
5026
|
} else {
|
|
4430
|
-
// Ensure there is room for the key name and the largest IV
|
|
5027
|
+
// Ensure there is room for the key name and the largest IV `ticket_key_cb`
|
|
4431
5028
|
// may try to consume. The real limit may be lower, but the maximum IV
|
|
4432
5029
|
// length should be well under the minimum size for the session material and
|
|
4433
5030
|
// HMAC.
|
|
4434
5031
|
if (ticket.size() < SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH) {
|
|
4435
5032
|
result = ssl_ticket_aead_ignore_ticket;
|
|
4436
|
-
} else if (ssl->session_ctx->ticket_key_cb !=
|
|
5033
|
+
} else if (ssl->session_ctx->ticket_key_cb != nullptr) {
|
|
4437
5034
|
result =
|
|
4438
5035
|
ssl_decrypt_ticket_with_cb(hs, &plaintext, out_renew_ticket, ticket);
|
|
4439
5036
|
} else {
|
|
@@ -4474,6 +5071,10 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
|
4474
5071
|
return ssl_ticket_aead_ignore_ticket;
|
|
4475
5072
|
}
|
|
4476
5073
|
|
|
5074
|
+
if (save_ticket && !session->ticket.CopyFrom(ticket)) {
|
|
5075
|
+
return ssl_ticket_aead_error;
|
|
5076
|
+
}
|
|
5077
|
+
|
|
4477
5078
|
// Envoy's tests expect the session to have a session ID that matches the
|
|
4478
5079
|
// placeholder used by the client. It's unclear whether this is a good idea,
|
|
4479
5080
|
// but we maintain it for now.
|
|
@@ -4510,8 +5111,7 @@ bool tls1_get_legacy_signature_algorithm(uint16_t *out, const EVP_PKEY *pkey) {
|
|
|
4510
5111
|
}
|
|
4511
5112
|
|
|
4512
5113
|
bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
|
|
4513
|
-
const
|
|
4514
|
-
uint16_t *out) {
|
|
5114
|
+
const SSLCredential *cred, uint16_t *out) {
|
|
4515
5115
|
SSL *const ssl = hs->ssl;
|
|
4516
5116
|
if (!cred->UsesPrivateKey()) {
|
|
4517
5117
|
OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CERTIFICATE_TYPE);
|
|
@@ -4545,7 +5145,8 @@ bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
|
|
|
4545
5145
|
}
|
|
4546
5146
|
|
|
4547
5147
|
Span<const uint16_t> sigalgs =
|
|
4548
|
-
cred->sigalgs.empty() ? Span(kSignSignatureAlgorithms)
|
|
5148
|
+
cred->sigalgs.empty() ? Span<const uint16_t>(kSignSignatureAlgorithms)
|
|
5149
|
+
: Span<const uint16_t>(cred->sigalgs);
|
|
4549
5150
|
for (uint16_t sigalg : sigalgs) {
|
|
4550
5151
|
if (!ssl_pkey_supports_algorithm(ssl, cred->pubkey.get(), sigalg,
|
|
4551
5152
|
/*is_verify=*/false)) {
|
|
@@ -4587,10 +5188,10 @@ bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg) {
|
|
|
4587
5188
|
}
|
|
4588
5189
|
|
|
4589
5190
|
const uint8_t *p = CBS_data(&extension);
|
|
4590
|
-
if (BN_bin2bn(p + 0, 32, x.get()) ==
|
|
4591
|
-
BN_bin2bn(p + 32, 32, y.get()) ==
|
|
4592
|
-
BN_bin2bn(p + 64, 32, sig->r) ==
|
|
4593
|
-
BN_bin2bn(p + 96, 32, sig->s) ==
|
|
5191
|
+
if (BN_bin2bn(p + 0, 32, x.get()) == nullptr ||
|
|
5192
|
+
BN_bin2bn(p + 32, 32, y.get()) == nullptr ||
|
|
5193
|
+
BN_bin2bn(p + 64, 32, sig->r) == nullptr ||
|
|
5194
|
+
BN_bin2bn(p + 96, 32, sig->s) == nullptr) {
|
|
4594
5195
|
return false;
|
|
4595
5196
|
}
|
|
4596
5197
|
|
|
@@ -4685,7 +5286,7 @@ bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len) {
|
|
|
4685
5286
|
static const char kClientIDMagic[] = "TLS Channel ID signature";
|
|
4686
5287
|
SHA256_Update(&ctx, kClientIDMagic, sizeof(kClientIDMagic));
|
|
4687
5288
|
|
|
4688
|
-
if (ssl->session !=
|
|
5289
|
+
if (ssl->session != nullptr) {
|
|
4689
5290
|
static const char kResumptionMagic[] = "Resumption";
|
|
4690
5291
|
SHA256_Update(&ctx, kResumptionMagic, sizeof(kResumptionMagic));
|
|
4691
5292
|
if (ssl->session->original_handshake_hash.empty()) {
|
|
@@ -4712,7 +5313,7 @@ bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs) {
|
|
|
4712
5313
|
// This function should never be called for a resumed session because the
|
|
4713
5314
|
// handshake hashes that we wish to record are for the original, full
|
|
4714
5315
|
// handshake.
|
|
4715
|
-
if (ssl->session !=
|
|
5316
|
+
if (ssl->session != nullptr) {
|
|
4716
5317
|
return false;
|
|
4717
5318
|
}
|
|
4718
5319
|
|