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
@@ -16,15 +16,19 @@
16
16
 
17
17
  #include <assert.h>
18
18
  #include <limits.h>
19
+ #include <stdint.h>
19
20
  #include <stdlib.h>
20
21
  #include <string.h>
21
22
 
22
23
  #include <algorithm>
24
+ #include <optional>
23
25
  #include <utility>
26
+ #include <variant>
24
27
 
25
28
  #include <openssl/aead.h>
26
29
  #include <openssl/bytestring.h>
27
30
  #include <openssl/chacha.h>
31
+ #include <openssl/cipher.h>
28
32
  #include <openssl/curve25519.h>
29
33
  #include <openssl/digest.h>
30
34
  #include <openssl/err.h>
@@ -33,9 +37,13 @@
33
37
  #include <openssl/hpke.h>
34
38
  #include <openssl/mem.h>
35
39
  #include <openssl/nid.h>
40
+ #include <openssl/pool.h>
36
41
  #include <openssl/rand.h>
42
+ #include <openssl/span.h>
37
43
 
44
+ #include "../crypto/bytestring/internal.h"
38
45
  #include "../crypto/internal.h"
46
+ #include "../crypto/mem_internal.h"
39
47
  #include "../crypto/spake2plus/internal.h"
40
48
  #include "internal.h"
41
49
 
@@ -99,19 +107,13 @@ static bool tls1_check_duplicate_extensions(const CBS *cbs) {
99
107
  }
100
108
 
101
109
  static bool is_post_quantum_group(uint16_t id) {
102
- switch (id) {
103
- case SSL_GROUP_X25519_KYBER768_DRAFT00:
104
- case SSL_GROUP_X25519_MLKEM768:
105
- return true;
106
- default:
107
- return false;
108
- }
110
+ return id == SSL_GROUP_X25519_MLKEM768 || id == SSL_GROUP_MLKEM1024;
109
111
  }
110
112
 
