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
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
#include <string_view>
|
|
32
32
|
#include <type_traits>
|
|
33
33
|
#include <utility>
|
|
34
|
+
#include <variant>
|
|
34
35
|
|
|
35
36
|
#include <openssl/aead.h>
|
|
36
37
|
#include <openssl/curve25519.h>
|
|
37
38
|
#include <openssl/err.h>
|
|
38
39
|
#include <openssl/hpke.h>
|
|
39
|
-
#include <openssl/lhash.h>
|
|
40
40
|
#include <openssl/mem.h>
|
|
41
41
|
#include <openssl/span.h>
|
|
42
42
|
#include <openssl/ssl.h>
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
#include "../crypto/err/internal.h"
|
|
46
46
|
#include "../crypto/internal.h"
|
|
47
47
|
#include "../crypto/lhash/internal.h"
|
|
48
|
+
#include "../crypto/mem_internal.h"
|
|
48
49
|
#include "../crypto/spake2plus/internal.h"
|
|
49
50
|
|
|
50
|
-
|
|
51
51
|
#if defined(OPENSSL_WINDOWS)
|
|
52
52
|
// Windows defines struct timeval in winsock2.h.
|
|
53
53
|
#include <winsock2.h>
|
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
#endif
|
|
57
57
|
|
|
58
58
|
|
|
59
|
+
DECLARE_OPAQUE_STRUCT(ssl_credential_st, SSLCredential)
|
|
60
|
+
DECLARE_OPAQUE_STRUCT(ssl_ctx_st, SSLContext)
|
|
61
|
+
DECLARE_OPAQUE_STRUCT(ssl_ech_keys_st, SSLECHKeys)
|
|
62
|
+
|
|
59
63
|
BSSL_NAMESPACE_BEGIN
|
|
60
64
|
|
|
61
65
|
struct SSL_CONFIG;
|
|
@@ -65,446 +69,7 @@ struct SSL_X509_METHOD;
|
|
|
65
69
|
|
|
66
70
|
// C++ utilities.
|
|
67
71
|
|
|
68
|
-
//
|
|
69
|
-
// returns nullptr on allocation error. It only implements single-object
|
|
70
|
-
// allocation and not new T[n].
|
|
71
|
-
//
|
|
72
|
-
// Note: unlike |new|, this does not support non-public constructors.
|
|
73
|
-
template <typename T, typename... Args>
|
|
74
|
-
T *New(Args &&...args) {
|
|
75
|
-
void *t = OPENSSL_malloc(sizeof(T));
|
|
76
|
-
if (t == nullptr) {
|
|
77
|
-
return nullptr;
|
|
78
|
-
}
|
|
79
|
-
return new (t) T(std::forward<Args>(args)...);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Delete behaves like |delete| but uses |OPENSSL_free| to release memory.
|
|
83
|
-
//
|
|
84
|
-
// Note: unlike |delete| this does not support non-public destructors.
|
|
85
|
-
template <typename T>
|
|
86
|
-
void Delete(T *t) {
|
|
87
|
-
if (t != nullptr) {
|
|
88
|
-
t->~T();
|
|
89
|
-
OPENSSL_free(t);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// All types with kAllowUniquePtr set may be used with UniquePtr. Other types
|
|
94
|
-
// may be C structs which require a |BORINGSSL_MAKE_DELETER| registration.
|
|
95
|
-
namespace internal {
|
|
96
|
-
template <typename T>
|
|
97
|
-
struct DeleterImpl<T, std::enable_if_t<T::kAllowUniquePtr>> {
|
|
98
|
-
static void Free(T *t) { Delete(t); }
|
|
99
|
-
};
|
|
100
|
-
} // namespace internal
|
|
101
|
-
|
|
102
|
-
// MakeUnique behaves like |std::make_unique| but returns nullptr on allocation
|
|
103
|
-
// error.
|
|
104
|
-
template <typename T, typename... Args>
|
|
105
|
-
UniquePtr<T> MakeUnique(Args &&...args) {
|
|
106
|
-
return UniquePtr<T>(New<T>(std::forward<Args>(args)...));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Array<T> is an owning array of elements of |T|.
|
|
110
|
-
template <typename T>
|
|
111
|
-
class Array {
|
|
112
|
-
public:
|
|
113
|
-
// Array's default constructor creates an empty array.
|
|
114
|
-
Array() {}
|
|
115
|
-
Array(const Array &) = delete;
|
|
116
|
-
Array(Array &&other) { *this = std::move(other); }
|
|
117
|
-
|
|
118
|
-
~Array() { Reset(); }
|
|
119
|
-
|
|
120
|
-
Array &operator=(const Array &) = delete;
|
|
121
|
-
Array &operator=(Array &&other) {
|
|
122
|
-
Reset();
|
|
123
|
-
other.Release(&data_, &size_);
|
|
124
|
-
return *this;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const T *data() const { return data_; }
|
|
128
|
-
T *data() { return data_; }
|
|
129
|
-
size_t size() const { return size_; }
|
|
130
|
-
bool empty() const { return size_ == 0; }
|
|
131
|
-
|
|
132
|
-
const T &operator[](size_t i) const {
|
|
133
|
-
BSSL_CHECK(i < size_);
|
|
134
|
-
return data_[i];
|
|
135
|
-
}
|
|
136
|
-
T &operator[](size_t i) {
|
|
137
|
-
BSSL_CHECK(i < size_);
|
|
138
|
-
return data_[i];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
T *begin() { return data_; }
|
|
142
|
-
const T *begin() const { return data_; }
|
|
143
|
-
T *end() { return data_ + size_; }
|
|
144
|
-
const T *end() const { return data_ + size_; }
|
|
145
|
-
|
|
146
|
-
void Reset() { Reset(nullptr, 0); }
|
|
147
|
-
|
|
148
|
-
// Reset releases the current contents of the array and takes ownership of the
|
|
149
|
-
// raw pointer supplied by the caller.
|
|
150
|
-
void Reset(T *new_data, size_t new_size) {
|
|
151
|
-
std::destroy_n(data_, size_);
|
|
152
|
-
OPENSSL_free(data_);
|
|
153
|
-
data_ = new_data;
|
|
154
|
-
size_ = new_size;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Release releases ownership of the array to a raw pointer supplied by the
|
|
158
|
-
// caller.
|
|
159
|
-
void Release(T **out, size_t *out_size) {
|
|
160
|
-
*out = data_;
|
|
161
|
-
*out_size = size_;
|
|
162
|
-
data_ = nullptr;
|
|
163
|
-
size_ = 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Init replaces the array with a newly-allocated array of |new_size|
|
|
167
|
-
// value-constructed copies of |T|. It returns true on success and false on
|
|
168
|
-
// error. If |T| is a primitive type like |uint8_t|, value-construction means
|
|
169
|
-
// it will be zero-initialized.
|
|
170
|
-
[[nodiscard]] bool Init(size_t new_size) {
|
|
171
|
-
if (!InitUninitialized(new_size)) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
std::uninitialized_value_construct_n(data_, size_);
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// InitForOverwrite behaves like |Init| but it default-constructs each element
|
|
179
|
-
// instead. This means that, if |T| is a primitive type, the array will be
|
|
180
|
-
// uninitialized and thus must be filled in by the caller.
|
|
181
|
-
[[nodiscard]] bool InitForOverwrite(size_t new_size) {
|
|
182
|
-
if (!InitUninitialized(new_size)) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
std::uninitialized_default_construct_n(data_, size_);
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// CopyFrom replaces the array with a newly-allocated copy of |in|. It returns
|
|
190
|
-
// true on success and false on error.
|
|
191
|
-
[[nodiscard]] bool CopyFrom(Span<const T> in) {
|
|
192
|
-
if (!InitUninitialized(in.size())) {
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
std::uninitialized_copy(in.begin(), in.end(), data_);
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Shrink shrinks the stored size of the array to |new_size|. It crashes if
|
|
200
|
-
// the new size is larger. Note this does not shrink the allocation itself.
|
|
201
|
-
void Shrink(size_t new_size) {
|
|
202
|
-
if (new_size > size_) {
|
|
203
|
-
abort();
|
|
204
|
-
}
|
|
205
|
-
std::destroy_n(data_ + new_size, size_ - new_size);
|
|
206
|
-
size_ = new_size;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
private:
|
|
210
|
-
// InitUninitialized replaces the array with a newly-allocated array of
|
|
211
|
-
// |new_size| elements, but whose constructor has not yet run. On success, the
|
|
212
|
-
// elements must be constructed before returning control to the caller.
|
|
213
|
-
bool InitUninitialized(size_t new_size) {
|
|
214
|
-
Reset();
|
|
215
|
-
if (new_size == 0) {
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (new_size > std::numeric_limits<size_t>::max() / sizeof(T)) {
|
|
220
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T)));
|
|
224
|
-
if (data_ == nullptr) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
size_ = new_size;
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
T *data_ = nullptr;
|
|
232
|
-
size_t size_ = 0;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// Vector<T> is a resizable array of elements of |T|.
|
|
236
|
-
template <typename T>
|
|
237
|
-
class Vector {
|
|
238
|
-
public:
|
|
239
|
-
Vector() = default;
|
|
240
|
-
Vector(const Vector &) = delete;
|
|
241
|
-
Vector(Vector &&other) { *this = std::move(other); }
|
|
242
|
-
~Vector() { clear(); }
|
|
243
|
-
|
|
244
|
-
Vector &operator=(const Vector &) = delete;
|
|
245
|
-
Vector &operator=(Vector &&other) {
|
|
246
|
-
clear();
|
|
247
|
-
std::swap(data_, other.data_);
|
|
248
|
-
std::swap(size_, other.size_);
|
|
249
|
-
std::swap(capacity_, other.capacity_);
|
|
250
|
-
return *this;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const T *data() const { return data_; }
|
|
254
|
-
T *data() { return data_; }
|
|
255
|
-
size_t size() const { return size_; }
|
|
256
|
-
bool empty() const { return size_ == 0; }
|
|
257
|
-
|
|
258
|
-
const T &operator[](size_t i) const {
|
|
259
|
-
BSSL_CHECK(i < size_);
|
|
260
|
-
return data_[i];
|
|
261
|
-
}
|
|
262
|
-
T &operator[](size_t i) {
|
|
263
|
-
BSSL_CHECK(i < size_);
|
|
264
|
-
return data_[i];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
T *begin() { return data_; }
|
|
268
|
-
const T *begin() const { return data_; }
|
|
269
|
-
T *end() { return data_ + size_; }
|
|
270
|
-
const T *end() const { return data_ + size_; }
|
|
271
|
-
|
|
272
|
-
void clear() {
|
|
273
|
-
std::destroy_n(data_, size_);
|
|
274
|
-
OPENSSL_free(data_);
|
|
275
|
-
data_ = nullptr;
|
|
276
|
-
size_ = 0;
|
|
277
|
-
capacity_ = 0;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Push adds |elem| at the end of the internal array, growing if necessary. It
|
|
281
|
-
// returns false when allocation fails.
|
|
282
|
-
[[nodiscard]] bool Push(T elem) {
|
|
283
|
-
if (!MaybeGrow()) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
new (&data_[size_]) T(std::move(elem));
|
|
287
|
-
size_++;
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// CopyFrom replaces the contents of the array with a copy of |in|. It returns
|
|
292
|
-
// true on success and false on allocation error.
|
|
293
|
-
[[nodiscard]] bool CopyFrom(Span<const T> in) {
|
|
294
|
-
Array<T> copy;
|
|
295
|
-
if (!copy.CopyFrom(in)) {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
clear();
|
|
300
|
-
copy.Release(&data_, &size_);
|
|
301
|
-
capacity_ = size_;
|
|
302
|
-
return true;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private:
|
|
306
|
-
// If there is no room for one more element, creates a new backing array with
|
|
307
|
-
// double the size of the old one and copies elements over.
|
|
308
|
-
bool MaybeGrow() {
|
|
309
|
-
// No need to grow if we have room for one more T.
|
|
310
|
-
if (size_ < capacity_) {
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
|
-
size_t new_capacity = kDefaultSize;
|
|
314
|
-
if (capacity_ > 0) {
|
|
315
|
-
// Double the array's size if it's safe to do so.
|
|
316
|
-
if (capacity_ > std::numeric_limits<size_t>::max() / 2) {
|
|
317
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
new_capacity = capacity_ * 2;
|
|
321
|
-
}
|
|
322
|
-
if (new_capacity > std::numeric_limits<size_t>::max() / sizeof(T)) {
|
|
323
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
T *new_data =
|
|
327
|
-
reinterpret_cast<T *>(OPENSSL_malloc(new_capacity * sizeof(T)));
|
|
328
|
-
if (new_data == nullptr) {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
size_t new_size = size_;
|
|
332
|
-
std::uninitialized_move(begin(), end(), new_data);
|
|
333
|
-
clear();
|
|
334
|
-
data_ = new_data;
|
|
335
|
-
size_ = new_size;
|
|
336
|
-
capacity_ = new_capacity;
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// data_ is a pointer to |capacity_| objects of size |T|, the first |size_| of
|
|
341
|
-
// which are constructed.
|
|
342
|
-
T *data_ = nullptr;
|
|
343
|
-
// |size_| is the number of elements stored in this Vector.
|
|
344
|
-
size_t size_ = 0;
|
|
345
|
-
// |capacity_| is the number of elements allocated in this Vector.
|
|
346
|
-
size_t capacity_ = 0;
|
|
347
|
-
// |kDefaultSize| is the default initial size of the backing array.
|
|
348
|
-
static constexpr size_t kDefaultSize = 16;
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
// A PackedSize is an integer that can store values from 0 to N, represented as
|
|
352
|
-
// a minimal-width integer.
|
|
353
|
-
template <size_t N>
|
|
354
|
-
using PackedSize = std::conditional_t<
|
|
355
|
-
N <= 0xff, uint8_t,
|
|
356
|
-
std::conditional_t<N <= 0xffff, uint16_t,
|
|
357
|
-
std::conditional_t<N <= 0xffffffff, uint32_t, size_t>>>;
|
|
358
|
-
|
|
359
|
-
// An InplaceVector is like a Vector, but stores up to N elements inline in the
|
|
360
|
-
// object. It is inspired by std::inplace_vector in C++26.
|
|
361
|
-
template <typename T, size_t N>
|
|
362
|
-
class InplaceVector {
|
|
363
|
-
public:
|
|
364
|
-
InplaceVector() = default;
|
|
365
|
-
InplaceVector(const InplaceVector &other) { *this = other; }
|
|
366
|
-
InplaceVector(InplaceVector &&other) { *this = std::move(other); }
|
|
367
|
-
~InplaceVector() { clear(); }
|
|
368
|
-
InplaceVector &operator=(const InplaceVector &other) {
|
|
369
|
-
if (this != &other) {
|
|
370
|
-
CopyFrom(other);
|
|
371
|
-
}
|
|
372
|
-
return *this;
|
|
373
|
-
}
|
|
374
|
-
InplaceVector &operator=(InplaceVector &&other) {
|
|
375
|
-
clear();
|
|
376
|
-
std::uninitialized_move(other.begin(), other.end(), data());
|
|
377
|
-
size_ = other.size();
|
|
378
|
-
return *this;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const T *data() const { return reinterpret_cast<const T *>(storage_); }
|
|
382
|
-
T *data() { return reinterpret_cast<T *>(storage_); }
|
|
383
|
-
size_t size() const { return size_; }
|
|
384
|
-
static constexpr size_t capacity() { return N; }
|
|
385
|
-
bool empty() const { return size_ == 0; }
|
|
386
|
-
|
|
387
|
-
const T &operator[](size_t i) const {
|
|
388
|
-
BSSL_CHECK(i < size_);
|
|
389
|
-
return data()[i];
|
|
390
|
-
}
|
|
391
|
-
T &operator[](size_t i) {
|
|
392
|
-
BSSL_CHECK(i < size_);
|
|
393
|
-
return data()[i];
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
T *begin() { return data(); }
|
|
397
|
-
const T *begin() const { return data(); }
|
|
398
|
-
T *end() { return data() + size_; }
|
|
399
|
-
const T *end() const { return data() + size_; }
|
|
400
|
-
|
|
401
|
-
void clear() { Shrink(0); }
|
|
402
|
-
|
|
403
|
-
// Shrink resizes the vector to |new_size|, which must not be larger than the
|
|
404
|
-
// current size. Unlike |Resize|, this can be called when |T| is not
|
|
405
|
-
// default-constructible.
|
|
406
|
-
void Shrink(size_t new_size) {
|
|
407
|
-
BSSL_CHECK(new_size <= size_);
|
|
408
|
-
std::destroy_n(data() + new_size, size_ - new_size);
|
|
409
|
-
size_ = static_cast<PackedSize<N>>(new_size);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// TryResize resizes the vector to |new_size| and returns true, or returns
|
|
413
|
-
// false if |new_size| is too large. Any newly-added elements are
|
|
414
|
-
// value-initialized.
|
|
415
|
-
[[nodiscard]] bool TryResize(size_t new_size) {
|
|
416
|
-
if (new_size <= size_) {
|
|
417
|
-
Shrink(new_size);
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
if (new_size > capacity()) {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
std::uninitialized_value_construct_n(data() + size_, new_size - size_);
|
|
424
|
-
size_ = static_cast<PackedSize<N>>(new_size);
|
|
425
|
-
return true;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// TryResizeForOverwrite behaves like |TryResize|, but newly-added elements
|
|
429
|
-
// are default-initialized, so POD types may contain uninitialized values that
|
|
430
|
-
// the caller is responsible for filling in.
|
|
431
|
-
[[nodiscard]] bool TryResizeForOverwrite(size_t new_size) {
|
|
432
|
-
if (new_size <= size_) {
|
|
433
|
-
Shrink(new_size);
|
|
434
|
-
return true;
|
|
435
|
-
}
|
|
436
|
-
if (new_size > capacity()) {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
std::uninitialized_default_construct_n(data() + size_, new_size - size_);
|
|
440
|
-
size_ = static_cast<PackedSize<N>>(new_size);
|
|
441
|
-
return true;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// TryCopyFrom sets the vector to a copy of |in| and returns true, or returns
|
|
445
|
-
// false if |in| is too large.
|
|
446
|
-
[[nodiscard]] bool TryCopyFrom(Span<const T> in) {
|
|
447
|
-
if (in.size() > capacity()) {
|
|
448
|
-
return false;
|
|
449
|
-
}
|
|
450
|
-
clear();
|
|
451
|
-
std::uninitialized_copy(in.begin(), in.end(), data());
|
|
452
|
-
size_ = in.size();
|
|
453
|
-
return true;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// TryPushBack appends |val| to the vector and returns a pointer to the
|
|
457
|
-
// newly-inserted value, or nullptr if the vector is at capacity.
|
|
458
|
-
[[nodiscard]] T *TryPushBack(T val) {
|
|
459
|
-
if (size() >= capacity()) {
|
|
460
|
-
return nullptr;
|
|
461
|
-
}
|
|
462
|
-
T *ret = &data()[size_];
|
|
463
|
-
new (ret) T(std::move(val));
|
|
464
|
-
size_++;
|
|
465
|
-
return ret;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// The following methods behave like their |Try*| counterparts, but abort the
|
|
469
|
-
// program on failure.
|
|
470
|
-
void Resize(size_t size) { BSSL_CHECK(TryResize(size)); }
|
|
471
|
-
void ResizeForOverwrite(size_t size) {
|
|
472
|
-
BSSL_CHECK(TryResizeForOverwrite(size));
|
|
473
|
-
}
|
|
474
|
-
void CopyFrom(Span<const T> in) { BSSL_CHECK(TryCopyFrom(in)); }
|
|
475
|
-
T &PushBack(T val) {
|
|
476
|
-
T *ret = TryPushBack(std::move(val));
|
|
477
|
-
BSSL_CHECK(ret != nullptr);
|
|
478
|
-
return *ret;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
template <typename Pred>
|
|
482
|
-
void EraseIf(Pred pred) {
|
|
483
|
-
// See if anything needs to be erased at all. This avoids a self-move.
|
|
484
|
-
auto iter = std::find_if(begin(), end(), pred);
|
|
485
|
-
if (iter == end()) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Elements before the first to be erased may be left as-is.
|
|
490
|
-
size_t new_size = iter - begin();
|
|
491
|
-
// Swap all subsequent elements in if they are to be kept.
|
|
492
|
-
for (size_t i = new_size + 1; i < size(); i++) {
|
|
493
|
-
if (!pred((*this)[i])) {
|
|
494
|
-
(*this)[new_size] = std::move((*this)[i]);
|
|
495
|
-
new_size++;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
Shrink(new_size);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
private:
|
|
503
|
-
alignas(T) char storage_[sizeof(T[N])];
|
|
504
|
-
PackedSize<N> size_ = 0;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
// An MRUQueue maintains a queue of up to |N| objects of type |T|. If the queue
|
|
72
|
+
// An MRUQueue maintains a queue of up to `N` objects of type `T`. If the queue
|
|
508
73
|
// is at capacity, adding to the queue pops the least recently added element.
|
|
509
74
|
template <typename T, size_t N>
|
|
510
75
|
class MRUQueue {
|
|
@@ -514,7 +79,7 @@ class MRUQueue {
|
|
|
514
79
|
MRUQueue() = default;
|
|
515
80
|
|
|
516
81
|
// If we ever need to make this type movable, we could. (The defaults almost
|
|
517
|
-
// work except we need
|
|
82
|
+
// work except we need `start_` to be reset when moved-from.)
|
|
518
83
|
MRUQueue(const MRUQueue &other) = delete;
|
|
519
84
|
MRUQueue &operator=(const MRUQueue &other) = delete;
|
|
520
85
|
|
|
@@ -549,72 +114,27 @@ class MRUQueue {
|
|
|
549
114
|
PackedSize<N> start_ = 0;
|
|
550
115
|
};
|
|
551
116
|
|
|
552
|
-
//
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
// GetAllNames helps to implement |*_get_all_*_names| style functions. It
|
|
556
|
-
// writes at most |max_out| string pointers to |out| and returns the number that
|
|
117
|
+
// GetAllNames helps to implement `*_get_all_*_names` style functions. It
|
|
118
|
+
// writes at most `max_out` string pointers to `out` and returns the number that
|
|
557
119
|
// it would have liked to have written. The strings written consist of
|
|
558
|
-
//
|
|
559
|
-
// strings taken by projecting
|
|
560
|
-
template <typename T, typename Name>
|
|
120
|
+
// `fixed_names_len` strings from `fixed_names` followed by `objects_len`
|
|
121
|
+
// strings taken by projecting `objects` through `name`.
|
|
122
|
+
template <typename T, typename Name, size_t S1, size_t S2>
|
|
561
123
|
inline size_t GetAllNames(const char **out, size_t max_out,
|
|
562
|
-
Span<const char *const> fixed_names,
|
|
563
|
-
Span<const T> objects) {
|
|
564
|
-
auto span =
|
|
124
|
+
Span<const char *const, S1> fixed_names,
|
|
125
|
+
Name(T::*name), Span<const T, S2> objects) {
|
|
126
|
+
auto span = Span(out, max_out);
|
|
565
127
|
for (size_t i = 0; !span.empty() && i < fixed_names.size(); i++) {
|
|
566
128
|
span[0] = fixed_names[i];
|
|
567
129
|
span = span.subspan(1);
|
|
568
130
|
}
|
|
569
|
-
span = span.
|
|
131
|
+
span = span.first(std::min(span.size(), objects.size()));
|
|
570
132
|
for (size_t i = 0; i < span.size(); i++) {
|
|
571
133
|
span[i] = objects[i].*name;
|
|
572
134
|
}
|
|
573
135
|
return fixed_names.size() + objects.size();
|
|
574
136
|
}
|
|
575
137
|
|
|
576
|
-
// RefCounted is a common base for ref-counted types. This is an instance of the
|
|
577
|
-
// C++ curiously-recurring template pattern, so a type Foo must subclass
|
|
578
|
-
// RefCounted<Foo>. It additionally must friend RefCounted<Foo> to allow calling
|
|
579
|
-
// the destructor.
|
|
580
|
-
template <typename Derived>
|
|
581
|
-
class RefCounted {
|
|
582
|
-
public:
|
|
583
|
-
RefCounted(const RefCounted &) = delete;
|
|
584
|
-
RefCounted &operator=(const RefCounted &) = delete;
|
|
585
|
-
|
|
586
|
-
// These methods are intentionally named differently from `bssl::UpRef` to
|
|
587
|
-
// avoid a collision. Only the implementations of `FOO_up_ref` and `FOO_free`
|
|
588
|
-
// should call these.
|
|
589
|
-
void UpRefInternal() { CRYPTO_refcount_inc(&references_); }
|
|
590
|
-
void DecRefInternal() {
|
|
591
|
-
if (CRYPTO_refcount_dec_and_test_zero(&references_)) {
|
|
592
|
-
Derived *d = static_cast<Derived *>(this);
|
|
593
|
-
d->~Derived();
|
|
594
|
-
OPENSSL_free(d);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
protected:
|
|
599
|
-
// Ensure that only `Derived`, which must inherit from `RefCounted<Derived>`,
|
|
600
|
-
// can call the constructor. This catches bugs where someone inherited from
|
|
601
|
-
// the wrong base.
|
|
602
|
-
class CheckSubClass {
|
|
603
|
-
private:
|
|
604
|
-
friend Derived;
|
|
605
|
-
CheckSubClass() = default;
|
|
606
|
-
};
|
|
607
|
-
RefCounted(CheckSubClass) {
|
|
608
|
-
static_assert(std::is_base_of<RefCounted, Derived>::value,
|
|
609
|
-
"Derived must subclass RefCounted<Derived>");
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
~RefCounted() = default;
|
|
613
|
-
|
|
614
|
-
private:
|
|
615
|
-
CRYPTO_refcount_t references_ = 1;
|
|
616
|
-
};
|
|
617
|
-
|
|
618
138
|
|
|
619
139
|
// Protocol versions.
|
|
620
140
|
//
|
|
@@ -630,45 +150,45 @@ class RefCounted {
|
|
|
630
150
|
// used. DTLS versions map to the corresponding TLS versions. Protocol versions
|
|
631
151
|
// are sequential and may be compared numerically.
|
|
632
152
|
|
|
633
|
-
// ssl_protocol_version_from_wire sets
|
|
634
|
-
// corresponding to wire version
|
|
153
|
+
// ssl_protocol_version_from_wire sets `*out` to the protocol version
|
|
154
|
+
// corresponding to wire version `version` and returns true. If `version` is not
|
|
635
155
|
// a valid TLS or DTLS version, it returns false.
|
|
636
156
|
//
|
|
637
157
|
// Note this simultaneously handles both DTLS and TLS. Use one of the
|
|
638
158
|
// higher-level functions below for most operations.
|
|
639
159
|
bool ssl_protocol_version_from_wire(uint16_t *out, uint16_t version);
|
|
640
160
|
|
|
641
|
-
// ssl_get_version_range sets
|
|
161
|
+
// ssl_get_version_range sets `*out_min_version` and `*out_max_version` to the
|
|
642
162
|
// minimum and maximum enabled protocol versions, respectively.
|
|
643
163
|
bool ssl_get_version_range(const SSL_HANDSHAKE *hs, uint16_t *out_min_version,
|
|
644
164
|
uint16_t *out_max_version);
|
|
645
165
|
|
|
646
|
-
// ssl_supports_version returns whether
|
|
166
|
+
// ssl_supports_version returns whether `hs` supports `version`.
|
|
647
167
|
bool ssl_supports_version(const SSL_HANDSHAKE *hs, uint16_t version);
|
|
648
168
|
|
|
649
|
-
// ssl_method_supports_version returns whether
|
|
169
|
+
// ssl_method_supports_version returns whether `method` supports `version`.
|
|
650
170
|
bool ssl_method_supports_version(const SSL_PROTOCOL_METHOD *method,
|
|
651
171
|
uint16_t version);
|
|
652
172
|
|
|
653
|
-
// ssl_add_supported_versions writes the supported versions of
|
|
173
|
+
// ssl_add_supported_versions writes the supported versions of `hs` to `cbb`, in
|
|
654
174
|
// decreasing preference order. The version list is filtered to those whose
|
|
655
|
-
// protocol version is at least
|
|
175
|
+
// protocol version is at least `extra_min_version`.
|
|
656
176
|
bool ssl_add_supported_versions(const SSL_HANDSHAKE *hs, CBB *cbb,
|
|
657
177
|
uint16_t extra_min_version);
|
|
658
178
|
|
|
659
|
-
// ssl_negotiate_version negotiates a common version based on
|
|
660
|
-
// and the peer preference list in
|
|
661
|
-
// and sets
|
|
662
|
-
// and sets
|
|
179
|
+
// ssl_negotiate_version negotiates a common version based on `hs`'s preferences
|
|
180
|
+
// and the peer preference list in `peer_versions`. On success, it returns true
|
|
181
|
+
// and sets `*out_version` to the selected version. Otherwise, it returns false
|
|
182
|
+
// and sets `*out_alert` to an alert to send.
|
|
663
183
|
bool ssl_negotiate_version(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
664
184
|
uint16_t *out_version, const CBS *peer_versions);
|
|
665
185
|
|
|
666
|
-
// ssl_has_final_version returns whether
|
|
186
|
+
// ssl_has_final_version returns whether `ssl` has determined the final version.
|
|
667
187
|
// This may be used to distinguish the predictive 0-RTT version from the final
|
|
668
188
|
// one.
|
|
669
189
|
bool ssl_has_final_version(const SSL *ssl);
|
|
670
190
|
|
|
671
|
-
// ssl_protocol_version returns
|
|
191
|
+
// ssl_protocol_version returns `ssl`'s protocol version. It is an error to
|
|
672
192
|
// call this function before the version is determined.
|
|
673
193
|
uint16_t ssl_protocol_version(const SSL *ssl);
|
|
674
194
|
|
|
@@ -681,8 +201,8 @@ struct ssl_cipher_st {
|
|
|
681
201
|
const char *name;
|
|
682
202
|
// standard_name is the IETF name for the cipher.
|
|
683
203
|
const char *standard_name;
|
|
684
|
-
//
|
|
685
|
-
|
|
204
|
+
// protocol_id is the cipher's two-byte protocol ID.
|
|
205
|
+
uint16_t protocol_id;
|
|
686
206
|
|
|
687
207
|
// algorithm_* determine the cipher suite. See constants below for the values.
|
|
688
208
|
uint32_t algorithm_mkey;
|
|
@@ -694,14 +214,14 @@ struct ssl_cipher_st {
|
|
|
694
214
|
|
|
695
215
|
BSSL_NAMESPACE_BEGIN
|
|
696
216
|
|
|
697
|
-
// Bits for
|
|
217
|
+
// Bits for `algorithm_mkey` (key exchange algorithm).
|
|
698
218
|
#define SSL_kRSA 0x00000001u
|
|
699
219
|
#define SSL_kECDHE 0x00000002u
|
|
700
220
|
// SSL_kPSK is only set for plain PSK, not ECDHE_PSK.
|
|
701
221
|
#define SSL_kPSK 0x00000004u
|
|
702
222
|
#define SSL_kGENERIC 0x00000008u
|
|
703
223
|
|
|
704
|
-
// Bits for
|
|
224
|
+
// Bits for `algorithm_auth` (server authentication).
|
|
705
225
|
#define SSL_aRSA_SIGN 0x00000001u
|
|
706
226
|
#define SSL_aRSA_DECRYPT 0x00000002u
|
|
707
227
|
#define SSL_aECDSA 0x00000004u
|
|
@@ -711,7 +231,7 @@ BSSL_NAMESPACE_BEGIN
|
|
|
711
231
|
|
|
712
232
|
#define SSL_aCERT (SSL_aRSA_SIGN | SSL_aRSA_DECRYPT | SSL_aECDSA)
|
|
713
233
|
|
|
714
|
-
// Bits for
|
|
234
|
+
// Bits for `algorithm_enc` (symmetric encryption).
|
|
715
235
|
#define SSL_3DES 0x00000001u
|
|
716
236
|
#define SSL_AES128 0x00000002u
|
|
717
237
|
#define SSL_AES256 0x00000004u
|
|
@@ -721,13 +241,13 @@ BSSL_NAMESPACE_BEGIN
|
|
|
721
241
|
|
|
722
242
|
#define SSL_AES (SSL_AES128 | SSL_AES256 | SSL_AES128GCM | SSL_AES256GCM)
|
|
723
243
|
|
|
724
|
-
// Bits for
|
|
244
|
+
// Bits for `algorithm_mac` (symmetric authentication).
|
|
725
245
|
#define SSL_SHA1 0x00000001u
|
|
726
246
|
#define SSL_SHA256 0x00000002u
|
|
727
247
|
// SSL_AEAD is set for all AEADs.
|
|
728
248
|
#define SSL_AEAD 0x00000004u
|
|
729
249
|
|
|
730
|
-
// Bits for
|
|
250
|
+
// Bits for `algorithm_prf` (handshake digest).
|
|
731
251
|
#define SSL_HANDSHAKE_MAC_DEFAULT 0x1
|
|
732
252
|
#define SSL_HANDSHAKE_MAC_SHA256 0x2
|
|
733
253
|
#define SSL_HANDSHAKE_MAC_SHA384 0x4
|
|
@@ -746,13 +266,13 @@ BSSL_NAMESPACE_BEGIN
|
|
|
746
266
|
// All elements of a group have the same priority: no ordering is expressed
|
|
747
267
|
// within a group.
|
|
748
268
|
//
|
|
749
|
-
// The values in
|
|
750
|
-
//
|
|
751
|
-
// bytes in
|
|
269
|
+
// The values in `ciphers` are in one-to-one correspondence with
|
|
270
|
+
// `in_group_flags`. (That is, sk_SSL_CIPHER_num(ciphers) is the number of
|
|
271
|
+
// bytes in `in_group_flags`.) The bytes in `in_group_flags` are either 1, to
|
|
752
272
|
// indicate that the corresponding SSL_CIPHER is not the last element of a
|
|
753
273
|
// group, or 0 to indicate that it is.
|
|
754
274
|
//
|
|
755
|
-
// For example, if
|
|
275
|
+
// For example, if `in_group_flags` contains all zeros then that indicates a
|
|
756
276
|
// traditional, fully-ordered preference. Every SSL_CIPHER is the last element
|
|
757
277
|
// of the group (i.e. they are all in a one-element group).
|
|
758
278
|
//
|
|
@@ -784,9 +304,9 @@ struct SSLCipherPreferenceList {
|
|
|
784
304
|
// AllCiphers returns an array of all supported ciphers, sorted by id.
|
|
785
305
|
Span<const SSL_CIPHER> AllCiphers();
|
|
786
306
|
|
|
787
|
-
// ssl_cipher_get_evp_aead sets
|
|
788
|
-
// object for
|
|
789
|
-
// and
|
|
307
|
+
// ssl_cipher_get_evp_aead sets `*out_aead` to point to the correct EVP_AEAD
|
|
308
|
+
// object for `cipher` protocol version `version`. It sets `*out_mac_secret_len`
|
|
309
|
+
// and `*out_fixed_iv_len` to the MAC key length and fixed IV length,
|
|
790
310
|
// respectively. The MAC key length is zero except for legacy block and stream
|
|
791
311
|
// ciphers. It returns true on success and false on error.
|
|
792
312
|
bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
|
|
@@ -794,34 +314,34 @@ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
|
|
|
794
314
|
size_t *out_fixed_iv_len, const SSL_CIPHER *cipher,
|
|
795
315
|
uint16_t version);
|
|
796
316
|
|
|
797
|
-
// ssl_get_handshake_digest returns the
|
|
798
|
-
//
|
|
317
|
+
// ssl_get_handshake_digest returns the `EVP_MD` corresponding to `version` and
|
|
318
|
+
// `cipher`.
|
|
799
319
|
const EVP_MD *ssl_get_handshake_digest(uint16_t version,
|
|
800
320
|
const SSL_CIPHER *cipher);
|
|
801
321
|
|
|
802
|
-
// ssl_create_cipher_list evaluates
|
|
803
|
-
// newly-allocated
|
|
804
|
-
// true on success and false on failure. If
|
|
322
|
+
// ssl_create_cipher_list evaluates `rule_str`. It sets `*out_cipher_list` to a
|
|
323
|
+
// newly-allocated `SSLCipherPreferenceList` containing the result. It returns
|
|
324
|
+
// true on success and false on failure. If `strict` is true, nonsense will be
|
|
805
325
|
// rejected. If false, nonsense will be silently ignored. An empty result is
|
|
806
|
-
// considered an error regardless of
|
|
326
|
+
// considered an error regardless of `strict`. `has_aes_hw` indicates if the
|
|
807
327
|
// list should be ordered based on having support for AES in hardware or not.
|
|
808
328
|
bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
|
|
809
329
|
const bool has_aes_hw, const char *rule_str,
|
|
810
330
|
bool strict);
|
|
811
331
|
|
|
812
|
-
// ssl_cipher_auth_mask_for_key returns the mask of cipher
|
|
813
|
-
// values suitable for use with
|
|
814
|
-
// whether
|
|
332
|
+
// ssl_cipher_auth_mask_for_key returns the mask of cipher `algorithm_auth`
|
|
333
|
+
// values suitable for use with `key` in TLS 1.2 and below. `sign_ok` indicates
|
|
334
|
+
// whether `key` may be used for signing.
|
|
815
335
|
uint32_t ssl_cipher_auth_mask_for_key(const EVP_PKEY *key, bool sign_ok);
|
|
816
336
|
|
|
817
|
-
// ssl_cipher_uses_certificate_auth returns whether
|
|
337
|
+
// ssl_cipher_uses_certificate_auth returns whether `cipher` authenticates the
|
|
818
338
|
// server and, optionally, the client with a certificate.
|
|
819
339
|
bool ssl_cipher_uses_certificate_auth(const SSL_CIPHER *cipher);
|
|
820
340
|
|
|
821
|
-
// ssl_cipher_requires_server_key_exchange returns whether
|
|
341
|
+
// ssl_cipher_requires_server_key_exchange returns whether `cipher` requires a
|
|
822
342
|
// ServerKeyExchange message.
|
|
823
343
|
//
|
|
824
|
-
// This function may return false while still allowing
|
|
344
|
+
// This function may return false while still allowing `cipher` an optional
|
|
825
345
|
// ServerKeyExchange. This is the case for plain PSK ciphers.
|
|
826
346
|
bool ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
|
|
827
347
|
|
|
@@ -830,20 +350,20 @@ bool ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
|
|
|
830
350
|
// it returns zero.
|
|
831
351
|
size_t ssl_cipher_get_record_split_len(const SSL_CIPHER *cipher);
|
|
832
352
|
|
|
833
|
-
// ssl_choose_tls13_cipher returns an
|
|
834
|
-
// available from
|
|
835
|
-
// returns NULL if there isn't a compatible cipher.
|
|
353
|
+
// ssl_choose_tls13_cipher returns an `SSL_CIPHER` corresponding with the best
|
|
354
|
+
// available from `cipher_suites` compatible with `version` and `policy`. It
|
|
355
|
+
// returns NULL if there isn't a compatible cipher. `has_aes_hw` indicates if
|
|
836
356
|
// the choice should be made as if support for AES in hardware is available.
|
|
837
357
|
const SSL_CIPHER *ssl_choose_tls13_cipher(CBS cipher_suites, bool has_aes_hw,
|
|
838
358
|
uint16_t version,
|
|
839
359
|
enum ssl_compliance_policy_t policy);
|
|
840
360
|
|
|
841
|
-
// ssl_tls13_cipher_meets_policy returns true if
|
|
842
|
-
//
|
|
361
|
+
// ssl_tls13_cipher_meets_policy returns true if `cipher_id` is acceptable given
|
|
362
|
+
// `policy`.
|
|
843
363
|
bool ssl_tls13_cipher_meets_policy(uint16_t cipher_id,
|
|
844
364
|
enum ssl_compliance_policy_t policy);
|
|
845
365
|
|
|
846
|
-
// ssl_cipher_is_deprecated returns true if
|
|
366
|
+
// ssl_cipher_is_deprecated returns true if `cipher` is deprecated.
|
|
847
367
|
OPENSSL_EXPORT bool ssl_cipher_is_deprecated(const SSL_CIPHER *cipher);
|
|
848
368
|
|
|
849
369
|
|
|
@@ -865,7 +385,7 @@ class SSLTranscript {
|
|
|
865
385
|
bool Init();
|
|
866
386
|
|
|
867
387
|
// InitHash initializes the handshake hash based on the PRF and contents of
|
|
868
|
-
// the handshake transcript. Subsequent calls to
|
|
388
|
+
// the handshake transcript. Subsequent calls to `Update` will update the
|
|
869
389
|
// rolling hash. It returns one on success and zero on failure. It is an error
|
|
870
390
|
// to call this function after the handshake buffer is released. This may be
|
|
871
391
|
// called multiple times to change the hash function.
|
|
@@ -877,10 +397,10 @@ class SSLTranscript {
|
|
|
877
397
|
// is released.
|
|
878
398
|
bool UpdateForHelloRetryRequest();
|
|
879
399
|
|
|
880
|
-
// CopyToHashContext initializes
|
|
400
|
+
// CopyToHashContext initializes `ctx` with `digest` and the data thus far in
|
|
881
401
|
// the transcript. It returns true on success and false on failure. If the
|
|
882
|
-
// handshake buffer is still present,
|
|
883
|
-
// Otherwise,
|
|
402
|
+
// handshake buffer is still present, `digest` may be any supported digest.
|
|
403
|
+
// Otherwise, `digest` must match the transcript hash.
|
|
884
404
|
bool CopyToHashContext(EVP_MD_CTX *ctx, const EVP_MD *digest) const;
|
|
885
405
|
|
|
886
406
|
Span<const uint8_t> buffer() const {
|
|
@@ -889,45 +409,45 @@ class SSLTranscript {
|
|
|
889
409
|
}
|
|
890
410
|
|
|
891
411
|
// FreeBuffer releases the handshake buffer. Subsequent calls to
|
|
892
|
-
//
|
|
412
|
+
// `Update` will not update the handshake buffer.
|
|
893
413
|
void FreeBuffer();
|
|
894
414
|
|
|
895
415
|
// DigestLen returns the length of the PRF hash.
|
|
896
416
|
size_t DigestLen() const;
|
|
897
417
|
|
|
898
418
|
// Digest returns the PRF hash. For TLS 1.1 and below, this is
|
|
899
|
-
//
|
|
419
|
+
// `EVP_md5_sha1`.
|
|
900
420
|
const EVP_MD *Digest() const;
|
|
901
421
|
|
|
902
|
-
// Update adds
|
|
422
|
+
// Update adds `in` to the handshake buffer and handshake hash, whichever is
|
|
903
423
|
// enabled. It returns true on success and false on failure.
|
|
904
424
|
bool Update(Span<const uint8_t> in);
|
|
905
425
|
|
|
906
|
-
// GetHash writes the handshake hash to
|
|
907
|
-
// least
|
|
426
|
+
// GetHash writes the handshake hash to `out` which must have room for at
|
|
427
|
+
// least `DigestLen` bytes. On success, it returns true and sets `*out_len` to
|
|
908
428
|
// the number of bytes written. Otherwise, it returns false.
|
|
909
429
|
bool GetHash(uint8_t *out, size_t *out_len) const;
|
|
910
430
|
|
|
911
431
|
// GetFinishedMAC computes the MAC for the Finished message into the bytes
|
|
912
|
-
// pointed by
|
|
913
|
-
// have room for
|
|
432
|
+
// pointed by `out` and writes the number of bytes to `*out_len`. `out` must
|
|
433
|
+
// have room for `EVP_MAX_MD_SIZE` bytes. It returns true on success and false
|
|
914
434
|
// on failure.
|
|
915
435
|
bool GetFinishedMAC(uint8_t *out, size_t *out_len, const SSL_SESSION *session,
|
|
916
436
|
bool from_server) const;
|
|
917
437
|
|
|
918
438
|
private:
|
|
919
|
-
// HashBuffer initializes
|
|
920
|
-
//
|
|
921
|
-
// bytes in
|
|
439
|
+
// HashBuffer initializes `ctx` to use `digest` and writes the contents of
|
|
440
|
+
// `buffer_` to `ctx`. If this SSLTranscript is for DTLS 1.3, the appropriate
|
|
441
|
+
// bytes in `buffer_` will be skipped when hashing the buffer.
|
|
922
442
|
bool HashBuffer(EVP_MD_CTX *ctx, const EVP_MD *digest) const;
|
|
923
443
|
|
|
924
|
-
// AddToBufferOrHash directly adds the contents of
|
|
925
|
-
//
|
|
444
|
+
// AddToBufferOrHash directly adds the contents of `in` to `buffer_` and/or
|
|
445
|
+
// `hash_`.
|
|
926
446
|
bool AddToBufferOrHash(Span<const uint8_t> in);
|
|
927
447
|
|
|
928
448
|
// buffer_, if non-null, contains the handshake transcript.
|
|
929
449
|
UniquePtr<BUF_MEM> buffer_;
|
|
930
|
-
// hash, if initialized with an
|
|
450
|
+
// hash, if initialized with an `EVP_MD`, maintains the handshake hash.
|
|
931
451
|
ScopedEVP_MD_CTX hash_;
|
|
932
452
|
// is_dtls_ indicates whether this is a transcript for a DTLS connection.
|
|
933
453
|
bool is_dtls_ : 1;
|
|
@@ -935,8 +455,8 @@ class SSLTranscript {
|
|
|
935
455
|
uint16_t version_ = 0;
|
|
936
456
|
};
|
|
937
457
|
|
|
938
|
-
// tls1_prf computes the PRF function for
|
|
939
|
-
// as the secret and
|
|
458
|
+
// tls1_prf computes the PRF function for `ssl`. It fills `out`, using `secret`
|
|
459
|
+
// as the secret and `label` as the label. `seed1` and `seed2` are concatenated
|
|
940
460
|
// to form the seed parameter. It returns true on success and false on failure.
|
|
941
461
|
bool tls1_prf(const EVP_MD *digest, Span<uint8_t> out,
|
|
942
462
|
Span<const uint8_t> secret, std::string_view label,
|
|
@@ -956,12 +476,12 @@ class SSLAEADContext {
|
|
|
956
476
|
SSLAEADContext(const SSLAEADContext &&) = delete;
|
|
957
477
|
SSLAEADContext &operator=(const SSLAEADContext &&) = delete;
|
|
958
478
|
|
|
959
|
-
// CreateNullCipher creates an
|
|
479
|
+
// CreateNullCipher creates an `SSLAEADContext` for the null cipher.
|
|
960
480
|
static UniquePtr<SSLAEADContext> CreateNullCipher();
|
|
961
481
|
|
|
962
|
-
// Create creates an
|
|
963
|
-
// returns nullptr on error. Only one of
|
|
964
|
-
// resulting object, depending on
|
|
482
|
+
// Create creates an `SSLAEADContext` using the supplied key material. It
|
|
483
|
+
// returns nullptr on error. Only one of `Open` or `Seal` may be used with the
|
|
484
|
+
// resulting object, depending on `direction`. `version` is the wire version.
|
|
965
485
|
static UniquePtr<SSLAEADContext> Create(enum evp_aead_direction_t direction,
|
|
966
486
|
uint16_t version,
|
|
967
487
|
const SSL_CIPHER *cipher,
|
|
@@ -969,7 +489,7 @@ class SSLAEADContext {
|
|
|
969
489
|
Span<const uint8_t> mac_key,
|
|
970
490
|
Span<const uint8_t> fixed_iv);
|
|
971
491
|
|
|
972
|
-
// CreatePlaceholderForQUIC creates a placeholder
|
|
492
|
+
// CreatePlaceholderForQUIC creates a placeholder `SSLAEADContext` for the
|
|
973
493
|
// given cipher. The resulting object can be queried for various properties
|
|
974
494
|
// but cannot encrypt or decrypt data.
|
|
975
495
|
static UniquePtr<SSLAEADContext> CreatePlaceholderForQUIC(
|
|
@@ -983,54 +503,54 @@ class SSLAEADContext {
|
|
|
983
503
|
// ExplicitNonceLen returns the length of the explicit nonce.
|
|
984
504
|
size_t ExplicitNonceLen() const;
|
|
985
505
|
|
|
986
|
-
// MaxOverhead returns the maximum overhead of calling
|
|
506
|
+
// MaxOverhead returns the maximum overhead of calling `Seal`.
|
|
987
507
|
size_t MaxOverhead() const;
|
|
988
508
|
|
|
989
|
-
// MaxSealInputLen returns the maximum length for
|
|
990
|
-
//
|
|
509
|
+
// MaxSealInputLen returns the maximum length for `Seal` that can fit in
|
|
510
|
+
// `max_out` output bytes, or zero if no input may fit.
|
|
991
511
|
size_t MaxSealInputLen(size_t max_out) const;
|
|
992
512
|
|
|
993
|
-
// SuffixLen calculates the suffix length written by
|
|
994
|
-
// it to
|
|
995
|
-
//
|
|
996
|
-
// passed to
|
|
513
|
+
// SuffixLen calculates the suffix length written by `SealScatter` and writes
|
|
514
|
+
// it to `*out_suffix_len`. It returns true on success and false on error.
|
|
515
|
+
// `in_len` and `extra_in_len` should equal the argument of the same names
|
|
516
|
+
// passed to `SealScatter`.
|
|
997
517
|
bool SuffixLen(size_t *out_suffix_len, size_t in_len,
|
|
998
518
|
size_t extra_in_len) const;
|
|
999
519
|
|
|
1000
520
|
// CiphertextLen calculates the total ciphertext length written by
|
|
1001
|
-
//
|
|
1002
|
-
// false on error.
|
|
1003
|
-
// the same names passed to
|
|
521
|
+
// `SealScatter` and writes it to `*out_len`. It returns true on success and
|
|
522
|
+
// false on error. `in_len` and `extra_in_len` should equal the argument of
|
|
523
|
+
// the same names passed to `SealScatter`.
|
|
1004
524
|
bool CiphertextLen(size_t *out_len, size_t in_len, size_t extra_in_len) const;
|
|
1005
525
|
|
|
1006
|
-
// Open authenticates and decrypts
|
|
1007
|
-
// to the plaintext in
|
|
1008
|
-
// false. The output will always be
|
|
526
|
+
// Open authenticates and decrypts `in` in-place. On success, it sets `*out`
|
|
527
|
+
// to the plaintext in `in` and returns true. Otherwise, it returns
|
|
528
|
+
// false. The output will always be `ExplicitNonceLen` bytes ahead of `in`.
|
|
1009
529
|
bool Open(Span<uint8_t> *out, uint8_t type, uint16_t record_version,
|
|
1010
530
|
uint64_t seqnum, Span<const uint8_t> header, Span<uint8_t> in);
|
|
1011
531
|
|
|
1012
|
-
// Seal encrypts and authenticates
|
|
1013
|
-
// result to
|
|
532
|
+
// Seal encrypts and authenticates `in_len` bytes from `in` and writes the
|
|
533
|
+
// result to `out`. It returns true on success and false on error.
|
|
1014
534
|
//
|
|
1015
|
-
// If
|
|
535
|
+
// If `in` and `out` alias then `out` + `ExplicitNonceLen` must be == `in`.
|
|
1016
536
|
bool Seal(uint8_t *out, size_t *out_len, size_t max_out, uint8_t type,
|
|
1017
537
|
uint16_t record_version, uint64_t seqnum,
|
|
1018
538
|
Span<const uint8_t> header, const uint8_t *in, size_t in_len);
|
|
1019
539
|
|
|
1020
|
-
// SealScatter encrypts and authenticates
|
|
1021
|
-
// the result between
|
|
540
|
+
// SealScatter encrypts and authenticates `in_len` bytes from `in` and splits
|
|
541
|
+
// the result between `out_prefix`, `out` and `out_suffix`. It returns one on
|
|
1022
542
|
// success and zero on error.
|
|
1023
543
|
//
|
|
1024
|
-
// On successful return, exactly
|
|
1025
|
-
//
|
|
1026
|
-
//
|
|
544
|
+
// On successful return, exactly `ExplicitNonceLen` bytes are written to
|
|
545
|
+
// `out_prefix`, `in_len` bytes to `out`, and `SuffixLen` bytes to
|
|
546
|
+
// `out_suffix`.
|
|
1027
547
|
//
|
|
1028
|
-
//
|
|
1029
|
-
//
|
|
1030
|
-
// ciphertext is written to the beginning of
|
|
1031
|
-
// be used to size
|
|
548
|
+
// `extra_in` may point to an additional plaintext buffer. If present,
|
|
549
|
+
// `extra_in_len` additional bytes are encrypted and authenticated, and the
|
|
550
|
+
// ciphertext is written to the beginning of `out_suffix`. `SuffixLen` should
|
|
551
|
+
// be used to size `out_suffix` accordingly.
|
|
1032
552
|
//
|
|
1033
|
-
// If
|
|
553
|
+
// If `in` and `out` alias then `out` must be == `in`. Other arguments may not
|
|
1034
554
|
// alias anything.
|
|
1035
555
|
bool SealScatter(uint8_t *out_prefix, uint8_t *out, uint8_t *out_suffix,
|
|
1036
556
|
uint8_t type, uint16_t record_version, uint64_t seqnum,
|
|
@@ -1040,7 +560,7 @@ class SSLAEADContext {
|
|
|
1040
560
|
bool GetIV(const uint8_t **out_iv, size_t *out_iv_len) const;
|
|
1041
561
|
|
|
1042
562
|
private:
|
|
1043
|
-
// GetAdditionalData returns the additional data, writing into
|
|
563
|
+
// GetAdditionalData returns the additional data, writing into `storage` if
|
|
1044
564
|
// necessary.
|
|
1045
565
|
Span<const uint8_t> GetAdditionalData(uint8_t storage[13], uint8_t type,
|
|
1046
566
|
uint16_t record_version,
|
|
@@ -1077,12 +597,12 @@ class SSLAEADContext {
|
|
|
1077
597
|
// replayed packets.
|
|
1078
598
|
class DTLSReplayBitmap {
|
|
1079
599
|
public:
|
|
1080
|
-
// ShouldDiscard returns true if
|
|
1081
|
-
//
|
|
600
|
+
// ShouldDiscard returns true if `seq_num` has been seen in
|
|
601
|
+
// `bitmap` or is stale. Otherwise it returns false.
|
|
1082
602
|
bool ShouldDiscard(uint64_t seqnum) const;
|
|
1083
603
|
|
|
1084
604
|
// Record updates the bitmap to record receipt of sequence number
|
|
1085
|
-
//
|
|
605
|
+
// `seq_num`. It slides the window forward if needed. It is an error to call
|
|
1086
606
|
// this function on a stale sequence number.
|
|
1087
607
|
void Record(uint64_t seqnum);
|
|
1088
608
|
|
|
@@ -1090,7 +610,7 @@ class DTLSReplayBitmap {
|
|
|
1090
610
|
|
|
1091
611
|
private:
|
|
1092
612
|
// map is a bitset of sequence numbers that have been seen. Bit i corresponds
|
|
1093
|
-
// to
|
|
613
|
+
// to `max_seq_num_ - i`.
|
|
1094
614
|
std::bitset<256> map_;
|
|
1095
615
|
// max_seq_num_ is the largest sequence number seen so far as a 64-bit
|
|
1096
616
|
// integer, or zero if none have been seen.
|
|
@@ -1099,18 +619,18 @@ class DTLSReplayBitmap {
|
|
|
1099
619
|
|
|
1100
620
|
// reconstruct_seqnum takes the low order bits of a record sequence number from
|
|
1101
621
|
// the wire and reconstructs the full sequence number. It does so using the
|
|
1102
|
-
// algorithm described in section 4.2.2 of RFC 9147, where
|
|
1103
|
-
// low bits of the sequence number as seen on the wire,
|
|
622
|
+
// algorithm described in section 4.2.2 of RFC 9147, where `wire_seq` is the
|
|
623
|
+
// low bits of the sequence number as seen on the wire, `seq_mask` is a bitmask
|
|
1104
624
|
// of 8 or 16 1 bits corresponding to the length of the sequence number on the
|
|
1105
|
-
// wire, and
|
|
625
|
+
// wire, and `max_valid_seqnum` is the largest sequence number of a record
|
|
1106
626
|
// successfully deprotected in this epoch. This function returns the sequence
|
|
1107
|
-
// number that is numerically closest to one plus
|
|
1108
|
-
// bitwise and-ed with
|
|
627
|
+
// number that is numerically closest to one plus `max_valid_seqnum` that when
|
|
628
|
+
// bitwise and-ed with `seq_mask` equals `wire_seq`.
|
|
1109
629
|
//
|
|
1110
|
-
//
|
|
630
|
+
// `max_valid_seqnum` must be most 2^48-1, in which case the output will also be
|
|
1111
631
|
// at most 2^48-1.
|
|
1112
|
-
|
|
1113
|
-
|
|
632
|
+
uint64_t reconstruct_seqnum(uint16_t wire_seq, uint64_t seq_mask,
|
|
633
|
+
uint64_t max_valid_seqnum);
|
|
1114
634
|
|
|
1115
635
|
|
|
1116
636
|
// Record layer.
|
|
@@ -1157,7 +677,7 @@ class RecordNumberEncrypter {
|
|
|
1157
677
|
static constexpr bool kAllowUniquePtr = true;
|
|
1158
678
|
static constexpr size_t kMaxKeySize = 32;
|
|
1159
679
|
|
|
1160
|
-
// Create returns a DTLS 1.3 record number encrypter for
|
|
680
|
+
// Create returns a DTLS 1.3 record number encrypter for `traffic_secret`, or
|
|
1161
681
|
// nullptr on error.
|
|
1162
682
|
static UniquePtr<RecordNumberEncrypter> Create(
|
|
1163
683
|
const SSL_CIPHER *cipher, Span<const uint8_t> traffic_secret);
|
|
@@ -1171,7 +691,7 @@ class RecordNumberEncrypter {
|
|
|
1171
691
|
struct DTLSReadEpoch {
|
|
1172
692
|
static constexpr bool kAllowUniquePtr = true;
|
|
1173
693
|
|
|
1174
|
-
// TODO(davidben): This could be made slightly more compact if
|
|
694
|
+
// TODO(davidben): This could be made slightly more compact if `bitmap` stored
|
|
1175
695
|
// a DTLSRecordNumber.
|
|
1176
696
|
uint16_t epoch = 0;
|
|
1177
697
|
UniquePtr<SSLAEADContext> aead;
|
|
@@ -1192,7 +712,7 @@ struct DTLSWriteEpoch {
|
|
|
1192
712
|
};
|
|
1193
713
|
|
|
1194
714
|
// ssl_record_prefix_len returns the length of the prefix before the ciphertext
|
|
1195
|
-
// of a record for
|
|
715
|
+
// of a record for `ssl`.
|
|
1196
716
|
//
|
|
1197
717
|
// TODO(davidben): Expose this as part of public API once the high-level
|
|
1198
718
|
// buffer-free APIs are available.
|
|
@@ -1206,63 +726,63 @@ enum ssl_open_record_t {
|
|
|
1206
726
|
ssl_open_record_error,
|
|
1207
727
|
};
|
|
1208
728
|
|
|
1209
|
-
// tls_open_record decrypts a record from
|
|
729
|
+
// tls_open_record decrypts a record from `in` in-place.
|
|
1210
730
|
//
|
|
1211
731
|
// If the input did not contain a complete record, it returns
|
|
1212
|
-
//
|
|
1213
|
-
// bytes necessary. It is guaranteed that a successful call to
|
|
732
|
+
// `ssl_open_record_partial`. It sets `*out_consumed` to the total number of
|
|
733
|
+
// bytes necessary. It is guaranteed that a successful call to `tls_open_record`
|
|
1214
734
|
// will consume at least that many bytes.
|
|
1215
735
|
//
|
|
1216
|
-
// Otherwise, it sets
|
|
736
|
+
// Otherwise, it sets `*out_consumed` to the number of bytes of input
|
|
1217
737
|
// consumed. Note that input may be consumed on all return codes if a record was
|
|
1218
738
|
// decrypted.
|
|
1219
739
|
//
|
|
1220
|
-
// On success, it returns
|
|
1221
|
-
// record type and
|
|
740
|
+
// On success, it returns `ssl_open_record_success`. It sets `*out_type` to the
|
|
741
|
+
// record type and `*out` to the record body in `in`. Note that `*out` may be
|
|
1222
742
|
// empty.
|
|
1223
743
|
//
|
|
1224
744
|
// If a record was successfully processed but should be discarded, it returns
|
|
1225
|
-
//
|
|
745
|
+
// `ssl_open_record_discard`.
|
|
1226
746
|
//
|
|
1227
747
|
// If a record was successfully processed but is a close_notify, it returns
|
|
1228
|
-
//
|
|
748
|
+
// `ssl_open_record_close_notify`.
|
|
1229
749
|
//
|
|
1230
|
-
// On failure or fatal alert, it returns
|
|
1231
|
-
//
|
|
750
|
+
// On failure or fatal alert, it returns `ssl_open_record_error` and sets
|
|
751
|
+
// `*out_alert` to an alert to emit, or zero if no alert should be emitted.
|
|
1232
752
|
enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type,
|
|
1233
753
|
Span<uint8_t> *out, size_t *out_consumed,
|
|
1234
754
|
uint8_t *out_alert, Span<uint8_t> in);
|
|
1235
755
|
|
|
1236
|
-
// dtls_open_record implements
|
|
1237
|
-
//
|
|
756
|
+
// dtls_open_record implements `tls_open_record` for DTLS. It only returns
|
|
757
|
+
// `ssl_open_record_partial` if `in` was empty and sets `*out_consumed` to
|
|
1238
758
|
// zero. The caller should read one packet and try again. On success,
|
|
1239
|
-
//
|
|
759
|
+
// `*out_number` is set to the record number of the record.
|
|
1240
760
|
enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
|
|
1241
761
|
DTLSRecordNumber *out_number,
|
|
1242
762
|
Span<uint8_t> *out,
|
|
1243
763
|
size_t *out_consumed,
|
|
1244
764
|
uint8_t *out_alert, Span<uint8_t> in);
|
|
1245
765
|
|
|
1246
|
-
// ssl_needs_record_splitting returns one if
|
|
766
|
+
// ssl_needs_record_splitting returns one if `ssl`'s current outgoing cipher
|
|
1247
767
|
// state needs record-splitting and zero otherwise.
|
|
1248
768
|
bool ssl_needs_record_splitting(const SSL *ssl);
|
|
1249
769
|
|
|
1250
|
-
// tls_seal_record seals a new record of type
|
|
1251
|
-
// to
|
|
1252
|
-
// and false on error. If enabled,
|
|
770
|
+
// tls_seal_record seals a new record of type `type` and body `in` and writes it
|
|
771
|
+
// to `out`. At most `max_out` bytes will be written. It returns true on success
|
|
772
|
+
// and false on error. If enabled, `tls_seal_record` implements TLS 1.0 CBC
|
|
1253
773
|
// 1/n-1 record splitting and may write two records concatenated.
|
|
1254
774
|
//
|
|
1255
775
|
// For a large record, the bulk of the ciphertext will begin
|
|
1256
|
-
//
|
|
1257
|
-
// improve performance. It writes at most
|
|
1258
|
-
// bytes to
|
|
776
|
+
// `tls_seal_align_prefix_len` bytes into out. Aligning `out` appropriately may
|
|
777
|
+
// improve performance. It writes at most `in_len` + `SSL_max_seal_overhead`
|
|
778
|
+
// bytes to `out`.
|
|
1259
779
|
//
|
|
1260
|
-
//
|
|
780
|
+
// `in` and `out` may not alias.
|
|
1261
781
|
bool tls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
|
|
1262
782
|
uint8_t type, const uint8_t *in, size_t in_len);
|
|
1263
783
|
|
|
1264
784
|
// dtls_record_header_write_len returns the length of the record header that
|
|
1265
|
-
// will be written at
|
|
785
|
+
// will be written at `epoch`.
|
|
1266
786
|
size_t dtls_record_header_write_len(const SSL *ssl, uint16_t epoch);
|
|
1267
787
|
|
|
1268
788
|
// dtls_max_seal_overhead returns the maximum overhead, in bytes, of sealing a
|
|
@@ -1274,26 +794,26 @@ size_t dtls_max_seal_overhead(const SSL *ssl, uint16_t epoch);
|
|
|
1274
794
|
size_t dtls_seal_prefix_len(const SSL *ssl, uint16_t epoch);
|
|
1275
795
|
|
|
1276
796
|
// dtls_seal_max_input_len returns the maximum number of input bytes that can
|
|
1277
|
-
// fit in a record of up to
|
|
797
|
+
// fit in a record of up to `max_out` bytes, or zero if none may fit.
|
|
1278
798
|
size_t dtls_seal_max_input_len(const SSL *ssl, uint16_t epoch, size_t max_out);
|
|
1279
799
|
|
|
1280
800
|
// dtls_get_read_epoch and dtls_get_write_epoch return the epoch corresponding
|
|
1281
|
-
// to
|
|
801
|
+
// to `epoch` or nullptr if there is none.
|
|
1282
802
|
DTLSReadEpoch *dtls_get_read_epoch(const SSL *ssl, uint16_t epoch);
|
|
1283
803
|
DTLSWriteEpoch *dtls_get_write_epoch(const SSL *ssl, uint16_t epoch);
|
|
1284
804
|
|
|
1285
|
-
// dtls_seal_record implements
|
|
1286
|
-
// epoch's cipher state to use. Unlike
|
|
1287
|
-
// alias but, if they do,
|
|
1288
|
-
// ahead of
|
|
805
|
+
// dtls_seal_record implements `tls_seal_record` for DTLS. `epoch` selects which
|
|
806
|
+
// epoch's cipher state to use. Unlike `tls_seal_record`, `in` and `out` may
|
|
807
|
+
// alias but, if they do, `in` must be exactly `dtls_seal_prefix_len` bytes
|
|
808
|
+
// ahead of `out`. On success, `*out_number` is set to the record number of the
|
|
1289
809
|
// record.
|
|
1290
810
|
bool dtls_seal_record(SSL *ssl, DTLSRecordNumber *out_number, uint8_t *out,
|
|
1291
811
|
size_t *out_len, size_t max_out, uint8_t type,
|
|
1292
812
|
const uint8_t *in, size_t in_len, uint16_t epoch);
|
|
1293
813
|
|
|
1294
|
-
// ssl_process_alert processes
|
|
1295
|
-
// state. It returns one of
|
|
1296
|
-
//
|
|
814
|
+
// ssl_process_alert processes `in` as an alert and updates `ssl`'s shutdown
|
|
815
|
+
// state. It returns one of `ssl_open_record_discard`, `ssl_open_record_error`,
|
|
816
|
+
// `ssl_open_record_close_notify`, or `ssl_open_record_fatal_alert` as
|
|
1297
817
|
// appropriate.
|
|
1298
818
|
enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert,
|
|
1299
819
|
Span<const uint8_t> in);
|
|
@@ -1302,10 +822,10 @@ enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert,
|
|
|
1302
822
|
// Private key operations.
|
|
1303
823
|
|
|
1304
824
|
// ssl_private_key_* perform the corresponding operation on
|
|
1305
|
-
//
|
|
1306
|
-
// call the corresponding function or
|
|
825
|
+
// `SSL_PRIVATE_KEY_METHOD`. If there is a custom private key configured, they
|
|
826
|
+
// call the corresponding function or `complete` depending on whether there is a
|
|
1307
827
|
// pending operation. Otherwise, they implement the operation with
|
|
1308
|
-
//
|
|
828
|
+
// `EVP_PKEY`.
|
|
1309
829
|
|
|
1310
830
|
enum ssl_private_key_result_t ssl_private_key_sign(
|
|
1311
831
|
SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
|
|
@@ -1317,13 +837,19 @@ enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
|
|
|
1317
837
|
size_t max_out,
|
|
1318
838
|
Span<const uint8_t> in);
|
|
1319
839
|
|
|
1320
|
-
//
|
|
1321
|
-
//
|
|
840
|
+
// ssl_parse_peer_subject_public_key_info decodes a SubjectPublicKeyInfo
|
|
841
|
+
// representing the peer TLS key. It returns a newly-allocated `EVP_PKEY` or
|
|
842
|
+
// nullptr on error.
|
|
843
|
+
UniquePtr<EVP_PKEY> ssl_parse_peer_subject_public_key_info(
|
|
844
|
+
Span<const uint8_t> spki);
|
|
845
|
+
|
|
846
|
+
// ssl_pkey_supports_algorithm returns whether `pkey` may be used to sign
|
|
847
|
+
// `sigalg`.
|
|
1322
848
|
bool ssl_pkey_supports_algorithm(const SSL *ssl, EVP_PKEY *pkey,
|
|
1323
849
|
uint16_t sigalg, bool is_verify);
|
|
1324
850
|
|
|
1325
|
-
// ssl_public_key_verify verifies that the
|
|
1326
|
-
// key
|
|
851
|
+
// ssl_public_key_verify verifies that the `signature` is valid for the public
|
|
852
|
+
// key `pkey` and input `in`, using the signature algorithm `sigalg`.
|
|
1327
853
|
bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature,
|
|
1328
854
|
uint16_t sigalg, EVP_PKEY *pkey,
|
|
1329
855
|
Span<const uint8_t> in);
|
|
@@ -1345,35 +871,35 @@ class SSLKeyShare {
|
|
|
1345
871
|
virtual ~SSLKeyShare() {}
|
|
1346
872
|
static constexpr bool kAllowUniquePtr = true;
|
|
1347
873
|
|
|
1348
|
-
// Create returns a SSLKeyShare instance for use with group
|
|
874
|
+
// Create returns a SSLKeyShare instance for use with group `group_id` or
|
|
1349
875
|
// nullptr on error.
|
|
1350
876
|
static UniquePtr<SSLKeyShare> Create(uint16_t group_id);
|
|
1351
877
|
|
|
1352
878
|
// GroupID returns the group ID.
|
|
1353
879
|
virtual uint16_t GroupID() const = 0;
|
|
1354
880
|
|
|
1355
|
-
// Generate generates a keypair and writes the public key to
|
|
881
|
+
// Generate generates a keypair and writes the public key to `out_public_key`.
|
|
1356
882
|
// It returns true on success and false on error.
|
|
1357
883
|
virtual bool Generate(CBB *out_public_key) = 0;
|
|
1358
884
|
|
|
1359
885
|
// Encap generates an ephemeral, symmetric secret and encapsulates it with
|
|
1360
|
-
//
|
|
1361
|
-
//
|
|
1362
|
-
// it returns false and sets
|
|
886
|
+
// `peer_key`. On success, it returns true, writes the encapsulated secret to
|
|
887
|
+
// `out_ciphertext`, and sets `*out_secret` to the shared secret. On failure,
|
|
888
|
+
// it returns false and sets `*out_alert` to an alert to send to the peer.
|
|
1363
889
|
virtual bool Encap(CBB *out_ciphertext, Array<uint8_t> *out_secret,
|
|
1364
890
|
uint8_t *out_alert, Span<const uint8_t> peer_key) = 0;
|
|
1365
891
|
|
|
1366
|
-
// Decap decapsulates the symmetric secret in
|
|
1367
|
-
// returns true and sets
|
|
1368
|
-
// returns false and sets
|
|
892
|
+
// Decap decapsulates the symmetric secret in `ciphertext`. On success, it
|
|
893
|
+
// returns true and sets `*out_secret` to the shared secret. On failure, it
|
|
894
|
+
// returns false and sets `*out_alert` to an alert to send to the peer.
|
|
1369
895
|
virtual bool Decap(Array<uint8_t> *out_secret, uint8_t *out_alert,
|
|
1370
896
|
Span<const uint8_t> ciphertext) = 0;
|
|
1371
897
|
|
|
1372
|
-
// SerializePrivateKey writes the private key to
|
|
1373
|
-
// successful and false otherwise. It should be called after
|
|
898
|
+
// SerializePrivateKey writes the private key to `out`, returning true if
|
|
899
|
+
// successful and false otherwise. It should be called after `Generate`.
|
|
1374
900
|
virtual bool SerializePrivateKey(CBB *out) { return false; }
|
|
1375
901
|
|
|
1376
|
-
// DeserializePrivateKey initializes the state of the key exchange from
|
|
902
|
+
// DeserializePrivateKey initializes the state of the key exchange from `in`,
|
|
1377
903
|
// returning true if successful and false otherwise.
|
|
1378
904
|
virtual bool DeserializePrivateKey(CBS *in) { return false; }
|
|
1379
905
|
};
|
|
@@ -1387,18 +913,25 @@ struct NamedGroup {
|
|
|
1387
913
|
// NamedGroups returns all supported groups.
|
|
1388
914
|
Span<const NamedGroup> NamedGroups();
|
|
1389
915
|
|
|
1390
|
-
//
|
|
1391
|
-
|
|
916
|
+
// kNumNamedGroups is the number of supported groups.
|
|
917
|
+
constexpr size_t kNumNamedGroups = 7u;
|
|
918
|
+
|
|
919
|
+
// DefaultSupportedGroupIds returns the list of IDs for the default groups that
|
|
920
|
+
// are supported when the caller hasn't explicitly configured supported groups.
|
|
921
|
+
Span<const uint16_t> DefaultSupportedGroupIds();
|
|
922
|
+
|
|
923
|
+
// ssl_nid_to_group_id looks up the group corresponding to `nid`. On success, it
|
|
924
|
+
// sets `*out_group_id` to the group ID and returns true. Otherwise, it returns
|
|
1392
925
|
// false.
|
|
1393
926
|
bool ssl_nid_to_group_id(uint16_t *out_group_id, int nid);
|
|
1394
927
|
|
|
1395
|
-
// ssl_name_to_group_id looks up the group corresponding to the
|
|
1396
|
-
// length
|
|
928
|
+
// ssl_name_to_group_id looks up the group corresponding to the `name` string of
|
|
929
|
+
// length `len`. On success, it sets `*out_group_id` to the group ID and returns
|
|
1397
930
|
// true. Otherwise, it returns false.
|
|
1398
931
|
bool ssl_name_to_group_id(uint16_t *out_group_id, const char *name, size_t len);
|
|
1399
932
|
|
|
1400
|
-
// ssl_group_id_to_nid returns the NID corresponding to
|
|
1401
|
-
//
|
|
933
|
+
// ssl_group_id_to_nid returns the NID corresponding to `group_id` or
|
|
934
|
+
// `NID_undef` if unknown.
|
|
1402
935
|
int ssl_group_id_to_nid(uint16_t group_id);
|
|
1403
936
|
|
|
1404
937
|
|
|
@@ -1425,23 +958,23 @@ extern const uint8_t kTLS13DowngradeRandom[8];
|
|
|
1425
958
|
extern const uint8_t kJDK11DowngradeRandom[8];
|
|
1426
959
|
|
|
1427
960
|
// ssl_max_handshake_message_len returns the maximum number of bytes permitted
|
|
1428
|
-
// in a handshake message for
|
|
961
|
+
// in a handshake message for `ssl`.
|
|
1429
962
|
size_t ssl_max_handshake_message_len(const SSL *ssl);
|
|
1430
963
|
|
|
1431
|
-
// tls_can_accept_handshake_data returns whether
|
|
964
|
+
// tls_can_accept_handshake_data returns whether `ssl` is able to accept more
|
|
1432
965
|
// data into handshake buffer.
|
|
1433
966
|
bool tls_can_accept_handshake_data(const SSL *ssl, uint8_t *out_alert);
|
|
1434
967
|
|
|
1435
968
|
// tls_has_unprocessed_handshake_data returns whether there is buffered
|
|
1436
|
-
// handshake data that has not been consumed by
|
|
969
|
+
// handshake data that has not been consumed by `get_message`.
|
|
1437
970
|
bool tls_has_unprocessed_handshake_data(const SSL *ssl);
|
|
1438
971
|
|
|
1439
|
-
// tls_append_handshake_data appends
|
|
972
|
+
// tls_append_handshake_data appends `data` to the handshake buffer. It returns
|
|
1440
973
|
// true on success and false on allocation failure.
|
|
1441
974
|
bool tls_append_handshake_data(SSL *ssl, Span<const uint8_t> data);
|
|
1442
975
|
|
|
1443
976
|
// dtls_has_unprocessed_handshake_data behaves like
|
|
1444
|
-
//
|
|
977
|
+
// `tls_has_unprocessed_handshake_data` for DTLS.
|
|
1445
978
|
bool dtls_has_unprocessed_handshake_data(const SSL *ssl);
|
|
1446
979
|
|
|
1447
980
|
// tls_flush_pending_hs_data flushes any handshake plaintext data.
|
|
@@ -1457,10 +990,10 @@ void dtls_clear_unused_write_epochs(SSL *ssl);
|
|
|
1457
990
|
|
|
1458
991
|
// Callbacks.
|
|
1459
992
|
|
|
1460
|
-
// ssl_do_info_callback calls
|
|
993
|
+
// ssl_do_info_callback calls `ssl`'s info callback, if set.
|
|
1461
994
|
void ssl_do_info_callback(const SSL *ssl, int type, int value);
|
|
1462
995
|
|
|
1463
|
-
// ssl_do_msg_callback calls
|
|
996
|
+
// ssl_do_msg_callback calls `ssl`'s message callback, if set.
|
|
1464
997
|
void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type,
|
|
1465
998
|
Span<const uint8_t> in);
|
|
1466
999
|
|
|
@@ -1487,19 +1020,19 @@ class SSLBuffer {
|
|
|
1487
1020
|
// Clear releases the buffer.
|
|
1488
1021
|
void Clear();
|
|
1489
1022
|
|
|
1490
|
-
// EnsureCap ensures the buffer has capacity at least
|
|
1491
|
-
// that data written after
|
|
1492
|
-
//
|
|
1023
|
+
// EnsureCap ensures the buffer has capacity at least `new_cap`, aligned such
|
|
1024
|
+
// that data written after `header_len` is aligned to a
|
|
1025
|
+
// `SSL3_ALIGN_PAYLOAD`-byte boundary. It returns true on success and false
|
|
1493
1026
|
// on error.
|
|
1494
1027
|
bool EnsureCap(size_t header_len, size_t new_cap);
|
|
1495
1028
|
|
|
1496
|
-
// DidWrite extends the buffer by
|
|
1029
|
+
// DidWrite extends the buffer by `len`. The caller must have filled in to
|
|
1497
1030
|
// this point.
|
|
1498
1031
|
void DidWrite(size_t len);
|
|
1499
1032
|
|
|
1500
|
-
// Consume consumes
|
|
1501
|
-
// consumed will remain valid until the next call to
|
|
1502
|
-
//
|
|
1033
|
+
// Consume consumes `len` bytes from the front of the buffer. The memory
|
|
1034
|
+
// consumed will remain valid until the next call to `DiscardConsumed` or
|
|
1035
|
+
// `Clear`.
|
|
1503
1036
|
void Consume(size_t len);
|
|
1504
1037
|
|
|
1505
1038
|
// DiscardConsumed discards the consumed bytes from the buffer. If the buffer
|
|
@@ -1509,28 +1042,28 @@ class SSLBuffer {
|
|
|
1509
1042
|
private:
|
|
1510
1043
|
// buf_ is the memory allocated for this buffer.
|
|
1511
1044
|
uint8_t *buf_ = nullptr;
|
|
1512
|
-
// offset_ is the offset into
|
|
1045
|
+
// offset_ is the offset into `buf_` which the buffer contents start at.
|
|
1513
1046
|
uint16_t offset_ = 0;
|
|
1514
|
-
// size_ is the size of the buffer contents from
|
|
1047
|
+
// size_ is the size of the buffer contents from `buf_` + `offset_`.
|
|
1515
1048
|
uint16_t size_ = 0;
|
|
1516
|
-
// cap_ is how much memory beyond
|
|
1049
|
+
// cap_ is how much memory beyond `buf_` + `offset_` is available.
|
|
1517
1050
|
uint16_t cap_ = 0;
|
|
1518
1051
|
// inline_buf_ is a static buffer for short reads.
|
|
1519
1052
|
uint8_t inline_buf_[SSL3_RT_HEADER_LENGTH];
|
|
1520
1053
|
};
|
|
1521
1054
|
|
|
1522
1055
|
// ssl_read_buffer_extend_to extends the read buffer to the desired length. For
|
|
1523
|
-
// TLS, it reads to the end of the buffer until the buffer is
|
|
1524
|
-
// long. For DTLS, it reads a new packet and ignores
|
|
1056
|
+
// TLS, it reads to the end of the buffer until the buffer is `len` bytes
|
|
1057
|
+
// long. For DTLS, it reads a new packet and ignores `len`. It returns one on
|
|
1525
1058
|
// success, zero on EOF, and a negative number on error.
|
|
1526
1059
|
//
|
|
1527
|
-
// It is an error to call
|
|
1060
|
+
// It is an error to call `ssl_read_buffer_extend_to` in DTLS when the buffer is
|
|
1528
1061
|
// non-empty.
|
|
1529
1062
|
int ssl_read_buffer_extend_to(SSL *ssl, size_t len);
|
|
1530
1063
|
|
|
1531
|
-
// ssl_handle_open_record handles the result of passing
|
|
1532
|
-
// to a record-processing function. If
|
|
1533
|
-
// should retry, it returns one and sets
|
|
1064
|
+
// ssl_handle_open_record handles the result of passing `ssl->s3->read_buffer`
|
|
1065
|
+
// to a record-processing function. If `ret` is a success or if the caller
|
|
1066
|
+
// should retry, it returns one and sets `*out_retry`. Otherwise, it returns <=
|
|
1534
1067
|
// 0.
|
|
1535
1068
|
int ssl_handle_open_record(SSL *ssl, bool *out_retry, ssl_open_record_t ret,
|
|
1536
1069
|
size_t consumed, uint8_t alert);
|
|
@@ -1543,53 +1076,64 @@ int ssl_write_buffer_flush(SSL *ssl);
|
|
|
1543
1076
|
|
|
1544
1077
|
// Certificate functions.
|
|
1545
1078
|
|
|
1546
|
-
// ssl_parse_cert_chain parses a certificate list from
|
|
1547
|
-
// by a TLS Certificate message. On success, it advances
|
|
1548
|
-
// true. Otherwise, it returns false and sets
|
|
1079
|
+
// ssl_parse_cert_chain parses a certificate list from `cbs` in the format used
|
|
1080
|
+
// by a TLS Certificate message. On success, it advances `cbs` and returns
|
|
1081
|
+
// true. Otherwise, it returns false and sets `*out_alert` to an alert to send
|
|
1549
1082
|
// to the peer.
|
|
1550
1083
|
//
|
|
1551
|
-
// If the list is non-empty then
|
|
1084
|
+
// If the list is non-empty then `*out_chain` and `*out_pubkey` will be set to
|
|
1552
1085
|
// the certificate chain and the leaf certificate's public key
|
|
1553
1086
|
// respectively. Otherwise, both will be set to nullptr.
|
|
1554
1087
|
//
|
|
1555
|
-
// If the list is non-empty and
|
|
1556
|
-
// SHA-256 hash of the leaf to
|
|
1088
|
+
// If the list is non-empty and `out_leaf_sha256` is non-NULL, it writes the
|
|
1089
|
+
// SHA-256 hash of the leaf to `out_leaf_sha256`.
|
|
1557
1090
|
bool ssl_parse_cert_chain(uint8_t *out_alert,
|
|
1558
1091
|
UniquePtr<STACK_OF(CRYPTO_BUFFER)> *out_chain,
|
|
1559
1092
|
UniquePtr<EVP_PKEY> *out_pubkey,
|
|
1560
1093
|
uint8_t *out_leaf_sha256, CBS *cbs,
|
|
1561
1094
|
CRYPTO_BUFFER_POOL *pool);
|
|
1562
1095
|
|
|
1096
|
+
// ssl_parse_rpk_cert parses a RawPublicKey certificate from `cbs` in the format
|
|
1097
|
+
// used by a TLS 1.2 Certificate message (RFC 7250). On success, it advances
|
|
1098
|
+
// `cbs` and returns true, and sets `*out_raw_public_key` to the parsed key, and
|
|
1099
|
+
// sets `*out_pubkey` to the same key by incrementing the reference count, and
|
|
1100
|
+
// if `out_rpk_sha256` is non-NULL, it writes the SHA-256 hash of the RPK to
|
|
1101
|
+
// `out_rpk_sha256`. Otherwise, it returns false and sets `*out_alert` to an
|
|
1102
|
+
// alert to send to the peer.
|
|
1103
|
+
bool ssl_parse_rpk_cert(uint8_t *out_alert,
|
|
1104
|
+
UniquePtr<EVP_PKEY> *out_raw_public_key,
|
|
1105
|
+
UniquePtr<EVP_PKEY> *out_pubkey,
|
|
1106
|
+
uint8_t *out_rpk_sha256, CBS *cbs);
|
|
1107
|
+
|
|
1563
1108
|
enum ssl_key_usage_t {
|
|
1564
1109
|
key_usage_digital_signature = 0,
|
|
1565
1110
|
key_usage_encipherment = 2,
|
|
1566
1111
|
};
|
|
1567
1112
|
|
|
1568
|
-
// ssl_cert_check_key_usage parses the DER-encoded, X.509 certificate in
|
|
1113
|
+
// ssl_cert_check_key_usage parses the DER-encoded, X.509 certificate in `in`
|
|
1569
1114
|
// and returns true if doesn't specify a key usage or, if it does, if it
|
|
1570
|
-
// includes
|
|
1571
|
-
|
|
1572
|
-
enum ssl_key_usage_t bit);
|
|
1115
|
+
// includes `bit`. Otherwise it pushes to the error queue and returns false.
|
|
1116
|
+
bool ssl_cert_check_key_usage(const CBS *in, enum ssl_key_usage_t bit);
|
|
1573
1117
|
|
|
1574
|
-
// ssl_cert_extract_issuer parses the DER-encoded, X.509 certificate in
|
|
1118
|
+
// ssl_cert_extract_issuer parses the DER-encoded, X.509 certificate in `in`
|
|
1575
1119
|
// and extracts the issuer. On success it returns true and the DER encoded
|
|
1576
|
-
// issuer is in
|
|
1577
|
-
|
|
1120
|
+
// issuer is in `out_dn`, otherwise it returns false.
|
|
1121
|
+
bool ssl_cert_extract_issuer(const CBS *in, CBS *out_dn);
|
|
1578
1122
|
|
|
1579
|
-
// ssl_cert_matches_issuer parses the DER-encoded, X.509 certificate in
|
|
1123
|
+
// ssl_cert_matches_issuer parses the DER-encoded, X.509 certificate in `in`
|
|
1580
1124
|
// and returns true if its issuer is an exact match for the DER encoded
|
|
1581
|
-
// distinguished name in
|
|
1125
|
+
// distinguished name in `dn`
|
|
1582
1126
|
bool ssl_cert_matches_issuer(const CBS *in, const CBS *dn);
|
|
1583
1127
|
|
|
1584
1128
|
// ssl_cert_parse_pubkey extracts the public key from the DER-encoded, X.509
|
|
1585
|
-
// certificate in
|
|
1129
|
+
// certificate in `in`. It returns an allocated `EVP_PKEY` or else returns
|
|
1586
1130
|
// nullptr and pushes to the error queue.
|
|
1587
1131
|
UniquePtr<EVP_PKEY> ssl_cert_parse_pubkey(const CBS *in);
|
|
1588
1132
|
|
|
1589
|
-
// SSL_parse_CA_list parses a CA list from
|
|
1133
|
+
// SSL_parse_CA_list parses a CA list from `cbs` in the format used by a TLS
|
|
1590
1134
|
// CertificateRequest message and Certificate Authorities extension. On success,
|
|
1591
|
-
// it returns a newly-allocated
|
|
1592
|
-
//
|
|
1135
|
+
// it returns a newly-allocated `CRYPTO_BUFFER` list and advances
|
|
1136
|
+
// `cbs`. Otherwise, it returns nullptr and sets `*out_alert` to an alert to
|
|
1593
1137
|
// send to the peer.
|
|
1594
1138
|
UniquePtr<STACK_OF(CRYPTO_BUFFER)> SSL_parse_CA_list(SSL *ssl,
|
|
1595
1139
|
uint8_t *out_alert,
|
|
@@ -1598,7 +1142,7 @@ UniquePtr<STACK_OF(CRYPTO_BUFFER)> SSL_parse_CA_list(SSL *ssl,
|
|
|
1598
1142
|
// ssl_has_client_CAs returns whether there are configured CAs.
|
|
1599
1143
|
bool ssl_has_client_CAs(const SSL_CONFIG *cfg);
|
|
1600
1144
|
|
|
1601
|
-
// ssl_add_client_CA_list adds the configured CA list to
|
|
1145
|
+
// ssl_add_client_CA_list adds the configured CA list to `cbb` in the format
|
|
1602
1146
|
// used by a TLS CertificateRequest message. It returns true on success and
|
|
1603
1147
|
// false on error.
|
|
1604
1148
|
bool ssl_add_client_CA_list(const SSL_HANDSHAKE *hs, CBB *cbb);
|
|
@@ -1606,13 +1150,13 @@ bool ssl_add_client_CA_list(const SSL_HANDSHAKE *hs, CBB *cbb);
|
|
|
1606
1150
|
// ssl_has_CA_names returns whether there are configured CA names.
|
|
1607
1151
|
bool ssl_has_CA_names(const SSL_CONFIG *cfg);
|
|
1608
1152
|
|
|
1609
|
-
// ssl_add_CA_names adds the configured CA_names list to
|
|
1153
|
+
// ssl_add_CA_names adds the configured CA_names list to `cbb` in the format
|
|
1610
1154
|
// used by a TLS Certificate Authorities extension. It returns true on success
|
|
1611
1155
|
// and false on error.
|
|
1612
1156
|
bool ssl_add_CA_names(const SSL_HANDSHAKE *hs, CBB *cbb);
|
|
1613
1157
|
|
|
1614
|
-
// ssl_check_leaf_certificate returns one if
|
|
1615
|
-
// a server's leaf certificate for
|
|
1158
|
+
// ssl_check_leaf_certificate returns one if `pkey` and `leaf` are suitable as
|
|
1159
|
+
// a server's leaf certificate for `hs`. Otherwise, it returns zero and pushes
|
|
1616
1160
|
// an error on the error queue.
|
|
1617
1161
|
bool ssl_check_leaf_certificate(SSL_HANDSHAKE *hs, EVP_PKEY *pkey,
|
|
1618
1162
|
const CRYPTO_BUFFER *leaf);
|
|
@@ -1626,17 +1170,17 @@ bool ssl_check_leaf_certificate(SSL_HANDSHAKE *hs, EVP_PKEY *pkey,
|
|
|
1626
1170
|
bool tls13_init_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> psk);
|
|
1627
1171
|
|
|
1628
1172
|
// tls13_init_early_key_schedule initializes the handshake hash and key
|
|
1629
|
-
// derivation state from
|
|
1173
|
+
// derivation state from `session` for use with 0-RTT. It returns one on success
|
|
1630
1174
|
// and zero on error.
|
|
1631
1175
|
bool tls13_init_early_key_schedule(SSL_HANDSHAKE *hs,
|
|
1632
1176
|
const SSL_SESSION *session);
|
|
1633
1177
|
|
|
1634
|
-
// tls13_advance_key_schedule incorporates
|
|
1178
|
+
// tls13_advance_key_schedule incorporates `in` into the key schedule with
|
|
1635
1179
|
// HKDF-Extract. It returns true on success and false on error.
|
|
1636
1180
|
bool tls13_advance_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> in);
|
|
1637
1181
|
|
|
1638
1182
|
// tls13_set_traffic_key sets the read or write traffic keys to
|
|
1639
|
-
//
|
|
1183
|
+
// `traffic_secret`. The version and cipher suite are determined from `session`.
|
|
1640
1184
|
// It returns true on success and false on error.
|
|
1641
1185
|
bool tls13_set_traffic_key(SSL *ssl, enum ssl_encryption_level_t level,
|
|
1642
1186
|
enum evp_aead_direction_t direction,
|
|
@@ -1656,47 +1200,81 @@ bool tls13_derive_handshake_secrets(SSL_HANDSHAKE *hs);
|
|
|
1656
1200
|
bool tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction);
|
|
1657
1201
|
|
|
1658
1202
|
// tls13_derive_application_secrets derives the initial application data traffic
|
|
1659
|
-
// and exporter secrets based on the handshake transcripts and
|
|
1203
|
+
// and exporter secrets based on the handshake transcripts and `master_secret`.
|
|
1660
1204
|
// It returns true on success and false on error.
|
|
1661
1205
|
bool tls13_derive_application_secrets(SSL_HANDSHAKE *hs);
|
|
1662
1206
|
|
|
1663
|
-
// tls13_derive_resumption_secret derives the
|
|
1207
|
+
// tls13_derive_resumption_secret derives the `resumption_secret`.
|
|
1664
1208
|
bool tls13_derive_resumption_secret(SSL_HANDSHAKE *hs);
|
|
1665
1209
|
|
|
1666
1210
|
// tls13_export_keying_material provides an exporter interface to use the
|
|
1667
|
-
//
|
|
1211
|
+
// `exporter_secret`.
|
|
1668
1212
|
bool tls13_export_keying_material(const SSL *ssl, Span<uint8_t> out,
|
|
1669
1213
|
Span<const uint8_t> secret,
|
|
1670
1214
|
std::string_view label,
|
|
1671
1215
|
Span<const uint8_t> context);
|
|
1672
1216
|
|
|
1673
1217
|
// tls13_finished_mac calculates the MAC of the handshake transcript to verify
|
|
1674
|
-
// the integrity of the Finished message, and stores the result in
|
|
1675
|
-
// length in
|
|
1218
|
+
// the integrity of the Finished message, and stores the result in `out` and
|
|
1219
|
+
// length in `out_len`. `is_server` is true if this is for the Server Finished
|
|
1676
1220
|
// and false for the Client Finished.
|
|
1677
1221
|
bool tls13_finished_mac(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len,
|
|
1678
1222
|
bool is_server);
|
|
1679
1223
|
|
|
1680
1224
|
// tls13_derive_session_psk calculates the PSK for this session based on the
|
|
1681
|
-
// resumption master secret and
|
|
1225
|
+
// resumption master secret and `nonce`. It returns true on success, and false
|
|
1682
1226
|
// on failure.
|
|
1683
1227
|
bool tls13_derive_session_psk(SSL_SESSION *session, Span<const uint8_t> nonce,
|
|
1684
1228
|
bool is_dtls);
|
|
1685
1229
|
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1230
|
+
struct SSLImportedPSK {
|
|
1231
|
+
static constexpr bool kAllowUniquePtr = true;
|
|
1232
|
+
UniquePtr<SSLCredential> credential;
|
|
1233
|
+
Array<uint8_t> imported_identity;
|
|
1234
|
+
InplaceVector<uint8_t, SSL_MAX_MD_SIZE> ipskx;
|
|
1235
|
+
uint16_t protocol = 0;
|
|
1236
|
+
const EVP_MD *md = nullptr;
|
|
1237
|
+
};
|
|
1693
1238
|
|
|
1694
|
-
//
|
|
1695
|
-
//
|
|
1696
|
-
//
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1239
|
+
// tls13_derive_imported_psk computes the imported PSK value for `cred`, which
|
|
1240
|
+
// must be an PSK credential, for use with a target KDF of HKDF with `hkdf_md`.
|
|
1241
|
+
// `protocol` should be the wire version (i.e. `TLS1_3_VERSION` or
|
|
1242
|
+
// `DTLS1_3_VERSION`) of the target protocol. It returns the imported PSK on
|
|
1243
|
+
// success and std::nullopt on error.
|
|
1244
|
+
std::optional<SSLImportedPSK> tls13_derive_imported_psk(const SSL_HANDSHAKE *hs,
|
|
1245
|
+
SSLCredential *cred,
|
|
1246
|
+
uint16_t protocol,
|
|
1247
|
+
const EVP_MD *hkdf_md);
|
|
1248
|
+
|
|
1249
|
+
// tls13_compare_imported_psk_identity returns whether `id` is equal to `cred`'s
|
|
1250
|
+
// imported identity for the specified target protocol and target KDF. This
|
|
1251
|
+
// allows matching against PSK identities without deriving imported PSK keys.
|
|
1252
|
+
bool tls13_compare_imported_psk_identity(Span<const uint8_t> id,
|
|
1253
|
+
const SSLCredential *cred,
|
|
1254
|
+
uint16_t protocol,
|
|
1255
|
+
const EVP_MD *hkdf_md);
|
|
1256
|
+
|
|
1257
|
+
using SSLPreSharedKey = std::variant<SSLImportedPSK, UniquePtr<SSL_SESSION>>;
|
|
1258
|
+
BORINGSSL_MAKE_DELETER(SSLPreSharedKey, Delete)
|
|
1259
|
+
|
|
1260
|
+
// ssl_pre_shared_key_hash return's `psk`'s hash.
|
|
1261
|
+
const EVP_MD *ssl_pre_shared_key_hash(const SSLPreSharedKey &psk);
|
|
1262
|
+
|
|
1263
|
+
// ssl_pre_shared_key_identity return's `psk`'s identity.
|
|
1264
|
+
Span<const uint8_t> ssl_pre_shared_key_identity(const SSLPreSharedKey &psk);
|
|
1265
|
+
|
|
1266
|
+
// ssl_pre_shared_key_secret return's `psk`'s secret.
|
|
1267
|
+
Span<const uint8_t> ssl_pre_shared_key_secret(const SSLPreSharedKey &psk);
|
|
1268
|
+
|
|
1269
|
+
// tls13_psk_binder calculates the PSK binder value for `psk` over `transcript`
|
|
1270
|
+
// and `client_hello`. On success, it writes the result to `out`, sets
|
|
1271
|
+
// `*out_len` to the length, and returns true. Otherwise, it returns false.
|
|
1272
|
+
// `binders_len` must be the length of the binders field, covering all binders
|
|
1273
|
+
// and the overall length prefix, in `client_hello`.
|
|
1274
|
+
bool tls13_psk_binder(const SSL_HANDSHAKE *hs, Span<uint8_t> out,
|
|
1275
|
+
size_t *out_len, const SSLPreSharedKey &psk,
|
|
1276
|
+
const SSLTranscript &transcript,
|
|
1277
|
+
Span<const uint8_t> client_hello, size_t binders_len);
|
|
1700
1278
|
|
|
1701
1279
|
|
|
1702
1280
|
// Encrypted ClientHello.
|
|
@@ -1705,7 +1283,7 @@ struct ECHConfig {
|
|
|
1705
1283
|
static constexpr bool kAllowUniquePtr = true;
|
|
1706
1284
|
// raw contains the serialized ECHConfig.
|
|
1707
1285
|
Array<uint8_t> raw;
|
|
1708
|
-
// The following fields alias into
|
|
1286
|
+
// The following fields alias into `raw`.
|
|
1709
1287
|
Span<const uint8_t> public_key;
|
|
1710
1288
|
Span<const uint8_t> public_name;
|
|
1711
1289
|
Span<const uint8_t> cipher_suites;
|
|
@@ -1721,12 +1299,12 @@ class ECHServerConfig {
|
|
|
1721
1299
|
ECHServerConfig(const ECHServerConfig &other) = delete;
|
|
1722
1300
|
ECHServerConfig &operator=(ECHServerConfig &&) = delete;
|
|
1723
1301
|
|
|
1724
|
-
// Init parses
|
|
1302
|
+
// Init parses `ech_config` as an ECHConfig and saves a copy of `key`.
|
|
1725
1303
|
// It returns true on success and false on error.
|
|
1726
1304
|
bool Init(Span<const uint8_t> ech_config, const EVP_HPKE_KEY *key,
|
|
1727
1305
|
bool is_retry_config);
|
|
1728
1306
|
|
|
1729
|
-
// SetupContext sets up
|
|
1307
|
+
// SetupContext sets up `ctx` for a new connection, given the specified
|
|
1730
1308
|
// HPKE ciphersuite and encapsulated KEM key. It returns true on success and
|
|
1731
1309
|
// false on error. This function may only be called on an initialized object.
|
|
1732
1310
|
bool SetupContext(EVP_HPKE_CTX *ctx, uint16_t kdf_id, uint16_t aead_id,
|
|
@@ -1741,6 +1319,17 @@ class ECHServerConfig {
|
|
|
1741
1319
|
bool is_retry_config_ = false;
|
|
1742
1320
|
};
|
|
1743
1321
|
|
|
1322
|
+
class SSLECHKeys : public ssl_ech_keys_st, public bssl::RefCounted<SSLECHKeys> {
|
|
1323
|
+
public:
|
|
1324
|
+
SSLECHKeys() : RefCounted(CheckSubClass()) {}
|
|
1325
|
+
|
|
1326
|
+
Vector<UniquePtr<ECHServerConfig>> configs;
|
|
1327
|
+
|
|
1328
|
+
private:
|
|
1329
|
+
friend RefCounted;
|
|
1330
|
+
~SSLECHKeys() = default;
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1744
1333
|
enum ssl_client_hello_type_t {
|
|
1745
1334
|
ssl_client_hello_unencrypted,
|
|
1746
1335
|
ssl_client_hello_inner,
|
|
@@ -1752,10 +1341,10 @@ enum ssl_client_hello_type_t {
|
|
|
1752
1341
|
#define ECH_CLIENT_INNER 1
|
|
1753
1342
|
|
|
1754
1343
|
// ssl_decode_client_hello_inner recovers the full ClientHelloInner from the
|
|
1755
|
-
// EncodedClientHelloInner
|
|
1344
|
+
// EncodedClientHelloInner `encoded_client_hello_inner` by replacing its
|
|
1756
1345
|
// outer_extensions extension with the referenced extensions from the
|
|
1757
|
-
// ClientHelloOuter
|
|
1758
|
-
// ClientHelloInner to
|
|
1346
|
+
// ClientHelloOuter `client_hello_outer`. If successful, it writes the recovered
|
|
1347
|
+
// ClientHelloInner to `out_client_hello_inner`. It returns true on success and
|
|
1759
1348
|
// false on failure.
|
|
1760
1349
|
//
|
|
1761
1350
|
// This function is exported for fuzzing.
|
|
@@ -1764,10 +1353,10 @@ OPENSSL_EXPORT bool ssl_decode_client_hello_inner(
|
|
|
1764
1353
|
Span<const uint8_t> encoded_client_hello_inner,
|
|
1765
1354
|
const SSL_CLIENT_HELLO *client_hello_outer);
|
|
1766
1355
|
|
|
1767
|
-
// ssl_client_hello_decrypt attempts to decrypt and decode the
|
|
1768
|
-
// writes the result to
|
|
1356
|
+
// ssl_client_hello_decrypt attempts to decrypt and decode the `payload`. It
|
|
1357
|
+
// writes the result to `*out`. `payload` must point into `client_hello_outer`.
|
|
1769
1358
|
// It returns true on success and false on error. On error, it sets
|
|
1770
|
-
//
|
|
1359
|
+
// `*out_is_decrypt_error` to whether the failure was due to a bad ciphertext.
|
|
1771
1360
|
bool ssl_client_hello_decrypt(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1772
1361
|
bool *out_is_decrypt_error, Array<uint8_t> *out,
|
|
1773
1362
|
const SSL_CLIENT_HELLO *client_hello_outer,
|
|
@@ -1780,48 +1369,48 @@ bool ssl_client_hello_decrypt(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
|
1780
1369
|
size_t ssl_ech_confirmation_signal_hello_offset(const SSL *ssl);
|
|
1781
1370
|
|
|
1782
1371
|
// ssl_ech_accept_confirmation computes the server's ECH acceptance signal,
|
|
1783
|
-
// writing it to
|
|
1784
|
-
//
|
|
1785
|
-
//
|
|
1372
|
+
// writing it to `out`. The transcript portion is the concatenation of
|
|
1373
|
+
// `transcript` with `msg`. The `ECH_CONFIRMATION_SIGNAL_LEN` bytes from
|
|
1374
|
+
// `offset` in `msg` are replaced with zeros before hashing. This function
|
|
1786
1375
|
// returns true on success, and false on failure.
|
|
1787
|
-
bool ssl_ech_accept_confirmation(
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1376
|
+
bool ssl_ech_accept_confirmation(
|
|
1377
|
+
const SSL_HANDSHAKE *hs, Span<uint8_t, ECH_CONFIRMATION_SIGNAL_LEN> out,
|
|
1378
|
+
Span<const uint8_t, SSL3_RANDOM_SIZE> client_random,
|
|
1379
|
+
const SSLTranscript &transcript, bool is_hrr, Span<const uint8_t> msg,
|
|
1380
|
+
size_t offset);
|
|
1791
1381
|
|
|
1792
|
-
// ssl_is_valid_ech_public_name returns true if
|
|
1382
|
+
// ssl_is_valid_ech_public_name returns true if `public_name` is a valid ECH
|
|
1793
1383
|
// public name and false otherwise. It is exported for testing.
|
|
1794
|
-
|
|
1795
|
-
Span<const uint8_t> public_name);
|
|
1384
|
+
bool ssl_is_valid_ech_public_name(Span<const uint8_t> public_name);
|
|
1796
1385
|
|
|
1797
|
-
// ssl_is_valid_ech_config_list returns true if
|
|
1386
|
+
// ssl_is_valid_ech_config_list returns true if `ech_config_list` is a valid
|
|
1798
1387
|
// ECHConfigList structure and false otherwise.
|
|
1799
1388
|
bool ssl_is_valid_ech_config_list(Span<const uint8_t> ech_config_list);
|
|
1800
1389
|
|
|
1801
1390
|
// ssl_select_ech_config selects an ECHConfig and associated parameters to offer
|
|
1802
|
-
// on the client and updates
|
|
1391
|
+
// on the client and updates `hs`. It returns true on success, whether an
|
|
1803
1392
|
// ECHConfig was found or not, and false on internal error. On success, the
|
|
1804
|
-
// encapsulated key is written to
|
|
1393
|
+
// encapsulated key is written to `out_enc` and `*out_enc_len` is set to the
|
|
1805
1394
|
// number of bytes written. If the function did not select an ECHConfig, the
|
|
1806
1395
|
// encapsulated key is the empty string.
|
|
1807
1396
|
bool ssl_select_ech_config(SSL_HANDSHAKE *hs, Span<uint8_t> out_enc,
|
|
1808
1397
|
size_t *out_enc_len);
|
|
1809
1398
|
|
|
1810
1399
|
// ssl_ech_extension_body_length returns the length of the body of a ClientHello
|
|
1811
|
-
// ECH extension that encrypts
|
|
1812
|
-
// length
|
|
1400
|
+
// ECH extension that encrypts `in_len` bytes with `aead` and an 'enc' value of
|
|
1401
|
+
// length `enc_len`. The result does not include the four-byte extension header.
|
|
1813
1402
|
size_t ssl_ech_extension_body_length(const EVP_HPKE_AEAD *aead, size_t enc_len,
|
|
1814
1403
|
size_t in_len);
|
|
1815
1404
|
|
|
1816
1405
|
// ssl_encrypt_client_hello constructs a new ClientHelloInner, adds it to the
|
|
1817
|
-
// inner transcript, and encrypts for inclusion in the ClientHelloOuter.
|
|
1406
|
+
// inner transcript, and encrypts for inclusion in the ClientHelloOuter. `enc`
|
|
1818
1407
|
// is the encapsulated key to include in the extension. It returns true on
|
|
1819
|
-
// success and false on error. If not offering ECH,
|
|
1408
|
+
// success and false on error. If not offering ECH, `enc` is ignored and the
|
|
1820
1409
|
// function will compute a GREASE ECH extension if necessary, and otherwise
|
|
1821
1410
|
// return success while doing nothing.
|
|
1822
1411
|
//
|
|
1823
1412
|
// Encrypting the ClientHelloInner incorporates all extensions in the
|
|
1824
|
-
// ClientHelloOuter, so all other state necessary for
|
|
1413
|
+
// ClientHelloOuter, so all other state necessary for `ssl_add_client_hello`
|
|
1825
1414
|
// must already be computed.
|
|
1826
1415
|
bool ssl_encrypt_client_hello(SSL_HANDSHAKE *hs, Span<const uint8_t> enc);
|
|
1827
1416
|
|
|
@@ -1833,20 +1422,21 @@ enum class SSLCredentialType {
|
|
|
1833
1422
|
kDelegated,
|
|
1834
1423
|
kSPAKE2PlusV1Client,
|
|
1835
1424
|
kSPAKE2PlusV1Server,
|
|
1425
|
+
kPreSharedKey,
|
|
1426
|
+
kRawPublicKey,
|
|
1836
1427
|
};
|
|
1837
1428
|
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
ssl_credential_st &operator=(const ssl_credential_st &) = delete;
|
|
1429
|
+
class SSLCredential : public ssl_credential_st,
|
|
1430
|
+
public RefCounted<SSLCredential> {
|
|
1431
|
+
public:
|
|
1432
|
+
explicit SSLCredential(SSLCredentialType type);
|
|
1433
|
+
SSLCredential(const SSLCredential &) = delete;
|
|
1434
|
+
SSLCredential &operator=(const SSLCredential &) = delete;
|
|
1845
1435
|
|
|
1846
|
-
// Dup returns a copy of the credential, or nullptr on error. The
|
|
1436
|
+
// Dup returns a copy of the credential, or nullptr on error. The `ex_data`
|
|
1847
1437
|
// values are not copied. This is only used on the legacy credential, whose
|
|
1848
|
-
//
|
|
1849
|
-
|
|
1438
|
+
// `ex_data` is inaccessible.
|
|
1439
|
+
UniquePtr<SSLCredential> Dup() const;
|
|
1850
1440
|
|
|
1851
1441
|
// ClearCertAndKey erases any certificate and private key on the credential.
|
|
1852
1442
|
void ClearCertAndKey();
|
|
@@ -1855,44 +1445,43 @@ struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
|
|
|
1855
1445
|
bool UsesX509() const;
|
|
1856
1446
|
|
|
1857
1447
|
// UsesPrivateKey returns true if the credential type uses an asymmetric
|
|
1858
|
-
// private
|
|
1448
|
+
// private and public keypair.
|
|
1859
1449
|
bool UsesPrivateKey() const;
|
|
1860
1450
|
|
|
1861
1451
|
// IsComplete returns whether all required fields in the credential have been
|
|
1862
1452
|
// filled in.
|
|
1863
1453
|
bool IsComplete() const;
|
|
1864
1454
|
|
|
1865
|
-
// SetLeafCert sets the leaf certificate to
|
|
1455
|
+
// SetLeafCert sets the leaf certificate to `leaf`, leaving the remaining
|
|
1866
1456
|
// certificates unmodified. It returns true on success and false on error. If
|
|
1867
|
-
//
|
|
1457
|
+
// `discard_key_on_mismatch` is true and the private key is inconsistent with
|
|
1868
1458
|
// the new leaf certificate, it is silently discarded.
|
|
1869
|
-
bool SetLeafCert(
|
|
1870
|
-
bool discard_key_on_mismatch);
|
|
1459
|
+
bool SetLeafCert(UniquePtr<CRYPTO_BUFFER> leaf, bool discard_key_on_mismatch);
|
|
1871
1460
|
|
|
1872
1461
|
// ClearIntermediateCerts clears intermediate certificates in the certificate
|
|
1873
1462
|
// chain, while preserving the leaf.
|
|
1874
1463
|
void ClearIntermediateCerts();
|
|
1875
1464
|
|
|
1876
|
-
// AppendIntermediateCert appends
|
|
1877
|
-
// no leaf certificate configured, it leaves a placeholder null in
|
|
1465
|
+
// AppendIntermediateCert appends `cert` to the certificate chain. If there is
|
|
1466
|
+
// no leaf certificate configured, it leaves a placeholder null in `chain`. It
|
|
1878
1467
|
// returns one on success and zero on error.
|
|
1879
|
-
bool AppendIntermediateCert(
|
|
1468
|
+
bool AppendIntermediateCert(UniquePtr<CRYPTO_BUFFER> cert);
|
|
1880
1469
|
|
|
1881
|
-
// ChainContainsIssuer returns true if
|
|
1882
|
-
// issuer of any certificate in
|
|
1883
|
-
bool ChainContainsIssuer(
|
|
1470
|
+
// ChainContainsIssuer returns true if `dn` is a byte for byte match with the
|
|
1471
|
+
// issuer of any certificate in `chain`, false otherwise.
|
|
1472
|
+
bool ChainContainsIssuer(Span<const uint8_t> dn) const;
|
|
1884
1473
|
|
|
1885
1474
|
// type is the credential type and determines which other fields apply.
|
|
1886
|
-
|
|
1475
|
+
SSLCredentialType type;
|
|
1887
1476
|
|
|
1888
|
-
// pubkey is the cached public key of the credential. Unlike
|
|
1477
|
+
// pubkey is the cached public key of the credential. Unlike `privkey`, it is
|
|
1889
1478
|
// always present and is extracted from the certificate, delegated credential,
|
|
1890
1479
|
// etc.
|
|
1891
|
-
|
|
1480
|
+
UniquePtr<EVP_PKEY> pubkey;
|
|
1892
1481
|
|
|
1893
1482
|
// privkey is the private key of the credential. It may be omitted in favor of
|
|
1894
|
-
//
|
|
1895
|
-
|
|
1483
|
+
// `key_method`.
|
|
1484
|
+
UniquePtr<EVP_PKEY> privkey;
|
|
1896
1485
|
|
|
1897
1486
|
// key_method, if non-null, is a set of callbacks to call for private key
|
|
1898
1487
|
// operations.
|
|
@@ -1904,53 +1493,60 @@ struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
|
|
|
1904
1493
|
//
|
|
1905
1494
|
// In delegated credentials, this field is not configurable and is instead
|
|
1906
1495
|
// computed from the dc_cert_verify_algorithm field.
|
|
1907
|
-
|
|
1496
|
+
Array<uint16_t> sigalgs;
|
|
1908
1497
|
|
|
1909
1498
|
// chain contains the certificate chain, with the leaf at the beginning. The
|
|
1910
|
-
// first element of
|
|
1499
|
+
// first element of `chain` may be nullptr to indicate that the leaf
|
|
1911
1500
|
// certificate has not yet been set.
|
|
1912
|
-
// If
|
|
1913
|
-
// If
|
|
1914
|
-
//
|
|
1915
|
-
|
|
1501
|
+
// If `chain` != nullptr -> len(chain) >= 1
|
|
1502
|
+
// If `chain[0]` == nullptr -> len(chain) >= 2.
|
|
1503
|
+
// `chain[1..]` != nullptr
|
|
1504
|
+
UniquePtr<STACK_OF(CRYPTO_BUFFER)> chain;
|
|
1916
1505
|
|
|
1917
1506
|
// dc is the DelegatedCredential structure, if this is a delegated credential.
|
|
1918
|
-
|
|
1507
|
+
UniquePtr<CRYPTO_BUFFER> dc;
|
|
1919
1508
|
|
|
1920
1509
|
// dc_algorithm is the signature scheme of the signature over the delegated
|
|
1921
1510
|
// credential itself, made by the end-entity certificate's public key.
|
|
1922
1511
|
uint16_t dc_algorithm = 0;
|
|
1923
1512
|
|
|
1924
1513
|
// Signed certificate timestamp list to be sent to the client, if requested
|
|
1925
|
-
|
|
1514
|
+
UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
|
|
1926
1515
|
|
|
1927
1516
|
// OCSP response to be sent to the client, if requested.
|
|
1928
|
-
|
|
1517
|
+
UniquePtr<CRYPTO_BUFFER> ocsp_response;
|
|
1929
1518
|
|
|
1930
1519
|
// SPAKE2+-specific information.
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1520
|
+
Array<uint8_t> pake_context;
|
|
1521
|
+
Array<uint8_t> client_identity;
|
|
1522
|
+
Array<uint8_t> server_identity;
|
|
1523
|
+
Array<uint8_t> password_verifier_w0;
|
|
1524
|
+
Array<uint8_t> password_verifier_w1; // server-only
|
|
1525
|
+
Array<uint8_t> registration_record; // client-only
|
|
1937
1526
|
mutable std::atomic<uint32_t> pake_limit;
|
|
1938
1527
|
|
|
1528
|
+
// External-PSK-specific information. epskx is the HKDF-Extract-ed value, from
|
|
1529
|
+
// Section 5.1 of RFC 9258.
|
|
1530
|
+
Array<uint8_t> epskx;
|
|
1531
|
+
Array<uint8_t> epsk_id;
|
|
1532
|
+
const EVP_MD *epsk_md = nullptr;
|
|
1533
|
+
Array<uint8_t> epsk_context;
|
|
1534
|
+
|
|
1939
1535
|
// Checks whether there are still permitted PAKE attempts remaining, without
|
|
1940
1536
|
// changing the counter.
|
|
1941
1537
|
bool HasPAKEAttempts() const;
|
|
1942
1538
|
|
|
1943
|
-
// Atomically decrement
|
|
1944
|
-
//
|
|
1539
|
+
// Atomically decrement `pake_limit`. Return true if successful and false if
|
|
1540
|
+
// `pake_limit` is already zero.
|
|
1945
1541
|
bool ClaimPAKEAttempt() const;
|
|
1946
1542
|
|
|
1947
|
-
// Atomically increment
|
|
1948
|
-
//
|
|
1543
|
+
// Atomically increment `pake_limit`. This must be paired with a
|
|
1544
|
+
// `ClaimPAKEAttempt` call.
|
|
1949
1545
|
void RestorePAKEAttempt() const;
|
|
1950
1546
|
|
|
1951
1547
|
// trust_anchor_id, if non-empty, is the trust anchor ID for the root of the
|
|
1952
|
-
// chain in
|
|
1953
|
-
|
|
1548
|
+
// chain in `chain`.
|
|
1549
|
+
Array<uint8_t> trust_anchor_id;
|
|
1954
1550
|
|
|
1955
1551
|
CRYPTO_EX_DATA ex_data;
|
|
1956
1552
|
|
|
@@ -1963,13 +1559,11 @@ struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
|
|
|
1963
1559
|
|
|
1964
1560
|
private:
|
|
1965
1561
|
friend RefCounted;
|
|
1966
|
-
~
|
|
1562
|
+
~SSLCredential();
|
|
1967
1563
|
};
|
|
1968
1564
|
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
// ssl_get_full_credential_list computes |hs|'s full credential list, including
|
|
1972
|
-
// the legacy credential. On success, it writes it to |*out| and returns true.
|
|
1565
|
+
// ssl_get_full_credential_list computes `hs`'s full credential list, including
|
|
1566
|
+
// the legacy credential. On success, it writes it to `*out` and returns true.
|
|
1973
1567
|
// Otherwise, it returns false. The credential list may be empty, in which case
|
|
1974
1568
|
// this function will successfully output an empty array.
|
|
1975
1569
|
//
|
|
@@ -1977,17 +1571,68 @@ BSSL_NAMESPACE_BEGIN
|
|
|
1977
1571
|
// intended to be used for certificate-based credentials. It runs the
|
|
1978
1572
|
// auto-chaining logic as part of finishing the legacy credential. Other uses of
|
|
1979
1573
|
// the credential list (e.g. PAKE credentials) should iterate over
|
|
1980
|
-
//
|
|
1574
|
+
// `hs->config->cert->credentials`.
|
|
1981
1575
|
//
|
|
1982
|
-
// The pointers in the result are only valid until
|
|
1576
|
+
// The pointers in the result are only valid until `hs` is next mutated.
|
|
1983
1577
|
bool ssl_get_full_credential_list(SSL_HANDSHAKE *hs,
|
|
1984
|
-
Array<
|
|
1578
|
+
Array<SSLCredential *> *out);
|
|
1985
1579
|
|
|
1986
|
-
// ssl_credential_matches_requested_issuers returns true if
|
|
1987
|
-
// usable match for any requested issuers in
|
|
1580
|
+
// ssl_credential_matches_requested_issuers returns true if `cred` is a
|
|
1581
|
+
// usable match for any requested issuers in `hs`, and false with an error
|
|
1988
1582
|
// otherwise.
|
|
1989
1583
|
bool ssl_credential_matches_requested_issuers(SSL_HANDSHAKE *hs,
|
|
1990
|
-
const
|
|
1584
|
+
const SSLCredential *cred);
|
|
1585
|
+
|
|
1586
|
+
// ssl_check_tls13_credential_ignoring_issuer returns true if `cred` is usable
|
|
1587
|
+
// as the certificate in a TLS 1.3 handshake, ignoring the issuer check.
|
|
1588
|
+
// `allowed_cert_types` is a nonempty set of cert types (`TLSEXT_cert_type_*`
|
|
1589
|
+
// values) that are usable; `cred` must match one of these types.
|
|
1590
|
+
// `out_sigalg` will be set to a matching signature algorithm if true is
|
|
1591
|
+
// returned.
|
|
1592
|
+
bool ssl_check_tls13_credential_ignoring_issuer(
|
|
1593
|
+
SSL_HANDSHAKE *hs, Span<const uint8_t> allowed_cert_types,
|
|
1594
|
+
const SSLCredential *cred, uint16_t *out_sigalg);
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
// Client certificate type & Server certificate type.
|
|
1598
|
+
|
|
1599
|
+
inline constexpr uint8_t kAllCertTypes[] = {
|
|
1600
|
+
TLSEXT_cert_type_x509,
|
|
1601
|
+
TLSEXT_cert_type_rpk,
|
|
1602
|
+
};
|
|
1603
|
+
inline constexpr size_t kNumCertTypes = std::size(kAllCertTypes);
|
|
1604
|
+
inline constexpr uint8_t kDefaultCertType = TLSEXT_cert_type_x509;
|
|
1605
|
+
|
|
1606
|
+
// ssl_credential_type_to_cert_type returns the certificate type value
|
|
1607
|
+
// (`TLSEXT_cert_type_*` value) corresponding to `cred_type`, or else
|
|
1608
|
+
// std::nullopt.
|
|
1609
|
+
std::optional<uint8_t> ssl_credential_type_to_cert_type(
|
|
1610
|
+
SSLCredentialType cred_type);
|
|
1611
|
+
|
|
1612
|
+
// ssl_setup_client_certificate_type computes the client cert types to offer, as
|
|
1613
|
+
// a client, and saves them in `hs`. The values are used later when checking
|
|
1614
|
+
// that the server responded with a valid value.
|
|
1615
|
+
void ssl_setup_client_certificate_type(SSL_HANDSHAKE *hs);
|
|
1616
|
+
|
|
1617
|
+
// ssl_negotiate_client_certificate_type, for a server, negotiates the
|
|
1618
|
+
// client_certificate_type extension, if applicable. It updates
|
|
1619
|
+
// `hs->peer_cert_type` appropriately and returns true if negotiation was
|
|
1620
|
+
// successful or not necessary (i.e. if we are not requesting a cert from the
|
|
1621
|
+
// client), or it returns false and sets `*out_alert` to an alert on error.
|
|
1622
|
+
bool ssl_negotiate_client_certificate_type(
|
|
1623
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
1624
|
+
const SSL_CLIENT_HELLO *client_hello);
|
|
1625
|
+
|
|
1626
|
+
// ssl_get_allowed_server_cert_types, for a server, returns the cert types that
|
|
1627
|
+
// may be used based on the server_certificate_type extension in the
|
|
1628
|
+
// ClientHello. It returns a nonempty list of allowable certificate types. By
|
|
1629
|
+
// default, if the client did not send the extension, X.509 certificates are
|
|
1630
|
+
// allowed. The returned cert types may include unrecognized values. Returns
|
|
1631
|
+
// nullopt and sets `out_alert` on failure.
|
|
1632
|
+
std::optional<Span<const uint8_t>> ssl_get_allowed_server_cert_types(
|
|
1633
|
+
const SSL_HANDSHAKE *hs, const SSL_CLIENT_HELLO *client_hello,
|
|
1634
|
+
uint8_t *out_alert);
|
|
1635
|
+
|
|
1991
1636
|
|
|
1992
1637
|
// Handshake functions.
|
|
1993
1638
|
|
|
@@ -2079,7 +1724,7 @@ enum handback_t {
|
|
|
2079
1724
|
};
|
|
2080
1725
|
|
|
2081
1726
|
// SSL_HANDSHAKE_HINTS contains handshake hints for a connection. See
|
|
2082
|
-
//
|
|
1727
|
+
// `SSL_request_handshake_hints` and related functions.
|
|
2083
1728
|
struct SSL_HANDSHAKE_HINTS {
|
|
2084
1729
|
static constexpr bool kAllowUniquePtr = true;
|
|
2085
1730
|
|
|
@@ -2124,30 +1769,30 @@ struct SSL_HANDSHAKE {
|
|
|
2124
1769
|
~SSL_HANDSHAKE();
|
|
2125
1770
|
static constexpr bool kAllowUniquePtr = true;
|
|
2126
1771
|
|
|
2127
|
-
// ssl is a non-owning pointer to the parent
|
|
1772
|
+
// ssl is a non-owning pointer to the parent `SSL` object.
|
|
2128
1773
|
SSL *ssl;
|
|
2129
1774
|
|
|
2130
1775
|
// config is a non-owning pointer to the handshake configuration.
|
|
2131
1776
|
SSL_CONFIG *config;
|
|
2132
1777
|
|
|
2133
1778
|
// wait contains the operation the handshake is currently blocking on or
|
|
2134
|
-
//
|
|
1779
|
+
// `ssl_hs_ok` if none.
|
|
2135
1780
|
enum ssl_hs_wait_t wait = ssl_hs_ok;
|
|
2136
1781
|
|
|
2137
1782
|
// state is the internal state for the TLS 1.2 and below handshake. Its
|
|
2138
|
-
// values depend on
|
|
1783
|
+
// values depend on `do_handshake` but the starting state is always zero.
|
|
2139
1784
|
int state = 0;
|
|
2140
1785
|
|
|
2141
1786
|
// tls13_state is the internal state for the TLS 1.3 handshake. Its values
|
|
2142
|
-
// depend on
|
|
1787
|
+
// depend on `do_handshake` but the starting state is always zero.
|
|
2143
1788
|
int tls13_state = 0;
|
|
2144
1789
|
|
|
2145
1790
|
// min_version is the minimum accepted protocol version, taking account both
|
|
2146
|
-
//
|
|
1791
|
+
// `SSL_OP_NO_*` and `SSL_CTX_set_min_proto_version` APIs.
|
|
2147
1792
|
uint16_t min_version = 0;
|
|
2148
1793
|
|
|
2149
1794
|
// max_version is the maximum accepted protocol version, taking account both
|
|
2150
|
-
//
|
|
1795
|
+
// `SSL_OP_NO_*` and `SSL_CTX_set_max_proto_version` APIs.
|
|
2151
1796
|
uint16_t max_version = 0;
|
|
2152
1797
|
|
|
2153
1798
|
InplaceVector<uint8_t, SSL_MAX_MD_SIZE> secret;
|
|
@@ -2160,11 +1805,11 @@ struct SSL_HANDSHAKE {
|
|
|
2160
1805
|
|
|
2161
1806
|
// GetClientHello, on the server, returns either the normal ClientHello
|
|
2162
1807
|
// message or the ClientHelloInner if it has been serialized to
|
|
2163
|
-
//
|
|
1808
|
+
// `ech_client_hello_buf`. This function should only be called when the
|
|
2164
1809
|
// current message is a ClientHello. It returns true on success and false on
|
|
2165
1810
|
// error.
|
|
2166
1811
|
//
|
|
2167
|
-
// Note that fields of the returned
|
|
1812
|
+
// Note that fields of the returned `out_msg` and `out_client_hello` point
|
|
2168
1813
|
// into a handshake-owned buffer, so their lifetimes should not exceed this
|
|
2169
1814
|
// SSL_HANDSHAKE.
|
|
2170
1815
|
bool GetClientHello(SSLMessage *out_msg, SSL_CLIENT_HELLO *out_client_hello);
|
|
@@ -2174,28 +1819,41 @@ struct SSL_HANDSHAKE {
|
|
|
2174
1819
|
// in extensions.cc. Each bit is set if that extension was sent in a
|
|
2175
1820
|
// ClientHello. It's not used by servers.
|
|
2176
1821
|
uint32_t sent = 0;
|
|
2177
|
-
// received is a bitset, like
|
|
1822
|
+
// received is a bitset, like `sent`, but is used by servers to record
|
|
2178
1823
|
// which extensions were received from a client.
|
|
2179
1824
|
uint32_t received;
|
|
2180
1825
|
} extensions;
|
|
2181
1826
|
|
|
2182
|
-
// inner_extensions_sent, on clients that offer ECH, is
|
|
1827
|
+
// inner_extensions_sent, on clients that offer ECH, is `extensions.sent` for
|
|
2183
1828
|
// the ClientHelloInner.
|
|
2184
1829
|
uint32_t inner_extensions_sent = 0;
|
|
2185
1830
|
|
|
2186
|
-
//
|
|
1831
|
+
// early_data_written is the amount of early data that has been written by the
|
|
1832
|
+
// record layer.
|
|
1833
|
+
uint32_t early_data_written = 0;
|
|
1834
|
+
|
|
1835
|
+
// error, if `wait` is `ssl_hs_error`, is the error the handshake failed on.
|
|
2187
1836
|
UniquePtr<ERR_SAVE_STATE> error;
|
|
2188
1837
|
|
|
2189
|
-
// key_shares are the current key exchange instances
|
|
2190
|
-
//
|
|
2191
|
-
|
|
2192
|
-
|
|
1838
|
+
// key_shares are the current key exchange instances, in preference order. Any
|
|
1839
|
+
// members of this vector must be non-null.
|
|
1840
|
+
InplaceVector<UniquePtr<SSLKeyShare>, kNumNamedGroups> key_shares;
|
|
1841
|
+
|
|
1842
|
+
// pre_shared_keys are the pre-shared keys to be offered by the client.
|
|
1843
|
+
Vector<SSLPreSharedKey> pre_shared_keys;
|
|
1844
|
+
|
|
1845
|
+
// pre_shared_key is the selected pre-shared key on the server.
|
|
1846
|
+
UniquePtr<SSLPreSharedKey> pre_shared_key;
|
|
1847
|
+
|
|
1848
|
+
// selected_psk_index is the index of the selected pre-shared key on the
|
|
1849
|
+
// server.
|
|
1850
|
+
std::optional<uint16_t> selected_psk_index;
|
|
2193
1851
|
|
|
2194
1852
|
// transcript is the current handshake transcript.
|
|
2195
1853
|
SSLTranscript transcript;
|
|
2196
1854
|
|
|
2197
1855
|
// inner_transcript, on the client, is the handshake transcript for the
|
|
2198
|
-
// ClientHelloInner handshake. It is moved to
|
|
1856
|
+
// ClientHelloInner handshake. It is moved to `transcript` if the server
|
|
2199
1857
|
// accepts ECH.
|
|
2200
1858
|
SSLTranscript inner_transcript;
|
|
2201
1859
|
|
|
@@ -2251,18 +1909,18 @@ struct SSL_HANDSHAKE {
|
|
|
2251
1909
|
Array<uint8_t> peer_key;
|
|
2252
1910
|
|
|
2253
1911
|
// extension_permutation is the permutation to apply to ClientHello
|
|
2254
|
-
// extensions. It maps indices into the
|
|
1912
|
+
// extensions. It maps indices into the `kExtensions` table into other
|
|
2255
1913
|
// indices.
|
|
2256
1914
|
Array<uint8_t> extension_permutation;
|
|
2257
1915
|
|
|
2258
1916
|
// cert_compression_alg_id, for a server, contains the negotiated certificate
|
|
2259
1917
|
// compression algorithm for this client. It is only valid if
|
|
2260
|
-
//
|
|
1918
|
+
// `cert_compression_negotiated` is true.
|
|
2261
1919
|
uint16_t cert_compression_alg_id;
|
|
2262
1920
|
|
|
2263
1921
|
// ech_hpke_ctx is the HPKE context used in ECH. On the server, it is
|
|
2264
|
-
// initialized if
|
|
2265
|
-
// initialized if
|
|
1922
|
+
// initialized if `ech_status` is `ssl_ech_accepted`. On the client, it is
|
|
1923
|
+
// initialized if `selected_ech_config` is not nullptr.
|
|
2266
1924
|
ScopedEVP_HPKE_CTX ech_hpke_ctx;
|
|
2267
1925
|
|
|
2268
1926
|
// server_params, in a TLS 1.2 server, stores the ServerKeyExchange
|
|
@@ -2289,8 +1947,8 @@ struct SSL_HANDSHAKE {
|
|
|
2289
1947
|
Array<uint8_t> peer_available_trust_anchors;
|
|
2290
1948
|
|
|
2291
1949
|
// cached_x509_ca_names contains a cache of parsed versions of the elements of
|
|
2292
|
-
//
|
|
2293
|
-
//
|
|
1950
|
+
// `ca_names`. This pointer is left non-owning so only
|
|
1951
|
+
// `ssl_crypto_x509_method` needs to link against crypto/x509.
|
|
2294
1952
|
STACK_OF(X509_NAME) *cached_x509_ca_names = nullptr;
|
|
2295
1953
|
|
|
2296
1954
|
// certificate_types, on the client, contains the set of certificate types
|
|
@@ -2298,7 +1956,7 @@ struct SSL_HANDSHAKE {
|
|
|
2298
1956
|
Array<uint8_t> certificate_types;
|
|
2299
1957
|
|
|
2300
1958
|
// credential is the credential we are using for the handshake.
|
|
2301
|
-
UniquePtr<
|
|
1959
|
+
UniquePtr<SSLCredential> credential;
|
|
2302
1960
|
|
|
2303
1961
|
// peer_pubkey is the public key parsed from the peer's leaf certificate.
|
|
2304
1962
|
UniquePtr<EVP_PKEY> peer_pubkey;
|
|
@@ -2308,16 +1966,16 @@ struct SSL_HANDSHAKE {
|
|
|
2308
1966
|
UniquePtr<SSL_SESSION> new_session;
|
|
2309
1967
|
|
|
2310
1968
|
// early_session is the session corresponding to the current 0-RTT state on
|
|
2311
|
-
// the client if
|
|
1969
|
+
// the client if `in_early_data` is true.
|
|
2312
1970
|
UniquePtr<SSL_SESSION> early_session;
|
|
2313
1971
|
|
|
2314
1972
|
// ssl_ech_keys, for servers, is the set of ECH keys to use with this
|
|
2315
|
-
// handshake. This is copied from
|
|
2316
|
-
//
|
|
2317
|
-
UniquePtr<
|
|
1973
|
+
// handshake. This is copied from `SSL_CTX` to ensure consistent behavior as
|
|
1974
|
+
// `SSL_CTX` rotates keys.
|
|
1975
|
+
UniquePtr<SSLECHKeys> ech_keys;
|
|
2318
1976
|
|
|
2319
1977
|
// selected_ech_config, for clients, is the ECHConfig the client uses to offer
|
|
2320
|
-
// ECH, or nullptr if ECH is not being offered. If non-NULL,
|
|
1978
|
+
// ECH, or nullptr if ECH is not being offered. If non-NULL, `ech_hpke_ctx`
|
|
2321
1979
|
// will be initialized.
|
|
2322
1980
|
UniquePtr<ECHConfig> selected_ech_config;
|
|
2323
1981
|
|
|
@@ -2328,7 +1986,7 @@ struct SSL_HANDSHAKE {
|
|
|
2328
1986
|
Array<uint8_t> key_block;
|
|
2329
1987
|
|
|
2330
1988
|
// hints contains the handshake hints for this connection. If
|
|
2331
|
-
//
|
|
1989
|
+
// `hints_requested` is true, this field is non-null and contains the pending
|
|
2332
1990
|
// hints to filled as the predicted handshake progresses. Otherwise, this
|
|
2333
1991
|
// field, if non-null, contains hints configured by the caller and will
|
|
2334
1992
|
// influence the handshake on match.
|
|
@@ -2408,16 +2066,16 @@ struct SSL_HANDSHAKE {
|
|
|
2408
2066
|
|
|
2409
2067
|
// handback indicates that a server should pause the handshake after
|
|
2410
2068
|
// finishing operations that require private key material, in such a way that
|
|
2411
|
-
//
|
|
2412
|
-
//
|
|
2069
|
+
// `SSL_get_error` returns `SSL_ERROR_HANDBACK`. It is set by
|
|
2070
|
+
// `SSL_apply_handoff`.
|
|
2413
2071
|
bool handback : 1;
|
|
2414
2072
|
|
|
2415
2073
|
// hints_requested indicates the caller has requested handshake hints. Only
|
|
2416
2074
|
// the first round-trip of the handshake will complete, after which the
|
|
2417
|
-
//
|
|
2075
|
+
// `hints` structure can be serialized.
|
|
2418
2076
|
bool hints_requested : 1;
|
|
2419
2077
|
|
|
2420
|
-
// cert_compression_negotiated is true iff
|
|
2078
|
+
// cert_compression_negotiated is true iff `cert_compression_alg_id` is valid.
|
|
2421
2079
|
bool cert_compression_negotiated : 1;
|
|
2422
2080
|
|
|
2423
2081
|
// apply_jdk11_workaround is true if the peer is probably a JDK 11 client
|
|
@@ -2451,10 +2109,6 @@ struct SSL_HANDSHAKE {
|
|
|
2451
2109
|
// record layer.
|
|
2452
2110
|
uint16_t early_data_read = 0;
|
|
2453
2111
|
|
|
2454
|
-
// early_data_written is the amount of early data that has been written by the
|
|
2455
|
-
// record layer.
|
|
2456
|
-
uint16_t early_data_written = 0;
|
|
2457
|
-
|
|
2458
2112
|
// signature_algorithm is the signature algorithm to be used in signing with
|
|
2459
2113
|
// the selected credential, or zero if not applicable or not yet selected.
|
|
2460
2114
|
uint16_t signature_algorithm = 0;
|
|
@@ -2479,6 +2133,29 @@ struct SSL_HANDSHAKE {
|
|
|
2479
2133
|
|
|
2480
2134
|
// pake_verifier is the PAKE context for a server.
|
|
2481
2135
|
UniquePtr<spake2plus::Verifier> pake_verifier;
|
|
2136
|
+
|
|
2137
|
+
// offered_client_cert_types, for a client, is a list of client certificate
|
|
2138
|
+
// types (`TLSEXT_cert_type_*` values) that were sent in the
|
|
2139
|
+
// client_certificate_type extension in the ClientHello.
|
|
2140
|
+
InplaceVector<uint8_t, kNumCertTypes> offered_client_cert_types;
|
|
2141
|
+
|
|
2142
|
+
// peer_cert_type, is the cert type expected from the peer in this handshake,
|
|
2143
|
+
// negotiated based on server_certificate_type extensions (for a client) or
|
|
2144
|
+
// client_certificate_type extensions (for a server), or set to X.509
|
|
2145
|
+
// certificates by default (if the peer didn't send the extension).
|
|
2146
|
+
// This is not used in resumption.
|
|
2147
|
+
uint8_t peer_cert_type = kDefaultCertType;
|
|
2148
|
+
|
|
2149
|
+
// client_cert_type, for a client, is the cert type for this side of the
|
|
2150
|
+
// handshake to present to the peer (server) in a Certificate message,
|
|
2151
|
+
// negotiated based on client_certificate_type extensions.
|
|
2152
|
+
// This is not used in resumption.
|
|
2153
|
+
uint8_t client_cert_type = kDefaultCertType;
|
|
2154
|
+
|
|
2155
|
+
// client_requested_server_cert_padding_size, for a server, is the number of
|
|
2156
|
+
// bytes that the client requested we send, or nullopt if the client did not
|
|
2157
|
+
// request any padding.
|
|
2158
|
+
std::optional<uint16_t> client_requested_server_padding_size;
|
|
2482
2159
|
};
|
|
2483
2160
|
|
|
2484
2161
|
// kMaxTickets is the maximum number of tickets to send immediately after the
|
|
@@ -2488,16 +2165,16 @@ constexpr size_t kMaxTickets = 16;
|
|
|
2488
2165
|
|
|
2489
2166
|
UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSL *ssl);
|
|
2490
2167
|
|
|
2491
|
-
// ssl_check_message_type checks if
|
|
2168
|
+
// ssl_check_message_type checks if `msg` has type `type`. If so it returns
|
|
2492
2169
|
// one. Otherwise, it sends an alert and returns zero.
|
|
2493
2170
|
bool ssl_check_message_type(SSL *ssl, const SSLMessage &msg, int type);
|
|
2494
2171
|
|
|
2495
2172
|
// ssl_run_handshake runs the TLS handshake. It returns one on success and <= 0
|
|
2496
|
-
// on error. It sets
|
|
2173
|
+
// on error. It sets `out_early_return` to one if we've completed the handshake
|
|
2497
2174
|
// early.
|
|
2498
2175
|
int ssl_run_handshake(SSL_HANDSHAKE *hs, bool *out_early_return);
|
|
2499
2176
|
|
|
2500
|
-
// The following are implementations of
|
|
2177
|
+
// The following are implementations of `do_handshake` for the client and
|
|
2501
2178
|
// server.
|
|
2502
2179
|
enum ssl_hs_wait_t ssl_client_handshake(SSL_HANDSHAKE *hs);
|
|
2503
2180
|
enum ssl_hs_wait_t ssl_server_handshake(SSL_HANDSHAKE *hs);
|
|
@@ -2511,8 +2188,8 @@ const char *ssl_server_handshake_state(SSL_HANDSHAKE *hs);
|
|
|
2511
2188
|
const char *tls13_client_handshake_state(SSL_HANDSHAKE *hs);
|
|
2512
2189
|
const char *tls13_server_handshake_state(SSL_HANDSHAKE *hs);
|
|
2513
2190
|
|
|
2514
|
-
// tls13_add_key_update queues a KeyUpdate message on
|
|
2515
|
-
// be one of
|
|
2191
|
+
// tls13_add_key_update queues a KeyUpdate message on `ssl`. `request_type` must
|
|
2192
|
+
// be one of `SSL_KEY_UPDATE_REQUESTED` or `SSL_KEY_UPDATE_NOT_REQUESTED`.
|
|
2516
2193
|
bool tls13_add_key_update(SSL *ssl, int request_type);
|
|
2517
2194
|
|
|
2518
2195
|
// tls13_post_handshake processes a post-handshake message. It returns true on
|
|
@@ -2523,35 +2200,51 @@ bool tls13_process_certificate(SSL_HANDSHAKE *hs, const SSLMessage &msg,
|
|
|
2523
2200
|
bool allow_anonymous);
|
|
2524
2201
|
bool tls13_process_certificate_verify(SSL_HANDSHAKE *hs, const SSLMessage &msg);
|
|
2525
2202
|
|
|
2526
|
-
// tls13_process_finished processes
|
|
2527
|
-
// peer. If
|
|
2528
|
-
//
|
|
2203
|
+
// tls13_process_finished processes `msg` as a Finished message from the
|
|
2204
|
+
// peer. If `use_saved_value` is true, the verify_data is compared against
|
|
2205
|
+
// `hs->expected_client_finished` rather than computed fresh.
|
|
2529
2206
|
bool tls13_process_finished(SSL_HANDSHAKE *hs, const SSLMessage &msg,
|
|
2530
2207
|
bool use_saved_value);
|
|
2531
2208
|
|
|
2532
2209
|
bool tls13_add_certificate(SSL_HANDSHAKE *hs);
|
|
2533
2210
|
|
|
2534
2211
|
// tls13_add_certificate_verify adds a TLS 1.3 CertificateVerify message to the
|
|
2535
|
-
// handshake. If it returns
|
|
2212
|
+
// handshake. If it returns `ssl_private_key_retry`, it should be called again
|
|
2536
2213
|
// to retry when the signing operation is completed.
|
|
2537
2214
|
enum ssl_private_key_result_t tls13_add_certificate_verify(SSL_HANDSHAKE *hs);
|
|
2538
2215
|
|
|
2539
2216
|
bool tls13_add_finished(SSL_HANDSHAKE *hs);
|
|
2540
2217
|
bool tls13_process_new_session_ticket(SSL *ssl, const SSLMessage &msg);
|
|
2541
|
-
|
|
2542
|
-
CBS *body);
|
|
2218
|
+
UniquePtr<SSL_SESSION> tls13_create_session_with_ticket(SSL *ssl, CBS *body);
|
|
2543
2219
|
|
|
2544
2220
|
// ssl_setup_extension_permutation computes a ClientHello extension permutation
|
|
2545
|
-
// for
|
|
2221
|
+
// for `hs`, if applicable. It returns true on success and false on error.
|
|
2546
2222
|
bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs);
|
|
2547
2223
|
|
|
2548
|
-
//
|
|
2549
|
-
// returns true on success and false on failure.
|
|
2550
|
-
|
|
2551
|
-
|
|
2224
|
+
// ssl_setup_pre_shared_keys computes the offered client PSKs and saves them in
|
|
2225
|
+
// `hs`. It returns true on success and false on failure.
|
|
2226
|
+
bool ssl_setup_pre_shared_keys(SSL_HANDSHAKE *hs);
|
|
2227
|
+
|
|
2228
|
+
// ssl_setup_key_shares computes client key shares and saves them in `hs`. It
|
|
2229
|
+
// returns true on success and false on failure. In order of precedence:
|
|
2230
|
+
//
|
|
2231
|
+
// - If `override_group_id` is non-zero, it offers a single key share of the
|
|
2232
|
+
// specified group.
|
|
2233
|
+
//
|
|
2234
|
+
// - If a group can be predicted on the basis of a server hint set via
|
|
2235
|
+
// `SSL_set1_server_supported_groups_hint`, a single key share of that group
|
|
2236
|
+
// is sent.
|
|
2237
|
+
//
|
|
2238
|
+
// - If any number of key shares (including zero) were previously specified by
|
|
2239
|
+
// the caller via `SSL_set1_client_key_shares`, those are used.
|
|
2240
|
+
//
|
|
2241
|
+
// - Otherwise, it selects the first supported group and may select a second if
|
|
2242
|
+
// at most one of the two is a post-quantum group.
|
|
2243
|
+
//
|
|
2244
|
+
// GREASE will be included if enabled, when `override_group_id` is zero.
|
|
2552
2245
|
bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id);
|
|
2553
2246
|
|
|
2554
|
-
// ssl_setup_pake_shares computes the client PAKE shares and saves them in
|
|
2247
|
+
// ssl_setup_pake_shares computes the client PAKE shares and saves them in `hs`.
|
|
2555
2248
|
// It returns true on success and false on failure.
|
|
2556
2249
|
bool ssl_setup_pake_shares(SSL_HANDSHAKE *hs);
|
|
2557
2250
|
|
|
@@ -2569,22 +2262,43 @@ bool ssl_ext_pake_parse_serverhello(SSL_HANDSHAKE *hs,
|
|
|
2569
2262
|
Array<uint8_t> *out_secret,
|
|
2570
2263
|
uint8_t *out_alert, CBS *contents);
|
|
2571
2264
|
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2265
|
+
struct SSLOfferedPSK {
|
|
2266
|
+
CBS identity, binder;
|
|
2267
|
+
uint32_t obfuscated_ticket_age;
|
|
2268
|
+
};
|
|
2269
|
+
|
|
2270
|
+
struct SSLOfferedPSKs {
|
|
2271
|
+
CBS identities, binders;
|
|
2272
|
+
std::optional<SSLOfferedPSK> Next();
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2275
|
+
const SSLPreSharedKey *ssl_ext_pre_shared_key_parse_serverhello(
|
|
2276
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert, CBS *contents);
|
|
2277
|
+
std::optional<SSLOfferedPSKs> ssl_ext_pre_shared_key_parse_clienthello(
|
|
2278
|
+
SSL_HANDSHAKE *hs, uint8_t *out_alert, const SSL_CLIENT_HELLO *client_hello,
|
|
2279
|
+
CBS *contents);
|
|
2280
|
+
|
|
2281
|
+
// ssl_verify_psk_binder verifies `client_hello` has a valid binder for `psk`.
|
|
2282
|
+
// The binder is computed with `client_hello` and `hs`'s transcript, which
|
|
2283
|
+
// should not have `client_hello` in it. On success, it returns true. Otherwise,
|
|
2284
|
+
// it returns false and sets `*out_alert` to an alert to send.
|
|
2285
|
+
//
|
|
2286
|
+
// This function additionally saves the index where `psk` was found in `hs`. It
|
|
2287
|
+
// must be called before `ssl_ext_pre_shared_key_add_serverhello`.
|
|
2288
|
+
bool ssl_verify_psk_binder(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
2289
|
+
const SSLPreSharedKey &psk,
|
|
2290
|
+
const SSL_CLIENT_HELLO &client_hello);
|
|
2291
|
+
|
|
2579
2292
|
bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
|
|
2580
2293
|
|
|
2581
|
-
|
|
2294
|
+
|
|
2295
|
+
// ssl_is_sct_list_valid does a shallow parse of the SCT list in `contents` and
|
|
2582
2296
|
// returns whether it's valid.
|
|
2583
2297
|
bool ssl_is_sct_list_valid(const CBS *contents);
|
|
2584
2298
|
|
|
2585
|
-
// ssl_write_client_hello_without_extensions writes a ClientHello to
|
|
2586
|
-
// up to the extensions field.
|
|
2587
|
-
// write. If
|
|
2299
|
+
// ssl_write_client_hello_without_extensions writes a ClientHello to `out`,
|
|
2300
|
+
// up to the extensions field. `type` determines the type of ClientHello to
|
|
2301
|
+
// write. If `omit_session_id` is true, the session ID is empty.
|
|
2588
2302
|
bool ssl_write_client_hello_without_extensions(const SSL_HANDSHAKE *hs,
|
|
2589
2303
|
CBB *cbb,
|
|
2590
2304
|
ssl_client_hello_type_t type,
|
|
@@ -2604,9 +2318,9 @@ struct ParsedServerHello {
|
|
|
2604
2318
|
CBS extensions;
|
|
2605
2319
|
};
|
|
2606
2320
|
|
|
2607
|
-
// ssl_parse_server_hello parses
|
|
2608
|
-
// the result to
|
|
2609
|
-
//
|
|
2321
|
+
// ssl_parse_server_hello parses `msg` as a ServerHello. On success, it writes
|
|
2322
|
+
// the result to `*out` and returns true. Otherwise, it returns false and sets
|
|
2323
|
+
// `*out_alert` to an alert to send to the peer.
|
|
2610
2324
|
bool ssl_parse_server_hello(ParsedServerHello *out, uint8_t *out_alert,
|
|
2611
2325
|
const SSLMessage &msg);
|
|
2612
2326
|
|
|
@@ -2617,34 +2331,34 @@ enum ssl_cert_verify_context_t {
|
|
|
2617
2331
|
};
|
|
2618
2332
|
|
|
2619
2333
|
// tls13_get_cert_verify_signature_input generates the message to be signed for
|
|
2620
|
-
// TLS 1.3's CertificateVerify message.
|
|
2621
|
-
// type of signature. It sets
|
|
2334
|
+
// TLS 1.3's CertificateVerify message. `cert_verify_context` determines the
|
|
2335
|
+
// type of signature. It sets `*out` to a newly allocated buffer containing the
|
|
2622
2336
|
// result. This function returns true on success and false on failure.
|
|
2623
2337
|
bool tls13_get_cert_verify_signature_input(
|
|
2624
2338
|
SSL_HANDSHAKE *hs, Array<uint8_t> *out,
|
|
2625
2339
|
enum ssl_cert_verify_context_t cert_verify_context);
|
|
2626
2340
|
|
|
2627
|
-
// ssl_is_valid_alpn_list returns whether
|
|
2341
|
+
// ssl_is_valid_alpn_list returns whether `in` is a valid ALPN protocol list.
|
|
2628
2342
|
bool ssl_is_valid_alpn_list(Span<const uint8_t> in);
|
|
2629
2343
|
|
|
2630
|
-
// ssl_is_alpn_protocol_allowed returns whether
|
|
2631
|
-
// selection for
|
|
2344
|
+
// ssl_is_alpn_protocol_allowed returns whether `protocol` is a valid server
|
|
2345
|
+
// selection for `hs->ssl`'s client preferences.
|
|
2632
2346
|
bool ssl_is_alpn_protocol_allowed(const SSL_HANDSHAKE *hs,
|
|
2633
2347
|
Span<const uint8_t> protocol);
|
|
2634
2348
|
|
|
2635
|
-
// ssl_alpn_list_contains_protocol returns whether
|
|
2636
|
-
// protocol list, contains
|
|
2349
|
+
// ssl_alpn_list_contains_protocol returns whether `list`, a serialized ALPN
|
|
2350
|
+
// protocol list, contains `protocol`.
|
|
2637
2351
|
bool ssl_alpn_list_contains_protocol(Span<const uint8_t> list,
|
|
2638
2352
|
Span<const uint8_t> protocol);
|
|
2639
2353
|
|
|
2640
2354
|
// ssl_negotiate_alpn negotiates the ALPN extension, if applicable. It returns
|
|
2641
2355
|
// true on successful negotiation or if nothing was negotiated. It returns false
|
|
2642
|
-
// and sets
|
|
2356
|
+
// and sets `*out_alert` to an alert on error.
|
|
2643
2357
|
bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
2644
2358
|
const SSL_CLIENT_HELLO *client_hello);
|
|
2645
2359
|
|
|
2646
2360
|
// ssl_get_local_application_settings looks up the configured ALPS value for
|
|
2647
|
-
//
|
|
2361
|
+
// `protocol`. If found, it sets `*out_settings` to the value and returns true.
|
|
2648
2362
|
// Otherwise, it returns false.
|
|
2649
2363
|
bool ssl_get_local_application_settings(const SSL_HANDSHAKE *hs,
|
|
2650
2364
|
Span<const uint8_t> *out_settings,
|
|
@@ -2652,11 +2366,11 @@ bool ssl_get_local_application_settings(const SSL_HANDSHAKE *hs,
|
|
|
2652
2366
|
|
|
2653
2367
|
// ssl_negotiate_alps negotiates the ALPS extension, if applicable. It returns
|
|
2654
2368
|
// true on successful negotiation or if nothing was negotiated. It returns false
|
|
2655
|
-
// and sets
|
|
2369
|
+
// and sets `*out_alert` to an alert on error.
|
|
2656
2370
|
bool ssl_negotiate_alps(SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
2657
2371
|
const SSL_CLIENT_HELLO *client_hello);
|
|
2658
2372
|
|
|
2659
|
-
// ssl_is_valid_trust_anchor_list returns whether
|
|
2373
|
+
// ssl_is_valid_trust_anchor_list returns whether `in` is a valid trust anchor
|
|
2660
2374
|
// identifiers list.
|
|
2661
2375
|
bool ssl_is_valid_trust_anchor_list(Span<const uint8_t> in);
|
|
2662
2376
|
|
|
@@ -2672,18 +2386,18 @@ struct SSLExtension {
|
|
|
2672
2386
|
CBS data;
|
|
2673
2387
|
};
|
|
2674
2388
|
|
|
2675
|
-
// ssl_parse_extensions parses a TLS extensions block out of
|
|
2676
|
-
// it. It writes the parsed extensions to pointers in
|
|
2677
|
-
// it fills in the
|
|
2678
|
-
// sets
|
|
2679
|
-
// are rejected unless
|
|
2389
|
+
// ssl_parse_extensions parses a TLS extensions block out of `cbs` and advances
|
|
2390
|
+
// it. It writes the parsed extensions to pointers in `extensions`. On success,
|
|
2391
|
+
// it fills in the `present` and `data` fields and returns true. Otherwise, it
|
|
2392
|
+
// sets `*out_alert` to an alert to send and returns false. Unknown extensions
|
|
2393
|
+
// are rejected unless `ignore_unknown` is true.
|
|
2680
2394
|
bool ssl_parse_extensions(const CBS *cbs, uint8_t *out_alert,
|
|
2681
2395
|
std::initializer_list<SSLExtension *> extensions,
|
|
2682
2396
|
bool ignore_unknown);
|
|
2683
2397
|
|
|
2684
|
-
// ssl_verify_peer_cert verifies the peer certificate for
|
|
2398
|
+
// ssl_verify_peer_cert verifies the peer certificate for `hs`.
|
|
2685
2399
|
enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs);
|
|
2686
|
-
// ssl_reverify_peer_cert verifies the peer certificate for
|
|
2400
|
+
// ssl_reverify_peer_cert verifies the peer certificate for `hs` when resuming a
|
|
2687
2401
|
// session.
|
|
2688
2402
|
enum ssl_verify_result_t ssl_reverify_peer_cert(SSL_HANDSHAKE *hs,
|
|
2689
2403
|
bool send_alert);
|
|
@@ -2698,14 +2412,20 @@ bool ssl_send_finished(SSL_HANDSHAKE *hs);
|
|
|
2698
2412
|
// flight of messages. It returns true on success and false on error.
|
|
2699
2413
|
bool ssl_send_tls12_certificate(SSL_HANDSHAKE *hs);
|
|
2700
2414
|
|
|
2701
|
-
// ssl_handshake_session returns the
|
|
2415
|
+
// ssl_handshake_session returns the `SSL_SESSION` corresponding to the current
|
|
2702
2416
|
// handshake. Note, in TLS 1.2 resumptions, this session is immutable.
|
|
2703
2417
|
const SSL_SESSION *ssl_handshake_session(const SSL_HANDSHAKE *hs);
|
|
2704
2418
|
|
|
2705
2419
|
// ssl_done_writing_client_hello is called after the last ClientHello is written
|
|
2706
|
-
// by
|
|
2420
|
+
// by `hs`. It releases some memory that is no longer needed.
|
|
2707
2421
|
void ssl_done_writing_client_hello(SSL_HANDSHAKE *hs);
|
|
2708
2422
|
|
|
2423
|
+
// ssl_accepts_server_certificate_auth returns whether `hs`, which must be a
|
|
2424
|
+
// client, accepts certificate-based authentication. If it returns false, the
|
|
2425
|
+
// client should not send certificate-related extensions, and should not accept
|
|
2426
|
+
// server responses that result in a certificate-based flow.
|
|
2427
|
+
bool ssl_accepts_server_certificate_auth(const SSL_HANDSHAKE *hs);
|
|
2428
|
+
|
|
2709
2429
|
|
|
2710
2430
|
// Flags.
|
|
2711
2431
|
|
|
@@ -2718,27 +2438,27 @@ using SSLFlags = uint32_t;
|
|
|
2718
2438
|
inline constexpr SSLFlags kSSLFlagResumptionAcrossNames = 1 << 8;
|
|
2719
2439
|
|
|
2720
2440
|
// ssl_add_flags_extension encodes a tls_flags extension (including the header)
|
|
2721
|
-
// containing the flags in
|
|
2722
|
-
// error. If
|
|
2723
|
-
// anything to
|
|
2441
|
+
// containing the flags in `flags`. It returns true on success and false on
|
|
2442
|
+
// error. If `flags` is zero (no flags set), it returns true without adding
|
|
2443
|
+
// anything to `cbb`.
|
|
2724
2444
|
bool ssl_add_flags_extension(CBB *cbb, SSLFlags flags);
|
|
2725
2445
|
|
|
2726
2446
|
// ssl_parse_flags_extension_request parses tls_flags extension value (excluding
|
|
2727
|
-
// the header) from
|
|
2447
|
+
// the header) from `cbs`, for a request message (ClientHello,
|
|
2728
2448
|
// CertificateRequest, or NewSessionTicket). Unrecognized flags will be ignored.
|
|
2729
2449
|
//
|
|
2730
|
-
// On success, it sets
|
|
2731
|
-
// sets
|
|
2450
|
+
// On success, it sets `*out` to the parsed flags and returns true. On error, it
|
|
2451
|
+
// sets `*out_alert` to a TLS alert and returns false.
|
|
2732
2452
|
bool ssl_parse_flags_extension_request(const CBS *cbs, SSLFlags *out,
|
|
2733
2453
|
uint8_t *out_alert);
|
|
2734
2454
|
|
|
2735
2455
|
// ssl_parse_flags_extension_response parses tls_flags extension value
|
|
2736
|
-
// (excluding the header) from
|
|
2456
|
+
// (excluding the header) from `cbs`, for a response message (HelloRetryRequest,
|
|
2737
2457
|
// ServerHello, EncryptedExtensions, or Certificate). Only the flags in
|
|
2738
|
-
//
|
|
2458
|
+
// `allowed_flags` may be present.
|
|
2739
2459
|
//
|
|
2740
|
-
// On success, it sets
|
|
2741
|
-
// sets
|
|
2460
|
+
// On success, it sets `*out` to the parsed flags and returns true. On error, it
|
|
2461
|
+
// sets `*out_alert` to a TLS alert and returns false.
|
|
2742
2462
|
bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
|
|
2743
2463
|
uint8_t *out_alert,
|
|
2744
2464
|
SSLFlags allowed_flags);
|
|
@@ -2746,8 +2466,8 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
|
|
|
2746
2466
|
|
|
2747
2467
|
// SSLKEYLOGFILE functions.
|
|
2748
2468
|
|
|
2749
|
-
// ssl_log_secret logs
|
|
2750
|
-
//
|
|
2469
|
+
// ssl_log_secret logs `secret` with label `label`, if logging is enabled for
|
|
2470
|
+
// `ssl`. It returns true on success and false on failure.
|
|
2751
2471
|
bool ssl_log_secret(const SSL *ssl, const char *label,
|
|
2752
2472
|
Span<const uint8_t> secret);
|
|
2753
2473
|
|
|
@@ -2766,7 +2486,7 @@ bool ssl_client_cipher_list_contains_cipher(
|
|
|
2766
2486
|
|
|
2767
2487
|
// GREASE.
|
|
2768
2488
|
|
|
2769
|
-
// ssl_get_grease_value returns a GREASE value for
|
|
2489
|
+
// ssl_get_grease_value returns a GREASE value for `hs`. For a given
|
|
2770
2490
|
// connection, the values for each index will be deterministic. This allows the
|
|
2771
2491
|
// same ClientHello be sent twice for a HelloRetryRequest or the same group be
|
|
2772
2492
|
// advertised in both supported_groups and key_shares.
|
|
@@ -2776,29 +2496,29 @@ uint16_t ssl_get_grease_value(const SSL_HANDSHAKE *hs,
|
|
|
2776
2496
|
|
|
2777
2497
|
// Signature algorithms.
|
|
2778
2498
|
|
|
2779
|
-
// tls1_parse_peer_sigalgs parses
|
|
2780
|
-
// algorithms and saves them on
|
|
2499
|
+
// tls1_parse_peer_sigalgs parses `sigalgs` as the list of peer signature
|
|
2500
|
+
// algorithms and saves them on `hs`. It returns true on success and false on
|
|
2781
2501
|
// error.
|
|
2782
2502
|
bool tls1_parse_peer_sigalgs(SSL_HANDSHAKE *hs, const CBS *sigalgs);
|
|
2783
2503
|
|
|
2784
|
-
// tls1_get_legacy_signature_algorithm sets
|
|
2785
|
-
// that should be used with
|
|
2786
|
-
// success and false if
|
|
2504
|
+
// tls1_get_legacy_signature_algorithm sets `*out` to the signature algorithm
|
|
2505
|
+
// that should be used with `pkey` in TLS 1.1 and earlier. It returns true on
|
|
2506
|
+
// success and false if `pkey` may not be used at those versions.
|
|
2787
2507
|
bool tls1_get_legacy_signature_algorithm(uint16_t *out, const EVP_PKEY *pkey);
|
|
2788
2508
|
|
|
2789
|
-
// tls1_choose_signature_algorithm sets
|
|
2790
|
-
// with
|
|
2509
|
+
// tls1_choose_signature_algorithm sets `*out` to a signature algorithm for use
|
|
2510
|
+
// with `cred` based on the peer's preferences and the algorithms supported. It
|
|
2791
2511
|
// returns true on success and false on error.
|
|
2792
2512
|
bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
|
|
2793
|
-
const
|
|
2513
|
+
const SSLCredential *cred, uint16_t *out);
|
|
2794
2514
|
|
|
2795
2515
|
// tls12_add_verify_sigalgs adds the signature algorithms acceptable for the
|
|
2796
|
-
// peer signature to
|
|
2516
|
+
// peer signature to `out`. It returns true on success and false on error.
|
|
2797
2517
|
bool tls12_add_verify_sigalgs(const SSL_HANDSHAKE *hs, CBB *out);
|
|
2798
2518
|
|
|
2799
|
-
// tls12_check_peer_sigalg checks if
|
|
2800
|
-
// signature from
|
|
2801
|
-
//
|
|
2519
|
+
// tls12_check_peer_sigalg checks if `sigalg` is acceptable for the peer
|
|
2520
|
+
// signature from `pkey`. It returns true on success and false on error, setting
|
|
2521
|
+
// `*out_alert` to an alert to send.
|
|
2802
2522
|
bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
|
|
2803
2523
|
uint16_t sigalg, EVP_PKEY *pkey);
|
|
2804
2524
|
|
|
@@ -2822,30 +2542,34 @@ struct CERT {
|
|
|
2822
2542
|
|
|
2823
2543
|
// credentials is the list of credentials to select between. Elements of this
|
|
2824
2544
|
// array immutable.
|
|
2825
|
-
Vector<UniquePtr<
|
|
2545
|
+
Vector<UniquePtr<SSLCredential>> credentials;
|
|
2826
2546
|
|
|
2827
2547
|
// legacy_credential is the credential configured by the legacy
|
|
2828
2548
|
// non-credential-based APIs. If IsComplete() returns true, it is appended to
|
|
2829
2549
|
// the list of credentials.
|
|
2830
|
-
UniquePtr<
|
|
2550
|
+
UniquePtr<SSLCredential> legacy_credential;
|
|
2831
2551
|
|
|
2832
|
-
//
|
|
2552
|
+
// available_trust_anchors, if not empty, overrides the default list of
|
|
2553
|
+
// available trust anchors to send in EncryptedExtensions.
|
|
2554
|
+
Array<uint8_t> available_trust_anchors;
|
|
2555
|
+
|
|
2556
|
+
// x509_method contains pointers to functions that might deal with `X509`
|
|
2833
2557
|
// compatibility, or might be a no-op, depending on the application.
|
|
2834
2558
|
const SSL_X509_METHOD *x509_method = nullptr;
|
|
2835
2559
|
|
|
2836
|
-
// x509_chain may contain a parsed copy of
|
|
2560
|
+
// x509_chain may contain a parsed copy of `chain[1..]` from the legacy
|
|
2837
2561
|
// credential. This is only used as a cache in order to implement “get0”
|
|
2838
2562
|
// functions that return a non-owning pointer to the certificate chain.
|
|
2839
2563
|
STACK_OF(X509) *x509_chain = nullptr;
|
|
2840
2564
|
|
|
2841
|
-
// x509_leaf may contain a parsed copy of the first element of
|
|
2565
|
+
// x509_leaf may contain a parsed copy of the first element of `chain` from
|
|
2842
2566
|
// the legacy credential. This is only used as a cache in order to implement
|
|
2843
2567
|
// “get0” functions that return a non-owning pointer to the certificate chain.
|
|
2844
2568
|
X509 *x509_leaf = nullptr;
|
|
2845
2569
|
|
|
2846
|
-
// x509_stash contains the last
|
|
2570
|
+
// x509_stash contains the last `X509` object append to the legacy
|
|
2847
2571
|
// credential's chain. This is a workaround for some third-party code that
|
|
2848
|
-
// continue to use an
|
|
2572
|
+
// continue to use an `X509` object even after passing ownership with an
|
|
2849
2573
|
// “add0” function.
|
|
2850
2574
|
X509 *x509_stash = nullptr;
|
|
2851
2575
|
|
|
@@ -2867,66 +2591,65 @@ struct CERT {
|
|
|
2867
2591
|
InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
|
|
2868
2592
|
};
|
|
2869
2593
|
|
|
2870
|
-
//
|
|
2594
|
+
// `SSL_PROTOCOL_METHOD` abstracts between TLS and DTLS.
|
|
2871
2595
|
struct SSL_PROTOCOL_METHOD {
|
|
2872
2596
|
bool is_dtls;
|
|
2873
2597
|
bool (*ssl_new)(SSL *ssl);
|
|
2874
2598
|
void (*ssl_free)(SSL *ssl);
|
|
2875
|
-
// get_message sets
|
|
2599
|
+
// get_message sets `*out` to the current handshake message and returns true
|
|
2876
2600
|
// if one has been received. It returns false if more input is needed.
|
|
2877
2601
|
bool (*get_message)(const SSL *ssl, SSLMessage *out);
|
|
2878
2602
|
// next_message is called to release the current handshake message.
|
|
2879
2603
|
void (*next_message)(SSL *ssl);
|
|
2880
2604
|
// has_unprocessed_handshake_data returns whether there is buffered
|
|
2881
|
-
// handshake data that has not been consumed by
|
|
2605
|
+
// handshake data that has not been consumed by `get_message`.
|
|
2882
2606
|
bool (*has_unprocessed_handshake_data)(const SSL *ssl);
|
|
2883
|
-
// Use the
|
|
2607
|
+
// Use the `ssl_open_handshake` wrapper.
|
|
2884
2608
|
ssl_open_record_t (*open_handshake)(SSL *ssl, size_t *out_consumed,
|
|
2885
2609
|
uint8_t *out_alert, Span<uint8_t> in);
|
|
2886
|
-
// Use the
|
|
2610
|
+
// Use the `ssl_open_change_cipher_spec` wrapper.
|
|
2887
2611
|
ssl_open_record_t (*open_change_cipher_spec)(SSL *ssl, size_t *out_consumed,
|
|
2888
2612
|
uint8_t *out_alert,
|
|
2889
2613
|
Span<uint8_t> in);
|
|
2890
|
-
// Use the
|
|
2614
|
+
// Use the `ssl_open_app_data` wrapper.
|
|
2891
2615
|
ssl_open_record_t (*open_app_data)(SSL *ssl, Span<uint8_t> *out,
|
|
2892
2616
|
size_t *out_consumed, uint8_t *out_alert,
|
|
2893
2617
|
Span<uint8_t> in);
|
|
2894
|
-
// write_app_data encrypts and writes
|
|
2895
|
-
// returns one and sets
|
|
2896
|
-
// written. Otherwise, it returns <= 0 and sets
|
|
2618
|
+
// write_app_data encrypts and writes `in` as application data. On success, it
|
|
2619
|
+
// returns one and sets `*out_bytes_written` to the number of bytes of `in`
|
|
2620
|
+
// written. Otherwise, it returns <= 0 and sets `*out_needs_handshake` to
|
|
2897
2621
|
// whether the operation failed because the caller needs to drive the
|
|
2898
2622
|
// handshake.
|
|
2899
2623
|
int (*write_app_data)(SSL *ssl, bool *out_needs_handshake,
|
|
2900
2624
|
size_t *out_bytes_written, Span<const uint8_t> in);
|
|
2901
2625
|
int (*dispatch_alert)(SSL *ssl);
|
|
2902
|
-
// init_message begins a new handshake message of type
|
|
2903
|
-
// root CBB to be passed into
|
|
2626
|
+
// init_message begins a new handshake message of type `type`. `cbb` is the
|
|
2627
|
+
// root CBB to be passed into `finish_message`. `*body` is set to a child CBB
|
|
2904
2628
|
// the caller should write to. It returns true on success and false on error.
|
|
2905
2629
|
bool (*init_message)(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
|
|
2906
|
-
// finish_message finishes a handshake message. It sets
|
|
2630
|
+
// finish_message finishes a handshake message. It sets `*out_msg` to the
|
|
2907
2631
|
// serialized message. It returns true on success and false on error.
|
|
2908
|
-
bool (*finish_message)(const SSL *ssl, CBB *cbb,
|
|
2909
|
-
bssl::Array<uint8_t> *out_msg);
|
|
2632
|
+
bool (*finish_message)(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
|
|
2910
2633
|
// add_message adds a handshake message to the pending flight. It returns
|
|
2911
2634
|
// true on success and false on error.
|
|
2912
|
-
bool (*add_message)(SSL *ssl,
|
|
2635
|
+
bool (*add_message)(SSL *ssl, Array<uint8_t> msg);
|
|
2913
2636
|
// add_change_cipher_spec adds a ChangeCipherSpec record to the pending
|
|
2914
2637
|
// flight. It returns true on success and false on error.
|
|
2915
2638
|
bool (*add_change_cipher_spec)(SSL *ssl);
|
|
2916
2639
|
// finish_flight marks the pending flight as finished and ready to send.
|
|
2917
|
-
//
|
|
2640
|
+
// `flush` must be called to write it.
|
|
2918
2641
|
void (*finish_flight)(SSL *ssl);
|
|
2919
2642
|
// schedule_ack schedules a DTLS 1.3 ACK to be sent, without an ACK delay.
|
|
2920
|
-
//
|
|
2643
|
+
// `flush` must be called to write it.
|
|
2921
2644
|
void (*schedule_ack)(SSL *ssl);
|
|
2922
2645
|
// flush writes any scheduled data to the transport. It returns one on success
|
|
2923
2646
|
// and <= 0 on error.
|
|
2924
2647
|
int (*flush)(SSL *ssl);
|
|
2925
2648
|
// on_handshake_complete is called when the handshake is complete.
|
|
2926
2649
|
void (*on_handshake_complete)(SSL *ssl);
|
|
2927
|
-
// set_read_state sets
|
|
2928
|
-
//
|
|
2929
|
-
//
|
|
2650
|
+
// set_read_state sets `ssl`'s read cipher state and level to `aead_ctx` and
|
|
2651
|
+
// `level`. In QUIC, `aead_ctx` is a placeholder object. In TLS 1.3,
|
|
2652
|
+
// `traffic_secret` is the original traffic secret. This function returns true
|
|
2930
2653
|
// on success and false on error.
|
|
2931
2654
|
//
|
|
2932
2655
|
// TODO(crbug.com/371998381): Take the traffic secrets as input and let the
|
|
@@ -2934,9 +2657,9 @@ struct SSL_PROTOCOL_METHOD {
|
|
|
2934
2657
|
bool (*set_read_state)(SSL *ssl, ssl_encryption_level_t level,
|
|
2935
2658
|
UniquePtr<SSLAEADContext> aead_ctx,
|
|
2936
2659
|
Span<const uint8_t> traffic_secret);
|
|
2937
|
-
// set_write_state sets
|
|
2938
|
-
//
|
|
2939
|
-
//
|
|
2660
|
+
// set_write_state sets `ssl`'s write cipher state and level to `aead_ctx` and
|
|
2661
|
+
// `level`. In QUIC, `aead_ctx` is a placeholder object In TLS 1.3,
|
|
2662
|
+
// `traffic_secret` is the original traffic secret. This function returns true
|
|
2940
2663
|
// on success and false on error.
|
|
2941
2664
|
//
|
|
2942
2665
|
// TODO(crbug.com/371998381): Take the traffic secrets as input and let the
|
|
@@ -2946,30 +2669,30 @@ struct SSL_PROTOCOL_METHOD {
|
|
|
2946
2669
|
Span<const uint8_t> traffic_secret);
|
|
2947
2670
|
};
|
|
2948
2671
|
|
|
2949
|
-
// The following wrappers call
|
|
2672
|
+
// The following wrappers call `open_*` but handle `read_shutdown` correctly.
|
|
2950
2673
|
|
|
2951
|
-
// ssl_open_handshake processes a record from
|
|
2674
|
+
// ssl_open_handshake processes a record from `in` for reading a handshake
|
|
2952
2675
|
// message.
|
|
2953
2676
|
ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
|
|
2954
2677
|
uint8_t *out_alert, Span<uint8_t> in);
|
|
2955
2678
|
|
|
2956
|
-
// ssl_open_change_cipher_spec processes a record from
|
|
2679
|
+
// ssl_open_change_cipher_spec processes a record from `in` for reading a
|
|
2957
2680
|
// ChangeCipherSpec.
|
|
2958
2681
|
ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
|
|
2959
2682
|
uint8_t *out_alert,
|
|
2960
2683
|
Span<uint8_t> in);
|
|
2961
2684
|
|
|
2962
|
-
// ssl_open_app_data processes a record from
|
|
2963
|
-
// On success, it returns
|
|
2685
|
+
// ssl_open_app_data processes a record from `in` for reading application data.
|
|
2686
|
+
// On success, it returns `ssl_open_record_success` and sets `*out` to the
|
|
2964
2687
|
// input. If it encounters a post-handshake message, it returns
|
|
2965
|
-
//
|
|
2966
|
-
// messages received with
|
|
2688
|
+
// `ssl_open_record_discard`. The caller should then retry, after processing any
|
|
2689
|
+
// messages received with `get_message`.
|
|
2967
2690
|
ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
|
|
2968
2691
|
size_t *out_consumed, uint8_t *out_alert,
|
|
2969
2692
|
Span<uint8_t> in);
|
|
2970
2693
|
|
|
2971
2694
|
struct SSL_X509_METHOD {
|
|
2972
|
-
// check_CA_list returns one if
|
|
2695
|
+
// check_CA_list returns one if `names` is a good list of X.509 distinguished
|
|
2973
2696
|
// names and zero otherwise. This is used to ensure that we can reject
|
|
2974
2697
|
// unparsable values at handshake time when using crypto/x509.
|
|
2975
2698
|
bool (*check_CA_list)(STACK_OF(CRYPTO_BUFFER) *names);
|
|
@@ -2978,57 +2701,57 @@ struct SSL_X509_METHOD {
|
|
|
2978
2701
|
void (*cert_clear)(CERT *cert);
|
|
2979
2702
|
// cert_free frees all X509-related state.
|
|
2980
2703
|
void (*cert_free)(CERT *cert);
|
|
2981
|
-
// cert_flush_cached_chain drops any cached
|
|
2982
|
-
// from
|
|
2983
|
-
// cert_dup duplicates any needed fields from
|
|
2704
|
+
// cert_flush_cached_chain drops any cached `X509`-based certificate chain
|
|
2705
|
+
// from `cert`.
|
|
2706
|
+
// cert_dup duplicates any needed fields from `cert` to `new_cert`.
|
|
2984
2707
|
void (*cert_dup)(CERT *new_cert, const CERT *cert);
|
|
2985
2708
|
void (*cert_flush_cached_chain)(CERT *cert);
|
|
2986
|
-
// cert_flush_cached_chain drops any cached
|
|
2987
|
-
// from
|
|
2709
|
+
// cert_flush_cached_chain drops any cached `X509`-based leaf certificate
|
|
2710
|
+
// from `cert`.
|
|
2988
2711
|
void (*cert_flush_cached_leaf)(CERT *cert);
|
|
2989
2712
|
|
|
2990
|
-
// session_cache_objects fills out
|
|
2991
|
-
// from
|
|
2713
|
+
// session_cache_objects fills out `sess->x509_peer` and `sess->x509_chain`
|
|
2714
|
+
// from `sess->certs` and erases `sess->x509_chain_without_leaf`. It returns
|
|
2992
2715
|
// true on success or false on error.
|
|
2993
2716
|
bool (*session_cache_objects)(SSL_SESSION *session);
|
|
2994
|
-
// session_dup duplicates any needed fields from
|
|
2717
|
+
// session_dup duplicates any needed fields from `session` to `new_session`.
|
|
2995
2718
|
// It returns true on success or false on error.
|
|
2996
2719
|
bool (*session_dup)(SSL_SESSION *new_session, const SSL_SESSION *session);
|
|
2997
|
-
// session_clear frees any X509-related state from
|
|
2720
|
+
// session_clear frees any X509-related state from `session`.
|
|
2998
2721
|
void (*session_clear)(SSL_SESSION *session);
|
|
2999
|
-
// session_verify_cert_chain verifies the certificate chain in
|
|
3000
|
-
// sets
|
|
2722
|
+
// session_verify_cert_chain verifies the certificate chain in `session`,
|
|
2723
|
+
// sets `session->verify_result` and returns true on success or false on
|
|
3001
2724
|
// error.
|
|
3002
2725
|
bool (*session_verify_cert_chain)(SSL_SESSION *session, SSL_HANDSHAKE *ssl,
|
|
3003
2726
|
uint8_t *out_alert);
|
|
3004
2727
|
|
|
3005
|
-
// hs_flush_cached_ca_names drops any cached
|
|
2728
|
+
// hs_flush_cached_ca_names drops any cached `X509_NAME`s from `hs`.
|
|
3006
2729
|
void (*hs_flush_cached_ca_names)(SSL_HANDSHAKE *hs);
|
|
3007
|
-
// ssl_new does any necessary initialisation of
|
|
2730
|
+
// ssl_new does any necessary initialisation of `hs`. It returns true on
|
|
3008
2731
|
// success or false on error.
|
|
3009
2732
|
bool (*ssl_new)(SSL_HANDSHAKE *hs);
|
|
3010
|
-
// ssl_free frees anything created by
|
|
2733
|
+
// ssl_free frees anything created by `ssl_new`.
|
|
3011
2734
|
void (*ssl_config_free)(SSL_CONFIG *cfg);
|
|
3012
|
-
// ssl_flush_cached_client_CA drops any cached
|
|
2735
|
+
// ssl_flush_cached_client_CA drops any cached `X509_NAME`s from `ssl`.
|
|
3013
2736
|
void (*ssl_flush_cached_client_CA)(SSL_CONFIG *cfg);
|
|
3014
2737
|
// ssl_auto_chain_if_needed runs the deprecated auto-chaining logic if
|
|
3015
|
-
// necessary. On success, it updates
|
|
2738
|
+
// necessary. On success, it updates `ssl`'s certificate configuration as
|
|
3016
2739
|
// needed and returns true. Otherwise, it returns false.
|
|
3017
2740
|
bool (*ssl_auto_chain_if_needed)(SSL_HANDSHAKE *hs);
|
|
3018
|
-
// ssl_ctx_new does any necessary initialisation of
|
|
2741
|
+
// ssl_ctx_new does any necessary initialisation of `ctx`. It returns true on
|
|
3019
2742
|
// success or false on error.
|
|
3020
|
-
bool (*ssl_ctx_new)(
|
|
3021
|
-
// ssl_ctx_free frees anything created by
|
|
3022
|
-
void (*ssl_ctx_free)(
|
|
3023
|
-
// ssl_ctx_flush_cached_client_CA drops any cached
|
|
3024
|
-
void (*ssl_ctx_flush_cached_client_CA)(
|
|
2743
|
+
bool (*ssl_ctx_new)(SSLContext *ctx);
|
|
2744
|
+
// ssl_ctx_free frees anything created by `ssl_ctx_new`.
|
|
2745
|
+
void (*ssl_ctx_free)(SSLContext *ctx);
|
|
2746
|
+
// ssl_ctx_flush_cached_client_CA drops any cached `X509_NAME`s from `ctx`.
|
|
2747
|
+
void (*ssl_ctx_flush_cached_client_CA)(SSLContext *ssl);
|
|
3025
2748
|
};
|
|
3026
2749
|
|
|
3027
|
-
// ssl_crypto_x509_method provides the
|
|
2750
|
+
// ssl_crypto_x509_method provides the `SSL_X509_METHOD` functions using
|
|
3028
2751
|
// crypto/x509.
|
|
3029
2752
|
extern const SSL_X509_METHOD ssl_crypto_x509_method;
|
|
3030
2753
|
|
|
3031
|
-
// ssl_noop_x509_method provides the
|
|
2754
|
+
// ssl_noop_x509_method provides the `SSL_X509_METHOD` functions that avoid
|
|
3032
2755
|
// crypto/x509.
|
|
3033
2756
|
extern const SSL_X509_METHOD ssl_noop_x509_method;
|
|
3034
2757
|
|
|
@@ -3053,12 +2776,8 @@ struct CertCompressionAlg {
|
|
|
3053
2776
|
uint16_t alg_id = 0;
|
|
3054
2777
|
};
|
|
3055
2778
|
|
|
3056
|
-
BSSL_NAMESPACE_END
|
|
3057
|
-
|
|
3058
2779
|
DEFINE_LHASH_OF(SSL_SESSION)
|
|
3059
2780
|
|
|
3060
|
-
BSSL_NAMESPACE_BEGIN
|
|
3061
|
-
|
|
3062
2781
|
// An ssl_shutdown_t describes the shutdown state of one end of the connection,
|
|
3063
2782
|
// whether it is alive or has been shutdown via close_notify or fatal alert.
|
|
3064
2783
|
enum ssl_shutdown_t {
|
|
@@ -3095,22 +2814,22 @@ struct SSL3_STATE {
|
|
|
3095
2814
|
SSLBuffer write_buffer;
|
|
3096
2815
|
|
|
3097
2816
|
// pending_app_data is the unconsumed application data. It points into
|
|
3098
|
-
//
|
|
2817
|
+
// `read_buffer`.
|
|
3099
2818
|
Span<uint8_t> pending_app_data;
|
|
3100
2819
|
|
|
3101
2820
|
// unreported_bytes_written is the number of bytes successfully written to the
|
|
3102
|
-
// transport, but not yet reported to the caller. The next
|
|
2821
|
+
// transport, but not yet reported to the caller. The next `SSL_write` will
|
|
3103
2822
|
// skip this many bytes from the input. This is used if
|
|
3104
|
-
//
|
|
2823
|
+
// `SSL_MODE_ENABLE_PARTIAL_WRITE` is disabled, in which case `SSL_write` only
|
|
3105
2824
|
// reports bytes written when the full caller input is written.
|
|
3106
2825
|
size_t unreported_bytes_written = 0;
|
|
3107
2826
|
|
|
3108
|
-
// pending_write, if
|
|
2827
|
+
// pending_write, if `has_pending_write` is true, is the caller-supplied data
|
|
3109
2828
|
// corresponding to the current pending write. This is used to check the
|
|
3110
2829
|
// caller retried with a compatible buffer.
|
|
3111
2830
|
Span<const uint8_t> pending_write;
|
|
3112
2831
|
|
|
3113
|
-
// pending_write_type, if
|
|
2832
|
+
// pending_write_type, if `has_pending_write` is true, is the record type
|
|
3114
2833
|
// for the current pending write.
|
|
3115
2834
|
//
|
|
3116
2835
|
// TODO(davidben): Remove this when alerts are moved out of this write path.
|
|
@@ -3122,7 +2841,7 @@ struct SSL3_STATE {
|
|
|
3122
2841
|
// write_shutdown is the shutdown state for the write half of the connection.
|
|
3123
2842
|
enum ssl_shutdown_t write_shutdown = ssl_shutdown_none;
|
|
3124
2843
|
|
|
3125
|
-
// read_error, if
|
|
2844
|
+
// read_error, if `read_shutdown` is `ssl_shutdown_error`, is the error for
|
|
3126
2845
|
// the receive half of the connection.
|
|
3127
2846
|
UniquePtr<ERR_SAVE_STATE> read_error;
|
|
3128
2847
|
|
|
@@ -3139,7 +2858,7 @@ struct SSL3_STATE {
|
|
|
3139
2858
|
// version is the protocol version, or zero if the version has not yet been
|
|
3140
2859
|
// set. In clients offering 0-RTT, this version will initially be set to the
|
|
3141
2860
|
// early version, then switched to the final version. To distinguish these
|
|
3142
|
-
// cases, use
|
|
2861
|
+
// cases, use `ssl_has_final_version`.
|
|
3143
2862
|
uint16_t version = 0;
|
|
3144
2863
|
|
|
3145
2864
|
// early_data_skipped is the amount of early data that has been skipped by the
|
|
@@ -3172,7 +2891,7 @@ struct SSL3_STATE {
|
|
|
3172
2891
|
bool is_v2_hello : 1;
|
|
3173
2892
|
|
|
3174
2893
|
// has_message is true if the current handshake message has been returned
|
|
3175
|
-
// at least once by
|
|
2894
|
+
// at least once by `get_message` and false otherwise.
|
|
3176
2895
|
bool has_message : 1;
|
|
3177
2896
|
|
|
3178
2897
|
// initial_handshake_complete is true if the initial handshake has
|
|
@@ -3185,7 +2904,7 @@ struct SSL3_STATE {
|
|
|
3185
2904
|
bool send_connection_binding : 1;
|
|
3186
2905
|
|
|
3187
2906
|
// channel_id_valid is true if, on the server, the client has negotiated a
|
|
3188
|
-
// Channel ID and the
|
|
2907
|
+
// Channel ID and the `channel_id` field is filled in.
|
|
3189
2908
|
bool channel_id_valid : 1;
|
|
3190
2909
|
|
|
3191
2910
|
// key_update_pending is true if we are in the process of sending a KeyUpdate
|
|
@@ -3197,7 +2916,7 @@ struct SSL3_STATE {
|
|
|
3197
2916
|
// early_data_accepted is true if early data was accepted by the server.
|
|
3198
2917
|
bool early_data_accepted : 1;
|
|
3199
2918
|
|
|
3200
|
-
// alert_dispatch is true there is an alert in
|
|
2919
|
+
// alert_dispatch is true there is an alert in `send_alert` to be sent.
|
|
3201
2920
|
bool alert_dispatch : 1;
|
|
3202
2921
|
|
|
3203
2922
|
// renegotiate_pending is whether the read half of the channel is blocked on a
|
|
@@ -3213,20 +2932,25 @@ struct SSL3_STATE {
|
|
|
3213
2932
|
// extension.
|
|
3214
2933
|
bool was_key_usage_invalid : 1;
|
|
3215
2934
|
|
|
2935
|
+
// server_sent_requested_padding is true iff a client requested padding
|
|
2936
|
+
// through the server padding extension, and the server sent back the
|
|
2937
|
+
// requested amount of padding.
|
|
2938
|
+
bool server_sent_requested_padding : 1;
|
|
2939
|
+
|
|
3216
2940
|
// hs_buf is the buffer of handshake data to process.
|
|
3217
2941
|
UniquePtr<BUF_MEM> hs_buf;
|
|
3218
2942
|
|
|
3219
2943
|
// pending_hs_data contains the pending handshake data that has not yet
|
|
3220
|
-
// been encrypted to
|
|
2944
|
+
// been encrypted to `pending_flight`. This allows packing the handshake into
|
|
3221
2945
|
// fewer records.
|
|
3222
2946
|
UniquePtr<BUF_MEM> pending_hs_data;
|
|
3223
2947
|
|
|
3224
2948
|
// pending_flight is the pending outgoing flight. This is used to flush each
|
|
3225
|
-
// handshake flight in a single write.
|
|
2949
|
+
// handshake flight in a single write. `write_buffer` must be written out
|
|
3226
2950
|
// before this data.
|
|
3227
2951
|
UniquePtr<BUF_MEM> pending_flight;
|
|
3228
2952
|
|
|
3229
|
-
// pending_flight_offset is the number of bytes of
|
|
2953
|
+
// pending_flight_offset is the number of bytes of `pending_flight` which have
|
|
3230
2954
|
// been successfully written.
|
|
3231
2955
|
uint32_t pending_flight_offset = 0;
|
|
3232
2956
|
|
|
@@ -3283,7 +3007,7 @@ struct SSL3_STATE {
|
|
|
3283
3007
|
UniquePtr<char> hostname;
|
|
3284
3008
|
|
|
3285
3009
|
// For a server:
|
|
3286
|
-
// If
|
|
3010
|
+
// If `channel_id_valid` is true, then this contains the
|
|
3287
3011
|
// verified Channel ID from the client: a P256 point, (x,y), where
|
|
3288
3012
|
// each are big-endian values.
|
|
3289
3013
|
uint8_t channel_id[64] = {0};
|
|
@@ -3321,7 +3045,7 @@ static_assert(DTLS1_RT_MAX_HEADER_LENGTH >= DTLS1_3_RECORD_HEADER_WRITE_LENGTH,
|
|
|
3321
3045
|
// a portion of a message was received or ACKed.
|
|
3322
3046
|
class DTLSMessageBitmap {
|
|
3323
3047
|
public:
|
|
3324
|
-
// A Range represents a range of bits from
|
|
3048
|
+
// A Range represents a range of bits from `start`, inclusive, to `end`,
|
|
3325
3049
|
// exclusive.
|
|
3326
3050
|
struct Range {
|
|
3327
3051
|
size_t start = 0;
|
|
@@ -3335,15 +3059,15 @@ class DTLSMessageBitmap {
|
|
|
3335
3059
|
bool operator!=(const Range &r) const { return !(*this == r); }
|
|
3336
3060
|
};
|
|
3337
3061
|
|
|
3338
|
-
// Init initializes the structure with
|
|
3339
|
-
// to
|
|
3062
|
+
// Init initializes the structure with `num_bits` unmarked bits, from zero
|
|
3063
|
+
// to `num_bits - 1`.
|
|
3340
3064
|
bool Init(size_t num_bits);
|
|
3341
3065
|
|
|
3342
|
-
// MarkRange marks the bits from
|
|
3066
|
+
// MarkRange marks the bits from `start`, inclusive, to `end`, exclusive.
|
|
3343
3067
|
void MarkRange(size_t start, size_t end);
|
|
3344
3068
|
|
|
3345
3069
|
// NextUnmarkedRange returns the next range of unmarked bits, starting from
|
|
3346
|
-
//
|
|
3070
|
+
// `start`, inclusive. If all bits after `start` are marked, it returns an
|
|
3347
3071
|
// empty range.
|
|
3348
3072
|
Range NextUnmarkedRange(size_t start) const;
|
|
3349
3073
|
|
|
@@ -3351,10 +3075,10 @@ class DTLSMessageBitmap {
|
|
|
3351
3075
|
bool IsComplete() const { return bytes_.empty(); }
|
|
3352
3076
|
|
|
3353
3077
|
private:
|
|
3354
|
-
// bytes_ contains the unmarked bits. We maintain an invariant: if
|
|
3078
|
+
// bytes_ contains the unmarked bits. We maintain an invariant: if `bytes_` is
|
|
3355
3079
|
// not empty, some bit is unset.
|
|
3356
3080
|
Array<uint8_t> bytes_;
|
|
3357
|
-
// first_unmarked_byte_ is the index of first byte in
|
|
3081
|
+
// first_unmarked_byte_ is the index of first byte in `bytes_` that is not
|
|
3358
3082
|
// 0xff. This is maintained to amortize checking if the message is complete.
|
|
3359
3083
|
size_t first_unmarked_byte_ = 0;
|
|
3360
3084
|
};
|
|
@@ -3383,7 +3107,7 @@ struct DTLSIncomingMessage {
|
|
|
3383
3107
|
// seq is the sequence number of this message.
|
|
3384
3108
|
uint16_t seq = 0;
|
|
3385
3109
|
// data contains the message, including the message header of length
|
|
3386
|
-
//
|
|
3110
|
+
// `DTLS1_HM_HEADER_LENGTH`.
|
|
3387
3111
|
Array<uint8_t> data;
|
|
3388
3112
|
// reassembly tracks which parts of the message have been received.
|
|
3389
3113
|
DTLSMessageBitmap reassembly;
|
|
@@ -3405,7 +3129,7 @@ struct DTLSOutgoingMessage {
|
|
|
3405
3129
|
uint16_t epoch = 0;
|
|
3406
3130
|
bool is_ccs = false;
|
|
3407
3131
|
// acked tracks which bits of the message have been ACKed by the peer. If
|
|
3408
|
-
//
|
|
3132
|
+
// `msg_len` is zero, it tracks one bit for whether the header has been
|
|
3409
3133
|
// received.
|
|
3410
3134
|
DTLSMessageBitmap acked;
|
|
3411
3135
|
};
|
|
@@ -3420,34 +3144,28 @@ struct DTLSTimer {
|
|
|
3420
3144
|
static constexpr uint64_t kNever = UINT64_MAX;
|
|
3421
3145
|
|
|
3422
3146
|
// StartMicroseconds schedules the timer to expire the specified number of
|
|
3423
|
-
// microseconds from
|
|
3147
|
+
// microseconds from `now`.
|
|
3424
3148
|
void StartMicroseconds(OPENSSL_timeval now, uint64_t microseconds);
|
|
3425
3149
|
|
|
3426
3150
|
// Stop disables the timer.
|
|
3427
3151
|
void Stop();
|
|
3428
3152
|
|
|
3429
|
-
// IsExpired returns true if the timer was set and is expired at time
|
|
3153
|
+
// IsExpired returns true if the timer was set and is expired at time `now`.
|
|
3430
3154
|
bool IsExpired(OPENSSL_timeval now) const;
|
|
3431
3155
|
|
|
3432
3156
|
// IsSet returns true if the timer is scheduled or expired, and false if it is
|
|
3433
3157
|
// stopped.
|
|
3434
3158
|
bool IsSet() const;
|
|
3435
3159
|
|
|
3160
|
+
void UpdateDuration(uint64_t microseconds) { duration_ = microseconds; }
|
|
3161
|
+
|
|
3436
3162
|
// MicrosecondsRemaining returns the time remaining, in microseconds, at
|
|
3437
|
-
//
|
|
3163
|
+
// `now`, or `kNever` if the timer is unset.
|
|
3438
3164
|
uint64_t MicrosecondsRemaining(OPENSSL_timeval now) const;
|
|
3439
3165
|
|
|
3440
3166
|
private:
|
|
3441
|
-
|
|
3442
|
-
// unset.
|
|
3443
|
-
//
|
|
3444
|
-
// TODO(crbug.com/366284846): This is an extremely inconvenient time
|
|
3445
|
-
// representation. Switch libssl to something like a 64-bit count of
|
|
3446
|
-
// microseconds. While it's decidedly past 1970 now, zero is a less obviously
|
|
3447
|
-
// sound distinguished value for the monotonic clock, so maybe we should use a
|
|
3448
|
-
// different distinguished time, like |INT64_MAX| in the microseconds
|
|
3449
|
-
// representation.
|
|
3450
|
-
OPENSSL_timeval expire_time_ = {0, 0};
|
|
3167
|
+
uint64_t start_time_;
|
|
3168
|
+
uint64_t duration_ = kNever; // If set to kNever then this timer is unset.
|
|
3451
3169
|
};
|
|
3452
3170
|
|
|
3453
3171
|
// DTLS_MAX_EXTRA_WRITE_EPOCHS is the maximum number of additional write epochs
|
|
@@ -3469,14 +3187,14 @@ struct DTLSTimer {
|
|
|
3469
3187
|
#define DTLS_MAX_ACK_BUFFER 32
|
|
3470
3188
|
|
|
3471
3189
|
// A DTLSSentRecord records information about a record we sent. Each record
|
|
3472
|
-
// covers all bytes from
|
|
3473
|
-
//
|
|
3474
|
-
// into
|
|
3475
|
-
//
|
|
3190
|
+
// covers all bytes from `first_msg_start` (inclusive) of `first_msg` to
|
|
3191
|
+
// `last_msg_end` (exclusive) of `last_msg`. Messages are referenced by index
|
|
3192
|
+
// into `outgoing_messages`. `last_msg_end` may be `outgoing_messages.size()` if
|
|
3193
|
+
// `last_msg_end` is zero.
|
|
3476
3194
|
//
|
|
3477
|
-
// When the message is empty,
|
|
3195
|
+
// When the message is empty, `first_msg_start` and `last_msg_end` are
|
|
3478
3196
|
// maintained as if there is a single bit in the message representing the
|
|
3479
|
-
// header. See
|
|
3197
|
+
// header. See `acked` in DTLSOutgoingMessage.
|
|
3480
3198
|
struct DTLSSentRecord {
|
|
3481
3199
|
DTLSRecordNumber number;
|
|
3482
3200
|
PackedSize<SSL_MAX_HANDSHAKE_FLIGHT> first_msg = 0;
|
|
@@ -3524,9 +3242,9 @@ struct DTLS1_STATE {
|
|
|
3524
3242
|
// the peer in this epoch.
|
|
3525
3243
|
bool has_change_cipher_spec : 1;
|
|
3526
3244
|
|
|
3527
|
-
// outgoing_messages_complete is true if
|
|
3528
|
-
// completed by an attempt to flush it. Future calls to
|
|
3529
|
-
//
|
|
3245
|
+
// outgoing_messages_complete is true if `outgoing_messages` has been
|
|
3246
|
+
// completed by an attempt to flush it. Future calls to `add_message` and
|
|
3247
|
+
// `add_change_cipher_spec` will start a new flight.
|
|
3530
3248
|
bool outgoing_messages_complete : 1;
|
|
3531
3249
|
|
|
3532
3250
|
// flight_has_reply is true if the current outgoing flight is complete and has
|
|
@@ -3543,6 +3261,8 @@ struct DTLS1_STATE {
|
|
|
3543
3261
|
// a handshake flight and ACK, respectively.
|
|
3544
3262
|
bool sending_flight : 1;
|
|
3545
3263
|
bool sending_ack : 1;
|
|
3264
|
+
// pending_flush is whether we have a pending flush on the transport.
|
|
3265
|
+
bool pending_flush : 1;
|
|
3546
3266
|
|
|
3547
3267
|
// queued_key_update, if not kNone, indicates we've queued a KeyUpdate message
|
|
3548
3268
|
// to send after the current flight is ACKed.
|
|
@@ -3572,8 +3292,8 @@ struct DTLS1_STATE {
|
|
|
3572
3292
|
|
|
3573
3293
|
// incoming_messages is a ring buffer of incoming handshake messages that have
|
|
3574
3294
|
// yet to be processed. The front of the ring buffer is message number
|
|
3575
|
-
//
|
|
3576
|
-
//
|
|
3295
|
+
// `handshake_read_seq`, at position `handshake_read_seq` %
|
|
3296
|
+
// `SSL_MAX_HANDSHAKE_FLIGHT`.
|
|
3577
3297
|
UniquePtr<DTLSIncomingMessage> incoming_messages[SSL_MAX_HANDSHAKE_FLIGHT];
|
|
3578
3298
|
|
|
3579
3299
|
// outgoing_messages is the queue of outgoing messages from the last handshake
|
|
@@ -3624,7 +3344,7 @@ struct ALPSConfig {
|
|
|
3624
3344
|
|
|
3625
3345
|
// SSL_CONFIG contains configuration bits that can be shed after the handshake
|
|
3626
3346
|
// completes. Objects of this type are not shared; they are unique to a
|
|
3627
|
-
// particular
|
|
3347
|
+
// particular `SSL`.
|
|
3628
3348
|
//
|
|
3629
3349
|
// See SSL_shed_handshake_config() for more about the conditions under which
|
|
3630
3350
|
// configuration can be shed.
|
|
@@ -3634,17 +3354,17 @@ struct SSL_CONFIG {
|
|
|
3634
3354
|
explicit SSL_CONFIG(SSL *ssl_arg);
|
|
3635
3355
|
~SSL_CONFIG();
|
|
3636
3356
|
|
|
3637
|
-
// ssl is a non-owning pointer to the parent
|
|
3357
|
+
// ssl is a non-owning pointer to the parent `SSL` object.
|
|
3638
3358
|
SSL *const ssl = nullptr;
|
|
3639
3359
|
|
|
3640
3360
|
// conf_max_version is the maximum acceptable version configured by
|
|
3641
|
-
//
|
|
3642
|
-
// and is further constrained by
|
|
3361
|
+
// `SSL_set_max_proto_version`. Note this version is not normalized in DTLS
|
|
3362
|
+
// and is further constrained by `SSL_OP_NO_*`.
|
|
3643
3363
|
uint16_t conf_max_version = 0;
|
|
3644
3364
|
|
|
3645
3365
|
// conf_min_version is the minimum acceptable version configured by
|
|
3646
|
-
//
|
|
3647
|
-
// and is further constrained by
|
|
3366
|
+
// `SSL_set_min_proto_version`. Note this version is not normalized in DTLS
|
|
3367
|
+
// and is further constrained by `SSL_OP_NO_*`.
|
|
3648
3368
|
uint16_t conf_min_version = 0;
|
|
3649
3369
|
|
|
3650
3370
|
X509_VERIFY_PARAM *param = nullptr;
|
|
@@ -3676,7 +3396,7 @@ struct SSL_CONFIG {
|
|
|
3676
3396
|
UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
|
|
3677
3397
|
|
|
3678
3398
|
// cached_x509_client_CA is a cache of parsed versions of the elements of
|
|
3679
|
-
//
|
|
3399
|
+
// `client_CA`.
|
|
3680
3400
|
STACK_OF(X509_NAME) *cached_x509_client_CA = nullptr;
|
|
3681
3401
|
|
|
3682
3402
|
// For client side, keep the list of CA distinguished names we can use
|
|
@@ -3689,7 +3409,27 @@ struct SSL_CONFIG {
|
|
|
3689
3409
|
// Trust anchor IDs to be requested in the trust_anchors extension.
|
|
3690
3410
|
std::optional<Array<uint8_t>> requested_trust_anchors;
|
|
3691
3411
|
|
|
3692
|
-
|
|
3412
|
+
// Our list of supported groups. If this list is modified, for a client,
|
|
3413
|
+
// `client_key_share_selections` must be reset if the key shares are no longer
|
|
3414
|
+
// a valid subsequence of the supported group list.
|
|
3415
|
+
Array<uint16_t> supported_group_list;
|
|
3416
|
+
|
|
3417
|
+
// Contains flags corresponding to `supported_group_list`, which are
|
|
3418
|
+
// SSL_GROUP_FLAG_* values ORed together.
|
|
3419
|
+
Array<uint32_t> supported_group_list_flags;
|
|
3420
|
+
|
|
3421
|
+
// For a client, this may contain a subsequence of the group IDs in
|
|
3422
|
+
// `suppported_group_list`, which gives the groups for which key shares should
|
|
3423
|
+
// be sent in the client's key_share extension. This is non-nullopt iff
|
|
3424
|
+
// `SSL_set1_client_key_shares` was successfully called to configure key
|
|
3425
|
+
// shares. If non-nullopt, these groups are in the same order as they appear
|
|
3426
|
+
// in `supported_group_list`, and may not contain duplicates.
|
|
3427
|
+
std::optional<InplaceVector<uint16_t, kNumNamedGroups>>
|
|
3428
|
+
client_key_share_selections;
|
|
3429
|
+
|
|
3430
|
+
// For a client, this contains a list of groups believed to be supported by
|
|
3431
|
+
// the server, in server preference order.
|
|
3432
|
+
Array<uint16_t> server_supported_groups_hint;
|
|
3693
3433
|
|
|
3694
3434
|
// channel_id_private is the client's Channel ID private key, or null if
|
|
3695
3435
|
// Channel ID should not be offered on this connection.
|
|
@@ -3725,9 +3465,27 @@ struct SSL_CONFIG {
|
|
|
3725
3465
|
// negotiating a TLS 1.3 connection.
|
|
3726
3466
|
enum ssl_compliance_policy_t compliance_policy = ssl_compliance_policy_none;
|
|
3727
3467
|
|
|
3728
|
-
//
|
|
3468
|
+
// server_padding_request, if set by the client, indicates that the client
|
|
3469
|
+
// will ask the server to include additional padding in the
|
|
3470
|
+
// EncryptedExtensions message of a TLS 1.3 connection.
|
|
3471
|
+
std::optional<uint16_t> server_padding_request;
|
|
3472
|
+
|
|
3473
|
+
// verify_mode is a bitmask of `SSL_VERIFY_*` values.
|
|
3729
3474
|
uint8_t verify_mode = SSL_VERIFY_NONE;
|
|
3730
3475
|
|
|
3476
|
+
// accepted_peer_cert_types contains a list of `TLSEXT_cert_type_*` values in
|
|
3477
|
+
// preference order indicating the types of certificates to accept from the
|
|
3478
|
+
// peer. This list should always be non-empty. If the caller did not configure
|
|
3479
|
+
// a valid list, only X.509 certificates are accepted by default.
|
|
3480
|
+
InplaceVector<uint8_t, kNumCertTypes> accepted_peer_cert_types;
|
|
3481
|
+
|
|
3482
|
+
// available_client_cert_types, if not empty, contains a list of
|
|
3483
|
+
// `TLSEXT_cert_type_*` values in preference order indicating the types of
|
|
3484
|
+
// client certificates that the caller, as a client, explicitly configured and
|
|
3485
|
+
// wishes to advertise, instead of the automatically inferred client cert
|
|
3486
|
+
// types from the configured credential list.
|
|
3487
|
+
InplaceVector<uint8_t, kNumCertTypes> available_client_cert_types;
|
|
3488
|
+
|
|
3731
3489
|
// ech_grease_enabled controls whether ECH GREASE may be sent in the
|
|
3732
3490
|
// ClientHello.
|
|
3733
3491
|
bool ech_grease_enabled : 1;
|
|
@@ -3739,7 +3497,7 @@ struct SSL_CONFIG {
|
|
|
3739
3497
|
// whether OCSP stapling will be requested.
|
|
3740
3498
|
bool ocsp_stapling_enabled : 1;
|
|
3741
3499
|
|
|
3742
|
-
// channel_id_enabled is copied from the
|
|
3500
|
+
// channel_id_enabled is copied from the `SSL_CTX`. For a server, it means
|
|
3743
3501
|
// that we'll accept Channel IDs from clients. It is ignored on the client.
|
|
3744
3502
|
bool channel_id_enabled : 1;
|
|
3745
3503
|
|
|
@@ -3754,8 +3512,8 @@ struct SSL_CONFIG {
|
|
|
3754
3512
|
bool retain_only_sha256_of_client_certs : 1;
|
|
3755
3513
|
|
|
3756
3514
|
// handoff indicates that a server should stop after receiving the
|
|
3757
|
-
// ClientHello and pause the handshake in such a way that
|
|
3758
|
-
// returns
|
|
3515
|
+
// ClientHello and pause the handshake in such a way that `SSL_get_error`
|
|
3516
|
+
// returns `SSL_ERROR_HANDOFF`. This is copied in `SSL_new` from the `SSL_CTX`
|
|
3759
3517
|
// element of the same name and may be cleared if the handoff is declined.
|
|
3760
3518
|
bool handoff : 1;
|
|
3761
3519
|
|
|
@@ -3779,13 +3537,17 @@ struct SSL_CONFIG {
|
|
|
3779
3537
|
bool aes_hw_override : 1;
|
|
3780
3538
|
|
|
3781
3539
|
// aes_hw_override_value is used for testing to indicate the support or lack
|
|
3782
|
-
// of support for AES hw. The value is only considered if
|
|
3540
|
+
// of support for AES hw. The value is only considered if `aes_hw_override` is
|
|
3783
3541
|
// true.
|
|
3784
3542
|
bool aes_hw_override_value : 1;
|
|
3785
3543
|
|
|
3786
3544
|
// alps_use_new_codepoint if set indicates we use new ALPS extension codepoint
|
|
3787
3545
|
// to negotiate and convey application settings.
|
|
3788
3546
|
bool alps_use_new_codepoint : 1;
|
|
3547
|
+
|
|
3548
|
+
// server_padding_enabled is true iff the server is willing to send additional
|
|
3549
|
+
// padding to clients that request it through the server padding extension.
|
|
3550
|
+
bool server_padding_enabled : 1;
|
|
3789
3551
|
};
|
|
3790
3552
|
|
|
3791
3553
|
// From RFC 8446, used in determining PSK modes.
|
|
@@ -3799,35 +3561,35 @@ static const size_t kMaxEarlyDataAccepted = 14336;
|
|
|
3799
3561
|
UniquePtr<CERT> ssl_cert_dup(CERT *cert);
|
|
3800
3562
|
bool ssl_set_cert(CERT *cert, UniquePtr<CRYPTO_BUFFER> buffer);
|
|
3801
3563
|
bool ssl_is_key_type_supported(int key_type);
|
|
3802
|
-
// ssl_compare_public_and_private_key returns true if
|
|
3803
|
-
// counterpart to
|
|
3564
|
+
// ssl_compare_public_and_private_key returns true if `pubkey` is the public
|
|
3565
|
+
// counterpart to `privkey`. Otherwise it returns false and pushes a helpful
|
|
3804
3566
|
// message on the error queue.
|
|
3805
3567
|
bool ssl_compare_public_and_private_key(const EVP_PKEY *pubkey,
|
|
3806
3568
|
const EVP_PKEY *privkey);
|
|
3807
3569
|
bool ssl_get_new_session(SSL_HANDSHAKE *hs);
|
|
3808
3570
|
|
|
3809
|
-
// ssl_encrypt_ticket encrypt a ticket for
|
|
3810
|
-
//
|
|
3811
|
-
// was written to
|
|
3571
|
+
// ssl_encrypt_ticket encrypt a ticket for `session` and writes the result to
|
|
3572
|
+
// `out`. It returns true on success and false on error. If, on success, nothing
|
|
3573
|
+
// was written to `out`, the caller should skip sending a ticket.
|
|
3812
3574
|
bool ssl_encrypt_ticket(SSL_HANDSHAKE *hs, CBB *out,
|
|
3813
3575
|
const SSL_SESSION *session);
|
|
3814
3576
|
|
|
3815
|
-
bool ssl_ctx_rotate_ticket_encryption_key(
|
|
3577
|
+
bool ssl_ctx_rotate_ticket_encryption_key(SSLContext *ctx);
|
|
3816
3578
|
|
|
3817
|
-
// ssl_session_new returns a newly-allocated blank
|
|
3579
|
+
// ssl_session_new returns a newly-allocated blank `SSL_SESSION` or nullptr on
|
|
3818
3580
|
// error.
|
|
3819
3581
|
UniquePtr<SSL_SESSION> ssl_session_new(const SSL_X509_METHOD *x509_method);
|
|
3820
3582
|
|
|
3821
|
-
// ssl_hash_session_id returns a hash of
|
|
3583
|
+
// ssl_hash_session_id returns a hash of `session_id`, suitable for a hash table
|
|
3822
3584
|
// keyed on session IDs.
|
|
3823
3585
|
uint32_t ssl_hash_session_id(Span<const uint8_t> session_id);
|
|
3824
3586
|
|
|
3825
|
-
// SSL_SESSION_parse parses an
|
|
3587
|
+
// SSL_SESSION_parse parses an `SSL_SESSION` from `cbs` and advances `cbs` over
|
|
3826
3588
|
// the parsed data.
|
|
3827
3589
|
OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_parse(
|
|
3828
3590
|
CBS *cbs, const SSL_X509_METHOD *x509_method, CRYPTO_BUFFER_POOL *pool);
|
|
3829
3591
|
|
|
3830
|
-
// ssl_session_serialize writes
|
|
3592
|
+
// ssl_session_serialize writes `in` to `cbb` as if it were serialising a
|
|
3831
3593
|
// session for Session-ID resumption. It returns true on success and false on
|
|
3832
3594
|
// error.
|
|
3833
3595
|
OPENSSL_EXPORT bool ssl_session_serialize(const SSL_SESSION *in, CBB *cbb);
|
|
@@ -3843,38 +3605,43 @@ enum class SSLSessionType {
|
|
|
3843
3605
|
kPreSharedKey,
|
|
3844
3606
|
};
|
|
3845
3607
|
|
|
3846
|
-
// ssl_session_get_type returns the type of
|
|
3608
|
+
// ssl_session_get_type returns the type of `session`.
|
|
3847
3609
|
SSLSessionType ssl_session_get_type(const SSL_SESSION *session);
|
|
3848
3610
|
|
|
3849
|
-
// ssl_session_is_context_valid returns whether
|
|
3850
|
-
// matches the one set on
|
|
3611
|
+
// ssl_session_is_context_valid returns whether `session`'s session ID context
|
|
3612
|
+
// matches the one set on `hs`.
|
|
3851
3613
|
bool ssl_session_is_context_valid(const SSL_HANDSHAKE *hs,
|
|
3852
3614
|
const SSL_SESSION *session);
|
|
3853
3615
|
|
|
3854
|
-
// ssl_session_is_time_valid returns true if
|
|
3616
|
+
// ssl_session_is_time_valid returns true if `session` is still valid and false
|
|
3855
3617
|
// if it has expired.
|
|
3856
3618
|
bool ssl_session_is_time_valid(const SSL *ssl, const SSL_SESSION *session);
|
|
3857
3619
|
|
|
3858
|
-
// ssl_session_is_resumable returns whether
|
|
3620
|
+
// ssl_session_is_resumable returns whether `session` is resumable for `hs`.
|
|
3859
3621
|
bool ssl_session_is_resumable(const SSL_HANDSHAKE *hs,
|
|
3860
3622
|
const SSL_SESSION *session);
|
|
3861
3623
|
|
|
3862
3624
|
// ssl_session_protocol_version returns the protocol version associated with
|
|
3863
|
-
//
|
|
3864
|
-
//
|
|
3625
|
+
// `session`. Note that despite the name, this is not the same as
|
|
3626
|
+
// `SSL_SESSION_get_protocol_version`. The latter is based on upstream's name.
|
|
3865
3627
|
uint16_t ssl_session_protocol_version(const SSL_SESSION *session);
|
|
3866
3628
|
|
|
3867
|
-
// ssl_session_get_digest returns the digest used in
|
|
3629
|
+
// ssl_session_get_digest returns the digest used in `session`.
|
|
3868
3630
|
const EVP_MD *ssl_session_get_digest(const SSL_SESSION *session);
|
|
3869
3631
|
|
|
3632
|
+
// ssl_session_has_peer_cred returns whether `session` contains the peer's
|
|
3633
|
+
// (non-PSK) credentials (either X.509 cert chain or raw public key, depending
|
|
3634
|
+
// on the peer's certificate type) or a valid SHA-256 hash thereof.
|
|
3635
|
+
bool ssl_session_has_peer_cred(const SSL_SESSION *session);
|
|
3636
|
+
|
|
3870
3637
|
void ssl_set_session(SSL *ssl, SSL_SESSION *session);
|
|
3871
3638
|
|
|
3872
|
-
// ssl_get_prev_session looks up the previous session based on
|
|
3873
|
-
// On success, it sets
|
|
3639
|
+
// ssl_get_prev_session looks up the previous session based on `client_hello`.
|
|
3640
|
+
// On success, it sets `*out_session` to the session or nullptr if none was
|
|
3874
3641
|
// found. If the session could not be looked up synchronously, it returns
|
|
3875
|
-
//
|
|
3876
|
-
// decrypted immediately it returns
|
|
3877
|
-
// be called again. Otherwise, it returns
|
|
3642
|
+
// `ssl_hs_pending_session` and should be called again. If a ticket could not be
|
|
3643
|
+
// decrypted immediately it returns `ssl_hs_pending_ticket` and should also
|
|
3644
|
+
// be called again. Otherwise, it returns `ssl_hs_error`.
|
|
3878
3645
|
enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
|
|
3879
3646
|
UniquePtr<SSL_SESSION> *out_session,
|
|
3880
3647
|
bool *out_tickets_supported,
|
|
@@ -3888,18 +3655,18 @@ enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
|
|
|
3888
3655
|
#define SSL_SESSION_DUP_ALL \
|
|
3889
3656
|
(SSL_SESSION_INCLUDE_TICKET | SSL_SESSION_INCLUDE_NONAUTH)
|
|
3890
3657
|
|
|
3891
|
-
// SSL_SESSION_dup returns a newly-allocated
|
|
3892
|
-
// fields in
|
|
3658
|
+
// SSL_SESSION_dup returns a newly-allocated `SSL_SESSION` with a copy of the
|
|
3659
|
+
// fields in `session` or nullptr on error. The new session is non-resumable and
|
|
3893
3660
|
// must be explicitly marked resumable once it has been filled in.
|
|
3894
|
-
OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_dup(
|
|
3895
|
-
|
|
3661
|
+
OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_dup(
|
|
3662
|
+
const SSL_SESSION *session, int dup_flags);
|
|
3896
3663
|
|
|
3897
|
-
// ssl_session_rebase_time updates
|
|
3664
|
+
// ssl_session_rebase_time updates `session`'s start time to the current time,
|
|
3898
3665
|
// adjusting the timeout so the expiration time is unchanged.
|
|
3899
3666
|
void ssl_session_rebase_time(SSL *ssl, SSL_SESSION *session);
|
|
3900
3667
|
|
|
3901
|
-
// ssl_session_renew_timeout calls
|
|
3902
|
-
//
|
|
3668
|
+
// ssl_session_renew_timeout calls `ssl_session_rebase_time` and renews
|
|
3669
|
+
// `session`'s timeout to `timeout` (measured from the current time). The
|
|
3903
3670
|
// renewal is clamped to the session's auth_timeout.
|
|
3904
3671
|
void ssl_session_renew_timeout(SSL *ssl, SSL_SESSION *session,
|
|
3905
3672
|
uint32_t timeout);
|
|
@@ -3940,11 +3707,11 @@ void dtls1_finish_flight(SSL *ssl);
|
|
|
3940
3707
|
void dtls1_schedule_ack(SSL *ssl);
|
|
3941
3708
|
int dtls1_flush(SSL *ssl);
|
|
3942
3709
|
|
|
3943
|
-
// ssl_add_message_cbb finishes the handshake message in
|
|
3710
|
+
// ssl_add_message_cbb finishes the handshake message in `cbb` and adds it to
|
|
3944
3711
|
// the pending flight. It returns true on success and false on error.
|
|
3945
3712
|
bool ssl_add_message_cbb(SSL *ssl, CBB *cbb);
|
|
3946
3713
|
|
|
3947
|
-
// ssl_hash_message incorporates
|
|
3714
|
+
// ssl_hash_message incorporates `msg` into the handshake hash. It returns true
|
|
3948
3715
|
// on success and false on allocation failure.
|
|
3949
3716
|
bool ssl_hash_message(SSL_HANDSHAKE *hs, const SSLMessage &msg);
|
|
3950
3717
|
|
|
@@ -3979,7 +3746,7 @@ bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
|
|
|
3979
3746
|
|
|
3980
3747
|
void dtls1_stop_timer(SSL *ssl);
|
|
3981
3748
|
|
|
3982
|
-
unsigned int dtls1_min_mtu(
|
|
3749
|
+
unsigned int dtls1_min_mtu();
|
|
3983
3750
|
|
|
3984
3751
|
bool dtls1_new(SSL *ssl);
|
|
3985
3752
|
void dtls1_free(SSL *ssl);
|
|
@@ -3994,8 +3761,8 @@ void dtls1_next_message(SSL *ssl);
|
|
|
3994
3761
|
int dtls1_dispatch_alert(SSL *ssl);
|
|
3995
3762
|
|
|
3996
3763
|
// tls1_configure_aead configures either the read or write direction AEAD (as
|
|
3997
|
-
// determined by
|
|
3998
|
-
//
|
|
3764
|
+
// determined by `direction`) using the keys generated by the TLS KDF. The
|
|
3765
|
+
// `key_block_cache` argument is used to store the generated key block, if
|
|
3999
3766
|
// empty. Otherwise it's assumed that the key block is already contained within
|
|
4000
3767
|
// it. It returns true on success or false on error.
|
|
4001
3768
|
bool tls1_configure_aead(SSL *ssl, evp_aead_direction_t direction,
|
|
@@ -4006,40 +3773,30 @@ bool tls1_configure_aead(SSL *ssl, evp_aead_direction_t direction,
|
|
|
4006
3773
|
bool tls1_change_cipher_state(SSL_HANDSHAKE *hs,
|
|
4007
3774
|
evp_aead_direction_t direction);
|
|
4008
3775
|
|
|
4009
|
-
// tls1_generate_master_secret computes the master secret from
|
|
4010
|
-
// writes it to
|
|
3776
|
+
// tls1_generate_master_secret computes the master secret from `premaster` and
|
|
3777
|
+
// writes it to `out`. `out` must have size `SSL3_MASTER_SECRET_SIZE`.
|
|
4011
3778
|
bool tls1_generate_master_secret(SSL_HANDSHAKE *hs, Span<uint8_t> out,
|
|
4012
3779
|
Span<const uint8_t> premaster);
|
|
4013
3780
|
|
|
4014
|
-
//
|
|
4015
|
-
Span<const uint16_t> tls1_get_grouplist(const SSL_HANDSHAKE *ssl);
|
|
4016
|
-
|
|
4017
|
-
// tls1_check_group_id returns whether |group_id| is consistent with locally-
|
|
3781
|
+
// tls1_check_group_id returns whether `group_id` is consistent with locally-
|
|
4018
3782
|
// configured group preferences.
|
|
4019
3783
|
bool tls1_check_group_id(const SSL_HANDSHAKE *ssl, uint16_t group_id);
|
|
4020
3784
|
|
|
4021
|
-
// tls1_get_shared_group sets
|
|
3785
|
+
// tls1_get_shared_group sets `*out_group_id` to the first preferred shared
|
|
4022
3786
|
// group between client and server preferences and returns true. If none may be
|
|
4023
3787
|
// found, it returns false.
|
|
4024
3788
|
bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id);
|
|
4025
3789
|
|
|
4026
|
-
// ssl_add_clienthello_tlsext writes ClientHello extensions to
|
|
4027
|
-
// It returns true on success and false on failure.
|
|
4028
|
-
//
|
|
4029
|
-
//
|
|
3790
|
+
// ssl_add_clienthello_tlsext writes ClientHello extensions to `out` for `type`.
|
|
3791
|
+
// It returns true on success and false on failure. `out` must currently contain
|
|
3792
|
+
// a ClientHello message, not including the message and record header. (Its
|
|
3793
|
+
// contents will be used to compute padding and PSK binders.)
|
|
4030
3794
|
//
|
|
4031
|
-
// If
|
|
4032
|
-
// compressed extensions to
|
|
3795
|
+
// If `type` is `ssl_client_hello_inner`, this function also writes the
|
|
3796
|
+
// compressed extensions to `out_encoded`. Otherwise, `out_encoded` should be
|
|
4033
3797
|
// nullptr.
|
|
4034
|
-
//
|
|
4035
|
-
// On success, the function sets |*out_needs_psk_binder| to whether the last
|
|
4036
|
-
// ClientHello extension was the pre_shared_key extension and needs a PSK binder
|
|
4037
|
-
// filled in. The caller should then update |out| and, if applicable,
|
|
4038
|
-
// |out_encoded| with the binder after completing the whole message.
|
|
4039
3798
|
bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
|
|
4040
|
-
|
|
4041
|
-
ssl_client_hello_type_t type,
|
|
4042
|
-
size_t header_len);
|
|
3799
|
+
ssl_client_hello_type_t type);
|
|
4043
3800
|
|
|
4044
3801
|
bool ssl_add_serverhello_tlsext(SSL_HANDSHAKE *hs, CBB *out);
|
|
4045
3802
|
bool ssl_parse_clienthello_tlsext(SSL_HANDSHAKE *hs,
|
|
@@ -4050,50 +3807,53 @@ bool ssl_parse_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *extensions);
|
|
|
4050
3807
|
|
|
4051
3808
|
// ssl_process_ticket processes a session ticket from the client. It returns
|
|
4052
3809
|
// one of:
|
|
4053
|
-
//
|
|
4054
|
-
//
|
|
4055
|
-
//
|
|
3810
|
+
// `ssl_ticket_aead_success`: `*out_session` is set to the parsed session and
|
|
3811
|
+
// `*out_renew_ticket` is set to whether the ticket should be renewed.
|
|
3812
|
+
// `ssl_ticket_aead_ignore_ticket`: `*out_renew_ticket` is set to whether a
|
|
4056
3813
|
// fresh ticket should be sent, but the given ticket cannot be used.
|
|
4057
|
-
//
|
|
3814
|
+
// `ssl_ticket_aead_retry`: the ticket could not be immediately decrypted.
|
|
4058
3815
|
// Retry later.
|
|
4059
|
-
//
|
|
3816
|
+
// `ssl_ticket_aead_error`: an error occurred that is fatal to the connection.
|
|
3817
|
+
//
|
|
3818
|
+
// If `save_ticket` is true, `*out_session` will have a copy of the ticket saved
|
|
3819
|
+
// in its `ticket` field.
|
|
4060
3820
|
enum ssl_ticket_aead_result_t ssl_process_ticket(
|
|
4061
3821
|
SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
|
|
4062
3822
|
bool *out_renew_ticket, Span<const uint8_t> ticket,
|
|
4063
|
-
Span<const uint8_t> session_id);
|
|
3823
|
+
Span<const uint8_t> session_id, bool save_ticket);
|
|
4064
3824
|
|
|
4065
|
-
// tls1_verify_channel_id processes
|
|
3825
|
+
// tls1_verify_channel_id processes `msg` as a Channel ID message, and verifies
|
|
4066
3826
|
// the signature. If the key is valid, it saves the Channel ID and returns true.
|
|
4067
3827
|
// Otherwise, it returns false.
|
|
4068
3828
|
bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg);
|
|
4069
3829
|
|
|
4070
3830
|
// tls1_write_channel_id generates a Channel ID message and puts the output in
|
|
4071
|
-
//
|
|
3831
|
+
// `cbb`. `ssl->channel_id_private` must already be set before calling. This
|
|
4072
3832
|
// function returns true on success and false on error.
|
|
4073
3833
|
bool tls1_write_channel_id(SSL_HANDSHAKE *hs, CBB *cbb);
|
|
4074
3834
|
|
|
4075
3835
|
// tls1_channel_id_hash computes the hash to be signed by Channel ID and writes
|
|
4076
|
-
// it to
|
|
3836
|
+
// it to `out`, which must contain at least `EVP_MAX_MD_SIZE` bytes. It returns
|
|
4077
3837
|
// true on success and false on failure.
|
|
4078
3838
|
bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len);
|
|
4079
3839
|
|
|
4080
3840
|
// tls1_record_handshake_hashes_for_channel_id records the current handshake
|
|
4081
|
-
// hashes in
|
|
3841
|
+
// hashes in `hs->new_session` so that Channel ID resumptions can sign that
|
|
4082
3842
|
// data.
|
|
4083
3843
|
bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs);
|
|
4084
3844
|
|
|
4085
|
-
// ssl_can_write returns whether
|
|
3845
|
+
// ssl_can_write returns whether `ssl` is allowed to write.
|
|
4086
3846
|
bool ssl_can_write(const SSL *ssl);
|
|
4087
3847
|
|
|
4088
|
-
// ssl_can_read returns
|
|
3848
|
+
// ssl_can_read returns whether `ssl` is allowed to read.
|
|
4089
3849
|
bool ssl_can_read(const SSL *ssl);
|
|
4090
3850
|
|
|
4091
|
-
OPENSSL_timeval ssl_ctx_get_current_time(const
|
|
3851
|
+
OPENSSL_timeval ssl_ctx_get_current_time(const SSLContext *ctx);
|
|
4092
3852
|
|
|
4093
|
-
// ssl_reset_error_state resets state for
|
|
3853
|
+
// ssl_reset_error_state resets state for `SSL_get_error`.
|
|
4094
3854
|
void ssl_reset_error_state(SSL *ssl);
|
|
4095
3855
|
|
|
4096
|
-
// ssl_set_read_error sets
|
|
3856
|
+
// ssl_set_read_error sets `ssl`'s read half into an error state, saving the
|
|
4097
3857
|
// current state of the error queue.
|
|
4098
3858
|
void ssl_set_read_error(SSL *ssl);
|
|
4099
3859
|
|
|
@@ -4104,8 +3864,10 @@ BSSL_NAMESPACE_END
|
|
|
4104
3864
|
//
|
|
4105
3865
|
// The following types are exported to C code as public typedefs, so they must
|
|
4106
3866
|
// be defined outside of the namespace.
|
|
3867
|
+
//
|
|
3868
|
+
// TODO(crbug.com/500444613): Move these to the bssl namespace.
|
|
4107
3869
|
|
|
4108
|
-
// ssl_method_st backs the public
|
|
3870
|
+
// ssl_method_st backs the public `SSL_METHOD` type. It is a compatibility
|
|
4109
3871
|
// structure to support the legacy version-locked methods.
|
|
4110
3872
|
struct ssl_method_st {
|
|
4111
3873
|
// version, if non-zero, is the only protocol version acceptable to an
|
|
@@ -4114,30 +3876,32 @@ struct ssl_method_st {
|
|
|
4114
3876
|
// method is the underlying SSL_PROTOCOL_METHOD that initializes the
|
|
4115
3877
|
// SSL_CTX.
|
|
4116
3878
|
const bssl::SSL_PROTOCOL_METHOD *method;
|
|
4117
|
-
// x509_method contains pointers to functions that might deal with
|
|
3879
|
+
// x509_method contains pointers to functions that might deal with `X509`
|
|
4118
3880
|
// compatibility, or might be a no-op, depending on the application.
|
|
4119
3881
|
const bssl::SSL_X509_METHOD *x509_method;
|
|
4120
3882
|
};
|
|
4121
3883
|
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
3884
|
+
BSSL_NAMESPACE_BEGIN
|
|
3885
|
+
class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
|
|
3886
|
+
public:
|
|
3887
|
+
explicit SSLContext(const SSL_METHOD *ssl_method);
|
|
3888
|
+
SSLContext(const SSLContext &) = delete;
|
|
3889
|
+
SSLContext &operator=(const SSLContext &) = delete;
|
|
4126
3890
|
|
|
4127
|
-
const
|
|
4128
|
-
const
|
|
3891
|
+
const SSL_PROTOCOL_METHOD *method = nullptr;
|
|
3892
|
+
const SSL_X509_METHOD *x509_method = nullptr;
|
|
4129
3893
|
|
|
4130
3894
|
// lock is used to protect various operations on this object.
|
|
4131
|
-
|
|
3895
|
+
mutable Mutex lock;
|
|
4132
3896
|
|
|
4133
3897
|
// conf_max_version is the maximum acceptable protocol version configured by
|
|
4134
|
-
//
|
|
4135
|
-
// and is further
|
|
3898
|
+
// `SSL_CTX_set_max_proto_version`. Note this version is normalized in DTLS
|
|
3899
|
+
// and is further constrained by `SSL_OP_NO_*`.
|
|
4136
3900
|
uint16_t conf_max_version = 0;
|
|
4137
3901
|
|
|
4138
3902
|
// conf_min_version is the minimum acceptable protocol version configured by
|
|
4139
|
-
//
|
|
4140
|
-
// and is further
|
|
3903
|
+
// `SSL_CTX_set_min_proto_version`. Note this version is normalized in DTLS
|
|
3904
|
+
// and is further constrained by `SSL_OP_NO_*`.
|
|
4141
3905
|
uint16_t conf_min_version = 0;
|
|
4142
3906
|
|
|
4143
3907
|
// num_tickets is the number of tickets to send immediately after the TLS 1.3
|
|
@@ -4148,7 +3912,7 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4148
3912
|
// quic_method is the method table corresponding to the QUIC hooks.
|
|
4149
3913
|
const SSL_QUIC_METHOD *quic_method = nullptr;
|
|
4150
3914
|
|
|
4151
|
-
|
|
3915
|
+
UniquePtr<SSLCipherPreferenceList> cipher_list;
|
|
4152
3916
|
|
|
4153
3917
|
X509_STORE *cert_store = nullptr;
|
|
4154
3918
|
LHASH_OF(SSL_SESSION) *sessions = nullptr;
|
|
@@ -4213,28 +3977,28 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4213
3977
|
void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
|
|
4214
3978
|
|
|
4215
3979
|
// what we put in client cert requests
|
|
4216
|
-
|
|
3980
|
+
UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
|
|
4217
3981
|
|
|
4218
3982
|
// cached_x509_client_CA is a cache of parsed versions of the elements of
|
|
4219
|
-
//
|
|
3983
|
+
// `client_CA`.
|
|
4220
3984
|
STACK_OF(X509_NAME) *cached_x509_client_CA = nullptr;
|
|
4221
3985
|
|
|
4222
3986
|
// What we put in client hello in the CA extension.
|
|
4223
|
-
|
|
3987
|
+
UniquePtr<STACK_OF(CRYPTO_BUFFER)> CA_names;
|
|
4224
3988
|
|
|
4225
3989
|
// What we request in the trust_anchors extension.
|
|
4226
|
-
std::optional<
|
|
3990
|
+
std::optional<Array<uint8_t>> requested_trust_anchors;
|
|
4227
3991
|
|
|
4228
3992
|
// Default values to use in SSL structures follow (these are copied by
|
|
4229
3993
|
// SSL_new)
|
|
4230
3994
|
|
|
4231
|
-
uint32_t options =
|
|
3995
|
+
uint32_t options = SSL_OP_ALL;
|
|
4232
3996
|
// Disable the auto-chaining feature by default. wpa_supplicant relies on this
|
|
4233
3997
|
// feature, but require callers opt into it.
|
|
4234
3998
|
uint32_t mode = SSL_MODE_NO_AUTO_CHAIN;
|
|
4235
3999
|
uint32_t max_cert_list = SSL_MAX_CERT_LIST_DEFAULT;
|
|
4236
4000
|
|
|
4237
|
-
|
|
4001
|
+
UniquePtr<CERT> cert;
|
|
4238
4002
|
|
|
4239
4003
|
// callback that allows applications to peek at protocol messages
|
|
4240
4004
|
void (*msg_callback)(int is_write, int version, int content_type,
|
|
@@ -4250,7 +4014,7 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4250
4014
|
|
|
4251
4015
|
// select_certificate_cb is called before most ClientHello processing and
|
|
4252
4016
|
// before the decision whether to resume a session is made. See
|
|
4253
|
-
//
|
|
4017
|
+
// `ssl_select_cert_result_t` for details of the return values.
|
|
4254
4018
|
ssl_select_cert_result_t (*select_certificate_cb)(const SSL_CLIENT_HELLO *) =
|
|
4255
4019
|
nullptr;
|
|
4256
4020
|
|
|
@@ -4272,12 +4036,12 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4272
4036
|
int (*servername_callback)(SSL *, int *, void *) = nullptr;
|
|
4273
4037
|
void *servername_arg = nullptr;
|
|
4274
4038
|
|
|
4275
|
-
// RFC 4507 session ticket keys.
|
|
4276
|
-
// first handshake and
|
|
4039
|
+
// RFC 4507 session ticket keys. `ticket_key_current` may be NULL before the
|
|
4040
|
+
// first handshake and `ticket_key_prev` may be NULL at any time.
|
|
4277
4041
|
// Automatically generated ticket keys are rotated as needed at handshake
|
|
4278
|
-
// time. Hence, all access must be synchronized through
|
|
4279
|
-
|
|
4280
|
-
|
|
4042
|
+
// time. Hence, all access must be synchronized through `lock`.
|
|
4043
|
+
UniquePtr<TicketKey> ticket_key_current;
|
|
4044
|
+
UniquePtr<TicketKey> ticket_key_prev;
|
|
4281
4045
|
|
|
4282
4046
|
// Callback to support customisation of ticket key setting
|
|
4283
4047
|
int (*ticket_key_cb)(SSL *ssl, uint8_t *name, uint8_t *iv,
|
|
@@ -4285,7 +4049,7 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4285
4049
|
|
|
4286
4050
|
// Server-only: psk_identity_hint is the default identity hint to send in
|
|
4287
4051
|
// PSK-based key exchanges.
|
|
4288
|
-
|
|
4052
|
+
UniquePtr<char> psk_identity_hint;
|
|
4289
4053
|
|
|
4290
4054
|
unsigned (*psk_client_callback)(SSL *ssl, const char *hint, char *identity,
|
|
4291
4055
|
unsigned max_identity_len, uint8_t *psk,
|
|
@@ -4316,10 +4080,10 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4316
4080
|
// server to select the protocol for the connection.
|
|
4317
4081
|
// out: on successful return, this must point to the raw protocol
|
|
4318
4082
|
// name (without the length prefix).
|
|
4319
|
-
// outlen: on successful return, this contains the length of
|
|
4083
|
+
// outlen: on successful return, this contains the length of `*out`.
|
|
4320
4084
|
// in: points to the client's list of supported protocols in
|
|
4321
4085
|
// wire-format.
|
|
4322
|
-
// inlen: the length of
|
|
4086
|
+
// inlen: the length of `in`.
|
|
4323
4087
|
int (*alpn_select_cb)(SSL *ssl, const uint8_t **out, uint8_t *out_len,
|
|
4324
4088
|
const uint8_t *in, unsigned in_len,
|
|
4325
4089
|
void *arg) = nullptr;
|
|
@@ -4327,38 +4091,39 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4327
4091
|
|
|
4328
4092
|
// For a client, this contains the list of supported protocols in wire
|
|
4329
4093
|
// format.
|
|
4330
|
-
|
|
4094
|
+
Array<uint8_t> alpn_client_proto_list;
|
|
4331
4095
|
|
|
4332
4096
|
// SRTP profiles we are willing to do from RFC 5764
|
|
4333
|
-
|
|
4097
|
+
UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> srtp_profiles;
|
|
4334
4098
|
|
|
4335
4099
|
// Defined compression algorithms for certificates.
|
|
4336
|
-
|
|
4100
|
+
Vector<CertCompressionAlg> cert_compression_algs;
|
|
4337
4101
|
|
|
4338
|
-
// Supported group values inherited by SSL structure
|
|
4339
|
-
|
|
4102
|
+
// Supported group values and flags inherited by SSL structure
|
|
4103
|
+
Array<uint16_t> supported_group_list;
|
|
4104
|
+
Array<uint32_t> supported_group_list_flags;
|
|
4340
4105
|
|
|
4341
4106
|
// channel_id_private is the client's Channel ID private key, or null if
|
|
4342
4107
|
// Channel ID should not be offered on this connection.
|
|
4343
|
-
|
|
4108
|
+
UniquePtr<EVP_PKEY> channel_id_private;
|
|
4344
4109
|
|
|
4345
4110
|
// ech_keys contains the server's list of ECHConfig values and associated
|
|
4346
4111
|
// private keys. This list may be swapped out at any time, so all access must
|
|
4347
|
-
// be synchronized through
|
|
4348
|
-
|
|
4112
|
+
// be synchronized through `lock`.
|
|
4113
|
+
UniquePtr<SSLECHKeys> ech_keys;
|
|
4349
4114
|
|
|
4350
4115
|
// keylog_callback, if not NULL, is the key logging callback. See
|
|
4351
|
-
//
|
|
4116
|
+
// `SSL_CTX_set_keylog_callback`.
|
|
4352
4117
|
void (*keylog_callback)(const SSL *ssl, const char *line) = nullptr;
|
|
4353
4118
|
|
|
4354
4119
|
// current_time_cb, if not NULL, is the function to use to get the current
|
|
4355
|
-
// time. It sets
|
|
4356
|
-
// always NULL. See
|
|
4120
|
+
// time. It sets `*out_clock` to the current time. The `ssl` argument is
|
|
4121
|
+
// always NULL. See `SSL_CTX_set_current_time_cb`.
|
|
4357
4122
|
void (*current_time_cb)(const SSL *ssl, struct timeval *out_clock) = nullptr;
|
|
4358
4123
|
|
|
4359
|
-
// pool is used for all
|
|
4124
|
+
// pool is used for all `CRYPTO_BUFFER`s in case we wish to share certificate
|
|
4360
4125
|
// memory.
|
|
4361
|
-
CRYPTO_BUFFER_POOL
|
|
4126
|
+
UniquePtr<CRYPTO_BUFFER_POOL> pool;
|
|
4362
4127
|
|
|
4363
4128
|
// ticket_aead_method contains function pointers for opening and sealing
|
|
4364
4129
|
// session tickets.
|
|
@@ -4375,7 +4140,13 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4375
4140
|
|
|
4376
4141
|
// verify_sigalgs, if not empty, is the set of signature algorithms
|
|
4377
4142
|
// accepted from the peer in decreasing order of preference.
|
|
4378
|
-
|
|
4143
|
+
Array<uint16_t> verify_sigalgs;
|
|
4144
|
+
|
|
4145
|
+
// accepted_peer_cert_types inherited by SSL struct.
|
|
4146
|
+
InplaceVector<uint8_t, kNumCertTypes> accepted_peer_cert_types;
|
|
4147
|
+
|
|
4148
|
+
// available_client_cert_types inherited by SSL struct.
|
|
4149
|
+
InplaceVector<uint8_t, kNumCertTypes> available_client_cert_types;
|
|
4379
4150
|
|
|
4380
4151
|
// retain_only_sha256_of_client_certs is true if we should compute the SHA256
|
|
4381
4152
|
// hash of the peer's certificate and then discard it to save memory and
|
|
@@ -4409,12 +4180,12 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4409
4180
|
bool allow_unknown_alpn_protos : 1;
|
|
4410
4181
|
|
|
4411
4182
|
// false_start_allowed_without_alpn is whether False Start (if
|
|
4412
|
-
//
|
|
4183
|
+
// `SSL_MODE_ENABLE_FALSE_START` is enabled) is allowed without ALPN.
|
|
4413
4184
|
bool false_start_allowed_without_alpn : 1;
|
|
4414
4185
|
|
|
4415
4186
|
// handoff indicates that a server should stop after receiving the
|
|
4416
|
-
// ClientHello and pause the handshake in such a way that
|
|
4417
|
-
// returns
|
|
4187
|
+
// ClientHello and pause the handshake in such a way that `SSL_get_error`
|
|
4188
|
+
// returns `SSL_ERROR_HANDOFF`.
|
|
4418
4189
|
bool handoff : 1;
|
|
4419
4190
|
|
|
4420
4191
|
// If enable_early_data is true, early data can be sent and accepted.
|
|
@@ -4426,7 +4197,7 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4426
4197
|
|
|
4427
4198
|
// aes_hw_override_value is used for testing to indicate the support or lack
|
|
4428
4199
|
// of support for AES hardware. The value is only considered if
|
|
4429
|
-
//
|
|
4200
|
+
// `aes_hw_override` is true.
|
|
4430
4201
|
bool aes_hw_override_value : 1;
|
|
4431
4202
|
|
|
4432
4203
|
// resumption_across_names_enabled indicates whether a TLS 1.3 server should
|
|
@@ -4435,11 +4206,12 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
|
|
|
4435
4206
|
|
|
4436
4207
|
private:
|
|
4437
4208
|
friend RefCounted;
|
|
4438
|
-
~
|
|
4209
|
+
~SSLContext();
|
|
4439
4210
|
};
|
|
4211
|
+
BSSL_NAMESPACE_END
|
|
4440
4212
|
|
|
4441
4213
|
struct ssl_st {
|
|
4442
|
-
explicit ssl_st(
|
|
4214
|
+
explicit ssl_st(bssl::SSLContext *ctx_arg);
|
|
4443
4215
|
ssl_st(const ssl_st &) = delete;
|
|
4444
4216
|
ssl_st &operator=(const ssl_st &) = delete;
|
|
4445
4217
|
~ssl_st();
|
|
@@ -4450,7 +4222,7 @@ struct ssl_st {
|
|
|
4450
4222
|
|
|
4451
4223
|
// config is a container for handshake configuration. Accesses to this field
|
|
4452
4224
|
// should check for nullptr, since configuration may be shed after the
|
|
4453
|
-
// handshake completes. (If you have the
|
|
4225
|
+
// handshake completes. (If you have the `SSL_HANDSHAKE` object at hand, use
|
|
4454
4226
|
// that instead, and skip the null check.)
|
|
4455
4227
|
bssl::UniquePtr<bssl::SSL_CONFIG> config;
|
|
4456
4228
|
|
|
@@ -4462,7 +4234,7 @@ struct ssl_st {
|
|
|
4462
4234
|
bssl::UniquePtr<BIO> rbio; // used by SSL_read
|
|
4463
4235
|
bssl::UniquePtr<BIO> wbio; // used by SSL_write
|
|
4464
4236
|
|
|
4465
|
-
// do_handshake runs the handshake. On completion, it returns
|
|
4237
|
+
// do_handshake runs the handshake. On completion, it returns `ssl_hs_ok`.
|
|
4466
4238
|
// Otherwise, it returns a value corresponding to what operation is needed to
|
|
4467
4239
|
// progress.
|
|
4468
4240
|
bssl::ssl_hs_wait_t (*do_handshake)(bssl::SSL_HANDSHAKE *hs) = nullptr;
|
|
@@ -4489,11 +4261,11 @@ struct ssl_st {
|
|
|
4489
4261
|
|
|
4490
4262
|
void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
|
|
4491
4263
|
|
|
4492
|
-
bssl::UniquePtr<
|
|
4264
|
+
bssl::UniquePtr<bssl::SSLContext> ctx;
|
|
4493
4265
|
|
|
4494
|
-
// session_ctx is the
|
|
4266
|
+
// session_ctx is the `SSLContext` used for the session cache and related
|
|
4495
4267
|
// settings.
|
|
4496
|
-
bssl::UniquePtr<
|
|
4268
|
+
bssl::UniquePtr<bssl::SSLContext> session_ctx;
|
|
4497
4269
|
|
|
4498
4270
|
// extra application data
|
|
4499
4271
|
CRYPTO_EX_DATA ex_data;
|
|
@@ -4544,7 +4316,7 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
|
|
|
4544
4316
|
|
|
4545
4317
|
// secret, in TLS 1.2 and below, is the master secret associated with the
|
|
4546
4318
|
// session. In TLS 1.3 and up, it is the resumption PSK for sessions handed to
|
|
4547
|
-
// the caller, but it stores the resumption secret when stored on
|
|
4319
|
+
// the caller, but it stores the resumption secret when stored on `SSL`
|
|
4548
4320
|
// objects.
|
|
4549
4321
|
bssl::InplaceVector<uint8_t, SSL_MAX_MASTER_KEY_LENGTH> secret;
|
|
4550
4322
|
|
|
@@ -4558,36 +4330,39 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
|
|
|
4558
4330
|
bssl::UniquePtr<char> psk_identity;
|
|
4559
4331
|
|
|
4560
4332
|
// certs contains the certificate chain from the peer, starting with the leaf
|
|
4561
|
-
// certificate.
|
|
4333
|
+
// certificate. This must be null if `peer_raw_public_key` is non-null.
|
|
4562
4334
|
bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> certs;
|
|
4563
4335
|
|
|
4564
4336
|
const bssl::SSL_X509_METHOD *x509_method = nullptr;
|
|
4565
4337
|
|
|
4566
|
-
// x509_peer is the peer's certificate.
|
|
4338
|
+
// x509_peer is the peer's certificate. This must be null if
|
|
4339
|
+
// `peer_raw_public_key` is non-null.
|
|
4567
4340
|
X509 *x509_peer = nullptr;
|
|
4568
4341
|
|
|
4569
4342
|
// x509_chain is the certificate chain sent by the peer. NOTE: for historical
|
|
4570
4343
|
// reasons, when a client (so the peer is a server), the chain includes
|
|
4571
|
-
//
|
|
4344
|
+
// `peer`, but when a server it does not. This must be null if
|
|
4345
|
+
// `peer_raw_public_key` is non-null.
|
|
4572
4346
|
STACK_OF(X509) *x509_chain = nullptr;
|
|
4573
4347
|
|
|
4574
|
-
// x509_chain_without_leaf is a lazily constructed copy of
|
|
4348
|
+
// x509_chain_without_leaf is a lazily constructed copy of `x509_chain` that
|
|
4575
4349
|
// omits the leaf certificate. This exists because OpenSSL, historically,
|
|
4576
4350
|
// didn't include the leaf certificate in the chain for a server, but did for
|
|
4577
|
-
// a client. The
|
|
4578
|
-
// a chain without, it is stored here.
|
|
4351
|
+
// a client. The `x509_chain` always includes it and, if an API call requires
|
|
4352
|
+
// a chain without, it is stored here. This must be null if
|
|
4353
|
+
// `peer_raw_public_key` is non-null.
|
|
4579
4354
|
STACK_OF(X509) *x509_chain_without_leaf = nullptr;
|
|
4580
4355
|
|
|
4581
4356
|
// verify_result is the result of certificate verification in the case of
|
|
4582
4357
|
// non-fatal certificate errors.
|
|
4583
4358
|
long verify_result = X509_V_ERR_INVALID_CALL;
|
|
4584
4359
|
|
|
4585
|
-
// timeout is the lifetime of the session in seconds, measured from
|
|
4586
|
-
// This is renewable up to
|
|
4360
|
+
// timeout is the lifetime of the session in seconds, measured from `time`.
|
|
4361
|
+
// This is renewable up to `auth_timeout`.
|
|
4587
4362
|
uint32_t timeout = SSL_DEFAULT_SESSION_TIMEOUT;
|
|
4588
4363
|
|
|
4589
4364
|
// auth_timeout is the non-renewable lifetime of the session in seconds,
|
|
4590
|
-
// measured from
|
|
4365
|
+
// measured from `time`.
|
|
4591
4366
|
uint32_t auth_timeout = SSL_DEFAULT_SESSION_TIMEOUT;
|
|
4592
4367
|
|
|
4593
4368
|
// time is the time the session was issued, measured in seconds from the UNIX
|
|
@@ -4609,8 +4384,9 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
|
|
|
4609
4384
|
// The OCSP response that came with the session.
|
|
4610
4385
|
bssl::UniquePtr<CRYPTO_BUFFER> ocsp_response;
|
|
4611
4386
|
|
|
4612
|
-
// peer_sha256 contains the SHA-256 hash of the peer's certificate
|
|
4613
|
-
//
|
|
4387
|
+
// peer_sha256 contains the SHA-256 hash of the peer's X.509 certificate or
|
|
4388
|
+
// raw public key if `peer_sha256_valid` is true. (`peer_cert_type` indicates
|
|
4389
|
+
// which type of credential is hashed here.)
|
|
4614
4390
|
uint8_t peer_sha256[SHA256_DIGEST_LENGTH] = {0};
|
|
4615
4391
|
|
|
4616
4392
|
// original_handshake_hash contains the handshake hash (either SHA-1+MD5 or
|
|
@@ -4629,14 +4405,14 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
|
|
|
4629
4405
|
// early_alpn is the ALPN protocol from the initial handshake. This is only
|
|
4630
4406
|
// stored for TLS 1.3 and above in order to enforce ALPN matching for 0-RTT
|
|
4631
4407
|
// resumptions. For the current connection's ALPN protocol, see
|
|
4632
|
-
//
|
|
4408
|
+
// `alpn_selected` on `SSL3_STATE`.
|
|
4633
4409
|
bssl::Array<uint8_t> early_alpn;
|
|
4634
4410
|
|
|
4635
|
-
// local_application_settings, if
|
|
4411
|
+
// local_application_settings, if `has_application_settings` is true, is the
|
|
4636
4412
|
// local ALPS value for this connection.
|
|
4637
4413
|
bssl::Array<uint8_t> local_application_settings;
|
|
4638
4414
|
|
|
4639
|
-
// peer_application_settings, if
|
|
4415
|
+
// peer_application_settings, if `has_application_settings` is true, is the
|
|
4640
4416
|
// peer ALPS value for this connection.
|
|
4641
4417
|
bssl::Array<uint8_t> peer_application_settings;
|
|
4642
4418
|
|
|
@@ -4645,13 +4421,13 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
|
|
|
4645
4421
|
// attack.
|
|
4646
4422
|
bool extended_master_secret : 1;
|
|
4647
4423
|
|
|
4648
|
-
// peer_sha256_valid is whether
|
|
4424
|
+
// peer_sha256_valid is whether `peer_sha256` is valid.
|
|
4649
4425
|
bool peer_sha256_valid : 1; // Non-zero if peer_sha256 is valid
|
|
4650
4426
|
|
|
4651
4427
|
// not_resumable is used to indicate that session resumption is disallowed.
|
|
4652
4428
|
bool not_resumable : 1;
|
|
4653
4429
|
|
|
4654
|
-
// ticket_age_add_valid is whether
|
|
4430
|
+
// ticket_age_add_valid is whether `ticket_age_add` is valid.
|
|
4655
4431
|
bool ticket_age_add_valid : 1;
|
|
4656
4432
|
|
|
4657
4433
|
// is_server is whether this session was created by a server.
|
|
@@ -4672,19 +4448,19 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
|
|
|
4672
4448
|
// rejected when performing a QUIC handshake.
|
|
4673
4449
|
bssl::Array<uint8_t> quic_early_data_context;
|
|
4674
4450
|
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
struct ssl_ech_keys_st : public bssl::RefCounted<ssl_ech_keys_st> {
|
|
4681
|
-
ssl_ech_keys_st() : RefCounted(CheckSubClass()) {}
|
|
4451
|
+
// peer_cert_type is the peer's cert type (`TLSEXT_cert_type_*` value), which
|
|
4452
|
+
// determines the type of Certificate the peer used for this session: which of
|
|
4453
|
+
// `certs` xor `peer_raw_public_key` is populated for an authenticated
|
|
4454
|
+
// session.
|
|
4455
|
+
uint8_t peer_cert_type = bssl::kDefaultCertType;
|
|
4682
4456
|
|
|
4683
|
-
|
|
4457
|
+
// peer_raw_public_key, if non-null, is the raw public key received from the
|
|
4458
|
+
// peer. This must be null if `certs` is non-null.
|
|
4459
|
+
bssl::UniquePtr<EVP_PKEY> peer_raw_public_key;
|
|
4684
4460
|
|
|
4685
4461
|
private:
|
|
4686
4462
|
friend RefCounted;
|
|
4687
|
-
~
|
|
4463
|
+
~ssl_session_st();
|
|
4688
4464
|
};
|
|
4689
4465
|
|
|
4690
4466
|
#endif // OPENSSL_HEADER_SSL_INTERNAL_H
|