grpc 1.84.1 → 1.86.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.
Files changed (1350) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +48 -31
  3. data/etc/roots.pem +0 -583
  4. data/include/grpc/channel_factory.h +78 -0
  5. data/include/grpc/credentials.h +21 -0
  6. data/include/grpc/event_engine/memory_allocator.h +1 -0
  7. data/include/grpc/grpc.h +10 -0
  8. data/include/grpc/grpc_security_constants.h +4 -0
  9. data/include/grpc/impl/channel_arg_names.h +4 -0
  10. data/include/grpc/module.modulemap +1 -0
  11. data/src/core/call/call_filters.cc +4 -1
  12. data/src/core/call/call_filters.h +13 -11
  13. data/src/core/call/call_spine.h +12 -6
  14. data/src/core/call/call_state.h +3 -3
  15. data/src/core/call/client_call.cc +4 -1
  16. data/src/core/call/client_call.h +1 -0
  17. data/src/core/{lib/security/authorization → call}/evaluate_args.cc +34 -12
  18. data/src/core/{lib/security/authorization → call}/evaluate_args.h +19 -5
  19. data/src/core/call/filter_fusion.h +17 -30
  20. data/src/core/call/interception_chain.h +5 -10
  21. data/src/core/call/metadata_batch.cc +6 -0
  22. data/src/core/call/metadata_batch.h +79 -36
  23. data/src/core/call/parsed_metadata.h +3 -3
  24. data/src/core/call/request_buffer.cc +7 -7
  25. data/src/core/call/request_buffer.h +1 -1
  26. data/src/core/call/server_call.cc +3 -3
  27. data/src/core/call/server_call.h +15 -0
  28. data/src/core/channelz/channel_trace.cc +5 -5
  29. data/src/core/channelz/channel_trace.h +1 -1
  30. data/src/core/channelz/channelz.cc +9 -9
  31. data/src/core/channelz/channelz.h +12 -12
  32. data/src/core/channelz/channelz_registry.cc +14 -14
  33. data/src/core/channelz/ztrace_collector.h +16 -7
  34. data/src/core/client_channel/backup_poller.cc +1 -2
  35. data/src/core/client_channel/channel_factory.cc +110 -0
  36. data/src/core/client_channel/channel_factory.h +45 -0
  37. data/src/core/client_channel/client_channel.cc +4 -4
  38. data/src/core/client_channel/client_channel_filter.cc +14 -14
  39. data/src/core/client_channel/global_subchannel_pool.cc +6 -6
  40. data/src/core/client_channel/lame_channel.cc +59 -0
  41. data/src/core/client_channel/lame_channel.h +86 -0
  42. data/src/core/client_channel/subchannel.cc +24 -23
  43. data/src/core/client_channel/subchannel_stream_client.cc +5 -5
  44. data/src/core/credentials/call/external/aws_external_account_credentials.cc +7 -7
  45. data/src/core/credentials/call/external/aws_request_signer.cc +18 -1
  46. data/src/core/credentials/call/external/external_account_credentials.cc +4 -4
  47. data/src/core/credentials/call/external/url_external_account_credentials.cc +6 -17
  48. data/src/core/credentials/call/external/url_external_account_credentials.h +0 -1
  49. data/src/core/credentials/call/jwt/jwt_verifier.cc +25 -13
  50. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +6 -4
  51. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +25 -9
  52. data/src/core/credentials/call/regional_access_boundary_fetcher.h +6 -2
  53. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +4 -4
  54. data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -3
  55. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +1 -1
  56. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +9 -9
  57. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +1 -1
  58. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +6 -6
  59. data/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc +3 -3
  60. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc +14 -0
  61. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.h +12 -2
  62. data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +4 -4
  63. data/src/core/credentials/transport/tls/ssl_utils.cc +30 -0
  64. data/src/core/credentials/transport/tls/ssl_utils.h +4 -0
  65. data/src/core/credentials/transport/tls/tls_security_connector.cc +16 -12
  66. data/src/core/credentials/transport/tls/tls_security_connector.h +6 -6
  67. data/src/core/credentials/transport/tls/tls_utils.h +9 -0
  68. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +1 -1
  69. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +1 -1
  70. data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +2 -2
  71. data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +1 -1
  72. data/src/core/ext/filters/http/message_compress/compression_filter.cc +15 -0
  73. data/src/core/ext/filters/http/server/http_server_filter.cc +6 -1
  74. data/src/core/ext/filters/rbac/rbac_filter.cc +3 -41
  75. data/src/core/ext/filters/rbac/rbac_filter.h +3 -12
  76. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +61 -45
  78. data/src/core/ext/transport/chttp2/server/chttp2_server.h +6 -13
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +80 -110
  80. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -1
  81. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
  82. data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -6
  83. data/src/core/ext/transport/chttp2/transport/flow_control_manager.h +1 -1
  84. data/src/core/ext/transport/chttp2/transport/frame.cc +15 -19
  85. data/src/core/ext/transport/chttp2/transport/frame.h +10 -1
  86. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +18 -61
  87. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +0 -4
  88. data/src/core/ext/transport/chttp2/transport/frame_security.cc +1 -2
  89. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +9 -0
  90. data/src/core/ext/transport/chttp2/transport/goaway.cc +1 -1
  91. data/src/core/ext/transport/chttp2/transport/goaway.h +0 -5
  92. data/src/core/ext/transport/chttp2/transport/header_assembler.h +1 -5
  93. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +3 -0
  94. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +8 -0
  95. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +45 -9
  96. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -2
  97. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +50 -37
  98. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +7 -3
  99. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +407 -267
  100. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +70 -32
  101. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +4 -3
  102. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +21 -57
  103. data/src/core/ext/transport/chttp2/transport/http2_transport.h +4 -35
  104. data/src/core/ext/transport/chttp2/transport/http2_transport_stats.h +60 -0
  105. data/src/core/ext/transport/chttp2/transport/internal.h +8 -3
  106. data/src/core/ext/transport/chttp2/transport/keepalive.h +1 -4
  107. data/src/core/ext/transport/chttp2/transport/parsing.cc +7 -10
  108. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +35 -11
  109. data/src/core/ext/transport/chttp2/transport/ping_promise.h +52 -47
  110. data/src/core/ext/transport/chttp2/transport/read_context.h +115 -8
  111. data/src/core/ext/transport/chttp2/transport/reclaimer.cc +32 -0
  112. data/src/core/ext/transport/chttp2/transport/reclaimer.h +64 -0
  113. data/src/core/ext/transport/chttp2/transport/security_frame.h +15 -14
  114. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +24 -14
  115. data/src/core/ext/transport/chttp2/transport/transport_common.cc +47 -0
  116. data/src/core/ext/transport/chttp2/transport/transport_common.h +29 -0
  117. data/src/core/ext/transport/chttp2/transport/writable_streams.h +1 -1
  118. data/src/core/ext/transport/chttp2/transport/write_cycle.h +23 -3
  119. data/src/core/ext/transport/inproc/inproc_transport.cc +5 -5
  120. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +1 -7
  121. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb.h +16 -0
  122. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb_minitable.c +4 -3
  123. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb.h +129 -81
  124. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb_minitable.c +50 -39
  125. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb.h +411 -163
  126. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.c +95 -44
  127. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.h +3 -0
  128. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb.h +41 -8
  129. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb_minitable.c +8 -5
  130. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb.h +427 -222
  131. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.c +97 -66
  132. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.h +1 -0
  133. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb.h +130 -99
  134. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb_minitable.c +29 -27
  135. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb.h +49 -33
  136. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb_minitable.c +19 -8
  137. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb.h +95 -3
  138. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.c +33 -6
  139. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.h +1 -0
  140. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb.h +93 -11
  141. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb_minitable.c +8 -5
  142. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb.h +656 -134
  143. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.c +117 -51
  144. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.h +2 -0
  145. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb.h +45 -23
  146. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb_minitable.c +19 -10
  147. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb.h +99 -34
  148. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb_minitable.c +12 -7
  149. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb.h +344 -273
  150. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.c +62 -69
  151. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.h +1 -3
  152. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb.h +53 -22
  153. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb_minitable.c +9 -7
  154. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb.h +108 -0
  155. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.c +26 -2
  156. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.h +1 -0
  157. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb.h +809 -231
  158. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.c +183 -77
  159. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.h +3 -0
  160. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb.h +151 -26
  161. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb_minitable.c +17 -9
  162. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb.h +24 -8
  163. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb_minitable.c +6 -5
  164. data/src/core/ext/upb-gen/envoy/data/accesslog/v3/accesslog.upb.h +2 -1
  165. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb.h +224 -16
  166. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.c +83 -10
  167. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.h +2 -0
  168. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +95 -79
  169. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +23 -22
  170. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb.h +34 -18
  171. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb_minitable.c +10 -9
  172. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h +243 -2
  173. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.c +53 -5
  174. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.h +3 -0
  175. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb.h +53 -22
  176. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb_minitable.c +9 -7
  177. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.h +23 -7
  178. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb_minitable.c +9 -4
  179. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +516 -215
  180. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.c +99 -60
  181. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.h +1 -0
  182. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +60 -28
  183. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb_minitable.c +12 -10
  184. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb.h +109 -0
  185. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.c +32 -2
  186. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.h +1 -0
  187. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb.h +37 -4
  188. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb_minitable.c +7 -4
  189. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb.h +65 -47
  190. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb_minitable.c +29 -12
  191. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +20 -4
  192. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb_minitable.c +6 -3
  193. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +776 -88
  194. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +195 -35
  195. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +5 -0
  196. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb.h +23 -7
  197. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb_minitable.c +10 -3
  198. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb.h +44 -0
  199. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.c +11 -2
  200. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.h +1 -0
  201. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb.h +218 -0
  202. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.c +70 -0
  203. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.h +31 -0
  204. data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb.h +137 -73
  205. data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb_minitable.c +45 -25
  206. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb.h +6 -6
  207. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.c +4 -4
  208. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.h +5 -5
  209. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb.h +46 -26
  210. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.c +17 -14
  211. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.h +5 -5
  212. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb.h +5 -5
  213. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.c +3 -3
  214. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.h +5 -5
  215. data/src/core/ext/upb-gen/grpc/health/v1/health.upb.h +329 -0
  216. data/src/core/ext/upb-gen/grpc/health/v1/health.upb_minitable.c +128 -0
  217. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/health/v1/health.upb_minitable.h +8 -5
  218. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb.h +5 -5
  219. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.c +3 -3
  220. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.h +5 -5
  221. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb.h +185 -23
  222. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.c +20 -12
  223. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.h +5 -5
  224. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb.h +58 -42
  225. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.c +17 -12
  226. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.h +5 -5
  227. data/src/core/ext/upbdefs-gen/envoy/admin/v3/clusters.upbdefs.c +30 -24
  228. data/src/core/ext/upbdefs-gen/envoy/admin/v3/server_info.upbdefs.c +166 -152
  229. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +467 -422
  230. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +15 -0
  231. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +120 -110
  232. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.c +912 -857
  233. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.h +5 -0
  234. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/outlier_detection.upbdefs.c +26 -19
  235. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/address.upbdefs.c +59 -54
  236. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.c +356 -346
  237. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.h +5 -0
  238. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/http_service.upbdefs.c +49 -37
  239. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.c +599 -483
  240. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.h +10 -0
  241. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_option.upbdefs.c +65 -49
  242. data/src/core/ext/upbdefs-gen/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +165 -161
  243. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.c +369 -327
  244. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.h +5 -15
  245. data/src/core/ext/upbdefs-gen/envoy/config/metrics/v3/stats.upbdefs.c +129 -121
  246. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.c +224 -204
  247. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.h +5 -0
  248. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.c +2046 -1932
  249. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.h +15 -0
  250. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/opentelemetry.upbdefs.c +70 -37
  251. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/zipkin.upbdefs.c +7 -3
  252. data/src/core/ext/upbdefs-gen/envoy/data/accesslog/v3/accesslog.upbdefs.c +5 -3
  253. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.c +121 -78
  254. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.h +10 -0
  255. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +165 -160
  256. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +121 -118
  257. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.c +68 -37
  258. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.h +15 -0
  259. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/router/v3/router.upbdefs.c +48 -40
  260. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.c +44 -37
  261. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +919 -870
  262. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
  263. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upbdefs.c +26 -14
  264. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +44 -36
  265. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +372 -371
  266. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c +32 -28
  267. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/address.upbdefs.c +17 -15
  268. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.c +4 -1
  269. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.h +5 -0
  270. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.c +76 -0
  271. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.h +37 -0
  272. data/src/core/ext/upbdefs-gen/envoy/type/v3/token_bucket.upbdefs.c +1 -1
  273. data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +567 -549
  274. data/src/core/ext/upbdefs-gen/grpc/lookup/v1/rls_config.upbdefs.c +182 -0
  275. data/src/core/ext/upbdefs-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upbdefs.h +14 -14
  276. data/src/core/filter/ext_proc/ext_proc_filter.cc +1883 -48
  277. data/src/core/filter/ext_proc/ext_proc_filter.h +88 -22
  278. data/src/core/filter/ext_proc/ext_proc_messages.cc +141 -65
  279. data/src/core/filter/ext_proc/ext_proc_messages.h +55 -16
  280. data/src/core/filter/filter_args.h +5 -60
  281. data/src/core/handshaker/handshaker.cc +4 -4
  282. data/src/core/handshaker/http_connect/http_connect_client_handshaker.cc +4 -4
  283. data/src/core/handshaker/security/pipelined_secure_endpoint.cc +33 -32
  284. data/src/core/handshaker/security/secure_endpoint.cc +29 -29
  285. data/src/core/handshaker/security/security_handshaker.cc +6 -6
  286. data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +4 -4
  287. data/src/core/lib/channel/channel_args.cc +20 -0
  288. data/src/core/lib/channel/channel_args.h +17 -17
  289. data/src/core/lib/channel/channel_stack.cc +0 -12
  290. data/src/core/lib/channel/channel_stack.h +0 -8
  291. data/src/core/lib/channel/promise_based_filter.cc +59 -46
  292. data/src/core/lib/channel/promise_based_filter.h +94 -67
  293. data/src/core/lib/debug/trace_flags.cc +2 -0
  294. data/src/core/lib/debug/trace_flags.h +1 -0
  295. data/src/core/lib/event_engine/ares_resolver.cc +24 -18
  296. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +7 -7
  297. data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +4 -4
  298. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +1 -1
  299. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +3 -3
  300. data/src/core/lib/event_engine/default_event_engine.cc +5 -5
  301. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +10 -14
  302. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +26 -26
  303. data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +8 -22
  304. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +24 -4
  305. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +6 -6
  306. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +7 -7
  307. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +27 -29
  308. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +3 -3
  309. data/src/core/lib/event_engine/posix_engine/posix_interface.h +1 -1
  310. data/src/core/lib/event_engine/posix_engine/timer.cc +7 -7
  311. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +5 -5
  312. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +3 -3
  313. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +1 -1
  314. data/src/core/lib/event_engine/shim.cc +1 -6
  315. data/src/core/lib/event_engine/shim.h +0 -5
  316. data/src/core/lib/event_engine/thread_pool/thread_count.cc +1 -1
  317. data/src/core/lib/event_engine/thread_pool/thread_count.h +3 -3
  318. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +50 -21
  319. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +3 -3
  320. data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +3 -3
  321. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -19
  322. data/src/core/lib/event_engine/windows/windows_listener.cc +7 -7
  323. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +6 -6
  324. data/src/core/lib/experiments/experiments.cc +177 -246
  325. data/src/core/lib/experiments/experiments.h +61 -109
  326. data/src/core/lib/iomgr/buffer_list.cc +3 -3
  327. data/src/core/lib/iomgr/buffer_list.h +1 -1
  328. data/src/core/lib/iomgr/combiner.cc +0 -1
  329. data/src/core/lib/iomgr/ev_apple.cc +4 -4
  330. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +2 -2
  331. data/src/core/lib/iomgr/iomgr_windows.cc +1 -6
  332. data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
  333. data/src/core/lib/iomgr/tcp_posix.cc +28 -28
  334. data/src/core/lib/iomgr/tcp_server_posix.cc +64 -242
  335. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -469
  336. data/src/core/lib/promise/activity.cc +9 -9
  337. data/src/core/lib/promise/activity.h +6 -6
  338. data/src/core/lib/promise/arena_promise.h +7 -7
  339. data/src/core/lib/promise/detail/promise_factory.h +8 -8
  340. data/src/core/lib/promise/detail/promise_like.h +4 -4
  341. data/src/core/lib/promise/inter_activity_latch.h +6 -6
  342. data/src/core/lib/promise/inter_activity_pipe.h +4 -4
  343. data/src/core/lib/promise/observable.h +3 -3
  344. data/src/core/lib/promise/party.cc +6 -6
  345. data/src/core/lib/promise/status_flag.h +7 -2
  346. data/src/core/lib/promise/try_seq.h +2 -2
  347. data/src/core/lib/resource_quota/arena.h +3 -3
  348. data/src/core/lib/resource_quota/memory_quota.cc +18 -18
  349. data/src/core/lib/resource_quota/memory_quota.h +1 -1
  350. data/src/core/lib/resource_quota/thread_quota.cc +3 -3
  351. data/src/core/lib/security/authorization/audit_logging.cc +5 -5
  352. data/src/core/lib/security/authorization/authorization_engine.h +1 -1
  353. data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
  354. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -1
  355. data/src/core/lib/security/authorization/grpc_server_authz_filter.h +1 -1
  356. data/src/core/lib/security/authorization/matchers.h +1 -1
  357. data/src/core/lib/security/authorization/rbac_policy.h +2 -2
  358. data/src/core/lib/surface/call.cc +20 -9
  359. data/src/core/lib/surface/call.h +24 -7
  360. data/src/core/lib/surface/call_utils.h +4 -0
  361. data/src/core/lib/surface/channel.cc +1 -1
  362. data/src/core/lib/surface/channel.h +1 -1
  363. data/src/core/lib/surface/channel_create.cc +7 -1
  364. data/src/core/lib/surface/channel_init.cc +1 -1
  365. data/src/core/lib/surface/channel_init.h +1 -8
  366. data/src/core/lib/surface/filter_stack_call.cc +16 -0
  367. data/src/core/lib/surface/filter_stack_call.h +1 -0
  368. data/src/core/lib/surface/init.cc +10 -10
  369. data/src/core/lib/surface/lame_client.cc +1 -1
  370. data/src/core/lib/surface/legacy_channel.cc +6 -3
  371. data/src/core/lib/surface/version.cc +2 -2
  372. data/src/core/lib/transport/transport.cc +15 -8
  373. data/src/core/lib/transport/transport_framing_endpoint_extension.h +9 -3
  374. data/src/core/load_balancing/autosharding/autosharding.cc +931 -0
  375. data/src/core/load_balancing/autosharding/autosharding.h +78 -0
  376. data/src/core/load_balancing/grpclb/grpclb_client_stats.cc +2 -2
  377. data/src/core/load_balancing/grpclb/load_balancer_api.cc +1 -1
  378. data/src/core/load_balancing/grpclb/load_balancer_api.h +3 -1
  379. data/src/core/load_balancing/health_check_client.cc +7 -7
  380. data/src/core/load_balancing/lb_policy.cc +1 -1
  381. data/src/core/load_balancing/oob_backend_metric.cc +5 -5
  382. data/src/core/load_balancing/outlier_detection/outlier_detection.cc +101 -10
  383. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.cc +38 -0
  384. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.h +55 -0
  385. data/src/core/load_balancing/ring_hash/ring_hash.cc +111 -38
  386. data/src/core/load_balancing/rls/rls.cc +44 -18
  387. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +10 -10
  388. data/src/core/load_balancing/xds/cds.cc +10 -56
  389. data/src/core/load_balancing/xds/xds_cluster_impl.cc +2 -2
  390. data/src/core/load_balancing/xds/xds_override_host.cc +10 -10
  391. data/src/core/mitigation_engine/mitigation_engine.h +28 -4
  392. data/src/core/plugin_registry/grpc_plugin_registry.cc +12 -13
  393. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +0 -7
  394. data/src/core/resolver/dns/dns_resolver.cc +7 -7
  395. data/src/core/resolver/fake/fake_resolver.cc +5 -5
  396. data/src/core/resolver/google_c2p/google_c2p_resolver.cc +38 -30
  397. data/src/core/resolver/xds/xds_resolver.cc +1 -1
  398. data/src/core/server/server.cc +88 -32
  399. data/src/core/server/server.h +4 -3
  400. data/src/core/server/server_config_selector.h +4 -18
  401. data/src/core/server/server_config_selector_filter.cc +20 -146
  402. data/src/core/server/server_config_selector_filter.h +2 -2
  403. data/src/core/server/xds_server_config_fetcher.cc +5 -20
  404. data/src/core/telemetry/default_tcp_tracer.cc +1 -1
  405. data/src/core/telemetry/instrument.cc +30 -16
  406. data/src/core/telemetry/instrument.h +3 -3
  407. data/src/core/transport/auth_context.cc +15 -5
  408. data/src/core/transport/auth_context.h +5 -0
  409. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
  410. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +4 -4
  411. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +2 -2
  412. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +1 -1
  413. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
  414. data/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +5 -5
  415. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +3 -3
  416. data/src/core/tsi/ssl_telemetry_utils.cc +9 -1
  417. data/src/core/tsi/ssl_transport_security.cc +203 -64
  418. data/src/core/tsi/ssl_transport_security.h +25 -2
  419. data/src/core/tsi/ssl_transport_security_utils.cc +139 -18
  420. data/src/core/tsi/ssl_transport_security_utils.h +19 -0
  421. data/src/core/util/event_log.cc +3 -3
  422. data/src/core/util/http_client/httpcli.cc +5 -5
  423. data/src/core/util/http_client/httpcli.h +1 -1
  424. data/src/core/util/json/json_object_loader.cc +7 -0
  425. data/src/core/util/json/json_object_loader.h +17 -2
  426. data/src/core/util/latent_see.cc +188 -39
  427. data/src/core/util/latent_see.h +71 -13
  428. data/src/core/util/linux/cpu.cc +12 -6
  429. data/src/core/util/mpscq.cc +3 -3
  430. data/src/core/util/notification.h +4 -4
  431. data/src/core/util/sync.h +20 -6
  432. data/src/core/util/sync_abseil.cc +3 -3
  433. data/src/core/util/table.h +20 -22
  434. data/src/core/util/trie_lookup.h +5 -1
  435. data/src/core/util/windows/env.cc +1 -0
  436. data/src/core/util/work_serializer.cc +3 -3
  437. data/src/core/xds/grpc/blackboard.cc +4 -3
  438. data/src/core/xds/grpc/certificate_provider_store.cc +2 -2
  439. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +10 -9
  440. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +3 -3
  441. data/src/core/xds/grpc/streaming_call_promise_wrapper.cc +184 -0
  442. data/src/core/xds/grpc/streaming_call_promise_wrapper.h +210 -0
  443. data/src/core/xds/grpc/xds_audit_logger_registry.cc +0 -54
  444. data/src/core/xds/grpc/xds_audit_logger_registry.h +0 -8
  445. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +4 -30
  446. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +0 -20
  447. data/src/core/xds/grpc/xds_client_grpc.cc +12 -12
  448. data/src/core/xds/grpc/xds_client_grpc.h +1 -1
  449. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -1
  450. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +2 -2
  451. data/src/core/xds/grpc/xds_common_types_parser.cc +12 -0
  452. data/src/core/xds/grpc/xds_endpoint.cc +1 -1
  453. data/src/core/xds/grpc/xds_endpoint_parser.cc +14 -3
  454. data/src/core/xds/grpc/xds_grpc_service_parser.cc +12 -10
  455. data/src/core/xds/grpc/xds_http_composite_filter.cc +0 -5
  456. data/src/core/xds/grpc/xds_http_composite_filter.h +1 -27
  457. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +18 -19
  458. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +3 -29
  459. data/src/core/xds/grpc/xds_http_fault_filter.cc +0 -4
  460. data/src/core/xds/grpc/xds_http_fault_filter.h +0 -26
  461. data/src/core/xds/grpc/xds_http_filter.h +1 -63
  462. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +0 -5
  463. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +1 -27
  464. data/src/core/xds/grpc/xds_http_rbac_filter.cc +0 -527
  465. data/src/core/xds/grpc/xds_http_rbac_filter.h +0 -15
  466. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +0 -5
  467. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +0 -26
  468. data/src/core/xds/grpc/xds_listener.cc +0 -2
  469. data/src/core/xds/grpc/xds_listener.h +0 -2
  470. data/src/core/xds/grpc/xds_listener_parser.cc +0 -7
  471. data/src/core/xds/grpc/xds_matcher.cc +17 -11
  472. data/src/core/xds/grpc/xds_matcher.h +4 -3
  473. data/src/core/xds/grpc/xds_matcher_context.cc +11 -0
  474. data/src/core/xds/grpc/xds_matcher_context.h +3 -2
  475. data/src/core/xds/grpc/xds_matcher_input.cc +19 -1
  476. data/src/core/xds/grpc/xds_matcher_parse.cc +3 -2
  477. data/src/core/xds/grpc/xds_route_config.cc +0 -2
  478. data/src/core/xds/grpc/xds_route_config.h +0 -2
  479. data/src/core/xds/grpc/xds_route_config_parser.cc +0 -5
  480. data/src/core/xds/grpc/xds_routing.cc +22 -112
  481. data/src/core/xds/grpc/xds_routing.h +2 -27
  482. data/src/core/xds/grpc/xds_transport_factory_grpc.cc +236 -0
  483. data/src/core/xds/grpc/xds_transport_factory_grpc.h +95 -0
  484. data/src/core/xds/grpc/xds_transport_grpc.cc +176 -299
  485. data/src/core/xds/grpc/xds_transport_grpc.h +60 -55
  486. data/src/core/xds/xds_client/lrs_client.cc +23 -22
  487. data/src/core/xds/xds_client/lrs_client.h +2 -1
  488. data/src/core/xds/xds_client/xds_client.cc +53 -37
  489. data/src/core/xds/xds_client/xds_client.h +6 -5
  490. data/src/core/xds/xds_client/xds_transport.h +113 -65
  491. data/src/core/xds/xds_client/xds_transport_factory.h +43 -0
  492. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  493. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +9 -0
  494. data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
  495. data/src/ruby/lib/grpc/version.rb +1 -1
  496. data/src/ruby/pb/README.md +1 -1
  497. data/src/ruby/pb/generate_proto_ruby.sh +1 -1
  498. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +34 -2
  499. data/third_party/abseil-cpp/absl/algorithm/container.h +345 -147
  500. data/third_party/abseil-cpp/absl/base/attributes.h +67 -44
  501. data/third_party/abseil-cpp/absl/base/call_once.h +1 -0
  502. data/third_party/abseil-cpp/absl/base/casts.cc +61 -0
  503. data/third_party/abseil-cpp/absl/base/casts.h +135 -2
  504. data/third_party/abseil-cpp/absl/base/config.h +63 -41
  505. data/third_party/abseil-cpp/absl/base/fast_type_id.h +30 -2
  506. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +1 -1
  507. data/third_party/abseil-cpp/absl/base/internal/hardening.h +136 -0
  508. data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +6 -2
  509. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +39 -4
  510. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +6 -0
  511. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +77 -15
  512. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +3 -4
  513. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +26 -24
  514. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +74 -29
  515. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -11
  516. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +52 -0
  517. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +5 -1
  518. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +5 -0
  519. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +1 -1
  520. data/third_party/abseil-cpp/absl/base/macros.h +76 -37
  521. data/third_party/abseil-cpp/absl/base/nullability.h +5 -5
  522. data/third_party/abseil-cpp/absl/base/optimization.h +4 -5
  523. data/third_party/abseil-cpp/absl/base/options.h +46 -18
  524. data/third_party/abseil-cpp/absl/base/policy_checks.h +5 -5
  525. data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.cc → throw_delegate.cc} +9 -7
  526. data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.h → throw_delegate.h} +4 -14
  527. data/third_party/abseil-cpp/absl/cleanup/cleanup.h +7 -2
  528. data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -2
  529. data/third_party/abseil-cpp/absl/container/btree_map.h +60 -10
  530. data/third_party/abseil-cpp/absl/container/btree_set.h +61 -15
  531. data/third_party/abseil-cpp/absl/container/fixed_array.h +19 -21
  532. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +49 -27
  533. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +50 -26
  534. data/third_party/abseil-cpp/absl/container/inlined_vector.h +42 -36
  535. data/third_party/abseil-cpp/absl/container/internal/btree.h +32 -24
  536. data/third_party/abseil-cpp/absl/container/internal/btree_container.h +30 -22
  537. data/third_party/abseil-cpp/absl/container/internal/common.h +57 -5
  538. data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
  539. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +40 -36
  540. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +119 -39
  541. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +14 -2
  542. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +14 -22
  543. data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +52 -52
  544. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +7 -7
  545. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +7 -7
  546. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +32 -40
  547. data/third_party/abseil-cpp/absl/container/internal/layout.h +13 -13
  548. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +95 -72
  549. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +633 -365
  550. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1016 -749
  551. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +0 -1
  552. data/third_party/abseil-cpp/absl/container/node_hash_map.h +58 -35
  553. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +23 -6
  554. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.h +7 -1
  555. data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -6
  556. data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +41 -0
  557. data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +0 -16
  558. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_arm_combined.cc +5 -0
  559. data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +304 -188
  560. data/third_party/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +4 -2
  561. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +2 -2
  562. data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.h +8 -0
  563. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +4 -4
  564. data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +15 -1
  565. data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h +7 -1
  566. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +12 -1
  567. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +6 -5
  568. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +13 -11
  569. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +14 -7
  570. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +3 -2
  571. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +6 -1
  572. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +14 -8
  573. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +48 -38
  574. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +4 -0
  575. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +63 -118
  576. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +7 -47
  577. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +20 -2
  578. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +83 -149
  579. data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +4 -17
  580. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +4 -4
  581. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +2 -4
  582. data/third_party/abseil-cpp/absl/flags/commandlineflag.h +8 -6
  583. data/third_party/abseil-cpp/absl/flags/declare.h +9 -0
  584. data/third_party/abseil-cpp/absl/flags/flag.h +2 -1
  585. data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +1 -1
  586. data/third_party/abseil-cpp/absl/flags/internal/flag.cc +19 -18
  587. data/third_party/abseil-cpp/absl/flags/internal/flag.h +33 -34
  588. data/third_party/abseil-cpp/absl/flags/internal/program_name.cc +2 -2
  589. data/third_party/abseil-cpp/absl/flags/marshalling.cc +1 -16
  590. data/third_party/abseil-cpp/absl/flags/marshalling.h +2 -28
  591. data/third_party/abseil-cpp/absl/flags/reflection.cc +11 -7
  592. data/third_party/abseil-cpp/absl/flags/usage_config.cc +2 -2
  593. data/third_party/abseil-cpp/absl/functional/any_invocable.h +22 -19
  594. data/third_party/abseil-cpp/absl/functional/bind_front.h +7 -1
  595. data/third_party/abseil-cpp/absl/functional/function_ref.h +125 -20
  596. data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +43 -31
  597. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +4 -4
  598. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +44 -6
  599. data/third_party/abseil-cpp/absl/hash/hash.h +1 -1
  600. data/third_party/abseil-cpp/absl/hash/internal/city.cc +39 -51
  601. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +379 -14
  602. data/third_party/abseil-cpp/absl/hash/internal/hash.h +457 -353
  603. data/third_party/abseil-cpp/absl/log/absl_vlog_is_on.h +0 -2
  604. data/third_party/abseil-cpp/absl/log/internal/check_impl.h +2 -1
  605. data/third_party/abseil-cpp/absl/log/internal/check_op.cc +4 -0
  606. data/third_party/abseil-cpp/absl/log/internal/check_op.h +128 -50
  607. data/third_party/abseil-cpp/absl/log/internal/conditions.h +38 -35
  608. data/third_party/abseil-cpp/absl/log/internal/log_impl.h +108 -110
  609. data/third_party/abseil-cpp/absl/log/internal/log_message.cc +10 -6
  610. data/third_party/abseil-cpp/absl/log/internal/log_message.h +19 -1
  611. data/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc +4 -4
  612. data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -1
  613. data/third_party/abseil-cpp/absl/log/internal/proto.cc +13 -0
  614. data/third_party/abseil-cpp/absl/log/internal/strip.h +30 -31
  615. data/third_party/abseil-cpp/absl/log/internal/structured_proto.cc +5 -5
  616. data/third_party/abseil-cpp/absl/log/internal/structured_proto.h +6 -5
  617. data/third_party/abseil-cpp/absl/log/internal/vlog_config.cc +30 -30
  618. data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +0 -1
  619. data/third_party/abseil-cpp/absl/log/log.h +2 -2
  620. data/third_party/abseil-cpp/absl/log/log_entry.cc +263 -0
  621. data/third_party/abseil-cpp/absl/log/log_entry.h +2 -0
  622. data/third_party/abseil-cpp/absl/log/vlog_is_on.h +0 -2
  623. data/third_party/abseil-cpp/absl/memory/memory.h +55 -5
  624. data/third_party/abseil-cpp/absl/meta/type_traits.h +161 -56
  625. data/third_party/abseil-cpp/absl/numeric/int128.h +41 -21
  626. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +16 -22
  627. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +5 -7
  628. data/third_party/abseil-cpp/absl/numeric/internal/bits.h +32 -4
  629. data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +9 -9
  630. data/third_party/abseil-cpp/absl/random/beta_distribution.h +2 -2
  631. data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +26 -53
  632. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +1 -1
  633. data/third_party/abseil-cpp/absl/random/distributions.h +17 -17
  634. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +1 -1
  635. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +8 -21
  636. data/third_party/abseil-cpp/absl/random/internal/entropy_pool.cc +2 -2
  637. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +1 -1
  638. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
  639. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +2 -2
  640. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +2 -2
  641. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +6 -6
  642. data/third_party/abseil-cpp/absl/random/internal/platform.h +0 -13
  643. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +6 -6
  644. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +2 -2
  645. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +6 -5
  646. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +5 -31
  647. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +2 -1
  648. data/third_party/abseil-cpp/absl/random/internal/traits.h +21 -0
  649. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +23 -23
  650. data/third_party/abseil-cpp/absl/random/mocking_access.h +74 -0
  651. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +1 -1
  652. data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +63 -18
  653. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +30 -4
  654. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +225 -63
  655. data/third_party/abseil-cpp/absl/status/status.cc +66 -70
  656. data/third_party/abseil-cpp/absl/status/status.h +254 -23
  657. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +3 -2
  658. data/third_party/abseil-cpp/absl/status/statusor.h +117 -137
  659. data/third_party/abseil-cpp/absl/strings/ascii.h +10 -6
  660. data/third_party/abseil-cpp/absl/strings/cord.cc +41 -17
  661. data/third_party/abseil-cpp/absl/strings/cord.h +26 -17
  662. data/third_party/abseil-cpp/absl/strings/cord_buffer.h +4 -2
  663. data/third_party/abseil-cpp/absl/strings/escaping.cc +305 -125
  664. data/third_party/abseil-cpp/absl/strings/escaping.h +12 -2
  665. data/third_party/abseil-cpp/absl/strings/internal/append_and_overwrite.h +93 -0
  666. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +2 -2
  667. data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +6 -6
  668. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +27 -21
  669. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +11 -19
  670. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +6 -0
  671. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +1 -0
  672. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +0 -141
  673. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +2 -24
  674. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +31 -36
  675. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +39 -39
  676. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -22
  677. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +2 -2
  678. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +2 -4
  679. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +921 -231
  680. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +18 -16
  681. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +16 -12
  682. data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.h +12 -0
  683. data/third_party/abseil-cpp/absl/strings/numbers.cc +477 -8
  684. data/third_party/abseil-cpp/absl/strings/numbers.h +29 -12
  685. data/third_party/abseil-cpp/absl/strings/resize_and_overwrite.h +198 -0
  686. data/third_party/abseil-cpp/absl/strings/str_cat.cc +96 -91
  687. data/third_party/abseil-cpp/absl/strings/str_cat.h +53 -13
  688. data/third_party/abseil-cpp/absl/strings/str_split.h +14 -9
  689. data/third_party/abseil-cpp/absl/strings/string_view.h +10 -716
  690. data/third_party/abseil-cpp/absl/strings/substitute.cc +24 -24
  691. data/third_party/abseil-cpp/absl/strings/substitute.h +2 -2
  692. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +1 -1
  693. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +2 -2
  694. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +24 -3
  695. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +30 -33
  696. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -2
  697. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +5 -0
  698. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +41 -29
  699. data/third_party/abseil-cpp/absl/synchronization/mutex.h +199 -94
  700. data/third_party/abseil-cpp/absl/synchronization/notification.cc +5 -5
  701. data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
  702. data/third_party/abseil-cpp/absl/time/clock.cc +29 -30
  703. data/third_party/abseil-cpp/absl/time/clock.h +3 -0
  704. data/third_party/abseil-cpp/absl/time/duration.cc +2 -2
  705. data/third_party/abseil-cpp/absl/time/format.cc +3 -10
  706. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +12 -0
  707. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +131 -91
  708. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +6 -103
  709. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +185 -0
  710. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.h +37 -0
  711. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +10 -15
  712. data/third_party/abseil-cpp/absl/time/time.cc +4 -4
  713. data/third_party/abseil-cpp/absl/time/time.h +14 -13
  714. data/third_party/abseil-cpp/absl/types/compare.h +64 -63
  715. data/third_party/abseil-cpp/absl/types/internal/span.h +6 -6
  716. data/third_party/abseil-cpp/absl/types/optional.h +31 -4
  717. data/third_party/abseil-cpp/absl/types/optional_ref.h +295 -0
  718. data/third_party/{boringssl-with-bazel/crypto/x509/x_val.cc → abseil-cpp/absl/types/source_location.cc} +4 -14
  719. data/third_party/abseil-cpp/absl/types/source_location.h +172 -0
  720. data/third_party/abseil-cpp/absl/types/span.h +67 -38
  721. data/third_party/abseil-cpp/absl/types/variant.h +75 -18
  722. data/third_party/abseil-cpp/absl/utility/utility.h +112 -16
  723. data/third_party/boringssl-with-bazel/crypto/aes/aes.cc +3 -0
  724. data/third_party/boringssl-with-bazel/crypto/armv8_feature_parsing.h +67 -0
  725. data/third_party/boringssl-with-bazel/crypto/asn1/a_bitstr.cc +143 -105
  726. data/third_party/boringssl-with-bazel/crypto/asn1/a_bool.cc +5 -8
  727. data/third_party/boringssl-with-bazel/crypto/asn1/a_d2i_fp.cc +3 -3
  728. data/third_party/boringssl-with-bazel/crypto/asn1/a_dup.cc +6 -6
  729. data/third_party/boringssl-with-bazel/crypto/asn1/a_gentm.cc +33 -12
  730. data/third_party/boringssl-with-bazel/crypto/asn1/a_i2d_fp.cc +7 -6
  731. data/third_party/boringssl-with-bazel/crypto/asn1/a_int.cc +80 -52
  732. data/third_party/boringssl-with-bazel/crypto/asn1/a_mbstr.cc +7 -4
  733. data/third_party/boringssl-with-bazel/crypto/asn1/a_object.cc +70 -72
  734. data/third_party/boringssl-with-bazel/crypto/asn1/a_strex.cc +38 -42
  735. data/third_party/boringssl-with-bazel/crypto/asn1/a_strnid.cc +41 -39
  736. data/third_party/boringssl-with-bazel/crypto/asn1/a_time.cc +59 -35
  737. data/third_party/boringssl-with-bazel/crypto/asn1/a_type.cc +325 -30
  738. data/third_party/boringssl-with-bazel/crypto/asn1/a_utctm.cc +32 -13
  739. data/third_party/boringssl-with-bazel/crypto/asn1/asn1_lib.cc +129 -31
  740. data/third_party/boringssl-with-bazel/crypto/asn1/asn_pack.cc +10 -10
  741. data/third_party/boringssl-with-bazel/crypto/asn1/f_int.cc +1 -1
  742. data/third_party/boringssl-with-bazel/crypto/asn1/f_string.cc +1 -1
  743. data/third_party/boringssl-with-bazel/crypto/asn1/internal.h +307 -115
  744. data/third_party/boringssl-with-bazel/crypto/asn1/posix_time.cc +8 -5
  745. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_dec.cc +376 -728
  746. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_enc.cc +215 -528
  747. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_fre.cc +30 -31
  748. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_new.cc +50 -52
  749. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_typ.cc +18 -6
  750. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_utl.cc +63 -74
  751. data/third_party/boringssl-with-bazel/crypto/base64/base64.cc +14 -15
  752. data/third_party/boringssl-with-bazel/crypto/bcm_support.h +7 -29
  753. data/third_party/boringssl-with-bazel/crypto/bio/bio.cc +234 -177
  754. data/third_party/boringssl-with-bazel/crypto/bio/bio_mem.cc +78 -86
  755. data/third_party/boringssl-with-bazel/crypto/bio/connect.cc +154 -200
  756. data/third_party/boringssl-with-bazel/crypto/bio/errno.cc +3 -1
  757. data/third_party/boringssl-with-bazel/crypto/bio/fd.cc +55 -55
  758. data/third_party/boringssl-with-bazel/crypto/bio/file.cc +69 -78
  759. data/third_party/boringssl-with-bazel/crypto/bio/hexdump.cc +6 -4
  760. data/third_party/boringssl-with-bazel/crypto/bio/internal.h +69 -18
  761. data/third_party/boringssl-with-bazel/crypto/bio/pair.cc +116 -136
  762. data/third_party/boringssl-with-bazel/crypto/bio/printf.cc +1 -1
  763. data/third_party/boringssl-with-bazel/crypto/bio/socket.cc +116 -50
  764. data/third_party/boringssl-with-bazel/crypto/bio/socket_helper.cc +53 -5
  765. data/third_party/boringssl-with-bazel/crypto/blake2/blake2.cc +9 -5
  766. data/third_party/boringssl-with-bazel/crypto/bn/bn_asn1.cc +2 -2
  767. data/third_party/boringssl-with-bazel/crypto/bn/convert.cc +56 -70
  768. data/third_party/boringssl-with-bazel/crypto/bn/div.cc +102 -0
  769. data/third_party/boringssl-with-bazel/crypto/bn/exponentiation.cc +26 -42
  770. data/third_party/boringssl-with-bazel/crypto/bn/sqrt.cc +93 -0
  771. data/third_party/boringssl-with-bazel/crypto/buf/buf.cc +6 -5
  772. data/third_party/boringssl-with-bazel/crypto/bytestring/asn1_compat.cc +6 -5
  773. data/third_party/boringssl-with-bazel/crypto/bytestring/ber.cc +22 -20
  774. data/third_party/boringssl-with-bazel/crypto/bytestring/cbb.cc +182 -97
  775. data/third_party/boringssl-with-bazel/crypto/bytestring/cbs.cc +114 -49
  776. data/third_party/boringssl-with-bazel/crypto/bytestring/internal.h +84 -24
  777. data/third_party/boringssl-with-bazel/crypto/bytestring/unicode.cc +2 -2
  778. data/third_party/boringssl-with-bazel/crypto/chacha/chacha.cc +5 -3
  779. data/third_party/boringssl-with-bazel/crypto/chacha/internal.h +23 -22
  780. data/third_party/boringssl-with-bazel/crypto/cipher/derive_key.cc +14 -18
  781. data/third_party/boringssl-with-bazel/crypto/cipher/e_aesctrhmac.cc +73 -58
  782. data/third_party/boringssl-with-bazel/crypto/cipher/e_aeseax.cc +132 -70
  783. data/third_party/boringssl-with-bazel/crypto/cipher/e_aesgcmsiv.cc +363 -367
  784. data/third_party/boringssl-with-bazel/crypto/cipher/e_chacha20poly1305.cc +200 -137
  785. data/third_party/boringssl-with-bazel/crypto/cipher/e_des.cc +45 -29
  786. data/third_party/boringssl-with-bazel/crypto/cipher/e_null.cc +9 -5
  787. data/third_party/boringssl-with-bazel/crypto/cipher/e_rc2.cc +43 -28
  788. data/third_party/boringssl-with-bazel/crypto/cipher/e_rc4.cc +7 -5
  789. data/third_party/boringssl-with-bazel/crypto/cipher/e_tls.cc +253 -237
  790. data/third_party/boringssl-with-bazel/crypto/cipher/get_cipher.cc +12 -12
  791. data/third_party/boringssl-with-bazel/crypto/cipher/internal.h +217 -58
  792. data/third_party/boringssl-with-bazel/crypto/cipher/tls_cbc.cc +111 -111
  793. data/third_party/boringssl-with-bazel/crypto/cms/cms.cc +48 -42
  794. data/third_party/boringssl-with-bazel/crypto/conf/conf.cc +69 -63
  795. data/third_party/boringssl-with-bazel/crypto/conf/internal.h +11 -12
  796. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_apple.cc +8 -5
  797. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_fuchsia.cc +6 -1
  798. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_linux.cc +7 -1
  799. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_openbsd.cc +7 -21
  800. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_sysreg.cc +15 -41
  801. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_win.cc +16 -3
  802. data/third_party/boringssl-with-bazel/crypto/cpu_arm_freebsd.cc +4 -2
  803. data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.cc +54 -31
  804. data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.h +79 -101
  805. data/third_party/boringssl-with-bazel/crypto/cpu_intel.cc +51 -45
  806. data/third_party/boringssl-with-bazel/crypto/crypto.cc +26 -55
  807. data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519.cc +323 -41
  808. data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519_tables.h +6 -6
  809. data/third_party/boringssl-with-bazel/crypto/curve25519/internal.h +39 -29
  810. data/third_party/boringssl-with-bazel/crypto/curve25519/spake25519.cc +23 -20
  811. data/third_party/boringssl-with-bazel/crypto/des/des.cc +27 -19
  812. data/third_party/boringssl-with-bazel/crypto/des/internal.h +4 -9
  813. data/third_party/boringssl-with-bazel/crypto/dh/dh_asn1.cc +34 -49
  814. data/third_party/boringssl-with-bazel/crypto/dh/params.cc +45 -42
  815. data/third_party/boringssl-with-bazel/crypto/digest/digest_extra.cc +87 -40
  816. data/third_party/boringssl-with-bazel/crypto/dsa/dsa.cc +237 -260
  817. data/third_party/boringssl-with-bazel/crypto/dsa/dsa_asn1.cc +100 -173
  818. data/third_party/boringssl-with-bazel/crypto/dsa/internal.h +23 -21
  819. data/third_party/boringssl-with-bazel/crypto/ec/ec_asn1.cc +181 -209
  820. data/third_party/boringssl-with-bazel/crypto/ec/ec_derive.cc +26 -28
  821. data/third_party/boringssl-with-bazel/crypto/ec/hash_to_curve.cc +459 -196
  822. data/third_party/boringssl-with-bazel/crypto/ec/internal.h +54 -18
  823. data/third_party/boringssl-with-bazel/crypto/ecdh/ecdh.cc +7 -5
  824. data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_asn1.cc +50 -70
  825. data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_p1363.cc +54 -0
  826. data/third_party/boringssl-with-bazel/crypto/engine/engine.cc +7 -7
  827. data/third_party/boringssl-with-bazel/crypto/err/err.cc +119 -107
  828. data/third_party/boringssl-with-bazel/crypto/err/internal.h +8 -21
  829. data/third_party/boringssl-with-bazel/crypto/evp/evp.cc +241 -166
  830. data/third_party/boringssl-with-bazel/crypto/evp/evp_asn1.cc +202 -234
  831. data/third_party/boringssl-with-bazel/crypto/evp/evp_ctx.cc +260 -159
  832. data/third_party/boringssl-with-bazel/crypto/evp/evp_kem.cc +101 -0
  833. data/third_party/boringssl-with-bazel/crypto/evp/internal.h +296 -137
  834. data/third_party/boringssl-with-bazel/crypto/evp/p_dh.cc +198 -25
  835. data/third_party/boringssl-with-bazel/crypto/evp/p_dsa.cc +333 -0
  836. data/third_party/boringssl-with-bazel/crypto/evp/p_ec.cc +548 -42
  837. data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519.cc +270 -14
  838. data/third_party/boringssl-with-bazel/crypto/evp/p_hkdf.cc +70 -102
  839. data/third_party/boringssl-with-bazel/crypto/evp/p_mldsa.cc +549 -0
  840. data/third_party/boringssl-with-bazel/crypto/evp/p_mlkem.cc +510 -0
  841. data/third_party/boringssl-with-bazel/crypto/evp/p_rsa.cc +734 -158
  842. data/third_party/boringssl-with-bazel/crypto/evp/p_x25519.cc +290 -28
  843. data/third_party/boringssl-with-bazel/crypto/evp/p_xwing.cc +300 -0
  844. data/third_party/boringssl-with-bazel/crypto/evp/pbkdf.cc +14 -7
  845. data/third_party/boringssl-with-bazel/crypto/evp/print.cc +34 -89
  846. data/third_party/boringssl-with-bazel/crypto/evp/scrypt.cc +23 -21
  847. data/third_party/boringssl-with-bazel/crypto/evp/sign.cc +23 -42
  848. data/third_party/boringssl-with-bazel/crypto/ex_data.cc +40 -41
  849. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes.cc.inc +34 -28
  850. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes_nohw.cc.inc +120 -122
  851. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cbc.cc.inc +16 -14
  852. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cfb.cc.inc +12 -10
  853. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ctr.cc.inc +7 -5
  854. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm.cc.inc +41 -31
  855. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm_nohw.cc.inc +15 -13
  856. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/internal.h +193 -177
  857. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/key_wrap.cc.inc +5 -3
  858. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/mode_wrappers.cc.inc +7 -3
  859. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ofb.cc.inc +7 -5
  860. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm.cc +24 -18
  861. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm_interface.h +512 -384
  862. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/add.cc.inc +16 -9
  863. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +64 -45
  864. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bn.cc.inc +40 -37
  865. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bytes.cc.inc +27 -22
  866. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/cmp.cc.inc +9 -7
  867. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/ctx.cc.inc +62 -126
  868. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div.cc.inc +92 -167
  869. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div_extra.cc.inc +15 -12
  870. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/exponentiation.cc.inc +98 -95
  871. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd.cc.inc +73 -92
  872. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd_extra.cc.inc +59 -71
  873. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/generic.cc.inc +54 -57
  874. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/internal.h +339 -255
  875. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/jacobi.cc.inc +13 -20
  876. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery.cc.inc +80 -95
  877. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery_inv.cc.inc +55 -98
  878. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/mul.cc.inc +58 -419
  879. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/prime.cc.inc +167 -216
  880. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/random.cc.inc +27 -26
  881. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.cc.inc +18 -16
  882. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.h +47 -49
  883. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/shift.cc.inc +14 -17
  884. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/sqrt.cc.inc +40 -129
  885. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/aead.cc.inc +429 -105
  886. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/cipher.cc.inc +381 -216
  887. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aes.cc.inc +230 -225
  888. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aesccm.cc.inc +115 -84
  889. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/internal.h +375 -27
  890. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cmac/cmac.cc.inc +28 -23
  891. data/third_party/boringssl-with-bazel/crypto/fipsmodule/delocate.h +36 -40
  892. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/check.cc.inc +68 -78
  893. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/dh.cc.inc +157 -199
  894. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/internal.h +24 -24
  895. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digest.cc.inc +40 -69
  896. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digests.cc.inc +13 -7
  897. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/internal.h +13 -11
  898. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/md32_common.h +86 -81
  899. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digestsign/digestsign.cc.inc +38 -34
  900. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec.cc.inc +254 -203
  901. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_key.cc.inc +196 -154
  902. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_montgomery.cc.inc +78 -138
  903. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/felem.cc.inc +151 -5
  904. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/internal.h +332 -289
  905. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/oct.cc.inc +45 -166
  906. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.cc.inc +44 -45
  907. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.h +18 -18
  908. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256.cc.inc +75 -246
  909. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/scalar.cc.inc +44 -39
  910. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple.cc.inc +73 -106
  911. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple_mul.cc.inc +39 -34
  912. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/util.cc.inc +6 -3
  913. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/wnaf.cc.inc +23 -20
  914. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdh/ecdh.cc.inc +6 -3
  915. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +48 -38
  916. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/internal.h +5 -10
  917. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/internal.h +38 -0
  918. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/jitter.cc.inc +463 -0
  919. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/sha512.cc.inc +329 -0
  920. data/third_party/boringssl-with-bazel/crypto/fipsmodule/fips_shared_support.cc +4 -4
  921. data/third_party/boringssl-with-bazel/crypto/fipsmodule/hkdf/hkdf.cc.inc +8 -6
  922. data/third_party/boringssl-with-bazel/crypto/fipsmodule/hmac/hmac.cc.inc +19 -16
  923. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/internal.h +109 -14
  924. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/keccak.cc.inc +424 -56
  925. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/fips_known_values.inc +5 -5
  926. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/mldsa.cc.inc +1796 -773
  927. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/fips_known_values.inc +5 -5
  928. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/mlkem.cc.inc +902 -443
  929. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/android_entropy_client.cc.inc +82 -0
  930. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/ctrdrbg.cc.inc +240 -53
  931. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/internal.h +41 -26
  932. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/rand.cc.inc +221 -218
  933. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/internal.h +64 -67
  934. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/padding.cc.inc +49 -57
  935. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa.cc.inc +247 -234
  936. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa_impl.cc.inc +395 -695
  937. data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/fips.cc.inc +10 -10
  938. data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/self_check.cc.inc +479 -449
  939. data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/internal.h +34 -11
  940. data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/service_indicator.cc.inc +46 -43
  941. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/internal.h +61 -70
  942. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha1.cc.inc +29 -15
  943. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha256.cc.inc +46 -30
  944. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha512.cc.inc +47 -47
  945. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/address.h +98 -73
  946. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.cc.inc +108 -98
  947. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.h +14 -24
  948. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.cc.inc +94 -91
  949. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.h +19 -31
  950. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/params.h +156 -56
  951. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/slhdsa.cc.inc +318 -132
  952. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.cc.inc +234 -81
  953. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.h +20 -34
  954. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.cc.inc +97 -96
  955. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.h +10 -20
  956. data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/internal.h +2 -16
  957. data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/kdf.cc.inc +26 -26
  958. data/third_party/boringssl-with-bazel/crypto/fuzzer_mode.cc +5 -5
  959. data/third_party/boringssl-with-bazel/crypto/hpke/hpke.cc +531 -112
  960. data/third_party/boringssl-with-bazel/crypto/hrss/hrss.cc +165 -161
  961. data/third_party/boringssl-with-bazel/crypto/hrss/internal.h +9 -13
  962. data/third_party/boringssl-with-bazel/crypto/internal.h +594 -394
  963. data/third_party/boringssl-with-bazel/crypto/lhash/internal.h +38 -37
  964. data/third_party/boringssl-with-bazel/crypto/lhash/lhash.cc +68 -65
  965. data/third_party/boringssl-with-bazel/crypto/md4/md4.cc +19 -6
  966. data/third_party/boringssl-with-bazel/crypto/md5/internal.h +6 -9
  967. data/third_party/boringssl-with-bazel/crypto/md5/md5.cc +18 -6
  968. data/third_party/boringssl-with-bazel/crypto/mem.cc +61 -65
  969. data/third_party/boringssl-with-bazel/crypto/mem_internal.h +706 -0
  970. data/third_party/boringssl-with-bazel/crypto/mldsa/mldsa.cc +238 -32
  971. data/third_party/boringssl-with-bazel/crypto/mlkem/mlkem.cc +21 -65
  972. data/third_party/boringssl-with-bazel/crypto/obj/obj.cc +132 -157
  973. data/third_party/boringssl-with-bazel/crypto/obj/obj_dat.h +175 -1
  974. data/third_party/boringssl-with-bazel/crypto/obj/obj_xref.cc +14 -11
  975. data/third_party/boringssl-with-bazel/crypto/params_internal.h +30 -0
  976. data/third_party/boringssl-with-bazel/crypto/pem/internal.h +106 -15
  977. data/third_party/boringssl-with-bazel/crypto/pem/pem_all.cc +28 -24
  978. data/third_party/boringssl-with-bazel/crypto/pem/pem_info.cc +72 -76
  979. data/third_party/boringssl-with-bazel/crypto/pem/pem_lib.cc +239 -273
  980. data/third_party/boringssl-with-bazel/crypto/pem/pem_oth.cc +6 -6
  981. data/third_party/boringssl-with-bazel/crypto/pem/pem_pk8.cc +16 -13
  982. data/third_party/boringssl-with-bazel/crypto/pem/pem_pkey.cc +21 -15
  983. data/third_party/boringssl-with-bazel/crypto/pem/pem_x509.cc +3 -0
  984. data/third_party/boringssl-with-bazel/crypto/pem/pem_xaux.cc +3 -0
  985. data/third_party/boringssl-with-bazel/crypto/pkcs7/internal.h +12 -17
  986. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7.cc +29 -27
  987. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7_x509.cc +55 -49
  988. data/third_party/boringssl-with-bazel/crypto/pkcs8/internal.h +21 -26
  989. data/third_party/boringssl-with-bazel/crypto/pkcs8/p5_pbev2.cc +33 -31
  990. data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8.cc +73 -81
  991. data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8_x509.cc +140 -139
  992. data/third_party/boringssl-with-bazel/crypto/poly1305/internal.h +20 -7
  993. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305.cc +5 -4
  994. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_arm.cc +43 -59
  995. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_vec.cc +32 -29
  996. data/third_party/boringssl-with-bazel/crypto/pool/internal.h +64 -20
  997. data/third_party/boringssl-with-bazel/crypto/pool/pool.cc +177 -157
  998. data/third_party/boringssl-with-bazel/crypto/rand/deterministic.cc +9 -16
  999. data/third_party/boringssl-with-bazel/crypto/rand/fork_detect.cc +70 -42
  1000. data/third_party/boringssl-with-bazel/crypto/rand/forkunsafe.cc +7 -7
  1001. data/third_party/boringssl-with-bazel/crypto/rand/getentropy.cc +6 -13
  1002. data/third_party/boringssl-with-bazel/crypto/rand/internal.h +16 -4
  1003. data/third_party/boringssl-with-bazel/crypto/rand/ios.cc +4 -11
  1004. data/third_party/boringssl-with-bazel/crypto/rand/rand.cc +11 -9
  1005. data/third_party/boringssl-with-bazel/crypto/rand/trusty.cc +4 -11
  1006. data/third_party/boringssl-with-bazel/crypto/rand/urandom.cc +16 -195
  1007. data/third_party/boringssl-with-bazel/crypto/rand/windows.cc +12 -19
  1008. data/third_party/boringssl-with-bazel/crypto/refcount.cc +7 -17
  1009. data/third_party/boringssl-with-bazel/crypto/rsa/internal.h +22 -7
  1010. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_asn1.cc +199 -78
  1011. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_crypt.cc +49 -50
  1012. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_extra.cc +11 -0
  1013. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_print.cc +4 -6
  1014. data/third_party/boringssl-with-bazel/crypto/sha/sha1.cc +3 -0
  1015. data/third_party/boringssl-with-bazel/crypto/sha/sha256.cc +3 -1
  1016. data/third_party/boringssl-with-bazel/crypto/sha/sha512.cc +6 -4
  1017. data/third_party/boringssl-with-bazel/crypto/siphash/siphash.cc +2 -0
  1018. data/third_party/boringssl-with-bazel/crypto/slhdsa/slhdsa.cc +60 -6
  1019. data/third_party/boringssl-with-bazel/crypto/spake2plus/internal.h +31 -31
  1020. data/third_party/boringssl-with-bazel/crypto/spake2plus/spake2plus.cc +1 -1
  1021. data/third_party/boringssl-with-bazel/crypto/stack/stack.cc +96 -130
  1022. data/third_party/boringssl-with-bazel/crypto/thread.cc +14 -14
  1023. data/third_party/boringssl-with-bazel/crypto/thread_none.cc +10 -13
  1024. data/third_party/boringssl-with-bazel/crypto/thread_pthread.cc +22 -35
  1025. data/third_party/boringssl-with-bazel/crypto/thread_win.cc +29 -40
  1026. data/third_party/boringssl-with-bazel/crypto/trust_token/internal.h +81 -88
  1027. data/third_party/boringssl-with-bazel/crypto/trust_token/pmbtoken.cc +160 -144
  1028. data/third_party/boringssl-with-bazel/crypto/trust_token/trust_token.cc +96 -80
  1029. data/third_party/boringssl-with-bazel/crypto/trust_token/voprf.cc +90 -87
  1030. data/third_party/boringssl-with-bazel/crypto/x509/a_digest.cc +5 -5
  1031. data/third_party/boringssl-with-bazel/crypto/x509/a_sign.cc +51 -48
  1032. data/third_party/boringssl-with-bazel/crypto/x509/a_verify.cc +39 -36
  1033. data/third_party/boringssl-with-bazel/crypto/x509/algorithm.cc +47 -16
  1034. data/third_party/boringssl-with-bazel/crypto/x509/asn1_gen.cc +41 -43
  1035. data/third_party/boringssl-with-bazel/crypto/x509/by_dir.cc +183 -237
  1036. data/third_party/boringssl-with-bazel/crypto/x509/by_file.cc +29 -30
  1037. data/third_party/boringssl-with-bazel/crypto/x509/internal.h +346 -216
  1038. data/third_party/boringssl-with-bazel/crypto/x509/name_print.cc +15 -13
  1039. data/third_party/boringssl-with-bazel/crypto/x509/policy.cc +415 -525
  1040. data/third_party/boringssl-with-bazel/crypto/x509/rsa_pss.cc +95 -272
  1041. data/third_party/boringssl-with-bazel/crypto/x509/t_crl.cc +11 -8
  1042. data/third_party/boringssl-with-bazel/crypto/x509/t_req.cc +26 -23
  1043. data/third_party/boringssl-with-bazel/crypto/x509/t_x509.cc +27 -22
  1044. data/third_party/boringssl-with-bazel/crypto/x509/t_x509a.cc +3 -1
  1045. data/third_party/boringssl-with-bazel/crypto/x509/v3_akey.cc +69 -76
  1046. data/third_party/boringssl-with-bazel/crypto/x509/v3_akeya.cc +2 -2
  1047. data/third_party/boringssl-with-bazel/crypto/x509/v3_alt.cc +112 -69
  1048. data/third_party/boringssl-with-bazel/crypto/x509/v3_bcons.cc +15 -14
  1049. data/third_party/boringssl-with-bazel/crypto/x509/v3_bitst.cc +16 -18
  1050. data/third_party/boringssl-with-bazel/crypto/x509/v3_conf.cc +62 -67
  1051. data/third_party/boringssl-with-bazel/crypto/x509/v3_cpols.cc +143 -170
  1052. data/third_party/boringssl-with-bazel/crypto/x509/v3_crld.cc +123 -209
  1053. data/third_party/boringssl-with-bazel/crypto/x509/v3_enum.cc +13 -12
  1054. data/third_party/boringssl-with-bazel/crypto/x509/v3_extku.cc +17 -34
  1055. data/third_party/boringssl-with-bazel/crypto/x509/v3_genn.cc +20 -10
  1056. data/third_party/boringssl-with-bazel/crypto/x509/v3_ia5.cc +22 -18
  1057. data/third_party/boringssl-with-bazel/crypto/x509/v3_info.cc +45 -47
  1058. data/third_party/boringssl-with-bazel/crypto/x509/v3_int.cc +35 -33
  1059. data/third_party/boringssl-with-bazel/crypto/x509/v3_lib.cc +106 -61
  1060. data/third_party/boringssl-with-bazel/crypto/x509/v3_ncons.cc +642 -358
  1061. data/third_party/boringssl-with-bazel/crypto/x509/v3_ocsp.cc +25 -22
  1062. data/third_party/boringssl-with-bazel/crypto/x509/v3_pcons.cc +15 -14
  1063. data/third_party/boringssl-with-bazel/crypto/x509/v3_pmaps.cc +16 -15
  1064. data/third_party/boringssl-with-bazel/crypto/x509/v3_prn.cc +6 -6
  1065. data/third_party/boringssl-with-bazel/crypto/x509/v3_purp.cc +149 -159
  1066. data/third_party/boringssl-with-bazel/crypto/x509/v3_skey.cc +23 -26
  1067. data/third_party/boringssl-with-bazel/crypto/x509/v3_utl.cc +161 -192
  1068. data/third_party/boringssl-with-bazel/crypto/x509/x509.cc +1 -1
  1069. data/third_party/boringssl-with-bazel/crypto/x509/x509_att.cc +32 -30
  1070. data/third_party/boringssl-with-bazel/crypto/x509/x509_cmp.cc +95 -90
  1071. data/third_party/boringssl-with-bazel/crypto/x509/x509_d2.cc +9 -9
  1072. data/third_party/boringssl-with-bazel/crypto/x509/x509_def.cc +6 -8
  1073. data/third_party/boringssl-with-bazel/crypto/x509/x509_ext.cc +46 -24
  1074. data/third_party/boringssl-with-bazel/crypto/x509/x509_lu.cc +211 -195
  1075. data/third_party/boringssl-with-bazel/crypto/x509/x509_mtc.cc +598 -0
  1076. data/third_party/boringssl-with-bazel/crypto/x509/x509_obj.cc +23 -18
  1077. data/third_party/boringssl-with-bazel/crypto/x509/x509_req.cc +37 -46
  1078. data/third_party/boringssl-with-bazel/crypto/x509/x509_set.cc +58 -90
  1079. data/third_party/boringssl-with-bazel/crypto/x509/x509_trs.cc +18 -13
  1080. data/third_party/boringssl-with-bazel/crypto/x509/x509_v3.cc +33 -33
  1081. data/third_party/boringssl-with-bazel/crypto/x509/x509_vfy.cc +398 -474
  1082. data/third_party/boringssl-with-bazel/crypto/x509/x509_vpm.cc +57 -48
  1083. data/third_party/boringssl-with-bazel/crypto/x509/x509cset.cc +27 -40
  1084. data/third_party/boringssl-with-bazel/crypto/x509/x509name.cc +91 -79
  1085. data/third_party/boringssl-with-bazel/crypto/x509/x509rset.cc +5 -17
  1086. data/third_party/boringssl-with-bazel/crypto/x509/x509spki.cc +13 -13
  1087. data/third_party/boringssl-with-bazel/crypto/x509/x_algor.cc +131 -24
  1088. data/third_party/boringssl-with-bazel/crypto/x509/x_all.cc +73 -39
  1089. data/third_party/boringssl-with-bazel/crypto/x509/x_attrib.cc +10 -4
  1090. data/third_party/boringssl-with-bazel/crypto/x509/x_crl.cc +76 -93
  1091. data/third_party/boringssl-with-bazel/crypto/x509/x_exten.cc +6 -0
  1092. data/third_party/boringssl-with-bazel/crypto/x509/x_name.cc +294 -388
  1093. data/third_party/boringssl-with-bazel/crypto/x509/x_pubkey.cc +113 -84
  1094. data/third_party/boringssl-with-bazel/crypto/x509/x_req.cc +12 -6
  1095. data/third_party/boringssl-with-bazel/crypto/x509/x_sig.cc +4 -4
  1096. data/third_party/boringssl-with-bazel/crypto/x509/x_spki.cc +11 -1
  1097. data/third_party/boringssl-with-bazel/crypto/x509/x_x509.cc +282 -277
  1098. data/third_party/boringssl-with-bazel/crypto/x509/x_x509a.cc +60 -60
  1099. data/third_party/boringssl-with-bazel/crypto/xwing/xwing.cc +257 -0
  1100. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +325 -0
  1101. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +325 -0
  1102. data/third_party/boringssl-with-bazel/gen/crypto/err_data.cc +538 -500
  1103. data/third_party/boringssl-with-bazel/include/openssl/aead.h +279 -119
  1104. data/third_party/boringssl-with-bazel/include/openssl/aes.h +43 -43
  1105. data/third_party/boringssl-with-bazel/include/openssl/asm_base.h +30 -17
  1106. data/third_party/boringssl-with-bazel/include/openssl/asn1.h +641 -635
  1107. data/third_party/boringssl-with-bazel/include/openssl/asn1t.h +7 -9
  1108. data/third_party/boringssl-with-bazel/include/openssl/base.h +76 -69
  1109. data/third_party/boringssl-with-bazel/include/openssl/base64.h +30 -30
  1110. data/third_party/boringssl-with-bazel/include/openssl/bio.h +394 -322
  1111. data/third_party/boringssl-with-bazel/include/openssl/blake2.h +15 -11
  1112. data/third_party/boringssl-with-bazel/include/openssl/blowfish.h +10 -3
  1113. data/third_party/boringssl-with-bazel/include/openssl/bn.h +298 -306
  1114. data/third_party/boringssl-with-bazel/include/openssl/buf.h +14 -14
  1115. data/third_party/boringssl-with-bazel/include/openssl/bytestring.h +305 -208
  1116. data/third_party/boringssl-with-bazel/include/openssl/cast.h +45 -8
  1117. data/third_party/boringssl-with-bazel/include/openssl/chacha.h +3 -3
  1118. data/third_party/boringssl-with-bazel/include/openssl/cipher.h +345 -161
  1119. data/third_party/boringssl-with-bazel/include/openssl/cmac.h +13 -13
  1120. data/third_party/boringssl-with-bazel/include/openssl/cms.h +35 -34
  1121. data/third_party/boringssl-with-bazel/include/openssl/conf.h +15 -14
  1122. data/third_party/boringssl-with-bazel/include/openssl/configuration.h +18 -0
  1123. data/third_party/boringssl-with-bazel/include/openssl/crypto.h +15 -13
  1124. data/third_party/boringssl-with-bazel/include/openssl/ctrdrbg.h +49 -15
  1125. data/third_party/boringssl-with-bazel/include/openssl/curve25519.h +60 -24
  1126. data/third_party/boringssl-with-bazel/include/openssl/des.h +22 -16
  1127. data/third_party/boringssl-with-bazel/include/openssl/dh.h +95 -95
  1128. data/third_party/boringssl-with-bazel/include/openssl/digest.h +144 -75
  1129. data/third_party/boringssl-with-bazel/include/openssl/dsa.h +101 -101
  1130. data/third_party/boringssl-with-bazel/include/openssl/ec.h +178 -120
  1131. data/third_party/boringssl-with-bazel/include/openssl/ec_key.h +99 -99
  1132. data/third_party/boringssl-with-bazel/include/openssl/ecdh.h +9 -9
  1133. data/third_party/boringssl-with-bazel/include/openssl/ecdsa.h +89 -46
  1134. data/third_party/boringssl-with-bazel/include/openssl/engine.h +5 -5
  1135. data/third_party/boringssl-with-bazel/include/openssl/err.h +73 -71
  1136. data/third_party/boringssl-with-bazel/include/openssl/evp.h +941 -344
  1137. data/third_party/boringssl-with-bazel/include/openssl/evp_errors.h +10 -2
  1138. data/third_party/boringssl-with-bazel/include/openssl/ex_data.h +27 -32
  1139. data/third_party/boringssl-with-bazel/include/openssl/hkdf.h +6 -6
  1140. data/third_party/boringssl-with-bazel/include/openssl/hmac.h +33 -33
  1141. data/third_party/boringssl-with-bazel/include/openssl/hpke.h +170 -123
  1142. data/third_party/boringssl-with-bazel/include/openssl/hrss.h +14 -8
  1143. data/third_party/boringssl-with-bazel/include/openssl/kdf.h +20 -19
  1144. data/third_party/boringssl-with-bazel/include/openssl/lhash.h +4 -25
  1145. data/third_party/boringssl-with-bazel/include/openssl/md4.h +14 -7
  1146. data/third_party/boringssl-with-bazel/include/openssl/md5.h +7 -7
  1147. data/third_party/boringssl-with-bazel/include/openssl/mem.h +42 -42
  1148. data/third_party/boringssl-with-bazel/include/openssl/mldsa.h +380 -24
  1149. data/third_party/boringssl-with-bazel/include/openssl/mlkem.h +43 -43
  1150. data/third_party/boringssl-with-bazel/include/openssl/nid.h +1339 -2
  1151. data/third_party/boringssl-with-bazel/include/openssl/obj.h +49 -49
  1152. data/third_party/boringssl-with-bazel/include/openssl/opensslconf.h +30 -0
  1153. data/third_party/boringssl-with-bazel/include/openssl/params.h +42 -0
  1154. data/third_party/boringssl-with-bazel/include/openssl/pem.h +669 -361
  1155. data/third_party/boringssl-with-bazel/include/openssl/pkcs7.h +40 -40
  1156. data/third_party/boringssl-with-bazel/include/openssl/pkcs8.h +69 -63
  1157. data/third_party/boringssl-with-bazel/include/openssl/poly1305.h +8 -5
  1158. data/third_party/boringssl-with-bazel/include/openssl/pool.h +54 -25
  1159. data/third_party/boringssl-with-bazel/include/openssl/posix_time.h +8 -8
  1160. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols.h +7992 -0
  1161. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_S.h +633 -0
  1162. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_c.h +329 -0
  1163. data/third_party/boringssl-with-bazel/include/openssl/rand.h +18 -18
  1164. data/third_party/boringssl-with-bazel/include/openssl/rc4.h +4 -4
  1165. data/third_party/boringssl-with-bazel/include/openssl/ripemd.h +15 -10
  1166. data/third_party/boringssl-with-bazel/include/openssl/rsa.h +272 -235
  1167. data/third_party/boringssl-with-bazel/include/openssl/service_indicator.h +4 -81
  1168. data/third_party/boringssl-with-bazel/include/openssl/sha.h +43 -166
  1169. data/third_party/boringssl-with-bazel/include/openssl/sha2.h +201 -0
  1170. data/third_party/boringssl-with-bazel/include/openssl/slhdsa.h +125 -49
  1171. data/third_party/boringssl-with-bazel/include/openssl/span.h +190 -75
  1172. data/third_party/boringssl-with-bazel/include/openssl/ssl.h +2403 -1633
  1173. data/third_party/boringssl-with-bazel/include/openssl/ssl3.h +11 -69
  1174. data/third_party/boringssl-with-bazel/include/openssl/stack.h +144 -80
  1175. data/third_party/boringssl-with-bazel/include/openssl/target.h +13 -1
  1176. data/third_party/boringssl-with-bazel/include/openssl/thread.h +0 -10
  1177. data/third_party/boringssl-with-bazel/include/openssl/tls1.h +31 -310
  1178. data/third_party/boringssl-with-bazel/include/openssl/tls_prf.h +47 -0
  1179. data/third_party/boringssl-with-bazel/include/openssl/trust_token.h +97 -92
  1180. data/third_party/boringssl-with-bazel/include/openssl/type_check.h +1 -1
  1181. data/third_party/boringssl-with-bazel/include/openssl/types.h +18 -0
  1182. data/third_party/boringssl-with-bazel/include/openssl/x509.h +1839 -1872
  1183. data/third_party/boringssl-with-bazel/include/openssl/x509v3.h +1 -1
  1184. data/third_party/boringssl-with-bazel/include/openssl/xwing.h +115 -0
  1185. data/third_party/boringssl-with-bazel/ssl/bio_ssl.cc +22 -19
  1186. data/third_party/boringssl-with-bazel/ssl/d1_both.cc +202 -135
  1187. data/third_party/boringssl-with-bazel/ssl/d1_lib.cc +84 -68
  1188. data/third_party/boringssl-with-bazel/ssl/d1_pkt.cc +10 -10
  1189. data/third_party/boringssl-with-bazel/ssl/d1_srtp.cc +12 -10
  1190. data/third_party/boringssl-with-bazel/ssl/dtls_method.cc +14 -14
  1191. data/third_party/boringssl-with-bazel/ssl/dtls_record.cc +21 -20
  1192. data/third_party/boringssl-with-bazel/ssl/encrypted_client_hello.cc +102 -96
  1193. data/third_party/boringssl-with-bazel/ssl/extensions.cc +1083 -500
  1194. data/third_party/boringssl-with-bazel/ssl/handoff.cc +154 -100
  1195. data/third_party/boringssl-with-bazel/ssl/handshake.cc +76 -44
  1196. data/third_party/boringssl-with-bazel/ssl/handshake_client.cc +153 -152
  1197. data/third_party/boringssl-with-bazel/ssl/handshake_server.cc +180 -212
  1198. data/third_party/boringssl-with-bazel/ssl/internal.h +1368 -1481
  1199. data/third_party/boringssl-with-bazel/ssl/s3_both.cc +40 -168
  1200. data/third_party/boringssl-with-bazel/ssl/s3_lib.cc +5 -5
  1201. data/third_party/boringssl-with-bazel/ssl/s3_pkt.cc +22 -21
  1202. data/third_party/boringssl-with-bazel/ssl/ssl_aead_ctx.cc +5 -5
  1203. data/third_party/boringssl-with-bazel/ssl/ssl_asn1.cc +123 -68
  1204. data/third_party/boringssl-with-bazel/ssl/ssl_buffer.cc +25 -26
  1205. data/third_party/boringssl-with-bazel/ssl/ssl_cert.cc +156 -84
  1206. data/third_party/boringssl-with-bazel/ssl/ssl_cipher.cc +341 -160
  1207. data/third_party/boringssl-with-bazel/ssl/ssl_credential.cc +349 -124
  1208. data/third_party/boringssl-with-bazel/ssl/ssl_file.cc +134 -225
  1209. data/third_party/boringssl-with-bazel/ssl/ssl_key_share.cc +80 -101
  1210. data/third_party/boringssl-with-bazel/ssl/ssl_lib.cc +1403 -694
  1211. data/third_party/boringssl-with-bazel/ssl/ssl_privkey.cc +173 -105
  1212. data/third_party/boringssl-with-bazel/ssl/ssl_session.cc +287 -235
  1213. data/third_party/boringssl-with-bazel/ssl/ssl_stat.cc +6 -3
  1214. data/third_party/boringssl-with-bazel/ssl/ssl_transcript.cc +4 -4
  1215. data/third_party/boringssl-with-bazel/ssl/ssl_versions.cc +47 -41
  1216. data/third_party/boringssl-with-bazel/ssl/ssl_x509.cc +321 -273
  1217. data/third_party/boringssl-with-bazel/ssl/t1_enc.cc +40 -29
  1218. data/third_party/boringssl-with-bazel/ssl/tls13_both.cc +109 -75
  1219. data/third_party/boringssl-with-bazel/ssl/tls13_client.cc +201 -115
  1220. data/third_party/boringssl-with-bazel/ssl/tls13_enc.cc +179 -124
  1221. data/third_party/boringssl-with-bazel/ssl/tls13_server.cc +241 -158
  1222. data/third_party/boringssl-with-bazel/ssl/tls_method.cc +35 -35
  1223. data/third_party/boringssl-with-bazel/ssl/tls_record.cc +40 -34
  1224. data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_bareminimum.c.inc +47 -0
  1225. data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_platform.c.inc +137 -0
  1226. data/third_party/boringssl-with-bazel/third_party/fiat/curve25519_64_adx.h +37 -33
  1227. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64.h +29 -80
  1228. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64_msvc.h +6 -69
  1229. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field.c.inc +26 -0
  1230. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_32.br.c.inc +71 -0
  1231. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_64.br.c.inc +84 -0
  1232. data/third_party/boringssl-with-bazel/third_party/fiat/p256_point.br.c.inc +112 -0
  1233. data/third_party/cares/cares/include/ares.h +8 -0
  1234. data/third_party/cares/cares/include/ares_dns_record.h +3 -2
  1235. data/third_party/cares/cares/include/ares_version.h +3 -3
  1236. data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +20 -20
  1237. data/third_party/cares/cares/src/lib/ares_cancel.c +17 -8
  1238. data/third_party/cares/cares/src/lib/ares_close_sockets.c +81 -16
  1239. data/third_party/cares/cares/src/lib/ares_conn.c +256 -10
  1240. data/third_party/cares/cares/src/lib/ares_conn.h +40 -3
  1241. data/third_party/cares/cares/src/lib/ares_cookie.c +2 -2
  1242. data/third_party/cares/cares/src/lib/ares_destroy.c +75 -10
  1243. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +85 -10
  1244. data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +5 -0
  1245. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +4 -0
  1246. data/third_party/cares/cares/src/lib/ares_getnameinfo.c +10 -2
  1247. data/third_party/cares/cares/src/lib/ares_hosts_file.c +8 -0
  1248. data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +28 -0
  1249. data/third_party/cares/cares/src/lib/ares_init.c +55 -10
  1250. data/third_party/cares/cares/src/lib/ares_library_init.c +25 -7
  1251. data/third_party/cares/cares/src/lib/ares_options.c +38 -10
  1252. data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +1 -1
  1253. data/third_party/cares/cares/src/lib/ares_private.h +186 -27
  1254. data/third_party/cares/cares/src/lib/ares_process.c +604 -112
  1255. data/third_party/cares/cares/src/lib/ares_qcache.c +200 -36
  1256. data/third_party/cares/cares/src/lib/ares_query.c +5 -0
  1257. data/third_party/cares/cares/src/lib/ares_search.c +10 -0
  1258. data/third_party/cares/cares/src/lib/ares_send.c +81 -10
  1259. data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +3 -1
  1260. data/third_party/cares/cares/src/lib/ares_socket.c +28 -0
  1261. data/third_party/cares/cares/src/lib/ares_socket.h +23 -0
  1262. data/third_party/cares/cares/src/lib/ares_sysconfig.c +6 -3
  1263. data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +33 -11
  1264. data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +132 -80
  1265. data/third_party/cares/cares/src/lib/ares_timeout.c +11 -0
  1266. data/third_party/cares/cares/src/lib/ares_update_servers.c +55 -11
  1267. data/third_party/cares/cares/src/lib/dsa/ares_array.c +20 -5
  1268. data/third_party/cares/cares/src/lib/dsa/ares_htable.c +8 -4
  1269. data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +2 -0
  1270. data/third_party/cares/cares/src/lib/dsa/ares_llist.c +4 -1
  1271. data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +5 -2
  1272. data/third_party/cares/cares/src/lib/event/ares_event_select.c +14 -1
  1273. data/third_party/cares/cares/src/lib/event/ares_event_thread.c +8 -0
  1274. data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +7 -1
  1275. data/third_party/cares/cares/src/lib/event/ares_event_win32.c +3 -0
  1276. data/third_party/cares/cares/src/lib/include/ares_mem.h +3 -0
  1277. data/third_party/cares/cares/src/lib/include/ares_str.h +17 -0
  1278. data/third_party/cares/cares/src/lib/inet_net_pton.c +37 -28
  1279. data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +1 -1
  1280. data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +5 -2
  1281. data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +5 -2
  1282. data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +2 -2
  1283. data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +2 -2
  1284. data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +1 -1
  1285. data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +19 -4
  1286. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +3 -1
  1287. data/third_party/cares/cares/src/lib/record/ares_dns_name.c +67 -4
  1288. data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +62 -34
  1289. data/third_party/cares/cares/src/lib/record/ares_dns_private.h +4 -0
  1290. data/third_party/cares/cares/src/lib/record/ares_dns_record.c +47 -7
  1291. data/third_party/cares/cares/src/lib/record/ares_dns_write.c +13 -5
  1292. data/third_party/cares/cares/src/lib/str/ares_buf.c +33 -16
  1293. data/third_party/cares/cares/src/lib/str/ares_str.c +54 -0
  1294. data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +22 -10
  1295. data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +1 -0
  1296. data/third_party/cares/cares/src/lib/util/ares_math.c +17 -2
  1297. data/third_party/cares/cares/src/lib/util/ares_math.h +32 -7
  1298. data/third_party/cares/cares/src/lib/util/ares_rand.c +4 -4
  1299. data/third_party/cares/cares/src/lib/util/ares_threads.c +1 -2
  1300. data/third_party/cares/cares/src/lib/util/ares_time.h +1 -0
  1301. data/third_party/cares/cares/src/lib/util/ares_uri.c +9 -3
  1302. data/third_party/zlib/compress.c +34 -10
  1303. data/third_party/zlib/crc32.c +49 -115
  1304. data/third_party/zlib/deflate.c +107 -61
  1305. data/third_party/zlib/deflate.h +7 -1
  1306. data/third_party/zlib/gzguts.h +33 -31
  1307. data/third_party/zlib/infback.c +20 -67
  1308. data/third_party/zlib/inffast.c +7 -6
  1309. data/third_party/zlib/inffixed.h +91 -91
  1310. data/third_party/zlib/inflate.c +38 -151
  1311. data/third_party/zlib/inflate.h +1 -1
  1312. data/third_party/zlib/inftrees.c +134 -9
  1313. data/third_party/zlib/inftrees.h +3 -1
  1314. data/third_party/zlib/trees.c +14 -12
  1315. data/third_party/zlib/uncompr.c +39 -23
  1316. data/third_party/zlib/zconf.h +27 -19
  1317. data/third_party/zlib/zlib.h +215 -96
  1318. data/third_party/zlib/zutil.c +49 -35
  1319. data/third_party/zlib/zutil.h +87 -10
  1320. metadata +4095 -4024
  1321. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +0 -916
  1322. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +0 -84
  1323. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +0 -240
  1324. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +0 -56
  1325. data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb.h +0 -157
  1326. data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb_minitable.c +0 -72
  1327. data/src/core/ext/upbdefs-gen/src/proto/grpc/lookup/v1/rls_config.upbdefs.c +0 -181
  1328. data/src/core/server/xds_channel_stack_modifier.cc +0 -108
  1329. data/src/core/server/xds_channel_stack_modifier.h +0 -62
  1330. data/src/core/server/xds_server_config_fetcher_legacy.cc +0 -1340
  1331. data/third_party/abseil-cpp/absl/base/internal/identity.h +0 -39
  1332. data/third_party/abseil-cpp/absl/base/internal/nullability_deprecated.h +0 -106
  1333. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +0 -105
  1334. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +0 -50
  1335. data/third_party/abseil-cpp/absl/strings/string_view.cc +0 -257
  1336. data/third_party/boringssl-with-bazel/crypto/evp/p_dh_asn1.cc +0 -142
  1337. data/third_party/boringssl-with-bazel/crypto/evp/p_dsa_asn1.cc +0 -279
  1338. data/third_party/boringssl-with-bazel/crypto/evp/p_ec_asn1.cc +0 -286
  1339. data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519_asn1.cc +0 -225
  1340. data/third_party/boringssl-with-bazel/crypto/evp/p_rsa_asn1.cc +0 -198
  1341. data/third_party/boringssl-with-bazel/crypto/evp/p_x25519_asn1.cc +0 -237
  1342. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p224-64.cc.inc +0 -1163
  1343. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/blinding.cc.inc +0 -147
  1344. data/third_party/boringssl-with-bazel/crypto/kyber/internal.h +0 -60
  1345. data/third_party/boringssl-with-bazel/crypto/kyber/kyber.cc +0 -869
  1346. data/third_party/boringssl-with-bazel/crypto/rand/getrandom_fillin.h +0 -64
  1347. data/third_party/boringssl-with-bazel/crypto/rand/passive.cc +0 -178
  1348. data/third_party/boringssl-with-bazel/crypto/x509/ext_dat.h +0 -92
  1349. data/third_party/boringssl-with-bazel/include/openssl/bcm_public.h +0 -82
  1350. data/third_party/boringssl-with-bazel/include/openssl/experimental/kyber.h +0 -146
@@ -24,19 +24,17 @@
24
24
  #include <algorithm>
25
25
  #include <atomic>
26
26
  #include <bitset>
27
+ #include <cstdint>
27
28
  #include <initializer_list>
28
- #include <limits>
29
- #include <new>
30
29
  #include <optional>
31
30
  #include <string_view>
32
- #include <type_traits>
33
31
  #include <utility>
32
+ #include <variant>
34
33
 
35
34
  #include <openssl/aead.h>
36
35
  #include <openssl/curve25519.h>
37
36
  #include <openssl/err.h>
38
37
  #include <openssl/hpke.h>
39
- #include <openssl/lhash.h>
40
38
  #include <openssl/mem.h>
41
39
  #include <openssl/span.h>
42
40
  #include <openssl/ssl.h>
@@ -45,9 +43,9 @@
45
43
  #include "../crypto/err/internal.h"
46
44
  #include "../crypto/internal.h"
47
45
  #include "../crypto/lhash/internal.h"
46
+ #include "../crypto/mem_internal.h"
48
47
  #include "../crypto/spake2plus/internal.h"
49
48
 
50
-
51
49
  #if defined(OPENSSL_WINDOWS)
52
50
  // Windows defines struct timeval in winsock2.h.
53
51
  #include <winsock2.h>
@@ -56,6 +54,12 @@
56
54
  #endif
57
55
 
58
56
 
57
+ DECLARE_OPAQUE_STRUCT(ssl_credential_st, SSLCredential)
58
+ DECLARE_OPAQUE_STRUCT(ssl_ctx_st, SSLContext)
59
+ DECLARE_OPAQUE_STRUCT(ssl_st, SSLImpl)
60
+ DECLARE_OPAQUE_STRUCT(ssl_session_st, SSLSession)
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
- // New behaves like |new| but uses |OPENSSL_malloc| for memory allocation. It
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 |start_| to be reset when moved-from.)
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
- // CBBFinishArray behaves like |CBB_finish| but stores the result in an Array.
553
- OPENSSL_EXPORT bool CBBFinishArray(CBB *cbb, Array<uint8_t> *out);
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
- // |fixed_names_len| strings from |fixed_names| followed by |objects_len|
559
- // strings taken by projecting |objects| through |name|.
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, Name(T::*name),
563
- Span<const T> objects) {
564
- auto span = bssl::Span(out, max_out);
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.subspan(0, objects.size());
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,47 +150,47 @@ 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 |*out| to the protocol version
634
- // corresponding to wire version |version| and returns true. If |version| is not
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 |*out_min_version| and |*out_max_version| to the
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 |hs| supports |version|.
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 |method| supports |version|.
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 |hs| to |cbb|, in
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 |extra_min_version|.
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 |hs|'s preferences
660
- // and the peer preference list in |peer_versions|. On success, it returns true
661
- // and sets |*out_version| to the selected version. Otherwise, it returns false
662
- // and sets |*out_alert| to an alert to send.
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 |ssl| has determined the final version.
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
- bool ssl_has_final_version(const SSL *ssl);
189
+ bool ssl_has_final_version(const SSLImpl *ssl);
670
190
 
671
- // ssl_protocol_version returns |ssl|'s protocol version. It is an error to
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
- uint16_t ssl_protocol_version(const SSL *ssl);
193
+ uint16_t ssl_protocol_version(const SSLImpl *ssl);
674
194
 
675
195
  // Cipher suites.
676
196
 
@@ -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
- // id is the cipher suite value bitwise OR-d with 0x03000000.
685
- uint32_t id;
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 |algorithm_mkey| (key exchange algorithm).
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 |algorithm_auth| (server authentication).
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 |algorithm_enc| (symmetric encryption).
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 |algorithm_mac| (symmetric authentication).
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 |algorithm_prf| (handshake digest).
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 |ciphers| are in one-to-one correspondence with
750
- // |in_group_flags|. (That is, sk_SSL_CIPHER_num(ciphers) is the number of
751
- // bytes in |in_group_flags|.) The bytes in |in_group_flags| are either 1, to
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 |in_group_flags| contains all zeros then that indicates a
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
  //
@@ -765,28 +285,69 @@ BSSL_NAMESPACE_BEGIN
765
285
  // A E
766
286
  // B -> D -> F
767
287
  // C
768
- struct SSLCipherPreferenceList {
288
+ class SSLCipherPreferenceList {
289
+ public:
769
290
  static constexpr bool kAllowUniquePtr = true;
770
291
 
771
292
  SSLCipherPreferenceList() = default;
772
- ~SSLCipherPreferenceList();
293
+ ~SSLCipherPreferenceList() = default;
773
294
 
295
+ // Initializes a list with the specified ciphers and flags. Calling Init on a
296
+ // previously initialized list discards the previous contents.
774
297
  bool Init(UniquePtr<STACK_OF(SSL_CIPHER)> ciphers,
775
- Span<const bool> in_group_flags);
776
- bool Init(const SSLCipherPreferenceList &);
298
+ Array<bool> in_group_flags);
299
+ // Same as above, but takes a list of cipher protocol IDs.
300
+ bool Init(Span<const uint16_t> cipher_ids, Span<const bool> in_group_flags);
301
+
302
+ // Reset clears any contents previously set by `Init`.
303
+ void Reset();
777
304
 
305
+ // Makes `this` a deep copy of another (already initialized) instance.
306
+ bool CopyFrom(const SSLCipherPreferenceList &);
307
+
308
+ // Removes `cipher` from the preference list.
778
309
  void Remove(const SSL_CIPHER *cipher);
779
310
 
780
- UniquePtr<STACK_OF(SSL_CIPHER)> ciphers;
781
- bool *in_group_flags = nullptr;
311
+ // Contains returns whether a cipher whose protocol ID is `cipher_id` appears
312
+ // in the list.
313
+ bool Contains(uint16_t cipher_id) const;
314
+
315
+ // ChooseCipher implements the logic for a server to select the most-preferred
316
+ // cipher satisfying the constraints that is listed in both `*this` and the
317
+ // client's preference list in `client_cipher_list`, which contains an ordered
318
+ // list of 2-byte cipher suite protocol IDs. The returned cipher must be
319
+ // supported for the SSL protocol `version`, and must match the key exchange
320
+ // algorithm mask `mask_k` and the server authentication mask `mask_a`. If
321
+ // `prioritize_client_pref` is true, then the client's preference list is
322
+ // prioritized over the list in `*this`. Otherwise, the server's preference
323
+ // list (`*this`) is prioritized. This function returns a pointer to the
324
+ // most-preferred shared cipher, or nullptr if no shared cipher was found.
325
+ const SSL_CIPHER *ChooseCipher(const CBS *client_cipher_list,
326
+ bool prioritize_client_pref, uint16_t version,
327
+ uint32_t mask_k, uint32_t mask_a) const;
328
+
329
+ size_t size() const { return sk_SSL_CIPHER_num(ciphers_.get()); }
330
+
331
+ const STACK_OF(SSL_CIPHER) *ciphers() const { return ciphers_.get(); }
332
+ Span<const bool> in_group_flags() const { return in_group_flags_; }
333
+
334
+ // TODO(crbug.com/550501994): Remove the non-const overload. This may result
335
+ // in callers mutating the internal state in an inconsistent way.
336
+ STACK_OF(SSL_CIPHER) *ciphers() { return ciphers_.get(); }
337
+
338
+ private:
339
+ // SSL_CIPHERs are maintained in a stack so they are easily accessible in the
340
+ // form required for `SSL{_CTX}_get_ciphers`.
341
+ UniquePtr<STACK_OF(SSL_CIPHER)> ciphers_;
342
+ Array<bool> in_group_flags_;
782
343
  };
783
344
 
784
345
  // AllCiphers returns an array of all supported ciphers, sorted by id.
785
346
  Span<const SSL_CIPHER> AllCiphers();
786
347
 
787
- // ssl_cipher_get_evp_aead sets |*out_aead| to point to the correct EVP_AEAD
788
- // object for |cipher| protocol version |version|. It sets |*out_mac_secret_len|
789
- // and |*out_fixed_iv_len| to the MAC key length and fixed IV length,
348
+ // ssl_cipher_get_evp_aead sets `*out_aead` to point to the correct EVP_AEAD
349
+ // object for `cipher` protocol version `version`. It sets `*out_mac_secret_len`
350
+ // and `*out_fixed_iv_len` to the MAC key length and fixed IV length,
790
351
  // respectively. The MAC key length is zero except for legacy block and stream
791
352
  // ciphers. It returns true on success and false on error.
792
353
  bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
@@ -794,34 +355,42 @@ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
794
355
  size_t *out_fixed_iv_len, const SSL_CIPHER *cipher,
795
356
  uint16_t version);
796
357
 
797
- // ssl_get_handshake_digest returns the |EVP_MD| corresponding to |version| and
798
- // |cipher|.
358
+ // ssl_get_handshake_digest returns the `EVP_MD` corresponding to `version` and
359
+ // `cipher`.
799
360
  const EVP_MD *ssl_get_handshake_digest(uint16_t version,
800
361
  const SSL_CIPHER *cipher);
801
362
 
802
- // ssl_create_cipher_list evaluates |rule_str|. It sets |*out_cipher_list| to a
803
- // newly-allocated |SSLCipherPreferenceList| containing the result. It returns
804
- // true on success and false on failure. If |strict| is true, nonsense will be
805
- // rejected. If false, nonsense will be silently ignored. An empty result is
806
- // considered an error regardless of |strict|. |has_aes_hw| indicates if the
807
- // list should be ordered based on having support for AES in hardware or not.
363
+ // ssl_create_cipher_list evaluates `rule_str` to create the TLS 1.2 cipher
364
+ // list. It sets `*out_cipher_list` to a newly-allocated
365
+ // `SSLCipherPreferenceList` containing the result. It returns true on success
366
+ // and false on failure. If `strict` is true, nonsense will be rejected. If
367
+ // false, nonsense will be silently ignored. An empty result is considered an
368
+ // error regardless of `strict`. The resulting list will be ordered based on
369
+ // having support for AES in hardware or not.
808
370
  bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
809
- const bool has_aes_hw, const char *rule_str,
810
- bool strict);
811
-
812
- // ssl_cipher_auth_mask_for_key returns the mask of cipher |algorithm_auth|
813
- // values suitable for use with |key| in TLS 1.2 and below. |sign_ok| indicates
814
- // whether |key| may be used for signing.
371
+ const char *rule_str, bool strict);
372
+
373
+ // ssl_create_default_tls13_cipher_list populates the default TLS 1.3 cipher
374
+ // list, clearing any previous contents in `*out_cipher_list` and replacing them
375
+ // with the result. It returns true on success and false on failure. The
376
+ // resulting list will be ordered based on having support for AES in hardware or
377
+ // not.
378
+ bool ssl_create_default_tls13_cipher_list(
379
+ SSLCipherPreferenceList *out_cipher_list);
380
+
381
+ // ssl_cipher_auth_mask_for_key returns the mask of cipher `algorithm_auth`
382
+ // values suitable for use with `key` in TLS 1.2 and below. `sign_ok` indicates
383
+ // whether `key` may be used for signing.
815
384
  uint32_t ssl_cipher_auth_mask_for_key(const EVP_PKEY *key, bool sign_ok);
816
385
 
817
- // ssl_cipher_uses_certificate_auth returns whether |cipher| authenticates the
386
+ // ssl_cipher_uses_certificate_auth returns whether `cipher` authenticates the
818
387
  // server and, optionally, the client with a certificate.
819
388
  bool ssl_cipher_uses_certificate_auth(const SSL_CIPHER *cipher);
820
389
 
821
- // ssl_cipher_requires_server_key_exchange returns whether |cipher| requires a
390
+ // ssl_cipher_requires_server_key_exchange returns whether `cipher` requires a
822
391
  // ServerKeyExchange message.
823
392
  //
824
- // This function may return false while still allowing |cipher| an optional
393
+ // This function may return false while still allowing `cipher` an optional
825
394
  // ServerKeyExchange. This is the case for plain PSK ciphers.
826
395
  bool ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
827
396
 
@@ -830,21 +399,8 @@ bool ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
830
399
  // it returns zero.
831
400
  size_t ssl_cipher_get_record_split_len(const SSL_CIPHER *cipher);
832
401
 
833
- // ssl_choose_tls13_cipher returns an |SSL_CIPHER| corresponding with the best
834
- // available from |cipher_suites| compatible with |version| and |policy|. It
835
- // returns NULL if there isn't a compatible cipher. |has_aes_hw| indicates if
836
- // the choice should be made as if support for AES in hardware is available.
837
- const SSL_CIPHER *ssl_choose_tls13_cipher(CBS cipher_suites, bool has_aes_hw,
838
- uint16_t version,
839
- enum ssl_compliance_policy_t policy);
840
-
841
- // ssl_tls13_cipher_meets_policy returns true if |cipher_id| is acceptable given
842
- // |policy|.
843
- bool ssl_tls13_cipher_meets_policy(uint16_t cipher_id,
844
- enum ssl_compliance_policy_t policy);
845
-
846
- // ssl_cipher_is_deprecated returns true if |cipher| is deprecated.
847
- OPENSSL_EXPORT bool ssl_cipher_is_deprecated(const SSL_CIPHER *cipher);
402
+ // ssl_cipher_is_deprecated returns true if `cipher` is deprecated.
403
+ bool ssl_cipher_is_deprecated(const SSL_CIPHER *cipher);
848
404
 
849
405
 
850
406
  // Transcript layer.
@@ -865,7 +421,7 @@ class SSLTranscript {
865
421
  bool Init();
866
422
 
867
423
  // InitHash initializes the handshake hash based on the PRF and contents of
868
- // the handshake transcript. Subsequent calls to |Update| will update the
424
+ // the handshake transcript. Subsequent calls to `Update` will update the
869
425
  // rolling hash. It returns one on success and zero on failure. It is an error
870
426
  // to call this function after the handshake buffer is released. This may be
871
427
  // called multiple times to change the hash function.
@@ -877,10 +433,10 @@ class SSLTranscript {
877
433
  // is released.
878
434
  bool UpdateForHelloRetryRequest();
879
435
 
880
- // CopyToHashContext initializes |ctx| with |digest| and the data thus far in
436
+ // CopyToHashContext initializes `ctx` with `digest` and the data thus far in
881
437
  // the transcript. It returns true on success and false on failure. If the
882
- // handshake buffer is still present, |digest| may be any supported digest.
883
- // Otherwise, |digest| must match the transcript hash.
438
+ // handshake buffer is still present, `digest` may be any supported digest.
439
+ // Otherwise, `digest` must match the transcript hash.
884
440
  bool CopyToHashContext(EVP_MD_CTX *ctx, const EVP_MD *digest) const;
885
441
 
886
442
  Span<const uint8_t> buffer() const {
@@ -889,45 +445,45 @@ class SSLTranscript {
889
445
  }
890
446
 
891
447
  // FreeBuffer releases the handshake buffer. Subsequent calls to
892
- // |Update| will not update the handshake buffer.
448
+ // `Update` will not update the handshake buffer.
893
449
  void FreeBuffer();
894
450
 
895
451
  // DigestLen returns the length of the PRF hash.
896
452
  size_t DigestLen() const;
897
453
 
898
454
  // Digest returns the PRF hash. For TLS 1.1 and below, this is
899
- // |EVP_md5_sha1|.
455
+ // `EVP_md5_sha1`.
900
456
  const EVP_MD *Digest() const;
901
457
 
902
- // Update adds |in| to the handshake buffer and handshake hash, whichever is
458
+ // Update adds `in` to the handshake buffer and handshake hash, whichever is
903
459
  // enabled. It returns true on success and false on failure.
904
460
  bool Update(Span<const uint8_t> in);
905
461
 
906
- // GetHash writes the handshake hash to |out| which must have room for at
907
- // least |DigestLen| bytes. On success, it returns true and sets |*out_len| to
462
+ // GetHash writes the handshake hash to `out` which must have room for at
463
+ // least `DigestLen` bytes. On success, it returns true and sets `*out_len` to
908
464
  // the number of bytes written. Otherwise, it returns false.
909
465
  bool GetHash(uint8_t *out, size_t *out_len) const;
910
466
 
911
467
  // GetFinishedMAC computes the MAC for the Finished message into the bytes
912
- // pointed by |out| and writes the number of bytes to |*out_len|. |out| must
913
- // have room for |EVP_MAX_MD_SIZE| bytes. It returns true on success and false
468
+ // pointed by `out` and writes the number of bytes to `*out_len`. `out` must
469
+ // have room for `EVP_MAX_MD_SIZE` bytes. It returns true on success and false
914
470
  // on failure.
915
- bool GetFinishedMAC(uint8_t *out, size_t *out_len, const SSL_SESSION *session,
471
+ bool GetFinishedMAC(uint8_t *out, size_t *out_len, const SSLSession *session,
916
472
  bool from_server) const;
917
473
 
918
474
  private:
919
- // HashBuffer initializes |ctx| to use |digest| and writes the contents of
920
- // |buffer_| to |ctx|. If this SSLTranscript is for DTLS 1.3, the appropriate
921
- // bytes in |buffer_| will be skipped when hashing the buffer.
475
+ // HashBuffer initializes `ctx` to use `digest` and writes the contents of
476
+ // `buffer_` to `ctx`. If this SSLTranscript is for DTLS 1.3, the appropriate
477
+ // bytes in `buffer_` will be skipped when hashing the buffer.
922
478
  bool HashBuffer(EVP_MD_CTX *ctx, const EVP_MD *digest) const;
923
479
 
924
- // AddToBufferOrHash directly adds the contents of |in| to |buffer_| and/or
925
- // |hash_|.
480
+ // AddToBufferOrHash directly adds the contents of `in` to `buffer_` and/or
481
+ // `hash_`.
926
482
  bool AddToBufferOrHash(Span<const uint8_t> in);
927
483
 
928
484
  // buffer_, if non-null, contains the handshake transcript.
929
485
  UniquePtr<BUF_MEM> buffer_;
930
- // hash, if initialized with an |EVP_MD|, maintains the handshake hash.
486
+ // hash, if initialized with an `EVP_MD`, maintains the handshake hash.
931
487
  ScopedEVP_MD_CTX hash_;
932
488
  // is_dtls_ indicates whether this is a transcript for a DTLS connection.
933
489
  bool is_dtls_ : 1;
@@ -935,8 +491,8 @@ class SSLTranscript {
935
491
  uint16_t version_ = 0;
936
492
  };
937
493
 
938
- // tls1_prf computes the PRF function for |ssl|. It fills |out|, using |secret|
939
- // as the secret and |label| as the label. |seed1| and |seed2| are concatenated
494
+ // tls1_prf computes the PRF function for `ssl`. It fills `out`, using `secret`
495
+ // as the secret and `label` as the label. `seed1` and `seed2` are concatenated
940
496
  // to form the seed parameter. It returns true on success and false on failure.
941
497
  bool tls1_prf(const EVP_MD *digest, Span<uint8_t> out,
942
498
  Span<const uint8_t> secret, std::string_view label,
@@ -956,12 +512,12 @@ class SSLAEADContext {
956
512
  SSLAEADContext(const SSLAEADContext &&) = delete;
957
513
  SSLAEADContext &operator=(const SSLAEADContext &&) = delete;
958
514
 
959
- // CreateNullCipher creates an |SSLAEADContext| for the null cipher.
515
+ // CreateNullCipher creates an `SSLAEADContext` for the null cipher.
960
516
  static UniquePtr<SSLAEADContext> CreateNullCipher();
961
517
 
962
- // Create creates an |SSLAEADContext| using the supplied key material. It
963
- // returns nullptr on error. Only one of |Open| or |Seal| may be used with the
964
- // resulting object, depending on |direction|. |version| is the wire version.
518
+ // Create creates an `SSLAEADContext` using the supplied key material. It
519
+ // returns nullptr on error. Only one of `Open` or `Seal` may be used with the
520
+ // resulting object, depending on `direction`. `version` is the wire version.
965
521
  static UniquePtr<SSLAEADContext> Create(enum evp_aead_direction_t direction,
966
522
  uint16_t version,
967
523
  const SSL_CIPHER *cipher,
@@ -969,7 +525,7 @@ class SSLAEADContext {
969
525
  Span<const uint8_t> mac_key,
970
526
  Span<const uint8_t> fixed_iv);
971
527
 
972
- // CreatePlaceholderForQUIC creates a placeholder |SSLAEADContext| for the
528
+ // CreatePlaceholderForQUIC creates a placeholder `SSLAEADContext` for the
973
529
  // given cipher. The resulting object can be queried for various properties
974
530
  // but cannot encrypt or decrypt data.
975
531
  static UniquePtr<SSLAEADContext> CreatePlaceholderForQUIC(
@@ -983,54 +539,54 @@ class SSLAEADContext {
983
539
  // ExplicitNonceLen returns the length of the explicit nonce.
984
540
  size_t ExplicitNonceLen() const;
985
541
 
986
- // MaxOverhead returns the maximum overhead of calling |Seal|.
542
+ // MaxOverhead returns the maximum overhead of calling `Seal`.
987
543
  size_t MaxOverhead() const;
988
544
 
989
- // MaxSealInputLen returns the maximum length for |Seal| that can fit in
990
- // |max_out| output bytes, or zero if no input may fit.
545
+ // MaxSealInputLen returns the maximum length for `Seal` that can fit in
546
+ // `max_out` output bytes, or zero if no input may fit.
991
547
  size_t MaxSealInputLen(size_t max_out) const;
992
548
 
993
- // SuffixLen calculates the suffix length written by |SealScatter| and writes
994
- // it to |*out_suffix_len|. It returns true on success and false on error.
995
- // |in_len| and |extra_in_len| should equal the argument of the same names
996
- // passed to |SealScatter|.
549
+ // SuffixLen calculates the suffix length written by `SealScatter` and writes
550
+ // it to `*out_suffix_len`. It returns true on success and false on error.
551
+ // `in_len` and `extra_in_len` should equal the argument of the same names
552
+ // passed to `SealScatter`.
997
553
  bool SuffixLen(size_t *out_suffix_len, size_t in_len,
998
554
  size_t extra_in_len) const;
999
555
 
1000
556
  // CiphertextLen calculates the total ciphertext length written by
1001
- // |SealScatter| and writes it to |*out_len|. It returns true on success and
1002
- // false on error. |in_len| and |extra_in_len| should equal the argument of
1003
- // the same names passed to |SealScatter|.
557
+ // `SealScatter` and writes it to `*out_len`. It returns true on success and
558
+ // false on error. `in_len` and `extra_in_len` should equal the argument of
559
+ // the same names passed to `SealScatter`.
1004
560
  bool CiphertextLen(size_t *out_len, size_t in_len, size_t extra_in_len) const;
1005
561
 
1006
- // Open authenticates and decrypts |in| in-place. On success, it sets |*out|
1007
- // to the plaintext in |in| and returns true. Otherwise, it returns
1008
- // false. The output will always be |ExplicitNonceLen| bytes ahead of |in|.
562
+ // Open authenticates and decrypts `in` in-place. On success, it sets `*out`
563
+ // to the plaintext in `in` and returns true. Otherwise, it returns
564
+ // false. The output will always be `ExplicitNonceLen` bytes ahead of `in`.
1009
565
  bool Open(Span<uint8_t> *out, uint8_t type, uint16_t record_version,
1010
566
  uint64_t seqnum, Span<const uint8_t> header, Span<uint8_t> in);
1011
567
 
1012
- // Seal encrypts and authenticates |in_len| bytes from |in| and writes the
1013
- // result to |out|. It returns true on success and false on error.
568
+ // Seal encrypts and authenticates `in_len` bytes from `in` and writes the
569
+ // result to `out`. It returns true on success and false on error.
1014
570
  //
1015
- // If |in| and |out| alias then |out| + |ExplicitNonceLen| must be == |in|.
571
+ // If `in` and `out` alias then `out` + `ExplicitNonceLen` must be == `in`.
1016
572
  bool Seal(uint8_t *out, size_t *out_len, size_t max_out, uint8_t type,
1017
573
  uint16_t record_version, uint64_t seqnum,
1018
574
  Span<const uint8_t> header, const uint8_t *in, size_t in_len);
1019
575
 
1020
- // SealScatter encrypts and authenticates |in_len| bytes from |in| and splits
1021
- // the result between |out_prefix|, |out| and |out_suffix|. It returns one on
576
+ // SealScatter encrypts and authenticates `in_len` bytes from `in` and splits
577
+ // the result between `out_prefix`, `out` and `out_suffix`. It returns one on
1022
578
  // success and zero on error.
1023
579
  //
1024
- // On successful return, exactly |ExplicitNonceLen| bytes are written to
1025
- // |out_prefix|, |in_len| bytes to |out|, and |SuffixLen| bytes to
1026
- // |out_suffix|.
580
+ // On successful return, exactly `ExplicitNonceLen` bytes are written to
581
+ // `out_prefix`, `in_len` bytes to `out`, and `SuffixLen` bytes to
582
+ // `out_suffix`.
1027
583
  //
1028
- // |extra_in| may point to an additional plaintext buffer. If present,
1029
- // |extra_in_len| additional bytes are encrypted and authenticated, and the
1030
- // ciphertext is written to the beginning of |out_suffix|. |SuffixLen| should
1031
- // be used to size |out_suffix| accordingly.
584
+ // `extra_in` may point to an additional plaintext buffer. If present,
585
+ // `extra_in_len` additional bytes are encrypted and authenticated, and the
586
+ // ciphertext is written to the beginning of `out_suffix`. `SuffixLen` should
587
+ // be used to size `out_suffix` accordingly.
1032
588
  //
1033
- // If |in| and |out| alias then |out| must be == |in|. Other arguments may not
589
+ // If `in` and `out` alias then `out` must be == `in`. Other arguments may not
1034
590
  // alias anything.
1035
591
  bool SealScatter(uint8_t *out_prefix, uint8_t *out, uint8_t *out_suffix,
1036
592
  uint8_t type, uint16_t record_version, uint64_t seqnum,
@@ -1040,7 +596,7 @@ class SSLAEADContext {
1040
596
  bool GetIV(const uint8_t **out_iv, size_t *out_iv_len) const;
1041
597
 
1042
598
  private:
1043
- // GetAdditionalData returns the additional data, writing into |storage| if
599
+ // GetAdditionalData returns the additional data, writing into `storage` if
1044
600
  // necessary.
1045
601
  Span<const uint8_t> GetAdditionalData(uint8_t storage[13], uint8_t type,
1046
602
  uint16_t record_version,
@@ -1077,12 +633,12 @@ class SSLAEADContext {
1077
633
  // replayed packets.
1078
634
  class DTLSReplayBitmap {
1079
635
  public:
1080
- // ShouldDiscard returns true if |seq_num| has been seen in
1081
- // |bitmap| or is stale. Otherwise it returns false.
636
+ // ShouldDiscard returns true if `seq_num` has been seen in
637
+ // `bitmap` or is stale. Otherwise it returns false.
1082
638
  bool ShouldDiscard(uint64_t seqnum) const;
1083
639
 
1084
640
  // Record updates the bitmap to record receipt of sequence number
1085
- // |seq_num|. It slides the window forward if needed. It is an error to call
641
+ // `seq_num`. It slides the window forward if needed. It is an error to call
1086
642
  // this function on a stale sequence number.
1087
643
  void Record(uint64_t seqnum);
1088
644
 
@@ -1090,7 +646,7 @@ class DTLSReplayBitmap {
1090
646
 
1091
647
  private:
1092
648
  // map is a bitset of sequence numbers that have been seen. Bit i corresponds
1093
- // to |max_seq_num_ - i|.
649
+ // to `max_seq_num_ - i`.
1094
650
  std::bitset<256> map_;
1095
651
  // max_seq_num_ is the largest sequence number seen so far as a 64-bit
1096
652
  // integer, or zero if none have been seen.
@@ -1099,18 +655,18 @@ class DTLSReplayBitmap {
1099
655
 
1100
656
  // reconstruct_seqnum takes the low order bits of a record sequence number from
1101
657
  // 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 |wire_seq| is the
1103
- // low bits of the sequence number as seen on the wire, |seq_mask| is a bitmask
658
+ // algorithm described in section 4.2.2 of RFC 9147, where `wire_seq` is the
659
+ // low bits of the sequence number as seen on the wire, `seq_mask` is a bitmask
1104
660
  // of 8 or 16 1 bits corresponding to the length of the sequence number on the
1105
- // wire, and |max_valid_seqnum| is the largest sequence number of a record
661
+ // wire, and `max_valid_seqnum` is the largest sequence number of a record
1106
662
  // successfully deprotected in this epoch. This function returns the sequence
1107
- // number that is numerically closest to one plus |max_valid_seqnum| that when
1108
- // bitwise and-ed with |seq_mask| equals |wire_seq|.
663
+ // number that is numerically closest to one plus `max_valid_seqnum` that when
664
+ // bitwise and-ed with `seq_mask` equals `wire_seq`.
1109
665
  //
1110
- // |max_valid_seqnum| must be most 2^48-1, in which case the output will also be
666
+ // `max_valid_seqnum` must be most 2^48-1, in which case the output will also be
1111
667
  // at most 2^48-1.
1112
- OPENSSL_EXPORT uint64_t reconstruct_seqnum(uint16_t wire_seq, uint64_t seq_mask,
1113
- uint64_t max_valid_seqnum);
668
+ uint64_t reconstruct_seqnum(uint16_t wire_seq, uint64_t seq_mask,
669
+ uint64_t max_valid_seqnum);
1114
670
 
1115
671
 
1116
672
  // Record layer.
@@ -1157,7 +713,7 @@ class RecordNumberEncrypter {
1157
713
  static constexpr bool kAllowUniquePtr = true;
1158
714
  static constexpr size_t kMaxKeySize = 32;
1159
715
 
1160
- // Create returns a DTLS 1.3 record number encrypter for |traffic_secret|, or
716
+ // Create returns a DTLS 1.3 record number encrypter for `traffic_secret`, or
1161
717
  // nullptr on error.
1162
718
  static UniquePtr<RecordNumberEncrypter> Create(
1163
719
  const SSL_CIPHER *cipher, Span<const uint8_t> traffic_secret);
@@ -1171,7 +727,7 @@ class RecordNumberEncrypter {
1171
727
  struct DTLSReadEpoch {
1172
728
  static constexpr bool kAllowUniquePtr = true;
1173
729
 
1174
- // TODO(davidben): This could be made slightly more compact if |bitmap| stored
730
+ // TODO(davidben): This could be made slightly more compact if `bitmap` stored
1175
731
  // a DTLSRecordNumber.
1176
732
  uint16_t epoch = 0;
1177
733
  UniquePtr<SSLAEADContext> aead;
@@ -1192,11 +748,11 @@ struct DTLSWriteEpoch {
1192
748
  };
1193
749
 
1194
750
  // ssl_record_prefix_len returns the length of the prefix before the ciphertext
1195
- // of a record for |ssl|.
751
+ // of a record for `ssl`.
1196
752
  //
1197
753
  // TODO(davidben): Expose this as part of public API once the high-level
1198
754
  // buffer-free APIs are available.
1199
- size_t ssl_record_prefix_len(const SSL *ssl);
755
+ size_t ssl_record_prefix_len(const SSLImpl *ssl);
1200
756
 
1201
757
  enum ssl_open_record_t {
1202
758
  ssl_open_record_success,
@@ -1206,106 +762,108 @@ enum ssl_open_record_t {
1206
762
  ssl_open_record_error,
1207
763
  };
1208
764
 
1209
- // tls_open_record decrypts a record from |in| in-place.
765
+ // tls_open_record decrypts a record from `in` in-place.
1210
766
  //
1211
767
  // If the input did not contain a complete record, it returns
1212
- // |ssl_open_record_partial|. It sets |*out_consumed| to the total number of
1213
- // bytes necessary. It is guaranteed that a successful call to |tls_open_record|
768
+ // `ssl_open_record_partial`. It sets `*out_consumed` to the total number of
769
+ // bytes necessary. It is guaranteed that a successful call to `tls_open_record`
1214
770
  // will consume at least that many bytes.
1215
771
  //
1216
- // Otherwise, it sets |*out_consumed| to the number of bytes of input
772
+ // Otherwise, it sets `*out_consumed` to the number of bytes of input
1217
773
  // consumed. Note that input may be consumed on all return codes if a record was
1218
774
  // decrypted.
1219
775
  //
1220
- // On success, it returns |ssl_open_record_success|. It sets |*out_type| to the
1221
- // record type and |*out| to the record body in |in|. Note that |*out| may be
776
+ // On success, it returns `ssl_open_record_success`. It sets `*out_type` to the
777
+ // record type and `*out` to the record body in `in`. Note that `*out` may be
1222
778
  // empty.
1223
779
  //
1224
780
  // If a record was successfully processed but should be discarded, it returns
1225
- // |ssl_open_record_discard|.
781
+ // `ssl_open_record_discard`.
1226
782
  //
1227
783
  // If a record was successfully processed but is a close_notify, it returns
1228
- // |ssl_open_record_close_notify|.
784
+ // `ssl_open_record_close_notify`.
1229
785
  //
1230
- // On failure or fatal alert, it returns |ssl_open_record_error| and sets
1231
- // |*out_alert| to an alert to emit, or zero if no alert should be emitted.
1232
- enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type,
786
+ // On failure or fatal alert, it returns `ssl_open_record_error` and sets
787
+ // `*out_alert` to an alert to emit, or zero if no alert should be emitted.
788
+ enum ssl_open_record_t tls_open_record(SSLImpl *ssl, uint8_t *out_type,
1233
789
  Span<uint8_t> *out, size_t *out_consumed,
1234
790
  uint8_t *out_alert, Span<uint8_t> in);
1235
791
 
1236
- // dtls_open_record implements |tls_open_record| for DTLS. It only returns
1237
- // |ssl_open_record_partial| if |in| was empty and sets |*out_consumed| to
792
+ // dtls_open_record implements `tls_open_record` for DTLS. It only returns
793
+ // `ssl_open_record_partial` if `in` was empty and sets `*out_consumed` to
1238
794
  // zero. The caller should read one packet and try again. On success,
1239
- // |*out_number| is set to the record number of the record.
1240
- enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
795
+ // `*out_number` is set to the record number of the record.
796
+ enum ssl_open_record_t dtls_open_record(SSLImpl *ssl, uint8_t *out_type,
1241
797
  DTLSRecordNumber *out_number,
1242
798
  Span<uint8_t> *out,
1243
799
  size_t *out_consumed,
1244
800
  uint8_t *out_alert, Span<uint8_t> in);
1245
801
 
1246
- // ssl_needs_record_splitting returns one if |ssl|'s current outgoing cipher
802
+ // ssl_needs_record_splitting returns one if `ssl`'s current outgoing cipher
1247
803
  // state needs record-splitting and zero otherwise.
1248
- bool ssl_needs_record_splitting(const SSL *ssl);
804
+ bool ssl_needs_record_splitting(const SSLImpl *ssl);
1249
805
 
1250
- // tls_seal_record seals a new record of type |type| and body |in| and writes it
1251
- // to |out|. At most |max_out| bytes will be written. It returns true on success
1252
- // and false on error. If enabled, |tls_seal_record| implements TLS 1.0 CBC
806
+ // tls_seal_record seals a new record of type `type` and body `in` and writes it
807
+ // to `out`. At most `max_out` bytes will be written. It returns true on success
808
+ // and false on error. If enabled, `tls_seal_record` implements TLS 1.0 CBC
1253
809
  // 1/n-1 record splitting and may write two records concatenated.
1254
810
  //
1255
811
  // For a large record, the bulk of the ciphertext will begin
1256
- // |tls_seal_align_prefix_len| bytes into out. Aligning |out| appropriately may
1257
- // improve performance. It writes at most |in_len| + |SSL_max_seal_overhead|
1258
- // bytes to |out|.
812
+ // `tls_seal_align_prefix_len` bytes into out. Aligning `out` appropriately may
813
+ // improve performance. It writes at most `in_len` + `SSL_max_seal_overhead`
814
+ // bytes to `out`.
1259
815
  //
1260
- // |in| and |out| may not alias.
1261
- bool tls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
1262
- uint8_t type, const uint8_t *in, size_t in_len);
816
+ // `in` and `out` may not alias.
817
+ bool tls_seal_record(SSLImpl *ssl, uint8_t *out, size_t *out_len,
818
+ size_t max_out, uint8_t type, const uint8_t *in,
819
+ size_t in_len);
1263
820
 
1264
821
  // dtls_record_header_write_len returns the length of the record header that
1265
- // will be written at |epoch|.
1266
- size_t dtls_record_header_write_len(const SSL *ssl, uint16_t epoch);
822
+ // will be written at `epoch`.
823
+ size_t dtls_record_header_write_len(const SSLImpl *ssl, uint16_t epoch);
1267
824
 
1268
825
  // dtls_max_seal_overhead returns the maximum overhead, in bytes, of sealing a
1269
826
  // record.
1270
- size_t dtls_max_seal_overhead(const SSL *ssl, uint16_t epoch);
827
+ size_t dtls_max_seal_overhead(const SSLImpl *ssl, uint16_t epoch);
1271
828
 
1272
829
  // dtls_seal_prefix_len returns the number of bytes of prefix to reserve in
1273
830
  // front of the plaintext when sealing a record in-place.
1274
- size_t dtls_seal_prefix_len(const SSL *ssl, uint16_t epoch);
831
+ size_t dtls_seal_prefix_len(const SSLImpl *ssl, uint16_t epoch);
1275
832
 
1276
833
  // dtls_seal_max_input_len returns the maximum number of input bytes that can
1277
- // fit in a record of up to |max_out| bytes, or zero if none may fit.
1278
- size_t dtls_seal_max_input_len(const SSL *ssl, uint16_t epoch, size_t max_out);
834
+ // fit in a record of up to `max_out` bytes, or zero if none may fit.
835
+ size_t dtls_seal_max_input_len(const SSLImpl *ssl, uint16_t epoch,
836
+ size_t max_out);
1279
837
 
1280
838
  // dtls_get_read_epoch and dtls_get_write_epoch return the epoch corresponding
1281
- // to |epoch| or nullptr if there is none.
1282
- DTLSReadEpoch *dtls_get_read_epoch(const SSL *ssl, uint16_t epoch);
1283
- DTLSWriteEpoch *dtls_get_write_epoch(const SSL *ssl, uint16_t epoch);
1284
-
1285
- // dtls_seal_record implements |tls_seal_record| for DTLS. |epoch| selects which
1286
- // epoch's cipher state to use. Unlike |tls_seal_record|, |in| and |out| may
1287
- // alias but, if they do, |in| must be exactly |dtls_seal_prefix_len| bytes
1288
- // ahead of |out|. On success, |*out_number| is set to the record number of the
839
+ // to `epoch` or nullptr if there is none.
840
+ DTLSReadEpoch *dtls_get_read_epoch(const SSLImpl *ssl, uint16_t epoch);
841
+ DTLSWriteEpoch *dtls_get_write_epoch(const SSLImpl *ssl, uint16_t epoch);
842
+
843
+ // dtls_seal_record implements `tls_seal_record` for DTLS. `epoch` selects which
844
+ // epoch's cipher state to use. Unlike `tls_seal_record`, `in` and `out` may
845
+ // alias but, if they do, `in` must be exactly `dtls_seal_prefix_len` bytes
846
+ // ahead of `out`. On success, `*out_number` is set to the record number of the
1289
847
  // record.
1290
- bool dtls_seal_record(SSL *ssl, DTLSRecordNumber *out_number, uint8_t *out,
848
+ bool dtls_seal_record(SSLImpl *ssl, DTLSRecordNumber *out_number, uint8_t *out,
1291
849
  size_t *out_len, size_t max_out, uint8_t type,
1292
850
  const uint8_t *in, size_t in_len, uint16_t epoch);
1293
851
 
1294
- // ssl_process_alert processes |in| as an alert and updates |ssl|'s shutdown
1295
- // state. It returns one of |ssl_open_record_discard|, |ssl_open_record_error|,
1296
- // |ssl_open_record_close_notify|, or |ssl_open_record_fatal_alert| as
852
+ // ssl_process_alert processes `in` as an alert and updates `ssl`'s shutdown
853
+ // state. It returns one of `ssl_open_record_discard`, `ssl_open_record_error`,
854
+ // `ssl_open_record_close_notify`, or `ssl_open_record_fatal_alert` as
1297
855
  // appropriate.
1298
- enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert,
856
+ enum ssl_open_record_t ssl_process_alert(SSLImpl *ssl, uint8_t *out_alert,
1299
857
  Span<const uint8_t> in);
1300
858
 
1301
859
 
1302
860
  // Private key operations.
1303
861
 
1304
862
  // ssl_private_key_* perform the corresponding operation on
1305
- // |SSL_PRIVATE_KEY_METHOD|. If there is a custom private key configured, they
1306
- // call the corresponding function or |complete| depending on whether there is a
863
+ // `SSL_PRIVATE_KEY_METHOD`. If there is a custom private key configured, they
864
+ // call the corresponding function or `complete` depending on whether there is a
1307
865
  // pending operation. Otherwise, they implement the operation with
1308
- // |EVP_PKEY|.
866
+ // `EVP_PKEY`.
1309
867
 
1310
868
  enum ssl_private_key_result_t ssl_private_key_sign(
1311
869
  SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
@@ -1317,14 +875,20 @@ enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
1317
875
  size_t max_out,
1318
876
  Span<const uint8_t> in);
1319
877
 
1320
- // ssl_pkey_supports_algorithm returns whether |pkey| may be used to sign
1321
- // |sigalg|.
1322
- bool ssl_pkey_supports_algorithm(const SSL *ssl, EVP_PKEY *pkey,
878
+ // ssl_parse_peer_subject_public_key_info decodes a SubjectPublicKeyInfo
879
+ // representing the peer TLS key. It returns a newly-allocated `EVP_PKEY` or
880
+ // nullptr on error.
881
+ UniquePtr<EVP_PKEY> ssl_parse_peer_subject_public_key_info(
882
+ Span<const uint8_t> spki);
883
+
884
+ // ssl_pkey_supports_algorithm returns whether `pkey` may be used to sign
885
+ // `sigalg`.
886
+ bool ssl_pkey_supports_algorithm(const SSLImpl *ssl, EVP_PKEY *pkey,
1323
887
  uint16_t sigalg, bool is_verify);
1324
888
 
1325
- // ssl_public_key_verify verifies that the |signature| is valid for the public
1326
- // key |pkey| and input |in|, using the signature algorithm |sigalg|.
1327
- bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature,
889
+ // ssl_public_key_verify verifies that the `signature` is valid for the public
890
+ // key `pkey` and input `in`, using the signature algorithm `sigalg`.
891
+ bool ssl_public_key_verify(SSLImpl *ssl, Span<const uint8_t> signature,
1328
892
  uint16_t sigalg, EVP_PKEY *pkey,
1329
893
  Span<const uint8_t> in);
1330
894
 
@@ -1345,35 +909,35 @@ class SSLKeyShare {
1345
909
  virtual ~SSLKeyShare() {}
1346
910
  static constexpr bool kAllowUniquePtr = true;
1347
911
 
1348
- // Create returns a SSLKeyShare instance for use with group |group_id| or
912
+ // Create returns a SSLKeyShare instance for use with group `group_id` or
1349
913
  // nullptr on error.
1350
914
  static UniquePtr<SSLKeyShare> Create(uint16_t group_id);
1351
915
 
1352
916
  // GroupID returns the group ID.
1353
917
  virtual uint16_t GroupID() const = 0;
1354
918
 
1355
- // Generate generates a keypair and writes the public key to |out_public_key|.
919
+ // Generate generates a keypair and writes the public key to `out_public_key`.
1356
920
  // It returns true on success and false on error.
1357
921
  virtual bool Generate(CBB *out_public_key) = 0;
1358
922
 
1359
923
  // Encap generates an ephemeral, symmetric secret and encapsulates it with
1360
- // |peer_key|. On success, it returns true, writes the encapsulated secret to
1361
- // |out_ciphertext|, and sets |*out_secret| to the shared secret. On failure,
1362
- // it returns false and sets |*out_alert| to an alert to send to the peer.
924
+ // `peer_key`. On success, it returns true, writes the encapsulated secret to
925
+ // `out_ciphertext`, and sets `*out_secret` to the shared secret. On failure,
926
+ // it returns false and sets `*out_alert` to an alert to send to the peer.
1363
927
  virtual bool Encap(CBB *out_ciphertext, Array<uint8_t> *out_secret,
1364
928
  uint8_t *out_alert, Span<const uint8_t> peer_key) = 0;
1365
929
 
1366
- // Decap decapsulates the symmetric secret in |ciphertext|. On success, it
1367
- // returns true and sets |*out_secret| to the shared secret. On failure, it
1368
- // returns false and sets |*out_alert| to an alert to send to the peer.
930
+ // Decap decapsulates the symmetric secret in `ciphertext`. On success, it
931
+ // returns true and sets `*out_secret` to the shared secret. On failure, it
932
+ // returns false and sets `*out_alert` to an alert to send to the peer.
1369
933
  virtual bool Decap(Array<uint8_t> *out_secret, uint8_t *out_alert,
1370
934
  Span<const uint8_t> ciphertext) = 0;
1371
935
 
1372
- // SerializePrivateKey writes the private key to |out|, returning true if
1373
- // successful and false otherwise. It should be called after |Generate|.
936
+ // SerializePrivateKey writes the private key to `out`, returning true if
937
+ // successful and false otherwise. It should be called after `Generate`.
1374
938
  virtual bool SerializePrivateKey(CBB *out) { return false; }
1375
939
 
1376
- // DeserializePrivateKey initializes the state of the key exchange from |in|,
940
+ // DeserializePrivateKey initializes the state of the key exchange from `in`,
1377
941
  // returning true if successful and false otherwise.
1378
942
  virtual bool DeserializePrivateKey(CBS *in) { return false; }
1379
943
  };
@@ -1387,18 +951,25 @@ struct NamedGroup {
1387
951
  // NamedGroups returns all supported groups.
1388
952
  Span<const NamedGroup> NamedGroups();
1389
953
 
1390
- // ssl_nid_to_group_id looks up the group corresponding to |nid|. On success, it
1391
- // sets |*out_group_id| to the group ID and returns true. Otherwise, it returns
954
+ // kNumNamedGroups is the number of supported groups.
955
+ constexpr size_t kNumNamedGroups = 6u;
956
+
957
+ // DefaultSupportedGroupIds returns the list of IDs for the default groups that
958
+ // are supported when the caller hasn't explicitly configured supported groups.
959
+ Span<const uint16_t> DefaultSupportedGroupIds();
960
+
961
+ // ssl_nid_to_group_id looks up the group corresponding to `nid`. On success, it
962
+ // sets `*out_group_id` to the group ID and returns true. Otherwise, it returns
1392
963
  // false.
1393
964
  bool ssl_nid_to_group_id(uint16_t *out_group_id, int nid);
1394
965
 
1395
- // ssl_name_to_group_id looks up the group corresponding to the |name| string of
1396
- // length |len|. On success, it sets |*out_group_id| to the group ID and returns
966
+ // ssl_name_to_group_id looks up the group corresponding to the `name` string of
967
+ // length `len`. On success, it sets `*out_group_id` to the group ID and returns
1397
968
  // true. Otherwise, it returns false.
1398
969
  bool ssl_name_to_group_id(uint16_t *out_group_id, const char *name, size_t len);
1399
970
 
1400
- // ssl_group_id_to_nid returns the NID corresponding to |group_id| or
1401
- // |NID_undef| if unknown.
971
+ // ssl_group_id_to_nid returns the NID corresponding to `group_id` or
972
+ // `NID_undef` if unknown.
1402
973
  int ssl_group_id_to_nid(uint16_t group_id);
1403
974
 
1404
975
 
@@ -1425,43 +996,43 @@ extern const uint8_t kTLS13DowngradeRandom[8];
1425
996
  extern const uint8_t kJDK11DowngradeRandom[8];
1426
997
 
1427
998
  // ssl_max_handshake_message_len returns the maximum number of bytes permitted
1428
- // in a handshake message for |ssl|.
1429
- size_t ssl_max_handshake_message_len(const SSL *ssl);
999
+ // in a handshake message for `ssl`.
1000
+ size_t ssl_max_handshake_message_len(const SSLImpl *ssl);
1430
1001
 
1431
- // tls_can_accept_handshake_data returns whether |ssl| is able to accept more
1002
+ // tls_can_accept_handshake_data returns whether `ssl` is able to accept more
1432
1003
  // data into handshake buffer.
1433
- bool tls_can_accept_handshake_data(const SSL *ssl, uint8_t *out_alert);
1004
+ bool tls_can_accept_handshake_data(const SSLImpl *ssl, uint8_t *out_alert);
1434
1005
 
1435
1006
  // tls_has_unprocessed_handshake_data returns whether there is buffered
1436
- // handshake data that has not been consumed by |get_message|.
1437
- bool tls_has_unprocessed_handshake_data(const SSL *ssl);
1007
+ // handshake data that has not been consumed by `get_message`.
1008
+ bool tls_has_unprocessed_handshake_data(const SSLImpl *ssl);
1438
1009
 
1439
- // tls_append_handshake_data appends |data| to the handshake buffer. It returns
1010
+ // tls_append_handshake_data appends `data` to the handshake buffer. It returns
1440
1011
  // true on success and false on allocation failure.
1441
- bool tls_append_handshake_data(SSL *ssl, Span<const uint8_t> data);
1012
+ bool tls_append_handshake_data(SSLImpl *ssl, Span<const uint8_t> data);
1442
1013
 
1443
1014
  // dtls_has_unprocessed_handshake_data behaves like
1444
- // |tls_has_unprocessed_handshake_data| for DTLS.
1445
- bool dtls_has_unprocessed_handshake_data(const SSL *ssl);
1015
+ // `tls_has_unprocessed_handshake_data` for DTLS.
1016
+ bool dtls_has_unprocessed_handshake_data(const SSLImpl *ssl);
1446
1017
 
1447
1018
  // tls_flush_pending_hs_data flushes any handshake plaintext data.
1448
- bool tls_flush_pending_hs_data(SSL *ssl);
1019
+ bool tls_flush_pending_hs_data(SSLImpl *ssl);
1449
1020
 
1450
1021
  // dtls_clear_outgoing_messages releases all buffered outgoing messages.
1451
- void dtls_clear_outgoing_messages(SSL *ssl);
1022
+ void dtls_clear_outgoing_messages(SSLImpl *ssl);
1452
1023
 
1453
1024
  // dtls_clear_unused_write_epochs releases any write epochs that are no longer
1454
1025
  // needed.
1455
- void dtls_clear_unused_write_epochs(SSL *ssl);
1026
+ void dtls_clear_unused_write_epochs(SSLImpl *ssl);
1456
1027
 
1457
1028
 
1458
1029
  // Callbacks.
1459
1030
 
1460
- // ssl_do_info_callback calls |ssl|'s info callback, if set.
1461
- void ssl_do_info_callback(const SSL *ssl, int type, int value);
1031
+ // ssl_do_info_callback calls `ssl`'s info callback, if set.
1032
+ void ssl_do_info_callback(const SSLImpl *ssl, int type, int value);
1462
1033
 
1463
- // ssl_do_msg_callback calls |ssl|'s message callback, if set.
1464
- void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type,
1034
+ // ssl_do_msg_callback calls `ssl`'s message callback, if set.
1035
+ void ssl_do_msg_callback(const SSLImpl *ssl, int is_write, int content_type,
1465
1036
  Span<const uint8_t> in);
1466
1037
 
1467
1038
 
@@ -1487,19 +1058,19 @@ class SSLBuffer {
1487
1058
  // Clear releases the buffer.
1488
1059
  void Clear();
1489
1060
 
1490
- // EnsureCap ensures the buffer has capacity at least |new_cap|, aligned such
1491
- // that data written after |header_len| is aligned to a
1492
- // |SSL3_ALIGN_PAYLOAD|-byte boundary. It returns true on success and false
1061
+ // EnsureCap ensures the buffer has capacity at least `new_cap`, aligned such
1062
+ // that data written after `header_len` is aligned to a
1063
+ // `SSL3_ALIGN_PAYLOAD`-byte boundary. It returns true on success and false
1493
1064
  // on error.
1494
1065
  bool EnsureCap(size_t header_len, size_t new_cap);
1495
1066
 
1496
- // DidWrite extends the buffer by |len|. The caller must have filled in to
1067
+ // DidWrite extends the buffer by `len`. The caller must have filled in to
1497
1068
  // this point.
1498
1069
  void DidWrite(size_t len);
1499
1070
 
1500
- // Consume consumes |len| bytes from the front of the buffer. The memory
1501
- // consumed will remain valid until the next call to |DiscardConsumed| or
1502
- // |Clear|.
1071
+ // Consume consumes `len` bytes from the front of the buffer. The memory
1072
+ // consumed will remain valid until the next call to `DiscardConsumed` or
1073
+ // `Clear`.
1503
1074
  void Consume(size_t len);
1504
1075
 
1505
1076
  // DiscardConsumed discards the consumed bytes from the buffer. If the buffer
@@ -1509,96 +1080,107 @@ class SSLBuffer {
1509
1080
  private:
1510
1081
  // buf_ is the memory allocated for this buffer.
1511
1082
  uint8_t *buf_ = nullptr;
1512
- // offset_ is the offset into |buf_| which the buffer contents start at.
1083
+ // offset_ is the offset into `buf_` which the buffer contents start at.
1513
1084
  uint16_t offset_ = 0;
1514
- // size_ is the size of the buffer contents from |buf_| + |offset_|.
1085
+ // size_ is the size of the buffer contents from `buf_` + `offset_`.
1515
1086
  uint16_t size_ = 0;
1516
- // cap_ is how much memory beyond |buf_| + |offset_| is available.
1087
+ // cap_ is how much memory beyond `buf_` + `offset_` is available.
1517
1088
  uint16_t cap_ = 0;
1518
1089
  // inline_buf_ is a static buffer for short reads.
1519
1090
  uint8_t inline_buf_[SSL3_RT_HEADER_LENGTH];
1520
1091
  };
1521
1092
 
1522
1093
  // 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 |len| bytes
1524
- // long. For DTLS, it reads a new packet and ignores |len|. It returns one on
1094
+ // TLS, it reads to the end of the buffer until the buffer is `len` bytes
1095
+ // long. For DTLS, it reads a new packet and ignores `len`. It returns one on
1525
1096
  // success, zero on EOF, and a negative number on error.
1526
1097
  //
1527
- // It is an error to call |ssl_read_buffer_extend_to| in DTLS when the buffer is
1098
+ // It is an error to call `ssl_read_buffer_extend_to` in DTLS when the buffer is
1528
1099
  // non-empty.
1529
- int ssl_read_buffer_extend_to(SSL *ssl, size_t len);
1100
+ int ssl_read_buffer_extend_to(SSLImpl *ssl, size_t len);
1530
1101
 
1531
- // ssl_handle_open_record handles the result of passing |ssl->s3->read_buffer|
1532
- // to a record-processing function. If |ret| is a success or if the caller
1533
- // should retry, it returns one and sets |*out_retry|. Otherwise, it returns <=
1102
+ // ssl_handle_open_record handles the result of passing `ssl->s3->read_buffer`
1103
+ // to a record-processing function. If `ret` is a success or if the caller
1104
+ // should retry, it returns one and sets `*out_retry`. Otherwise, it returns <=
1534
1105
  // 0.
1535
- int ssl_handle_open_record(SSL *ssl, bool *out_retry, ssl_open_record_t ret,
1106
+ int ssl_handle_open_record(SSLImpl *ssl, bool *out_retry, ssl_open_record_t ret,
1536
1107
  size_t consumed, uint8_t alert);
1537
1108
 
1538
1109
  // ssl_write_buffer_flush flushes the write buffer to the transport. It returns
1539
1110
  // one on success and <= 0 on error. For DTLS, whether or not the write
1540
1111
  // succeeds, the write buffer will be cleared.
1541
- int ssl_write_buffer_flush(SSL *ssl);
1112
+ int ssl_write_buffer_flush(SSLImpl *ssl);
1542
1113
 
1543
1114
 
1544
1115
  // Certificate functions.
1545
1116
 
1546
- // ssl_parse_cert_chain parses a certificate list from |cbs| in the format used
1547
- // by a TLS Certificate message. On success, it advances |cbs| and returns
1548
- // true. Otherwise, it returns false and sets |*out_alert| to an alert to send
1117
+ // ssl_parse_cert_chain parses a certificate list from `cbs` in the format used
1118
+ // by a TLS Certificate message. On success, it advances `cbs` and returns
1119
+ // true. Otherwise, it returns false and sets `*out_alert` to an alert to send
1549
1120
  // to the peer.
1550
1121
  //
1551
- // If the list is non-empty then |*out_chain| and |*out_pubkey| will be set to
1122
+ // If the list is non-empty then `*out_chain` and `*out_pubkey` will be set to
1552
1123
  // the certificate chain and the leaf certificate's public key
1553
1124
  // respectively. Otherwise, both will be set to nullptr.
1554
1125
  //
1555
- // If the list is non-empty and |out_leaf_sha256| is non-NULL, it writes the
1556
- // SHA-256 hash of the leaf to |out_leaf_sha256|.
1126
+ // If the list is non-empty and `out_leaf_sha256` is non-NULL, it writes the
1127
+ // SHA-256 hash of the leaf to `out_leaf_sha256`.
1557
1128
  bool ssl_parse_cert_chain(uint8_t *out_alert,
1558
1129
  UniquePtr<STACK_OF(CRYPTO_BUFFER)> *out_chain,
1559
1130
  UniquePtr<EVP_PKEY> *out_pubkey,
1560
1131
  uint8_t *out_leaf_sha256, CBS *cbs,
1561
1132
  CRYPTO_BUFFER_POOL *pool);
1562
1133
 
1134
+ // ssl_parse_rpk_cert parses a RawPublicKey certificate from `cbs` in the format
1135
+ // used by a TLS 1.2 Certificate message (RFC 7250). On success, it advances
1136
+ // `cbs` and returns true, and sets `*out_raw_public_key` to the parsed key, and
1137
+ // sets `*out_pubkey` to the same key by incrementing the reference count, and
1138
+ // if `out_rpk_sha256` is non-NULL, it writes the SHA-256 hash of the RPK to
1139
+ // `out_rpk_sha256`. Otherwise, it returns false and sets `*out_alert` to an
1140
+ // alert to send to the peer.
1141
+ bool ssl_parse_rpk_cert(uint8_t *out_alert,
1142
+ UniquePtr<EVP_PKEY> *out_raw_public_key,
1143
+ UniquePtr<EVP_PKEY> *out_pubkey,
1144
+ uint8_t *out_rpk_sha256, CBS *cbs);
1145
+
1563
1146
  enum ssl_key_usage_t {
1564
1147
  key_usage_digital_signature = 0,
1565
1148
  key_usage_encipherment = 2,
1566
1149
  };
1567
1150
 
1568
- // ssl_cert_check_key_usage parses the DER-encoded, X.509 certificate in |in|
1151
+ // ssl_cert_check_key_usage parses the DER-encoded, X.509 certificate in `in`
1569
1152
  // and returns true if doesn't specify a key usage or, if it does, if it
1570
- // includes |bit|. Otherwise it pushes to the error queue and returns false.
1571
- OPENSSL_EXPORT bool ssl_cert_check_key_usage(const CBS *in,
1572
- enum ssl_key_usage_t bit);
1153
+ // includes `bit`. Otherwise it pushes to the error queue and returns false.
1154
+ bool ssl_cert_check_key_usage(const CBS *in, enum ssl_key_usage_t bit);
1573
1155
 
1574
- // ssl_cert_extract_issuer parses the DER-encoded, X.509 certificate in |in|
1156
+ // ssl_cert_extract_issuer parses the DER-encoded, X.509 certificate in `in`
1575
1157
  // and extracts the issuer. On success it returns true and the DER encoded
1576
- // issuer is in |out_dn|, otherwise it returns false.
1577
- OPENSSL_EXPORT bool ssl_cert_extract_issuer(const CBS *in, CBS *out_dn);
1158
+ // issuer is in `out_dn`, otherwise it returns false.
1159
+ bool ssl_cert_extract_issuer(const CBS *in, CBS *out_dn);
1578
1160
 
1579
- // ssl_cert_matches_issuer parses the DER-encoded, X.509 certificate in |in|
1161
+ // ssl_cert_matches_issuer parses the DER-encoded, X.509 certificate in `in`
1580
1162
  // and returns true if its issuer is an exact match for the DER encoded
1581
- // distinguished name in |dn|
1163
+ // distinguished name in `dn`
1582
1164
  bool ssl_cert_matches_issuer(const CBS *in, const CBS *dn);
1583
1165
 
1584
1166
  // ssl_cert_parse_pubkey extracts the public key from the DER-encoded, X.509
1585
- // certificate in |in|. It returns an allocated |EVP_PKEY| or else returns
1167
+ // certificate in `in`. It returns an allocated `EVP_PKEY` or else returns
1586
1168
  // nullptr and pushes to the error queue.
1587
1169
  UniquePtr<EVP_PKEY> ssl_cert_parse_pubkey(const CBS *in);
1588
1170
 
1589
- // SSL_parse_CA_list parses a CA list from |cbs| in the format used by a TLS
1171
+ // SSL_parse_CA_list parses a CA list from `cbs` in the format used by a TLS
1590
1172
  // CertificateRequest message and Certificate Authorities extension. On success,
1591
- // it returns a newly-allocated |CRYPTO_BUFFER| list and advances
1592
- // |cbs|. Otherwise, it returns nullptr and sets |*out_alert| to an alert to
1173
+ // it returns a newly-allocated `CRYPTO_BUFFER` list and advances
1174
+ // `cbs`. Otherwise, it returns nullptr and sets `*out_alert` to an alert to
1593
1175
  // send to the peer.
1594
- UniquePtr<STACK_OF(CRYPTO_BUFFER)> SSL_parse_CA_list(SSL *ssl,
1176
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> SSL_parse_CA_list(SSLImpl *ssl,
1595
1177
  uint8_t *out_alert,
1596
1178
  CBS *cbs);
1597
1179
 
1598
1180
  // ssl_has_client_CAs returns whether there are configured CAs.
1599
1181
  bool ssl_has_client_CAs(const SSL_CONFIG *cfg);
1600
1182
 
1601
- // ssl_add_client_CA_list adds the configured CA list to |cbb| in the format
1183
+ // ssl_add_client_CA_list adds the configured CA list to `cbb` in the format
1602
1184
  // used by a TLS CertificateRequest message. It returns true on success and
1603
1185
  // false on error.
1604
1186
  bool ssl_add_client_CA_list(const SSL_HANDSHAKE *hs, CBB *cbb);
@@ -1606,13 +1188,13 @@ bool ssl_add_client_CA_list(const SSL_HANDSHAKE *hs, CBB *cbb);
1606
1188
  // ssl_has_CA_names returns whether there are configured CA names.
1607
1189
  bool ssl_has_CA_names(const SSL_CONFIG *cfg);
1608
1190
 
1609
- // ssl_add_CA_names adds the configured CA_names list to |cbb| in the format
1191
+ // ssl_add_CA_names adds the configured CA_names list to `cbb` in the format
1610
1192
  // used by a TLS Certificate Authorities extension. It returns true on success
1611
1193
  // and false on error.
1612
1194
  bool ssl_add_CA_names(const SSL_HANDSHAKE *hs, CBB *cbb);
1613
1195
 
1614
- // ssl_check_leaf_certificate returns one if |pkey| and |leaf| are suitable as
1615
- // a server's leaf certificate for |hs|. Otherwise, it returns zero and pushes
1196
+ // ssl_check_leaf_certificate returns one if `pkey` and `leaf` are suitable as
1197
+ // a server's leaf certificate for `hs`. Otherwise, it returns zero and pushes
1616
1198
  // an error on the error queue.
1617
1199
  bool ssl_check_leaf_certificate(SSL_HANDSHAKE *hs, EVP_PKEY *pkey,
1618
1200
  const CRYPTO_BUFFER *leaf);
@@ -1626,21 +1208,21 @@ bool ssl_check_leaf_certificate(SSL_HANDSHAKE *hs, EVP_PKEY *pkey,
1626
1208
  bool tls13_init_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> psk);
1627
1209
 
1628
1210
  // tls13_init_early_key_schedule initializes the handshake hash and key
1629
- // derivation state from |session| for use with 0-RTT. It returns one on success
1211
+ // derivation state from `session` for use with 0-RTT. It returns one on success
1630
1212
  // and zero on error.
1631
1213
  bool tls13_init_early_key_schedule(SSL_HANDSHAKE *hs,
1632
- const SSL_SESSION *session);
1214
+ const SSLSession *session);
1633
1215
 
1634
- // tls13_advance_key_schedule incorporates |in| into the key schedule with
1216
+ // tls13_advance_key_schedule incorporates `in` into the key schedule with
1635
1217
  // HKDF-Extract. It returns true on success and false on error.
1636
1218
  bool tls13_advance_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> in);
1637
1219
 
1638
1220
  // tls13_set_traffic_key sets the read or write traffic keys to
1639
- // |traffic_secret|. The version and cipher suite are determined from |session|.
1221
+ // `traffic_secret`. The version and cipher suite are determined from `session`.
1640
1222
  // It returns true on success and false on error.
1641
- bool tls13_set_traffic_key(SSL *ssl, enum ssl_encryption_level_t level,
1223
+ bool tls13_set_traffic_key(SSLImpl *ssl, enum ssl_encryption_level_t level,
1642
1224
  enum evp_aead_direction_t direction,
1643
- const SSL_SESSION *session,
1225
+ const SSLSession *session,
1644
1226
  Span<const uint8_t> traffic_secret);
1645
1227
 
1646
1228
  // tls13_derive_early_secret derives the early traffic secret. It returns true
@@ -1653,50 +1235,85 @@ bool tls13_derive_handshake_secrets(SSL_HANDSHAKE *hs);
1653
1235
 
1654
1236
  // tls13_rotate_traffic_key derives the next read or write traffic secret. It
1655
1237
  // returns true on success and false on error.
1656
- bool tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction);
1238
+ bool tls13_rotate_traffic_key(SSLImpl *ssl,
1239
+ enum evp_aead_direction_t direction);
1657
1240
 
1658
1241
  // tls13_derive_application_secrets derives the initial application data traffic
1659
- // and exporter secrets based on the handshake transcripts and |master_secret|.
1242
+ // and exporter secrets based on the handshake transcripts and `master_secret`.
1660
1243
  // It returns true on success and false on error.
1661
1244
  bool tls13_derive_application_secrets(SSL_HANDSHAKE *hs);
1662
1245
 
1663
- // tls13_derive_resumption_secret derives the |resumption_secret|.
1246
+ // tls13_derive_resumption_secret derives the `resumption_secret`.
1664
1247
  bool tls13_derive_resumption_secret(SSL_HANDSHAKE *hs);
1665
1248
 
1666
1249
  // tls13_export_keying_material provides an exporter interface to use the
1667
- // |exporter_secret|.
1668
- bool tls13_export_keying_material(const SSL *ssl, Span<uint8_t> out,
1250
+ // `exporter_secret`.
1251
+ bool tls13_export_keying_material(const SSLImpl *ssl, Span<uint8_t> out,
1669
1252
  Span<const uint8_t> secret,
1670
1253
  std::string_view label,
1671
1254
  Span<const uint8_t> context);
1672
1255
 
1673
1256
  // tls13_finished_mac calculates the MAC of the handshake transcript to verify
1674
- // the integrity of the Finished message, and stores the result in |out| and
1675
- // length in |out_len|. |is_server| is true if this is for the Server Finished
1257
+ // the integrity of the Finished message, and stores the result in `out` and
1258
+ // length in `out_len`. `is_server` is true if this is for the Server Finished
1676
1259
  // and false for the Client Finished.
1677
1260
  bool tls13_finished_mac(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len,
1678
1261
  bool is_server);
1679
1262
 
1680
1263
  // tls13_derive_session_psk calculates the PSK for this session based on the
1681
- // resumption master secret and |nonce|. It returns true on success, and false
1264
+ // resumption master secret and `nonce`. It returns true on success, and false
1682
1265
  // on failure.
1683
- bool tls13_derive_session_psk(SSL_SESSION *session, Span<const uint8_t> nonce,
1266
+ bool tls13_derive_session_psk(SSLSession *session, Span<const uint8_t> nonce,
1684
1267
  bool is_dtls);
1685
1268
 
1686
- // tls13_write_psk_binder calculates the PSK binder value over |transcript| and
1687
- // |msg|, and replaces the last bytes of |msg| with the resulting value. It
1688
- // returns true on success, and false on failure. If |out_binder_len| is
1689
- // non-NULL, it sets |*out_binder_len| to the length of the value computed.
1690
- bool tls13_write_psk_binder(const SSL_HANDSHAKE *hs,
1691
- const SSLTranscript &transcript, Span<uint8_t> msg,
1692
- size_t *out_binder_len);
1269
+ struct SSLImportedPSK {
1270
+ static constexpr bool kAllowUniquePtr = true;
1271
+ UniquePtr<SSLCredential> credential;
1272
+ Array<uint8_t> imported_identity;
1273
+ InplaceVector<uint8_t, SSL_MAX_MD_SIZE> ipskx;
1274
+ uint16_t protocol = 0;
1275
+ const EVP_MD *md = nullptr;
1276
+ };
1693
1277
 
1694
- // tls13_verify_psk_binder verifies that the handshake transcript, truncated up
1695
- // to the binders has a valid signature using the value of |session|'s
1696
- // resumption secret. It returns true on success, and false on failure.
1697
- bool tls13_verify_psk_binder(const SSL_HANDSHAKE *hs,
1698
- const SSL_SESSION *session, const SSLMessage &msg,
1699
- CBS *binders);
1278
+ // tls13_derive_imported_psk computes the imported PSK value for `cred`, which
1279
+ // must be an PSK credential, for use with a target KDF of HKDF with `hkdf_md`.
1280
+ // `protocol` should be the wire version (i.e. `TLS1_3_VERSION` or
1281
+ // `DTLS1_3_VERSION`) of the target protocol. It returns the imported PSK on
1282
+ // success and std::nullopt on error.
1283
+ std::optional<SSLImportedPSK> tls13_derive_imported_psk(const SSL_HANDSHAKE *hs,
1284
+ SSLCredential *cred,
1285
+ uint16_t protocol,
1286
+ const EVP_MD *hkdf_md);
1287
+
1288
+ // tls13_compare_imported_psk_identity returns whether `id` is equal to `cred`'s
1289
+ // imported identity for the specified target protocol and target KDF. This
1290
+ // allows matching against PSK identities without deriving imported PSK keys.
1291
+ bool tls13_compare_imported_psk_identity(Span<const uint8_t> id,
1292
+ const SSLCredential *cred,
1293
+ uint16_t protocol,
1294
+ const EVP_MD *hkdf_md);
1295
+
1296
+ using SSLPreSharedKey = std::variant<SSLImportedPSK, UniquePtr<SSLSession>>;
1297
+ BORINGSSL_MAKE_DELETER(SSLPreSharedKey, Delete)
1298
+
1299
+ // ssl_pre_shared_key_hash return's `psk`'s hash.
1300
+ const EVP_MD *ssl_pre_shared_key_hash(const SSLPreSharedKey &psk);
1301
+
1302
+ // ssl_pre_shared_key_identity return's `psk`'s identity.
1303
+ Span<const uint8_t> ssl_pre_shared_key_identity(const SSLPreSharedKey &psk);
1304
+
1305
+ // ssl_pre_shared_key_secret return's `psk`'s secret.
1306
+ Span<const uint8_t> ssl_pre_shared_key_secret(const SSLPreSharedKey &psk);
1307
+
1308
+ // tls13_psk_binder calculates the PSK binder value for `psk` over `transcript`
1309
+ // and `client_hello`. On success, it writes the result to `out`, sets
1310
+ // `*out_len` to the length, and returns true. Otherwise, it returns false.
1311
+ // `binders_len` must be the length of the binders field, covering all binders
1312
+ // and the overall length prefix, in `client_hello`.
1313
+ bool tls13_psk_binder(const SSL_HANDSHAKE *hs, Span<uint8_t> out,
1314
+ size_t *out_len, const SSLPreSharedKey &psk,
1315
+ const SSLTranscript &transcript,
1316
+ Span<const uint8_t> client_hello, size_t binders_len);
1700
1317
 
1701
1318
 
1702
1319
  // Encrypted ClientHello.
@@ -1705,7 +1322,7 @@ struct ECHConfig {
1705
1322
  static constexpr bool kAllowUniquePtr = true;
1706
1323
  // raw contains the serialized ECHConfig.
1707
1324
  Array<uint8_t> raw;
1708
- // The following fields alias into |raw|.
1325
+ // The following fields alias into `raw`.
1709
1326
  Span<const uint8_t> public_key;
1710
1327
  Span<const uint8_t> public_name;
1711
1328
  Span<const uint8_t> cipher_suites;
@@ -1721,12 +1338,12 @@ class ECHServerConfig {
1721
1338
  ECHServerConfig(const ECHServerConfig &other) = delete;
1722
1339
  ECHServerConfig &operator=(ECHServerConfig &&) = delete;
1723
1340
 
1724
- // Init parses |ech_config| as an ECHConfig and saves a copy of |key|.
1341
+ // Init parses `ech_config` as an ECHConfig and saves a copy of `key`.
1725
1342
  // It returns true on success and false on error.
1726
1343
  bool Init(Span<const uint8_t> ech_config, const EVP_HPKE_KEY *key,
1727
1344
  bool is_retry_config);
1728
1345
 
1729
- // SetupContext sets up |ctx| for a new connection, given the specified
1346
+ // SetupContext sets up `ctx` for a new connection, given the specified
1730
1347
  // HPKE ciphersuite and encapsulated KEM key. It returns true on success and
1731
1348
  // false on error. This function may only be called on an initialized object.
1732
1349
  bool SetupContext(EVP_HPKE_CTX *ctx, uint16_t kdf_id, uint16_t aead_id,
@@ -1741,6 +1358,17 @@ class ECHServerConfig {
1741
1358
  bool is_retry_config_ = false;
1742
1359
  };
1743
1360
 
1361
+ class SSLECHKeys : public ssl_ech_keys_st, public bssl::RefCounted<SSLECHKeys> {
1362
+ public:
1363
+ SSLECHKeys() : RefCounted(CheckSubClass()) {}
1364
+
1365
+ Vector<UniquePtr<ECHServerConfig>> configs;
1366
+
1367
+ private:
1368
+ friend RefCounted;
1369
+ ~SSLECHKeys() = default;
1370
+ };
1371
+
1744
1372
  enum ssl_client_hello_type_t {
1745
1373
  ssl_client_hello_unencrypted,
1746
1374
  ssl_client_hello_inner,
@@ -1752,22 +1380,22 @@ enum ssl_client_hello_type_t {
1752
1380
  #define ECH_CLIENT_INNER 1
1753
1381
 
1754
1382
  // ssl_decode_client_hello_inner recovers the full ClientHelloInner from the
1755
- // EncodedClientHelloInner |encoded_client_hello_inner| by replacing its
1383
+ // EncodedClientHelloInner `encoded_client_hello_inner` by replacing its
1756
1384
  // outer_extensions extension with the referenced extensions from the
1757
- // ClientHelloOuter |client_hello_outer|. If successful, it writes the recovered
1758
- // ClientHelloInner to |out_client_hello_inner|. It returns true on success and
1385
+ // ClientHelloOuter `client_hello_outer`. If successful, it writes the recovered
1386
+ // ClientHelloInner to `out_client_hello_inner`. It returns true on success and
1759
1387
  // false on failure.
1760
1388
  //
1761
1389
  // This function is exported for fuzzing.
1762
1390
  OPENSSL_EXPORT bool ssl_decode_client_hello_inner(
1763
- SSL *ssl, uint8_t *out_alert, Array<uint8_t> *out_client_hello_inner,
1391
+ SSLImpl *ssl, uint8_t *out_alert, Array<uint8_t> *out_client_hello_inner,
1764
1392
  Span<const uint8_t> encoded_client_hello_inner,
1765
1393
  const SSL_CLIENT_HELLO *client_hello_outer);
1766
1394
 
1767
- // ssl_client_hello_decrypt attempts to decrypt and decode the |payload|. It
1768
- // writes the result to |*out|. |payload| must point into |client_hello_outer|.
1395
+ // ssl_client_hello_decrypt attempts to decrypt and decode the `payload`. It
1396
+ // writes the result to `*out`. `payload` must point into `client_hello_outer`.
1769
1397
  // It returns true on success and false on error. On error, it sets
1770
- // |*out_is_decrypt_error| to whether the failure was due to a bad ciphertext.
1398
+ // `*out_is_decrypt_error` to whether the failure was due to a bad ciphertext.
1771
1399
  bool ssl_client_hello_decrypt(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1772
1400
  bool *out_is_decrypt_error, Array<uint8_t> *out,
1773
1401
  const SSL_CLIENT_HELLO *client_hello_outer,
@@ -1777,51 +1405,51 @@ bool ssl_client_hello_decrypt(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1777
1405
 
1778
1406
  // ssl_ech_confirmation_signal_hello_offset returns the offset of the ECH
1779
1407
  // confirmation signal in a ServerHello message, including the handshake header.
1780
- size_t ssl_ech_confirmation_signal_hello_offset(const SSL *ssl);
1408
+ size_t ssl_ech_confirmation_signal_hello_offset(const SSLImpl *ssl);
1781
1409
 
1782
1410
  // ssl_ech_accept_confirmation computes the server's ECH acceptance signal,
1783
- // writing it to |out|. The transcript portion is the concatenation of
1784
- // |transcript| with |msg|. The |ECH_CONFIRMATION_SIGNAL_LEN| bytes from
1785
- // |offset| in |msg| are replaced with zeros before hashing. This function
1411
+ // writing it to `out`. The transcript portion is the concatenation of
1412
+ // `transcript` with `msg`. The `ECH_CONFIRMATION_SIGNAL_LEN` bytes from
1413
+ // `offset` in `msg` are replaced with zeros before hashing. This function
1786
1414
  // returns true on success, and false on failure.
1787
- bool ssl_ech_accept_confirmation(const SSL_HANDSHAKE *hs, Span<uint8_t> out,
1788
- Span<const uint8_t> client_random,
1789
- const SSLTranscript &transcript, bool is_hrr,
1790
- Span<const uint8_t> msg, size_t offset);
1415
+ bool ssl_ech_accept_confirmation(
1416
+ const SSL_HANDSHAKE *hs, Span<uint8_t, ECH_CONFIRMATION_SIGNAL_LEN> out,
1417
+ Span<const uint8_t, SSL3_RANDOM_SIZE> client_random,
1418
+ const SSLTranscript &transcript, bool is_hrr, Span<const uint8_t> msg,
1419
+ size_t offset);
1791
1420
 
1792
- // ssl_is_valid_ech_public_name returns true if |public_name| is a valid ECH
1421
+ // ssl_is_valid_ech_public_name returns true if `public_name` is a valid ECH
1793
1422
  // public name and false otherwise. It is exported for testing.
1794
- OPENSSL_EXPORT bool ssl_is_valid_ech_public_name(
1795
- Span<const uint8_t> public_name);
1423
+ bool ssl_is_valid_ech_public_name(Span<const uint8_t> public_name);
1796
1424
 
1797
- // ssl_is_valid_ech_config_list returns true if |ech_config_list| is a valid
1425
+ // ssl_is_valid_ech_config_list returns true if `ech_config_list` is a valid
1798
1426
  // ECHConfigList structure and false otherwise.
1799
1427
  bool ssl_is_valid_ech_config_list(Span<const uint8_t> ech_config_list);
1800
1428
 
1801
1429
  // ssl_select_ech_config selects an ECHConfig and associated parameters to offer
1802
- // on the client and updates |hs|. It returns true on success, whether an
1430
+ // on the client and updates `hs`. It returns true on success, whether an
1803
1431
  // ECHConfig was found or not, and false on internal error. On success, the
1804
- // encapsulated key is written to |out_enc| and |*out_enc_len| is set to the
1432
+ // encapsulated key is written to `out_enc` and `*out_enc_len` is set to the
1805
1433
  // number of bytes written. If the function did not select an ECHConfig, the
1806
1434
  // encapsulated key is the empty string.
1807
1435
  bool ssl_select_ech_config(SSL_HANDSHAKE *hs, Span<uint8_t> out_enc,
1808
1436
  size_t *out_enc_len);
1809
1437
 
1810
1438
  // ssl_ech_extension_body_length returns the length of the body of a ClientHello
1811
- // ECH extension that encrypts |in_len| bytes with |aead| and an 'enc' value of
1812
- // length |enc_len|. The result does not include the four-byte extension header.
1439
+ // ECH extension that encrypts `in_len` bytes with `aead` and an 'enc' value of
1440
+ // length `enc_len`. The result does not include the four-byte extension header.
1813
1441
  size_t ssl_ech_extension_body_length(const EVP_HPKE_AEAD *aead, size_t enc_len,
1814
1442
  size_t in_len);
1815
1443
 
1816
1444
  // ssl_encrypt_client_hello constructs a new ClientHelloInner, adds it to the
1817
- // inner transcript, and encrypts for inclusion in the ClientHelloOuter. |enc|
1445
+ // inner transcript, and encrypts for inclusion in the ClientHelloOuter. `enc`
1818
1446
  // is the encapsulated key to include in the extension. It returns true on
1819
- // success and false on error. If not offering ECH, |enc| is ignored and the
1447
+ // success and false on error. If not offering ECH, `enc` is ignored and the
1820
1448
  // function will compute a GREASE ECH extension if necessary, and otherwise
1821
1449
  // return success while doing nothing.
1822
1450
  //
1823
1451
  // Encrypting the ClientHelloInner incorporates all extensions in the
1824
- // ClientHelloOuter, so all other state necessary for |ssl_add_client_hello|
1452
+ // ClientHelloOuter, so all other state necessary for `ssl_add_client_hello`
1825
1453
  // must already be computed.
1826
1454
  bool ssl_encrypt_client_hello(SSL_HANDSHAKE *hs, Span<const uint8_t> enc);
1827
1455
 
@@ -1833,20 +1461,21 @@ enum class SSLCredentialType {
1833
1461
  kDelegated,
1834
1462
  kSPAKE2PlusV1Client,
1835
1463
  kSPAKE2PlusV1Server,
1464
+ kPreSharedKey,
1465
+ kRawPublicKey,
1836
1466
  };
1837
1467
 
1838
- BSSL_NAMESPACE_END
1839
-
1840
- // SSL_CREDENTIAL is exported to C, so it must be defined outside the namespace.
1841
- struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
1842
- explicit ssl_credential_st(bssl::SSLCredentialType type);
1843
- ssl_credential_st(const ssl_credential_st &) = delete;
1844
- ssl_credential_st &operator=(const ssl_credential_st &) = delete;
1468
+ class SSLCredential : public ssl_credential_st,
1469
+ public RefCounted<SSLCredential> {
1470
+ public:
1471
+ explicit SSLCredential(SSLCredentialType type);
1472
+ SSLCredential(const SSLCredential &) = delete;
1473
+ SSLCredential &operator=(const SSLCredential &) = delete;
1845
1474
 
1846
- // Dup returns a copy of the credential, or nullptr on error. The |ex_data|
1475
+ // Dup returns a copy of the credential, or nullptr on error. The `ex_data`
1847
1476
  // values are not copied. This is only used on the legacy credential, whose
1848
- // |ex_data| is inaccessible.
1849
- bssl::UniquePtr<SSL_CREDENTIAL> Dup() const;
1477
+ // `ex_data` is inaccessible.
1478
+ UniquePtr<SSLCredential> Dup() const;
1850
1479
 
1851
1480
  // ClearCertAndKey erases any certificate and private key on the credential.
1852
1481
  void ClearCertAndKey();
@@ -1855,44 +1484,43 @@ struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
1855
1484
  bool UsesX509() const;
1856
1485
 
1857
1486
  // UsesPrivateKey returns true if the credential type uses an asymmetric
1858
- // private key.
1487
+ // private and public keypair.
1859
1488
  bool UsesPrivateKey() const;
1860
1489
 
1861
1490
  // IsComplete returns whether all required fields in the credential have been
1862
1491
  // filled in.
1863
1492
  bool IsComplete() const;
1864
1493
 
1865
- // SetLeafCert sets the leaf certificate to |leaf|, leaving the remaining
1494
+ // SetLeafCert sets the leaf certificate to `leaf`, leaving the remaining
1866
1495
  // certificates unmodified. It returns true on success and false on error. If
1867
- // |discard_key_on_mismatch| is true and the private key is inconsistent with
1496
+ // `discard_key_on_mismatch` is true and the private key is inconsistent with
1868
1497
  // the new leaf certificate, it is silently discarded.
1869
- bool SetLeafCert(bssl::UniquePtr<CRYPTO_BUFFER> leaf,
1870
- bool discard_key_on_mismatch);
1498
+ bool SetLeafCert(UniquePtr<CRYPTO_BUFFER> leaf, bool discard_key_on_mismatch);
1871
1499
 
1872
1500
  // ClearIntermediateCerts clears intermediate certificates in the certificate
1873
1501
  // chain, while preserving the leaf.
1874
1502
  void ClearIntermediateCerts();
1875
1503
 
1876
- // AppendIntermediateCert appends |cert| to the certificate chain. If there is
1877
- // no leaf certificate configured, it leaves a placeholder null in |chain|. It
1504
+ // AppendIntermediateCert appends `cert` to the certificate chain. If there is
1505
+ // no leaf certificate configured, it leaves a placeholder null in `chain`. It
1878
1506
  // returns one on success and zero on error.
1879
- bool AppendIntermediateCert(bssl::UniquePtr<CRYPTO_BUFFER> cert);
1507
+ bool AppendIntermediateCert(UniquePtr<CRYPTO_BUFFER> cert);
1880
1508
 
1881
- // ChainContainsIssuer returns true if |dn| is a byte for byte match with the
1882
- // issuer of any certificate in |chain|, false otherwise.
1883
- bool ChainContainsIssuer(bssl::Span<const uint8_t> dn) const;
1509
+ // ChainContainsIssuer returns true if `dn` is a byte for byte match with the
1510
+ // issuer of any certificate in `chain`, false otherwise.
1511
+ bool ChainContainsIssuer(Span<const uint8_t> dn) const;
1884
1512
 
1885
1513
  // type is the credential type and determines which other fields apply.
1886
- bssl::SSLCredentialType type;
1514
+ SSLCredentialType type;
1887
1515
 
1888
- // pubkey is the cached public key of the credential. Unlike |privkey|, it is
1516
+ // pubkey is the cached public key of the credential. Unlike `privkey`, it is
1889
1517
  // always present and is extracted from the certificate, delegated credential,
1890
1518
  // etc.
1891
- bssl::UniquePtr<EVP_PKEY> pubkey;
1519
+ UniquePtr<EVP_PKEY> pubkey;
1892
1520
 
1893
1521
  // privkey is the private key of the credential. It may be omitted in favor of
1894
- // |key_method|.
1895
- bssl::UniquePtr<EVP_PKEY> privkey;
1522
+ // `key_method`.
1523
+ UniquePtr<EVP_PKEY> privkey;
1896
1524
 
1897
1525
  // key_method, if non-null, is a set of callbacks to call for private key
1898
1526
  // operations.
@@ -1904,53 +1532,68 @@ struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
1904
1532
  //
1905
1533
  // In delegated credentials, this field is not configurable and is instead
1906
1534
  // computed from the dc_cert_verify_algorithm field.
1907
- bssl::Array<uint16_t> sigalgs;
1535
+ Array<uint16_t> sigalgs;
1908
1536
 
1909
1537
  // chain contains the certificate chain, with the leaf at the beginning. The
1910
- // first element of |chain| may be nullptr to indicate that the leaf
1538
+ // first element of `chain` may be nullptr to indicate that the leaf
1911
1539
  // certificate has not yet been set.
1912
- // If |chain| != nullptr -> len(chain) >= 1
1913
- // If |chain[0]| == nullptr -> len(chain) >= 2.
1914
- // |chain[1..]| != nullptr
1915
- bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> chain;
1540
+ // If `chain` != nullptr -> len(chain) >= 1
1541
+ // If `chain[0]` == nullptr -> len(chain) >= 2.
1542
+ // `chain[1..]` != nullptr
1543
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> chain;
1916
1544
 
1917
1545
  // dc is the DelegatedCredential structure, if this is a delegated credential.
1918
- bssl::UniquePtr<CRYPTO_BUFFER> dc;
1546
+ UniquePtr<CRYPTO_BUFFER> dc;
1919
1547
 
1920
1548
  // dc_algorithm is the signature scheme of the signature over the delegated
1921
1549
  // credential itself, made by the end-entity certificate's public key.
1922
1550
  uint16_t dc_algorithm = 0;
1923
1551
 
1924
1552
  // Signed certificate timestamp list to be sent to the client, if requested
1925
- bssl::UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
1553
+ UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
1926
1554
 
1927
1555
  // OCSP response to be sent to the client, if requested.
1928
- bssl::UniquePtr<CRYPTO_BUFFER> ocsp_response;
1556
+ UniquePtr<CRYPTO_BUFFER> ocsp_response;
1557
+
1558
+ // sid_ctx partitions the session space within a shared session cache or
1559
+ // ticket key. If empty, the session ID context in `SSL` will be used.
1560
+ InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
1929
1561
 
1930
1562
  // SPAKE2+-specific information.
1931
- bssl::Array<uint8_t> pake_context;
1932
- bssl::Array<uint8_t> client_identity;
1933
- bssl::Array<uint8_t> server_identity;
1934
- bssl::Array<uint8_t> password_verifier_w0;
1935
- bssl::Array<uint8_t> password_verifier_w1; // server-only
1936
- bssl::Array<uint8_t> registration_record; // client-only
1563
+ Array<uint8_t> pake_context;
1564
+ Array<uint8_t> client_identity;
1565
+ Array<uint8_t> server_identity;
1566
+ Array<uint8_t> password_verifier_w0;
1567
+ Array<uint8_t> password_verifier_w1; // server-only
1568
+ Array<uint8_t> registration_record; // client-only
1937
1569
  mutable std::atomic<uint32_t> pake_limit;
1938
1570
 
1571
+ // External-PSK-specific information. epskx is the HKDF-Extract-ed value, from
1572
+ // Section 5.1 of RFC 9258.
1573
+ Array<uint8_t> epskx;
1574
+ Array<uint8_t> epsk_id;
1575
+ const EVP_MD *epsk_md = nullptr;
1576
+ Array<uint8_t> epsk_context;
1577
+
1939
1578
  // Checks whether there are still permitted PAKE attempts remaining, without
1940
1579
  // changing the counter.
1941
1580
  bool HasPAKEAttempts() const;
1942
1581
 
1943
- // Atomically decrement |pake_limit|. Return true if successful and false if
1944
- // |pake_limit| is already zero.
1582
+ // Atomically decrement `pake_limit`. Return true if successful and false if
1583
+ // `pake_limit` is already zero.
1945
1584
  bool ClaimPAKEAttempt() const;
1946
1585
 
1947
- // Atomically increment |pake_limit|. This must be paired with a
1948
- // |ClaimPAKEAttempt| call.
1586
+ // Atomically increment `pake_limit`. This must be paired with a
1587
+ // `ClaimPAKEAttempt` call.
1949
1588
  void RestorePAKEAttempt() const;
1950
1589
 
1951
1590
  // trust_anchor_id, if non-empty, is the trust anchor ID for the root of the
1952
- // chain in |chain|.
1953
- bssl::Array<uint8_t> trust_anchor_id;
1591
+ // chain in `chain`.
1592
+ Array<uint8_t> trust_anchor_id;
1593
+
1594
+ // trust_anchor_group_patterns describes trust anchor groups that also match
1595
+ // this credential.
1596
+ Vector<Array<uint8_t>> trust_anchor_group_patterns;
1954
1597
 
1955
1598
  CRYPTO_EX_DATA ex_data;
1956
1599
 
@@ -1963,13 +1606,16 @@ struct ssl_credential_st : public bssl::RefCounted<ssl_credential_st> {
1963
1606
 
1964
1607
  private:
1965
1608
  friend RefCounted;
1966
- ~ssl_credential_st();
1609
+ ~SSLCredential();
1967
1610
  };
1968
1611
 
1969
- BSSL_NAMESPACE_BEGIN
1612
+ // ssl_trust_anchor_pattern_matches_id returns whether `pattern`, a trust anchor
1613
+ // ID pattern, matches `id`, a trust anchor ID.
1614
+ bool ssl_trust_anchor_pattern_matches_id(Span<const uint8_t> pattern,
1615
+ Span<const uint8_t> id);
1970
1616
 
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.
1617
+ // ssl_get_full_credential_list computes `hs`'s full credential list, including
1618
+ // the legacy credential. On success, it writes it to `*out` and returns true.
1973
1619
  // Otherwise, it returns false. The credential list may be empty, in which case
1974
1620
  // this function will successfully output an empty array.
1975
1621
  //
@@ -1977,17 +1623,68 @@ BSSL_NAMESPACE_BEGIN
1977
1623
  // intended to be used for certificate-based credentials. It runs the
1978
1624
  // auto-chaining logic as part of finishing the legacy credential. Other uses of
1979
1625
  // the credential list (e.g. PAKE credentials) should iterate over
1980
- // |hs->config->cert->credentials|.
1626
+ // `hs->config->cert->credentials`.
1981
1627
  //
1982
- // The pointers in the result are only valid until |hs| is next mutated.
1628
+ // The pointers in the result are only valid until `hs` is next mutated.
1983
1629
  bool ssl_get_full_credential_list(SSL_HANDSHAKE *hs,
1984
- Array<SSL_CREDENTIAL *> *out);
1630
+ Array<SSLCredential *> *out);
1985
1631
 
1986
- // ssl_credential_matches_requested_issuers returns true if |cred| is a
1987
- // usable match for any requested issuers in |hs|, and false with an error
1632
+ // ssl_credential_matches_requested_issuers returns true if `cred` is a
1633
+ // usable match for any requested issuers in `hs`, and false with an error
1988
1634
  // otherwise.
1989
1635
  bool ssl_credential_matches_requested_issuers(SSL_HANDSHAKE *hs,
1990
- const SSL_CREDENTIAL *cred);
1636
+ const SSLCredential *cred);
1637
+
1638
+ // ssl_check_tls13_credential_ignoring_issuer returns true if `cred` is usable
1639
+ // as the certificate in a TLS 1.3 handshake, ignoring the issuer check.
1640
+ // `allowed_cert_types` is a nonempty set of cert types (`TLSEXT_cert_type_*`
1641
+ // values) that are usable; `cred` must match one of these types.
1642
+ // `out_sigalg` will be set to a matching signature algorithm if true is
1643
+ // returned.
1644
+ bool ssl_check_tls13_credential_ignoring_issuer(
1645
+ SSL_HANDSHAKE *hs, Span<const uint8_t> allowed_cert_types,
1646
+ const SSLCredential *cred, uint16_t *out_sigalg);
1647
+
1648
+
1649
+ // Client certificate type & Server certificate type.
1650
+
1651
+ inline constexpr uint8_t kAllCertTypes[] = {
1652
+ TLSEXT_cert_type_x509,
1653
+ TLSEXT_cert_type_rpk,
1654
+ };
1655
+ inline constexpr size_t kNumCertTypes = std::size(kAllCertTypes);
1656
+ inline constexpr uint8_t kDefaultCertType = TLSEXT_cert_type_x509;
1657
+
1658
+ // ssl_credential_type_to_cert_type returns the certificate type value
1659
+ // (`TLSEXT_cert_type_*` value) corresponding to `cred_type`, or else
1660
+ // std::nullopt.
1661
+ std::optional<uint8_t> ssl_credential_type_to_cert_type(
1662
+ SSLCredentialType cred_type);
1663
+
1664
+ // ssl_setup_client_certificate_type computes the client cert types to offer, as
1665
+ // a client, and saves them in `hs`. The values are used later when checking
1666
+ // that the server responded with a valid value.
1667
+ void ssl_setup_client_certificate_type(SSL_HANDSHAKE *hs);
1668
+
1669
+ // ssl_negotiate_client_certificate_type, for a server, negotiates the
1670
+ // client_certificate_type extension, if applicable. It updates
1671
+ // `hs->peer_cert_type` appropriately and returns true if negotiation was
1672
+ // successful or not necessary (i.e. if we are not requesting a cert from the
1673
+ // client), or it returns false and sets `*out_alert` to an alert on error.
1674
+ bool ssl_negotiate_client_certificate_type(
1675
+ SSL_HANDSHAKE *hs, uint8_t *out_alert,
1676
+ const SSL_CLIENT_HELLO *client_hello);
1677
+
1678
+ // ssl_get_allowed_server_cert_types, for a server, returns the cert types that
1679
+ // may be used based on the server_certificate_type extension in the
1680
+ // ClientHello. It returns a nonempty list of allowable certificate types. By
1681
+ // default, if the client did not send the extension, X.509 certificates are
1682
+ // allowed. The returned cert types may include unrecognized values. Returns
1683
+ // nullopt and sets `out_alert` on failure.
1684
+ std::optional<Span<const uint8_t>> ssl_get_allowed_server_cert_types(
1685
+ const SSL_HANDSHAKE *hs, const SSL_CLIENT_HELLO *client_hello,
1686
+ uint8_t *out_alert);
1687
+
1991
1688
 
1992
1689
  // Handshake functions.
1993
1690
 
@@ -2020,7 +1717,8 @@ enum ssl_grease_index_t {
2020
1717
  ssl_grease_version,
2021
1718
  ssl_grease_ticket_extension,
2022
1719
  ssl_grease_ech_config_id,
2023
- ssl_grease_last_index = ssl_grease_ech_config_id,
1720
+ ssl_grease_signature_algorithm,
1721
+ ssl_grease_last_index = ssl_grease_signature_algorithm,
2024
1722
  };
2025
1723
 
2026
1724
  enum tls12_server_hs_state_t {
@@ -2079,7 +1777,7 @@ enum handback_t {
2079
1777
  };
2080
1778
 
2081
1779
  // SSL_HANDSHAKE_HINTS contains handshake hints for a connection. See
2082
- // |SSL_request_handshake_hints| and related functions.
1780
+ // `SSL_request_handshake_hints` and related functions.
2083
1781
  struct SSL_HANDSHAKE_HINTS {
2084
1782
  static constexpr bool kAllowUniquePtr = true;
2085
1783
 
@@ -2120,34 +1818,34 @@ struct SSLPAKEShare {
2120
1818
  };
2121
1819
 
2122
1820
  struct SSL_HANDSHAKE {
2123
- explicit SSL_HANDSHAKE(SSL *ssl);
1821
+ explicit SSL_HANDSHAKE(SSLImpl *ssl);
2124
1822
  ~SSL_HANDSHAKE();
2125
1823
  static constexpr bool kAllowUniquePtr = true;
2126
1824
 
2127
- // ssl is a non-owning pointer to the parent |SSL| object.
2128
- SSL *ssl;
1825
+ // ssl is a non-owning pointer to the parent `SSL` object.
1826
+ SSLImpl *ssl;
2129
1827
 
2130
1828
  // config is a non-owning pointer to the handshake configuration.
2131
1829
  SSL_CONFIG *config;
2132
1830
 
2133
1831
  // wait contains the operation the handshake is currently blocking on or
2134
- // |ssl_hs_ok| if none.
1832
+ // `ssl_hs_ok` if none.
2135
1833
  enum ssl_hs_wait_t wait = ssl_hs_ok;
2136
1834
 
2137
1835
  // state is the internal state for the TLS 1.2 and below handshake. Its
2138
- // values depend on |do_handshake| but the starting state is always zero.
1836
+ // values depend on `do_handshake` but the starting state is always zero.
2139
1837
  int state = 0;
2140
1838
 
2141
1839
  // tls13_state is the internal state for the TLS 1.3 handshake. Its values
2142
- // depend on |do_handshake| but the starting state is always zero.
1840
+ // depend on `do_handshake` but the starting state is always zero.
2143
1841
  int tls13_state = 0;
2144
1842
 
2145
1843
  // min_version is the minimum accepted protocol version, taking account both
2146
- // |SSL_OP_NO_*| and |SSL_CTX_set_min_proto_version| APIs.
1844
+ // `SSL_OP_NO_*` and `SSL_CTX_set_min_proto_version` APIs.
2147
1845
  uint16_t min_version = 0;
2148
1846
 
2149
1847
  // max_version is the maximum accepted protocol version, taking account both
2150
- // |SSL_OP_NO_*| and |SSL_CTX_set_max_proto_version| APIs.
1848
+ // `SSL_OP_NO_*` and `SSL_CTX_set_max_proto_version` APIs.
2151
1849
  uint16_t max_version = 0;
2152
1850
 
2153
1851
  InplaceVector<uint8_t, SSL_MAX_MD_SIZE> secret;
@@ -2160,11 +1858,11 @@ struct SSL_HANDSHAKE {
2160
1858
 
2161
1859
  // GetClientHello, on the server, returns either the normal ClientHello
2162
1860
  // message or the ClientHelloInner if it has been serialized to
2163
- // |ech_client_hello_buf|. This function should only be called when the
1861
+ // `ech_client_hello_buf`. This function should only be called when the
2164
1862
  // current message is a ClientHello. It returns true on success and false on
2165
1863
  // error.
2166
1864
  //
2167
- // Note that fields of the returned |out_msg| and |out_client_hello| point
1865
+ // Note that fields of the returned `out_msg` and `out_client_hello` point
2168
1866
  // into a handshake-owned buffer, so their lifetimes should not exceed this
2169
1867
  // SSL_HANDSHAKE.
2170
1868
  bool GetClientHello(SSLMessage *out_msg, SSL_CLIENT_HELLO *out_client_hello);
@@ -2174,28 +1872,41 @@ struct SSL_HANDSHAKE {
2174
1872
  // in extensions.cc. Each bit is set if that extension was sent in a
2175
1873
  // ClientHello. It's not used by servers.
2176
1874
  uint32_t sent = 0;
2177
- // received is a bitset, like |sent|, but is used by servers to record
1875
+ // received is a bitset, like `sent`, but is used by servers to record
2178
1876
  // which extensions were received from a client.
2179
1877
  uint32_t received;
2180
1878
  } extensions;
2181
1879
 
2182
- // inner_extensions_sent, on clients that offer ECH, is |extensions.sent| for
1880
+ // inner_extensions_sent, on clients that offer ECH, is `extensions.sent` for
2183
1881
  // the ClientHelloInner.
2184
1882
  uint32_t inner_extensions_sent = 0;
2185
1883
 
2186
- // error, if |wait| is |ssl_hs_error|, is the error the handshake failed on.
1884
+ // early_data_written is the amount of early data that has been written by the
1885
+ // record layer.
1886
+ uint32_t early_data_written = 0;
1887
+
1888
+ // error, if `wait` is `ssl_hs_error`, is the error the handshake failed on.
2187
1889
  UniquePtr<ERR_SAVE_STATE> error;
2188
1890
 
2189
- // key_shares are the current key exchange instances. The second is only used
2190
- // as a client if we believe that we should offer two key shares in a
2191
- // ClientHello.
2192
- UniquePtr<SSLKeyShare> key_shares[2];
1891
+ // key_shares are the current key exchange instances, in preference order. Any
1892
+ // members of this vector must be non-null.
1893
+ InplaceVector<UniquePtr<SSLKeyShare>, kNumNamedGroups> key_shares;
1894
+
1895
+ // pre_shared_keys are the pre-shared keys to be offered by the client.
1896
+ Vector<SSLPreSharedKey> pre_shared_keys;
1897
+
1898
+ // pre_shared_key is the selected pre-shared key on the server.
1899
+ UniquePtr<SSLPreSharedKey> pre_shared_key;
1900
+
1901
+ // selected_psk_index is the index of the selected pre-shared key on the
1902
+ // server.
1903
+ std::optional<uint16_t> selected_psk_index;
2193
1904
 
2194
1905
  // transcript is the current handshake transcript.
2195
1906
  SSLTranscript transcript;
2196
1907
 
2197
1908
  // inner_transcript, on the client, is the handshake transcript for the
2198
- // ClientHelloInner handshake. It is moved to |transcript| if the server
1909
+ // ClientHelloInner handshake. It is moved to `transcript` if the server
2199
1910
  // accepts ECH.
2200
1911
  SSLTranscript inner_transcript;
2201
1912
 
@@ -2251,18 +1962,18 @@ struct SSL_HANDSHAKE {
2251
1962
  Array<uint8_t> peer_key;
2252
1963
 
2253
1964
  // extension_permutation is the permutation to apply to ClientHello
2254
- // extensions. It maps indices into the |kExtensions| table into other
1965
+ // extensions. It maps indices into the `kExtensions` table into other
2255
1966
  // indices.
2256
1967
  Array<uint8_t> extension_permutation;
2257
1968
 
2258
1969
  // cert_compression_alg_id, for a server, contains the negotiated certificate
2259
1970
  // compression algorithm for this client. It is only valid if
2260
- // |cert_compression_negotiated| is true.
1971
+ // `cert_compression_negotiated` is true.
2261
1972
  uint16_t cert_compression_alg_id;
2262
1973
 
2263
1974
  // ech_hpke_ctx is the HPKE context used in ECH. On the server, it is
2264
- // initialized if |ech_status| is |ssl_ech_accepted|. On the client, it is
2265
- // initialized if |selected_ech_config| is not nullptr.
1975
+ // initialized if `ech_status` is `ssl_ech_accepted`. On the client, it is
1976
+ // initialized if `selected_ech_config` is not nullptr.
2266
1977
  ScopedEVP_HPKE_CTX ech_hpke_ctx;
2267
1978
 
2268
1979
  // server_params, in a TLS 1.2 server, stores the ServerKeyExchange
@@ -2289,8 +2000,8 @@ struct SSL_HANDSHAKE {
2289
2000
  Array<uint8_t> peer_available_trust_anchors;
2290
2001
 
2291
2002
  // cached_x509_ca_names contains a cache of parsed versions of the elements of
2292
- // |ca_names|. This pointer is left non-owning so only
2293
- // |ssl_crypto_x509_method| needs to link against crypto/x509.
2003
+ // `ca_names`. This pointer is left non-owning so only
2004
+ // `ssl_crypto_x509_method` needs to link against crypto/x509.
2294
2005
  STACK_OF(X509_NAME) *cached_x509_ca_names = nullptr;
2295
2006
 
2296
2007
  // certificate_types, on the client, contains the set of certificate types
@@ -2298,26 +2009,26 @@ struct SSL_HANDSHAKE {
2298
2009
  Array<uint8_t> certificate_types;
2299
2010
 
2300
2011
  // credential is the credential we are using for the handshake.
2301
- UniquePtr<SSL_CREDENTIAL> credential;
2012
+ UniquePtr<SSLCredential> credential;
2302
2013
 
2303
2014
  // peer_pubkey is the public key parsed from the peer's leaf certificate.
2304
2015
  UniquePtr<EVP_PKEY> peer_pubkey;
2305
2016
 
2306
2017
  // new_session is the new mutable session being established by the current
2307
2018
  // handshake. It should not be cached.
2308
- UniquePtr<SSL_SESSION> new_session;
2019
+ UniquePtr<SSLSession> new_session;
2309
2020
 
2310
2021
  // early_session is the session corresponding to the current 0-RTT state on
2311
- // the client if |in_early_data| is true.
2312
- UniquePtr<SSL_SESSION> early_session;
2022
+ // the client if `in_early_data` is true.
2023
+ UniquePtr<SSLSession> early_session;
2313
2024
 
2314
2025
  // ssl_ech_keys, for servers, is the set of ECH keys to use with this
2315
- // handshake. This is copied from |SSL_CTX| to ensure consistent behavior as
2316
- // |SSL_CTX| rotates keys.
2317
- UniquePtr<SSL_ECH_KEYS> ech_keys;
2026
+ // handshake. This is copied from `SSL_CTX` to ensure consistent behavior as
2027
+ // `SSL_CTX` rotates keys.
2028
+ UniquePtr<SSLECHKeys> ech_keys;
2318
2029
 
2319
2030
  // 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, |ech_hpke_ctx|
2031
+ // ECH, or nullptr if ECH is not being offered. If non-NULL, `ech_hpke_ctx`
2321
2032
  // will be initialized.
2322
2033
  UniquePtr<ECHConfig> selected_ech_config;
2323
2034
 
@@ -2327,12 +2038,15 @@ struct SSL_HANDSHAKE {
2327
2038
  // key_block is the record-layer key block for TLS 1.2 and earlier.
2328
2039
  Array<uint8_t> key_block;
2329
2040
 
2330
- // hints contains the handshake hints for this connection. If
2331
- // |hints_requested| is true, this field is non-null and contains the pending
2332
- // hints to filled as the predicted handshake progresses. Otherwise, this
2333
- // field, if non-null, contains hints configured by the caller and will
2334
- // influence the handshake on match.
2335
- UniquePtr<SSL_HANDSHAKE_HINTS> hints;
2041
+ // pending_hints, if non-null, contains the pending hints to filled as the
2042
+ // predicted handshake progresses. If non-null, only the first round-trip of
2043
+ // the handshake will complete, after which the `pending_hints` structure can
2044
+ // be serialized.
2045
+ UniquePtr<SSL_HANDSHAKE_HINTS> pending_hints;
2046
+
2047
+ // provided_hints, if non-null, contains hints configured by the caller
2048
+ // and will influence the (real or predicted) handshake on match.
2049
+ UniquePtr<SSL_HANDSHAKE_HINTS> provided_hints;
2336
2050
 
2337
2051
  // ech_is_inner, on the server, indicates whether the ClientHello contained an
2338
2052
  // inner ECH extension.
@@ -2408,16 +2122,11 @@ struct SSL_HANDSHAKE {
2408
2122
 
2409
2123
  // handback indicates that a server should pause the handshake after
2410
2124
  // finishing operations that require private key material, in such a way that
2411
- // |SSL_get_error| returns |SSL_ERROR_HANDBACK|. It is set by
2412
- // |SSL_apply_handoff|.
2125
+ // `SSL_get_error` returns `SSL_ERROR_HANDBACK`. It is set by
2126
+ // `SSL_apply_handoff`.
2413
2127
  bool handback : 1;
2414
2128
 
2415
- // hints_requested indicates the caller has requested handshake hints. Only
2416
- // the first round-trip of the handshake will complete, after which the
2417
- // |hints| structure can be serialized.
2418
- bool hints_requested : 1;
2419
-
2420
- // cert_compression_negotiated is true iff |cert_compression_alg_id| is valid.
2129
+ // cert_compression_negotiated is true iff `cert_compression_alg_id` is valid.
2421
2130
  bool cert_compression_negotiated : 1;
2422
2131
 
2423
2132
  // apply_jdk11_workaround is true if the peer is probably a JDK 11 client
@@ -2451,10 +2160,6 @@ struct SSL_HANDSHAKE {
2451
2160
  // record layer.
2452
2161
  uint16_t early_data_read = 0;
2453
2162
 
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
2163
  // signature_algorithm is the signature algorithm to be used in signing with
2459
2164
  // the selected credential, or zero if not applicable or not yet selected.
2460
2165
  uint16_t signature_algorithm = 0;
@@ -2479,6 +2184,29 @@ struct SSL_HANDSHAKE {
2479
2184
 
2480
2185
  // pake_verifier is the PAKE context for a server.
2481
2186
  UniquePtr<spake2plus::Verifier> pake_verifier;
2187
+
2188
+ // offered_client_cert_types, for a client, is a list of client certificate
2189
+ // types (`TLSEXT_cert_type_*` values) that were sent in the
2190
+ // client_certificate_type extension in the ClientHello.
2191
+ InplaceVector<uint8_t, kNumCertTypes> offered_client_cert_types;
2192
+
2193
+ // peer_cert_type, is the cert type expected from the peer in this handshake,
2194
+ // negotiated based on server_certificate_type extensions (for a client) or
2195
+ // client_certificate_type extensions (for a server), or set to X.509
2196
+ // certificates by default (if the peer didn't send the extension).
2197
+ // This is not used in resumption.
2198
+ uint8_t peer_cert_type = kDefaultCertType;
2199
+
2200
+ // client_cert_type, for a client, is the cert type for this side of the
2201
+ // handshake to present to the peer (server) in a Certificate message,
2202
+ // negotiated based on client_certificate_type extensions.
2203
+ // This is not used in resumption.
2204
+ uint8_t client_cert_type = kDefaultCertType;
2205
+
2206
+ // client_requested_server_cert_padding_size, for a server, is the number of
2207
+ // bytes that the client requested we send, or nullopt if the client did not
2208
+ // request any padding.
2209
+ std::optional<uint16_t> client_requested_server_padding_size;
2482
2210
  };
2483
2211
 
2484
2212
  // kMaxTickets is the maximum number of tickets to send immediately after the
@@ -2486,18 +2214,18 @@ struct SSL_HANDSHAKE {
2486
2214
  // so many tickets.
2487
2215
  constexpr size_t kMaxTickets = 16;
2488
2216
 
2489
- UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSL *ssl);
2217
+ UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSLImpl *ssl);
2490
2218
 
2491
- // ssl_check_message_type checks if |msg| has type |type|. If so it returns
2219
+ // ssl_check_message_type checks if `msg` has type `type`. If so it returns
2492
2220
  // one. Otherwise, it sends an alert and returns zero.
2493
- bool ssl_check_message_type(SSL *ssl, const SSLMessage &msg, int type);
2221
+ bool ssl_check_message_type(SSLImpl *ssl, const SSLMessage &msg, int type);
2494
2222
 
2495
2223
  // ssl_run_handshake runs the TLS handshake. It returns one on success and <= 0
2496
- // on error. It sets |out_early_return| to one if we've completed the handshake
2224
+ // on error. It sets `out_early_return` to one if we've completed the handshake
2497
2225
  // early.
2498
2226
  int ssl_run_handshake(SSL_HANDSHAKE *hs, bool *out_early_return);
2499
2227
 
2500
- // The following are implementations of |do_handshake| for the client and
2228
+ // The following are implementations of `do_handshake` for the client and
2501
2229
  // server.
2502
2230
  enum ssl_hs_wait_t ssl_client_handshake(SSL_HANDSHAKE *hs);
2503
2231
  enum ssl_hs_wait_t ssl_server_handshake(SSL_HANDSHAKE *hs);
@@ -2511,47 +2239,63 @@ const char *ssl_server_handshake_state(SSL_HANDSHAKE *hs);
2511
2239
  const char *tls13_client_handshake_state(SSL_HANDSHAKE *hs);
2512
2240
  const char *tls13_server_handshake_state(SSL_HANDSHAKE *hs);
2513
2241
 
2514
- // tls13_add_key_update queues a KeyUpdate message on |ssl|. |request_type| must
2515
- // be one of |SSL_KEY_UPDATE_REQUESTED| or |SSL_KEY_UPDATE_NOT_REQUESTED|.
2516
- bool tls13_add_key_update(SSL *ssl, int request_type);
2242
+ // tls13_add_key_update queues a KeyUpdate message on `ssl`. `request_type` must
2243
+ // be one of `SSL_KEY_UPDATE_REQUESTED` or `SSL_KEY_UPDATE_NOT_REQUESTED`.
2244
+ bool tls13_add_key_update(SSLImpl *ssl, int request_type);
2517
2245
 
2518
2246
  // tls13_post_handshake processes a post-handshake message. It returns true on
2519
2247
  // success and false on failure.
2520
- bool tls13_post_handshake(SSL *ssl, const SSLMessage &msg);
2248
+ bool tls13_post_handshake(SSLImpl *ssl, const SSLMessage &msg);
2521
2249
 
2522
2250
  bool tls13_process_certificate(SSL_HANDSHAKE *hs, const SSLMessage &msg,
2523
2251
  bool allow_anonymous);
2524
2252
  bool tls13_process_certificate_verify(SSL_HANDSHAKE *hs, const SSLMessage &msg);
2525
2253
 
2526
- // tls13_process_finished processes |msg| as a Finished message from the
2527
- // peer. If |use_saved_value| is true, the verify_data is compared against
2528
- // |hs->expected_client_finished| rather than computed fresh.
2254
+ // tls13_process_finished processes `msg` as a Finished message from the
2255
+ // peer. If `use_saved_value` is true, the verify_data is compared against
2256
+ // `hs->expected_client_finished` rather than computed fresh.
2529
2257
  bool tls13_process_finished(SSL_HANDSHAKE *hs, const SSLMessage &msg,
2530
2258
  bool use_saved_value);
2531
2259
 
2532
2260
  bool tls13_add_certificate(SSL_HANDSHAKE *hs);
2533
2261
 
2534
2262
  // tls13_add_certificate_verify adds a TLS 1.3 CertificateVerify message to the
2535
- // handshake. If it returns |ssl_private_key_retry|, it should be called again
2263
+ // handshake. If it returns `ssl_private_key_retry`, it should be called again
2536
2264
  // to retry when the signing operation is completed.
2537
2265
  enum ssl_private_key_result_t tls13_add_certificate_verify(SSL_HANDSHAKE *hs);
2538
2266
 
2539
2267
  bool tls13_add_finished(SSL_HANDSHAKE *hs);
2540
- bool tls13_process_new_session_ticket(SSL *ssl, const SSLMessage &msg);
2541
- bssl::UniquePtr<SSL_SESSION> tls13_create_session_with_ticket(SSL *ssl,
2542
- CBS *body);
2268
+ bool tls13_process_new_session_ticket(SSLImpl *ssl, const SSLMessage &msg);
2269
+ UniquePtr<SSLSession> tls13_create_session_with_ticket(SSLImpl *ssl, CBS *body);
2543
2270
 
2544
2271
  // ssl_setup_extension_permutation computes a ClientHello extension permutation
2545
- // for |hs|, if applicable. It returns true on success and false on error.
2272
+ // for `hs`, if applicable. It returns true on success and false on error.
2546
2273
  bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs);
2547
2274
 
2548
- // ssl_setup_key_shares computes client key shares and saves them in |hs|. It
2549
- // returns true on success and false on failure. If |override_group_id| is zero,
2550
- // it offers the default groups, including GREASE. If it is non-zero, it offers
2551
- // a single key share of the specified group.
2275
+ // ssl_setup_pre_shared_keys computes the offered client PSKs and saves them in
2276
+ // `hs`. It returns true on success and false on failure.
2277
+ bool ssl_setup_pre_shared_keys(SSL_HANDSHAKE *hs);
2278
+
2279
+ // ssl_setup_key_shares computes client key shares and saves them in `hs`. It
2280
+ // returns true on success and false on failure. In order of precedence:
2281
+ //
2282
+ // - If `override_group_id` is non-zero, it offers a single key share of the
2283
+ // specified group.
2284
+ //
2285
+ // - If a group can be predicted on the basis of a server hint set via
2286
+ // `SSL_set1_server_supported_groups_hint`, a single key share of that group
2287
+ // is sent.
2288
+ //
2289
+ // - If any number of key shares (including zero) were previously specified by
2290
+ // the caller via `SSL_set1_client_key_shares`, those are used.
2291
+ //
2292
+ // - Otherwise, it selects the first supported group and may select a second if
2293
+ // at most one of the two is a post-quantum group.
2294
+ //
2295
+ // GREASE will be included if enabled, when `override_group_id` is zero.
2552
2296
  bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id);
2553
2297
 
2554
- // ssl_setup_pake_shares computes the client PAKE shares and saves them in |hs|.
2298
+ // ssl_setup_pake_shares computes the client PAKE shares and saves them in `hs`.
2555
2299
  // It returns true on success and false on failure.
2556
2300
  bool ssl_setup_pake_shares(SSL_HANDSHAKE *hs);
2557
2301
 
@@ -2569,22 +2313,43 @@ bool ssl_ext_pake_parse_serverhello(SSL_HANDSHAKE *hs,
2569
2313
  Array<uint8_t> *out_secret,
2570
2314
  uint8_t *out_alert, CBS *contents);
2571
2315
 
2572
- bool ssl_ext_pre_shared_key_parse_serverhello(SSL_HANDSHAKE *hs,
2573
- uint8_t *out_alert,
2574
- CBS *contents);
2575
- bool ssl_ext_pre_shared_key_parse_clienthello(
2576
- SSL_HANDSHAKE *hs, CBS *out_ticket, CBS *out_binders,
2577
- uint32_t *out_obfuscated_ticket_age, uint8_t *out_alert,
2578
- const SSL_CLIENT_HELLO *client_hello, CBS *contents);
2316
+ struct SSLOfferedPSK {
2317
+ CBS identity, binder;
2318
+ uint32_t obfuscated_ticket_age;
2319
+ };
2320
+
2321
+ struct SSLOfferedPSKs {
2322
+ CBS identities, binders;
2323
+ std::optional<SSLOfferedPSK> Next();
2324
+ };
2325
+
2326
+ const SSLPreSharedKey *ssl_ext_pre_shared_key_parse_serverhello(
2327
+ SSL_HANDSHAKE *hs, uint8_t *out_alert, CBS *contents);
2328
+ std::optional<SSLOfferedPSKs> ssl_ext_pre_shared_key_parse_clienthello(
2329
+ SSL_HANDSHAKE *hs, uint8_t *out_alert, const SSL_CLIENT_HELLO *client_hello,
2330
+ CBS *contents);
2331
+
2332
+ // ssl_verify_psk_binder verifies `client_hello` has a valid binder for `psk`.
2333
+ // The binder is computed with `client_hello` and `hs`'s transcript, which
2334
+ // should not have `client_hello` in it. On success, it returns true. Otherwise,
2335
+ // it returns false and sets `*out_alert` to an alert to send.
2336
+ //
2337
+ // This function additionally saves the index where `psk` was found in `hs`. It
2338
+ // must be called before `ssl_ext_pre_shared_key_add_serverhello`.
2339
+ bool ssl_verify_psk_binder(SSL_HANDSHAKE *hs, uint8_t *out_alert,
2340
+ const SSLPreSharedKey &psk,
2341
+ const SSL_CLIENT_HELLO &client_hello);
2342
+
2579
2343
  bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
2580
2344
 
2581
- // ssl_is_sct_list_valid does a shallow parse of the SCT list in |contents| and
2345
+
2346
+ // ssl_is_sct_list_valid does a shallow parse of the SCT list in `contents` and
2582
2347
  // returns whether it's valid.
2583
2348
  bool ssl_is_sct_list_valid(const CBS *contents);
2584
2349
 
2585
- // ssl_write_client_hello_without_extensions writes a ClientHello to |out|,
2586
- // up to the extensions field. |type| determines the type of ClientHello to
2587
- // write. If |omit_session_id| is true, the session ID is empty.
2350
+ // ssl_write_client_hello_without_extensions writes a ClientHello to `out`,
2351
+ // up to the extensions field. `type` determines the type of ClientHello to
2352
+ // write. If `omit_session_id` is true, the session ID is empty.
2588
2353
  bool ssl_write_client_hello_without_extensions(const SSL_HANDSHAKE *hs,
2589
2354
  CBB *cbb,
2590
2355
  ssl_client_hello_type_t type,
@@ -2604,9 +2369,9 @@ struct ParsedServerHello {
2604
2369
  CBS extensions;
2605
2370
  };
2606
2371
 
2607
- // ssl_parse_server_hello parses |msg| as a ServerHello. On success, it writes
2608
- // the result to |*out| and returns true. Otherwise, it returns false and sets
2609
- // |*out_alert| to an alert to send to the peer.
2372
+ // ssl_parse_server_hello parses `msg` as a ServerHello. On success, it writes
2373
+ // the result to `*out` and returns true. Otherwise, it returns false and sets
2374
+ // `*out_alert` to an alert to send to the peer.
2610
2375
  bool ssl_parse_server_hello(ParsedServerHello *out, uint8_t *out_alert,
2611
2376
  const SSLMessage &msg);
2612
2377
 
@@ -2617,34 +2382,34 @@ enum ssl_cert_verify_context_t {
2617
2382
  };
2618
2383
 
2619
2384
  // tls13_get_cert_verify_signature_input generates the message to be signed for
2620
- // TLS 1.3's CertificateVerify message. |cert_verify_context| determines the
2621
- // type of signature. It sets |*out| to a newly allocated buffer containing the
2385
+ // TLS 1.3's CertificateVerify message. `cert_verify_context` determines the
2386
+ // type of signature. It sets `*out` to a newly allocated buffer containing the
2622
2387
  // result. This function returns true on success and false on failure.
2623
2388
  bool tls13_get_cert_verify_signature_input(
2624
2389
  SSL_HANDSHAKE *hs, Array<uint8_t> *out,
2625
2390
  enum ssl_cert_verify_context_t cert_verify_context);
2626
2391
 
2627
- // ssl_is_valid_alpn_list returns whether |in| is a valid ALPN protocol list.
2392
+ // ssl_is_valid_alpn_list returns whether `in` is a valid ALPN protocol list.
2628
2393
  bool ssl_is_valid_alpn_list(Span<const uint8_t> in);
2629
2394
 
2630
- // ssl_is_alpn_protocol_allowed returns whether |protocol| is a valid server
2631
- // selection for |hs->ssl|'s client preferences.
2395
+ // ssl_is_alpn_protocol_allowed returns whether `protocol` is a valid server
2396
+ // selection for `hs->ssl`'s client preferences.
2632
2397
  bool ssl_is_alpn_protocol_allowed(const SSL_HANDSHAKE *hs,
2633
2398
  Span<const uint8_t> protocol);
2634
2399
 
2635
- // ssl_alpn_list_contains_protocol returns whether |list|, a serialized ALPN
2636
- // protocol list, contains |protocol|.
2400
+ // ssl_alpn_list_contains_protocol returns whether `list`, a serialized ALPN
2401
+ // protocol list, contains `protocol`.
2637
2402
  bool ssl_alpn_list_contains_protocol(Span<const uint8_t> list,
2638
2403
  Span<const uint8_t> protocol);
2639
2404
 
2640
2405
  // ssl_negotiate_alpn negotiates the ALPN extension, if applicable. It returns
2641
2406
  // true on successful negotiation or if nothing was negotiated. It returns false
2642
- // and sets |*out_alert| to an alert on error.
2407
+ // and sets `*out_alert` to an alert on error.
2643
2408
  bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
2644
2409
  const SSL_CLIENT_HELLO *client_hello);
2645
2410
 
2646
2411
  // ssl_get_local_application_settings looks up the configured ALPS value for
2647
- // |protocol|. If found, it sets |*out_settings| to the value and returns true.
2412
+ // `protocol`. If found, it sets `*out_settings` to the value and returns true.
2648
2413
  // Otherwise, it returns false.
2649
2414
  bool ssl_get_local_application_settings(const SSL_HANDSHAKE *hs,
2650
2415
  Span<const uint8_t> *out_settings,
@@ -2652,11 +2417,11 @@ bool ssl_get_local_application_settings(const SSL_HANDSHAKE *hs,
2652
2417
 
2653
2418
  // ssl_negotiate_alps negotiates the ALPS extension, if applicable. It returns
2654
2419
  // true on successful negotiation or if nothing was negotiated. It returns false
2655
- // and sets |*out_alert| to an alert on error.
2420
+ // and sets `*out_alert` to an alert on error.
2656
2421
  bool ssl_negotiate_alps(SSL_HANDSHAKE *hs, uint8_t *out_alert,
2657
2422
  const SSL_CLIENT_HELLO *client_hello);
2658
2423
 
2659
- // ssl_is_valid_trust_anchor_list returns whether |in| is a valid trust anchor
2424
+ // ssl_is_valid_trust_anchor_list returns whether `in` is a valid trust anchor
2660
2425
  // identifiers list.
2661
2426
  bool ssl_is_valid_trust_anchor_list(Span<const uint8_t> in);
2662
2427
 
@@ -2672,18 +2437,18 @@ struct SSLExtension {
2672
2437
  CBS data;
2673
2438
  };
2674
2439
 
2675
- // ssl_parse_extensions parses a TLS extensions block out of |cbs| and advances
2676
- // it. It writes the parsed extensions to pointers in |extensions|. On success,
2677
- // it fills in the |present| and |data| fields and returns true. Otherwise, it
2678
- // sets |*out_alert| to an alert to send and returns false. Unknown extensions
2679
- // are rejected unless |ignore_unknown| is true.
2440
+ // ssl_parse_extensions parses a TLS extensions block out of `cbs` and advances
2441
+ // it. It writes the parsed extensions to pointers in `extensions`. On success,
2442
+ // it fills in the `present` and `data` fields and returns true. Otherwise, it
2443
+ // sets `*out_alert` to an alert to send and returns false. Unknown extensions
2444
+ // are rejected unless `ignore_unknown` is true.
2680
2445
  bool ssl_parse_extensions(const CBS *cbs, uint8_t *out_alert,
2681
2446
  std::initializer_list<SSLExtension *> extensions,
2682
2447
  bool ignore_unknown);
2683
2448
 
2684
- // ssl_verify_peer_cert verifies the peer certificate for |hs|.
2449
+ // ssl_verify_peer_cert verifies the peer certificate for `hs`.
2685
2450
  enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs);
2686
- // ssl_reverify_peer_cert verifies the peer certificate for |hs| when resuming a
2451
+ // ssl_reverify_peer_cert verifies the peer certificate for `hs` when resuming a
2687
2452
  // session.
2688
2453
  enum ssl_verify_result_t ssl_reverify_peer_cert(SSL_HANDSHAKE *hs,
2689
2454
  bool send_alert);
@@ -2698,14 +2463,20 @@ bool ssl_send_finished(SSL_HANDSHAKE *hs);
2698
2463
  // flight of messages. It returns true on success and false on error.
2699
2464
  bool ssl_send_tls12_certificate(SSL_HANDSHAKE *hs);
2700
2465
 
2701
- // ssl_handshake_session returns the |SSL_SESSION| corresponding to the current
2466
+ // ssl_handshake_session returns the `SSL_SESSION` corresponding to the current
2702
2467
  // handshake. Note, in TLS 1.2 resumptions, this session is immutable.
2703
- const SSL_SESSION *ssl_handshake_session(const SSL_HANDSHAKE *hs);
2468
+ const SSLSession *ssl_handshake_session(const SSL_HANDSHAKE *hs);
2704
2469
 
2705
2470
  // ssl_done_writing_client_hello is called after the last ClientHello is written
2706
- // by |hs|. It releases some memory that is no longer needed.
2471
+ // by `hs`. It releases some memory that is no longer needed.
2707
2472
  void ssl_done_writing_client_hello(SSL_HANDSHAKE *hs);
2708
2473
 
2474
+ // ssl_accepts_server_certificate_auth returns whether `hs`, which must be a
2475
+ // client, accepts certificate-based authentication. If it returns false, the
2476
+ // client should not send certificate-related extensions, and should not accept
2477
+ // server responses that result in a certificate-based flow.
2478
+ bool ssl_accepts_server_certificate_auth(const SSL_HANDSHAKE *hs);
2479
+
2709
2480
 
2710
2481
  // Flags.
2711
2482
 
@@ -2718,27 +2489,27 @@ using SSLFlags = uint32_t;
2718
2489
  inline constexpr SSLFlags kSSLFlagResumptionAcrossNames = 1 << 8;
2719
2490
 
2720
2491
  // ssl_add_flags_extension encodes a tls_flags extension (including the header)
2721
- // containing the flags in |flags|. It returns true on success and false on
2722
- // error. If |flags| is zero (no flags set), it returns true without adding
2723
- // anything to |cbb|.
2492
+ // containing the flags in `flags`. It returns true on success and false on
2493
+ // error. If `flags` is zero (no flags set), it returns true without adding
2494
+ // anything to `cbb`.
2724
2495
  bool ssl_add_flags_extension(CBB *cbb, SSLFlags flags);
2725
2496
 
2726
2497
  // ssl_parse_flags_extension_request parses tls_flags extension value (excluding
2727
- // the header) from |cbs|, for a request message (ClientHello,
2498
+ // the header) from `cbs`, for a request message (ClientHello,
2728
2499
  // CertificateRequest, or NewSessionTicket). Unrecognized flags will be ignored.
2729
2500
  //
2730
- // On success, it sets |*out| to the parsed flags and returns true. On error, it
2731
- // sets |*out_alert| to a TLS alert and returns false.
2501
+ // On success, it sets `*out` to the parsed flags and returns true. On error, it
2502
+ // sets `*out_alert` to a TLS alert and returns false.
2732
2503
  bool ssl_parse_flags_extension_request(const CBS *cbs, SSLFlags *out,
2733
2504
  uint8_t *out_alert);
2734
2505
 
2735
2506
  // ssl_parse_flags_extension_response parses tls_flags extension value
2736
- // (excluding the header) from |cbs|, for a response message (HelloRetryRequest,
2507
+ // (excluding the header) from `cbs`, for a response message (HelloRetryRequest,
2737
2508
  // ServerHello, EncryptedExtensions, or Certificate). Only the flags in
2738
- // |allowed_flags| may be present.
2509
+ // `allowed_flags` may be present.
2739
2510
  //
2740
- // On success, it sets |*out| to the parsed flags and returns true. On error, it
2741
- // sets |*out_alert| to a TLS alert and returns false.
2511
+ // On success, it sets `*out` to the parsed flags and returns true. On error, it
2512
+ // sets `*out_alert` to a TLS alert and returns false.
2742
2513
  bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
2743
2514
  uint8_t *out_alert,
2744
2515
  SSLFlags allowed_flags);
@@ -2746,15 +2517,15 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
2746
2517
 
2747
2518
  // SSLKEYLOGFILE functions.
2748
2519
 
2749
- // ssl_log_secret logs |secret| with label |label|, if logging is enabled for
2750
- // |ssl|. It returns true on success and false on failure.
2751
- bool ssl_log_secret(const SSL *ssl, const char *label,
2520
+ // ssl_log_secret logs `secret` with label `label`, if logging is enabled for
2521
+ // `ssl`. It returns true on success and false on failure.
2522
+ bool ssl_log_secret(const SSLImpl *ssl, const char *label,
2752
2523
  Span<const uint8_t> secret);
2753
2524
 
2754
2525
 
2755
2526
  // ClientHello functions.
2756
2527
 
2757
- bool ssl_parse_client_hello_with_trailing_data(const SSL *ssl, CBS *cbs,
2528
+ bool ssl_parse_client_hello_with_trailing_data(const SSLImpl *ssl, CBS *cbs,
2758
2529
  SSL_CLIENT_HELLO *out);
2759
2530
 
2760
2531
  bool ssl_client_hello_get_extension(const SSL_CLIENT_HELLO *client_hello,
@@ -2766,7 +2537,7 @@ bool ssl_client_cipher_list_contains_cipher(
2766
2537
 
2767
2538
  // GREASE.
2768
2539
 
2769
- // ssl_get_grease_value returns a GREASE value for |hs|. For a given
2540
+ // ssl_get_grease_value returns a GREASE value for `hs`. For a given
2770
2541
  // connection, the values for each index will be deterministic. This allows the
2771
2542
  // same ClientHello be sent twice for a HelloRetryRequest or the same group be
2772
2543
  // advertised in both supported_groups and key_shares.
@@ -2776,29 +2547,29 @@ uint16_t ssl_get_grease_value(const SSL_HANDSHAKE *hs,
2776
2547
 
2777
2548
  // Signature algorithms.
2778
2549
 
2779
- // tls1_parse_peer_sigalgs parses |sigalgs| as the list of peer signature
2780
- // algorithms and saves them on |hs|. It returns true on success and false on
2550
+ // tls1_parse_peer_sigalgs parses `sigalgs` as the list of peer signature
2551
+ // algorithms and saves them on `hs`. It returns true on success and false on
2781
2552
  // error.
2782
2553
  bool tls1_parse_peer_sigalgs(SSL_HANDSHAKE *hs, const CBS *sigalgs);
2783
2554
 
2784
- // tls1_get_legacy_signature_algorithm sets |*out| to the signature algorithm
2785
- // that should be used with |pkey| in TLS 1.1 and earlier. It returns true on
2786
- // success and false if |pkey| may not be used at those versions.
2555
+ // tls1_get_legacy_signature_algorithm sets `*out` to the signature algorithm
2556
+ // that should be used with `pkey` in TLS 1.1 and earlier. It returns true on
2557
+ // success and false if `pkey` may not be used at those versions.
2787
2558
  bool tls1_get_legacy_signature_algorithm(uint16_t *out, const EVP_PKEY *pkey);
2788
2559
 
2789
- // tls1_choose_signature_algorithm sets |*out| to a signature algorithm for use
2790
- // with |cred| based on the peer's preferences and the algorithms supported. It
2560
+ // tls1_choose_signature_algorithm sets `*out` to a signature algorithm for use
2561
+ // with `cred` based on the peer's preferences and the algorithms supported. It
2791
2562
  // returns true on success and false on error.
2792
2563
  bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
2793
- const SSL_CREDENTIAL *cred, uint16_t *out);
2564
+ const SSLCredential *cred, uint16_t *out);
2794
2565
 
2795
2566
  // tls12_add_verify_sigalgs adds the signature algorithms acceptable for the
2796
- // peer signature to |out|. It returns true on success and false on error.
2567
+ // peer signature to `out`. It returns true on success and false on error.
2797
2568
  bool tls12_add_verify_sigalgs(const SSL_HANDSHAKE *hs, CBB *out);
2798
2569
 
2799
- // tls12_check_peer_sigalg checks if |sigalg| is acceptable for the peer
2800
- // signature from |pkey|. It returns true on success and false on error, setting
2801
- // |*out_alert| to an alert to send.
2570
+ // tls12_check_peer_sigalg checks if `sigalg` is acceptable for the peer
2571
+ // signature from `pkey`. It returns true on success and false on error, setting
2572
+ // `*out_alert` to an alert to send.
2802
2573
  bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
2803
2574
  uint16_t sigalg, EVP_PKEY *pkey);
2804
2575
 
@@ -2812,6 +2583,29 @@ bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
2812
2583
  // From RFC 4492, used in encoding the curve type in ECParameters
2813
2584
  #define NAMED_CURVE_TYPE 3
2814
2585
 
2586
+ struct CertCb {
2587
+ using OldCallback = int (*)(SSL *ssl, void *arg);
2588
+ using NewCallback = int (*)(SSL *ssl, void *arg, uint8_t *out_alert);
2589
+
2590
+ std::variant<std::monostate, OldCallback, NewCallback> cb;
2591
+
2592
+ explicit operator bool() const {
2593
+ return !std::holds_alternative<std::monostate>(cb);
2594
+ }
2595
+
2596
+ int operator()(SSL *ssl, void *arg, uint8_t *out_alert) const {
2597
+ switch (cb.index()) {
2598
+ default:
2599
+ case 0:
2600
+ return 0;
2601
+ case 1:
2602
+ return std::get<1>(cb)(ssl, arg);
2603
+ case 2:
2604
+ return std::get<2>(cb)(ssl, arg, out_alert);
2605
+ }
2606
+ }
2607
+ };
2608
+
2815
2609
  struct CERT {
2816
2610
  static constexpr bool kAllowUniquePtr = true;
2817
2611
 
@@ -2822,30 +2616,34 @@ struct CERT {
2822
2616
 
2823
2617
  // credentials is the list of credentials to select between. Elements of this
2824
2618
  // array immutable.
2825
- Vector<UniquePtr<SSL_CREDENTIAL>> credentials;
2619
+ Vector<UniquePtr<SSLCredential>> credentials;
2826
2620
 
2827
2621
  // legacy_credential is the credential configured by the legacy
2828
2622
  // non-credential-based APIs. If IsComplete() returns true, it is appended to
2829
2623
  // the list of credentials.
2830
- UniquePtr<SSL_CREDENTIAL> legacy_credential;
2624
+ UniquePtr<SSLCredential> legacy_credential;
2625
+
2626
+ // available_trust_anchors, if not empty, overrides the default list of
2627
+ // available trust anchors to send in EncryptedExtensions.
2628
+ Array<uint8_t> available_trust_anchors;
2831
2629
 
2832
- // x509_method contains pointers to functions that might deal with |X509|
2630
+ // x509_method contains pointers to functions that might deal with `X509`
2833
2631
  // compatibility, or might be a no-op, depending on the application.
2834
2632
  const SSL_X509_METHOD *x509_method = nullptr;
2835
2633
 
2836
- // x509_chain may contain a parsed copy of |chain[1..]| from the legacy
2634
+ // x509_chain may contain a parsed copy of `chain[1..]` from the legacy
2837
2635
  // credential. This is only used as a cache in order to implement “get0”
2838
2636
  // functions that return a non-owning pointer to the certificate chain.
2839
2637
  STACK_OF(X509) *x509_chain = nullptr;
2840
2638
 
2841
- // x509_leaf may contain a parsed copy of the first element of |chain| from
2639
+ // x509_leaf may contain a parsed copy of the first element of `chain` from
2842
2640
  // the legacy credential. This is only used as a cache in order to implement
2843
2641
  // “get0” functions that return a non-owning pointer to the certificate chain.
2844
2642
  X509 *x509_leaf = nullptr;
2845
2643
 
2846
- // x509_stash contains the last |X509| object append to the legacy
2644
+ // x509_stash contains the last `X509` object append to the legacy
2847
2645
  // credential's chain. This is a workaround for some third-party code that
2848
- // continue to use an |X509| object even after passing ownership with an
2646
+ // continue to use an `X509` object even after passing ownership with an
2849
2647
  // “add0” function.
2850
2648
  X509 *x509_stash = nullptr;
2851
2649
 
@@ -2855,7 +2653,7 @@ struct CERT {
2855
2653
  // certificates required. This allows advanced applications
2856
2654
  // to select certificates on the fly: for example based on
2857
2655
  // supported signature algorithms or curves.
2858
- int (*cert_cb)(SSL *ssl, void *arg) = nullptr;
2656
+ CertCb cert_cb = {};
2859
2657
  void *cert_cb_arg = nullptr;
2860
2658
 
2861
2659
  // Optional X509_STORE for certificate validation. If NULL the parent SSL_CTX
@@ -2867,109 +2665,110 @@ struct CERT {
2867
2665
  InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
2868
2666
  };
2869
2667
 
2870
- // |SSL_PROTOCOL_METHOD| abstracts between TLS and DTLS.
2668
+ // `SSL_PROTOCOL_METHOD` abstracts between TLS and DTLS.
2871
2669
  struct SSL_PROTOCOL_METHOD {
2872
2670
  bool is_dtls;
2873
- bool (*ssl_new)(SSL *ssl);
2874
- void (*ssl_free)(SSL *ssl);
2875
- // get_message sets |*out| to the current handshake message and returns true
2671
+ bool (*ssl_new)(SSLImpl *ssl);
2672
+ void (*ssl_free)(SSLImpl *ssl);
2673
+ // get_message sets `*out` to the current handshake message and returns true
2876
2674
  // if one has been received. It returns false if more input is needed.
2877
- bool (*get_message)(const SSL *ssl, SSLMessage *out);
2675
+ bool (*get_message)(const SSLImpl *ssl, SSLMessage *out);
2878
2676
  // next_message is called to release the current handshake message.
2879
- void (*next_message)(SSL *ssl);
2677
+ void (*next_message)(SSLImpl *ssl);
2880
2678
  // has_unprocessed_handshake_data returns whether there is buffered
2881
- // handshake data that has not been consumed by |get_message|.
2882
- bool (*has_unprocessed_handshake_data)(const SSL *ssl);
2883
- // Use the |ssl_open_handshake| wrapper.
2884
- ssl_open_record_t (*open_handshake)(SSL *ssl, size_t *out_consumed,
2679
+ // handshake data that has not been consumed by `get_message`.
2680
+ bool (*has_unprocessed_handshake_data)(const SSLImpl *ssl);
2681
+ // Use the `ssl_open_handshake` wrapper.
2682
+ ssl_open_record_t (*open_handshake)(SSLImpl *ssl, size_t *out_consumed,
2885
2683
  uint8_t *out_alert, Span<uint8_t> in);
2886
- // Use the |ssl_open_change_cipher_spec| wrapper.
2887
- ssl_open_record_t (*open_change_cipher_spec)(SSL *ssl, size_t *out_consumed,
2684
+ // Use the `ssl_open_change_cipher_spec` wrapper.
2685
+ ssl_open_record_t (*open_change_cipher_spec)(SSLImpl *ssl,
2686
+ size_t *out_consumed,
2888
2687
  uint8_t *out_alert,
2889
2688
  Span<uint8_t> in);
2890
- // Use the |ssl_open_app_data| wrapper.
2891
- ssl_open_record_t (*open_app_data)(SSL *ssl, Span<uint8_t> *out,
2689
+ // Use the `ssl_open_app_data` wrapper.
2690
+ ssl_open_record_t (*open_app_data)(SSLImpl *ssl, Span<uint8_t> *out,
2892
2691
  size_t *out_consumed, uint8_t *out_alert,
2893
2692
  Span<uint8_t> in);
2894
- // write_app_data encrypts and writes |in| as application data. On success, it
2895
- // returns one and sets |*out_bytes_written| to the number of bytes of |in|
2896
- // written. Otherwise, it returns <= 0 and sets |*out_needs_handshake| to
2693
+ // write_app_data encrypts and writes `in` as application data. On success, it
2694
+ // returns one and sets `*out_bytes_written` to the number of bytes of `in`
2695
+ // written. Otherwise, it returns <= 0 and sets `*out_needs_handshake` to
2897
2696
  // whether the operation failed because the caller needs to drive the
2898
2697
  // handshake.
2899
- int (*write_app_data)(SSL *ssl, bool *out_needs_handshake,
2698
+ int (*write_app_data)(SSLImpl *ssl, bool *out_needs_handshake,
2900
2699
  size_t *out_bytes_written, Span<const uint8_t> in);
2901
- int (*dispatch_alert)(SSL *ssl);
2902
- // init_message begins a new handshake message of type |type|. |cbb| is the
2903
- // root CBB to be passed into |finish_message|. |*body| is set to a child CBB
2700
+ int (*dispatch_alert)(SSLImpl *ssl);
2701
+ // init_message begins a new handshake message of type `type`. `cbb` is the
2702
+ // root CBB to be passed into `finish_message`. `*body` is set to a child CBB
2904
2703
  // the caller should write to. It returns true on success and false on error.
2905
- bool (*init_message)(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2906
- // finish_message finishes a handshake message. It sets |*out_msg| to the
2704
+ bool (*init_message)(const SSLImpl *ssl, CBB *cbb, CBB *body, uint8_t type);
2705
+ // finish_message finishes a handshake message. It sets `*out_msg` to the
2907
2706
  // 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);
2707
+ bool (*finish_message)(const SSLImpl *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2910
2708
  // add_message adds a handshake message to the pending flight. It returns
2911
2709
  // true on success and false on error.
2912
- bool (*add_message)(SSL *ssl, bssl::Array<uint8_t> msg);
2710
+ bool (*add_message)(SSLImpl *ssl, Array<uint8_t> msg);
2913
2711
  // add_change_cipher_spec adds a ChangeCipherSpec record to the pending
2914
2712
  // flight. It returns true on success and false on error.
2915
- bool (*add_change_cipher_spec)(SSL *ssl);
2713
+ bool (*add_change_cipher_spec)(SSLImpl *ssl);
2916
2714
  // finish_flight marks the pending flight as finished and ready to send.
2917
- // |flush| must be called to write it.
2918
- void (*finish_flight)(SSL *ssl);
2715
+ // `flush` must be called to write it.
2716
+ void (*finish_flight)(SSLImpl *ssl);
2919
2717
  // schedule_ack schedules a DTLS 1.3 ACK to be sent, without an ACK delay.
2920
- // |flush| must be called to write it.
2921
- void (*schedule_ack)(SSL *ssl);
2718
+ // `flush` must be called to write it.
2719
+ void (*schedule_ack)(SSLImpl *ssl);
2922
2720
  // flush writes any scheduled data to the transport. It returns one on success
2923
2721
  // and <= 0 on error.
2924
- int (*flush)(SSL *ssl);
2722
+ int (*flush)(SSLImpl *ssl);
2925
2723
  // on_handshake_complete is called when the handshake is complete.
2926
- void (*on_handshake_complete)(SSL *ssl);
2927
- // set_read_state sets |ssl|'s read cipher state and level to |aead_ctx| and
2928
- // |level|. In QUIC, |aead_ctx| is a placeholder object. In TLS 1.3,
2929
- // |traffic_secret| is the original traffic secret. This function returns true
2724
+ void (*on_handshake_complete)(SSLImpl *ssl);
2725
+ // set_read_state sets `ssl`'s read cipher state and level to `aead_ctx` and
2726
+ // `level`. In QUIC, `aead_ctx` is a placeholder object. In TLS 1.3,
2727
+ // `traffic_secret` is the original traffic secret. This function returns true
2930
2728
  // on success and false on error.
2931
2729
  //
2932
2730
  // TODO(crbug.com/371998381): Take the traffic secrets as input and let the
2933
2731
  // function create the SSLAEADContext.
2934
- bool (*set_read_state)(SSL *ssl, ssl_encryption_level_t level,
2732
+ bool (*set_read_state)(SSLImpl *ssl, ssl_encryption_level_t level,
2935
2733
  UniquePtr<SSLAEADContext> aead_ctx,
2936
2734
  Span<const uint8_t> traffic_secret);
2937
- // set_write_state sets |ssl|'s write cipher state and level to |aead_ctx| and
2938
- // |level|. In QUIC, |aead_ctx| is a placeholder object In TLS 1.3,
2939
- // |traffic_secret| is the original traffic secret. This function returns true
2735
+ // set_write_state sets `ssl`'s write cipher state and level to `aead_ctx` and
2736
+ // `level`. In QUIC, `aead_ctx` is a placeholder object In TLS 1.3,
2737
+ // `traffic_secret` is the original traffic secret. This function returns true
2940
2738
  // on success and false on error.
2941
2739
  //
2942
2740
  // TODO(crbug.com/371998381): Take the traffic secrets as input and let the
2943
2741
  // function create the SSLAEADContext.
2944
- bool (*set_write_state)(SSL *ssl, ssl_encryption_level_t level,
2742
+ bool (*set_write_state)(SSLImpl *ssl, ssl_encryption_level_t level,
2945
2743
  UniquePtr<SSLAEADContext> aead_ctx,
2946
2744
  Span<const uint8_t> traffic_secret);
2947
2745
  };
2948
2746
 
2949
- // The following wrappers call |open_*| but handle |read_shutdown| correctly.
2747
+ // The following wrappers call `open_*` but handle `read_shutdown` correctly.
2950
2748
 
2951
- // ssl_open_handshake processes a record from |in| for reading a handshake
2749
+ // ssl_open_handshake processes a record from `in` for reading a handshake
2952
2750
  // message.
2953
- ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
2751
+ ssl_open_record_t ssl_open_handshake(SSLImpl *ssl, size_t *out_consumed,
2954
2752
  uint8_t *out_alert, Span<uint8_t> in);
2955
2753
 
2956
- // ssl_open_change_cipher_spec processes a record from |in| for reading a
2754
+ // ssl_open_change_cipher_spec processes a record from `in` for reading a
2957
2755
  // ChangeCipherSpec.
2958
- ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2756
+ ssl_open_record_t ssl_open_change_cipher_spec(SSLImpl *ssl,
2757
+ size_t *out_consumed,
2959
2758
  uint8_t *out_alert,
2960
2759
  Span<uint8_t> in);
2961
2760
 
2962
- // ssl_open_app_data processes a record from |in| for reading application data.
2963
- // On success, it returns |ssl_open_record_success| and sets |*out| to the
2761
+ // ssl_open_app_data processes a record from `in` for reading application data.
2762
+ // On success, it returns `ssl_open_record_success` and sets `*out` to the
2964
2763
  // input. If it encounters a post-handshake message, it returns
2965
- // |ssl_open_record_discard|. The caller should then retry, after processing any
2966
- // messages received with |get_message|.
2967
- ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
2764
+ // `ssl_open_record_discard`. The caller should then retry, after processing any
2765
+ // messages received with `get_message`.
2766
+ ssl_open_record_t ssl_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
2968
2767
  size_t *out_consumed, uint8_t *out_alert,
2969
2768
  Span<uint8_t> in);
2970
2769
 
2971
2770
  struct SSL_X509_METHOD {
2972
- // check_CA_list returns one if |names| is a good list of X.509 distinguished
2771
+ // check_CA_list returns one if `names` is a good list of X.509 distinguished
2973
2772
  // names and zero otherwise. This is used to ensure that we can reject
2974
2773
  // unparsable values at handshake time when using crypto/x509.
2975
2774
  bool (*check_CA_list)(STACK_OF(CRYPTO_BUFFER) *names);
@@ -2978,57 +2777,57 @@ struct SSL_X509_METHOD {
2978
2777
  void (*cert_clear)(CERT *cert);
2979
2778
  // cert_free frees all X509-related state.
2980
2779
  void (*cert_free)(CERT *cert);
2981
- // cert_flush_cached_chain drops any cached |X509|-based certificate chain
2982
- // from |cert|.
2983
- // cert_dup duplicates any needed fields from |cert| to |new_cert|.
2780
+ // cert_flush_cached_chain drops any cached `X509`-based certificate chain
2781
+ // from `cert`.
2782
+ // cert_dup duplicates any needed fields from `cert` to `new_cert`.
2984
2783
  void (*cert_dup)(CERT *new_cert, const CERT *cert);
2985
2784
  void (*cert_flush_cached_chain)(CERT *cert);
2986
- // cert_flush_cached_chain drops any cached |X509|-based leaf certificate
2987
- // from |cert|.
2785
+ // cert_flush_cached_chain drops any cached `X509`-based leaf certificate
2786
+ // from `cert`.
2988
2787
  void (*cert_flush_cached_leaf)(CERT *cert);
2989
2788
 
2990
- // session_cache_objects fills out |sess->x509_peer| and |sess->x509_chain|
2991
- // from |sess->certs| and erases |sess->x509_chain_without_leaf|. It returns
2789
+ // session_cache_objects fills out `sess->x509_peer` and `sess->x509_chain`
2790
+ // from `sess->certs` and erases `sess->x509_chain_without_leaf`. It returns
2992
2791
  // true on success or false on error.
2993
- bool (*session_cache_objects)(SSL_SESSION *session);
2994
- // session_dup duplicates any needed fields from |session| to |new_session|.
2792
+ bool (*session_cache_objects)(SSLSession *session);
2793
+ // session_dup duplicates any needed fields from `session` to `new_session`.
2995
2794
  // It returns true on success or false on error.
2996
- bool (*session_dup)(SSL_SESSION *new_session, const SSL_SESSION *session);
2997
- // session_clear frees any X509-related state from |session|.
2998
- void (*session_clear)(SSL_SESSION *session);
2999
- // session_verify_cert_chain verifies the certificate chain in |session|,
3000
- // sets |session->verify_result| and returns true on success or false on
2795
+ bool (*session_dup)(SSLSession *new_session, const SSLSession *session);
2796
+ // session_clear frees any X509-related state from `session`.
2797
+ void (*session_clear)(SSLSession *session);
2798
+ // session_verify_cert_chain verifies the certificate chain in `session`,
2799
+ // sets `session->verify_result` and returns true on success or false on
3001
2800
  // error.
3002
- bool (*session_verify_cert_chain)(SSL_SESSION *session, SSL_HANDSHAKE *ssl,
2801
+ bool (*session_verify_cert_chain)(SSLSession *session, SSL_HANDSHAKE *ssl,
3003
2802
  uint8_t *out_alert);
3004
2803
 
3005
- // hs_flush_cached_ca_names drops any cached |X509_NAME|s from |hs|.
2804
+ // hs_flush_cached_ca_names drops any cached `X509_NAME`s from `hs`.
3006
2805
  void (*hs_flush_cached_ca_names)(SSL_HANDSHAKE *hs);
3007
- // ssl_new does any necessary initialisation of |hs|. It returns true on
2806
+ // ssl_new does any necessary initialisation of `hs`. It returns true on
3008
2807
  // success or false on error.
3009
2808
  bool (*ssl_new)(SSL_HANDSHAKE *hs);
3010
- // ssl_free frees anything created by |ssl_new|.
2809
+ // ssl_free frees anything created by `ssl_new`.
3011
2810
  void (*ssl_config_free)(SSL_CONFIG *cfg);
3012
- // ssl_flush_cached_client_CA drops any cached |X509_NAME|s from |ssl|.
2811
+ // ssl_flush_cached_client_CA drops any cached `X509_NAME`s from `ssl`.
3013
2812
  void (*ssl_flush_cached_client_CA)(SSL_CONFIG *cfg);
3014
2813
  // ssl_auto_chain_if_needed runs the deprecated auto-chaining logic if
3015
- // necessary. On success, it updates |ssl|'s certificate configuration as
2814
+ // necessary. On success, it updates `ssl`'s certificate configuration as
3016
2815
  // needed and returns true. Otherwise, it returns false.
3017
2816
  bool (*ssl_auto_chain_if_needed)(SSL_HANDSHAKE *hs);
3018
- // ssl_ctx_new does any necessary initialisation of |ctx|. It returns true on
2817
+ // ssl_ctx_new does any necessary initialisation of `ctx`. It returns true on
3019
2818
  // success or false on error.
3020
- bool (*ssl_ctx_new)(SSL_CTX *ctx);
3021
- // ssl_ctx_free frees anything created by |ssl_ctx_new|.
3022
- void (*ssl_ctx_free)(SSL_CTX *ctx);
3023
- // ssl_ctx_flush_cached_client_CA drops any cached |X509_NAME|s from |ctx|.
3024
- void (*ssl_ctx_flush_cached_client_CA)(SSL_CTX *ssl);
2819
+ bool (*ssl_ctx_new)(SSLContext *ctx);
2820
+ // ssl_ctx_free frees anything created by `ssl_ctx_new`.
2821
+ void (*ssl_ctx_free)(SSLContext *ctx);
2822
+ // ssl_ctx_flush_cached_client_CA drops any cached `X509_NAME`s from `ctx`.
2823
+ void (*ssl_ctx_flush_cached_client_CA)(SSLContext *ssl);
3025
2824
  };
3026
2825
 
3027
- // ssl_crypto_x509_method provides the |SSL_X509_METHOD| functions using
2826
+ // ssl_crypto_x509_method provides the `SSL_X509_METHOD` functions using
3028
2827
  // crypto/x509.
3029
2828
  extern const SSL_X509_METHOD ssl_crypto_x509_method;
3030
2829
 
3031
- // ssl_noop_x509_method provides the |SSL_X509_METHOD| functions that avoid
2830
+ // ssl_noop_x509_method provides the `SSL_X509_METHOD` functions that avoid
3032
2831
  // crypto/x509.
3033
2832
  extern const SSL_X509_METHOD ssl_noop_x509_method;
3034
2833
 
@@ -3053,12 +2852,10 @@ struct CertCompressionAlg {
3053
2852
  uint16_t alg_id = 0;
3054
2853
  };
3055
2854
 
3056
- BSSL_NAMESPACE_END
3057
-
2855
+ // TODO(crbug.com/565766495): Switch this to `SSLSession`. bssl_shim calls
2856
+ // `lh_SSL_SESSION_*` directly, so this is still defined on the public type.
3058
2857
  DEFINE_LHASH_OF(SSL_SESSION)
3059
2858
 
3060
- BSSL_NAMESPACE_BEGIN
3061
-
3062
2859
  // An ssl_shutdown_t describes the shutdown state of one end of the connection,
3063
2860
  // whether it is alive or has been shutdown via close_notify or fatal alert.
3064
2861
  enum ssl_shutdown_t {
@@ -3095,22 +2892,22 @@ struct SSL3_STATE {
3095
2892
  SSLBuffer write_buffer;
3096
2893
 
3097
2894
  // pending_app_data is the unconsumed application data. It points into
3098
- // |read_buffer|.
2895
+ // `read_buffer`.
3099
2896
  Span<uint8_t> pending_app_data;
3100
2897
 
3101
2898
  // unreported_bytes_written is the number of bytes successfully written to the
3102
- // transport, but not yet reported to the caller. The next |SSL_write| will
2899
+ // transport, but not yet reported to the caller. The next `SSL_write` will
3103
2900
  // skip this many bytes from the input. This is used if
3104
- // |SSL_MODE_ENABLE_PARTIAL_WRITE| is disabled, in which case |SSL_write| only
2901
+ // `SSL_MODE_ENABLE_PARTIAL_WRITE` is disabled, in which case `SSL_write` only
3105
2902
  // reports bytes written when the full caller input is written.
3106
2903
  size_t unreported_bytes_written = 0;
3107
2904
 
3108
- // pending_write, if |has_pending_write| is true, is the caller-supplied data
2905
+ // pending_write, if `has_pending_write` is true, is the caller-supplied data
3109
2906
  // corresponding to the current pending write. This is used to check the
3110
2907
  // caller retried with a compatible buffer.
3111
2908
  Span<const uint8_t> pending_write;
3112
2909
 
3113
- // pending_write_type, if |has_pending_write| is true, is the record type
2910
+ // pending_write_type, if `has_pending_write` is true, is the record type
3114
2911
  // for the current pending write.
3115
2912
  //
3116
2913
  // TODO(davidben): Remove this when alerts are moved out of this write path.
@@ -3122,7 +2919,7 @@ struct SSL3_STATE {
3122
2919
  // write_shutdown is the shutdown state for the write half of the connection.
3123
2920
  enum ssl_shutdown_t write_shutdown = ssl_shutdown_none;
3124
2921
 
3125
- // read_error, if |read_shutdown| is |ssl_shutdown_error|, is the error for
2922
+ // read_error, if `read_shutdown` is `ssl_shutdown_error`, is the error for
3126
2923
  // the receive half of the connection.
3127
2924
  UniquePtr<ERR_SAVE_STATE> read_error;
3128
2925
 
@@ -3139,7 +2936,7 @@ struct SSL3_STATE {
3139
2936
  // version is the protocol version, or zero if the version has not yet been
3140
2937
  // set. In clients offering 0-RTT, this version will initially be set to the
3141
2938
  // early version, then switched to the final version. To distinguish these
3142
- // cases, use |ssl_has_final_version|.
2939
+ // cases, use `ssl_has_final_version`.
3143
2940
  uint16_t version = 0;
3144
2941
 
3145
2942
  // early_data_skipped is the amount of early data that has been skipped by the
@@ -3172,7 +2969,7 @@ struct SSL3_STATE {
3172
2969
  bool is_v2_hello : 1;
3173
2970
 
3174
2971
  // has_message is true if the current handshake message has been returned
3175
- // at least once by |get_message| and false otherwise.
2972
+ // at least once by `get_message` and false otherwise.
3176
2973
  bool has_message : 1;
3177
2974
 
3178
2975
  // initial_handshake_complete is true if the initial handshake has
@@ -3185,7 +2982,7 @@ struct SSL3_STATE {
3185
2982
  bool send_connection_binding : 1;
3186
2983
 
3187
2984
  // channel_id_valid is true if, on the server, the client has negotiated a
3188
- // Channel ID and the |channel_id| field is filled in.
2985
+ // Channel ID and the `channel_id` field is filled in.
3189
2986
  bool channel_id_valid : 1;
3190
2987
 
3191
2988
  // key_update_pending is true if we are in the process of sending a KeyUpdate
@@ -3197,7 +2994,7 @@ struct SSL3_STATE {
3197
2994
  // early_data_accepted is true if early data was accepted by the server.
3198
2995
  bool early_data_accepted : 1;
3199
2996
 
3200
- // alert_dispatch is true there is an alert in |send_alert| to be sent.
2997
+ // alert_dispatch is true there is an alert in `send_alert` to be sent.
3201
2998
  bool alert_dispatch : 1;
3202
2999
 
3203
3000
  // renegotiate_pending is whether the read half of the channel is blocked on a
@@ -3208,25 +3005,25 @@ struct SSL3_STATE {
3208
3005
  // HelloRetryRequest message.
3209
3006
  bool used_hello_retry_request : 1;
3210
3007
 
3211
- // was_key_usage_invalid is whether the handshake succeeded despite using a
3212
- // TLS mode which was incompatible with the leaf certificate's keyUsage
3213
- // extension.
3214
- bool was_key_usage_invalid : 1;
3008
+ // server_sent_requested_padding is true iff a client requested padding
3009
+ // through the server padding extension, and the server sent back the
3010
+ // requested amount of padding.
3011
+ bool server_sent_requested_padding : 1;
3215
3012
 
3216
3013
  // hs_buf is the buffer of handshake data to process.
3217
3014
  UniquePtr<BUF_MEM> hs_buf;
3218
3015
 
3219
3016
  // pending_hs_data contains the pending handshake data that has not yet
3220
- // been encrypted to |pending_flight|. This allows packing the handshake into
3017
+ // been encrypted to `pending_flight`. This allows packing the handshake into
3221
3018
  // fewer records.
3222
3019
  UniquePtr<BUF_MEM> pending_hs_data;
3223
3020
 
3224
3021
  // pending_flight is the pending outgoing flight. This is used to flush each
3225
- // handshake flight in a single write. |write_buffer| must be written out
3022
+ // handshake flight in a single write. `write_buffer` must be written out
3226
3023
  // before this data.
3227
3024
  UniquePtr<BUF_MEM> pending_flight;
3228
3025
 
3229
- // pending_flight_offset is the number of bytes of |pending_flight| which have
3026
+ // pending_flight_offset is the number of bytes of `pending_flight` which have
3230
3027
  // been successfully written.
3231
3028
  uint32_t pending_flight_offset = 0;
3232
3029
 
@@ -3261,7 +3058,7 @@ struct SSL3_STATE {
3261
3058
  // established_session is the session established by the connection. This
3262
3059
  // session is only filled upon the completion of the handshake and is
3263
3060
  // immutable.
3264
- UniquePtr<SSL_SESSION> established_session;
3061
+ UniquePtr<SSLSession> established_session;
3265
3062
 
3266
3063
  // Next protocol negotiation. For the client, this is the protocol that we
3267
3064
  // sent in NextProtocol and is set when handling ServerHello extensions.
@@ -3283,7 +3080,7 @@ struct SSL3_STATE {
3283
3080
  UniquePtr<char> hostname;
3284
3081
 
3285
3082
  // For a server:
3286
- // If |channel_id_valid| is true, then this contains the
3083
+ // If `channel_id_valid` is true, then this contains the
3287
3084
  // verified Channel ID from the client: a P256 point, (x,y), where
3288
3085
  // each are big-endian values.
3289
3086
  uint8_t channel_id[64] = {0};
@@ -3321,7 +3118,7 @@ static_assert(DTLS1_RT_MAX_HEADER_LENGTH >= DTLS1_3_RECORD_HEADER_WRITE_LENGTH,
3321
3118
  // a portion of a message was received or ACKed.
3322
3119
  class DTLSMessageBitmap {
3323
3120
  public:
3324
- // A Range represents a range of bits from |start|, inclusive, to |end|,
3121
+ // A Range represents a range of bits from `start`, inclusive, to `end`,
3325
3122
  // exclusive.
3326
3123
  struct Range {
3327
3124
  size_t start = 0;
@@ -3335,15 +3132,15 @@ class DTLSMessageBitmap {
3335
3132
  bool operator!=(const Range &r) const { return !(*this == r); }
3336
3133
  };
3337
3134
 
3338
- // Init initializes the structure with |num_bits| unmarked bits, from zero
3339
- // to |num_bits - 1|.
3135
+ // Init initializes the structure with `num_bits` unmarked bits, from zero
3136
+ // to `num_bits - 1`.
3340
3137
  bool Init(size_t num_bits);
3341
3138
 
3342
- // MarkRange marks the bits from |start|, inclusive, to |end|, exclusive.
3139
+ // MarkRange marks the bits from `start`, inclusive, to `end`, exclusive.
3343
3140
  void MarkRange(size_t start, size_t end);
3344
3141
 
3345
3142
  // NextUnmarkedRange returns the next range of unmarked bits, starting from
3346
- // |start|, inclusive. If all bits after |start| are marked, it returns an
3143
+ // `start`, inclusive. If all bits after `start` are marked, it returns an
3347
3144
  // empty range.
3348
3145
  Range NextUnmarkedRange(size_t start) const;
3349
3146
 
@@ -3351,15 +3148,15 @@ class DTLSMessageBitmap {
3351
3148
  bool IsComplete() const { return bytes_.empty(); }
3352
3149
 
3353
3150
  private:
3354
- // bytes_ contains the unmarked bits. We maintain an invariant: if |bytes_| is
3151
+ // bytes_ contains the unmarked bits. We maintain an invariant: if `bytes_` is
3355
3152
  // not empty, some bit is unset.
3356
3153
  Array<uint8_t> bytes_;
3357
- // first_unmarked_byte_ is the index of first byte in |bytes_| that is not
3154
+ // first_unmarked_byte_ is the index of first byte in `bytes_` that is not
3358
3155
  // 0xff. This is maintained to amortize checking if the message is complete.
3359
3156
  size_t first_unmarked_byte_ = 0;
3360
3157
  };
3361
3158
 
3362
- struct hm_header_st {
3159
+ struct DTLSHandshakeHeader {
3363
3160
  uint8_t type;
3364
3161
  uint32_t msg_len;
3365
3162
  uint16_t seq;
@@ -3369,24 +3166,59 @@ struct hm_header_st {
3369
3166
 
3370
3167
  // An DTLSIncomingMessage is an incoming DTLS message, possibly not yet
3371
3168
  // assembled.
3372
- struct DTLSIncomingMessage {
3169
+ class DTLSIncomingMessage {
3170
+ public:
3373
3171
  static constexpr bool kAllowUniquePtr = true;
3374
3172
 
3375
- Span<uint8_t> msg() { return Span(data).subspan(DTLS1_HM_HEADER_LENGTH); }
3376
- Span<const uint8_t> msg() const {
3377
- return Span(data).subspan(DTLS1_HM_HEADER_LENGTH);
3173
+ explicit DTLSIncomingMessage(const DTLSHandshakeHeader &hdr);
3174
+
3175
+ uint8_t type() const { return type_; }
3176
+ uint16_t seq() const { return seq_; }
3177
+ size_t msg_len() const {
3178
+ return std::holds_alternative<FragmentList>(msg_)
3179
+ ? std::get<FragmentList>(msg_).msg_len
3180
+ : std::get<ReassemblyBuffer>(msg_).msg.size() -
3181
+ DTLS1_HM_HEADER_LENGTH;
3378
3182
  }
3379
- size_t msg_len() const { return msg().size(); }
3380
-
3381
- // type is the type of the message.
3382
- uint8_t type = 0;
3383
- // seq is the sequence number of this message.
3384
- uint16_t seq = 0;
3385
- // data contains the message, including the message header of length
3386
- // |DTLS1_HM_HEADER_LENGTH|.
3387
- Array<uint8_t> data;
3388
- // reassembly tracks which parts of the message have been received.
3389
- DTLSMessageBitmap reassembly;
3183
+
3184
+ // AddFragment adds the fragment to the incoming message. It returns true on
3185
+ // success and false on error. The caller must have checked that `offset` and
3186
+ // `data` fit in the message body.
3187
+ bool AddFragment(uint32_t offset, Span<const uint8_t> data);
3188
+
3189
+ // IsComplete returns whether the incoming message is complete.
3190
+ bool IsComplete() const;
3191
+
3192
+ // GetMessage returns the message as an SSLMessage if complete, and
3193
+ // std::nullopt otherwise.
3194
+ std::optional<SSLMessage> GetMessage() const;
3195
+
3196
+ private:
3197
+ struct FragmentList {
3198
+ // fragments contains fragment data in order of 24-bit offset, 24-bit
3199
+ // length, data.
3200
+ Vector<uint8_t> fragments;
3201
+ // msg_len contains the length of the handshake message.
3202
+ uint32_t msg_len;
3203
+ };
3204
+
3205
+ struct ReassemblyBuffer {
3206
+ void AddFragment(uint32_t offset, Span<const uint8_t> data);
3207
+
3208
+ // msg holds the message data, including `DTLS1_HM_HEADER_LENGTH` bytes
3209
+ // of reconstructed header.
3210
+ Array<uint8_t> msg;
3211
+ // reassembly tracks which parts of the message have been received.
3212
+ DTLSMessageBitmap reassembly;
3213
+ };
3214
+
3215
+ uint8_t type_;
3216
+ uint16_t seq_;
3217
+ // msg_ holds the message data. Before enough data has been received for the
3218
+ // message to be complete, it stores a FragmentList, which is proportional to
3219
+ // total data received. Once the message might be complete, it switches to
3220
+ // ReassemblyBuffer, which is proportional to the final amount.
3221
+ std::variant<FragmentList, ReassemblyBuffer> msg_;
3390
3222
  };
3391
3223
 
3392
3224
  struct DTLSOutgoingMessage {
@@ -3405,7 +3237,7 @@ struct DTLSOutgoingMessage {
3405
3237
  uint16_t epoch = 0;
3406
3238
  bool is_ccs = false;
3407
3239
  // acked tracks which bits of the message have been ACKed by the peer. If
3408
- // |msg_len| is zero, it tracks one bit for whether the header has been
3240
+ // `msg_len` is zero, it tracks one bit for whether the header has been
3409
3241
  // received.
3410
3242
  DTLSMessageBitmap acked;
3411
3243
  };
@@ -3420,34 +3252,28 @@ struct DTLSTimer {
3420
3252
  static constexpr uint64_t kNever = UINT64_MAX;
3421
3253
 
3422
3254
  // StartMicroseconds schedules the timer to expire the specified number of
3423
- // microseconds from |now|.
3255
+ // microseconds from `now`.
3424
3256
  void StartMicroseconds(OPENSSL_timeval now, uint64_t microseconds);
3425
3257
 
3426
3258
  // Stop disables the timer.
3427
3259
  void Stop();
3428
3260
 
3429
- // IsExpired returns true if the timer was set and is expired at time |now|.
3261
+ // IsExpired returns true if the timer was set and is expired at time `now`.
3430
3262
  bool IsExpired(OPENSSL_timeval now) const;
3431
3263
 
3432
3264
  // IsSet returns true if the timer is scheduled or expired, and false if it is
3433
3265
  // stopped.
3434
3266
  bool IsSet() const;
3435
3267
 
3268
+ void UpdateDuration(uint64_t microseconds) { duration_ = microseconds; }
3269
+
3436
3270
  // MicrosecondsRemaining returns the time remaining, in microseconds, at
3437
- // |now|, or |kNever| if the timer is unset.
3271
+ // `now`, or `kNever` if the timer is unset.
3438
3272
  uint64_t MicrosecondsRemaining(OPENSSL_timeval now) const;
3439
3273
 
3440
3274
  private:
3441
- // expire_time_ is the time when the timer expires, or zero if the timer is
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};
3275
+ uint64_t start_time_;
3276
+ uint64_t duration_ = kNever; // If set to kNever then this timer is unset.
3451
3277
  };
3452
3278
 
3453
3279
  // DTLS_MAX_EXTRA_WRITE_EPOCHS is the maximum number of additional write epochs
@@ -3469,14 +3295,14 @@ struct DTLSTimer {
3469
3295
  #define DTLS_MAX_ACK_BUFFER 32
3470
3296
 
3471
3297
  // A DTLSSentRecord records information about a record we sent. Each record
3472
- // covers all bytes from |first_msg_start| (inclusive) of |first_msg| to
3473
- // |last_msg_end| (exclusive) of |last_msg|. Messages are referenced by index
3474
- // into |outgoing_messages|. |last_msg_end| may be |outgoing_messages.size()| if
3475
- // |last_msg_end| is zero.
3298
+ // covers all bytes from `first_msg_start` (inclusive) of `first_msg` to
3299
+ // `last_msg_end` (exclusive) of `last_msg`. Messages are referenced by index
3300
+ // into `outgoing_messages`. `last_msg_end` may be `outgoing_messages.size()` if
3301
+ // `last_msg_end` is zero.
3476
3302
  //
3477
- // When the message is empty, |first_msg_start| and |last_msg_end| are
3303
+ // When the message is empty, `first_msg_start` and `last_msg_end` are
3478
3304
  // maintained as if there is a single bit in the message representing the
3479
- // header. See |acked| in DTLSOutgoingMessage.
3305
+ // header. See `acked` in DTLSOutgoingMessage.
3480
3306
  struct DTLSSentRecord {
3481
3307
  DTLSRecordNumber number;
3482
3308
  PackedSize<SSL_MAX_HANDSHAKE_FLIGHT> first_msg = 0;
@@ -3524,9 +3350,9 @@ struct DTLS1_STATE {
3524
3350
  // the peer in this epoch.
3525
3351
  bool has_change_cipher_spec : 1;
3526
3352
 
3527
- // outgoing_messages_complete is true if |outgoing_messages| has been
3528
- // completed by an attempt to flush it. Future calls to |add_message| and
3529
- // |add_change_cipher_spec| will start a new flight.
3353
+ // outgoing_messages_complete is true if `outgoing_messages` has been
3354
+ // completed by an attempt to flush it. Future calls to `add_message` and
3355
+ // `add_change_cipher_spec` will start a new flight.
3530
3356
  bool outgoing_messages_complete : 1;
3531
3357
 
3532
3358
  // flight_has_reply is true if the current outgoing flight is complete and has
@@ -3543,6 +3369,8 @@ struct DTLS1_STATE {
3543
3369
  // a handshake flight and ACK, respectively.
3544
3370
  bool sending_flight : 1;
3545
3371
  bool sending_ack : 1;
3372
+ // pending_flush is whether we have a pending flush on the transport.
3373
+ bool pending_flush : 1;
3546
3374
 
3547
3375
  // queued_key_update, if not kNone, indicates we've queued a KeyUpdate message
3548
3376
  // to send after the current flight is ACKed.
@@ -3572,8 +3400,8 @@ struct DTLS1_STATE {
3572
3400
 
3573
3401
  // incoming_messages is a ring buffer of incoming handshake messages that have
3574
3402
  // yet to be processed. The front of the ring buffer is message number
3575
- // |handshake_read_seq|, at position |handshake_read_seq| %
3576
- // |SSL_MAX_HANDSHAKE_FLIGHT|.
3403
+ // `handshake_read_seq`, at position `handshake_read_seq` %
3404
+ // `SSL_MAX_HANDSHAKE_FLIGHT`.
3577
3405
  UniquePtr<DTLSIncomingMessage> incoming_messages[SSL_MAX_HANDSHAKE_FLIGHT];
3578
3406
 
3579
3407
  // outgoing_messages is the queue of outgoing messages from the last handshake
@@ -3624,33 +3452,36 @@ struct ALPSConfig {
3624
3452
 
3625
3453
  // SSL_CONFIG contains configuration bits that can be shed after the handshake
3626
3454
  // completes. Objects of this type are not shared; they are unique to a
3627
- // particular |SSL|.
3455
+ // particular `SSL`.
3628
3456
  //
3629
3457
  // See SSL_shed_handshake_config() for more about the conditions under which
3630
3458
  // configuration can be shed.
3631
3459
  struct SSL_CONFIG {
3632
3460
  static constexpr bool kAllowUniquePtr = true;
3633
3461
 
3634
- explicit SSL_CONFIG(SSL *ssl_arg);
3462
+ explicit SSL_CONFIG(SSLImpl *ssl_arg);
3635
3463
  ~SSL_CONFIG();
3636
3464
 
3637
- // ssl is a non-owning pointer to the parent |SSL| object.
3638
- SSL *const ssl = nullptr;
3465
+ // ssl is a non-owning pointer to the parent `SSL` object.
3466
+ SSLImpl *const ssl = nullptr;
3639
3467
 
3640
3468
  // conf_max_version is the maximum acceptable version configured by
3641
- // |SSL_set_max_proto_version|. Note this version is not normalized in DTLS
3642
- // and is further constrained by |SSL_OP_NO_*|.
3469
+ // `SSL_set_max_proto_version`. Note this version is not normalized in DTLS
3470
+ // and is further constrained by `SSL_OP_NO_*`.
3643
3471
  uint16_t conf_max_version = 0;
3644
3472
 
3645
3473
  // conf_min_version is the minimum acceptable version configured by
3646
- // |SSL_set_min_proto_version|. Note this version is not normalized in DTLS
3647
- // and is further constrained by |SSL_OP_NO_*|.
3474
+ // `SSL_set_min_proto_version`. Note this version is not normalized in DTLS
3475
+ // and is further constrained by `SSL_OP_NO_*`.
3648
3476
  uint16_t conf_min_version = 0;
3649
3477
 
3650
3478
  X509_VERIFY_PARAM *param = nullptr;
3651
3479
 
3652
3480
  // crypto
3653
- UniquePtr<SSLCipherPreferenceList> cipher_list;
3481
+ UniquePtr<SSLCipherPreferenceList> cipher_list; // for TLS 1.2 ciphers.
3482
+
3483
+ // Inherited from `SSL_CTX`.
3484
+ SSLCipherPreferenceList tls13_cipher_list;
3654
3485
 
3655
3486
  // This is used to hold the local certificate used (i.e. the server
3656
3487
  // certificate for a server or the client certificate for a client).
@@ -3676,7 +3507,7 @@ struct SSL_CONFIG {
3676
3507
  UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
3677
3508
 
3678
3509
  // cached_x509_client_CA is a cache of parsed versions of the elements of
3679
- // |client_CA|.
3510
+ // `client_CA`.
3680
3511
  STACK_OF(X509_NAME) *cached_x509_client_CA = nullptr;
3681
3512
 
3682
3513
  // For client side, keep the list of CA distinguished names we can use
@@ -3689,7 +3520,27 @@ struct SSL_CONFIG {
3689
3520
  // Trust anchor IDs to be requested in the trust_anchors extension.
3690
3521
  std::optional<Array<uint8_t>> requested_trust_anchors;
3691
3522
 
3692
- Array<uint16_t> supported_group_list; // our list
3523
+ // Our list of supported groups. If this list is modified, for a client,
3524
+ // `client_key_share_selections` must be reset if the key shares are no longer
3525
+ // a valid subsequence of the supported group list.
3526
+ Array<uint16_t> supported_group_list;
3527
+
3528
+ // Contains flags corresponding to `supported_group_list`, which are
3529
+ // SSL_GROUP_FLAG_* values ORed together.
3530
+ Array<uint32_t> supported_group_list_flags;
3531
+
3532
+ // For a client, this may contain a subsequence of the group IDs in
3533
+ // `suppported_group_list`, which gives the groups for which key shares should
3534
+ // be sent in the client's key_share extension. This is non-nullopt iff
3535
+ // `SSL_set1_client_key_shares` was successfully called to configure key
3536
+ // shares. If non-nullopt, these groups are in the same order as they appear
3537
+ // in `supported_group_list`, and may not contain duplicates.
3538
+ std::optional<InplaceVector<uint16_t, kNumNamedGroups>>
3539
+ client_key_share_selections;
3540
+
3541
+ // For a client, this contains a list of groups believed to be supported by
3542
+ // the server, in server preference order.
3543
+ Array<uint16_t> server_supported_groups_hint;
3693
3544
 
3694
3545
  // channel_id_private is the client's Channel ID private key, or null if
3695
3546
  // Channel ID should not be offered on this connection.
@@ -3725,13 +3576,35 @@ struct SSL_CONFIG {
3725
3576
  // negotiating a TLS 1.3 connection.
3726
3577
  enum ssl_compliance_policy_t compliance_policy = ssl_compliance_policy_none;
3727
3578
 
3728
- // verify_mode is a bitmask of |SSL_VERIFY_*| values.
3579
+ // server_padding_request, if set by the client, indicates that the client
3580
+ // will ask the server to include additional padding in the
3581
+ // EncryptedExtensions message of a TLS 1.3 connection.
3582
+ std::optional<uint16_t> server_padding_request;
3583
+
3584
+ // verify_mode is a bitmask of `SSL_VERIFY_*` values.
3729
3585
  uint8_t verify_mode = SSL_VERIFY_NONE;
3730
3586
 
3587
+ // accepted_peer_cert_types contains a list of `TLSEXT_cert_type_*` values in
3588
+ // preference order indicating the types of certificates to accept from the
3589
+ // peer. This list should always be non-empty. If the caller did not configure
3590
+ // a valid list, only X.509 certificates are accepted by default.
3591
+ InplaceVector<uint8_t, kNumCertTypes> accepted_peer_cert_types;
3592
+
3593
+ // available_client_cert_types, if not empty, contains a list of
3594
+ // `TLSEXT_cert_type_*` values in preference order indicating the types of
3595
+ // client certificates that the caller, as a client, explicitly configured and
3596
+ // wishes to advertise, instead of the automatically inferred client cert
3597
+ // types from the configured credential list.
3598
+ InplaceVector<uint8_t, kNumCertTypes> available_client_cert_types;
3599
+
3731
3600
  // ech_grease_enabled controls whether ECH GREASE may be sent in the
3732
3601
  // ClientHello.
3733
3602
  bool ech_grease_enabled : 1;
3734
3603
 
3604
+ // reject_unusable_ech_config controls whether the client will fail the
3605
+ // handshake if ECH cannot be offered.
3606
+ bool reject_unusable_ech_config : 1;
3607
+
3735
3608
  // Enable signed certificate time stamps. Currently client only.
3736
3609
  bool signed_cert_timestamps_enabled : 1;
3737
3610
 
@@ -3739,23 +3612,18 @@ struct SSL_CONFIG {
3739
3612
  // whether OCSP stapling will be requested.
3740
3613
  bool ocsp_stapling_enabled : 1;
3741
3614
 
3742
- // channel_id_enabled is copied from the |SSL_CTX|. For a server, it means
3615
+ // channel_id_enabled is copied from the `SSL_CTX`. For a server, it means
3743
3616
  // that we'll accept Channel IDs from clients. It is ignored on the client.
3744
3617
  bool channel_id_enabled : 1;
3745
3618
 
3746
- // If enforce_rsa_key_usage is true, the handshake will fail if the
3747
- // keyUsage extension is present and incompatible with the TLS usage.
3748
- // This field is not read until after certificate verification.
3749
- bool enforce_rsa_key_usage : 1;
3750
-
3751
3619
  // retain_only_sha256_of_client_certs is true if we should compute the SHA256
3752
3620
  // hash of the peer's certificate and then discard it to save memory and
3753
3621
  // session space. Only effective on the server side.
3754
3622
  bool retain_only_sha256_of_client_certs : 1;
3755
3623
 
3756
3624
  // handoff indicates that a server should stop after receiving the
3757
- // ClientHello and pause the handshake in such a way that |SSL_get_error|
3758
- // returns |SSL_ERROR_HANDOFF|. This is copied in |SSL_new| from the |SSL_CTX|
3625
+ // ClientHello and pause the handshake in such a way that `SSL_get_error`
3626
+ // returns `SSL_ERROR_HANDOFF`. This is copied in `SSL_new` from the `SSL_CTX`
3759
3627
  // element of the same name and may be cleared if the handoff is declined.
3760
3628
  bool handoff : 1;
3761
3629
 
@@ -3774,18 +3642,13 @@ struct SSL_CONFIG {
3774
3642
  // permute_extensions is whether to permute extensions when sending messages.
3775
3643
  bool permute_extensions : 1;
3776
3644
 
3777
- // aes_hw_override if set indicates we should override checking for aes
3778
- // hardware support, and use the value in aes_hw_override_value instead.
3779
- bool aes_hw_override : 1;
3780
-
3781
- // 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 |aes_hw_override| is
3783
- // true.
3784
- bool aes_hw_override_value : 1;
3785
-
3786
3645
  // alps_use_new_codepoint if set indicates we use new ALPS extension codepoint
3787
3646
  // to negotiate and convey application settings.
3788
3647
  bool alps_use_new_codepoint : 1;
3648
+
3649
+ // server_padding_enabled is true iff the server is willing to send additional
3650
+ // padding to clients that request it through the server padding extension.
3651
+ bool server_padding_enabled : 1;
3789
3652
  };
3790
3653
 
3791
3654
  // From RFC 8446, used in determining PSK modes.
@@ -3799,38 +3662,38 @@ static const size_t kMaxEarlyDataAccepted = 14336;
3799
3662
  UniquePtr<CERT> ssl_cert_dup(CERT *cert);
3800
3663
  bool ssl_set_cert(CERT *cert, UniquePtr<CRYPTO_BUFFER> buffer);
3801
3664
  bool ssl_is_key_type_supported(int key_type);
3802
- // ssl_compare_public_and_private_key returns true if |pubkey| is the public
3803
- // counterpart to |privkey|. Otherwise it returns false and pushes a helpful
3665
+ // ssl_compare_public_and_private_key returns true if `pubkey` is the public
3666
+ // counterpart to `privkey`. Otherwise it returns false and pushes a helpful
3804
3667
  // message on the error queue.
3805
3668
  bool ssl_compare_public_and_private_key(const EVP_PKEY *pubkey,
3806
3669
  const EVP_PKEY *privkey);
3807
3670
  bool ssl_get_new_session(SSL_HANDSHAKE *hs);
3808
3671
 
3809
- // ssl_encrypt_ticket encrypt a ticket for |session| and writes the result to
3810
- // |out|. It returns true on success and false on error. If, on success, nothing
3811
- // was written to |out|, the caller should skip sending a ticket.
3812
- bool ssl_encrypt_ticket(SSL_HANDSHAKE *hs, CBB *out,
3813
- const SSL_SESSION *session);
3672
+ // ssl_encrypt_ticket encrypt a ticket for `session` and writes the result to
3673
+ // `out`. It returns true on success and false on error. If, on success, nothing
3674
+ // was written to `out`, the caller should skip sending a ticket.
3675
+ bool ssl_encrypt_ticket(SSL_HANDSHAKE *hs, CBB *out, const SSLSession *session);
3814
3676
 
3815
- bool ssl_ctx_rotate_ticket_encryption_key(SSL_CTX *ctx);
3677
+ bool ssl_ctx_rotate_ticket_encryption_key(SSLContext *ctx);
3816
3678
 
3817
- // ssl_session_new returns a newly-allocated blank |SSL_SESSION| or nullptr on
3679
+ // ssl_session_new returns a newly-allocated blank `SSL_SESSION` or nullptr on
3818
3680
  // error.
3819
- UniquePtr<SSL_SESSION> ssl_session_new(const SSL_X509_METHOD *x509_method);
3681
+ UniquePtr<SSLSession> ssl_session_new(const SSL_X509_METHOD *x509_method);
3820
3682
 
3821
- // ssl_hash_session_id returns a hash of |session_id|, suitable for a hash table
3683
+ // ssl_hash_session_id returns a hash of `session_id`, suitable for a hash table
3822
3684
  // keyed on session IDs.
3823
3685
  uint32_t ssl_hash_session_id(Span<const uint8_t> session_id);
3824
3686
 
3825
- // SSL_SESSION_parse parses an |SSL_SESSION| from |cbs| and advances |cbs| over
3687
+ // SSL_SESSION_parse parses an `SSL_SESSION` from `cbs` and advances `cbs` over
3826
3688
  // the parsed data.
3827
- OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_parse(
3828
- CBS *cbs, const SSL_X509_METHOD *x509_method, CRYPTO_BUFFER_POOL *pool);
3689
+ UniquePtr<SSLSession> SSL_SESSION_parse(CBS *cbs,
3690
+ const SSL_X509_METHOD *x509_method,
3691
+ CRYPTO_BUFFER_POOL *pool);
3829
3692
 
3830
- // ssl_session_serialize writes |in| to |cbb| as if it were serialising a
3693
+ // ssl_session_serialize writes `in` to `cbb` as if it were serialising a
3831
3694
  // session for Session-ID resumption. It returns true on success and false on
3832
3695
  // error.
3833
- OPENSSL_EXPORT bool ssl_session_serialize(const SSL_SESSION *in, CBB *cbb);
3696
+ bool ssl_session_serialize(const SSLSession *in, CBB *cbb);
3834
3697
 
3835
3698
  enum class SSLSessionType {
3836
3699
  // The session is not resumable.
@@ -3843,40 +3706,48 @@ enum class SSLSessionType {
3843
3706
  kPreSharedKey,
3844
3707
  };
3845
3708
 
3846
- // ssl_session_get_type returns the type of |session|.
3847
- SSLSessionType ssl_session_get_type(const SSL_SESSION *session);
3709
+ // ssl_session_get_type returns the type of `session`.
3710
+ SSLSessionType ssl_session_get_type(const SSLSession *session);
3848
3711
 
3849
- // ssl_session_is_context_valid returns whether |session|'s session ID context
3850
- // matches the one set on |hs|.
3712
+ // ssl_session_is_context_valid returns whether `session`'s session ID context
3713
+ // matches the one set on `hs`.
3851
3714
  bool ssl_session_is_context_valid(const SSL_HANDSHAKE *hs,
3852
- const SSL_SESSION *session);
3715
+ const SSLSession *session);
3853
3716
 
3854
- // ssl_session_is_time_valid returns true if |session| is still valid and false
3717
+ // ssl_session_is_time_valid returns true if `session` is still valid and false
3855
3718
  // if it has expired.
3856
- bool ssl_session_is_time_valid(const SSL *ssl, const SSL_SESSION *session);
3719
+ bool ssl_session_is_time_valid(const SSLImpl *ssl, const SSLSession *session);
3857
3720
 
3858
- // ssl_session_is_resumable returns whether |session| is resumable for |hs|.
3721
+ // ssl_session_is_resumable returns whether `session` is resumable for `hs`.
3859
3722
  bool ssl_session_is_resumable(const SSL_HANDSHAKE *hs,
3860
- const SSL_SESSION *session);
3723
+ const SSLSession *session);
3861
3724
 
3862
3725
  // ssl_session_protocol_version returns the protocol version associated with
3863
- // |session|. Note that despite the name, this is not the same as
3864
- // |SSL_SESSION_get_protocol_version|. The latter is based on upstream's name.
3865
- uint16_t ssl_session_protocol_version(const SSL_SESSION *session);
3726
+ // `session`. Note that despite the name, this is not the same as
3727
+ // `SSL_SESSION_get_protocol_version`. The latter is based on upstream's name.
3728
+ uint16_t ssl_session_protocol_version(const SSLSession *session);
3729
+
3730
+ // ssl_session_get_digest returns the digest used in `session`.
3731
+ const EVP_MD *ssl_session_get_digest(const SSLSession *session);
3732
+
3733
+ // ssl_session_has_peer_cred returns whether `session` contains the peer's
3734
+ // (non-PSK) credentials (either X.509 cert chain or raw public key, depending
3735
+ // on the peer's certificate type) or a valid SHA-256 hash thereof.
3736
+ bool ssl_session_has_peer_cred(const SSLSession *session);
3866
3737
 
3867
- // ssl_session_get_digest returns the digest used in |session|.
3868
- const EVP_MD *ssl_session_get_digest(const SSL_SESSION *session);
3738
+ void ssl_set_session(SSLImpl *ssl, SSLSession *session);
3869
3739
 
3870
- void ssl_set_session(SSL *ssl, SSL_SESSION *session);
3740
+ // ssl_get_session implements `SSL_get_session`.
3741
+ SSLSession *ssl_get_session(const SSLImpl *ssl);
3871
3742
 
3872
- // ssl_get_prev_session looks up the previous session based on |client_hello|.
3873
- // On success, it sets |*out_session| to the session or nullptr if none was
3743
+ // ssl_get_prev_session looks up the previous session based on `client_hello`.
3744
+ // On success, it sets `*out_session` to the session or nullptr if none was
3874
3745
  // found. If the session could not be looked up synchronously, it returns
3875
- // |ssl_hs_pending_session| and should be called again. If a ticket could not be
3876
- // decrypted immediately it returns |ssl_hs_pending_ticket| and should also
3877
- // be called again. Otherwise, it returns |ssl_hs_error|.
3746
+ // `ssl_hs_pending_session` and should be called again. If a ticket could not be
3747
+ // decrypted immediately it returns `ssl_hs_pending_ticket` and should also
3748
+ // be called again. Otherwise, it returns `ssl_hs_error`.
3878
3749
  enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
3879
- UniquePtr<SSL_SESSION> *out_session,
3750
+ UniquePtr<SSLSession> *out_session,
3880
3751
  bool *out_tickets_supported,
3881
3752
  bool *out_renew_ticket,
3882
3753
  const SSL_CLIENT_HELLO *client_hello);
@@ -3888,85 +3759,87 @@ enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
3888
3759
  #define SSL_SESSION_DUP_ALL \
3889
3760
  (SSL_SESSION_INCLUDE_TICKET | SSL_SESSION_INCLUDE_NONAUTH)
3890
3761
 
3891
- // SSL_SESSION_dup returns a newly-allocated |SSL_SESSION| with a copy of the
3892
- // fields in |session| or nullptr on error. The new session is non-resumable and
3762
+ // SSL_SESSION_dup returns a newly-allocated `SSL_SESSION` with a copy of the
3763
+ // fields in `session` or nullptr on error. The new session is non-resumable and
3893
3764
  // must be explicitly marked resumable once it has been filled in.
3894
- OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_dup(SSL_SESSION *session,
3895
- int dup_flags);
3765
+ UniquePtr<SSLSession> SSL_SESSION_dup(const SSLSession *session, int dup_flags);
3896
3766
 
3897
- // ssl_session_rebase_time updates |session|'s start time to the current time,
3767
+ // ssl_session_rebase_time updates `session`'s start time to the current time,
3898
3768
  // adjusting the timeout so the expiration time is unchanged.
3899
- void ssl_session_rebase_time(SSL *ssl, SSL_SESSION *session);
3769
+ void ssl_session_rebase_time(SSLImpl *ssl, SSLSession *session);
3900
3770
 
3901
- // ssl_session_renew_timeout calls |ssl_session_rebase_time| and renews
3902
- // |session|'s timeout to |timeout| (measured from the current time). The
3771
+ // ssl_session_renew_timeout calls `ssl_session_rebase_time` and renews
3772
+ // `session`'s timeout to `timeout` (measured from the current time). The
3903
3773
  // renewal is clamped to the session's auth_timeout.
3904
- void ssl_session_renew_timeout(SSL *ssl, SSL_SESSION *session,
3774
+ void ssl_session_renew_timeout(SSLImpl *ssl, SSLSession *session,
3905
3775
  uint32_t timeout);
3906
3776
 
3907
- void ssl_update_cache(SSL *ssl);
3777
+ void ssl_update_cache(SSLImpl *ssl);
3908
3778
 
3909
- void ssl_send_alert(SSL *ssl, int level, int desc);
3910
- int ssl_send_alert_impl(SSL *ssl, int level, int desc);
3911
- bool tls_get_message(const SSL *ssl, SSLMessage *out);
3912
- ssl_open_record_t tls_open_handshake(SSL *ssl, size_t *out_consumed,
3779
+ void ssl_send_alert(SSLImpl *ssl, int level, int desc);
3780
+ int ssl_send_alert_impl(SSLImpl *ssl, int level, int desc);
3781
+ bool tls_get_message(const SSLImpl *ssl, SSLMessage *out);
3782
+ ssl_open_record_t tls_open_handshake(SSLImpl *ssl, size_t *out_consumed,
3913
3783
  uint8_t *out_alert, Span<uint8_t> in);
3914
- void tls_next_message(SSL *ssl);
3784
+ void tls_next_message(SSLImpl *ssl);
3915
3785
 
3916
- int tls_dispatch_alert(SSL *ssl);
3917
- ssl_open_record_t tls_open_app_data(SSL *ssl, Span<uint8_t> *out,
3786
+ int tls_dispatch_alert(SSLImpl *ssl);
3787
+ ssl_open_record_t tls_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
3918
3788
  size_t *out_consumed, uint8_t *out_alert,
3919
3789
  Span<uint8_t> in);
3920
- ssl_open_record_t tls_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
3790
+ ssl_open_record_t tls_open_change_cipher_spec(SSLImpl *ssl,
3791
+ size_t *out_consumed,
3921
3792
  uint8_t *out_alert,
3922
3793
  Span<uint8_t> in);
3923
- int tls_write_app_data(SSL *ssl, bool *out_needs_handshake,
3794
+ int tls_write_app_data(SSLImpl *ssl, bool *out_needs_handshake,
3924
3795
  size_t *out_bytes_written, Span<const uint8_t> in);
3925
3796
 
3926
- bool tls_new(SSL *ssl);
3927
- void tls_free(SSL *ssl);
3928
-
3929
- bool tls_init_message(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
3930
- bool tls_finish_message(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
3931
- bool tls_add_message(SSL *ssl, Array<uint8_t> msg);
3932
- bool tls_add_change_cipher_spec(SSL *ssl);
3933
- int tls_flush(SSL *ssl);
3934
-
3935
- bool dtls1_init_message(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
3936
- bool dtls1_finish_message(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
3937
- bool dtls1_add_message(SSL *ssl, Array<uint8_t> msg);
3938
- bool dtls1_add_change_cipher_spec(SSL *ssl);
3939
- void dtls1_finish_flight(SSL *ssl);
3940
- void dtls1_schedule_ack(SSL *ssl);
3941
- int dtls1_flush(SSL *ssl);
3942
-
3943
- // ssl_add_message_cbb finishes the handshake message in |cbb| and adds it to
3797
+ bool tls_new(SSLImpl *ssl);
3798
+ void tls_free(SSLImpl *ssl);
3799
+
3800
+ bool tls_init_message(const SSLImpl *ssl, CBB *cbb, CBB *body, uint8_t type);
3801
+ bool tls_finish_message(const SSLImpl *ssl, CBB *cbb, Array<uint8_t> *out_msg);
3802
+ bool tls_add_message(SSLImpl *ssl, Array<uint8_t> msg);
3803
+ bool tls_add_change_cipher_spec(SSLImpl *ssl);
3804
+ int tls_flush(SSLImpl *ssl);
3805
+
3806
+ bool dtls1_init_message(const SSLImpl *ssl, CBB *cbb, CBB *body, uint8_t type);
3807
+ bool dtls1_finish_message(const SSLImpl *ssl, CBB *cbb,
3808
+ Array<uint8_t> *out_msg);
3809
+ bool dtls1_add_message(SSLImpl *ssl, Array<uint8_t> msg);
3810
+ bool dtls1_add_change_cipher_spec(SSLImpl *ssl);
3811
+ void dtls1_finish_flight(SSLImpl *ssl);
3812
+ void dtls1_schedule_ack(SSLImpl *ssl);
3813
+ int dtls1_flush(SSLImpl *ssl);
3814
+
3815
+ // ssl_add_message_cbb finishes the handshake message in `cbb` and adds it to
3944
3816
  // the pending flight. It returns true on success and false on error.
3945
- bool ssl_add_message_cbb(SSL *ssl, CBB *cbb);
3817
+ bool ssl_add_message_cbb(SSLImpl *ssl, CBB *cbb);
3946
3818
 
3947
- // ssl_hash_message incorporates |msg| into the handshake hash. It returns true
3819
+ // ssl_hash_message incorporates `msg` into the handshake hash. It returns true
3948
3820
  // on success and false on allocation failure.
3949
3821
  bool ssl_hash_message(SSL_HANDSHAKE *hs, const SSLMessage &msg);
3950
3822
 
3951
- ssl_open_record_t dtls1_process_ack(SSL *ssl, uint8_t *out_alert,
3823
+ ssl_open_record_t dtls1_process_ack(SSLImpl *ssl, uint8_t *out_alert,
3952
3824
  DTLSRecordNumber ack_record_number,
3953
3825
  Span<const uint8_t> data);
3954
- ssl_open_record_t dtls1_open_app_data(SSL *ssl, Span<uint8_t> *out,
3826
+ ssl_open_record_t dtls1_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
3955
3827
  size_t *out_consumed, uint8_t *out_alert,
3956
3828
  Span<uint8_t> in);
3957
- ssl_open_record_t dtls1_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
3829
+ ssl_open_record_t dtls1_open_change_cipher_spec(SSLImpl *ssl,
3830
+ size_t *out_consumed,
3958
3831
  uint8_t *out_alert,
3959
3832
  Span<uint8_t> in);
3960
3833
 
3961
- int dtls1_write_app_data(SSL *ssl, bool *out_needs_handshake,
3834
+ int dtls1_write_app_data(SSLImpl *ssl, bool *out_needs_handshake,
3962
3835
  size_t *out_bytes_written, Span<const uint8_t> in);
3963
3836
 
3964
3837
  // dtls1_write_record sends a record. It returns one on success and <= 0 on
3965
3838
  // error.
3966
- int dtls1_write_record(SSL *ssl, int type, Span<const uint8_t> in,
3839
+ int dtls1_write_record(SSLImpl *ssl, int type, Span<const uint8_t> in,
3967
3840
  uint16_t epoch);
3968
3841
 
3969
- bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
3842
+ bool dtls1_parse_fragment(CBS *cbs, DTLSHandshakeHeader *out_hdr,
3970
3843
  CBS *out_body);
3971
3844
 
3972
3845
  // DTLS1_MTU_TIMEOUTS is the maximum number of retransmit timeouts to expire
@@ -3977,69 +3850,59 @@ bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
3977
3850
  // before failing the DTLS handshake.
3978
3851
  #define DTLS1_MAX_TIMEOUTS 12
3979
3852
 
3980
- void dtls1_stop_timer(SSL *ssl);
3853
+ void dtls1_stop_timer(SSLImpl *ssl);
3981
3854
 
3982
- unsigned int dtls1_min_mtu(void);
3855
+ unsigned int dtls1_min_mtu();
3983
3856
 
3984
- bool dtls1_new(SSL *ssl);
3985
- void dtls1_free(SSL *ssl);
3857
+ bool dtls1_new(SSLImpl *ssl);
3858
+ void dtls1_free(SSLImpl *ssl);
3986
3859
 
3987
- bool dtls1_process_handshake_fragments(SSL *ssl, uint8_t *out_alert,
3860
+ bool dtls1_process_handshake_fragments(SSLImpl *ssl, uint8_t *out_alert,
3988
3861
  DTLSRecordNumber record_number,
3989
3862
  Span<const uint8_t> record);
3990
- bool dtls1_get_message(const SSL *ssl, SSLMessage *out);
3991
- ssl_open_record_t dtls1_open_handshake(SSL *ssl, size_t *out_consumed,
3863
+ bool dtls1_get_message(const SSLImpl *ssl, SSLMessage *out);
3864
+ ssl_open_record_t dtls1_open_handshake(SSLImpl *ssl, size_t *out_consumed,
3992
3865
  uint8_t *out_alert, Span<uint8_t> in);
3993
- void dtls1_next_message(SSL *ssl);
3994
- int dtls1_dispatch_alert(SSL *ssl);
3866
+ void dtls1_next_message(SSLImpl *ssl);
3867
+ int dtls1_dispatch_alert(SSLImpl *ssl);
3995
3868
 
3996
3869
  // tls1_configure_aead configures either the read or write direction AEAD (as
3997
- // determined by |direction|) using the keys generated by the TLS KDF. The
3998
- // |key_block_cache| argument is used to store the generated key block, if
3870
+ // determined by `direction`) using the keys generated by the TLS KDF. The
3871
+ // `key_block_cache` argument is used to store the generated key block, if
3999
3872
  // empty. Otherwise it's assumed that the key block is already contained within
4000
3873
  // it. It returns true on success or false on error.
4001
- bool tls1_configure_aead(SSL *ssl, evp_aead_direction_t direction,
3874
+ bool tls1_configure_aead(SSLImpl *ssl, evp_aead_direction_t direction,
4002
3875
  Array<uint8_t> *key_block_cache,
4003
- const SSL_SESSION *session,
3876
+ const SSLSession *session,
4004
3877
  Span<const uint8_t> iv_override);
4005
3878
 
4006
3879
  bool tls1_change_cipher_state(SSL_HANDSHAKE *hs,
4007
3880
  evp_aead_direction_t direction);
4008
3881
 
4009
- // tls1_generate_master_secret computes the master secret from |premaster| and
4010
- // writes it to |out|. |out| must have size |SSL3_MASTER_SECRET_SIZE|.
3882
+ // tls1_generate_master_secret computes the master secret from `premaster` and
3883
+ // writes it to `out`. `out` must have size `SSL3_MASTER_SECRET_SIZE`.
4011
3884
  bool tls1_generate_master_secret(SSL_HANDSHAKE *hs, Span<uint8_t> out,
4012
3885
  Span<const uint8_t> premaster);
4013
3886
 
4014
- // tls1_get_grouplist returns the locally-configured group preference list.
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-
3887
+ // tls1_check_group_id returns whether `group_id` is consistent with locally-
4018
3888
  // configured group preferences.
4019
3889
  bool tls1_check_group_id(const SSL_HANDSHAKE *ssl, uint16_t group_id);
4020
3890
 
4021
- // tls1_get_shared_group sets |*out_group_id| to the first preferred shared
3891
+ // tls1_get_shared_group sets `*out_group_id` to the first preferred shared
4022
3892
  // group between client and server preferences and returns true. If none may be
4023
3893
  // found, it returns false.
4024
3894
  bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id);
4025
3895
 
4026
- // ssl_add_clienthello_tlsext writes ClientHello extensions to |out| for |type|.
4027
- // It returns true on success and false on failure. The |header_len| argument is
4028
- // the length of the ClientHello written so far and is used to compute the
4029
- // padding length. (It does not include the record header or handshake headers.)
3896
+ // ssl_add_clienthello_tlsext writes ClientHello extensions to `out` for `type`.
3897
+ // It returns true on success and false on failure. `out` must currently contain
3898
+ // a ClientHello message, not including the message and record header. (Its
3899
+ // contents will be used to compute padding and PSK binders.)
4030
3900
  //
4031
- // If |type| is |ssl_client_hello_inner|, this function also writes the
4032
- // compressed extensions to |out_encoded|. Otherwise, |out_encoded| should be
3901
+ // If `type` is `ssl_client_hello_inner`, this function also writes the
3902
+ // compressed extensions to `out_encoded`. Otherwise, `out_encoded` should be
4033
3903
  // 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
3904
  bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
4040
- bool *out_needs_psk_binder,
4041
- ssl_client_hello_type_t type,
4042
- size_t header_len);
3905
+ ssl_client_hello_type_t type);
4043
3906
 
4044
3907
  bool ssl_add_serverhello_tlsext(SSL_HANDSHAKE *hs, CBB *out);
4045
3908
  bool ssl_parse_clienthello_tlsext(SSL_HANDSHAKE *hs,
@@ -4050,94 +3913,76 @@ bool ssl_parse_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *extensions);
4050
3913
 
4051
3914
  // ssl_process_ticket processes a session ticket from the client. It returns
4052
3915
  // one of:
4053
- // |ssl_ticket_aead_success|: |*out_session| is set to the parsed session and
4054
- // |*out_renew_ticket| is set to whether the ticket should be renewed.
4055
- // |ssl_ticket_aead_ignore_ticket|: |*out_renew_ticket| is set to whether a
3916
+ // `ssl_ticket_aead_success`: `*out_session` is set to the parsed session and
3917
+ // `*out_renew_ticket` is set to whether the ticket should be renewed.
3918
+ // `ssl_ticket_aead_ignore_ticket`: `*out_renew_ticket` is set to whether a
4056
3919
  // fresh ticket should be sent, but the given ticket cannot be used.
4057
- // |ssl_ticket_aead_retry|: the ticket could not be immediately decrypted.
3920
+ // `ssl_ticket_aead_retry`: the ticket could not be immediately decrypted.
4058
3921
  // Retry later.
4059
- // |ssl_ticket_aead_error|: an error occured that is fatal to the connection.
3922
+ // `ssl_ticket_aead_error`: an error occurred that is fatal to the connection.
3923
+ //
3924
+ // If `save_ticket` is true, `*out_session` will have a copy of the ticket saved
3925
+ // in its `ticket` field.
4060
3926
  enum ssl_ticket_aead_result_t ssl_process_ticket(
4061
- SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
3927
+ SSL_HANDSHAKE *hs, UniquePtr<SSLSession> *out_session,
4062
3928
  bool *out_renew_ticket, Span<const uint8_t> ticket,
4063
- Span<const uint8_t> session_id);
3929
+ Span<const uint8_t> session_id, bool save_ticket);
4064
3930
 
4065
- // tls1_verify_channel_id processes |msg| as a Channel ID message, and verifies
3931
+ // tls1_verify_channel_id processes `msg` as a Channel ID message, and verifies
4066
3932
  // the signature. If the key is valid, it saves the Channel ID and returns true.
4067
3933
  // Otherwise, it returns false.
4068
3934
  bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg);
4069
3935
 
4070
3936
  // tls1_write_channel_id generates a Channel ID message and puts the output in
4071
- // |cbb|. |ssl->channel_id_private| must already be set before calling. This
3937
+ // `cbb`. `ssl->channel_id_private` must already be set before calling. This
4072
3938
  // function returns true on success and false on error.
4073
3939
  bool tls1_write_channel_id(SSL_HANDSHAKE *hs, CBB *cbb);
4074
3940
 
4075
3941
  // tls1_channel_id_hash computes the hash to be signed by Channel ID and writes
4076
- // it to |out|, which must contain at least |EVP_MAX_MD_SIZE| bytes. It returns
3942
+ // it to `out`, which must contain at least `EVP_MAX_MD_SIZE` bytes. It returns
4077
3943
  // true on success and false on failure.
4078
3944
  bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len);
4079
3945
 
4080
3946
  // tls1_record_handshake_hashes_for_channel_id records the current handshake
4081
- // hashes in |hs->new_session| so that Channel ID resumptions can sign that
3947
+ // hashes in `hs->new_session` so that Channel ID resumptions can sign that
4082
3948
  // data.
4083
3949
  bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs);
4084
3950
 
4085
- // ssl_can_write returns whether |ssl| is allowed to write.
4086
- bool ssl_can_write(const SSL *ssl);
3951
+ // ssl_can_write returns whether `ssl` is allowed to write.
3952
+ bool ssl_can_write(const SSLImpl *ssl);
4087
3953
 
4088
- // ssl_can_read returns wheter |ssl| is allowed to read.
4089
- bool ssl_can_read(const SSL *ssl);
3954
+ // ssl_can_read returns whether `ssl` is allowed to read.
3955
+ bool ssl_can_read(const SSLImpl *ssl);
4090
3956
 
4091
- OPENSSL_timeval ssl_ctx_get_current_time(const SSL_CTX *ctx);
3957
+ OPENSSL_timeval ssl_ctx_get_current_time(const SSLContext *ctx);
4092
3958
 
4093
- // ssl_reset_error_state resets state for |SSL_get_error|.
4094
- void ssl_reset_error_state(SSL *ssl);
3959
+ // ssl_reset_error_state resets state for `SSL_get_error`.
3960
+ void ssl_reset_error_state(SSLImpl *ssl);
4095
3961
 
4096
- // ssl_set_read_error sets |ssl|'s read half into an error state, saving the
3962
+ // ssl_set_read_error sets `ssl`'s read half into an error state, saving the
4097
3963
  // current state of the error queue.
4098
- void ssl_set_read_error(SSL *ssl);
4099
-
4100
- BSSL_NAMESPACE_END
4101
-
4102
-
4103
- // Opaque C types.
4104
- //
4105
- // The following types are exported to C code as public typedefs, so they must
4106
- // be defined outside of the namespace.
4107
-
4108
- // ssl_method_st backs the public |SSL_METHOD| type. It is a compatibility
4109
- // structure to support the legacy version-locked methods.
4110
- struct ssl_method_st {
4111
- // version, if non-zero, is the only protocol version acceptable to an
4112
- // SSL_CTX initialized from this method.
4113
- uint16_t version;
4114
- // method is the underlying SSL_PROTOCOL_METHOD that initializes the
4115
- // SSL_CTX.
4116
- const bssl::SSL_PROTOCOL_METHOD *method;
4117
- // x509_method contains pointers to functions that might deal with |X509|
4118
- // compatibility, or might be a no-op, depending on the application.
4119
- const bssl::SSL_X509_METHOD *x509_method;
4120
- };
3964
+ void ssl_set_read_error(SSLImpl *ssl);
4121
3965
 
4122
- struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4123
- explicit ssl_ctx_st(const SSL_METHOD *ssl_method);
4124
- ssl_ctx_st(const ssl_ctx_st &) = delete;
4125
- ssl_ctx_st &operator=(const ssl_ctx_st &) = delete;
3966
+ class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
3967
+ public:
3968
+ explicit SSLContext(const SSL_METHOD *ssl_method);
3969
+ SSLContext(const SSLContext &) = delete;
3970
+ SSLContext &operator=(const SSLContext &) = delete;
4126
3971
 
4127
- const bssl::SSL_PROTOCOL_METHOD *method = nullptr;
4128
- const bssl::SSL_X509_METHOD *x509_method = nullptr;
3972
+ const SSL_PROTOCOL_METHOD *method = nullptr;
3973
+ const SSL_X509_METHOD *x509_method = nullptr;
4129
3974
 
4130
3975
  // lock is used to protect various operations on this object.
4131
- CRYPTO_MUTEX lock;
3976
+ mutable Mutex lock;
4132
3977
 
4133
3978
  // conf_max_version is the maximum acceptable protocol version configured by
4134
- // |SSL_CTX_set_max_proto_version|. Note this version is normalized in DTLS
4135
- // and is further constrainted by |SSL_OP_NO_*|.
3979
+ // `SSL_CTX_set_max_proto_version`. Note this version is normalized in DTLS
3980
+ // and is further constrained by `SSL_OP_NO_*`.
4136
3981
  uint16_t conf_max_version = 0;
4137
3982
 
4138
3983
  // conf_min_version is the minimum acceptable protocol version configured by
4139
- // |SSL_CTX_set_min_proto_version|. Note this version is normalized in DTLS
4140
- // and is further constrainted by |SSL_OP_NO_*|.
3984
+ // `SSL_CTX_set_min_proto_version`. Note this version is normalized in DTLS
3985
+ // and is further constrained by `SSL_OP_NO_*`.
4141
3986
  uint16_t conf_min_version = 0;
4142
3987
 
4143
3988
  // num_tickets is the number of tickets to send immediately after the TLS 1.3
@@ -4148,15 +3993,17 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4148
3993
  // quic_method is the method table corresponding to the QUIC hooks.
4149
3994
  const SSL_QUIC_METHOD *quic_method = nullptr;
4150
3995
 
4151
- bssl::UniquePtr<bssl::SSLCipherPreferenceList> cipher_list;
3996
+ UniquePtr<SSLCipherPreferenceList> cipher_list; // for TLS 1.2 ciphers.
3997
+ SSLCipherPreferenceList tls13_cipher_list;
4152
3998
 
4153
3999
  X509_STORE *cert_store = nullptr;
4000
+ // TODO(crbug.com/565766495): Switch this to `SSLSession`.
4154
4001
  LHASH_OF(SSL_SESSION) *sessions = nullptr;
4155
4002
  // Most session-ids that will be cached, default is
4156
4003
  // SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.
4157
4004
  unsigned long session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT;
4158
- SSL_SESSION *session_cache_head = nullptr;
4159
- SSL_SESSION *session_cache_tail = nullptr;
4005
+ SSLSession *session_cache_head = nullptr;
4006
+ SSLSession *session_cache_tail = nullptr;
4160
4007
 
4161
4008
  // handshakes_since_cache_flush is the number of successful handshakes since
4162
4009
  // the last cache flush.
@@ -4213,28 +4060,28 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4213
4060
  void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
4214
4061
 
4215
4062
  // what we put in client cert requests
4216
- bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
4063
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
4217
4064
 
4218
4065
  // cached_x509_client_CA is a cache of parsed versions of the elements of
4219
- // |client_CA|.
4066
+ // `client_CA`.
4220
4067
  STACK_OF(X509_NAME) *cached_x509_client_CA = nullptr;
4221
4068
 
4222
4069
  // What we put in client hello in the CA extension.
4223
- bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> CA_names;
4070
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> CA_names;
4224
4071
 
4225
4072
  // What we request in the trust_anchors extension.
4226
- std::optional<bssl::Array<uint8_t>> requested_trust_anchors;
4073
+ std::optional<Array<uint8_t>> requested_trust_anchors;
4227
4074
 
4228
4075
  // Default values to use in SSL structures follow (these are copied by
4229
4076
  // SSL_new)
4230
4077
 
4231
- uint32_t options = 0;
4078
+ uint32_t options = SSL_OP_ALL;
4232
4079
  // Disable the auto-chaining feature by default. wpa_supplicant relies on this
4233
4080
  // feature, but require callers opt into it.
4234
4081
  uint32_t mode = SSL_MODE_NO_AUTO_CHAIN;
4235
4082
  uint32_t max_cert_list = SSL_MAX_CERT_LIST_DEFAULT;
4236
4083
 
4237
- bssl::UniquePtr<bssl::CERT> cert;
4084
+ UniquePtr<CERT> cert;
4238
4085
 
4239
4086
  // callback that allows applications to peek at protocol messages
4240
4087
  void (*msg_callback)(int is_write, int version, int content_type,
@@ -4250,7 +4097,7 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4250
4097
 
4251
4098
  // select_certificate_cb is called before most ClientHello processing and
4252
4099
  // before the decision whether to resume a session is made. See
4253
- // |ssl_select_cert_result_t| for details of the return values.
4100
+ // `ssl_select_cert_result_t` for details of the return values.
4254
4101
  ssl_select_cert_result_t (*select_certificate_cb)(const SSL_CLIENT_HELLO *) =
4255
4102
  nullptr;
4256
4103
 
@@ -4272,12 +4119,12 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4272
4119
  int (*servername_callback)(SSL *, int *, void *) = nullptr;
4273
4120
  void *servername_arg = nullptr;
4274
4121
 
4275
- // RFC 4507 session ticket keys. |ticket_key_current| may be NULL before the
4276
- // first handshake and |ticket_key_prev| may be NULL at any time.
4122
+ // RFC 4507 session ticket keys. `ticket_key_current` may be NULL before the
4123
+ // first handshake and `ticket_key_prev` may be NULL at any time.
4277
4124
  // Automatically generated ticket keys are rotated as needed at handshake
4278
- // time. Hence, all access must be synchronized through |lock|.
4279
- bssl::UniquePtr<bssl::TicketKey> ticket_key_current;
4280
- bssl::UniquePtr<bssl::TicketKey> ticket_key_prev;
4125
+ // time. Hence, all access must be synchronized through `lock`.
4126
+ UniquePtr<TicketKey> ticket_key_current;
4127
+ UniquePtr<TicketKey> ticket_key_prev;
4281
4128
 
4282
4129
  // Callback to support customisation of ticket key setting
4283
4130
  int (*ticket_key_cb)(SSL *ssl, uint8_t *name, uint8_t *iv,
@@ -4285,7 +4132,7 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4285
4132
 
4286
4133
  // Server-only: psk_identity_hint is the default identity hint to send in
4287
4134
  // PSK-based key exchanges.
4288
- bssl::UniquePtr<char> psk_identity_hint;
4135
+ UniquePtr<char> psk_identity_hint;
4289
4136
 
4290
4137
  unsigned (*psk_client_callback)(SSL *ssl, const char *hint, char *identity,
4291
4138
  unsigned max_identity_len, uint8_t *psk,
@@ -4316,10 +4163,10 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4316
4163
  // server to select the protocol for the connection.
4317
4164
  // out: on successful return, this must point to the raw protocol
4318
4165
  // name (without the length prefix).
4319
- // outlen: on successful return, this contains the length of |*out|.
4166
+ // outlen: on successful return, this contains the length of `*out`.
4320
4167
  // in: points to the client's list of supported protocols in
4321
4168
  // wire-format.
4322
- // inlen: the length of |in|.
4169
+ // inlen: the length of `in`.
4323
4170
  int (*alpn_select_cb)(SSL *ssl, const uint8_t **out, uint8_t *out_len,
4324
4171
  const uint8_t *in, unsigned in_len,
4325
4172
  void *arg) = nullptr;
@@ -4327,38 +4174,39 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4327
4174
 
4328
4175
  // For a client, this contains the list of supported protocols in wire
4329
4176
  // format.
4330
- bssl::Array<uint8_t> alpn_client_proto_list;
4177
+ Array<uint8_t> alpn_client_proto_list;
4331
4178
 
4332
4179
  // SRTP profiles we are willing to do from RFC 5764
4333
- bssl::UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> srtp_profiles;
4180
+ UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> srtp_profiles;
4334
4181
 
4335
4182
  // Defined compression algorithms for certificates.
4336
- bssl::Vector<bssl::CertCompressionAlg> cert_compression_algs;
4183
+ Vector<CertCompressionAlg> cert_compression_algs;
4337
4184
 
4338
- // Supported group values inherited by SSL structure
4339
- bssl::Array<uint16_t> supported_group_list;
4185
+ // Supported group values and flags inherited by SSL structure
4186
+ Array<uint16_t> supported_group_list;
4187
+ Array<uint32_t> supported_group_list_flags;
4340
4188
 
4341
4189
  // channel_id_private is the client's Channel ID private key, or null if
4342
4190
  // Channel ID should not be offered on this connection.
4343
- bssl::UniquePtr<EVP_PKEY> channel_id_private;
4191
+ UniquePtr<EVP_PKEY> channel_id_private;
4344
4192
 
4345
4193
  // ech_keys contains the server's list of ECHConfig values and associated
4346
4194
  // private keys. This list may be swapped out at any time, so all access must
4347
- // be synchronized through |lock|.
4348
- bssl::UniquePtr<SSL_ECH_KEYS> ech_keys;
4195
+ // be synchronized through `lock`.
4196
+ UniquePtr<SSLECHKeys> ech_keys;
4349
4197
 
4350
4198
  // keylog_callback, if not NULL, is the key logging callback. See
4351
- // |SSL_CTX_set_keylog_callback|.
4199
+ // `SSL_CTX_set_keylog_callback`.
4352
4200
  void (*keylog_callback)(const SSL *ssl, const char *line) = nullptr;
4353
4201
 
4354
4202
  // current_time_cb, if not NULL, is the function to use to get the current
4355
- // time. It sets |*out_clock| to the current time. The |ssl| argument is
4356
- // always NULL. See |SSL_CTX_set_current_time_cb|.
4203
+ // time. It sets `*out_clock` to the current time. The `ssl` argument is
4204
+ // always NULL. See `SSL_CTX_set_current_time_cb`.
4357
4205
  void (*current_time_cb)(const SSL *ssl, struct timeval *out_clock) = nullptr;
4358
4206
 
4359
- // pool is used for all |CRYPTO_BUFFER|s in case we wish to share certificate
4207
+ // pool is used for all `CRYPTO_BUFFER`s in case we wish to share certificate
4360
4208
  // memory.
4361
- CRYPTO_BUFFER_POOL *pool = nullptr;
4209
+ UniquePtr<CRYPTO_BUFFER_POOL> pool;
4362
4210
 
4363
4211
  // ticket_aead_method contains function pointers for opening and sealing
4364
4212
  // session tickets.
@@ -4375,7 +4223,13 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4375
4223
 
4376
4224
  // verify_sigalgs, if not empty, is the set of signature algorithms
4377
4225
  // accepted from the peer in decreasing order of preference.
4378
- bssl::Array<uint16_t> verify_sigalgs;
4226
+ Array<uint16_t> verify_sigalgs;
4227
+
4228
+ // accepted_peer_cert_types inherited by SSL struct.
4229
+ InplaceVector<uint8_t, kNumCertTypes> accepted_peer_cert_types;
4230
+
4231
+ // available_client_cert_types inherited by SSL struct.
4232
+ InplaceVector<uint8_t, kNumCertTypes> available_client_cert_types;
4379
4233
 
4380
4234
  // retain_only_sha256_of_client_certs is true if we should compute the SHA256
4381
4235
  // hash of the peer's certificate and then discard it to save memory and
@@ -4401,6 +4255,11 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4401
4255
  // grease_enabled is whether GREASE (RFC 8701) is enabled.
4402
4256
  bool grease_enabled : 1;
4403
4257
 
4258
+ // grease_sigalgs_enabled controls whether GREASE signature algorithms may be
4259
+ // sent.
4260
+ // TODO(crbug.com/526597789): Fold into `grease_enabled` once deployed safely.
4261
+ bool grease_sigalgs_enabled : 1;
4262
+
4404
4263
  // permute_extensions is whether to permute extensions when sending messages.
4405
4264
  bool permute_extensions : 1;
4406
4265
 
@@ -4409,66 +4268,60 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
4409
4268
  bool allow_unknown_alpn_protos : 1;
4410
4269
 
4411
4270
  // false_start_allowed_without_alpn is whether False Start (if
4412
- // |SSL_MODE_ENABLE_FALSE_START| is enabled) is allowed without ALPN.
4271
+ // `SSL_MODE_ENABLE_FALSE_START` is enabled) is allowed without ALPN.
4413
4272
  bool false_start_allowed_without_alpn : 1;
4414
4273
 
4415
4274
  // handoff indicates that a server should stop after receiving the
4416
- // ClientHello and pause the handshake in such a way that |SSL_get_error|
4417
- // returns |SSL_ERROR_HANDOFF|.
4275
+ // ClientHello and pause the handshake in such a way that `SSL_get_error`
4276
+ // returns `SSL_ERROR_HANDOFF`.
4418
4277
  bool handoff : 1;
4419
4278
 
4420
4279
  // If enable_early_data is true, early data can be sent and accepted.
4421
4280
  bool enable_early_data : 1;
4422
4281
 
4423
- // aes_hw_override if set indicates we should override checking for AES
4424
- // hardware support, and use the value in aes_hw_override_value instead.
4425
- bool aes_hw_override : 1;
4426
-
4427
- // aes_hw_override_value is used for testing to indicate the support or lack
4428
- // of support for AES hardware. The value is only considered if
4429
- // |aes_hw_override| is true.
4430
- bool aes_hw_override_value : 1;
4431
-
4432
4282
  // resumption_across_names_enabled indicates whether a TLS 1.3 server should
4433
4283
  // signal its sessions may be resumed across names in the server certificate.
4434
4284
  bool resumption_across_names_enabled : 1;
4435
4285
 
4436
4286
  private:
4437
4287
  friend RefCounted;
4438
- ~ssl_ctx_st();
4288
+ ~SSLContext();
4439
4289
  };
4440
4290
 
4441
- struct ssl_st {
4442
- explicit ssl_st(SSL_CTX *ctx_arg);
4443
- ssl_st(const ssl_st &) = delete;
4444
- ssl_st &operator=(const ssl_st &) = delete;
4445
- ~ssl_st();
4291
+ class SSLImpl : public ssl_st {
4292
+ public:
4293
+ static constexpr bool kAllowUniquePtr = true;
4294
+
4295
+ explicit SSLImpl(SSLContext *ctx_arg);
4296
+ SSLImpl(const SSLImpl &) = delete;
4297
+ SSLImpl &operator=(const SSLImpl &) = delete;
4298
+ ~SSLImpl();
4446
4299
 
4447
4300
  // method is the method table corresponding to the current protocol (DTLS or
4448
4301
  // TLS).
4449
- const bssl::SSL_PROTOCOL_METHOD *method = nullptr;
4302
+ const SSL_PROTOCOL_METHOD *method = nullptr;
4450
4303
 
4451
4304
  // config is a container for handshake configuration. Accesses to this field
4452
4305
  // should check for nullptr, since configuration may be shed after the
4453
- // handshake completes. (If you have the |SSL_HANDSHAKE| object at hand, use
4306
+ // handshake completes. (If you have the `SSL_HANDSHAKE` object at hand, use
4454
4307
  // that instead, and skip the null check.)
4455
- bssl::UniquePtr<bssl::SSL_CONFIG> config;
4308
+ UniquePtr<SSL_CONFIG> config;
4456
4309
 
4457
4310
  uint16_t max_send_fragment = 0;
4458
4311
 
4459
4312
  // There are 2 BIO's even though they are normally both the same. This is so
4460
4313
  // data can be read and written to different handlers
4461
4314
 
4462
- bssl::UniquePtr<BIO> rbio; // used by SSL_read
4463
- bssl::UniquePtr<BIO> wbio; // used by SSL_write
4315
+ UniquePtr<BIO> rbio; // used by SSL_read
4316
+ UniquePtr<BIO> wbio; // used by SSL_write
4464
4317
 
4465
- // do_handshake runs the handshake. On completion, it returns |ssl_hs_ok|.
4318
+ // do_handshake runs the handshake. On completion, it returns `ssl_hs_ok`.
4466
4319
  // Otherwise, it returns a value corresponding to what operation is needed to
4467
4320
  // progress.
4468
- bssl::ssl_hs_wait_t (*do_handshake)(bssl::SSL_HANDSHAKE *hs) = nullptr;
4321
+ ssl_hs_wait_t (*do_handshake)(SSL_HANDSHAKE *hs) = nullptr;
4469
4322
 
4470
- bssl::SSL3_STATE *s3 = nullptr; // TLS variables
4471
- bssl::DTLS1_STATE *d1 = nullptr; // DTLS variables
4323
+ SSL3_STATE *s3 = nullptr; // TLS variables
4324
+ DTLS1_STATE *d1 = nullptr; // DTLS variables
4472
4325
 
4473
4326
  // callback that allows applications to peek at protocol messages
4474
4327
  void (*msg_callback)(int write_p, int version, int content_type,
@@ -4485,15 +4338,15 @@ struct ssl_st {
4485
4338
 
4486
4339
  // session is the configured session to be offered by the client. This session
4487
4340
  // is immutable.
4488
- bssl::UniquePtr<SSL_SESSION> session;
4341
+ UniquePtr<SSLSession> session;
4489
4342
 
4490
4343
  void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
4491
4344
 
4492
- bssl::UniquePtr<SSL_CTX> ctx;
4345
+ UniquePtr<SSLContext> ctx;
4493
4346
 
4494
- // session_ctx is the |SSL_CTX| used for the session cache and related
4347
+ // session_ctx is the `SSLContext` used for the session cache and related
4495
4348
  // settings.
4496
- bssl::UniquePtr<SSL_CTX> session_ctx;
4349
+ UniquePtr<SSLContext> session_ctx;
4497
4350
 
4498
4351
  // extra application data
4499
4352
  CRYPTO_EX_DATA ex_data;
@@ -4501,7 +4354,7 @@ struct ssl_st {
4501
4354
  uint32_t options = 0; // protocol behaviour
4502
4355
  uint32_t mode = 0; // API behaviour
4503
4356
  uint32_t max_cert_list = 0;
4504
- bssl::UniquePtr<char> hostname;
4357
+ UniquePtr<char> hostname;
4505
4358
 
4506
4359
  // quic_method is the method table corresponding to the QUIC hooks.
4507
4360
  const SSL_QUIC_METHOD *quic_method = nullptr;
@@ -4509,7 +4362,7 @@ struct ssl_st {
4509
4362
  // renegotiate_mode controls how peer renegotiation attempts are handled.
4510
4363
  ssl_renegotiate_mode_t renegotiate_mode = ssl_renegotiate_never;
4511
4364
 
4512
- // server is true iff the this SSL* is the server half. Note: before the SSL*
4365
+ // server is true iff this SSL* is the server half. Note: before the SSL*
4513
4366
  // is initialized by either SSL_set_accept_state or SSL_set_connect_state,
4514
4367
  // the side is not determined. In this state, server is always false.
4515
4368
  bool server : 1;
@@ -4526,10 +4379,11 @@ struct ssl_st {
4526
4379
  bool resumption_across_names_enabled : 1;
4527
4380
  };
4528
4381
 
4529
- struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4530
- explicit ssl_session_st(const bssl::SSL_X509_METHOD *method);
4531
- ssl_session_st(const ssl_session_st &) = delete;
4532
- ssl_session_st &operator=(const ssl_session_st &) = delete;
4382
+ class SSLSession : public ssl_session_st, public RefCounted<SSLSession> {
4383
+ public:
4384
+ explicit SSLSession(const SSL_X509_METHOD *method);
4385
+ SSLSession(const SSLSession &) = delete;
4386
+ SSLSession &operator=(const SSLSession &) = delete;
4533
4387
 
4534
4388
  // ssl_version is the (D)TLS version that established the session.
4535
4389
  uint16_t ssl_version = 0;
@@ -4544,50 +4398,53 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4544
4398
 
4545
4399
  // secret, in TLS 1.2 and below, is the master secret associated with the
4546
4400
  // 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 |SSL|
4401
+ // the caller, but it stores the resumption secret when stored on `SSL`
4548
4402
  // objects.
4549
- bssl::InplaceVector<uint8_t, SSL_MAX_MASTER_KEY_LENGTH> secret;
4403
+ InplaceVector<uint8_t, SSL_MAX_MASTER_KEY_LENGTH> secret;
4550
4404
 
4551
- bssl::InplaceVector<uint8_t, SSL_MAX_SSL_SESSION_ID_LENGTH> session_id;
4405
+ InplaceVector<uint8_t, SSL_MAX_SSL_SESSION_ID_LENGTH> session_id;
4552
4406
 
4553
4407
  // this is used to determine whether the session is being reused in
4554
4408
  // the appropriate context. It is up to the application to set this,
4555
4409
  // via SSL_new
4556
- bssl::InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
4410
+ InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
4557
4411
 
4558
- bssl::UniquePtr<char> psk_identity;
4412
+ UniquePtr<char> psk_identity;
4559
4413
 
4560
4414
  // certs contains the certificate chain from the peer, starting with the leaf
4561
- // certificate.
4562
- bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> certs;
4415
+ // certificate. This must be null if `peer_raw_public_key` is non-null.
4416
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> certs;
4563
4417
 
4564
- const bssl::SSL_X509_METHOD *x509_method = nullptr;
4418
+ const SSL_X509_METHOD *x509_method = nullptr;
4565
4419
 
4566
- // x509_peer is the peer's certificate.
4420
+ // x509_peer is the peer's certificate. This must be null if
4421
+ // `peer_raw_public_key` is non-null.
4567
4422
  X509 *x509_peer = nullptr;
4568
4423
 
4569
4424
  // x509_chain is the certificate chain sent by the peer. NOTE: for historical
4570
4425
  // reasons, when a client (so the peer is a server), the chain includes
4571
- // |peer|, but when a server it does not.
4426
+ // `peer`, but when a server it does not. This must be null if
4427
+ // `peer_raw_public_key` is non-null.
4572
4428
  STACK_OF(X509) *x509_chain = nullptr;
4573
4429
 
4574
- // x509_chain_without_leaf is a lazily constructed copy of |x509_chain| that
4430
+ // x509_chain_without_leaf is a lazily constructed copy of `x509_chain` that
4575
4431
  // omits the leaf certificate. This exists because OpenSSL, historically,
4576
4432
  // didn't include the leaf certificate in the chain for a server, but did for
4577
- // a client. The |x509_chain| always includes it and, if an API call requires
4578
- // a chain without, it is stored here.
4433
+ // a client. The `x509_chain` always includes it and, if an API call requires
4434
+ // a chain without, it is stored here. This must be null if
4435
+ // `peer_raw_public_key` is non-null.
4579
4436
  STACK_OF(X509) *x509_chain_without_leaf = nullptr;
4580
4437
 
4581
4438
  // verify_result is the result of certificate verification in the case of
4582
4439
  // non-fatal certificate errors.
4583
4440
  long verify_result = X509_V_ERR_INVALID_CALL;
4584
4441
 
4585
- // timeout is the lifetime of the session in seconds, measured from |time|.
4586
- // This is renewable up to |auth_timeout|.
4442
+ // timeout is the lifetime of the session in seconds, measured from `time`.
4443
+ // This is renewable up to `auth_timeout`.
4587
4444
  uint32_t timeout = SSL_DEFAULT_SESSION_TIMEOUT;
4588
4445
 
4589
4446
  // auth_timeout is the non-renewable lifetime of the session in seconds,
4590
- // measured from |time|.
4447
+ // measured from `time`.
4591
4448
  uint32_t auth_timeout = SSL_DEFAULT_SESSION_TIMEOUT;
4592
4449
 
4593
4450
  // time is the time the session was issued, measured in seconds from the UNIX
@@ -4600,23 +4457,29 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4600
4457
 
4601
4458
  // These are used to make removal of session-ids more efficient and to
4602
4459
  // implement a maximum cache size.
4603
- SSL_SESSION *prev = nullptr, *next = nullptr;
4460
+ //
4461
+ // TODO(crbug.com/527997772): At the ends of the list, `prev` and `next` point
4462
+ // to `session_cache_head` and `session_cache_tail` on `SSLContext`. These
4463
+ // sentinel values are not real sessions, so they must never be dereferenced
4464
+ // or converted to `SSL_SESSION`.
4465
+ SSLSession *prev = nullptr, *next = nullptr;
4604
4466
 
4605
- bssl::Array<uint8_t> ticket;
4467
+ Array<uint8_t> ticket;
4606
4468
 
4607
- bssl::UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
4469
+ UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
4608
4470
 
4609
4471
  // The OCSP response that came with the session.
4610
- bssl::UniquePtr<CRYPTO_BUFFER> ocsp_response;
4472
+ UniquePtr<CRYPTO_BUFFER> ocsp_response;
4611
4473
 
4612
- // peer_sha256 contains the SHA-256 hash of the peer's certificate if
4613
- // |peer_sha256_valid| is true.
4474
+ // peer_sha256 contains the SHA-256 hash of the peer's X.509 certificate or
4475
+ // raw public key if `peer_sha256_valid` is true. (`peer_cert_type` indicates
4476
+ // which type of credential is hashed here.)
4614
4477
  uint8_t peer_sha256[SHA256_DIGEST_LENGTH] = {0};
4615
4478
 
4616
4479
  // original_handshake_hash contains the handshake hash (either SHA-1+MD5 or
4617
4480
  // SHA-2, depending on TLS version) for the original, full handshake that
4618
4481
  // created a session. This is used by Channel IDs during resumption.
4619
- bssl::InplaceVector<uint8_t, SSL_MAX_MD_SIZE> original_handshake_hash;
4482
+ InplaceVector<uint8_t, SSL_MAX_MD_SIZE> original_handshake_hash;
4620
4483
 
4621
4484
  uint32_t ticket_lifetime_hint = 0; // Session lifetime hint in seconds
4622
4485
 
@@ -4629,29 +4492,29 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4629
4492
  // early_alpn is the ALPN protocol from the initial handshake. This is only
4630
4493
  // stored for TLS 1.3 and above in order to enforce ALPN matching for 0-RTT
4631
4494
  // resumptions. For the current connection's ALPN protocol, see
4632
- // |alpn_selected| on |SSL3_STATE|.
4633
- bssl::Array<uint8_t> early_alpn;
4495
+ // `alpn_selected` on `SSL3_STATE`.
4496
+ Array<uint8_t> early_alpn;
4634
4497
 
4635
- // local_application_settings, if |has_application_settings| is true, is the
4498
+ // local_application_settings, if `has_application_settings` is true, is the
4636
4499
  // local ALPS value for this connection.
4637
- bssl::Array<uint8_t> local_application_settings;
4500
+ Array<uint8_t> local_application_settings;
4638
4501
 
4639
- // peer_application_settings, if |has_application_settings| is true, is the
4502
+ // peer_application_settings, if `has_application_settings` is true, is the
4640
4503
  // peer ALPS value for this connection.
4641
- bssl::Array<uint8_t> peer_application_settings;
4504
+ Array<uint8_t> peer_application_settings;
4642
4505
 
4643
4506
  // extended_master_secret is whether the master secret in this session was
4644
4507
  // generated using EMS and thus isn't vulnerable to the Triple Handshake
4645
4508
  // attack.
4646
4509
  bool extended_master_secret : 1;
4647
4510
 
4648
- // peer_sha256_valid is whether |peer_sha256| is valid.
4511
+ // peer_sha256_valid is whether `peer_sha256` is valid.
4649
4512
  bool peer_sha256_valid : 1; // Non-zero if peer_sha256 is valid
4650
4513
 
4651
4514
  // not_resumable is used to indicate that session resumption is disallowed.
4652
4515
  bool not_resumable : 1;
4653
4516
 
4654
- // ticket_age_add_valid is whether |ticket_age_add| is valid.
4517
+ // ticket_age_add_valid is whether `ticket_age_add` is valid.
4655
4518
  bool ticket_age_add_valid : 1;
4656
4519
 
4657
4520
  // is_server is whether this session was created by a server.
@@ -4670,21 +4533,45 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4670
4533
 
4671
4534
  // quic_early_data_context is used to determine whether early data must be
4672
4535
  // rejected when performing a QUIC handshake.
4673
- bssl::Array<uint8_t> quic_early_data_context;
4536
+ Array<uint8_t> quic_early_data_context;
4537
+
4538
+ // peer_cert_type is the peer's cert type (`TLSEXT_cert_type_*` value), which
4539
+ // determines the type of Certificate the peer used for this session: which of
4540
+ // `certs` xor `peer_raw_public_key` is populated for an authenticated
4541
+ // session.
4542
+ uint8_t peer_cert_type = kDefaultCertType;
4543
+
4544
+ // peer_raw_public_key, if non-null, is the raw public key received from the
4545
+ // peer. This must be null if `certs` is non-null.
4546
+ UniquePtr<EVP_PKEY> peer_raw_public_key;
4674
4547
 
4675
4548
  private:
4676
4549
  friend RefCounted;
4677
- ~ssl_session_st();
4550
+ ~SSLSession();
4678
4551
  };
4679
4552
 
4680
- struct ssl_ech_keys_st : public bssl::RefCounted<ssl_ech_keys_st> {
4681
- ssl_ech_keys_st() : RefCounted(CheckSubClass()) {}
4553
+ BSSL_NAMESPACE_END
4682
4554
 
4683
- bssl::Vector<bssl::UniquePtr<bssl::ECHServerConfig>> configs;
4684
4555
 
4685
- private:
4686
- friend RefCounted;
4687
- ~ssl_ech_keys_st() = default;
4556
+ // Opaque C types.
4557
+ //
4558
+ // `SSL_METHOD` is exported to C code as public typedefs, so it must be defined
4559
+ // outside of the namespace. We can switch it to `DECLARE_OPAQUE_STRUCT` if
4560
+ // becomes more complex than a plain struct.
4561
+
4562
+ // ssl_method_st backs the public `SSL_METHOD` type. It is a compatibility
4563
+ // structure to support the legacy version-locked methods.
4564
+ struct ssl_method_st {
4565
+ // version, if non-zero, is the only protocol version acceptable to an
4566
+ // SSL_CTX initialized from this method.
4567
+ uint16_t version;
4568
+ // method is the underlying SSL_PROTOCOL_METHOD that initializes the
4569
+ // SSL_CTX.
4570
+ const bssl::SSL_PROTOCOL_METHOD *method;
4571
+ // x509_method contains pointers to functions that might deal with `X509`
4572
+ // compatibility, or might be a no-op, depending on the application.
4573
+ const bssl::SSL_X509_METHOD *x509_method;
4688
4574
  };
4689
4575
 
4576
+
4690
4577
  #endif // OPENSSL_HEADER_SSL_INTERNAL_H