111
- bool ssl_parse_client_hello_with_trailing_data(const SSL *ssl, CBS *cbs,
113
+ bool ssl_parse_client_hello_with_trailing_data(const SSLImpl *ssl, CBS *cbs,
112
114
  SSL_CLIENT_HELLO *out) {
113
115
  OPENSSL_memset(out, 0, sizeof(*out));
114
- out->ssl = const_cast<SSL *>(ssl);
116
+ out->ssl = const_cast<SSLImpl *>(ssl);
115
117
 
116
118
  CBS copy = *cbs;
117
119
  CBS random, session_id;
@@ -199,21 +201,8 @@ bool ssl_client_hello_get_extension(const SSL_CLIENT_HELLO *client_hello,
199
201
  return false;
200
202
  }
201
203
 
202
- static const uint16_t kDefaultGroups[] = {
203
- SSL_GROUP_X25519,
204
- SSL_GROUP_SECP256R1,
205
- SSL_GROUP_SECP384R1,
206
- };
207
-
208
- Span<const uint16_t> tls1_get_grouplist(const SSL_HANDSHAKE *hs) {
209
- if (!hs->config->supported_group_list.empty()) {
210
- return hs->config->supported_group_list;
211
- }
212
- return Span<const uint16_t>(kDefaultGroups);
213
- }
214
-
215
204
  bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id) {
216
- SSL *const ssl = hs->ssl;
205
+ SSLImpl *const ssl = hs->ssl;
217
206
  assert(ssl->server);
218
207
 
219
208
  // Clients are not required to send a supported_groups extension. In this
@@ -222,33 +211,53 @@ bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id) {
222
211
  //
223
212
  // However, in the interests of compatibility, we will skip ECDH if the
224
213
  // client didn't send an extension because we can't be sure that they'll
225
- // support our favoured group. Thus we do not special-case an emtpy
226
- // |peer_supported_group_list|.
214
+ // support our favoured group. Thus we do not special-case an empty
215
+ // `peer_supported_group_list`.
227
216
 
228
- Span<const uint16_t> groups = tls1_get_grouplist(hs);
217
+ Span<const uint16_t> groups = hs->config->supported_group_list;
229
218
  Span<const uint16_t> pref, supp;
219
+ Span<const uint32_t> pref_flags;
230
220
  if (ssl->options & SSL_OP_CIPHER_SERVER_PREFERENCE) {
231
221
  pref = groups;
222
+ pref_flags = hs->config->supported_group_list_flags;
232
223
  supp = hs->peer_supported_group_list;
233
224
  } else {
234
225
  pref = hs->peer_supported_group_list;
235
226
  supp = groups;
236
227
  }
237
228
 
238
- for (uint16_t pref_group : pref) {
239
- for (uint16_t supp_group : supp) {
240
- if (pref_group == supp_group &&
241
- // Post-quantum key agreements don't fit in the u8-length-prefixed
242
- // ECPoint field in TLS 1.2 and below.
243
- (ssl_protocol_version(ssl) >= TLS1_3_VERSION ||
244
- !is_post_quantum_group(pref_group))) {
245
- *out_group_id = pref_group;
246
- return true;
229
+ // Index within `supp` of the best matching group so far.
230
+ std::optional<size_t> best_match;
231
+ for (size_t i = 0u; i < pref.size(); ++i) {
232
+ uint16_t candidate_group = pref[i];
233
+ auto match_it = std::find(supp.begin(), supp.end(), candidate_group);
234
+ // Post-quantum key agreements don't fit in the u8-length-prefixed
235
+ // ECPoint field in TLS 1.2 and below.
236
+ if (ssl_protocol_version(ssl) < TLS1_3_VERSION &&
237
+ is_post_quantum_group(candidate_group)) {
238
+ match_it = supp.end();
239
+ }
240
+ if (match_it != supp.end()) {
241
+ size_t match_idx = match_it - supp.begin();
242
+ if (!best_match.has_value() || match_idx < *best_match) {
243
+ best_match = match_idx;
247
244
  }
248
245
  }
246
+
247
+ // If we found a match, stop at the current equipreference group.
248
+ bool equal_with_next =
249
+ !pref_flags.empty() &&
250
+ (pref_flags[i] & SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT);
251
+ if (!equal_with_next && best_match.has_value()) {
252
+ break;
253
+ }
249
254
  }
250
255
 
251
- return false;
256
+ if (!best_match.has_value()) {
257
+ return false;
258
+ }
259
+ *out_group_id = supp[*best_match];
260
+ return true;
252
261
  }
253
262
 
254
263
  bool tls1_check_group_id(const SSL_HANDSHAKE *hs, uint16_t group_id) {
@@ -263,7 +272,7 @@ bool tls1_check_group_id(const SSL_HANDSHAKE *hs, uint16_t group_id) {
263
272
  return false;
264
273
  }
265
274
 
266
- for (uint16_t supported : tls1_get_grouplist(hs)) {
275
+ for (uint16_t supported : hs->config->supported_group_list) {
267
276
  if (supported == group_id) {
268
277
  return true;
269
278
  }
@@ -296,6 +305,11 @@ static const uint16_t kVerifySignatureAlgorithms[] = {
296
305
  // algorithms for signing.
297
306
  static const uint16_t kSignSignatureAlgorithms[] = {
298
307
  // List our preferred algorithms first.
308
+ SSL_SIGN_ML_DSA_44,
309
+ SSL_SIGN_ML_DSA_65,
310
+ SSL_SIGN_ML_DSA_87,
311
+
312
+ // Classical signature algorithms.
299
313
  SSL_SIGN_ED25519,
300
314
  SSL_SIGN_ECDSA_SECP256R1_SHA256,
301
315
  SSL_SIGN_RSA_PSS_RSAE_SHA256,
@@ -428,7 +442,7 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
428
442
  return false;
429
443
  }
430
444
 
431
- // Check for unsolicited flags that fit in |SSLFlags|.
445
+ // Check for unsolicited flags that fit in `SSLFlags`.
432
446
  if ((*out & allowed_flags) != *out) {
433
447
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
434
448
  *out_alert = SSL_AD_ILLEGAL_PARAMETER;
@@ -440,30 +454,30 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
440
454
 
441
455
  // tls_extension represents a TLS extension that is handled internally.
442
456
  //
443
- // The parse callbacks receive a |CBS| that contains the contents of the
457
+ // The parse callbacks receive a `CBS` that contains the contents of the
444
458
  // extension (i.e. not including the type and length bytes). If an extension is
445
459
  // not received then the parse callbacks will be called with a NULL CBS so that
446
460
  // they can do any processing needed to handle the absence of an extension.
447
461
  //
448
- // The add callbacks receive a |CBB| to which the extension can be appended but
462
+ // The add callbacks receive a `CBB` to which the extension can be appended but
449
463
  // the function is responsible for appending the type and length bytes too.
450
464
  //
451
- // |add_clienthello| may be called multiple times and must not mutate |hs|. It
452
- // is additionally passed two output |CBB|s. If the extension is the same
453
- // independent of the value of |type|, the callback may write to
454
- // |out_compressible| instead of |out|. When serializing the ClientHelloInner,
455
- // all compressible extensions will be made continguous and replaced with
465
+ // `add_clienthello` may be called multiple times and must not mutate `hs`. It
466
+ // is additionally passed two output `CBB`s. If the extension is the same
467
+ // independent of the value of `type`, the callback may write to
468
+ // `out_compressible` instead of `out`. When serializing the ClientHelloInner,
469
+ // all compressible extensions will be made contiguous and replaced with
456
470
  // ech_outer_extensions when encrypted. When serializing the ClientHelloOuter
457
- // or not offering ECH, |out| will be equal to |out_compressible|, so writing to
458
- // |out_compressible| still works.
471
+ // or not offering ECH, `out` will be equal to `out_compressible`, so writing to
472
+ // `out_compressible` still works.
459
473
  //
460
- // Note the |parse_serverhello| and |add_serverhello| callbacks refer to the
474
+ // Note the `parse_serverhello` and `add_serverhello` callbacks refer to the
461
475
  // TLS 1.2 ServerHello. In TLS 1.3, these callbacks act on EncryptedExtensions,
462
476
  // with ServerHello extensions handled elsewhere in the handshake.
463
477
  //
464
478
  // All callbacks return true for success and false for error. If a parse
465
- // function returns zero then a fatal alert with value |*out_alert| will be
466
- // sent. If |*out_alert| isn't set, then a |decode_error| alert will be sent.
479
+ // function returns zero then a fatal alert with value `*out_alert` will be
480
+ // sent. If `*out_alert` isn't set, then a `decode_error` alert will be sent.
467
481
  struct tls_extension {
468
482
  uint16_t value;
469
483
 
@@ -479,7 +493,7 @@ struct tls_extension {
479
493
 
480
494
  static bool forbid_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
481
495
  CBS *contents) {
482
- if (contents != NULL) {
496
+ if (contents != nullptr) {
483
497
  // Servers MUST NOT send this extension.
484
498
  *out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
485
499
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
@@ -504,7 +518,7 @@ static bool dont_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) { return true; }
504
518
  static bool ext_sni_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
505
519
  CBB *out_compressible,
506
520
  ssl_client_hello_type_t type) {
507
- const SSL *const ssl = hs->ssl;
521
+ const SSLImpl *const ssl = hs->ssl;
508
522
  // If offering ECH, send the public name instead of the configured name.
509
523
  Span<const uint8_t> hostname;
510
524
  if (type == ssl_client_hello_outer) {
@@ -534,16 +548,18 @@ static bool ext_sni_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
534
548
  CBS *contents) {
535
549
  // The server may acknowledge SNI with an empty extension. We check the syntax
536
550
  // but otherwise ignore this signal.
537
- return contents == NULL || CBS_len(contents) == 0;
551
+ return contents == nullptr || CBS_len(contents) == 0;
538
552
  }
539
553
 
540
554
  static bool ext_sni_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
541
555
  CBS *contents) {
542
- // SNI has already been parsed earlier in the handshake. See |extract_sni|.
556
+ // SNI has already been parsed earlier in the handshake. See `extract_sni`.
543
557
  return true;
544
558
  }
545
559
 
546
560
  static bool ext_sni_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
561
+ // RFC 6066 says "When resuming a session, the server MUST NOT include a
562
+ // server_name extension in the server hello."
547
563
  if (hs->ssl->s3->session_reused || //
548
564
  !hs->should_ack_sni) {
549
565
  return true;
@@ -560,7 +576,7 @@ static bool ext_sni_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
560
576
 
561
577
  // Encrypted ClientHello (ECH)
562
578
  //
563
- // https://tools.ietf.org/html/draft-ietf-tls-esni-13
579
+ // https://www.rfc-editor.org/rfc/rfc9849.html
564
580
 
565
581
  static bool ext_ech_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
566
582
  CBB *out_compressible,
@@ -592,8 +608,8 @@ static bool ext_ech_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
592
608
 
593
609
  static bool ext_ech_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
594
610
  CBS *contents) {
595
- SSL *const ssl = hs->ssl;
596
- if (contents == NULL) {
611
+ SSLImpl *const ssl = hs->ssl;
612
+ if (contents == nullptr) {
597
613
  return true;
598
614
  }
599
615
 
@@ -644,15 +660,15 @@ static bool ext_ech_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
644
660
  }
645
661
 
646
662
  static bool ext_ech_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
647
- SSL *const ssl = hs->ssl;
663
+ SSLImpl *const ssl = hs->ssl;
648
664
  if (ssl_protocol_version(ssl) < TLS1_3_VERSION ||
649
665
  ssl->s3->ech_status == ssl_ech_accepted || //
650
666
  hs->ech_keys == nullptr) {
651
667
  return true;
652
668
  }
653
669
 
654
- // Write the list of retry configs to |out|. Note |SSL_CTX_set1_ech_keys|
655
- // ensures |ech_keys| contains at least one retry config.
670
+ // Write the list of retry configs to `out`. Note `SSL_CTX_set1_ech_keys`
671
+ // ensures `ech_keys` contains at least one retry config.
656
672
  CBB body, retry_configs;
657
673
  if (!CBB_add_u16(out, TLSEXT_TYPE_encrypted_client_hello) ||
658
674
  !CBB_add_u16_length_prefixed(out, &body) ||
@@ -679,7 +695,7 @@ static bool ext_ech_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
679
695
  static bool ext_ri_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
680
696
  CBB *out_compressible,
681
697
  ssl_client_hello_type_t type) {
682
- const SSL *const ssl = hs->ssl;
698
+ const SSLImpl *const ssl = hs->ssl;
683
699
  // Renegotiation indication is not necessary in TLS 1.3.
684
700
  if (hs->min_version >= TLS1_3_VERSION || //
685
701
  type == ssl_client_hello_inner) {
@@ -704,29 +720,35 @@ static bool ext_ri_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
704
720
 
705
721
  static bool ext_ri_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
706
722
  CBS *contents) {
707
- SSL *const ssl = hs->ssl;
708
- if (contents != NULL && ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
709
- *out_alert = SSL_AD_ILLEGAL_PARAMETER;
710
- return false;
723
+ SSLImpl *const ssl = hs->ssl;
724
+ if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
725
+ if (contents != nullptr) {
726
+ *out_alert = SSL_AD_ILLEGAL_PARAMETER;
727
+ return false;
728
+ }
729
+ return true;
711
730
  }
712
731
 
713
732
  // Servers may not switch between omitting the extension and supporting it.
714
733
  // See RFC 5746, sections 3.5 and 4.2.
715
734
  if (ssl->s3->initial_handshake_complete &&
716
- (contents != NULL) != ssl->s3->send_connection_binding) {
735
+ (contents != nullptr) != ssl->s3->send_connection_binding) {
717
736
  *out_alert = SSL_AD_HANDSHAKE_FAILURE;
718
737
  OPENSSL_PUT_ERROR(SSL, SSL_R_RENEGOTIATION_MISMATCH);
719
738
  return false;
720
739
  }
721
740
 
722
- if (contents == NULL) {
741
+ if (contents == nullptr) {
723
742
  // Strictly speaking, if we want to avoid an attack we should *always* see
724
743
  // RI even on initial ServerHello because the client doesn't see any
725
744
  // renegotiation during an attack. However this would mean we could not
726
- // connect to any server which doesn't support RI.
727
- //
728
- // OpenSSL has |SSL_OP_LEGACY_SERVER_CONNECT| to control this, but in
729
- // practical terms every client sets it so it's just assumed here.
745
+ // connect to any server which doesn't support RI. See RFC 5746,
746
+ // section 4.1.
747
+ if (!(ssl->options & SSL_OP_LEGACY_SERVER_CONNECT)) {
748
+ OPENSSL_PUT_ERROR(SSL, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
749
+ *out_alert = SSL_AD_HANDSHAKE_FAILURE;
750
+ return false;
751
+ }
730
752
  return true;
731
753
  }
732
754
 
@@ -777,7 +799,7 @@ static bool ext_ri_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
777
799
 
778
800
  static bool ext_ri_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
779
801
  CBS *contents) {
780
- SSL *const ssl = hs->ssl;
802
+ SSLImpl *const ssl = hs->ssl;
781
803
  // Renegotiation isn't supported as a server so this function should never be
782
804
  // called after the initial handshake.
783
805
  assert(!ssl->s3->initial_handshake_complete);
@@ -786,7 +808,8 @@ static bool ext_ri_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
786
808
  return true;
787
809
  }
788
810
 
789
- if (contents == NULL) {
811
+ if (contents == nullptr) {
812
+ // Permit clients to omit the extension. We never renegotiate as a server.
790
813
  return true;
791
814
  }
792
815
 
@@ -811,7 +834,7 @@ static bool ext_ri_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
811
834
  }
812
835
 
813
836
  static bool ext_ri_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
814
- SSL *const ssl = hs->ssl;
837
+ SSLImpl *const ssl = hs->ssl;
815
838
  // Renegotiation isn't supported as a server so this function should never be
816
839
  // called after the initial handshake.
817
840
  assert(!ssl->s3->initial_handshake_complete);
@@ -852,9 +875,9 @@ static bool ext_ems_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
852
875
 
853
876
  static bool ext_ems_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
854
877
  CBS *contents) {
855
- SSL *const ssl = hs->ssl;
878
+ SSLImpl *const ssl = hs->ssl;
856
879
 
857
- if (contents != NULL) {
880
+ if (contents != nullptr) {
858
881
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION || //
859
882
  CBS_len(contents) != 0) {
860
883
  return false;
@@ -881,7 +904,7 @@ static bool ext_ems_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
881
904
  return true;
882
905
  }
883
906
 
884
- if (contents == NULL) {
907
+ if (contents == nullptr) {
885
908
  return true;
886
909
  }
887
910
 
@@ -914,7 +937,7 @@ static bool ext_ems_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
914
937
  static bool ext_ticket_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
915
938
  CBB *out_compressible,
916
939
  ssl_client_hello_type_t type) {
917
- const SSL *const ssl = hs->ssl;
940
+ const SSLImpl *const ssl = hs->ssl;
918
941
  // TLS 1.3 uses a different ticket extension.
919
942
  if (hs->min_version >= TLS1_3_VERSION || type == ssl_client_hello_inner ||
920
943
  SSL_get_options(ssl) & SSL_OP_NO_TICKET) {
@@ -945,8 +968,8 @@ static bool ext_ticket_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
945
968
 
946
969
  static bool ext_ticket_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
947
970
  CBS *contents) {
948
- SSL *const ssl = hs->ssl;
949
- if (contents == NULL) {
971
+ SSLImpl *const ssl = hs->ssl;
972
+ if (contents == nullptr) {
950
973
  return true;
951
974
  }
952
975
 
@@ -954,7 +977,7 @@ static bool ext_ticket_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
954
977
  return false;
955
978
  }
956
979
 
957
- // If |SSL_OP_NO_TICKET| is set then no extension will have been sent and
980
+ // If `SSL_OP_NO_TICKET` is set then no extension will have been sent and
958
981
  // this function should never be called, even if the server tries to send the
959
982
  // extension.
960
983
  assert((SSL_get_options(ssl) & SSL_OP_NO_TICKET) == 0);
@@ -972,7 +995,7 @@ static bool ext_ticket_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
972
995
  return true;
973
996
  }
974
997
 
975
- // If |SSL_OP_NO_TICKET| is set, |ticket_expected| should never be true.
998
+ // If `SSL_OP_NO_TICKET` is set, `ticket_expected` should never be true.
976
999
  assert((SSL_get_options(hs->ssl) & SSL_OP_NO_TICKET) == 0);
977
1000
 
978
1001
  if (!CBB_add_u16(out, TLSEXT_TYPE_session_ticket) ||
@@ -994,16 +1017,24 @@ static bool ext_sigalgs_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
994
1017
  if (hs->max_version < TLS1_2_VERSION) {
995
1018
  return true;
996
1019
  }
997
- // In PAKE mode, signature_algorithms is not used.
998
- if (hs->pake_prover != nullptr) {
1020
+ // Skip signature_algorithms if we wouldn't accept a certificate mode anyway.
1021
+ if (!ssl_accepts_server_certificate_auth(hs)) {
999
1022
  return true;
1000
1023
  }
1001
1024
 
1002
1025
  CBB contents, sigalgs_cbb;
1003
1026
  if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_signature_algorithms) ||
1004
1027
  !CBB_add_u16_length_prefixed(out_compressible, &contents) ||
1005
- !CBB_add_u16_length_prefixed(&contents, &sigalgs_cbb) ||
1006
- !tls12_add_verify_sigalgs(hs, &sigalgs_cbb) ||
1028
+ !CBB_add_u16_length_prefixed(&contents, &sigalgs_cbb)) {
1029
+ return false;
1030
+ }
1031
+ // Add a fake signature algorithm. See RFC 8701.
1032
+ if (hs->ssl->ctx->grease_sigalgs_enabled &&
1033
+ !CBB_add_u16(&sigalgs_cbb,
1034
+ ssl_get_grease_value(hs, ssl_grease_signature_algorithm))) {
1035
+ return false;
1036
+ }
1037
+ if (!tls12_add_verify_sigalgs(hs, &sigalgs_cbb) ||
1007
1038
  !CBB_flush(out_compressible)) {
1008
1039
  return false;
1009
1040
  }
@@ -1014,7 +1045,7 @@ static bool ext_sigalgs_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1014
1045
  static bool ext_sigalgs_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1015
1046
  CBS *contents) {
1016
1047
  hs->peer_sigalgs.Reset();
1017
- if (contents == NULL) {
1048
+ if (contents == nullptr) {
1018
1049
  return true;
1019
1050
  }
1020
1051
 
@@ -1055,8 +1086,8 @@ static bool ext_ocsp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1055
1086
 
1056
1087
  static bool ext_ocsp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1057
1088
  CBS *contents) {
1058
- SSL *const ssl = hs->ssl;
1059
- if (contents == NULL) {
1089
+ SSLImpl *const ssl = hs->ssl;
1090
+ if (contents == nullptr) {
1060
1091
  return true;
1061
1092
  }
1062
1093
 
@@ -1081,7 +1112,7 @@ static bool ext_ocsp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1081
1112
 
1082
1113
  static bool ext_ocsp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1083
1114
  CBS *contents) {
1084
- if (contents == NULL) {
1115
+ if (contents == nullptr) {
1085
1116
  return true;
1086
1117
  }
1087
1118
 
@@ -1098,7 +1129,7 @@ static bool ext_ocsp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1098
1129
  }
1099
1130
 
1100
1131
  static bool ext_ocsp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1101
- SSL *const ssl = hs->ssl;
1132
+ SSLImpl *const ssl = hs->ssl;
1102
1133
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION ||
1103
1134
  !hs->ocsp_stapling_requested || ssl->s3->session_reused ||
1104
1135
  !ssl_cipher_uses_certificate_auth(hs->new_cipher) ||
@@ -1120,8 +1151,8 @@ static bool ext_ocsp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1120
1151
  static bool ext_npn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1121
1152
  CBB *out_compressible,
1122
1153
  ssl_client_hello_type_t type) {
1123
- const SSL *const ssl = hs->ssl;
1124
- if (ssl->ctx->next_proto_select_cb == NULL ||
1154
+ const SSLImpl *const ssl = hs->ssl;
1155
+ if (ssl->ctx->next_proto_select_cb == nullptr ||
1125
1156
  // Do not allow NPN to change on renegotiation.
1126
1157
  ssl->s3->initial_handshake_complete ||
1127
1158
  // NPN is not defined in DTLS or TLS 1.3.
@@ -1140,8 +1171,8 @@ static bool ext_npn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1140
1171
 
1141
1172
  static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1142
1173
  CBS *contents) {
1143
- SSL *const ssl = hs->ssl;
1144
- if (contents == NULL) {
1174
+ SSLImpl *const ssl = hs->ssl;
1175
+ if (contents == nullptr) {
1145
1176
  return true;
1146
1177
  }
1147
1178
 
@@ -1154,7 +1185,7 @@ static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1154
1185
  // called.
1155
1186
  assert(!ssl->s3->initial_handshake_complete);
1156
1187
  assert(!SSL_is_dtls(ssl));
1157
- assert(ssl->ctx->next_proto_select_cb != NULL);
1188
+ assert(ssl->ctx->next_proto_select_cb != nullptr);
1158
1189
 
1159
1190
  if (!ssl->s3->alpn_selected.empty()) {
1160
1191
  // NPN and ALPN may not be negotiated in the same connection.
@@ -1174,7 +1205,7 @@ static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1174
1205
  }
1175
1206
  }
1176
1207
 
1177
- // |orig_len| fits in |unsigned| because TLS extensions use 16-bit lengths.
1208
+ // `orig_len` fits in `unsigned` because TLS extensions use 16-bit lengths.
1178
1209
  uint8_t *selected;
1179
1210
  uint8_t selected_len;
1180
1211
  if (ssl->ctx->next_proto_select_cb(
@@ -1192,18 +1223,18 @@ static bool ext_npn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1192
1223
 
1193
1224
  static bool ext_npn_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1194
1225
  CBS *contents) {
1195
- SSL *const ssl = hs->ssl;
1226
+ SSLImpl *const ssl = hs->ssl;
1196
1227
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
1197
1228
  return true;
1198
1229
  }
1199
1230
 
1200
- if (contents != NULL && CBS_len(contents) != 0) {
1231
+ if (contents != nullptr && CBS_len(contents) != 0) {
1201
1232
  return false;
1202
1233
  }
1203
1234
 
1204
- if (contents == NULL || //
1205
- ssl->s3->initial_handshake_complete || //
1206
- ssl->ctx->next_protos_advertised_cb == NULL || //
1235
+ if (contents == nullptr || //
1236
+ ssl->s3->initial_handshake_complete || //
1237
+ ssl->ctx->next_protos_advertised_cb == nullptr || //
1207
1238
  SSL_is_dtls(ssl)) {
1208
1239
  return true;
1209
1240
  }
@@ -1213,8 +1244,8 @@ static bool ext_npn_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1213
1244
  }
1214
1245
 
1215
1246
  static bool ext_npn_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1216
- SSL *const ssl = hs->ssl;
1217
- // |next_proto_neg_seen| might have been cleared when an ALPN extension was
1247
+ SSLImpl *const ssl = hs->ssl;
1248
+ // `next_proto_neg_seen` might have been cleared when an ALPN extension was
1218
1249
  // parsed.
1219
1250
  if (!hs->next_proto_neg_seen) {
1220
1251
  return true;
@@ -1263,8 +1294,8 @@ static bool ext_sct_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1263
1294
 
1264
1295
  static bool ext_sct_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1265
1296
  CBS *contents) {
1266
- SSL *const ssl = hs->ssl;
1267
- if (contents == NULL) {
1297
+ SSLImpl *const ssl = hs->ssl;
1298
+ if (contents == nullptr) {
1268
1299
  return true;
1269
1300
  }
1270
1301
 
@@ -1290,7 +1321,7 @@ static bool ext_sct_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1290
1321
  // TODO(davidben): Enforce this anyway.
1291
1322
  if (!ssl->s3->session_reused) {
1292
1323
  hs->new_session->signed_cert_timestamp_list.reset(
1293
- CRYPTO_BUFFER_new_from_CBS(contents, ssl->ctx->pool));
1324
+ CRYPTO_BUFFER_new_from_CBS(contents, ssl->ctx->pool.get()));
1294
1325
  if (hs->new_session->signed_cert_timestamp_list == nullptr) {
1295
1326
  *out_alert = SSL_AD_INTERNAL_ERROR;
1296
1327
  return false;
@@ -1302,7 +1333,7 @@ static bool ext_sct_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1302
1333
 
1303
1334
  static bool ext_sct_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1304
1335
  CBS *contents) {
1305
- if (contents == NULL) {
1336
+ if (contents == nullptr) {
1306
1337
  return true;
1307
1338
  }
1308
1339
 
@@ -1315,7 +1346,7 @@ static bool ext_sct_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1315
1346
  }
1316
1347
 
1317
1348
  static bool ext_sct_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1318
- SSL *const ssl = hs->ssl;
1349
+ SSLImpl *const ssl = hs->ssl;
1319
1350
  assert(hs->scts_requested);
1320
1351
  // The extension shouldn't be sent when resuming sessions.
1321
1352
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION || ssl->s3->session_reused ||
@@ -1343,7 +1374,7 @@ static bool ext_sct_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1343
1374
  static bool ext_alpn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1344
1375
  CBB *out_compressible,
1345
1376
  ssl_client_hello_type_t type) {
1346
- const SSL *const ssl = hs->ssl;
1377
+ const SSLImpl *const ssl = hs->ssl;
1347
1378
  if (hs->config->alpn_client_proto_list.empty() && SSL_is_quic(ssl)) {
1348
1379
  // ALPN MUST be used with QUIC.
1349
1380
  OPENSSL_PUT_ERROR(SSL, SSL_R_NO_APPLICATION_PROTOCOL);
@@ -1371,8 +1402,8 @@ static bool ext_alpn_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1371
1402
 
1372
1403
  static bool ext_alpn_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1373
1404
  CBS *contents) {
1374
- SSL *const ssl = hs->ssl;
1375
- if (contents == NULL) {
1405
+ SSLImpl *const ssl = hs->ssl;
1406
+ if (contents == nullptr) {
1376
1407
  if (SSL_is_quic(ssl)) {
1377
1408
  // ALPN is required when QUIC is used.
1378
1409
  OPENSSL_PUT_ERROR(SSL, SSL_R_NO_APPLICATION_PROTOCOL);
@@ -1465,14 +1496,51 @@ bool ssl_alpn_list_contains_protocol(Span<const uint8_t> list,
1465
1496
  return false;
1466
1497
  }
1467
1498
 
1499
+ static int default_alpn_select_cb(SSL *ssl, const uint8_t **out,
1500
+ uint8_t *out_len, const uint8_t *in,
1501
+ unsigned inlen, void *arg) {
1502
+ auto *ssl_impl = FromOpaque(ssl);
1503
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
1504
+ if (hs == nullptr) {
1505
+ return SSL_TLSEXT_ERR_ALERT_FATAL;
1506
+ }
1507
+
1508
+ bssl::Span<const uint8_t> client_protos(in, inlen);
1509
+ CBS cbs = client_protos;
1510
+ CBS proto;
1511
+ while (CBS_len(&cbs) != 0) {
1512
+ if (!CBS_get_u8_length_prefixed(&cbs, &proto) || CBS_len(&proto) == 0) {
1513
+ return SSL_TLSEXT_ERR_ALERT_FATAL;
1514
+ }
1515
+ if (ssl_alpn_list_contains_protocol(hs->config->alpn_client_proto_list,
1516
+ proto)) {
1517
+ *out = CBS_data(&proto);
1518
+ *out_len = static_cast<uint8_t>(CBS_len(&proto));
1519
+ return SSL_TLSEXT_ERR_OK;
1520
+ }
1521
+ }
1522
+
1523
+ return SSL_TLSEXT_ERR_ALERT_FATAL;
1524
+ }
1525
+
1468
1526
  bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1469
1527
  const SSL_CLIENT_HELLO *client_hello) {
1470
- SSL *const ssl = hs->ssl;
1528
+ SSLImpl *const ssl = hs->ssl;
1471
1529
  CBS contents;
1472
- if (ssl->ctx->alpn_select_cb == NULL ||
1473
- !ssl_client_hello_get_extension(
1474
- client_hello, &contents,
1475
- TLSEXT_TYPE_application_layer_protocol_negotiation)) {
1530
+ const bool has_extension = ssl_client_hello_get_extension(
1531
+ client_hello, &contents,
1532
+ TLSEXT_TYPE_application_layer_protocol_negotiation);
1533
+
1534
+ auto alpn_select_cb = ssl->ctx->alpn_select_cb;
1535
+ void *alpn_select_cb_arg = ssl->ctx->alpn_select_cb_arg;
1536
+
1537
+ if (alpn_select_cb == nullptr &&
1538
+ !hs->config->alpn_client_proto_list.empty()) {
1539
+ alpn_select_cb = default_alpn_select_cb;
1540
+ alpn_select_cb_arg = nullptr;
1541
+ }
1542
+
1543
+ if (!has_extension || alpn_select_cb == nullptr) {
1476
1544
  if (SSL_is_quic(ssl)) {
1477
1545
  // ALPN is required when QUIC is used.
1478
1546
  OPENSSL_PUT_ERROR(SSL, SSL_R_NO_APPLICATION_PROTOCOL);
@@ -1495,14 +1563,13 @@ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1495
1563
  return false;
1496
1564
  }
1497
1565
 
1498
- // |protocol_name_list| fits in |unsigned| because TLS extensions use 16-bit
1566
+ // `protocol_name_list` fits in `unsigned` because TLS extensions use 16-bit
1499
1567
  // lengths.
1500
- const uint8_t *selected;
1501
- uint8_t selected_len;
1502
- int ret = ssl->ctx->alpn_select_cb(
1568
+ const uint8_t *selected = nullptr;
1569
+ uint8_t selected_len = 0;
1570
+ int ret = alpn_select_cb(
1503
1571
  ssl, &selected, &selected_len, CBS_data(&protocol_name_list),
1504
- static_cast<unsigned>(CBS_len(&protocol_name_list)),
1505
- ssl->ctx->alpn_select_cb_arg);
1572
+ static_cast<unsigned>(CBS_len(&protocol_name_list)), alpn_select_cb_arg);
1506
1573
  // ALPN is required when QUIC is used.
1507
1574
  if (SSL_is_quic(ssl) &&
1508
1575
  (ret == SSL_TLSEXT_ERR_NOACK || ret == SSL_TLSEXT_ERR_ALERT_WARNING)) {
@@ -1538,7 +1605,7 @@ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1538
1605
  }
1539
1606
 
1540
1607
  static bool ext_alpn_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1541
- SSL *const ssl = hs->ssl;
1608
+ SSLImpl *const ssl = hs->ssl;
1542
1609
  if (ssl->s3->alpn_selected.empty()) {
1543
1610
  return true;
1544
1611
  }
@@ -1565,14 +1632,14 @@ static bool ext_alpn_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1565
1632
  static bool ext_channel_id_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1566
1633
  CBB *out_compressible,
1567
1634
  ssl_client_hello_type_t type) {
1568
- const SSL *const ssl = hs->ssl;
1635
+ const SSLImpl *const ssl = hs->ssl;
1569
1636
  if (!hs->config->channel_id_private || SSL_is_dtls(ssl) ||
1570
1637
  // Don't offer Channel ID in ClientHelloOuter. ClientHelloOuter handshakes
1571
1638
  // are not authenticated for the name that can learn the Channel ID.
1572
1639
  //
1573
1640
  // We could alternatively offer the extension but sign with a random key.
1574
- // For other extensions, we try to align |ssl_client_hello_outer| and
1575
- // |ssl_client_hello_unencrypted|, to improve the effectiveness of ECH
1641
+ // For other extensions, we try to align `ssl_client_hello_outer` and
1642
+ // `ssl_client_hello_unencrypted`, to improve the effectiveness of ECH
1576
1643
  // GREASE. However, Channel ID is deprecated and unlikely to be used with
1577
1644
  // ECH, so do the simplest thing.
1578
1645
  type == ssl_client_hello_outer) {
@@ -1590,7 +1657,7 @@ static bool ext_channel_id_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1590
1657
  static bool ext_channel_id_parse_serverhello(SSL_HANDSHAKE *hs,
1591
1658
  uint8_t *out_alert,
1592
1659
  CBS *contents) {
1593
- if (contents == NULL) {
1660
+ if (contents == nullptr) {
1594
1661
  return true;
1595
1662
  }
1596
1663
 
@@ -1608,8 +1675,9 @@ static bool ext_channel_id_parse_serverhello(SSL_HANDSHAKE *hs,
1608
1675
  static bool ext_channel_id_parse_clienthello(SSL_HANDSHAKE *hs,
1609
1676
  uint8_t *out_alert,
1610
1677
  CBS *contents) {
1611
- SSL *const ssl = hs->ssl;
1612
- if (contents == NULL || !hs->config->channel_id_enabled || SSL_is_dtls(ssl)) {
1678
+ SSLImpl *const ssl = hs->ssl;
1679
+ if (contents == nullptr || !hs->config->channel_id_enabled ||
1680
+ SSL_is_dtls(ssl)) {
1613
1681
  return true;
1614
1682
  }
1615
1683
 
@@ -1642,10 +1710,10 @@ static bool ext_channel_id_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1642
1710
  static bool ext_srtp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1643
1711
  CBB *out_compressible,
1644
1712
  ssl_client_hello_type_t type) {
1645
- const SSL *const ssl = hs->ssl;
1713
+ const SSLImpl *const ssl = hs->ssl;
1646
1714
  const STACK_OF(SRTP_PROTECTION_PROFILE) *profiles =
1647
1715
  SSL_get_srtp_profiles(ssl);
1648
- if (profiles == NULL || //
1716
+ if (profiles == nullptr || //
1649
1717
  sk_SRTP_PROTECTION_PROFILE_num(profiles) == 0 || //
1650
1718
  !SSL_is_dtls(ssl)) {
1651
1719
  return true;
@@ -1674,8 +1742,8 @@ static bool ext_srtp_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1674
1742
 
1675
1743
  static bool ext_srtp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1676
1744
  CBS *contents) {
1677
- SSL *const ssl = hs->ssl;
1678
- if (contents == NULL) {
1745
+ SSLImpl *const ssl = hs->ssl;
1746
+ if (contents == nullptr) {
1679
1747
  return true;
1680
1748
  }
1681
1749
 
@@ -1717,9 +1785,9 @@ static bool ext_srtp_parse_serverhello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1717
1785
 
1718
1786
  static bool ext_srtp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1719
1787
  CBS *contents) {
1720
- SSL *const ssl = hs->ssl;
1788
+ SSLImpl *const ssl = hs->ssl;
1721
1789
  // DTLS-SRTP is only defined for DTLS.
1722
- if (contents == NULL || !SSL_is_dtls(ssl)) {
1790
+ if (contents == nullptr || !SSL_is_dtls(ssl)) {
1723
1791
  return true;
1724
1792
  }
1725
1793
 
@@ -1758,8 +1826,8 @@ static bool ext_srtp_parse_clienthello(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1758
1826
  }
1759
1827
 
1760
1828
  static bool ext_srtp_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1761
- SSL *const ssl = hs->ssl;
1762
- if (ssl->s3->srtp_profile == NULL) {
1829
+ SSLImpl *const ssl = hs->ssl;
1830
+ if (ssl->s3->srtp_profile == nullptr) {
1763
1831
  return true;
1764
1832
  }
1765
1833
 
@@ -1807,7 +1875,7 @@ static bool ext_ec_point_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
1807
1875
 
1808
1876
  static bool ext_ec_point_parse_serverhello(SSL_HANDSHAKE *hs,
1809
1877
  uint8_t *out_alert, CBS *contents) {
1810
- if (contents == NULL) {
1878
+ if (contents == nullptr) {
1811
1879
  return true;
1812
1880
  }
1813
1881
 
@@ -1825,7 +1893,7 @@ static bool ext_ec_point_parse_serverhello(SSL_HANDSHAKE *hs,
1825
1893
  // point format.
1826
1894
  if (OPENSSL_memchr(CBS_data(&ec_point_format_list),
1827
1895
  TLSEXT_ECPOINTFORMAT_uncompressed,
1828
- CBS_len(&ec_point_format_list)) == NULL) {
1896
+ CBS_len(&ec_point_format_list)) == nullptr) {
1829
1897
  *out_alert = SSL_AD_ILLEGAL_PARAMETER;
1830
1898
  return false;
1831
1899
  }
@@ -1843,7 +1911,7 @@ static bool ext_ec_point_parse_clienthello(SSL_HANDSHAKE *hs,
1843
1911
  }
1844
1912
 
1845
1913
  static bool ext_ec_point_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1846
- SSL *const ssl = hs->ssl;
1914
+ SSLImpl *const ssl = hs->ssl;
1847
1915
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
1848
1916
  return true;
1849
1917
  }
@@ -1864,174 +1932,301 @@ static bool ext_ec_point_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
1864
1932
  //
1865
1933
  // https://tools.ietf.org/html/rfc8446#section-4.2.11
1866
1934
 
1867
- static bool should_offer_psk(const SSL_HANDSHAKE *hs,
1868
- ssl_client_hello_type_t type) {
1869
- const SSL *const ssl = hs->ssl;
1870
- if (hs->max_version < TLS1_3_VERSION || ssl->session == nullptr ||
1871
- ssl_session_get_type(ssl->session.get()) !=
1872
- SSLSessionType::kPreSharedKey ||
1873
- // TODO(https://crbug.com/boringssl/275): Should we synthesize a
1874
- // placeholder PSK, at least when we offer early data? Otherwise
1875
- // ClientHelloOuter will contain an early_data extension without a
1876
- // pre_shared_key extension and potentially break the recovery flow.
1877
- type == ssl_client_hello_outer) {
1878
- return false;
1935
+ bool ssl_setup_pre_shared_keys(SSL_HANDSHAKE *hs) {
1936
+ const SSLImpl *const ssl = hs->ssl;
1937
+ if (hs->max_version < TLS1_3_VERSION) {
1938
+ return true;
1879
1939
  }
1880
1940
 
1881
- // Per RFC 8446 section 4.1.4, skip offering the session if the selected
1882
- // cipher in HelloRetryRequest does not match. This avoids performing the
1883
- // transcript hash transformation for multiple hashes.
1884
- if (ssl->s3->used_hello_retry_request &&
1885
- ssl->session->cipher->algorithm_prf != hs->new_cipher->algorithm_prf) {
1941
+ if (SSLSession *session = ssl->session.get();
1942
+ session != nullptr &&
1943
+ ssl_session_get_type(session) == SSLSessionType::kPreSharedKey &&
1944
+ !hs->pre_shared_keys.Push(UpRef(session))) {
1886
1945
  return false;
1887
1946
  }
1888
1947
 
1948
+ const uint16_t epsk_protocol =
1949
+ SSL_is_dtls(ssl) ? DTLS1_3_VERSION : TLS1_3_VERSION;
1950
+ #if defined(TLS1_4_VERSION)
1951
+ #error "More imported PSKs may be needed when TLS 1.4 exists"
1952
+ #endif
1953
+ for (const auto &cred : hs->config->cert->credentials) {
1954
+ if (cred->type != SSLCredentialType::kPreSharedKey) {
1955
+ continue;
1956
+ }
1957
+ // We need SHA-256 and SHA-384 variants to cover supported cipher suites.
1958
+ for (const EVP_MD *md : {EVP_sha256(), EVP_sha384()}) {
1959
+ std::optional<SSLImportedPSK> psk =
1960
+ tls13_derive_imported_psk(hs, cred.get(), epsk_protocol, md);
1961
+ if (!psk || !hs->pre_shared_keys.Push(*std::move(psk))) {
1962
+ return false;
1963
+ }
1964
+ }
1965
+ }
1966
+
1889
1967
  return true;
1890
1968
  }
1891
1969
 
1892
- static size_t ext_pre_shared_key_clienthello_length(
1893
- const SSL_HANDSHAKE *hs, ssl_client_hello_type_t type) {
1894
- const SSL *const ssl = hs->ssl;
1895
- if (!should_offer_psk(hs, type)) {
1896
- return 0;
1897
- }
1898
-
1899
- size_t binder_len = EVP_MD_size(ssl_session_get_digest(ssl->session.get()));
1900
- return 15 + ssl->session->ticket.size() + binder_len;
1970
+ static bool should_offer_psk(const SSL_HANDSHAKE *hs,
1971
+ ssl_client_hello_type_t type) {
1972
+ // TODO(https://crbug.com/boringssl/275): Should we synthesize a placeholder
1973
+ // PSK, at least when we offer early data? Otherwise ClientHelloOuter will
1974
+ // contain an early_data extension without a pre_shared_key extension and
1975
+ // potentially break the recovery flow.
1976
+ return hs->max_version >= TLS1_3_VERSION && !hs->pre_shared_keys.empty() &&
1977
+ type != ssl_client_hello_outer;
1901
1978
  }
1902
1979
 
1980
+ // ext_pre_shared_key_add_clienthello writes a pre_shared_key extension to
1981
+ // `out_extensions` and flushes `out_client_hello`, invalidating
1982
+ // `out_extensions`. `out_extensions` must be a child of `out_client_hello`.
1983
+ //
1984
+ // This function differs from other `CBB` functions because it needs to
1985
+ // accommodate PSK binders. It must write the PSK extension, flush the `CBB` to
1986
+ // write out a length prefix, and then finally sample the whole ClientHello.
1903
1987
  static bool ext_pre_shared_key_add_clienthello(const SSL_HANDSHAKE *hs,
1904
- CBB *out, bool *out_needs_binder,
1988
+ CBB *out_client_hello,
1989
+ CBB *out_extensions,
1990
+ size_t *out_psk_len,
1905
1991
  ssl_client_hello_type_t type) {
1906
- const SSL *const ssl = hs->ssl;
1907
- *out_needs_binder = false;
1992
+ const SSLImpl *const ssl = hs->ssl;
1908
1993
  if (!should_offer_psk(hs, type)) {
1909
- return true;
1994
+ *out_psk_len = 0;
1995
+ // Discard empty extensions blocks.
1996
+ if (CBB_len(out_extensions) == 0) {
1997
+ CBB_discard_child(out_client_hello);
1998
+ }
1999
+ return CBB_flush(out_client_hello);
2000
+ }
2001
+
2002
+ const size_t len_before = CBB_len(out_extensions);
2003
+ CBB contents, identities, identity, binders, binder;
2004
+ if (!CBB_add_u16(out_extensions, TLSEXT_TYPE_pre_shared_key) ||
2005
+ !CBB_add_u16_length_prefixed(out_extensions, &contents) ||
2006
+ !CBB_add_u16_length_prefixed(&contents, &identities)) {
2007
+ return false;
1910
2008
  }
1911
2009
 
1912
- OPENSSL_timeval now = ssl_ctx_get_current_time(ssl->ctx.get());
1913
- uint32_t ticket_age = 1000 * (now.tv_sec - ssl->session->time);
1914
- uint32_t obfuscated_ticket_age = ticket_age + ssl->session->ticket_age_add;
2010
+ // Fill in the PSK identities.
2011
+ for (const auto &psk : hs->pre_shared_keys) {
2012
+ if (const auto *imported = std::get_if<SSLImportedPSK>(&psk);
2013
+ imported != nullptr) {
2014
+ if (!CBB_add_u16_length_prefixed(&identities, &identity) ||
2015
+ !CBB_add_bytes(&identity, imported->imported_identity.data(),
2016
+ imported->imported_identity.size()) ||
2017
+ !CBB_add_u32(&identities, 0 /* obfuscated_ticket_age */)) {
2018
+ return false;
2019
+ }
2020
+ } else {
2021
+ const SSLSession *session = std::get<UniquePtr<SSLSession>>(psk).get();
2022
+ // At most one PSK will be a session.
2023
+ assert(session == ssl->session.get());
2024
+ OPENSSL_timeval now = ssl_ctx_get_current_time(ssl->ctx.get());
2025
+ uint32_t ticket_age = 1000 * (now.tv_sec - session->time);
2026
+ uint32_t obfuscated_ticket_age = ticket_age + session->ticket_age_add;
2027
+ if (!CBB_add_u16_length_prefixed(&identities, &identity) ||
2028
+ !CBB_add_bytes(&identity, session->ticket.data(),
2029
+ session->ticket.size()) ||
2030
+ !CBB_add_u32(&identities, obfuscated_ticket_age)) {
2031
+ return false;
2032
+ }
2033
+ }
2034
+ }
1915
2035
 
1916
- // Fill in a placeholder zero binder of the appropriate length. It will be
2036
+ // Fill in placeholder zero binders of the appropriate length. They will be
1917
2037
  // computed and filled in later after length prefixes are computed.
1918
- size_t binder_len = EVP_MD_size(ssl_session_get_digest(ssl->session.get()));
2038
+ if (!CBB_add_u16_length_prefixed(&contents, &binders)) {
2039
+ return false;
2040
+ }
2041
+ for (const auto &psk : hs->pre_shared_keys) {
2042
+ size_t binder_len = EVP_MD_size(ssl_pre_shared_key_hash(psk));
2043
+ if (!CBB_add_u8_length_prefixed(&binders, &binder) ||
2044
+ !CBB_add_zeros(&binder, binder_len)) {
2045
+ return false;
2046
+ }
2047
+ }
2048
+ if (!CBB_flush(&binders)) {
2049
+ return false;
2050
+ }
2051
+ const size_t binders_len = CBB_len(&binders);
1919
2052
 
1920
- CBB contents, identity, ticket, binders, binder;
1921
- if (!CBB_add_u16(out, TLSEXT_TYPE_pre_shared_key) ||
1922
- !CBB_add_u16_length_prefixed(out, &contents) ||
1923
- !CBB_add_u16_length_prefixed(&contents, &identity) ||
1924
- !CBB_add_u16_length_prefixed(&identity, &ticket) ||
1925
- !CBB_add_bytes(&ticket, ssl->session->ticket.data(),
1926
- ssl->session->ticket.size()) ||
1927
- !CBB_add_u32(&identity, obfuscated_ticket_age) ||
1928
- !CBB_add_u16_length_prefixed(&contents, &binders) ||
1929
- !CBB_add_u8_length_prefixed(&binders, &binder) ||
1930
- !CBB_add_zeros(&binder, binder_len)) {
2053
+ // Finish the PSK extension and save the length.
2054
+ if (!CBB_flush(out_extensions)) {
1931
2055
  return false;
1932
2056
  }
2057
+ *out_psk_len = CBB_len(out_extensions) - len_before;
1933
2058
 
1934
- *out_needs_binder = true;
1935
- return CBB_flush(out);
2059
+ // Fill in `out_extensions`'s length prefix.
2060
+ if (!CBB_flush(out_client_hello)) {
2061
+ return false;
2062
+ }
2063
+
2064
+ // Fill in binders.
2065
+ const auto client_hello = CBBAsSpan(out_client_hello);
2066
+ auto remaining_binders_out = client_hello.last(binders_len);
2067
+ const auto &transcript =
2068
+ type == ssl_client_hello_inner ? hs->inner_transcript : hs->transcript;
2069
+ for (const auto &psk : hs->pre_shared_keys) {
2070
+ // Skip length prefix.
2071
+ remaining_binders_out = remaining_binders_out.subspan(1);
2072
+ size_t one_binder_len;
2073
+ if (!tls13_psk_binder(hs, remaining_binders_out, &one_binder_len, psk,
2074
+ transcript, client_hello,
2075
+ 2 /* length */ + binders_len)) {
2076
+ return false;
2077
+ }
2078
+ remaining_binders_out = remaining_binders_out.subspan(one_binder_len);
2079
+ }
2080
+ assert(remaining_binders_out.empty());
2081
+ return true;
1936
2082
  }
1937
2083
 
1938
- bool ssl_ext_pre_shared_key_parse_serverhello(SSL_HANDSHAKE *hs,
1939
- uint8_t *out_alert,
1940
- CBS *contents) {
1941
- uint16_t psk_id;
1942
- if (!CBS_get_u16(contents, &psk_id) || //
2084
+ const SSLPreSharedKey *ssl_ext_pre_shared_key_parse_serverhello(
2085
+ SSL_HANDSHAKE *hs, uint8_t *out_alert, CBS *contents) {
2086
+ uint16_t selected_identity;
2087
+ if (!CBS_get_u16(contents, &selected_identity) || //
1943
2088
  CBS_len(contents) != 0) {
1944
2089
  OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
1945
2090
  *out_alert = SSL_AD_DECODE_ERROR;
1946
- return false;
2091
+ return nullptr;
1947
2092
  }
1948
2093
 
1949
- // We only advertise one PSK identity, so the only legal index is zero.
1950
- if (psk_id != 0) {
2094
+ if (selected_identity >= hs->pre_shared_keys.size()) {
1951
2095
  OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_NOT_FOUND);
1952
2096
  *out_alert = SSL_AD_UNKNOWN_PSK_IDENTITY;
1953
- return false;
2097
+ return nullptr;
1954
2098
  }
1955
2099
 
1956
- return true;
2100
+ return &hs->pre_shared_keys[selected_identity];
1957
2101
  }
1958
2102
 
1959
- bool ssl_ext_pre_shared_key_parse_clienthello(
1960
- SSL_HANDSHAKE *hs, CBS *out_ticket, CBS *out_binders,
1961
- uint32_t *out_obfuscated_ticket_age, uint8_t *out_alert,
1962
- const SSL_CLIENT_HELLO *client_hello, CBS *contents) {
2103
+ std::optional<SSLOfferedPSK> SSLOfferedPSKs::Next() {
2104
+ if (CBS_len(&identities) == 0) {
2105
+ return std::nullopt;
2106
+ }
2107
+ SSLOfferedPSK psk;
2108
+ if (!CBS_get_u16_length_prefixed(&identities, &psk.identity) ||
2109
+ CBS_len(&psk.identity) == 0 ||
2110
+ !CBS_get_u32(&identities, &psk.obfuscated_ticket_age) ||
2111
+ !CBS_get_u8_length_prefixed(&binders, &psk.binder) ||
2112
+ CBS_len(&psk.binder) == 0) {
2113
+ // After a successful parse, this should never happen.
2114
+ return std::nullopt;
2115
+ }
2116
+ return psk;
2117
+ }
2118
+
2119
+ std::optional<SSLOfferedPSKs> ssl_ext_pre_shared_key_parse_clienthello(
2120
+ SSL_HANDSHAKE *hs, uint8_t *out_alert, const SSL_CLIENT_HELLO *client_hello,
2121
+ CBS *contents) {
1963
2122
  // Verify that the pre_shared_key extension is the last extension in
1964
2123
  // ClientHello.
1965
2124
  if (CBS_data(contents) + CBS_len(contents) !=
1966
2125
  client_hello->extensions + client_hello->extensions_len) {
1967
2126
  OPENSSL_PUT_ERROR(SSL, SSL_R_PRE_SHARED_KEY_MUST_BE_LAST);
1968
2127
  *out_alert = SSL_AD_ILLEGAL_PARAMETER;
1969
- return false;
2128
+ return std::nullopt;
1970
2129
  }
1971
2130
 
1972
- // We only process the first PSK identity since we don't support pure PSK.
1973
- CBS identities, binders;
1974
- if (!CBS_get_u16_length_prefixed(contents, &identities) || //
1975
- !CBS_get_u16_length_prefixed(&identities, out_ticket) || //
1976
- !CBS_get_u32(&identities, out_obfuscated_ticket_age) || //
1977
- !CBS_get_u16_length_prefixed(contents, &binders) || //
1978
- CBS_len(&binders) == 0 || //
2131
+ SSLOfferedPSKs psks;
2132
+ if (!CBS_get_u16_length_prefixed(contents, &psks.identities) ||
2133
+ !CBS_get_u16_length_prefixed(contents, &psks.binders) ||
2134
+ CBS_len(&psks.identities) == 0 || //
2135
+ CBS_len(&psks.binders) == 0 || //
1979
2136
  CBS_len(contents) != 0) {
1980
2137
  OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
1981
2138
  *out_alert = SSL_AD_DECODE_ERROR;
1982
- return false;
2139
+ return std::nullopt;
1983
2140
  }
1984
2141
 
1985
- *out_binders = binders;
1986
-
1987
- // Check the syntax of the remaining identities, but do not process them.
1988
- size_t num_identities = 1;
1989
- while (CBS_len(&identities) != 0) {
1990
- CBS unused_ticket;
1991
- uint32_t unused_obfuscated_ticket_age;
1992
- if (!CBS_get_u16_length_prefixed(&identities, &unused_ticket) ||
1993
- !CBS_get_u32(&identities, &unused_obfuscated_ticket_age)) {
2142
+ // Check the syntax of the extension.
2143
+ SSLOfferedPSKs copy = psks;
2144
+ while (CBS_len(&copy.identities) != 0 && CBS_len(&copy.binders) != 0) {
2145
+ if (!copy.Next()) {
1994
2146
  OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
1995
2147
  *out_alert = SSL_AD_DECODE_ERROR;
1996
- return false;
2148
+ return std::nullopt;
1997
2149
  }
2150
+ }
1998
2151
 
1999
- num_identities++;
2152
+ // We should have run out of identities and binders at the same time.
2153
+ if (CBS_len(&copy.identities) != 0 || CBS_len(&copy.binders) != 0) {
2154
+ OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_BINDER_COUNT_MISMATCH);
2155
+ *out_alert = SSL_AD_ILLEGAL_PARAMETER;
2156
+ return std::nullopt;
2000
2157
  }
2001
2158
 
2002
- // Check the syntax of the binders. The value will be checked later if
2003
- // resuming.
2004
- size_t num_binders = 0;
2005
- while (CBS_len(&binders) != 0) {
2006
- CBS binder;
2007
- if (!CBS_get_u8_length_prefixed(&binders, &binder)) {
2008
- OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
2009
- *out_alert = SSL_AD_DECODE_ERROR;
2010
- return false;
2011
- }
2159
+ return psks;
2160
+ }
2012
2161
 
2013
- num_binders++;
2162
+ bool ssl_verify_psk_binder(SSL_HANDSHAKE *hs, uint8_t *out_alert,
2163
+ const SSLPreSharedKey &psk,
2164
+ const SSL_CLIENT_HELLO &client_hello) {
2165
+ CBS pre_shared_key;
2166
+ if (!ssl_client_hello_get_extension(&client_hello, &pre_shared_key,
2167
+ TLSEXT_TYPE_pre_shared_key)) {
2168
+ OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_EXTENSION);
2169
+ *out_alert = SSL_AD_MISSING_EXTENSION;
2170
+ return false;
2014
2171
  }
2015
2172
 
2016
- if (num_identities != num_binders) {
2017
- OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_BINDER_COUNT_MISMATCH);
2018
- *out_alert = SSL_AD_ILLEGAL_PARAMETER;
2173
+ std::optional<SSLOfferedPSKs> offered_psks =
2174
+ ssl_ext_pre_shared_key_parse_clienthello(hs, out_alert, &client_hello,
2175
+ &pre_shared_key);
2176
+ if (!offered_psks) {
2019
2177
  return false;
2020
2178
  }
2179
+ const size_t binders_len =
2180
+ 2 /* length prefix */ + CBS_len(&offered_psks->binders);
2021
2181
 
2022
- return true;
2182
+ Span<const uint8_t> identity = ssl_pre_shared_key_identity(psk);
2183
+ for (uint16_t index = 0; true; index++) {
2184
+ std::optional<SSLOfferedPSK> offered_psk = offered_psks->Next();
2185
+ if (!offered_psk) {
2186
+ OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_NOT_FOUND);
2187
+ *out_alert = SSL_AD_ILLEGAL_PARAMETER;
2188
+ return false;
2189
+ }
2190
+
2191
+ if (offered_psk->identity != identity) {
2192
+ continue;
2193
+ }
2194
+
2195
+ hs->selected_psk_index = index;
2196
+ uint8_t verify_data[EVP_MAX_MD_SIZE];
2197
+ size_t verify_data_len;
2198
+ if (!tls13_psk_binder(
2199
+ hs, verify_data, &verify_data_len, psk, hs->transcript,
2200
+ Span(client_hello.client_hello, client_hello.client_hello_len),
2201
+ binders_len)) {
2202
+ *out_alert = SSL_AD_INTERNAL_ERROR;
2203
+ return false;
2204
+ }
2205
+
2206
+ bool binder_ok = CBS_len(&offered_psk->binder) == verify_data_len &&
2207
+ CRYPTO_memcmp(CBS_data(&offered_psk->binder), verify_data,
2208
+ verify_data_len) == 0;
2209
+ if (CRYPTO_fuzzer_mode_enabled()) {
2210
+ binder_ok = true;
2211
+ }
2212
+ if (!binder_ok) {
2213
+ OPENSSL_PUT_ERROR(SSL, SSL_R_DIGEST_CHECK_FAILED);
2214
+ *out_alert = SSL_AD_DECRYPT_ERROR;
2215
+ return false;
2216
+ }
2217
+ return true;
2218
+ }
2023
2219
  }
2024
2220
 
2025
2221
  bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
2026
- if (!hs->ssl->s3->session_reused) {
2222
+ if (!hs->selected_psk_index.has_value()) {
2027
2223
  return true;
2028
2224
  }
2029
2225
 
2030
2226
  CBB contents;
2031
- if (!CBB_add_u16(out, TLSEXT_TYPE_pre_shared_key) || //
2032
- !CBB_add_u16_length_prefixed(out, &contents) || //
2033
- // We only consider the first identity for resumption
2034
- !CBB_add_u16(&contents, 0) || //
2227
+ if (!CBB_add_u16(out, TLSEXT_TYPE_pre_shared_key) ||
2228
+ !CBB_add_u16_length_prefixed(out, &contents) ||
2229
+ !CBB_add_u16(&contents, *hs->selected_psk_index) || //
2035
2230
  !CBB_flush(out)) {
2036
2231
  return false;
2037
2232
  }
@@ -2070,7 +2265,7 @@ static bool ext_psk_key_exchange_modes_add_clienthello(
2070
2265
  static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
2071
2266
  uint8_t *out_alert,
2072
2267
  CBS *contents) {
2073
- if (contents == NULL) {
2268
+ if (contents == nullptr) {
2074
2269
  return true;
2075
2270
  }
2076
2271
 
@@ -2084,7 +2279,7 @@ static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
2084
2279
 
2085
2280
  // We only support tickets with PSK_DHE_KE.
2086
2281
  hs->accept_psk_mode = OPENSSL_memchr(CBS_data(&ke_modes), SSL_PSK_DHE_KE,
2087
- CBS_len(&ke_modes)) != NULL;
2282
+ CBS_len(&ke_modes)) != nullptr;
2088
2283
 
2089
2284
  return true;
2090
2285
  }
@@ -2097,9 +2292,9 @@ static bool ext_psk_key_exchange_modes_parse_clienthello(SSL_HANDSHAKE *hs,
2097
2292
  static bool ext_early_data_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
2098
2293
  CBB *out_compressible,
2099
2294
  ssl_client_hello_type_t type) {
2100
- const SSL *const ssl = hs->ssl;
2295
+ const SSLImpl *const ssl = hs->ssl;
2101
2296
  // The second ClientHello never offers early data, and we must have already
2102
- // filled in |early_data_reason| by this point.
2297
+ // filled in `early_data_reason` by this point.
2103
2298
  if (ssl->s3->used_hello_retry_request) {
2104
2299
  assert(ssl->s3->early_data_reason != ssl_early_data_unknown);
2105
2300
  return true;
@@ -2112,7 +2307,7 @@ static bool ext_early_data_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
2112
2307
  // If offering ECH, the extension only applies to ClientHelloInner, but we
2113
2308
  // send the extension in both ClientHellos. This ensures that, if the server
2114
2309
  // handshakes with ClientHelloOuter, it can skip past early data. See
2115
- // draft-ietf-tls-esni-13, section 6.1.
2310
+ // RFC 9849, section 6.1.
2116
2311
  if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_early_data) || //
2117
2312
  !CBB_add_u16(out_compressible, 0) || //
2118
2313
  !CBB_flush(out_compressible)) {
@@ -2125,14 +2320,14 @@ static bool ext_early_data_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
2125
2320
  static bool ext_early_data_parse_serverhello(SSL_HANDSHAKE *hs,
2126
2321
  uint8_t *out_alert,
2127
2322
  CBS *contents) {
2128
- SSL *const ssl = hs->ssl;
2129
- if (contents == NULL) {
2323
+ SSLImpl *const ssl = hs->ssl;
2324
+ if (contents == nullptr) {
2130
2325
  if (hs->early_data_offered && !ssl->s3->used_hello_retry_request) {
2131
2326
  ssl->s3->early_data_reason = ssl->s3->session_reused
2132
2327
  ? ssl_early_data_peer_declined
2133
2328
  : ssl_early_data_session_not_resumed;
2134
2329
  } else {
2135
- // We already filled in |early_data_reason| when declining to offer 0-RTT
2330
+ // We already filled in `early_data_reason` when declining to offer 0-RTT
2136
2331
  // or handling the implicit HelloRetryRequest reject.
2137
2332
  assert(ssl->s3->early_data_reason != ssl_early_data_unknown);
2138
2333
  }
@@ -2163,8 +2358,8 @@ static bool ext_early_data_parse_serverhello(SSL_HANDSHAKE *hs,
2163
2358
  static bool ext_early_data_parse_clienthello(SSL_HANDSHAKE *hs,
2164
2359
  uint8_t *out_alert,
2165
2360
  CBS *contents) {
2166
- SSL *const ssl = hs->ssl;
2167
- if (contents == NULL || ssl_protocol_version(ssl) < TLS1_3_VERSION) {
2361
+ SSLImpl *const ssl = hs->ssl;
2362
+ if (contents == nullptr || ssl_protocol_version(ssl) < TLS1_3_VERSION) {
2168
2363
  return true;
2169
2364
  }
2170
2365
 
@@ -2197,9 +2392,8 @@ static bool ext_early_data_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
2197
2392
  // https://tools.ietf.org/html/rfc8446#section-4.2.8
2198
2393
 
2199
2394
  bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id) {
2200
- SSL *const ssl = hs->ssl;
2201
- hs->key_shares[0].reset();
2202
- hs->key_shares[1].reset();
2395
+ SSLImpl *const ssl = hs->ssl;
2396
+ hs->key_shares.clear();
2203
2397
  hs->key_share_bytes.Reset();
2204
2398
 
2205
2399
  // If offering a PAKE, do not set up key shares. We do not currently support
@@ -2208,57 +2402,89 @@ bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id) {
2208
2402
  return true;
2209
2403
  }
2210
2404
 
2211
- bssl::ScopedCBB cbb;
2212
- if (!CBB_init(cbb.get(), 64)) {
2405
+ const Span<const uint16_t> supported_group_list =
2406
+ hs->config->supported_group_list;
2407
+ if (supported_group_list.empty()) {
2408
+ OPENSSL_PUT_ERROR(SSL, SSL_R_NO_GROUPS_SPECIFIED);
2213
2409
  return false;
2214
2410
  }
2215
2411
 
2216
- if (override_group_id == 0 && ssl->ctx->grease_enabled) {
2217
- // Add a fake group. See RFC 8701.
2218
- if (!CBB_add_u16(cbb.get(), ssl_get_grease_value(hs, ssl_grease_group)) ||
2219
- !CBB_add_u16(cbb.get(), 1 /* length */) ||
2220
- !CBB_add_u8(cbb.get(), 0 /* one byte key share */)) {
2221
- return false;
2222
- }
2412
+ std::optional<Span<const uint16_t>> selected_key_shares;
2413
+
2414
+ // This is used for HelloRetryRequest, where we have already been given the
2415
+ // correct group to use.
2416
+ if (override_group_id != 0) {
2417
+ assert(std::find(supported_group_list.begin(), supported_group_list.end(),
2418
+ override_group_id) != supported_group_list.end());
2419
+ selected_key_shares.emplace(&override_group_id, 1u);
2223
2420
  }
2224
2421
 
2225
- uint16_t group_id = override_group_id;
2226
- uint16_t second_group_id = 0;
2227
- if (override_group_id == 0) {
2228
- // Predict the most preferred group.
2229
- Span<const uint16_t> groups = tls1_get_grouplist(hs);
2230
- if (groups.empty()) {
2231
- OPENSSL_PUT_ERROR(SSL, SSL_R_NO_GROUPS_SPECIFIED);
2232
- return false;
2422
+ // First try to predict the most preferred (by our preference order) group
2423
+ // that was hinted by the server.
2424
+ const auto &server_hint_list = ssl->config->server_supported_groups_hint;
2425
+ if (!selected_key_shares.has_value() && !server_hint_list.empty()) {
2426
+ for (const uint16_t &supported_group : supported_group_list) {
2427
+ if (std::find(server_hint_list.begin(), server_hint_list.end(),
2428
+ supported_group) != server_hint_list.end()) {
2429
+ selected_key_shares.emplace(&supported_group, 1u);
2430
+ break;
2431
+ }
2233
2432
  }
2433
+ }
2234
2434
 
2235
- group_id = groups[0];
2435
+ // Otherwise, try to use explicitly configured key shares from the caller.
2436
+ if (!selected_key_shares.has_value() &&
2437
+ ssl->config->client_key_share_selections.has_value()) {
2438
+ selected_key_shares.emplace(*ssl->config->client_key_share_selections);
2439
+ }
2236
2440
 
2441
+ // Run the default selection if we don't have anything better.
2442
+ InplaceVector<uint16_t, 2> default_key_shares;
2443
+ if (!selected_key_shares.has_value()) {
2444
+ // By default, predict the most preferred group.
2445
+ if (!default_key_shares.TryPushBack(supported_group_list[0])) {
2446
+ return false;
2447
+ }
2237
2448
  // We'll try to include one post-quantum and one classical initial key
2238
2449
  // share.
2239
- for (size_t i = 1; i < groups.size() && second_group_id == 0; i++) {
2240
- if (is_post_quantum_group(group_id) != is_post_quantum_group(groups[i])) {
2241
- second_group_id = groups[i];
2242
- assert(second_group_id != group_id);
2450
+ for (size_t i = 1; i < supported_group_list.size(); i++) {
2451
+ if (is_post_quantum_group(default_key_shares[0]) ==
2452
+ is_post_quantum_group(supported_group_list[i])) {
2453
+ continue;
2243
2454
  }
2455
+ if (!default_key_shares.TryPushBack(supported_group_list[i])) {
2456
+ return false;
2457
+ }
2458
+ assert(default_key_shares[1] != default_key_shares[0]);
2459
+ break;
2244
2460
  }
2461
+ selected_key_shares.emplace(default_key_shares);
2245
2462
  }
2246
2463
 
2247
- CBB key_exchange;
2248
- hs->key_shares[0] = SSLKeyShare::Create(group_id);
2249
- if (!hs->key_shares[0] || //
2250
- !CBB_add_u16(cbb.get(), group_id) ||
2251
- !CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) ||
2252
- !hs->key_shares[0]->Generate(&key_exchange)) {
2464
+ assert(selected_key_shares.has_value());
2465
+
2466
+ bssl::ScopedCBB cbb;
2467
+ if (!CBB_init(cbb.get(), 64)) {
2253
2468
  return false;
2254
2469
  }
2255
2470
 
2256
- if (second_group_id != 0) {
2257
- hs->key_shares[1] = SSLKeyShare::Create(second_group_id);
2258
- if (!hs->key_shares[1] || //
2259
- !CBB_add_u16(cbb.get(), second_group_id) ||
2260
- !CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) ||
2261
- !hs->key_shares[1]->Generate(&key_exchange)) {
2471
+ if (override_group_id == 0 && ssl->ctx->grease_enabled) {
2472
+ // Add a fake group. See RFC 8701.
2473
+ if (!CBB_add_u16(cbb.get(), ssl_get_grease_value(hs, ssl_grease_group)) ||
2474
+ !CBB_add_u16(cbb.get(), 1 /* length */) ||
2475
+ !CBB_add_u8(cbb.get(), 0 /* one byte key share */)) {
2476
+ return false;
2477
+ }
2478
+ }
2479
+
2480
+ CBB key_exchange;
2481
+ for (const uint16_t group_id : *selected_key_shares) {
2482
+ UniquePtr<SSLKeyShare> key_share = SSLKeyShare::Create(group_id);
2483
+ if (key_share == nullptr || //
2484
+ !CBB_add_u16(cbb.get(), group_id) || //
2485
+ !CBB_add_u16_length_prefixed(cbb.get(), &key_exchange) || //
2486
+ !key_share->Generate(&key_exchange) || //
2487
+ !hs->key_shares.TryPushBack(std::move(key_share))) {
2262
2488
  return false;
2263
2489
  }
2264
2490
  }
@@ -2275,7 +2501,12 @@ static bool ext_key_share_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
2275
2501
  return true;
2276
2502
  }
2277
2503
 
2278
- assert(!hs->key_share_bytes.empty());
2504
+ // The caller may explicitly configure empty key shares to request a
2505
+ // HelloRetryRequest.
2506
+ assert(!hs->key_share_bytes.empty() ||
2507
+ (hs->config->client_key_share_selections.has_value() &&
2508
+ hs->config->client_key_share_selections->empty()));
2509
+
2279
2510
  CBB contents, kse_bytes;
2280
2511
  if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_key_share) ||
2281
2512
  !CBB_add_u16_length_prefixed(out_compressible, &contents) ||
@@ -2292,13 +2523,9 @@ static bool ext_key_share_add_clienthello(const SSL_HANDSHAKE *hs, CBB *out,
2292
2523
  bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
2293
2524
  Array<uint8_t> *out_secret,
2294
2525
  uint8_t *out_alert, CBS *contents) {
2295
- if (hs->key_shares[0] == nullptr) {
2296
- // If we did not offer key shares, the extension should have been rejected
2297
- // as unsolicited.
2298
- OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
2299
- *out_alert = SSL_AD_INTERNAL_ERROR;
2300
- return false;
2301
- }
2526
+ // If we did not offer key shares, the extension should have been rejected
2527
+ // as unsolicited.
2528
+ assert(!hs->key_shares.empty());
2302
2529
 
2303
2530
  CBS ciphertext;
2304
2531
  uint16_t group_id;
@@ -2310,24 +2537,23 @@ bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
2310
2537
  return false;
2311
2538
  }
2312
2539
 
2313
- SSLKeyShare *key_share = hs->key_shares[0].get();
2314
- if (key_share->GroupID() != group_id) {
2315
- if (!hs->key_shares[1] || hs->key_shares[1]->GroupID() != group_id) {
2316
- *out_alert = SSL_AD_ILLEGAL_PARAMETER;
2317
- OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_CURVE);
2318
- return false;
2319
- }
2320
- key_share = hs->key_shares[1].get();
2540
+ const auto key_share_it =
2541
+ std::find_if(hs->key_shares.begin(), hs->key_shares.end(),
2542
+ [group_id](const auto &key_share) {
2543
+ return key_share->GroupID() == group_id;
2544
+ });
2545
+ if (key_share_it == hs->key_shares.end()) {
2546
+ *out_alert = SSL_AD_ILLEGAL_PARAMETER;
2547
+ OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_CURVE);
2548
+ return false;
2321
2549
  }
2322
-
2323
- if (!key_share->Decap(out_secret, out_alert, ciphertext)) {
2550
+ if (!(*key_share_it)->Decap(out_secret, out_alert, ciphertext)) {
2324
2551
  *out_alert = SSL_AD_INTERNAL_ERROR;
2325
2552
  return false;
2326
2553
  }
2327
2554
 
2328
2555
  hs->new_session->group_id = group_id;
2329
- hs->key_shares[0].reset();
2330
- hs->key_shares[1].reset();
2556
+ hs->key_shares.clear();
2331
2557
  return true;
2332
2558
  }
2333
2559
 
@@ -2430,7 +2656,7 @@ bool ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
2430
2656
  static bool ext_supported_versions_add_clienthello(
2431
2657
  const SSL_HANDSHAKE *hs, CBB *out, CBB *out_compressible,
2432
2658
  ssl_client_hello_type_t type) {
2433
- const SSL *const ssl = hs->ssl;
2659
+ const SSLImpl *const ssl = hs->ssl;
2434
2660
  if (hs->max_version <= TLS1_2_VERSION) {
2435
2661
  return true;
2436
2662
  }
@@ -2499,7 +2725,7 @@ static bool ext_supported_groups_add_clienthello(const SSL_HANDSHAKE *hs,
2499
2725
  CBB *out,
2500
2726
  CBB *out_compressible,
2501
2727
  ssl_client_hello_type_t type) {
2502
- const SSL *const ssl = hs->ssl;
2728
+ const SSLImpl *const ssl = hs->ssl;
2503
2729
  // In PAKE mode, supported_groups and key_share are not used.
2504
2730
  if (hs->pake_prover != nullptr) {
2505
2731
  return true;
@@ -2518,7 +2744,7 @@ static bool ext_supported_groups_add_clienthello(const SSL_HANDSHAKE *hs,
2518
2744
  return false;
2519
2745
  }
2520
2746
 
2521
- for (uint16_t group : tls1_get_grouplist(hs)) {
2747
+ for (uint16_t group : hs->config->supported_group_list) {
2522
2748
  if (is_post_quantum_group(group) && hs->max_version < TLS1_3_VERSION) {
2523
2749
  continue;
2524
2750
  }
@@ -2564,7 +2790,7 @@ static bool parse_u16_array(const CBS *cbs, Array<uint16_t> *out) {
2564
2790
  static bool ext_supported_groups_parse_clienthello(SSL_HANDSHAKE *hs,
2565
2791
  uint8_t *out_alert,
2566
2792
  CBS *contents) {
2567
- if (contents == NULL) {
2793
+ if (contents == nullptr) {
2568
2794
  return true;
2569
2795
  }
2570
2796
 
@@ -2591,9 +2817,9 @@ static bool ext_certificate_authorities_add_clienthello(
2591
2817
  if (ssl_has_CA_names(hs->config)) {
2592
2818
  CBB ca_contents;
2593
2819
  if (!CBB_add_u16(out_compressible,
2594
- TLSEXT_TYPE_certificate_authorities) || //
2595
- !CBB_add_u16_length_prefixed(out_compressible, &ca_contents) || //
2596
- !ssl_add_CA_names(hs, &ca_contents) || //
2820
+ TLSEXT_TYPE_certificate_authorities) || //
2821
+ !CBB_add_u16_length_prefixed(out_compressible, &ca_contents) || //
2822
+ !ssl_add_CA_names(hs, &ca_contents) || //
2597
2823
  !CBB_flush(out_compressible)) {
2598
2824
  return false;
2599
2825
  }
@@ -2604,7 +2830,7 @@ static bool ext_certificate_authorities_add_clienthello(
2604
2830
  static bool ext_certificate_authorities_parse_clienthello(SSL_HANDSHAKE *hs,
2605
2831
  uint8_t *out_alert,
2606
2832
  CBS *contents) {
2607
- if (contents == NULL) {
2833
+ if (contents == nullptr) {
2608
2834
  return true;
2609
2835
  }
2610
2836
 
@@ -2613,13 +2839,115 @@ static bool ext_certificate_authorities_parse_clienthello(SSL_HANDSHAKE *hs,
2613
2839
  }
2614
2840
 
2615
2841
  hs->ca_names = SSL_parse_CA_list(hs->ssl, out_alert, contents);
2616
- if (!hs->ca_names) {
2842
+ if (!hs->ca_names || sk_CRYPTO_BUFFER_num(hs->ca_names.get()) == 0 ||
2843
+ CBS_len(contents) != 0) {
2617
2844
  return false;
2618
2845
  }
2619
2846
 
2620
2847
  return true;
2621
2848
  }
2622
2849
 
2850
+ // Server Padding extension.
2851
+ //
2852
+ // Adds empty bytes to EncryptedExtensions for TLS 1.3 connections that request
2853
+ // it.
2854
+
2855
+ // Limit max padding to 16k.
2856
+ constexpr uint16_t kMaxServerPadding = 16 * 1024;
2857
+
2858
+ static bool ext_server_padding_add_clienthello(const SSL_HANDSHAKE *hs,
2859
+ CBB *out, CBB *out_compressible,
2860
+ ssl_client_hello_type_t type) {
2861
+ if (!hs->config->server_padding_request.has_value()) {
2862
+ return true;
2863
+ }
2864
+
2865
+ CBB contents;
2866
+ if (!CBB_add_u16(out_compressible, TLSEXT_TYPE_server_padding) ||
2867
+ !CBB_add_u16_length_prefixed(out_compressible, &contents) ||
2868
+ !CBB_add_u16(&contents, hs->config->server_padding_request.value()) ||
2869
+ !CBB_flush(out_compressible)) {
2870
+ return false;
2871
+ }
2872
+
2873
+ return true;
2874
+ }
2875
+
2876
+ static bool ext_server_padding_parse_clienthello(SSL_HANDSHAKE *hs,
2877
+ uint8_t *out_alert,
2878
+ CBS *contents) {
2879
+ if (contents == nullptr) {
2880
+ return true;
2881
+ }
2882
+
2883
+ if (ssl_protocol_version(hs->ssl) < TLS1_3_VERSION) {
2884
+ return true;
2885
+ }
2886
+
2887
+ uint16_t padding_requested;
2888
+ if (!CBS_get_u16(contents, &padding_requested) || CBS_len(contents) != 0) {
2889
+ *out_alert = SSL_AD_DECODE_ERROR;
2890
+ OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
2891
+ return false;
2892
+ }
2893
+
2894
+ hs->client_requested_server_padding_size = padding_requested;
2895
+ return true;
2896
+ }
2897
+
2898
+ static bool ext_server_padding_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
2899
+ SSLImpl *const ssl = hs->ssl;
2900
+ if (ssl_protocol_version(ssl) < TLS1_3_VERSION ||
2901
+ !hs->client_requested_server_padding_size ||
2902
+ !hs->config->server_padding_enabled) {
2903
+ return true;
2904
+ }
2905
+
2906
+ // The extension shouldn't be sent when resuming sessions.
2907
+ if (ssl->s3->session_reused) {
2908
+ return true;
2909
+ }
2910
+
2911
+ // Limit max padding; if a client requests more than this, don't return any
2912
+ // padding.
2913
+ uint16_t padding_len = hs->client_requested_server_padding_size.value();
2914
+ if (padding_len > kMaxServerPadding) {
2915
+ return true;
2916
+ }
2917
+
2918
+ CBB contents;
2919
+ if (!CBB_add_u16(out, TLSEXT_TYPE_server_padding) ||
2920
+ !CBB_add_u16_length_prefixed(out, &contents) ||
2921
+ !CBB_add_zeros(&contents, padding_len) || !CBB_flush(out)) {
2922
+ return false;
2923
+ }
2924
+
2925
+ return true;
2926
+ }
2927
+
2928
+ static bool ext_server_padding_parse_serverhello(SSL_HANDSHAKE *hs,
2929
+ uint8_t *out_alert,
2930
+ CBS *contents) {
2931
+ if (contents == nullptr) {
2932
+ return true;
2933
+ }
2934
+
2935
+ if (ssl_protocol_version(hs->ssl) < TLS1_3_VERSION ||
2936
+ !hs->config->server_padding_request) {
2937
+ OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
2938
+ *out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
2939
+ return false;
2940
+ }
2941
+
2942
+ if (hs->config->server_padding_request.value() != CBS_len(contents)) {
2943
+ OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
2944
+ *out_alert = SSL_AD_DECODE_ERROR;
2945
+ return false;
2946
+ }
2947
+
2948
+ hs->ssl->s3->server_sent_requested_padding = true;
2949
+ return true;
2950
+ }
2623
2951
 
2624
2952
  // Trust Anchor Identifiers
2625
2953
  //
@@ -2665,7 +2993,8 @@ static bool ext_trust_anchors_parse_clienthello(SSL_HANDSHAKE *hs,
2665
2993
 
2666
2994
  CBS child;
2667
2995
  if (!CBS_get_u16_length_prefixed(contents, &child) ||
2668
- !ssl_is_valid_trust_anchor_list(child)) {
2996
+ !ssl_is_valid_trust_anchor_list(child) || //
2997
+ CBS_len(contents) != 0) {
2669
2998
  *out_alert = SSL_AD_DECODE_ERROR;
2670
2999
  OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
2671
3000
  return false;
@@ -2680,25 +3009,36 @@ static bool ext_trust_anchors_parse_clienthello(SSL_HANDSHAKE *hs,
2680
3009
  }
2681
3010
 
2682
3011
  static bool ext_trust_anchors_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
2683
- SSL *const ssl = hs->ssl;
2684
- const auto &creds = hs->config->cert->credentials;
2685
- if (ssl_protocol_version(ssl) < TLS1_3_VERSION ||
2686
- // Check if any credentials have trust anchor IDs.
2687
- std::none_of(creds.begin(), creds.end(), [](const auto &cred) {
2688
- return !cred->trust_anchor_id.empty();
2689
- })) {
3012
+ SSLImpl *const ssl = hs->ssl;
3013
+ if (ssl_protocol_version(ssl) < TLS1_3_VERSION) {
2690
3014
  return true;
2691
3015
  }
2692
- CBB contents, list;
2693
- if (!CBB_add_u16(out, TLSEXT_TYPE_trust_anchors) || //
2694
- !CBB_add_u16_length_prefixed(out, &contents) || //
3016
+
3017
+ const size_t old_len = CBB_len(out);
3018
+ CBB contents, list, child;
3019
+ if (!CBB_add_u16(out, TLSEXT_TYPE_trust_anchors) ||
3020
+ !CBB_add_u16_length_prefixed(out, &contents) ||
2695
3021
  !CBB_add_u16_length_prefixed(&contents, &list)) {
2696
3022
  return false;
2697
3023
  }
2698
- for (const auto &cred : creds) {
3024
+
3025
+ // Use the caller-provided list if they overrode it.
3026
+ if (!hs->config->cert->available_trust_anchors.empty()) {
3027
+ return CBB_add_bytes(&list,
3028
+ hs->config->cert->available_trust_anchors.data(),
3029
+ hs->config->cert->available_trust_anchors.size()) &&
3030
+ CBB_flush(out);
3031
+ }
3032
+
3033
+ for (const auto &cred : hs->config->cert->credentials) {
2699
3034
  if (!cred->trust_anchor_id.empty()) {
2700
- CBB child;
2701
- if (!CBB_add_u8_length_prefixed(&list, &child) || //
3035
+ uint16_t unused_sigalg;
3036
+ if (!ssl_check_tls13_credential_ignoring_issuer(
3037
+ hs, kAllCertTypes, cred.get(), &unused_sigalg)) {
3038
+ ERR_clear_error();
3039
+ continue;
3040
+ }
3041
+ if (!CBB_add_u8_length_prefixed(&list, &child) ||
2702
3042
  !CBB_add_bytes(&child, cred->trust_anchor_id.data(),
2703
3043
  cred->trust_anchor_id.size()) ||
2704
3044
  !CBB_flush(&list)) {
@@ -2706,7 +3046,17 @@ static bool ext_trust_anchors_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
2706
3046
  }
2707
3047
  }
2708
3048
  }
2709
- return CBB_flush(out);
3049
+
3050
+ bool empty = CBB_len(&list) == 0;
3051
+ if (!CBB_flush(out)) {
3052
+ return false;
3053
+ }
3054
+
3055
+ // Don't send the extension if it would have been empty.
3056
+ if (empty) {
3057
+ CBB_discard(out, CBB_len(out) - old_len);
3058
+ }
3059
+ return true;
2710
3060
  }
2711
3061
 
2712
3062
  static bool ext_trust_anchors_parse_serverhello(SSL_HANDSHAKE *hs,
@@ -2725,8 +3075,9 @@ static bool ext_trust_anchors_parse_serverhello(SSL_HANDSHAKE *hs,
2725
3075
  CBS child;
2726
3076
  if (!CBS_get_u16_length_prefixed(contents, &child) ||
2727
3077
  // The list of available trust anchors may not be empty.
2728
- CBS_len(&child) == 0 || //
2729
- !ssl_is_valid_trust_anchor_list(child)) {
3078
+ CBS_len(&child) == 0 || //
3079
+ !ssl_is_valid_trust_anchor_list(child) || //
3080
+ CBS_len(contents) != 0) {
2730
3081
  *out_alert = SSL_AD_DECODE_ERROR;
2731
3082
  OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
2732
3083
  return false;
@@ -2792,7 +3143,7 @@ static bool ext_quic_transport_params_add_clienthello_legacy(
2792
3143
  static bool ext_quic_transport_params_parse_serverhello_impl(
2793
3144
  SSL_HANDSHAKE *hs, uint8_t *out_alert, CBS *contents,
2794
3145
  bool used_legacy_codepoint) {
2795
- SSL *const ssl = hs->ssl;
3146
+ SSLImpl *const ssl = hs->ssl;
2796
3147
  if (contents == nullptr) {
2797
3148
  if (used_legacy_codepoint != hs->config->quic_use_legacy_codepoint) {
2798
3149
  // Silently ignore because we expect the other QUIC codepoint.
@@ -2828,13 +3179,13 @@ static bool ext_quic_transport_params_parse_serverhello_legacy(
2828
3179
  static bool ext_quic_transport_params_parse_clienthello_impl(
2829
3180
  SSL_HANDSHAKE *hs, uint8_t *out_alert, CBS *contents,
2830
3181
  bool used_legacy_codepoint) {
2831
- SSL *const ssl = hs->ssl;
3182
+ SSLImpl *const ssl = hs->ssl;
2832
3183
  if (!contents) {
2833
3184
  if (!SSL_is_quic(ssl)) {
2834
3185
  if (hs->config->quic_transport_params.empty()) {
2835
3186
  return true;
2836
3187
  }
2837
- // QUIC transport parameters must not be set if |ssl| is not configured
3188
+ // QUIC transport parameters must not be set if `ssl` is not configured
2838
3189
  // for QUIC.
2839
3190
  OPENSSL_PUT_ERROR(SSL, SSL_R_QUIC_TRANSPORT_PARAMETERS_MISCONFIGURED);
2840
3191
  *out_alert = SSL_AD_INTERNAL_ERROR;
@@ -3005,7 +3356,7 @@ static bool cert_compression_parse_clienthello(SSL_HANDSHAKE *hs,
3005
3356
  return true;
3006
3357
  }
3007
3358
 
3008
- const SSL_CTX *ctx = hs->ssl->ctx.get();
3359
+ const SSLContext *ctx = hs->ssl->ctx.get();
3009
3360
  const size_t num_algs = ctx->cert_compression_algs.size();
3010
3361
 
3011
3362
  CBS alg_ids;
@@ -3090,7 +3441,7 @@ bool ssl_setup_pake_shares(SSL_HANDSHAKE *hs) {
3090
3441
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CREDENTIAL_LIST);
3091
3442
  return false;
3092
3443
  }
3093
- SSL_CREDENTIAL *cred = creds[0].get();
3444
+ SSLCredential *cred = creds[0].get();
3094
3445
  assert(cred->type == SSLCredentialType::kSPAKE2PlusV1Client);
3095
3446
 
3096
3447
  hs->pake_prover = MakeUnique<spake2plus::Prover>();
@@ -3175,7 +3526,7 @@ bool ssl_ext_pake_parse_serverhello(SSL_HANDSHAKE *hs,
3175
3526
  }
3176
3527
  Span<const uint8_t> pake_msg_span = pake_msg;
3177
3528
 
3178
- // Releasing the result of |ComputeConfirmation| lets the client confirm one
3529
+ // Releasing the result of `ComputeConfirmation` lets the client confirm one
3179
3530
  // PAKE guess. If all failures are used up, no more guesses are allowed.
3180
3531
  if (!hs->credential->HasPAKEAttempts()) {
3181
3532
  OPENSSL_PUT_ERROR(SSL, SSL_R_PAKE_EXHAUSTED);
@@ -3187,7 +3538,7 @@ bool ssl_ext_pake_parse_serverhello(SSL_HANDSHAKE *hs,
3187
3538
  uint8_t prover_secret[spake2plus::kSecretSize];
3188
3539
  if (!hs->pake_prover->ComputeConfirmation(
3189
3540
  prover_confirm, prover_secret,
3190
- pake_msg_span.subspan(0, spake2plus::kShareSize),
3541
+ pake_msg_span.first<spake2plus::kShareSize>(),
3191
3542
  pake_msg_span.subspan(spake2plus::kShareSize))) {
3192
3543
  // Record a failure before releasing the answer to the client.
3193
3544
  hs->credential->ClaimPAKEAttempt();
@@ -3294,7 +3645,7 @@ static bool ext_alps_add_clienthello_impl(const SSL_HANDSHAKE *hs, CBB *out,
3294
3645
  CBB *out_compressible,
3295
3646
  ssl_client_hello_type_t type,
3296
3647
  bool use_new_codepoint) {
3297
- const SSL *const ssl = hs->ssl;
3648
+ const SSLImpl *const ssl = hs->ssl;
3298
3649
  if ( // ALPS requires TLS 1.3.
3299
3650
  hs->max_version < TLS1_3_VERSION ||
3300
3651
  // Do not offer ALPS without ALPN.
@@ -3351,7 +3702,7 @@ static bool ext_alps_add_clienthello_old(const SSL_HANDSHAKE *hs, CBB *out,
3351
3702
  static bool ext_alps_parse_serverhello_impl(SSL_HANDSHAKE *hs,
3352
3703
  uint8_t *out_alert, CBS *contents,
3353
3704
  bool use_new_codepoint) {
3354
- SSL *const ssl = hs->ssl;
3705
+ SSLImpl *const ssl = hs->ssl;
3355
3706
  if (contents == nullptr) {
3356
3707
  return true;
3357
3708
  }
@@ -3369,7 +3720,7 @@ static bool ext_alps_parse_serverhello_impl(SSL_HANDSHAKE *hs,
3369
3720
  }
3370
3721
 
3371
3722
  // Note extension callbacks may run in any order, so we defer checking
3372
- // consistency with ALPN to |ssl_check_serverhello_tlsext|.
3723
+ // consistency with ALPN to `ssl_check_serverhello_tlsext`.
3373
3724
  if (!hs->new_session->peer_application_settings.CopyFrom(*contents)) {
3374
3725
  *out_alert = SSL_AD_INTERNAL_ERROR;
3375
3726
  return false;
@@ -3393,7 +3744,7 @@ static bool ext_alps_parse_serverhello_old(SSL_HANDSHAKE *hs,
3393
3744
 
3394
3745
  static bool ext_alps_add_serverhello_impl(SSL_HANDSHAKE *hs, CBB *out,
3395
3746
  bool use_new_codepoint) {
3396
- SSL *const ssl = hs->ssl;
3747
+ SSLImpl *const ssl = hs->ssl;
3397
3748
  // If early data is accepted, we omit the ALPS extension. It is implicitly
3398
3749
  // carried over from the previous connection.
3399
3750
  if (hs->new_session == nullptr ||
@@ -3435,7 +3786,7 @@ static bool ext_alps_add_serverhello_old(SSL_HANDSHAKE *hs, CBB *out) {
3435
3786
 
3436
3787
  bool ssl_negotiate_alps(SSL_HANDSHAKE *hs, uint8_t *out_alert,
3437
3788
  const SSL_CLIENT_HELLO *client_hello) {
3438
- SSL *const ssl = hs->ssl;
3789
+ SSLImpl *const ssl = hs->ssl;
3439
3790
  if (ssl->s3->alpn_selected.empty()) {
3440
3791
  return true;
3441
3792
  }
@@ -3489,6 +3840,249 @@ bool ssl_negotiate_alps(SSL_HANDSHAKE *hs, uint8_t *out_alert,
3489
3840
  return true;
3490
3841
  }
3491
3842
 
3843
+ // Client certificate type & Server certificate type
3844
+ //
3845
+ // https://www.rfc-editor.org/rfc/rfc7250.html#section-3
3846
+
3847
+ // parse_clienthello_cert_types_list returns a span containing the cert type
3848
+ // values from a client_certificate_type or server_certificate_type ClientHello
3849
+ // extension. Returns std::nullopt on error, or returns a nonempty span
3850
+ // containing the values. This rejects the invalid empty list and list
3851
+ // containing only the default X.509. This does not filter out unrecognized
3852
+ // values. We don't check for duplicates here, even though a list containing
3853
+ // duplicates should be considered invalid, to avoid quadratic behavior.
3854
+ static std::optional<Span<const uint8_t>> parse_clienthello_cert_types_list(
3855
+ uint8_t *out_alert, CBS *contents) {
3856
+ CBS cert_types;
3857
+ if (!CBS_get_u8_length_prefixed(contents, &cert_types) ||
3858
+ CBS_len(contents) != 0) {
3859
+ OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
3860
+ *out_alert = SSL_AD_ILLEGAL_PARAMETER;
3861
+ return std::nullopt;
3862
+ }
3863
+ Span<const uint8_t> cert_types_list(cert_types);
3864
+ // The client must omit the extension if the only type would be the default,
3865
+ // X.509.
3866
+ if (cert_types_list.empty() ||
3867
+ (cert_types_list.size() == 1 && cert_types_list[0] == kDefaultCertType)) {
3868
+ OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
3869
+ *out_alert = SSL_AD_ILLEGAL_PARAMETER;
3870
+ return std::nullopt;
3871
+ }
3872
+ return cert_types_list;
3873
+ }
3874
+
3875
+ void ssl_setup_client_certificate_type(SSL_HANDSHAKE *hs) {
3876
+ assert(!hs->ssl->server);
3877
+ hs->offered_client_cert_types.clear();
3878
+ InplaceVector<uint8_t, kNumCertTypes> available_cert_types;
3879
+ if (!hs->ssl->config->available_client_cert_types.empty()) {
3880
+ available_cert_types.CopyFrom(hs->ssl->config->available_client_cert_types);
3881
+ } else {
3882
+ // Compute the available cert types based on configured SSL_CREDENTIALs.
3883
+ const auto append_if_not_present = [&](uint8_t cert_type) {
3884
+ if (std::find(available_cert_types.begin(), available_cert_types.end(),
3885
+ cert_type) == available_cert_types.end()) {
3886
+ available_cert_types.PushBack(cert_type);
3887
+ }
3888
+ };
3889
+ for (const auto &credential : hs->config->cert->credentials) {
3890
+ if (std::optional<uint8_t> cert_type =
3891
+ ssl_credential_type_to_cert_type(credential->type);
3892
+ cert_type.has_value()) {
3893
+ append_if_not_present(*cert_type);
3894
+ }
3895
+ }
3896
+ }
3897
+ if (available_cert_types.empty() ||
3898
+ // Omit extension if the only type would be the default, X.509.
3899
+ (available_cert_types.size() == 1 &&
3900
+ available_cert_types[0] == kDefaultCertType)) {
3901
+ return;
3902
+ }
3903
+ hs->offered_client_cert_types = std::move(available_cert_types);
3904
+ }
3905
+
3906
+ bool ssl_negotiate_client_certificate_type(
3907
+ SSL_HANDSHAKE *hs, uint8_t *out_alert,
3908
+ const SSL_CLIENT_HELLO *client_hello) {
3909
+ assert(hs->ssl->server);
3910
+ assert(!hs->config->accepted_peer_cert_types.empty());
3911
+ CBS contents;
3912
+ Span<const uint8_t> peer_available_client_cert_types;
3913
+ if (ssl_client_hello_get_extension(client_hello, &contents,
3914
+ TLSEXT_TYPE_client_cert_type)) {
3915
+ std::optional<Span<const uint8_t>> client_hello_client_cert_types =
3916
+ parse_clienthello_cert_types_list(out_alert, &contents);
3917
+ if (!client_hello_client_cert_types.has_value()) {
3918
+ return false;
3919
+ }
3920
+ peer_available_client_cert_types = *client_hello_client_cert_types;
3921
+ }
3922
+ if (!hs->cert_request) {
3923
+ return true;
3924
+ }
3925
+ // If the client didn't send the extension, assume the client supports X.509
3926
+ // only by default.
3927
+ if (peer_available_client_cert_types.empty()) {
3928
+ peer_available_client_cert_types =
3929
+ Span<const uint8_t>(&kDefaultCertType, 1u);
3930
+ }
3931
+ for (const uint8_t cert_type : hs->config->accepted_peer_cert_types) {
3932
+ if (std::find(peer_available_client_cert_types.begin(),
3933
+ peer_available_client_cert_types.end(),
3934
+ cert_type) == peer_available_client_cert_types.end()) {
3935
+ continue;
3936
+ }
3937
+ hs->peer_cert_type = cert_type;
3938
+ return true;
3939
+ }
3940
+ OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CERTIFICATE);
3941
+ *out_alert = SSL_AD_UNSUPPORTED_CERTIFICATE;
3942
+ return false;
3943
+ }
3944
+
3945
+ static bool ext_client_cert_type_add_clienthello(const SSL_HANDSHAKE *hs,
3946
+ CBB *out,
3947
+ CBB *out_compressible,
3948
+ ssl_client_hello_type_t type) {
3949
+ if (hs->offered_client_cert_types.empty()) {
3950
+ return true;
3951
+ }
3952
+ CBB contents, client_cert_types;
3953
+ if (!CBB_add_u16(out, TLSEXT_TYPE_client_cert_type) ||
3954
+ !CBB_add_u16_length_prefixed(out, &contents) ||
3955
+ !CBB_add_u8_length_prefixed(&contents, &client_cert_types) ||
3956
+ !CBB_add_bytes(&client_cert_types, hs->offered_client_cert_types.data(),
3957
+ hs->offered_client_cert_types.size()) ||
3958
+ !CBB_flush(out)) {
3959
+ return false;
3960
+ }
3961
+ return true;
3962
+ }
3963
+
3964
+ static bool ext_client_cert_type_parse_serverhello(SSL_HANDSHAKE *hs,
3965
+ uint8_t *out_alert,
3966
+ CBS *contents) {
3967
+ if (contents == nullptr) {
3968
+ return true;
3969
+ }
3970
+ uint8_t cert_type;
3971
+ if (!CBS_get_u8(contents, &cert_type) || CBS_len(contents) != 0) {
3972
+ OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
3973
+ *out_alert = SSL_AD_DECODE_ERROR;
3974
+ return false;
3975
+ }
3976
+ // Reject if the server picked a cert type that we didn't offer in the
3977
+ // ClientHello.
3978
+ if (std::find(hs->offered_client_cert_types.begin(),
3979
+ hs->offered_client_cert_types.end(),
3980
+ cert_type) == hs->offered_client_cert_types.end()) {
3981
+ OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CERTIFICATE);
3982
+ *out_alert = SSL_AD_UNSUPPORTED_CERTIFICATE;
3983
+ return false;
3984
+ }
3985
+ hs->client_cert_type = cert_type;
3986
+ return true;
3987
+ }
3988
+
3989
+ static bool ext_client_cert_type_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
3990
+ // Only send client_certificate_type if we plan to send a CertificateRequest.
3991
+ if (!hs->cert_request) {
3992
+ return true;
3993
+ }
3994
+ CBB contents;
3995
+ if (!CBB_add_u16(out, TLSEXT_TYPE_client_cert_type) ||
3996
+ !CBB_add_u16_length_prefixed(out, &contents) ||
3997
+ !CBB_add_u8(&contents, hs->peer_cert_type) || //
3998
+ !CBB_flush(out)) {
3999
+ return false;
4000
+ }
4001
+ return true;
4002
+ }
4003
+
4004
+ std::optional<Span<const uint8_t>> ssl_get_allowed_server_cert_types(
4005
+ const SSL_HANDSHAKE *hs, const SSL_CLIENT_HELLO *client_hello,
4006
+ uint8_t *out_alert) {
4007
+ assert(hs->ssl->server);
4008
+ std::optional<Span<const uint8_t>> clienthello_server_cert_types;
4009
+ CBS server_cert_types_ext;
4010
+ if (ssl_client_hello_get_extension(client_hello, &server_cert_types_ext,
4011
+ TLSEXT_TYPE_server_cert_type)) {
4012
+ clienthello_server_cert_types =
4013
+ parse_clienthello_cert_types_list(out_alert, &server_cert_types_ext);
4014
+ if (!clienthello_server_cert_types.has_value()) {
4015
+ OPENSSL_PUT_ERROR(SSL, SSL_R_ERROR_PARSING_EXTENSION);
4016
+ return std::nullopt;
4017
+ }
4018
+ }
4019
+ // Allow X.509 certificates by default.
4020
+ return clienthello_server_cert_types.value_or(Span(&kDefaultCertType, 1u));
4021
+ }
4022
+
4023
+ static bool ext_server_cert_type_add_clienthello(const SSL_HANDSHAKE *hs,
4024
+ CBB *out,
4025
+ CBB *out_compressible,
4026
+ ssl_client_hello_type_t type) {
4027
+ assert(!hs->config->accepted_peer_cert_types.empty());
4028
+ // Omit extension if the only type would be the default, X.509.
4029
+ if (hs->config->accepted_peer_cert_types.size() == 1 &&
4030
+ hs->config->accepted_peer_cert_types[0] == kDefaultCertType) {
4031
+ return true;
4032
+ }
4033
+ CBB contents, server_cert_types;
4034
+ if (!CBB_add_u16(out, TLSEXT_TYPE_server_cert_type) ||
4035
+ !CBB_add_u16_length_prefixed(out, &contents) ||
4036
+ !CBB_add_u8_length_prefixed(&contents, &server_cert_types) ||
4037
+ !CBB_add_bytes(&server_cert_types,
4038
+ hs->config->accepted_peer_cert_types.data(),
4039
+ hs->config->accepted_peer_cert_types.size()) ||
4040
+ !CBB_flush(out)) {
4041
+ return false;
4042
+ }
4043
+ return true;
4044
+ }
4045
+
4046
+ static bool ext_server_cert_type_parse_serverhello(SSL_HANDSHAKE *hs,
4047
+ uint8_t *out_alert,
4048
+ CBS *contents) {
4049
+ assert(!hs->config->accepted_peer_cert_types.empty());
4050
+ // Absence of an extension from the server implies the default, X.509.
4051
+ uint8_t cert_type = kDefaultCertType;
4052
+ if (contents != nullptr &&
4053
+ (!CBS_get_u8(contents, &cert_type) || CBS_len(contents) != 0)) {
4054
+ return false;
4055
+ }
4056
+ // Check that the server's chosen type is among the types we accept.
4057
+ if (std::find(hs->config->accepted_peer_cert_types.begin(),
4058
+ hs->config->accepted_peer_cert_types.end(),
4059
+ cert_type) == hs->config->accepted_peer_cert_types.end()) {
4060
+ OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_CERTIFICATE);
4061
+ *out_alert = SSL_AD_UNSUPPORTED_CERTIFICATE;
4062
+ return false;
4063
+ }
4064
+ hs->peer_cert_type = cert_type;
4065
+ return true;
4066
+ }
4067
+
4068
+ static bool ext_server_cert_type_add_serverhello(SSL_HANDSHAKE *hs, CBB *out) {
4069
+ if (hs->credential == nullptr) {
4070
+ return true;
4071
+ }
4072
+ const auto cert_type = ssl_credential_type_to_cert_type(hs->credential->type);
4073
+ if (!cert_type.has_value()) {
4074
+ return true;
4075
+ }
4076
+ CBB contents;
4077
+ if (!CBB_add_u16(out, TLSEXT_TYPE_server_cert_type) ||
4078
+ !CBB_add_u16_length_prefixed(out, &contents) ||
4079
+ !CBB_add_u8(&contents, *cert_type) || //
4080
+ !CBB_flush(out)) {
4081
+ return false;
4082
+ }
4083
+ return true;
4084
+ }
4085
+
3492
4086
  // kExtensions contains all the supported extensions.
3493
4087
  static const struct tls_extension kExtensions[] = {
3494
4088
  {
@@ -3545,7 +4139,7 @@ static const struct tls_extension kExtensions[] = {
3545
4139
  TLSEXT_TYPE_application_layer_protocol_negotiation,
3546
4140
  ext_alpn_add_clienthello,
3547
4141
  ext_alpn_parse_serverhello,
3548
- // ALPN is negotiated late in |ssl_negotiate_alpn|.
4142
+ // ALPN is negotiated late in `ssl_negotiate_alpn`.
3549
4143
  ignore_parse_clienthello,
3550
4144
  ext_alpn_add_serverhello,
3551
4145
  },
@@ -3658,7 +4252,7 @@ static const struct tls_extension kExtensions[] = {
3658
4252
  TLSEXT_TYPE_application_settings,
3659
4253
  ext_alps_add_clienthello,
3660
4254
  ext_alps_parse_serverhello,
3661
- // ALPS is negotiated late in |ssl_negotiate_alpn|.
4255
+ // ALPS is negotiated late in `ssl_negotiate_alpn`.
3662
4256
  ignore_parse_clienthello,
3663
4257
  ext_alps_add_serverhello,
3664
4258
  },
@@ -3666,7 +4260,7 @@ static const struct tls_extension kExtensions[] = {
3666
4260
  TLSEXT_TYPE_application_settings_old,
3667
4261
  ext_alps_add_clienthello_old,
3668
4262
  ext_alps_parse_serverhello_old,
3669
- // ALPS is negotiated late in |ssl_negotiate_alpn|.
4263
+ // ALPS is negotiated late in `ssl_negotiate_alpn`.
3670
4264
  ignore_parse_clienthello,
3671
4265
  ext_alps_add_serverhello_old,
3672
4266
  },
@@ -3693,15 +4287,40 @@ static const struct tls_extension kExtensions[] = {
3693
4287
  ext_trust_anchors_parse_clienthello,
3694
4288
  ext_trust_anchors_add_serverhello,
3695
4289
  },
4290
+ {
4291
+ TLSEXT_TYPE_client_cert_type,
4292
+ ext_client_cert_type_add_clienthello,
4293
+ ext_client_cert_type_parse_serverhello,
4294
+ // client_certificate_type is negotiated late in
4295
+ // `ssl_negotiate_client_cert_type`.
4296
+ ignore_parse_clienthello,
4297
+ ext_client_cert_type_add_serverhello,
4298
+ },
4299
+ {
4300
+ TLSEXT_TYPE_server_cert_type,
4301
+ ext_server_cert_type_add_clienthello,
4302
+ ext_server_cert_type_parse_serverhello,
4303
+ // The server_certificate_type list from the client is parsed later,
4304
+ // during credential selection.
4305
+ ignore_parse_clienthello,
4306
+ ext_server_cert_type_add_serverhello,
4307
+ },
4308
+ {
4309
+ TLSEXT_TYPE_server_padding,
4310
+ ext_server_padding_add_clienthello,
4311
+ ext_server_padding_parse_serverhello,
4312
+ ext_server_padding_parse_clienthello,
4313
+ ext_server_padding_add_serverhello,
4314
+ },
3696
4315
  };
3697
4316
 
3698
4317
  #define kNumExtensions (sizeof(kExtensions) / sizeof(struct tls_extension))
3699
4318
 
3700
4319
  static_assert(kNumExtensions <=
3701
- sizeof(((SSL_HANDSHAKE *)NULL)->extensions.sent) * 8,
4320
+ sizeof(((SSL_HANDSHAKE *)nullptr)->extensions.sent) * 8,
3702
4321
  "too many extensions for sent bitset");
3703
4322
  static_assert(kNumExtensions <=
3704
- sizeof(((SSL_HANDSHAKE *)NULL)->extensions.received) * 8,
4323
+ sizeof(((SSL_HANDSHAKE *)nullptr)->extensions.received) * 8,
3705
4324
  "too many extensions for received bitset");
3706
4325
 
3707
4326
  bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs) {
@@ -3721,7 +4340,7 @@ bool ssl_setup_extension_permutation(SSL_HANDSHAKE *hs) {
3721
4340
  permutation[i] = i;
3722
4341
  }
3723
4342
  for (size_t i = kNumExtensions - 1; i > 0; i--) {
3724
- // Set element |i| to a randomly-selected element 0 <= j <= i.
4343
+ // Set element `i` to a randomly-selected element 0 <= j <= i.
3725
4344
  std::swap(permutation[i], permutation[seeds[i - 1] % (i + 1)]);
3726
4345
  }
3727
4346
  hs->extension_permutation = std::move(permutation);
@@ -3738,7 +4357,7 @@ static const struct tls_extension *tls_extension_find(uint32_t *out_index,
3738
4357
  }
3739
4358
  }
3740
4359
 
3741
- return NULL;
4360
+ return nullptr;
3742
4361
  }
3743
4362
 
3744
4363
  static bool add_padding_extension(CBB *cbb, uint16_t ext, size_t len) {
@@ -3753,14 +4372,13 @@ static bool add_padding_extension(CBB *cbb, uint16_t ext, size_t len) {
3753
4372
  }
3754
4373
 
3755
4374
  static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
3756
- CBB *out_encoded,
3757
- bool *out_needs_psk_binder) {
4375
+ CBB *out_encoded) {
3758
4376
  // When writing ClientHelloInner, we construct the real and encoded
3759
4377
  // ClientHellos concurrently, to handle compression. Uncompressed extensions
3760
- // are written to |extensions| and copied to |extensions_encoded|. Compressed
3761
- // extensions are buffered in |compressed| and written to the end. (ECH can
3762
- // only compress continguous extensions.)
3763
- SSL *const ssl = hs->ssl;
4378
+ // are written to `extensions` and copied to `extensions_encoded`. Compressed
4379
+ // extensions are buffered in `compressed` and written to the end. (ECH can
4380
+ // only compress contiguous extensions.)
4381
+ SSLImpl *const ssl = hs->ssl;
3764
4382
  bssl::ScopedCBB compressed, outer_extensions;
3765
4383
  CBB extensions, extensions_encoded;
3766
4384
  if (!CBB_add_u16_length_prefixed(out, &extensions) ||
@@ -3775,7 +4393,7 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
3775
4393
 
3776
4394
  if (ssl->ctx->grease_enabled) {
3777
4395
  // Add a fake empty extension. See RFC 8701. This always matches
3778
- // |ssl_add_clienthello_tlsext|, so compress it.
4396
+ // `ssl_add_clienthello_tlsext`, so compress it.
3779
4397
  uint16_t grease_ext = ssl_get_grease_value(hs, ssl_grease_extension1);
3780
4398
  if (!add_padding_extension(compressed.get(), grease_ext, 0) ||
3781
4399
  !CBB_add_u16(outer_extensions.get(), grease_ext)) {
@@ -3813,7 +4431,7 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
3813
4431
 
3814
4432
  if (ssl->ctx->grease_enabled) {
3815
4433
  // Add a fake non-empty extension. See RFC 8701. This always matches
3816
- // |ssl_add_clienthello_tlsext|, so compress it.
4434
+ // `ssl_add_clienthello_tlsext`, so compress it.
3817
4435
  uint16_t grease_ext = ssl_get_grease_value(hs, ssl_grease_extension2);
3818
4436
  if (!add_padding_extension(compressed.get(), grease_ext, 1) ||
3819
4437
  !CBB_add_u16(outer_extensions.get(), grease_ext)) {
@@ -3844,15 +4462,16 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
3844
4462
  }
3845
4463
  }
3846
4464
 
3847
- // The PSK extension must be last. It is never compressed. Note, if there is a
3848
- // binder, the caller will need to update both ClientHelloInner and
3849
- // EncodedClientHelloInner after computing it.
3850
- const size_t len_before = CBB_len(&extensions);
3851
- if (!ext_pre_shared_key_add_clienthello(hs, &extensions, out_needs_psk_binder,
3852
- ssl_client_hello_inner) ||
3853
- !CBB_add_bytes(&extensions_encoded, CBB_data(&extensions) + len_before,
3854
- CBB_len(&extensions) - len_before) ||
3855
- !CBB_flush(out) || //
4465
+ // The PSK extension must be last. It is never compressed.
4466
+ size_t psk_len;
4467
+ if (!ext_pre_shared_key_add_clienthello(hs, out, &extensions, &psk_len,
4468
+ ssl_client_hello_inner)) {
4469
+ return false;
4470
+ }
4471
+
4472
+ // Copy the PSK extension to EncodedClientHelloInner.
4473
+ auto psk = CBBAsSpan(out).last(psk_len);
4474
+ if (!CBB_add_bytes(&extensions_encoded, psk.data(), psk.size()) ||
3856
4475
  !CBB_flush(out_encoded)) {
3857
4476
  return false;
3858
4477
  }
@@ -3861,18 +4480,18 @@ static bool ssl_add_clienthello_tlsext_inner(SSL_HANDSHAKE *hs, CBB *out,
3861
4480
  }
3862
4481
 
3863
4482
  bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
3864
- bool *out_needs_psk_binder,
3865
- ssl_client_hello_type_t type,
3866
- size_t header_len) {
3867
- *out_needs_psk_binder = false;
4483
+ ssl_client_hello_type_t type) {
4484
+ // `out` must contain the start of a ClientHello, which means it must begin
4485
+ // with a TLS or DTLS version.
4486
+ assert(CBB_len(out) != 0 && (CBB_data(out)[0] == SSL3_VERSION_MAJOR ||
4487
+ CBB_data(out)[0] == DTLS1_VERSION_MAJOR));
3868
4488
 
3869
4489
  if (type == ssl_client_hello_inner) {
3870
- return ssl_add_clienthello_tlsext_inner(hs, out, out_encoded,
3871
- out_needs_psk_binder);
4490
+ return ssl_add_clienthello_tlsext_inner(hs, out, out_encoded);
3872
4491
  }
3873
4492
 
3874
4493
  assert(out_encoded == nullptr); // Only ClientHelloInner needs two outputs.
3875
- SSL *const ssl = hs->ssl;
4494
+ SSLImpl *const ssl = hs->ssl;
3876
4495
  CBB extensions;
3877
4496
  if (!CBB_add_u16_length_prefixed(out, &extensions)) {
3878
4497
  OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
@@ -3921,73 +4540,29 @@ bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, CBB *out_encoded,
3921
4540
  last_was_empty = false;
3922
4541
  }
3923
4542
 
3924
- // In cleartext ClientHellos, we add the padding extension to work around
3925
- // bugs. We also apply this padding to ClientHelloOuter, to keep the wire
3926
- // images aligned.
3927
- size_t psk_extension_len = ext_pre_shared_key_clienthello_length(hs, type);
3928
- if (!SSL_is_dtls(ssl) && !SSL_is_quic(ssl) &&
3929
- !ssl->s3->used_hello_retry_request) {
3930
- header_len +=
3931
- SSL3_HM_HEADER_LENGTH + 2 + CBB_len(&extensions) + psk_extension_len;
3932
- size_t padding_len = 0;
3933
-
3934
- // The final extension must be non-empty. WebSphere Application
3935
- // Server 7.0 is intolerant to the last extension being zero-length. See
3936
- // https://crbug.com/363583.
3937
- if (last_was_empty && psk_extension_len == 0) {
3938
- padding_len = 1;
3939
- // The addition of the padding extension may push us into the F5 bug.
3940
- header_len += 4 + padding_len;
3941
- }
3942
-
3943
- // Add padding to workaround bugs in F5 terminators. See RFC 7685.
3944
- //
3945
- // NB: because this code works out the length of all existing extensions
3946
- // it MUST always appear last (save for any PSK extension).
3947
- if (header_len > 0xff && header_len < 0x200) {
3948
- // If our calculations already included a padding extension, remove that
3949
- // factor because we're about to change its length.
3950
- if (padding_len != 0) {
3951
- header_len -= 4 + padding_len;
3952
- }
3953
- padding_len = 0x200 - header_len;
3954
- // Extensions take at least four bytes to encode. Always include at least
3955
- // one byte of data if including the extension. WebSphere Application
3956
- // Server 7.0 is intolerant to the last extension being zero-length. See
3957
- // https://crbug.com/363583.
3958
- if (padding_len >= 4 + 1) {
3959
- padding_len -= 4;
3960
- } else {
3961
- padding_len = 1;
3962
- }
3963
- }
3964
-
3965
- if (padding_len != 0 &&
3966
- !add_padding_extension(&extensions, TLSEXT_TYPE_padding, padding_len)) {
4543
+ // The final extension must be non-empty. WebSphere Application Server 7.0 is
4544
+ // intolerant to the last extension being zero-length. See
4545
+ // https://crbug.com/363583.
4546
+ bool offering_psk = should_offer_psk(hs, type);
4547
+ if (!offering_psk && last_was_empty && !SSL_is_dtls(ssl) &&
4548
+ !SSL_is_quic(ssl) && !ssl->s3->used_hello_retry_request) {
4549
+ if (!add_padding_extension(&extensions, TLSEXT_TYPE_padding, 1)) {
3967
4550
  return false;
3968
4551
  }
3969
4552
  }
3970
4553
 
3971
4554
  // The PSK extension must be last, including after the padding.
3972
- const size_t len_before = CBB_len(&extensions);
3973
- if (!ext_pre_shared_key_add_clienthello(hs, &extensions, out_needs_psk_binder,
4555
+ size_t psk_len;
4556
+ if (!ext_pre_shared_key_add_clienthello(hs, out, &extensions, &psk_len,
3974
4557
  type)) {
3975
- OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
3976
4558
  return false;
3977
4559
  }
3978
- assert(psk_extension_len == CBB_len(&extensions) - len_before);
3979
- (void)len_before; // |assert| is omitted in release builds.
3980
-
3981
- // Discard empty extensions blocks.
3982
- if (CBB_len(&extensions) == 0) {
3983
- CBB_discard_child(out);
3984
- }
3985
-
3986
- return CBB_flush(out);
4560
+ assert(offering_psk == (psk_len != 0));
4561
+ return true;
3987
4562
  }
3988
4563
 
3989
4564
  bool ssl_add_serverhello_tlsext(SSL_HANDSHAKE *hs, CBB *out) {
3990
- SSL *const ssl = hs->ssl;
4565
+ SSLImpl *const ssl = hs->ssl;
3991
4566
  CBB extensions;
3992
4567
  if (!CBB_add_u16_length_prefixed(out, &extensions)) {
3993
4568
  goto err;
@@ -4039,7 +4614,7 @@ static bool ssl_scan_clienthello_tlsext(SSL_HANDSHAKE *hs,
4039
4614
  unsigned ext_index;
4040
4615
  const struct tls_extension *const ext =
4041
4616
  tls_extension_find(&ext_index, type);
4042
- if (ext == NULL) {
4617
+ if (ext == nullptr) {
4043
4618
  continue;
4044
4619
  }
4045
4620
 
@@ -4058,11 +4633,11 @@ static bool ssl_scan_clienthello_tlsext(SSL_HANDSHAKE *hs,
4058
4633
  continue;
4059
4634
  }
4060
4635
 
4061
- CBS *contents = NULL, fake_contents;
4636
+ CBS *contents = nullptr, fake_contents;
4062
4637
  static const uint8_t kFakeRenegotiateExtension[] = {0};
4063
4638
  if (kExtensions[i].value == TLSEXT_TYPE_renegotiate &&
4064
- ssl_client_cipher_list_contains_cipher(client_hello,
4065
- SSL3_CK_SCSV & 0xffff)) {
4639
+ ssl_client_cipher_list_contains_cipher(
4640
+ client_hello, SSL_CIPHER_EMPTY_RENEGOTIATION_INFO_SCSV)) {
4066
4641
  // The renegotiation SCSV was received so pretend that we received a
4067
4642
  // renegotiation extension.
4068
4643
  CBS_init(&fake_contents, kFakeRenegotiateExtension,
@@ -4087,7 +4662,7 @@ static bool ssl_scan_clienthello_tlsext(SSL_HANDSHAKE *hs,
4087
4662
 
4088
4663
  bool ssl_parse_clienthello_tlsext(SSL_HANDSHAKE *hs,
4089
4664
  const SSL_CLIENT_HELLO *client_hello) {
4090
- SSL *const ssl = hs->ssl;
4665
+ SSLImpl *const ssl = hs->ssl;
4091
4666
  int alert = SSL_AD_DECODE_ERROR;
4092
4667
  if (!ssl_scan_clienthello_tlsext(hs, client_hello, &alert)) {
4093
4668
  ssl_send_alert(ssl, SSL3_AL_FATAL, alert);
@@ -4126,7 +4701,7 @@ static bool ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *cbs,
4126
4701
  const struct tls_extension *const ext =
4127
4702
  tls_extension_find(&ext_index, type);
4128
4703
 
4129
- if (ext == NULL) {
4704
+ if (ext == nullptr) {
4130
4705
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_EXTENSION);
4131
4706
  ERR_add_error_dataf("extension %u", (unsigned)type);
4132
4707
  *out_alert = SSL_AD_UNSUPPORTED_EXTENSION;
@@ -4160,7 +4735,7 @@ static bool ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *cbs,
4160
4735
  // Extension wasn't observed so call the callback with a NULL
4161
4736
  // parameter.
4162
4737
  uint8_t alert = SSL_AD_DECODE_ERROR;
4163
- if (!kExtensions[i].parse_serverhello(hs, &alert, NULL)) {
4738
+ if (!kExtensions[i].parse_serverhello(hs, &alert, nullptr)) {
4164
4739
  OPENSSL_PUT_ERROR(SSL, SSL_R_MISSING_EXTENSION);
4165
4740
  ERR_add_error_dataf("extension %u", (unsigned)kExtensions[i].value);
4166
4741
  *out_alert = alert;
@@ -4173,12 +4748,12 @@ static bool ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *cbs,
4173
4748
  }
4174
4749
 
4175
4750
  static bool ssl_check_clienthello_tlsext(SSL_HANDSHAKE *hs) {
4176
- SSL *const ssl = hs->ssl;
4751
+ SSLImpl *const ssl = hs->ssl;
4177
4752
  int ret = SSL_TLSEXT_ERR_NOACK;
4178
4753
  int al = SSL_AD_UNRECOGNIZED_NAME;
4179
- if (ssl->ctx->servername_callback != 0) {
4754
+ if (ssl->ctx->servername_callback != nullptr) {
4180
4755
  ret = ssl->ctx->servername_callback(ssl, &al, ssl->ctx->servername_arg);
4181
- } else if (ssl->session_ctx->servername_callback != 0) {
4756
+ } else if (ssl->session_ctx->servername_callback != nullptr) {
4182
4757
  ret = ssl->session_ctx->servername_callback(
4183
4758
  ssl, &al, ssl->session_ctx->servername_arg);
4184
4759
  }
@@ -4199,7 +4774,7 @@ static bool ssl_check_clienthello_tlsext(SSL_HANDSHAKE *hs) {
4199
4774
  }
4200
4775
 
4201
4776
  static bool ssl_check_serverhello_tlsext(SSL_HANDSHAKE *hs) {
4202
- SSL *const ssl = hs->ssl;
4777
+ SSLImpl *const ssl = hs->ssl;
4203
4778
  // ALPS and ALPN have a dependency between each other, so we defer checking
4204
4779
  // consistency to after the callbacks run.
4205
4780
  if (hs->new_session != nullptr && hs->new_session->has_application_settings) {
@@ -4229,7 +4804,7 @@ static bool ssl_check_serverhello_tlsext(SSL_HANDSHAKE *hs) {
4229
4804
  }
4230
4805
 
4231
4806
  bool ssl_parse_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *cbs) {
4232
- SSL *const ssl = hs->ssl;
4807
+ SSLImpl *const ssl = hs->ssl;
4233
4808
  int alert = SSL_AD_DECODE_ERROR;
4234
4809
  if (!ssl_scan_serverhello_tlsext(hs, cbs, &alert)) {
4235
4810
  ssl_send_alert(ssl, SSL3_AL_FATAL, alert);
@@ -4259,7 +4834,7 @@ static enum ssl_ticket_aead_result_t decrypt_ticket_with_cipher_ctx(
4259
4834
  auto ticket_mac = ticket.last(mac_len);
4260
4835
  ticket = ticket.first(ticket.size() - mac_len);
4261
4836
  HMAC_Update(hmac_ctx, ticket.data(), ticket.size());
4262
- HMAC_Final(hmac_ctx, mac, NULL);
4837
+ HMAC_Final(hmac_ctx, mac, nullptr);
4263
4838
  assert(mac_len == ticket_mac.size());
4264
4839
  bool mac_ok = CRYPTO_memcmp(mac, ticket_mac.data(), mac_len) == 0;
4265
4840
  if (CRYPTO_fuzzer_mode_enabled()) {
@@ -4283,14 +4858,16 @@ static enum ssl_ticket_aead_result_t decrypt_ticket_with_cipher_ctx(
4283
4858
  if (!plaintext.InitForOverwrite(ciphertext.size())) {
4284
4859
  return ssl_ticket_aead_error;
4285
4860
  }
4286
- int len1, len2;
4287
- if (!EVP_DecryptUpdate(cipher_ctx, plaintext.data(), &len1,
4288
- ciphertext.data(), (int)ciphertext.size()) ||
4289
- !EVP_DecryptFinal_ex(cipher_ctx, plaintext.data() + len1, &len2)) {
4861
+ size_t len1, len2;
4862
+ if (!EVP_DecryptUpdate_ex(cipher_ctx, plaintext.data(), &len1,
4863
+ plaintext.size(), ciphertext.data(),
4864
+ (int)ciphertext.size()) ||
4865
+ !EVP_DecryptFinal_ex2(cipher_ctx, plaintext.data() + len1, &len2,
4866
+ plaintext.size() - len1)) {
4290
4867
  ERR_clear_error();
4291
4868
  return ssl_ticket_aead_ignore_ticket;
4292
4869
  }
4293
- plaintext.Shrink(static_cast<size_t>(len1) + len2);
4870
+ plaintext.Shrink(len1 + len2);
4294
4871
  }
4295
4872
 
4296
4873
  *out = std::move(plaintext);
@@ -4303,11 +4880,11 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_cb(
4303
4880
  assert(ticket.size() >= SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH);
4304
4881
  ScopedEVP_CIPHER_CTX cipher_ctx;
4305
4882
  ScopedHMAC_CTX hmac_ctx;
4306
- auto name = ticket.subspan(0, SSL_TICKET_KEY_NAME_LEN);
4883
+ auto name = ticket.first<SSL_TICKET_KEY_NAME_LEN>();
4307
4884
  // The actual IV is shorter, but the length is determined by the callback's
4308
- // chosen cipher. Instead we pass in |EVP_MAX_IV_LENGTH| worth of IV to ensure
4885
+ // chosen cipher. Instead we pass in `EVP_MAX_IV_LENGTH` worth of IV to ensure
4309
4886
  // the callback has enough.
4310
- auto iv = ticket.subspan(SSL_TICKET_KEY_NAME_LEN, EVP_MAX_IV_LENGTH);
4887
+ auto iv = ticket.subspan<SSL_TICKET_KEY_NAME_LEN, EVP_MAX_IV_LENGTH>();
4311
4888
  int cb_ret = hs->ssl->session_ctx->ticket_key_cb(
4312
4889
  hs->ssl, const_cast<uint8_t *>(name.data()),
4313
4890
  const_cast<uint8_t *>(iv.data()), cipher_ctx.get(), hmac_ctx.get(),
@@ -4328,7 +4905,7 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_cb(
4328
4905
  static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_ticket_keys(
4329
4906
  SSL_HANDSHAKE *hs, Array<uint8_t> *out, Span<const uint8_t> ticket) {
4330
4907
  assert(ticket.size() >= SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH);
4331
- SSL_CTX *ctx = hs->ssl->session_ctx.get();
4908
+ SSLContext *ctx = hs->ssl->session_ctx.get();
4332
4909
 
4333
4910
  // Rotate the ticket key if necessary.
4334
4911
  if (!ssl_ctx_rotate_ticket_encryption_key(ctx)) {
@@ -4336,7 +4913,7 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_ticket_keys(
4336
4913
  }
4337
4914
 
4338
4915
  const EVP_CIPHER *cipher = EVP_aes_128_cbc();
4339
- auto name = ticket.subspan(0, SSL_TICKET_KEY_NAME_LEN);
4916
+ auto name = ticket.first<SSL_TICKET_KEY_NAME_LEN>();
4340
4917
  auto iv =
4341
4918
  ticket.subspan(SSL_TICKET_KEY_NAME_LEN, EVP_CIPHER_iv_length(cipher));
4342
4919
 
@@ -4354,8 +4931,8 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_ticket_keys(
4354
4931
  return ssl_ticket_aead_ignore_ticket;
4355
4932
  }
4356
4933
  if (!HMAC_Init_ex(hmac_ctx.get(), key->hmac_key, sizeof(key->hmac_key),
4357
- tlsext_tick_md(), NULL) ||
4358
- !EVP_DecryptInit_ex(cipher_ctx.get(), cipher, NULL, key->aes_key,
4934
+ tlsext_tick_md(), nullptr) ||
4935
+ !EVP_DecryptInit_ex(cipher_ctx.get(), cipher, nullptr, key->aes_key,
4359
4936
  iv.data())) {
4360
4937
  return ssl_ticket_aead_error;
4361
4938
  }
@@ -4387,10 +4964,10 @@ static enum ssl_ticket_aead_result_t ssl_decrypt_ticket_with_method(
4387
4964
  }
4388
4965
 
4389
4966
  enum ssl_ticket_aead_result_t ssl_process_ticket(
4390
- SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
4967
+ SSL_HANDSHAKE *hs, UniquePtr<SSLSession> *out_session,
4391
4968
  bool *out_renew_ticket, Span<const uint8_t> ticket,
4392
- Span<const uint8_t> session_id) {
4393
- SSL *const ssl = hs->ssl;
4969
+ Span<const uint8_t> session_id, bool save_ticket) {
4970
+ SSLImpl *const ssl = hs->ssl;
4394
4971
  *out_renew_ticket = false;
4395
4972
  out_session->reset();
4396
4973
 
@@ -4400,40 +4977,42 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
4400
4977
  }
4401
4978
 
4402
4979
  // Tickets in TLS 1.3 are tied into pre-shared keys (PSKs), unlike in TLS 1.2
4403
- // where that concept doesn't exist. The |decrypted_psk| and |ignore_psk|
4980
+ // where that concept doesn't exist. The `decrypted_psk` and `ignore_psk`
4404
4981
  // hints only apply to PSKs. We check the version to determine which this is.
4405
4982
  const bool is_psk = ssl_protocol_version(ssl) >= TLS1_3_VERSION;
4406
4983
 
4407
4984
  Array<uint8_t> plaintext;
4408
4985
  enum ssl_ticket_aead_result_t result;
4409
- SSL_HANDSHAKE_HINTS *const hints = hs->hints.get();
4410
- if (is_psk && hints && !hs->hints_requested &&
4411
- !hints->decrypted_psk.empty()) {
4412
- result = plaintext.CopyFrom(hints->decrypted_psk) ? ssl_ticket_aead_success
4413
- : ssl_ticket_aead_error;
4414
- } else if (is_psk && hints && !hs->hints_requested && hints->ignore_psk) {
4986
+ if (is_psk && hs->provided_hints != nullptr &&
4987
+ !hs->provided_hints->decrypted_psk.empty()) {
4988
+ result = plaintext.CopyFrom(hs->provided_hints->decrypted_psk)
4989
+ ? ssl_ticket_aead_success
4990
+ : ssl_ticket_aead_error;
4991
+ } else if (is_psk && hs->provided_hints != nullptr &&
4992
+ hs->provided_hints->ignore_psk) {
4415
4993
  result = ssl_ticket_aead_ignore_ticket;
4416
- } else if (!is_psk && hints && !hs->hints_requested &&
4417
- !hints->decrypted_ticket.empty()) {
4418
- if (plaintext.CopyFrom(hints->decrypted_ticket)) {
4994
+ } else if (!is_psk && hs->provided_hints != nullptr &&
4995
+ !hs->provided_hints->decrypted_ticket.empty()) {
4996
+ if (plaintext.CopyFrom(hs->provided_hints->decrypted_ticket)) {
4419
4997
  result = ssl_ticket_aead_success;
4420
- *out_renew_ticket = hints->renew_ticket;
4998
+ *out_renew_ticket = hs->provided_hints->renew_ticket;
4421
4999
  } else {
4422
5000
  result = ssl_ticket_aead_error;
4423
5001
  }
4424
- } else if (!is_psk && hints && !hs->hints_requested && hints->ignore_ticket) {
5002
+ } else if (!is_psk && hs->provided_hints != nullptr &&
5003
+ hs->provided_hints->ignore_ticket) {
4425
5004
  result = ssl_ticket_aead_ignore_ticket;
4426
- } else if (ssl->session_ctx->ticket_aead_method != NULL) {
5005
+ } else if (ssl->session_ctx->ticket_aead_method != nullptr) {
4427
5006
  result = ssl_decrypt_ticket_with_method(hs, &plaintext, out_renew_ticket,
4428
5007
  ticket);
4429
5008
  } else {
4430
- // Ensure there is room for the key name and the largest IV |ticket_key_cb|
5009
+ // Ensure there is room for the key name and the largest IV `ticket_key_cb`
4431
5010
  // may try to consume. The real limit may be lower, but the maximum IV
4432
5011
  // length should be well under the minimum size for the session material and
4433
5012
  // HMAC.
4434
5013
  if (ticket.size() < SSL_TICKET_KEY_NAME_LEN + EVP_MAX_IV_LENGTH) {
4435
5014
  result = ssl_ticket_aead_ignore_ticket;
4436
- } else if (ssl->session_ctx->ticket_key_cb != NULL) {
5015
+ } else if (ssl->session_ctx->ticket_key_cb != nullptr) {
4437
5016
  result =
4438
5017
  ssl_decrypt_ticket_with_cb(hs, &plaintext, out_renew_ticket, ticket);
4439
5018
  } else {
@@ -4441,23 +5020,23 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
4441
5020
  }
4442
5021
  }
4443
5022
 
4444
- if (hints && hs->hints_requested) {
5023
+ if (hs->pending_hints != nullptr) {
4445
5024
  if (result == ssl_ticket_aead_ignore_ticket) {
4446
5025
  if (is_psk) {
4447
- hints->ignore_psk = true;
5026
+ hs->pending_hints->ignore_psk = true;
4448
5027
  } else {
4449
- hints->ignore_ticket = true;
5028
+ hs->pending_hints->ignore_ticket = true;
4450
5029
  }
4451
5030
  } else if (result == ssl_ticket_aead_success) {
4452
5031
  if (is_psk) {
4453
- if (!hints->decrypted_psk.CopyFrom(plaintext)) {
5032
+ if (!hs->pending_hints->decrypted_psk.CopyFrom(plaintext)) {
4454
5033
  return ssl_ticket_aead_error;
4455
5034
  }
4456
5035
  } else {
4457
- if (!hints->decrypted_ticket.CopyFrom(plaintext)) {
5036
+ if (!hs->pending_hints->decrypted_ticket.CopyFrom(plaintext)) {
4458
5037
  return ssl_ticket_aead_error;
4459
5038
  }
4460
- hints->renew_ticket = *out_renew_ticket;
5039
+ hs->pending_hints->renew_ticket = *out_renew_ticket;
4461
5040
  }
4462
5041
  }
4463
5042
  }
@@ -4467,13 +5046,17 @@ enum ssl_ticket_aead_result_t ssl_process_ticket(
4467
5046
  }
4468
5047
 
4469
5048
  // Decode the session.
4470
- UniquePtr<SSL_SESSION> session(SSL_SESSION_from_bytes(
4471
- plaintext.data(), plaintext.size(), ssl->ctx.get()));
5049
+ UniquePtr<SSLSession> session(FromOpaque(SSL_SESSION_from_bytes(
5050
+ plaintext.data(), plaintext.size(), ssl->ctx.get())));
4472
5051
  if (!session) {
4473
5052
  ERR_clear_error(); // Don't leave an error on the queue.
4474
5053
  return ssl_ticket_aead_ignore_ticket;
4475
5054
  }
4476
5055
 
5056
+ if (save_ticket && !session->ticket.CopyFrom(ticket)) {
5057
+ return ssl_ticket_aead_error;
5058
+ }
5059
+
4477
5060
  // Envoy's tests expect the session to have a session ID that matches the
4478
5061
  // placeholder used by the client. It's unclear whether this is a good idea,
4479
5062
  // but we maintain it for now.
@@ -4510,9 +5093,8 @@ bool tls1_get_legacy_signature_algorithm(uint16_t *out, const EVP_PKEY *pkey) {
4510
5093
  }
4511
5094
 
4512
5095
  bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
4513
- const SSL_CREDENTIAL *cred,
4514
- uint16_t *out) {
4515
- SSL *const ssl = hs->ssl;
5096
+ const SSLCredential *cred, uint16_t *out) {
5097
+ SSLImpl *const ssl = hs->ssl;
4516
5098
  if (!cred->UsesPrivateKey()) {
4517
5099
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CERTIFICATE_TYPE);
4518
5100
  return false;
@@ -4545,7 +5127,8 @@ bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
4545
5127
  }
4546
5128
 
4547
5129
  Span<const uint16_t> sigalgs =
4548
- cred->sigalgs.empty() ? Span(kSignSignatureAlgorithms) : cred->sigalgs;
5130
+ cred->sigalgs.empty() ? Span<const uint16_t>(kSignSignatureAlgorithms)
5131
+ : Span<const uint16_t>(cred->sigalgs);
4549
5132
  for (uint16_t sigalg : sigalgs) {
4550
5133
  if (!ssl_pkey_supports_algorithm(ssl, cred->pubkey.get(), sigalg,
4551
5134
  /*is_verify=*/false)) {
@@ -4564,7 +5147,7 @@ bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs,
4564
5147
  }
4565
5148
 
4566
5149
  bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg) {
4567
- SSL *const ssl = hs->ssl;
5150
+ SSLImpl *const ssl = hs->ssl;
4568
5151
  // A Channel ID handshake message is structured to contain multiple
4569
5152
  // extensions, but the only one that can be present is Channel ID.
4570
5153
  uint16_t extension_type;
@@ -4587,10 +5170,10 @@ bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg) {
4587
5170
  }
4588
5171
 
4589
5172
  const uint8_t *p = CBS_data(&extension);
4590
- if (BN_bin2bn(p + 0, 32, x.get()) == NULL ||
4591
- BN_bin2bn(p + 32, 32, y.get()) == NULL ||
4592
- BN_bin2bn(p + 64, 32, sig->r) == NULL ||
4593
- BN_bin2bn(p + 96, 32, sig->s) == NULL) {
5173
+ if (BN_bin2bn(p + 0, 32, x.get()) == nullptr ||
5174
+ BN_bin2bn(p + 32, 32, y.get()) == nullptr ||
5175
+ BN_bin2bn(p + 64, 32, sig->r) == nullptr ||
5176
+ BN_bin2bn(p + 96, 32, sig->s) == nullptr) {
4594
5177
  return false;
4595
5178
  }
4596
5179
 
@@ -4667,7 +5250,7 @@ bool tls1_write_channel_id(SSL_HANDSHAKE *hs, CBB *cbb) {
4667
5250
  }
4668
5251
 
4669
5252
  bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len) {
4670
- SSL *const ssl = hs->ssl;
5253
+ SSLImpl *const ssl = hs->ssl;
4671
5254
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
4672
5255
  Array<uint8_t> msg;
4673
5256
  if (!tls13_get_cert_verify_signature_input(hs, &msg,
@@ -4685,7 +5268,7 @@ bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len) {
4685
5268
  static const char kClientIDMagic[] = "TLS Channel ID signature";
4686
5269
  SHA256_Update(&ctx, kClientIDMagic, sizeof(kClientIDMagic));
4687
5270
 
4688
- if (ssl->session != NULL) {
5271
+ if (ssl->session != nullptr) {
4689
5272
  static const char kResumptionMagic[] = "Resumption";
4690
5273
  SHA256_Update(&ctx, kResumptionMagic, sizeof(kResumptionMagic));
4691
5274
  if (ssl->session->original_handshake_hash.empty()) {
@@ -4708,11 +5291,11 @@ bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len) {
4708
5291
  }
4709
5292
 
4710
5293
  bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs) {
4711
- SSL *const ssl = hs->ssl;
5294
+ SSLImpl *const ssl = hs->ssl;
4712
5295
  // This function should never be called for a resumed session because the
4713
5296
  // handshake hashes that we wish to record are for the original, full
4714
5297
  // handshake.
4715
- if (ssl->session != NULL) {
5298
+ if (ssl->session != nullptr) {
4716
5299
  return false;
4717
5300
  }
4718
5301
 
@@ -4755,7 +5338,7 @@ using namespace bssl;
4755
5338
  int SSL_parse_client_hello(const SSL *ssl, SSL_CLIENT_HELLO *out,
4756
5339
  const uint8_t *in, size_t len) {
4757
5340
  CBS cbs = Span(in, len);
4758
- if (!ssl_parse_client_hello_with_trailing_data(ssl, &cbs, out)) {
5341
+ if (!ssl_parse_client_hello_with_trailing_data(FromOpaque(ssl), &cbs, out)) {
4759
5342
  return 0;
4760
5343
  }
4761
5344
  if (CBS_len(&cbs) != 0) {