grpc 1.85.0 → 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 (634) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +13 -9
  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/grpc.h +7 -0
  7. data/include/grpc/grpc_security_constants.h +2 -0
  8. data/include/grpc/module.modulemap +1 -0
  9. data/src/core/call/call_filters.cc +4 -1
  10. data/src/core/call/call_filters.h +3 -1
  11. data/src/core/call/call_spine.h +12 -6
  12. data/src/core/call/call_state.h +3 -3
  13. data/src/core/call/client_call.cc +4 -1
  14. data/src/core/call/client_call.h +1 -0
  15. data/src/core/call/evaluate_args.cc +15 -14
  16. data/src/core/call/filter_fusion.h +2 -15
  17. data/src/core/call/interception_chain.h +2 -7
  18. data/src/core/call/metadata_batch.cc +5 -0
  19. data/src/core/call/metadata_batch.h +34 -3
  20. data/src/core/call/request_buffer.cc +1 -1
  21. data/src/core/call/server_call.cc +3 -3
  22. data/src/core/call/server_call.h +15 -0
  23. data/src/core/channelz/channelz_registry.cc +4 -4
  24. data/src/core/channelz/ztrace_collector.h +11 -2
  25. data/src/core/client_channel/backup_poller.cc +1 -2
  26. data/src/core/client_channel/channel_factory.cc +110 -0
  27. data/src/core/client_channel/channel_factory.h +45 -0
  28. data/src/core/client_channel/global_subchannel_pool.cc +2 -2
  29. data/src/core/client_channel/lame_channel.cc +59 -0
  30. data/src/core/client_channel/lame_channel.h +86 -0
  31. data/src/core/credentials/call/external/aws_request_signer.cc +2 -1
  32. data/src/core/credentials/call/external/url_external_account_credentials.cc +6 -17
  33. data/src/core/credentials/call/external/url_external_account_credentials.h +0 -1
  34. data/src/core/credentials/call/jwt/jwt_verifier.cc +25 -13
  35. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +6 -4
  36. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +16 -0
  37. data/src/core/credentials/call/regional_access_boundary_fetcher.h +6 -2
  38. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc +14 -0
  39. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.h +12 -2
  40. data/src/core/credentials/transport/tls/ssl_utils.cc +20 -0
  41. data/src/core/credentials/transport/tls/ssl_utils.h +4 -0
  42. data/src/core/credentials/transport/tls/tls_security_connector.cc +6 -2
  43. data/src/core/ext/filters/http/server/http_server_filter.cc +6 -1
  44. data/src/core/ext/filters/rbac/rbac_filter.cc +3 -41
  45. data/src/core/ext/filters/rbac/rbac_filter.h +2 -11
  46. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -2
  47. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +31 -24
  48. data/src/core/ext/transport/chttp2/server/chttp2_server.h +1 -2
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +69 -102
  50. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -1
  51. data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -2
  52. data/src/core/ext/transport/chttp2/transport/flow_control_manager.h +1 -1
  53. data/src/core/ext/transport/chttp2/transport/frame.cc +15 -19
  54. data/src/core/ext/transport/chttp2/transport/frame.h +1 -1
  55. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +18 -61
  56. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +0 -4
  57. data/src/core/ext/transport/chttp2/transport/frame_security.cc +1 -2
  58. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +9 -0
  59. data/src/core/ext/transport/chttp2/transport/goaway.cc +1 -1
  60. data/src/core/ext/transport/chttp2/transport/goaway.h +0 -5
  61. data/src/core/ext/transport/chttp2/transport/header_assembler.h +1 -5
  62. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +3 -0
  63. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +8 -0
  64. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -0
  65. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +34 -19
  66. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +5 -2
  67. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +134 -82
  68. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +30 -15
  69. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +4 -3
  70. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +9 -33
  71. data/src/core/ext/transport/chttp2/transport/http2_transport.h +1 -6
  72. data/src/core/ext/transport/chttp2/transport/http2_transport_stats.h +60 -0
  73. data/src/core/ext/transport/chttp2/transport/internal.h +6 -1
  74. data/src/core/ext/transport/chttp2/transport/keepalive.h +1 -4
  75. data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -8
  76. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +35 -11
  77. data/src/core/ext/transport/chttp2/transport/ping_promise.h +52 -47
  78. data/src/core/ext/transport/chttp2/transport/read_context.h +19 -5
  79. data/src/core/ext/transport/chttp2/transport/security_frame.h +7 -6
  80. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +7 -5
  81. data/src/core/ext/transport/chttp2/transport/transport_common.cc +47 -0
  82. data/src/core/ext/transport/chttp2/transport/transport_common.h +29 -0
  83. data/src/core/ext/transport/chttp2/transport/writable_streams.h +1 -1
  84. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +1 -7
  85. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb.h +16 -0
  86. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb_minitable.c +4 -3
  87. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb.h +129 -81
  88. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb_minitable.c +50 -39
  89. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb.h +411 -163
  90. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.c +95 -44
  91. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.h +3 -0
  92. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb.h +41 -8
  93. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb_minitable.c +8 -5
  94. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb.h +427 -222
  95. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.c +97 -66
  96. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.h +1 -0
  97. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb.h +130 -99
  98. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb_minitable.c +29 -27
  99. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb.h +49 -33
  100. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb_minitable.c +19 -8
  101. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb.h +95 -3
  102. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.c +33 -6
  103. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.h +1 -0
  104. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb.h +93 -11
  105. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb_minitable.c +8 -5
  106. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb.h +656 -134
  107. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.c +117 -51
  108. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.h +2 -0
  109. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb.h +45 -23
  110. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb_minitable.c +19 -10
  111. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb.h +99 -34
  112. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb_minitable.c +12 -7
  113. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb.h +344 -273
  114. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.c +62 -69
  115. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.h +1 -3
  116. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb.h +53 -22
  117. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb_minitable.c +9 -7
  118. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb.h +108 -0
  119. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.c +26 -2
  120. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.h +1 -0
  121. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb.h +809 -231
  122. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.c +183 -77
  123. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.h +3 -0
  124. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb.h +151 -26
  125. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb_minitable.c +17 -9
  126. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb.h +24 -8
  127. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb_minitable.c +6 -5
  128. data/src/core/ext/upb-gen/envoy/data/accesslog/v3/accesslog.upb.h +2 -1
  129. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb.h +224 -16
  130. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.c +83 -10
  131. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.h +2 -0
  132. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +95 -79
  133. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +23 -22
  134. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb.h +34 -18
  135. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb_minitable.c +10 -9
  136. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h +243 -2
  137. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.c +53 -5
  138. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.h +3 -0
  139. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb.h +53 -22
  140. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb_minitable.c +9 -7
  141. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.h +23 -7
  142. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb_minitable.c +9 -4
  143. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +516 -215
  144. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.c +99 -60
  145. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.h +1 -0
  146. 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
  147. 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
  148. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb.h +109 -0
  149. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.c +32 -2
  150. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.h +1 -0
  151. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb.h +37 -4
  152. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb_minitable.c +7 -4
  153. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb.h +65 -47
  154. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb_minitable.c +29 -12
  155. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +20 -4
  156. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb_minitable.c +6 -3
  157. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +776 -88
  158. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +195 -35
  159. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +5 -0
  160. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb.h +23 -7
  161. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb_minitable.c +10 -3
  162. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb.h +44 -0
  163. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.c +11 -2
  164. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.h +1 -0
  165. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb.h +218 -0
  166. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.c +70 -0
  167. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.h +31 -0
  168. data/src/core/ext/upbdefs-gen/envoy/admin/v3/clusters.upbdefs.c +30 -24
  169. data/src/core/ext/upbdefs-gen/envoy/admin/v3/server_info.upbdefs.c +166 -152
  170. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +467 -422
  171. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +15 -0
  172. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +120 -110
  173. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.c +912 -857
  174. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.h +5 -0
  175. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/outlier_detection.upbdefs.c +26 -19
  176. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/address.upbdefs.c +59 -54
  177. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.c +356 -346
  178. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.h +5 -0
  179. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/http_service.upbdefs.c +49 -37
  180. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.c +599 -483
  181. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.h +10 -0
  182. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_option.upbdefs.c +65 -49
  183. data/src/core/ext/upbdefs-gen/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +165 -161
  184. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.c +369 -327
  185. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.h +5 -15
  186. data/src/core/ext/upbdefs-gen/envoy/config/metrics/v3/stats.upbdefs.c +129 -121
  187. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.c +224 -204
  188. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.h +5 -0
  189. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.c +2046 -1932
  190. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.h +15 -0
  191. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/opentelemetry.upbdefs.c +70 -37
  192. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/zipkin.upbdefs.c +7 -3
  193. data/src/core/ext/upbdefs-gen/envoy/data/accesslog/v3/accesslog.upbdefs.c +5 -3
  194. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.c +121 -78
  195. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.h +10 -0
  196. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +165 -160
  197. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +121 -118
  198. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.c +68 -37
  199. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.h +15 -0
  200. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/router/v3/router.upbdefs.c +48 -40
  201. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.c +44 -37
  202. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +919 -870
  203. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
  204. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upbdefs.c +26 -14
  205. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +44 -36
  206. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +372 -371
  207. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c +32 -28
  208. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/address.upbdefs.c +17 -15
  209. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.c +4 -1
  210. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.h +5 -0
  211. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.c +76 -0
  212. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.h +37 -0
  213. data/src/core/ext/upbdefs-gen/envoy/type/v3/token_bucket.upbdefs.c +1 -1
  214. data/src/core/filter/ext_proc/ext_proc_filter.cc +537 -259
  215. data/src/core/filter/ext_proc/ext_proc_filter.h +47 -14
  216. data/src/core/filter/ext_proc/ext_proc_messages.cc +38 -17
  217. data/src/core/filter/ext_proc/ext_proc_messages.h +19 -7
  218. data/src/core/filter/filter_args.h +5 -60
  219. data/src/core/handshaker/http_connect/http_connect_client_handshaker.cc +1 -1
  220. data/src/core/handshaker/security/pipelined_secure_endpoint.cc +23 -22
  221. data/src/core/handshaker/security/secure_endpoint.cc +16 -16
  222. data/src/core/lib/channel/channel_stack.cc +0 -12
  223. data/src/core/lib/channel/channel_stack.h +0 -8
  224. data/src/core/lib/channel/promise_based_filter.cc +57 -44
  225. data/src/core/lib/channel/promise_based_filter.h +29 -41
  226. data/src/core/lib/event_engine/ares_resolver.cc +10 -4
  227. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +1 -1
  228. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +3 -3
  229. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -5
  230. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +10 -12
  231. data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +3 -17
  232. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +21 -1
  233. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +5 -5
  234. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +10 -12
  235. data/src/core/lib/event_engine/posix_engine/posix_interface.h +1 -1
  236. data/src/core/lib/event_engine/posix_engine/timer.cc +2 -2
  237. data/src/core/lib/event_engine/shim.cc +1 -6
  238. data/src/core/lib/event_engine/shim.h +0 -5
  239. data/src/core/lib/event_engine/windows/windows_engine.cc +4 -4
  240. data/src/core/lib/event_engine/windows/windows_listener.cc +1 -1
  241. data/src/core/lib/experiments/experiments.cc +144 -261
  242. data/src/core/lib/experiments/experiments.h +48 -120
  243. data/src/core/lib/iomgr/iomgr_windows.cc +1 -6
  244. data/src/core/lib/iomgr/tcp_posix.cc +21 -21
  245. data/src/core/lib/iomgr/tcp_server_posix.cc +64 -242
  246. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -469
  247. data/src/core/lib/promise/activity.cc +8 -8
  248. data/src/core/lib/promise/activity.h +5 -5
  249. data/src/core/lib/promise/inter_activity_pipe.h +3 -3
  250. data/src/core/lib/promise/party.cc +5 -5
  251. data/src/core/lib/promise/status_flag.h +7 -2
  252. data/src/core/lib/resource_quota/memory_quota.cc +2 -2
  253. data/src/core/lib/security/authorization/rbac_policy.h +2 -2
  254. data/src/core/lib/surface/call.cc +13 -3
  255. data/src/core/lib/surface/call.h +23 -6
  256. data/src/core/lib/surface/channel_create.cc +7 -1
  257. data/src/core/lib/surface/channel_init.h +1 -8
  258. data/src/core/lib/surface/filter_stack_call.cc +16 -0
  259. data/src/core/lib/surface/filter_stack_call.h +1 -0
  260. data/src/core/lib/surface/init.cc +3 -3
  261. data/src/core/lib/surface/legacy_channel.cc +4 -1
  262. data/src/core/lib/surface/version.cc +2 -2
  263. data/src/core/lib/transport/transport.cc +15 -8
  264. data/src/core/lib/transport/transport_framing_endpoint_extension.h +8 -2
  265. data/src/core/load_balancing/outlier_detection/outlier_detection.cc +99 -8
  266. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.cc +38 -0
  267. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.h +55 -0
  268. data/src/core/load_balancing/ring_hash/ring_hash.cc +2 -1
  269. data/src/core/load_balancing/rls/rls.cc +21 -1
  270. data/src/core/load_balancing/xds/cds.cc +4 -51
  271. data/src/core/plugin_registry/grpc_plugin_registry.cc +10 -13
  272. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +0 -7
  273. data/src/core/resolver/xds/xds_resolver.cc +1 -1
  274. data/src/core/server/server.cc +60 -4
  275. data/src/core/server/server_config_selector.h +4 -18
  276. data/src/core/server/server_config_selector_filter.cc +20 -146
  277. data/src/core/server/server_config_selector_filter.h +2 -2
  278. data/src/core/server/xds_server_config_fetcher.cc +5 -20
  279. data/src/core/transport/auth_context.cc +15 -5
  280. data/src/core/transport/auth_context.h +5 -0
  281. data/src/core/tsi/ssl_telemetry_utils.cc +9 -1
  282. data/src/core/tsi/ssl_transport_security.cc +158 -52
  283. data/src/core/tsi/ssl_transport_security.h +18 -2
  284. data/src/core/tsi/ssl_transport_security_utils.cc +123 -12
  285. data/src/core/tsi/ssl_transport_security_utils.h +19 -0
  286. data/src/core/util/latent_see.cc +65 -3
  287. data/src/core/util/latent_see.h +57 -12
  288. data/src/core/util/linux/cpu.cc +12 -6
  289. data/src/core/util/mpscq.cc +2 -2
  290. data/src/core/util/sync_abseil.cc +3 -3
  291. data/src/core/util/trie_lookup.h +5 -1
  292. data/src/core/util/windows/env.cc +1 -0
  293. data/src/core/util/work_serializer.cc +1 -1
  294. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +10 -9
  295. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +3 -3
  296. data/src/core/xds/grpc/streaming_call_promise_wrapper.cc +5 -2
  297. data/src/core/xds/grpc/streaming_call_promise_wrapper.h +2 -5
  298. data/src/core/xds/grpc/xds_audit_logger_registry.cc +0 -54
  299. data/src/core/xds/grpc/xds_audit_logger_registry.h +0 -8
  300. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +2 -28
  301. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +0 -20
  302. data/src/core/xds/grpc/xds_client_grpc.cc +4 -4
  303. data/src/core/xds/grpc/xds_client_grpc.h +1 -1
  304. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -1
  305. data/src/core/xds/grpc/xds_common_types_parser.cc +12 -0
  306. data/src/core/xds/grpc/xds_endpoint_parser.cc +3 -3
  307. data/src/core/xds/grpc/xds_http_composite_filter.cc +0 -5
  308. data/src/core/xds/grpc/xds_http_composite_filter.h +1 -27
  309. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +1 -5
  310. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +3 -29
  311. data/src/core/xds/grpc/xds_http_fault_filter.cc +0 -4
  312. data/src/core/xds/grpc/xds_http_fault_filter.h +0 -26
  313. data/src/core/xds/grpc/xds_http_filter.h +1 -63
  314. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +0 -5
  315. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +1 -27
  316. data/src/core/xds/grpc/xds_http_rbac_filter.cc +0 -527
  317. data/src/core/xds/grpc/xds_http_rbac_filter.h +0 -15
  318. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +0 -5
  319. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +0 -26
  320. data/src/core/xds/grpc/xds_listener.cc +0 -2
  321. data/src/core/xds/grpc/xds_listener.h +0 -2
  322. data/src/core/xds/grpc/xds_listener_parser.cc +0 -7
  323. data/src/core/xds/grpc/xds_matcher.cc +17 -11
  324. data/src/core/xds/grpc/xds_matcher.h +2 -1
  325. data/src/core/xds/grpc/xds_matcher_context.cc +11 -0
  326. data/src/core/xds/grpc/xds_matcher_context.h +3 -2
  327. data/src/core/xds/grpc/xds_matcher_input.cc +19 -1
  328. data/src/core/xds/grpc/xds_matcher_parse.cc +3 -2
  329. data/src/core/xds/grpc/xds_route_config.cc +0 -2
  330. data/src/core/xds/grpc/xds_route_config.h +0 -2
  331. data/src/core/xds/grpc/xds_route_config_parser.cc +0 -5
  332. data/src/core/xds/grpc/xds_routing.cc +22 -112
  333. data/src/core/xds/grpc/xds_routing.h +2 -27
  334. data/src/core/xds/grpc/xds_transport_factory_grpc.cc +236 -0
  335. data/src/core/xds/grpc/xds_transport_factory_grpc.h +95 -0
  336. data/src/core/xds/grpc/xds_transport_grpc.cc +78 -241
  337. data/src/core/xds/grpc/xds_transport_grpc.h +41 -51
  338. data/src/core/xds/xds_client/lrs_client.cc +3 -5
  339. data/src/core/xds/xds_client/lrs_client.h +2 -1
  340. data/src/core/xds/xds_client/xds_client.cc +36 -23
  341. data/src/core/xds/xds_client/xds_client.h +6 -5
  342. data/src/core/xds/xds_client/xds_transport.h +110 -108
  343. data/src/core/xds/xds_client/xds_transport_factory.h +43 -0
  344. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  345. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  346. data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
  347. data/src/ruby/lib/grpc/version.rb +1 -1
  348. data/third_party/boringssl-with-bazel/crypto/asn1/a_type.cc +54 -19
  349. data/third_party/boringssl-with-bazel/crypto/asn1/asn1_lib.cc +1 -1
  350. data/third_party/boringssl-with-bazel/crypto/asn1/internal.h +58 -12
  351. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_dec.cc +13 -13
  352. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_enc.cc +13 -11
  353. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_fre.cc +14 -18
  354. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_new.cc +31 -35
  355. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_typ.cc +0 -2
  356. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_utl.cc +17 -24
  357. data/third_party/boringssl-with-bazel/crypto/bio/bio.cc +0 -1
  358. data/third_party/boringssl-with-bazel/crypto/bio/bio_mem.cc +9 -3
  359. data/third_party/boringssl-with-bazel/crypto/bio/connect.cc +3 -3
  360. data/third_party/boringssl-with-bazel/crypto/bio/fd.cc +0 -1
  361. data/third_party/boringssl-with-bazel/crypto/bio/file.cc +0 -1
  362. data/third_party/boringssl-with-bazel/crypto/bio/internal.h +2 -3
  363. data/third_party/boringssl-with-bazel/crypto/bio/pair.cc +0 -1
  364. data/third_party/boringssl-with-bazel/crypto/bio/socket.cc +1 -1
  365. data/third_party/boringssl-with-bazel/crypto/bytestring/cbb.cc +70 -45
  366. data/third_party/boringssl-with-bazel/crypto/bytestring/cbs.cc +15 -34
  367. data/third_party/boringssl-with-bazel/crypto/bytestring/internal.h +5 -0
  368. data/third_party/boringssl-with-bazel/crypto/cipher/e_aesgcmsiv.cc +20 -165
  369. data/third_party/boringssl-with-bazel/crypto/cipher/e_tls.cc +7 -4
  370. data/third_party/boringssl-with-bazel/crypto/cipher/internal.h +159 -0
  371. data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519.cc +295 -16
  372. data/third_party/boringssl-with-bazel/crypto/curve25519/internal.h +25 -14
  373. data/third_party/boringssl-with-bazel/crypto/dh/params.cc +1 -1
  374. data/third_party/boringssl-with-bazel/crypto/ec/hash_to_curve.cc +208 -36
  375. data/third_party/boringssl-with-bazel/crypto/err/err.cc +3 -2
  376. data/third_party/boringssl-with-bazel/crypto/evp/evp.cc +3 -0
  377. data/third_party/boringssl-with-bazel/crypto/evp/evp_kem.cc +25 -6
  378. data/third_party/boringssl-with-bazel/crypto/evp/internal.h +15 -11
  379. data/third_party/boringssl-with-bazel/crypto/evp/p_ec.cc +121 -0
  380. data/third_party/boringssl-with-bazel/crypto/evp/p_mlkem.cc +34 -9
  381. data/third_party/boringssl-with-bazel/crypto/evp/p_rsa.cc +76 -8
  382. data/third_party/boringssl-with-bazel/crypto/evp/p_xwing.cc +47 -20
  383. data/third_party/boringssl-with-bazel/crypto/ex_data.cc +1 -1
  384. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes_nohw.cc.inc +1 -1
  385. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm.cc.inc +2 -2
  386. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm.cc +1 -0
  387. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/add.cc.inc +9 -4
  388. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +4 -4
  389. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/exponentiation.cc.inc +2 -2
  390. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/internal.h +12 -6
  391. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/jacobi.cc.inc +1 -1
  392. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery_inv.cc.inc +4 -4
  393. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/prime.cc.inc +3 -3
  394. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.cc.inc +6 -6
  395. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/sqrt.cc.inc +21 -21
  396. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/aead.cc.inc +4 -2
  397. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/cipher.cc.inc +97 -132
  398. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/internal.h +7 -6
  399. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/dh.cc.inc +3 -3
  400. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/internal.h +1 -1
  401. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec.cc.inc +77 -17
  402. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_montgomery.cc.inc +13 -13
  403. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/felem.cc.inc +117 -34
  404. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/internal.h +67 -18
  405. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/oct.cc.inc +29 -151
  406. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.cc.inc +740 -0
  407. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.h +207 -0
  408. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256.cc.inc +407 -519
  409. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple.cc.inc +27 -28
  410. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +1 -1
  411. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/jitter.cc.inc +1 -1
  412. data/third_party/boringssl-with-bazel/crypto/fipsmodule/fips_shared_support.cc +4 -4
  413. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/internal.h +70 -1
  414. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/keccak.cc.inc +292 -52
  415. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/mldsa.cc.inc +226 -69
  416. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/mlkem.cc.inc +238 -83
  417. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa_impl.cc.inc +6 -6
  418. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha1.cc.inc +2 -2
  419. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.cc.inc +1 -1
  420. data/third_party/boringssl-with-bazel/crypto/hpke/hpke.cc +327 -272
  421. data/third_party/boringssl-with-bazel/crypto/hrss/hrss.cc +14 -14
  422. data/third_party/boringssl-with-bazel/crypto/internal.h +63 -0
  423. data/third_party/boringssl-with-bazel/crypto/mem_internal.h +38 -3
  424. data/third_party/boringssl-with-bazel/crypto/obj/obj_dat.h +97 -1
  425. data/third_party/boringssl-with-bazel/crypto/pem/internal.h +86 -0
  426. data/third_party/boringssl-with-bazel/crypto/pem/pem_all.cc +8 -5
  427. data/third_party/boringssl-with-bazel/crypto/pem/pem_lib.cc +41 -73
  428. data/third_party/boringssl-with-bazel/crypto/pem/pem_pk8.cc +3 -0
  429. data/third_party/boringssl-with-bazel/crypto/pem/pem_pkey.cc +10 -4
  430. data/third_party/boringssl-with-bazel/crypto/pem/pem_x509.cc +3 -0
  431. data/third_party/boringssl-with-bazel/crypto/pem/pem_xaux.cc +3 -0
  432. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7.cc +1 -1
  433. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7_x509.cc +2 -2
  434. data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8_x509.cc +1 -1
  435. data/third_party/boringssl-with-bazel/crypto/poly1305/internal.h +17 -0
  436. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_arm.cc +1 -13
  437. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_vec.cc +3 -3
  438. data/third_party/boringssl-with-bazel/crypto/slhdsa/slhdsa.cc +23 -6
  439. data/third_party/boringssl-with-bazel/crypto/stack/stack.cc +7 -0
  440. data/third_party/boringssl-with-bazel/crypto/trust_token/internal.h +1 -1
  441. data/third_party/boringssl-with-bazel/crypto/x509/a_verify.cc +14 -7
  442. data/third_party/boringssl-with-bazel/crypto/x509/internal.h +110 -76
  443. data/third_party/boringssl-with-bazel/crypto/x509/name_print.cc +1 -1
  444. data/third_party/boringssl-with-bazel/crypto/x509/rsa_pss.cc +1 -1
  445. data/third_party/boringssl-with-bazel/crypto/x509/t_req.cc +1 -1
  446. data/third_party/boringssl-with-bazel/crypto/x509/t_x509.cc +6 -5
  447. data/third_party/boringssl-with-bazel/crypto/x509/v3_crld.cc +11 -53
  448. data/third_party/boringssl-with-bazel/crypto/x509/v3_ncons.cc +5 -5
  449. data/third_party/boringssl-with-bazel/crypto/x509/v3_purp.cc +16 -39
  450. data/third_party/boringssl-with-bazel/crypto/x509/v3_skey.cc +1 -1
  451. data/third_party/boringssl-with-bazel/crypto/x509/v3_utl.cc +12 -16
  452. data/third_party/boringssl-with-bazel/crypto/x509/x509_cmp.cc +9 -11
  453. data/third_party/boringssl-with-bazel/crypto/x509/x509_mtc.cc +598 -0
  454. data/third_party/boringssl-with-bazel/crypto/x509/x509_obj.cc +9 -8
  455. data/third_party/boringssl-with-bazel/crypto/x509/x509_set.cc +14 -18
  456. data/third_party/boringssl-with-bazel/crypto/x509/x509_vfy.cc +315 -390
  457. data/third_party/boringssl-with-bazel/crypto/x509/x509_vpm.cc +1 -1
  458. data/third_party/boringssl-with-bazel/crypto/x509/x509name.cc +31 -29
  459. data/third_party/boringssl-with-bazel/crypto/x509/x_all.cc +10 -9
  460. data/third_party/boringssl-with-bazel/crypto/x509/x_crl.cc +3 -53
  461. data/third_party/boringssl-with-bazel/crypto/x509/x_name.cc +37 -59
  462. data/third_party/boringssl-with-bazel/crypto/x509/x_pubkey.cc +29 -47
  463. data/third_party/boringssl-with-bazel/crypto/x509/x_req.cc +2 -1
  464. data/third_party/boringssl-with-bazel/crypto/x509/x_x509.cc +53 -53
  465. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +24 -0
  466. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +24 -0
  467. data/third_party/boringssl-with-bazel/gen/crypto/err_data.cc +509 -497
  468. data/third_party/boringssl-with-bazel/include/openssl/aead.h +7 -19
  469. data/third_party/boringssl-with-bazel/include/openssl/asm_base.h +1 -1
  470. data/third_party/boringssl-with-bazel/include/openssl/asn1.h +6 -10
  471. data/third_party/boringssl-with-bazel/include/openssl/base.h +43 -16
  472. data/third_party/boringssl-with-bazel/include/openssl/bio.h +25 -10
  473. data/third_party/boringssl-with-bazel/include/openssl/bytestring.h +33 -1
  474. data/third_party/boringssl-with-bazel/include/openssl/cipher.h +11 -9
  475. data/third_party/boringssl-with-bazel/include/openssl/configuration.h +18 -0
  476. data/third_party/boringssl-with-bazel/include/openssl/curve25519.h +36 -0
  477. data/third_party/boringssl-with-bazel/include/openssl/digest.h +4 -4
  478. data/third_party/boringssl-with-bazel/include/openssl/ec.h +35 -1
  479. data/third_party/boringssl-with-bazel/include/openssl/ec_key.h +2 -2
  480. data/third_party/boringssl-with-bazel/include/openssl/evp.h +120 -3
  481. data/third_party/boringssl-with-bazel/include/openssl/evp_errors.h +1 -0
  482. data/third_party/boringssl-with-bazel/include/openssl/hmac.h +2 -2
  483. data/third_party/boringssl-with-bazel/include/openssl/hpke.h +38 -7
  484. data/third_party/boringssl-with-bazel/include/openssl/mem.h +5 -5
  485. data/third_party/boringssl-with-bazel/include/openssl/nid.h +42 -0
  486. data/third_party/boringssl-with-bazel/include/openssl/pem.h +650 -351
  487. data/third_party/boringssl-with-bazel/include/openssl/posix_time.h +4 -4
  488. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols.h +130 -4
  489. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_S.h +48 -0
  490. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_c.h +24 -0
  491. data/third_party/boringssl-with-bazel/include/openssl/rsa.h +1 -1
  492. data/third_party/boringssl-with-bazel/include/openssl/slhdsa.h +25 -1
  493. data/third_party/boringssl-with-bazel/include/openssl/ssl.h +256 -87
  494. data/third_party/boringssl-with-bazel/include/openssl/stack.h +9 -0
  495. data/third_party/boringssl-with-bazel/include/openssl/types.h +18 -0
  496. data/third_party/boringssl-with-bazel/include/openssl/x509.h +40 -21
  497. data/third_party/boringssl-with-bazel/ssl/bio_ssl.cc +3 -5
  498. data/third_party/boringssl-with-bazel/ssl/d1_both.cc +146 -81
  499. data/third_party/boringssl-with-bazel/ssl/d1_lib.cc +39 -34
  500. data/third_party/boringssl-with-bazel/ssl/d1_pkt.cc +6 -6
  501. data/third_party/boringssl-with-bazel/ssl/d1_srtp.cc +10 -8
  502. data/third_party/boringssl-with-bazel/ssl/dtls_method.cc +4 -4
  503. data/third_party/boringssl-with-bazel/ssl/dtls_record.cc +15 -14
  504. data/third_party/boringssl-with-bazel/ssl/encrypted_client_hello.cc +41 -25
  505. data/third_party/boringssl-with-bazel/ssl/extensions.cc +153 -171
  506. data/third_party/boringssl-with-bazel/ssl/handoff.cc +79 -64
  507. data/third_party/boringssl-with-bazel/ssl/handshake.cc +15 -16
  508. data/third_party/boringssl-with-bazel/ssl/handshake_client.cc +35 -78
  509. data/third_party/boringssl-with-bazel/ssl/handshake_server.cc +75 -155
  510. data/third_party/boringssl-with-bazel/ssl/internal.h +419 -308
  511. data/third_party/boringssl-with-bazel/ssl/s3_both.cc +17 -150
  512. data/third_party/boringssl-with-bazel/ssl/s3_lib.cc +2 -3
  513. data/third_party/boringssl-with-bazel/ssl/s3_pkt.cc +10 -9
  514. data/third_party/boringssl-with-bazel/ssl/ssl_asn1.cc +13 -13
  515. data/third_party/boringssl-with-bazel/ssl/ssl_buffer.cc +8 -8
  516. data/third_party/boringssl-with-bazel/ssl/ssl_cert.cc +58 -24
  517. data/third_party/boringssl-with-bazel/ssl/ssl_cipher.cc +198 -26
  518. data/third_party/boringssl-with-bazel/ssl/ssl_credential.cc +164 -37
  519. data/third_party/boringssl-with-bazel/ssl/ssl_file.cc +10 -8
  520. data/third_party/boringssl-with-bazel/ssl/ssl_key_share.cc +2 -95
  521. data/third_party/boringssl-with-bazel/ssl/ssl_lib.cc +785 -472
  522. data/third_party/boringssl-with-bazel/ssl/ssl_privkey.cc +78 -67
  523. data/third_party/boringssl-with-bazel/ssl/ssl_session.cc +187 -150
  524. data/third_party/boringssl-with-bazel/ssl/ssl_stat.cc +6 -3
  525. data/third_party/boringssl-with-bazel/ssl/ssl_transcript.cc +1 -1
  526. data/third_party/boringssl-with-bazel/ssl/ssl_versions.cc +25 -19
  527. data/third_party/boringssl-with-bazel/ssl/ssl_x509.cc +148 -114
  528. data/third_party/boringssl-with-bazel/ssl/t1_enc.cc +28 -19
  529. data/third_party/boringssl-with-bazel/ssl/tls13_both.cc +24 -22
  530. data/third_party/boringssl-with-bazel/ssl/tls13_client.cc +30 -30
  531. data/third_party/boringssl-with-bazel/ssl/tls13_enc.cc +17 -16
  532. data/third_party/boringssl-with-bazel/ssl/tls13_server.cc +55 -63
  533. data/third_party/boringssl-with-bazel/ssl/tls_method.cc +12 -12
  534. data/third_party/boringssl-with-bazel/ssl/tls_record.cc +23 -20
  535. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64.h +38 -0
  536. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64_msvc.h +2 -0
  537. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field.c.inc +26 -0
  538. data/third_party/boringssl-with-bazel/third_party/fiat/p256_point.br.c.inc +0 -54
  539. data/third_party/cares/cares/include/ares.h +8 -0
  540. data/third_party/cares/cares/include/ares_dns_record.h +3 -2
  541. data/third_party/cares/cares/include/ares_version.h +3 -3
  542. data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +20 -20
  543. data/third_party/cares/cares/src/lib/ares_cancel.c +17 -8
  544. data/third_party/cares/cares/src/lib/ares_close_sockets.c +81 -16
  545. data/third_party/cares/cares/src/lib/ares_conn.c +256 -10
  546. data/third_party/cares/cares/src/lib/ares_conn.h +40 -3
  547. data/third_party/cares/cares/src/lib/ares_cookie.c +2 -2
  548. data/third_party/cares/cares/src/lib/ares_destroy.c +75 -10
  549. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +85 -10
  550. data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +5 -0
  551. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +4 -0
  552. data/third_party/cares/cares/src/lib/ares_getnameinfo.c +10 -2
  553. data/third_party/cares/cares/src/lib/ares_hosts_file.c +8 -0
  554. data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +28 -0
  555. data/third_party/cares/cares/src/lib/ares_init.c +55 -10
  556. data/third_party/cares/cares/src/lib/ares_library_init.c +25 -7
  557. data/third_party/cares/cares/src/lib/ares_options.c +38 -10
  558. data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +1 -1
  559. data/third_party/cares/cares/src/lib/ares_private.h +186 -27
  560. data/third_party/cares/cares/src/lib/ares_process.c +604 -112
  561. data/third_party/cares/cares/src/lib/ares_qcache.c +200 -36
  562. data/third_party/cares/cares/src/lib/ares_query.c +5 -0
  563. data/third_party/cares/cares/src/lib/ares_search.c +10 -0
  564. data/third_party/cares/cares/src/lib/ares_send.c +81 -10
  565. data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +3 -1
  566. data/third_party/cares/cares/src/lib/ares_socket.c +28 -0
  567. data/third_party/cares/cares/src/lib/ares_socket.h +23 -0
  568. data/third_party/cares/cares/src/lib/ares_sysconfig.c +6 -3
  569. data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +33 -11
  570. data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +132 -80
  571. data/third_party/cares/cares/src/lib/ares_timeout.c +11 -0
  572. data/third_party/cares/cares/src/lib/ares_update_servers.c +55 -11
  573. data/third_party/cares/cares/src/lib/dsa/ares_array.c +20 -5
  574. data/third_party/cares/cares/src/lib/dsa/ares_htable.c +8 -4
  575. data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +2 -0
  576. data/third_party/cares/cares/src/lib/dsa/ares_llist.c +4 -1
  577. data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +5 -2
  578. data/third_party/cares/cares/src/lib/event/ares_event_select.c +14 -1
  579. data/third_party/cares/cares/src/lib/event/ares_event_thread.c +8 -0
  580. data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +7 -1
  581. data/third_party/cares/cares/src/lib/event/ares_event_win32.c +3 -0
  582. data/third_party/cares/cares/src/lib/include/ares_mem.h +3 -0
  583. data/third_party/cares/cares/src/lib/include/ares_str.h +17 -0
  584. data/third_party/cares/cares/src/lib/inet_net_pton.c +37 -28
  585. data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +1 -1
  586. data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +5 -2
  587. data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +5 -2
  588. data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +2 -2
  589. data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +2 -2
  590. data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +1 -1
  591. data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +19 -4
  592. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +3 -1
  593. data/third_party/cares/cares/src/lib/record/ares_dns_name.c +67 -4
  594. data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +62 -34
  595. data/third_party/cares/cares/src/lib/record/ares_dns_private.h +4 -0
  596. data/third_party/cares/cares/src/lib/record/ares_dns_record.c +47 -7
  597. data/third_party/cares/cares/src/lib/record/ares_dns_write.c +13 -5
  598. data/third_party/cares/cares/src/lib/str/ares_buf.c +33 -16
  599. data/third_party/cares/cares/src/lib/str/ares_str.c +54 -0
  600. data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +22 -10
  601. data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +1 -0
  602. data/third_party/cares/cares/src/lib/util/ares_math.c +17 -2
  603. data/third_party/cares/cares/src/lib/util/ares_math.h +32 -7
  604. data/third_party/cares/cares/src/lib/util/ares_rand.c +4 -4
  605. data/third_party/cares/cares/src/lib/util/ares_threads.c +1 -2
  606. data/third_party/cares/cares/src/lib/util/ares_time.h +1 -0
  607. data/third_party/cares/cares/src/lib/util/ares_uri.c +9 -3
  608. data/third_party/zlib/compress.c +34 -10
  609. data/third_party/zlib/crc32.c +49 -115
  610. data/third_party/zlib/deflate.c +107 -61
  611. data/third_party/zlib/deflate.h +7 -1
  612. data/third_party/zlib/gzguts.h +33 -31
  613. data/third_party/zlib/infback.c +20 -67
  614. data/third_party/zlib/inffast.c +7 -6
  615. data/third_party/zlib/inffixed.h +91 -91
  616. data/third_party/zlib/inflate.c +38 -151
  617. data/third_party/zlib/inflate.h +1 -1
  618. data/third_party/zlib/inftrees.c +134 -9
  619. data/third_party/zlib/inftrees.h +3 -1
  620. data/third_party/zlib/trees.c +14 -12
  621. data/third_party/zlib/uncompr.c +39 -23
  622. data/third_party/zlib/zconf.h +27 -19
  623. data/third_party/zlib/zlib.h +215 -96
  624. data/third_party/zlib/zutil.c +49 -35
  625. data/third_party/zlib/zutil.h +87 -10
  626. metadata +4095 -4049
  627. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +0 -916
  628. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +0 -84
  629. data/src/core/server/xds_channel_stack_modifier.cc +0 -108
  630. data/src/core/server/xds_channel_stack_modifier.h +0 -62
  631. data/src/core/server/xds_server_config_fetcher_legacy.cc +0 -1340
  632. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256_internal.h +0 -193
  633. data/third_party/boringssl-with-bazel/crypto/kyber/internal.h +0 -165
  634. data/third_party/boringssl-with-bazel/crypto/kyber/kyber.cc +0 -870
@@ -24,12 +24,10 @@
24
24
  #include <algorithm>
25
25
  #include <atomic>
26
26
  #include <bitset>
27
+ #include <cstdint>
27
28
  #include <initializer_list>
28
- #include <limits>
29
- #include <new>
30
29
  #include <optional>
31
30
  #include <string_view>
32
- #include <type_traits>
33
31
  #include <utility>
34
32
  #include <variant>
35
33
 
@@ -58,6 +56,8 @@
58
56
 
59
57
  DECLARE_OPAQUE_STRUCT(ssl_credential_st, SSLCredential)
60
58
  DECLARE_OPAQUE_STRUCT(ssl_ctx_st, SSLContext)
59
+ DECLARE_OPAQUE_STRUCT(ssl_st, SSLImpl)
60
+ DECLARE_OPAQUE_STRUCT(ssl_session_st, SSLSession)
61
61
  DECLARE_OPAQUE_STRUCT(ssl_ech_keys_st, SSLECHKeys)
62
62
 
63
63
  BSSL_NAMESPACE_BEGIN
@@ -186,11 +186,11 @@ bool ssl_negotiate_version(SSL_HANDSHAKE *hs, uint8_t *out_alert,
186
186
  // ssl_has_final_version returns whether `ssl` has determined the final version.
187
187
  // This may be used to distinguish the predictive 0-RTT version from the final
188
188
  // one.
189
- bool ssl_has_final_version(const SSL *ssl);
189
+ bool ssl_has_final_version(const SSLImpl *ssl);
190
190
 
191
191
  // ssl_protocol_version returns `ssl`'s protocol version. It is an error to
192
192
  // call this function before the version is determined.
193
- uint16_t ssl_protocol_version(const SSL *ssl);
193
+ uint16_t ssl_protocol_version(const SSLImpl *ssl);
194
194
 
195
195
  // Cipher suites.
196
196
 
@@ -285,20 +285,61 @@ BSSL_NAMESPACE_BEGIN
285
285
  // A E
286
286
  // B -> D -> F
287
287
  // C
288
- struct SSLCipherPreferenceList {
288
+ class SSLCipherPreferenceList {
289
+ public:
289
290
  static constexpr bool kAllowUniquePtr = true;
290
291
 
291
292
  SSLCipherPreferenceList() = default;
292
- ~SSLCipherPreferenceList();
293
+ ~SSLCipherPreferenceList() = default;
293
294
 
295
+ // Initializes a list with the specified ciphers and flags. Calling Init on a
296
+ // previously initialized list discards the previous contents.
294
297
  bool Init(UniquePtr<STACK_OF(SSL_CIPHER)> ciphers,
295
- Span<const bool> in_group_flags);
296
- bool Init(const SSLCipherPreferenceList &);
298
+ Array<bool> in_group_flags);
299
+ // Same as above, but takes a list of cipher protocol IDs.
300
+ bool Init(Span<const uint16_t> cipher_ids, Span<const bool> in_group_flags);
301
+
302
+ // Reset clears any contents previously set by `Init`.
303
+ void Reset();
297
304
 
305
+ // Makes `this` a deep copy of another (already initialized) instance.
306
+ bool CopyFrom(const SSLCipherPreferenceList &);
307
+
308
+ // Removes `cipher` from the preference list.
298
309
  void Remove(const SSL_CIPHER *cipher);
299
310
 
300
- UniquePtr<STACK_OF(SSL_CIPHER)> ciphers;
301
- bool *in_group_flags = nullptr;
311
+ // Contains returns whether a cipher whose protocol ID is `cipher_id` appears
312
+ // in the list.
313
+ bool Contains(uint16_t cipher_id) const;
314
+
315
+ // ChooseCipher implements the logic for a server to select the most-preferred
316
+ // cipher satisfying the constraints that is listed in both `*this` and the
317
+ // client's preference list in `client_cipher_list`, which contains an ordered
318
+ // list of 2-byte cipher suite protocol IDs. The returned cipher must be
319
+ // supported for the SSL protocol `version`, and must match the key exchange
320
+ // algorithm mask `mask_k` and the server authentication mask `mask_a`. If
321
+ // `prioritize_client_pref` is true, then the client's preference list is
322
+ // prioritized over the list in `*this`. Otherwise, the server's preference
323
+ // list (`*this`) is prioritized. This function returns a pointer to the
324
+ // most-preferred shared cipher, or nullptr if no shared cipher was found.
325
+ const SSL_CIPHER *ChooseCipher(const CBS *client_cipher_list,
326
+ bool prioritize_client_pref, uint16_t version,
327
+ uint32_t mask_k, uint32_t mask_a) const;
328
+
329
+ size_t size() const { return sk_SSL_CIPHER_num(ciphers_.get()); }
330
+
331
+ const STACK_OF(SSL_CIPHER) *ciphers() const { return ciphers_.get(); }
332
+ Span<const bool> in_group_flags() const { return in_group_flags_; }
333
+
334
+ // TODO(crbug.com/550501994): Remove the non-const overload. This may result
335
+ // in callers mutating the internal state in an inconsistent way.
336
+ STACK_OF(SSL_CIPHER) *ciphers() { return ciphers_.get(); }
337
+
338
+ private:
339
+ // SSL_CIPHERs are maintained in a stack so they are easily accessible in the
340
+ // form required for `SSL{_CTX}_get_ciphers`.
341
+ UniquePtr<STACK_OF(SSL_CIPHER)> ciphers_;
342
+ Array<bool> in_group_flags_;
302
343
  };
303
344
 
304
345
  // AllCiphers returns an array of all supported ciphers, sorted by id.
@@ -319,15 +360,23 @@ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
319
360
  const EVP_MD *ssl_get_handshake_digest(uint16_t version,
320
361
  const SSL_CIPHER *cipher);
321
362
 
322
- // ssl_create_cipher_list evaluates `rule_str`. It sets `*out_cipher_list` to a
323
- // newly-allocated `SSLCipherPreferenceList` containing the result. It returns
324
- // true on success and false on failure. If `strict` is true, nonsense will be
325
- // rejected. If false, nonsense will be silently ignored. An empty result is
326
- // considered an error regardless of `strict`. `has_aes_hw` indicates if the
327
- // list should be ordered based on having support for AES in hardware or not.
363
+ // ssl_create_cipher_list evaluates `rule_str` to create the TLS 1.2 cipher
364
+ // list. It sets `*out_cipher_list` to a newly-allocated
365
+ // `SSLCipherPreferenceList` containing the result. It returns true on success
366
+ // and false on failure. If `strict` is true, nonsense will be rejected. If
367
+ // false, nonsense will be silently ignored. An empty result is considered an
368
+ // error regardless of `strict`. The resulting list will be ordered based on
369
+ // having support for AES in hardware or not.
328
370
  bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
329
- const bool has_aes_hw, const char *rule_str,
330
- bool strict);
371
+ const char *rule_str, bool strict);
372
+
373
+ // ssl_create_default_tls13_cipher_list populates the default TLS 1.3 cipher
374
+ // list, clearing any previous contents in `*out_cipher_list` and replacing them
375
+ // with the result. It returns true on success and false on failure. The
376
+ // resulting list will be ordered based on having support for AES in hardware or
377
+ // not.
378
+ bool ssl_create_default_tls13_cipher_list(
379
+ SSLCipherPreferenceList *out_cipher_list);
331
380
 
332
381
  // ssl_cipher_auth_mask_for_key returns the mask of cipher `algorithm_auth`
333
382
  // values suitable for use with `key` in TLS 1.2 and below. `sign_ok` indicates
@@ -350,21 +399,8 @@ bool ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
350
399
  // it returns zero.
351
400
  size_t ssl_cipher_get_record_split_len(const SSL_CIPHER *cipher);
352
401
 
353
- // ssl_choose_tls13_cipher returns an `SSL_CIPHER` corresponding with the best
354
- // available from `cipher_suites` compatible with `version` and `policy`. It
355
- // returns NULL if there isn't a compatible cipher. `has_aes_hw` indicates if
356
- // the choice should be made as if support for AES in hardware is available.
357
- const SSL_CIPHER *ssl_choose_tls13_cipher(CBS cipher_suites, bool has_aes_hw,
358
- uint16_t version,
359
- enum ssl_compliance_policy_t policy);
360
-
361
- // ssl_tls13_cipher_meets_policy returns true if `cipher_id` is acceptable given
362
- // `policy`.
363
- bool ssl_tls13_cipher_meets_policy(uint16_t cipher_id,
364
- enum ssl_compliance_policy_t policy);
365
-
366
402
  // ssl_cipher_is_deprecated returns true if `cipher` is deprecated.
367
- OPENSSL_EXPORT bool ssl_cipher_is_deprecated(const SSL_CIPHER *cipher);
403
+ bool ssl_cipher_is_deprecated(const SSL_CIPHER *cipher);
368
404
 
369
405
 
370
406
  // Transcript layer.
@@ -432,7 +468,7 @@ class SSLTranscript {
432
468
  // pointed by `out` and writes the number of bytes to `*out_len`. `out` must
433
469
  // have room for `EVP_MAX_MD_SIZE` bytes. It returns true on success and false
434
470
  // on failure.
435
- bool GetFinishedMAC(uint8_t *out, size_t *out_len, const SSL_SESSION *session,
471
+ bool GetFinishedMAC(uint8_t *out, size_t *out_len, const SSLSession *session,
436
472
  bool from_server) const;
437
473
 
438
474
  private:
@@ -716,7 +752,7 @@ struct DTLSWriteEpoch {
716
752
  //
717
753
  // TODO(davidben): Expose this as part of public API once the high-level
718
754
  // buffer-free APIs are available.
719
- size_t ssl_record_prefix_len(const SSL *ssl);
755
+ size_t ssl_record_prefix_len(const SSLImpl *ssl);
720
756
 
721
757
  enum ssl_open_record_t {
722
758
  ssl_open_record_success,
@@ -749,7 +785,7 @@ enum ssl_open_record_t {
749
785
  //
750
786
  // On failure or fatal alert, it returns `ssl_open_record_error` and sets
751
787
  // `*out_alert` to an alert to emit, or zero if no alert should be emitted.
752
- enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type,
788
+ enum ssl_open_record_t tls_open_record(SSLImpl *ssl, uint8_t *out_type,
753
789
  Span<uint8_t> *out, size_t *out_consumed,
754
790
  uint8_t *out_alert, Span<uint8_t> in);
755
791
 
@@ -757,7 +793,7 @@ enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type,
757
793
  // `ssl_open_record_partial` if `in` was empty and sets `*out_consumed` to
758
794
  // zero. The caller should read one packet and try again. On success,
759
795
  // `*out_number` is set to the record number of the record.
760
- enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
796
+ enum ssl_open_record_t dtls_open_record(SSLImpl *ssl, uint8_t *out_type,
761
797
  DTLSRecordNumber *out_number,
762
798
  Span<uint8_t> *out,
763
799
  size_t *out_consumed,
@@ -765,7 +801,7 @@ enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
765
801
 
766
802
  // ssl_needs_record_splitting returns one if `ssl`'s current outgoing cipher
767
803
  // state needs record-splitting and zero otherwise.
768
- bool ssl_needs_record_splitting(const SSL *ssl);
804
+ bool ssl_needs_record_splitting(const SSLImpl *ssl);
769
805
 
770
806
  // tls_seal_record seals a new record of type `type` and body `in` and writes it
771
807
  // to `out`. At most `max_out` bytes will be written. It returns true on success
@@ -778,36 +814,38 @@ bool ssl_needs_record_splitting(const SSL *ssl);
778
814
  // bytes to `out`.
779
815
  //
780
816
  // `in` and `out` may not alias.
781
- bool tls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
782
- uint8_t type, const uint8_t *in, size_t in_len);
817
+ bool tls_seal_record(SSLImpl *ssl, uint8_t *out, size_t *out_len,
818
+ size_t max_out, uint8_t type, const uint8_t *in,
819
+ size_t in_len);
783
820
 
784
821
  // dtls_record_header_write_len returns the length of the record header that
785
822
  // will be written at `epoch`.
786
- size_t dtls_record_header_write_len(const SSL *ssl, uint16_t epoch);
823
+ size_t dtls_record_header_write_len(const SSLImpl *ssl, uint16_t epoch);
787
824
 
788
825
  // dtls_max_seal_overhead returns the maximum overhead, in bytes, of sealing a
789
826
  // record.
790
- size_t dtls_max_seal_overhead(const SSL *ssl, uint16_t epoch);
827
+ size_t dtls_max_seal_overhead(const SSLImpl *ssl, uint16_t epoch);
791
828
 
792
829
  // dtls_seal_prefix_len returns the number of bytes of prefix to reserve in
793
830
  // front of the plaintext when sealing a record in-place.
794
- size_t dtls_seal_prefix_len(const SSL *ssl, uint16_t epoch);
831
+ size_t dtls_seal_prefix_len(const SSLImpl *ssl, uint16_t epoch);
795
832
 
796
833
  // dtls_seal_max_input_len returns the maximum number of input bytes that can
797
834
  // fit in a record of up to `max_out` bytes, or zero if none may fit.
798
- size_t dtls_seal_max_input_len(const SSL *ssl, uint16_t epoch, size_t max_out);
835
+ size_t dtls_seal_max_input_len(const SSLImpl *ssl, uint16_t epoch,
836
+ size_t max_out);
799
837
 
800
838
  // dtls_get_read_epoch and dtls_get_write_epoch return the epoch corresponding
801
839
  // to `epoch` or nullptr if there is none.
802
- DTLSReadEpoch *dtls_get_read_epoch(const SSL *ssl, uint16_t epoch);
803
- DTLSWriteEpoch *dtls_get_write_epoch(const SSL *ssl, uint16_t epoch);
840
+ DTLSReadEpoch *dtls_get_read_epoch(const SSLImpl *ssl, uint16_t epoch);
841
+ DTLSWriteEpoch *dtls_get_write_epoch(const SSLImpl *ssl, uint16_t epoch);
804
842
 
805
843
  // dtls_seal_record implements `tls_seal_record` for DTLS. `epoch` selects which
806
844
  // epoch's cipher state to use. Unlike `tls_seal_record`, `in` and `out` may
807
845
  // alias but, if they do, `in` must be exactly `dtls_seal_prefix_len` bytes
808
846
  // ahead of `out`. On success, `*out_number` is set to the record number of the
809
847
  // record.
810
- bool dtls_seal_record(SSL *ssl, DTLSRecordNumber *out_number, uint8_t *out,
848
+ bool dtls_seal_record(SSLImpl *ssl, DTLSRecordNumber *out_number, uint8_t *out,
811
849
  size_t *out_len, size_t max_out, uint8_t type,
812
850
  const uint8_t *in, size_t in_len, uint16_t epoch);
813
851
 
@@ -815,7 +853,7 @@ bool dtls_seal_record(SSL *ssl, DTLSRecordNumber *out_number, uint8_t *out,
815
853
  // state. It returns one of `ssl_open_record_discard`, `ssl_open_record_error`,
816
854
  // `ssl_open_record_close_notify`, or `ssl_open_record_fatal_alert` as
817
855
  // appropriate.
818
- enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert,
856
+ enum ssl_open_record_t ssl_process_alert(SSLImpl *ssl, uint8_t *out_alert,
819
857
  Span<const uint8_t> in);
820
858
 
821
859
 
@@ -845,12 +883,12 @@ UniquePtr<EVP_PKEY> ssl_parse_peer_subject_public_key_info(
845
883
 
846
884
  // ssl_pkey_supports_algorithm returns whether `pkey` may be used to sign
847
885
  // `sigalg`.
848
- bool ssl_pkey_supports_algorithm(const SSL *ssl, EVP_PKEY *pkey,
886
+ bool ssl_pkey_supports_algorithm(const SSLImpl *ssl, EVP_PKEY *pkey,
849
887
  uint16_t sigalg, bool is_verify);
850
888
 
851
889
  // ssl_public_key_verify verifies that the `signature` is valid for the public
852
890
  // key `pkey` and input `in`, using the signature algorithm `sigalg`.
853
- bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature,
891
+ bool ssl_public_key_verify(SSLImpl *ssl, Span<const uint8_t> signature,
854
892
  uint16_t sigalg, EVP_PKEY *pkey,
855
893
  Span<const uint8_t> in);
856
894
 
@@ -914,7 +952,7 @@ struct NamedGroup {
914
952
  Span<const NamedGroup> NamedGroups();
915
953
 
916
954
  // kNumNamedGroups is the number of supported groups.
917
- constexpr size_t kNumNamedGroups = 7u;
955
+ constexpr size_t kNumNamedGroups = 6u;
918
956
 
919
957
  // DefaultSupportedGroupIds returns the list of IDs for the default groups that
920
958
  // are supported when the caller hasn't explicitly configured supported groups.
@@ -959,42 +997,42 @@ extern const uint8_t kJDK11DowngradeRandom[8];
959
997
 
960
998
  // ssl_max_handshake_message_len returns the maximum number of bytes permitted
961
999
  // in a handshake message for `ssl`.
962
- size_t ssl_max_handshake_message_len(const SSL *ssl);
1000
+ size_t ssl_max_handshake_message_len(const SSLImpl *ssl);
963
1001
 
964
1002
  // tls_can_accept_handshake_data returns whether `ssl` is able to accept more
965
1003
  // data into handshake buffer.
966
- bool tls_can_accept_handshake_data(const SSL *ssl, uint8_t *out_alert);
1004
+ bool tls_can_accept_handshake_data(const SSLImpl *ssl, uint8_t *out_alert);
967
1005
 
968
1006
  // tls_has_unprocessed_handshake_data returns whether there is buffered
969
1007
  // handshake data that has not been consumed by `get_message`.
970
- bool tls_has_unprocessed_handshake_data(const SSL *ssl);
1008
+ bool tls_has_unprocessed_handshake_data(const SSLImpl *ssl);
971
1009
 
972
1010
  // tls_append_handshake_data appends `data` to the handshake buffer. It returns
973
1011
  // true on success and false on allocation failure.
974
- bool tls_append_handshake_data(SSL *ssl, Span<const uint8_t> data);
1012
+ bool tls_append_handshake_data(SSLImpl *ssl, Span<const uint8_t> data);
975
1013
 
976
1014
  // dtls_has_unprocessed_handshake_data behaves like
977
1015
  // `tls_has_unprocessed_handshake_data` for DTLS.
978
- bool dtls_has_unprocessed_handshake_data(const SSL *ssl);
1016
+ bool dtls_has_unprocessed_handshake_data(const SSLImpl *ssl);
979
1017
 
980
1018
  // tls_flush_pending_hs_data flushes any handshake plaintext data.
981
- bool tls_flush_pending_hs_data(SSL *ssl);
1019
+ bool tls_flush_pending_hs_data(SSLImpl *ssl);
982
1020
 
983
1021
  // dtls_clear_outgoing_messages releases all buffered outgoing messages.
984
- void dtls_clear_outgoing_messages(SSL *ssl);
1022
+ void dtls_clear_outgoing_messages(SSLImpl *ssl);
985
1023
 
986
1024
  // dtls_clear_unused_write_epochs releases any write epochs that are no longer
987
1025
  // needed.
988
- void dtls_clear_unused_write_epochs(SSL *ssl);
1026
+ void dtls_clear_unused_write_epochs(SSLImpl *ssl);
989
1027
 
990
1028
 
991
1029
  // Callbacks.
992
1030
 
993
1031
  // ssl_do_info_callback calls `ssl`'s info callback, if set.
994
- void ssl_do_info_callback(const SSL *ssl, int type, int value);
1032
+ void ssl_do_info_callback(const SSLImpl *ssl, int type, int value);
995
1033
 
996
1034
  // ssl_do_msg_callback calls `ssl`'s message callback, if set.
997
- void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type,
1035
+ void ssl_do_msg_callback(const SSLImpl *ssl, int is_write, int content_type,
998
1036
  Span<const uint8_t> in);
999
1037
 
1000
1038
 
@@ -1059,19 +1097,19 @@ class SSLBuffer {
1059
1097
  //
1060
1098
  // It is an error to call `ssl_read_buffer_extend_to` in DTLS when the buffer is
1061
1099
  // non-empty.
1062
- int ssl_read_buffer_extend_to(SSL *ssl, size_t len);
1100
+ int ssl_read_buffer_extend_to(SSLImpl *ssl, size_t len);
1063
1101
 
1064
1102
  // ssl_handle_open_record handles the result of passing `ssl->s3->read_buffer`
1065
1103
  // to a record-processing function. If `ret` is a success or if the caller
1066
1104
  // should retry, it returns one and sets `*out_retry`. Otherwise, it returns <=
1067
1105
  // 0.
1068
- int ssl_handle_open_record(SSL *ssl, bool *out_retry, ssl_open_record_t ret,
1106
+ int ssl_handle_open_record(SSLImpl *ssl, bool *out_retry, ssl_open_record_t ret,
1069
1107
  size_t consumed, uint8_t alert);
1070
1108
 
1071
1109
  // ssl_write_buffer_flush flushes the write buffer to the transport. It returns
1072
1110
  // one on success and <= 0 on error. For DTLS, whether or not the write
1073
1111
  // succeeds, the write buffer will be cleared.
1074
- int ssl_write_buffer_flush(SSL *ssl);
1112
+ int ssl_write_buffer_flush(SSLImpl *ssl);
1075
1113
 
1076
1114
 
1077
1115
  // Certificate functions.
@@ -1135,7 +1173,7 @@ UniquePtr<EVP_PKEY> ssl_cert_parse_pubkey(const CBS *in);
1135
1173
  // it returns a newly-allocated `CRYPTO_BUFFER` list and advances
1136
1174
  // `cbs`. Otherwise, it returns nullptr and sets `*out_alert` to an alert to
1137
1175
  // send to the peer.
1138
- UniquePtr<STACK_OF(CRYPTO_BUFFER)> SSL_parse_CA_list(SSL *ssl,
1176
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> SSL_parse_CA_list(SSLImpl *ssl,
1139
1177
  uint8_t *out_alert,
1140
1178
  CBS *cbs);
1141
1179
 
@@ -1173,7 +1211,7 @@ bool tls13_init_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> psk);
1173
1211
  // derivation state from `session` for use with 0-RTT. It returns one on success
1174
1212
  // and zero on error.
1175
1213
  bool tls13_init_early_key_schedule(SSL_HANDSHAKE *hs,
1176
- const SSL_SESSION *session);
1214
+ const SSLSession *session);
1177
1215
 
1178
1216
  // tls13_advance_key_schedule incorporates `in` into the key schedule with
1179
1217
  // HKDF-Extract. It returns true on success and false on error.
@@ -1182,9 +1220,9 @@ bool tls13_advance_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> in);
1182
1220
  // tls13_set_traffic_key sets the read or write traffic keys to
1183
1221
  // `traffic_secret`. The version and cipher suite are determined from `session`.
1184
1222
  // It returns true on success and false on error.
1185
- bool tls13_set_traffic_key(SSL *ssl, enum ssl_encryption_level_t level,
1223
+ bool tls13_set_traffic_key(SSLImpl *ssl, enum ssl_encryption_level_t level,
1186
1224
  enum evp_aead_direction_t direction,
1187
- const SSL_SESSION *session,
1225
+ const SSLSession *session,
1188
1226
  Span<const uint8_t> traffic_secret);
1189
1227
 
1190
1228
  // tls13_derive_early_secret derives the early traffic secret. It returns true
@@ -1197,7 +1235,8 @@ bool tls13_derive_handshake_secrets(SSL_HANDSHAKE *hs);
1197
1235
 
1198
1236
  // tls13_rotate_traffic_key derives the next read or write traffic secret. It
1199
1237
  // returns true on success and false on error.
1200
- bool tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction);
1238
+ bool tls13_rotate_traffic_key(SSLImpl *ssl,
1239
+ enum evp_aead_direction_t direction);
1201
1240
 
1202
1241
  // tls13_derive_application_secrets derives the initial application data traffic
1203
1242
  // and exporter secrets based on the handshake transcripts and `master_secret`.
@@ -1209,7 +1248,7 @@ bool tls13_derive_resumption_secret(SSL_HANDSHAKE *hs);
1209
1248
 
1210
1249
  // tls13_export_keying_material provides an exporter interface to use the
1211
1250
  // `exporter_secret`.
1212
- bool tls13_export_keying_material(const SSL *ssl, Span<uint8_t> out,
1251
+ bool tls13_export_keying_material(const SSLImpl *ssl, Span<uint8_t> out,
1213
1252
  Span<const uint8_t> secret,
1214
1253
  std::string_view label,
1215
1254
  Span<const uint8_t> context);
@@ -1224,7 +1263,7 @@ bool tls13_finished_mac(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len,
1224
1263
  // tls13_derive_session_psk calculates the PSK for this session based on the
1225
1264
  // resumption master secret and `nonce`. It returns true on success, and false
1226
1265
  // on failure.
1227
- bool tls13_derive_session_psk(SSL_SESSION *session, Span<const uint8_t> nonce,
1266
+ bool tls13_derive_session_psk(SSLSession *session, Span<const uint8_t> nonce,
1228
1267
  bool is_dtls);
1229
1268
 
1230
1269
  struct SSLImportedPSK {
@@ -1254,7 +1293,7 @@ bool tls13_compare_imported_psk_identity(Span<const uint8_t> id,
1254
1293
  uint16_t protocol,
1255
1294
  const EVP_MD *hkdf_md);
1256
1295
 
1257
- using SSLPreSharedKey = std::variant<SSLImportedPSK, UniquePtr<SSL_SESSION>>;
1296
+ using SSLPreSharedKey = std::variant<SSLImportedPSK, UniquePtr<SSLSession>>;
1258
1297
  BORINGSSL_MAKE_DELETER(SSLPreSharedKey, Delete)
1259
1298
 
1260
1299
  // ssl_pre_shared_key_hash return's `psk`'s hash.
@@ -1349,7 +1388,7 @@ enum ssl_client_hello_type_t {
1349
1388
  //
1350
1389
  // This function is exported for fuzzing.
1351
1390
  OPENSSL_EXPORT bool ssl_decode_client_hello_inner(
1352
- SSL *ssl, uint8_t *out_alert, Array<uint8_t> *out_client_hello_inner,
1391
+ SSLImpl *ssl, uint8_t *out_alert, Array<uint8_t> *out_client_hello_inner,
1353
1392
  Span<const uint8_t> encoded_client_hello_inner,
1354
1393
  const SSL_CLIENT_HELLO *client_hello_outer);
1355
1394
 
@@ -1366,7 +1405,7 @@ bool ssl_client_hello_decrypt(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1366
1405
 
1367
1406
  // ssl_ech_confirmation_signal_hello_offset returns the offset of the ECH
1368
1407
  // confirmation signal in a ServerHello message, including the handshake header.
1369
- size_t ssl_ech_confirmation_signal_hello_offset(const SSL *ssl);
1408
+ size_t ssl_ech_confirmation_signal_hello_offset(const SSLImpl *ssl);
1370
1409
 
1371
1410
  // ssl_ech_accept_confirmation computes the server's ECH acceptance signal,
1372
1411
  // writing it to `out`. The transcript portion is the concatenation of
@@ -1516,6 +1555,10 @@ class SSLCredential : public ssl_credential_st,
1516
1555
  // OCSP response to be sent to the client, if requested.
1517
1556
  UniquePtr<CRYPTO_BUFFER> ocsp_response;
1518
1557
 
1558
+ // sid_ctx partitions the session space within a shared session cache or
1559
+ // ticket key. If empty, the session ID context in `SSL` will be used.
1560
+ InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
1561
+
1519
1562
  // SPAKE2+-specific information.
1520
1563
  Array<uint8_t> pake_context;
1521
1564
  Array<uint8_t> client_identity;
@@ -1548,6 +1591,10 @@ class SSLCredential : public ssl_credential_st,
1548
1591
  // chain in `chain`.
1549
1592
  Array<uint8_t> trust_anchor_id;
1550
1593
 
1594
+ // trust_anchor_group_patterns describes trust anchor groups that also match
1595
+ // this credential.
1596
+ Vector<Array<uint8_t>> trust_anchor_group_patterns;
1597
+
1551
1598
  CRYPTO_EX_DATA ex_data;
1552
1599
 
1553
1600
  // must_match_issuer is a flag indicating that this credential should be
@@ -1562,6 +1609,11 @@ class SSLCredential : public ssl_credential_st,
1562
1609
  ~SSLCredential();
1563
1610
  };
1564
1611
 
1612
+ // ssl_trust_anchor_pattern_matches_id returns whether `pattern`, a trust anchor
1613
+ // ID pattern, matches `id`, a trust anchor ID.
1614
+ bool ssl_trust_anchor_pattern_matches_id(Span<const uint8_t> pattern,
1615
+ Span<const uint8_t> id);
1616
+
1565
1617
  // ssl_get_full_credential_list computes `hs`'s full credential list, including
1566
1618
  // the legacy credential. On success, it writes it to `*out` and returns true.
1567
1619
  // Otherwise, it returns false. The credential list may be empty, in which case
@@ -1665,7 +1717,8 @@ enum ssl_grease_index_t {
1665
1717
  ssl_grease_version,
1666
1718
  ssl_grease_ticket_extension,
1667
1719
  ssl_grease_ech_config_id,
1668
- ssl_grease_last_index = ssl_grease_ech_config_id,
1720
+ ssl_grease_signature_algorithm,
1721
+ ssl_grease_last_index = ssl_grease_signature_algorithm,
1669
1722
  };
1670
1723
 
1671
1724
  enum tls12_server_hs_state_t {
@@ -1765,12 +1818,12 @@ struct SSLPAKEShare {
1765
1818
  };
1766
1819
 
1767
1820
  struct SSL_HANDSHAKE {
1768
- explicit SSL_HANDSHAKE(SSL *ssl);
1821
+ explicit SSL_HANDSHAKE(SSLImpl *ssl);
1769
1822
  ~SSL_HANDSHAKE();
1770
1823
  static constexpr bool kAllowUniquePtr = true;
1771
1824
 
1772
1825
  // ssl is a non-owning pointer to the parent `SSL` object.
1773
- SSL *ssl;
1826
+ SSLImpl *ssl;
1774
1827
 
1775
1828
  // config is a non-owning pointer to the handshake configuration.
1776
1829
  SSL_CONFIG *config;
@@ -1963,11 +2016,11 @@ struct SSL_HANDSHAKE {
1963
2016
 
1964
2017
  // new_session is the new mutable session being established by the current
1965
2018
  // handshake. It should not be cached.
1966
- UniquePtr<SSL_SESSION> new_session;
2019
+ UniquePtr<SSLSession> new_session;
1967
2020
 
1968
2021
  // early_session is the session corresponding to the current 0-RTT state on
1969
2022
  // the client if `in_early_data` is true.
1970
- UniquePtr<SSL_SESSION> early_session;
2023
+ UniquePtr<SSLSession> early_session;
1971
2024
 
1972
2025
  // ssl_ech_keys, for servers, is the set of ECH keys to use with this
1973
2026
  // handshake. This is copied from `SSL_CTX` to ensure consistent behavior as
@@ -1985,12 +2038,15 @@ struct SSL_HANDSHAKE {
1985
2038
  // key_block is the record-layer key block for TLS 1.2 and earlier.
1986
2039
  Array<uint8_t> key_block;
1987
2040
 
1988
- // hints contains the handshake hints for this connection. If
1989
- // `hints_requested` is true, this field is non-null and contains the pending
1990
- // hints to filled as the predicted handshake progresses. Otherwise, this
1991
- // field, if non-null, contains hints configured by the caller and will
1992
- // influence the handshake on match.
1993
- UniquePtr<SSL_HANDSHAKE_HINTS> hints;
2041
+ // pending_hints, if non-null, contains the pending hints to filled as the
2042
+ // predicted handshake progresses. If non-null, only the first round-trip of
2043
+ // the handshake will complete, after which the `pending_hints` structure can
2044
+ // be serialized.
2045
+ UniquePtr<SSL_HANDSHAKE_HINTS> pending_hints;
2046
+
2047
+ // provided_hints, if non-null, contains hints configured by the caller
2048
+ // and will influence the (real or predicted) handshake on match.
2049
+ UniquePtr<SSL_HANDSHAKE_HINTS> provided_hints;
1994
2050
 
1995
2051
  // ech_is_inner, on the server, indicates whether the ClientHello contained an
1996
2052
  // inner ECH extension.
@@ -2070,11 +2126,6 @@ struct SSL_HANDSHAKE {
2070
2126
  // `SSL_apply_handoff`.
2071
2127
  bool handback : 1;
2072
2128
 
2073
- // hints_requested indicates the caller has requested handshake hints. Only
2074
- // the first round-trip of the handshake will complete, after which the
2075
- // `hints` structure can be serialized.
2076
- bool hints_requested : 1;
2077
-
2078
2129
  // cert_compression_negotiated is true iff `cert_compression_alg_id` is valid.
2079
2130
  bool cert_compression_negotiated : 1;
2080
2131
 
@@ -2163,11 +2214,11 @@ struct SSL_HANDSHAKE {
2163
2214
  // so many tickets.
2164
2215
  constexpr size_t kMaxTickets = 16;
2165
2216
 
2166
- UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSL *ssl);
2217
+ UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSLImpl *ssl);
2167
2218
 
2168
2219
  // ssl_check_message_type checks if `msg` has type `type`. If so it returns
2169
2220
  // one. Otherwise, it sends an alert and returns zero.
2170
- bool ssl_check_message_type(SSL *ssl, const SSLMessage &msg, int type);
2221
+ bool ssl_check_message_type(SSLImpl *ssl, const SSLMessage &msg, int type);
2171
2222
 
2172
2223
  // ssl_run_handshake runs the TLS handshake. It returns one on success and <= 0
2173
2224
  // on error. It sets `out_early_return` to one if we've completed the handshake
@@ -2190,11 +2241,11 @@ const char *tls13_server_handshake_state(SSL_HANDSHAKE *hs);
2190
2241
 
2191
2242
  // tls13_add_key_update queues a KeyUpdate message on `ssl`. `request_type` must
2192
2243
  // be one of `SSL_KEY_UPDATE_REQUESTED` or `SSL_KEY_UPDATE_NOT_REQUESTED`.
2193
- bool tls13_add_key_update(SSL *ssl, int request_type);
2244
+ bool tls13_add_key_update(SSLImpl *ssl, int request_type);
2194
2245
 
2195
2246
  // tls13_post_handshake processes a post-handshake message. It returns true on
2196
2247
  // success and false on failure.
2197
- bool tls13_post_handshake(SSL *ssl, const SSLMessage &msg);
2248
+ bool tls13_post_handshake(SSLImpl *ssl, const SSLMessage &msg);
2198
2249
 
2199
2250
  bool tls13_process_certificate(SSL_HANDSHAKE *hs, const SSLMessage &msg,
2200
2251
  bool allow_anonymous);
@@ -2214,8 +2265,8 @@ bool tls13_add_certificate(SSL_HANDSHAKE *hs);
2214
2265
  enum ssl_private_key_result_t tls13_add_certificate_verify(SSL_HANDSHAKE *hs);
2215
2266
 
2216
2267
  bool tls13_add_finished(SSL_HANDSHAKE *hs);
2217
- bool tls13_process_new_session_ticket(SSL *ssl, const SSLMessage &msg);
2218
- UniquePtr<SSL_SESSION> tls13_create_session_with_ticket(SSL *ssl, CBS *body);
2268
+ bool tls13_process_new_session_ticket(SSLImpl *ssl, const SSLMessage &msg);
2269
+ UniquePtr<SSLSession> tls13_create_session_with_ticket(SSLImpl *ssl, CBS *body);
2219
2270
 
2220
2271
  // ssl_setup_extension_permutation computes a ClientHello extension permutation
2221
2272
  // for `hs`, if applicable. It returns true on success and false on error.
@@ -2414,7 +2465,7 @@ bool ssl_send_tls12_certificate(SSL_HANDSHAKE *hs);
2414
2465
 
2415
2466
  // ssl_handshake_session returns the `SSL_SESSION` corresponding to the current
2416
2467
  // handshake. Note, in TLS 1.2 resumptions, this session is immutable.
2417
- const SSL_SESSION *ssl_handshake_session(const SSL_HANDSHAKE *hs);
2468
+ const SSLSession *ssl_handshake_session(const SSL_HANDSHAKE *hs);
2418
2469
 
2419
2470
  // ssl_done_writing_client_hello is called after the last ClientHello is written
2420
2471
  // by `hs`. It releases some memory that is no longer needed.
@@ -2468,13 +2519,13 @@ bool ssl_parse_flags_extension_response(const CBS *cbs, SSLFlags *out,
2468
2519
 
2469
2520
  // ssl_log_secret logs `secret` with label `label`, if logging is enabled for
2470
2521
  // `ssl`. It returns true on success and false on failure.
2471
- bool ssl_log_secret(const SSL *ssl, const char *label,
2522
+ bool ssl_log_secret(const SSLImpl *ssl, const char *label,
2472
2523
  Span<const uint8_t> secret);
2473
2524
 
2474
2525
 
2475
2526
  // ClientHello functions.
2476
2527
 
2477
- bool ssl_parse_client_hello_with_trailing_data(const SSL *ssl, CBS *cbs,
2528
+ bool ssl_parse_client_hello_with_trailing_data(const SSLImpl *ssl, CBS *cbs,
2478
2529
  SSL_CLIENT_HELLO *out);
2479
2530
 
2480
2531
  bool ssl_client_hello_get_extension(const SSL_CLIENT_HELLO *client_hello,
@@ -2532,6 +2583,29 @@ bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
2532
2583
  // From RFC 4492, used in encoding the curve type in ECParameters
2533
2584
  #define NAMED_CURVE_TYPE 3
2534
2585
 
2586
+ struct CertCb {
2587
+ using OldCallback = int (*)(SSL *ssl, void *arg);
2588
+ using NewCallback = int (*)(SSL *ssl, void *arg, uint8_t *out_alert);
2589
+
2590
+ std::variant<std::monostate, OldCallback, NewCallback> cb;
2591
+
2592
+ explicit operator bool() const {
2593
+ return !std::holds_alternative<std::monostate>(cb);
2594
+ }
2595
+
2596
+ int operator()(SSL *ssl, void *arg, uint8_t *out_alert) const {
2597
+ switch (cb.index()) {
2598
+ default:
2599
+ case 0:
2600
+ return 0;
2601
+ case 1:
2602
+ return std::get<1>(cb)(ssl, arg);
2603
+ case 2:
2604
+ return std::get<2>(cb)(ssl, arg, out_alert);
2605
+ }
2606
+ }
2607
+ };
2608
+
2535
2609
  struct CERT {
2536
2610
  static constexpr bool kAllowUniquePtr = true;
2537
2611
 
@@ -2579,7 +2653,7 @@ struct CERT {
2579
2653
  // certificates required. This allows advanced applications
2580
2654
  // to select certificates on the fly: for example based on
2581
2655
  // supported signature algorithms or curves.
2582
- int (*cert_cb)(SSL *ssl, void *arg) = nullptr;
2656
+ CertCb cert_cb = {};
2583
2657
  void *cert_cb_arg = nullptr;
2584
2658
 
2585
2659
  // Optional X509_STORE for certificate validation. If NULL the parent SSL_CTX
@@ -2594,25 +2668,26 @@ struct CERT {
2594
2668
  // `SSL_PROTOCOL_METHOD` abstracts between TLS and DTLS.
2595
2669
  struct SSL_PROTOCOL_METHOD {
2596
2670
  bool is_dtls;
2597
- bool (*ssl_new)(SSL *ssl);
2598
- void (*ssl_free)(SSL *ssl);
2671
+ bool (*ssl_new)(SSLImpl *ssl);
2672
+ void (*ssl_free)(SSLImpl *ssl);
2599
2673
  // get_message sets `*out` to the current handshake message and returns true
2600
2674
  // if one has been received. It returns false if more input is needed.
2601
- bool (*get_message)(const SSL *ssl, SSLMessage *out);
2675
+ bool (*get_message)(const SSLImpl *ssl, SSLMessage *out);
2602
2676
  // next_message is called to release the current handshake message.
2603
- void (*next_message)(SSL *ssl);
2677
+ void (*next_message)(SSLImpl *ssl);
2604
2678
  // has_unprocessed_handshake_data returns whether there is buffered
2605
2679
  // handshake data that has not been consumed by `get_message`.
2606
- bool (*has_unprocessed_handshake_data)(const SSL *ssl);
2680
+ bool (*has_unprocessed_handshake_data)(const SSLImpl *ssl);
2607
2681
  // Use the `ssl_open_handshake` wrapper.
2608
- ssl_open_record_t (*open_handshake)(SSL *ssl, size_t *out_consumed,
2682
+ ssl_open_record_t (*open_handshake)(SSLImpl *ssl, size_t *out_consumed,
2609
2683
  uint8_t *out_alert, Span<uint8_t> in);
2610
2684
  // Use the `ssl_open_change_cipher_spec` wrapper.
2611
- ssl_open_record_t (*open_change_cipher_spec)(SSL *ssl, size_t *out_consumed,
2685
+ ssl_open_record_t (*open_change_cipher_spec)(SSLImpl *ssl,
2686
+ size_t *out_consumed,
2612
2687
  uint8_t *out_alert,
2613
2688
  Span<uint8_t> in);
2614
2689
  // Use the `ssl_open_app_data` wrapper.
2615
- ssl_open_record_t (*open_app_data)(SSL *ssl, Span<uint8_t> *out,
2690
+ ssl_open_record_t (*open_app_data)(SSLImpl *ssl, Span<uint8_t> *out,
2616
2691
  size_t *out_consumed, uint8_t *out_alert,
2617
2692
  Span<uint8_t> in);
2618
2693
  // write_app_data encrypts and writes `in` as application data. On success, it
@@ -2620,33 +2695,33 @@ struct SSL_PROTOCOL_METHOD {
2620
2695
  // written. Otherwise, it returns <= 0 and sets `*out_needs_handshake` to
2621
2696
  // whether the operation failed because the caller needs to drive the
2622
2697
  // handshake.
2623
- int (*write_app_data)(SSL *ssl, bool *out_needs_handshake,
2698
+ int (*write_app_data)(SSLImpl *ssl, bool *out_needs_handshake,
2624
2699
  size_t *out_bytes_written, Span<const uint8_t> in);
2625
- int (*dispatch_alert)(SSL *ssl);
2700
+ int (*dispatch_alert)(SSLImpl *ssl);
2626
2701
  // init_message begins a new handshake message of type `type`. `cbb` is the
2627
2702
  // root CBB to be passed into `finish_message`. `*body` is set to a child CBB
2628
2703
  // the caller should write to. It returns true on success and false on error.
2629
- bool (*init_message)(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2704
+ bool (*init_message)(const SSLImpl *ssl, CBB *cbb, CBB *body, uint8_t type);
2630
2705
  // finish_message finishes a handshake message. It sets `*out_msg` to the
2631
2706
  // serialized message. It returns true on success and false on error.
2632
- bool (*finish_message)(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2707
+ bool (*finish_message)(const SSLImpl *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2633
2708
  // add_message adds a handshake message to the pending flight. It returns
2634
2709
  // true on success and false on error.
2635
- bool (*add_message)(SSL *ssl, Array<uint8_t> msg);
2710
+ bool (*add_message)(SSLImpl *ssl, Array<uint8_t> msg);
2636
2711
  // add_change_cipher_spec adds a ChangeCipherSpec record to the pending
2637
2712
  // flight. It returns true on success and false on error.
2638
- bool (*add_change_cipher_spec)(SSL *ssl);
2713
+ bool (*add_change_cipher_spec)(SSLImpl *ssl);
2639
2714
  // finish_flight marks the pending flight as finished and ready to send.
2640
2715
  // `flush` must be called to write it.
2641
- void (*finish_flight)(SSL *ssl);
2716
+ void (*finish_flight)(SSLImpl *ssl);
2642
2717
  // schedule_ack schedules a DTLS 1.3 ACK to be sent, without an ACK delay.
2643
2718
  // `flush` must be called to write it.
2644
- void (*schedule_ack)(SSL *ssl);
2719
+ void (*schedule_ack)(SSLImpl *ssl);
2645
2720
  // flush writes any scheduled data to the transport. It returns one on success
2646
2721
  // and <= 0 on error.
2647
- int (*flush)(SSL *ssl);
2722
+ int (*flush)(SSLImpl *ssl);
2648
2723
  // on_handshake_complete is called when the handshake is complete.
2649
- void (*on_handshake_complete)(SSL *ssl);
2724
+ void (*on_handshake_complete)(SSLImpl *ssl);
2650
2725
  // set_read_state sets `ssl`'s read cipher state and level to `aead_ctx` and
2651
2726
  // `level`. In QUIC, `aead_ctx` is a placeholder object. In TLS 1.3,
2652
2727
  // `traffic_secret` is the original traffic secret. This function returns true
@@ -2654,7 +2729,7 @@ struct SSL_PROTOCOL_METHOD {
2654
2729
  //
2655
2730
  // TODO(crbug.com/371998381): Take the traffic secrets as input and let the
2656
2731
  // function create the SSLAEADContext.
2657
- bool (*set_read_state)(SSL *ssl, ssl_encryption_level_t level,
2732
+ bool (*set_read_state)(SSLImpl *ssl, ssl_encryption_level_t level,
2658
2733
  UniquePtr<SSLAEADContext> aead_ctx,
2659
2734
  Span<const uint8_t> traffic_secret);
2660
2735
  // set_write_state sets `ssl`'s write cipher state and level to `aead_ctx` and
@@ -2664,7 +2739,7 @@ struct SSL_PROTOCOL_METHOD {
2664
2739
  //
2665
2740
  // TODO(crbug.com/371998381): Take the traffic secrets as input and let the
2666
2741
  // function create the SSLAEADContext.
2667
- bool (*set_write_state)(SSL *ssl, ssl_encryption_level_t level,
2742
+ bool (*set_write_state)(SSLImpl *ssl, ssl_encryption_level_t level,
2668
2743
  UniquePtr<SSLAEADContext> aead_ctx,
2669
2744
  Span<const uint8_t> traffic_secret);
2670
2745
  };
@@ -2673,12 +2748,13 @@ struct SSL_PROTOCOL_METHOD {
2673
2748
 
2674
2749
  // ssl_open_handshake processes a record from `in` for reading a handshake
2675
2750
  // message.
2676
- ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
2751
+ ssl_open_record_t ssl_open_handshake(SSLImpl *ssl, size_t *out_consumed,
2677
2752
  uint8_t *out_alert, Span<uint8_t> in);
2678
2753
 
2679
2754
  // ssl_open_change_cipher_spec processes a record from `in` for reading a
2680
2755
  // ChangeCipherSpec.
2681
- ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2756
+ ssl_open_record_t ssl_open_change_cipher_spec(SSLImpl *ssl,
2757
+ size_t *out_consumed,
2682
2758
  uint8_t *out_alert,
2683
2759
  Span<uint8_t> in);
2684
2760
 
@@ -2687,7 +2763,7 @@ ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2687
2763
  // input. If it encounters a post-handshake message, it returns
2688
2764
  // `ssl_open_record_discard`. The caller should then retry, after processing any
2689
2765
  // messages received with `get_message`.
2690
- ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
2766
+ ssl_open_record_t ssl_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
2691
2767
  size_t *out_consumed, uint8_t *out_alert,
2692
2768
  Span<uint8_t> in);
2693
2769
 
@@ -2713,16 +2789,16 @@ struct SSL_X509_METHOD {
2713
2789
  // session_cache_objects fills out `sess->x509_peer` and `sess->x509_chain`
2714
2790
  // from `sess->certs` and erases `sess->x509_chain_without_leaf`. It returns
2715
2791
  // true on success or false on error.
2716
- bool (*session_cache_objects)(SSL_SESSION *session);
2792
+ bool (*session_cache_objects)(SSLSession *session);
2717
2793
  // session_dup duplicates any needed fields from `session` to `new_session`.
2718
2794
  // It returns true on success or false on error.
2719
- bool (*session_dup)(SSL_SESSION *new_session, const SSL_SESSION *session);
2795
+ bool (*session_dup)(SSLSession *new_session, const SSLSession *session);
2720
2796
  // session_clear frees any X509-related state from `session`.
2721
- void (*session_clear)(SSL_SESSION *session);
2797
+ void (*session_clear)(SSLSession *session);
2722
2798
  // session_verify_cert_chain verifies the certificate chain in `session`,
2723
2799
  // sets `session->verify_result` and returns true on success or false on
2724
2800
  // error.
2725
- bool (*session_verify_cert_chain)(SSL_SESSION *session, SSL_HANDSHAKE *ssl,
2801
+ bool (*session_verify_cert_chain)(SSLSession *session, SSL_HANDSHAKE *ssl,
2726
2802
  uint8_t *out_alert);
2727
2803
 
2728
2804
  // hs_flush_cached_ca_names drops any cached `X509_NAME`s from `hs`.
@@ -2776,6 +2852,8 @@ struct CertCompressionAlg {
2776
2852
  uint16_t alg_id = 0;
2777
2853
  };
2778
2854
 
2855
+ // TODO(crbug.com/565766495): Switch this to `SSLSession`. bssl_shim calls
2856
+ // `lh_SSL_SESSION_*` directly, so this is still defined on the public type.
2779
2857
  DEFINE_LHASH_OF(SSL_SESSION)
2780
2858
 
2781
2859
  // An ssl_shutdown_t describes the shutdown state of one end of the connection,
@@ -2927,11 +3005,6 @@ struct SSL3_STATE {
2927
3005
  // HelloRetryRequest message.
2928
3006
  bool used_hello_retry_request : 1;
2929
3007
 
2930
- // was_key_usage_invalid is whether the handshake succeeded despite using a
2931
- // TLS mode which was incompatible with the leaf certificate's keyUsage
2932
- // extension.
2933
- bool was_key_usage_invalid : 1;
2934
-
2935
3008
  // server_sent_requested_padding is true iff a client requested padding
2936
3009
  // through the server padding extension, and the server sent back the
2937
3010
  // requested amount of padding.
@@ -2985,7 +3058,7 @@ struct SSL3_STATE {
2985
3058
  // established_session is the session established by the connection. This
2986
3059
  // session is only filled upon the completion of the handshake and is
2987
3060
  // immutable.
2988
- UniquePtr<SSL_SESSION> established_session;
3061
+ UniquePtr<SSLSession> established_session;
2989
3062
 
2990
3063
  // Next protocol negotiation. For the client, this is the protocol that we
2991
3064
  // sent in NextProtocol and is set when handling ServerHello extensions.
@@ -3083,7 +3156,7 @@ class DTLSMessageBitmap {
3083
3156
  size_t first_unmarked_byte_ = 0;
3084
3157
  };
3085
3158
 
3086
- struct hm_header_st {
3159
+ struct DTLSHandshakeHeader {
3087
3160
  uint8_t type;
3088
3161
  uint32_t msg_len;
3089
3162
  uint16_t seq;
@@ -3093,24 +3166,59 @@ struct hm_header_st {
3093
3166
 
3094
3167
  // An DTLSIncomingMessage is an incoming DTLS message, possibly not yet
3095
3168
  // assembled.
3096
- struct DTLSIncomingMessage {
3169
+ class DTLSIncomingMessage {
3170
+ public:
3097
3171
  static constexpr bool kAllowUniquePtr = true;
3098
3172
 
3099
- Span<uint8_t> msg() { return Span(data).subspan(DTLS1_HM_HEADER_LENGTH); }
3100
- Span<const uint8_t> msg() const {
3101
- return Span(data).subspan(DTLS1_HM_HEADER_LENGTH);
3173
+ explicit DTLSIncomingMessage(const DTLSHandshakeHeader &hdr);
3174
+
3175
+ uint8_t type() const { return type_; }
3176
+ uint16_t seq() const { return seq_; }
3177
+ size_t msg_len() const {
3178
+ return std::holds_alternative<FragmentList>(msg_)
3179
+ ? std::get<FragmentList>(msg_).msg_len
3180
+ : std::get<ReassemblyBuffer>(msg_).msg.size() -
3181
+ DTLS1_HM_HEADER_LENGTH;
3102
3182
  }
3103
- size_t msg_len() const { return msg().size(); }
3104
-
3105
- // type is the type of the message.
3106
- uint8_t type = 0;
3107
- // seq is the sequence number of this message.
3108
- uint16_t seq = 0;
3109
- // data contains the message, including the message header of length
3110
- // `DTLS1_HM_HEADER_LENGTH`.
3111
- Array<uint8_t> data;
3112
- // reassembly tracks which parts of the message have been received.
3113
- DTLSMessageBitmap reassembly;
3183
+
3184
+ // AddFragment adds the fragment to the incoming message. It returns true on
3185
+ // success and false on error. The caller must have checked that `offset` and
3186
+ // `data` fit in the message body.
3187
+ bool AddFragment(uint32_t offset, Span<const uint8_t> data);
3188
+
3189
+ // IsComplete returns whether the incoming message is complete.
3190
+ bool IsComplete() const;
3191
+
3192
+ // GetMessage returns the message as an SSLMessage if complete, and
3193
+ // std::nullopt otherwise.
3194
+ std::optional<SSLMessage> GetMessage() const;
3195
+
3196
+ private:
3197
+ struct FragmentList {
3198
+ // fragments contains fragment data in order of 24-bit offset, 24-bit
3199
+ // length, data.
3200
+ Vector<uint8_t> fragments;
3201
+ // msg_len contains the length of the handshake message.
3202
+ uint32_t msg_len;
3203
+ };
3204
+
3205
+ struct ReassemblyBuffer {
3206
+ void AddFragment(uint32_t offset, Span<const uint8_t> data);
3207
+
3208
+ // msg holds the message data, including `DTLS1_HM_HEADER_LENGTH` bytes
3209
+ // of reconstructed header.
3210
+ Array<uint8_t> msg;
3211
+ // reassembly tracks which parts of the message have been received.
3212
+ DTLSMessageBitmap reassembly;
3213
+ };
3214
+
3215
+ uint8_t type_;
3216
+ uint16_t seq_;
3217
+ // msg_ holds the message data. Before enough data has been received for the
3218
+ // message to be complete, it stores a FragmentList, which is proportional to
3219
+ // total data received. Once the message might be complete, it switches to
3220
+ // ReassemblyBuffer, which is proportional to the final amount.
3221
+ std::variant<FragmentList, ReassemblyBuffer> msg_;
3114
3222
  };
3115
3223
 
3116
3224
  struct DTLSOutgoingMessage {
@@ -3351,11 +3459,11 @@ struct ALPSConfig {
3351
3459
  struct SSL_CONFIG {
3352
3460
  static constexpr bool kAllowUniquePtr = true;
3353
3461
 
3354
- explicit SSL_CONFIG(SSL *ssl_arg);
3462
+ explicit SSL_CONFIG(SSLImpl *ssl_arg);
3355
3463
  ~SSL_CONFIG();
3356
3464
 
3357
3465
  // ssl is a non-owning pointer to the parent `SSL` object.
3358
- SSL *const ssl = nullptr;
3466
+ SSLImpl *const ssl = nullptr;
3359
3467
 
3360
3468
  // conf_max_version is the maximum acceptable version configured by
3361
3469
  // `SSL_set_max_proto_version`. Note this version is not normalized in DTLS
@@ -3370,7 +3478,10 @@ struct SSL_CONFIG {
3370
3478
  X509_VERIFY_PARAM *param = nullptr;
3371
3479
 
3372
3480
  // crypto
3373
- UniquePtr<SSLCipherPreferenceList> cipher_list;
3481
+ UniquePtr<SSLCipherPreferenceList> cipher_list; // for TLS 1.2 ciphers.
3482
+
3483
+ // Inherited from `SSL_CTX`.
3484
+ SSLCipherPreferenceList tls13_cipher_list;
3374
3485
 
3375
3486
  // This is used to hold the local certificate used (i.e. the server
3376
3487
  // certificate for a server or the client certificate for a client).
@@ -3490,6 +3601,10 @@ struct SSL_CONFIG {
3490
3601
  // ClientHello.
3491
3602
  bool ech_grease_enabled : 1;
3492
3603
 
3604
+ // reject_unusable_ech_config controls whether the client will fail the
3605
+ // handshake if ECH cannot be offered.
3606
+ bool reject_unusable_ech_config : 1;
3607
+
3493
3608
  // Enable signed certificate time stamps. Currently client only.
3494
3609
  bool signed_cert_timestamps_enabled : 1;
3495
3610
 
@@ -3501,11 +3616,6 @@ struct SSL_CONFIG {
3501
3616
  // that we'll accept Channel IDs from clients. It is ignored on the client.
3502
3617
  bool channel_id_enabled : 1;
3503
3618
 
3504
- // If enforce_rsa_key_usage is true, the handshake will fail if the
3505
- // keyUsage extension is present and incompatible with the TLS usage.
3506
- // This field is not read until after certificate verification.
3507
- bool enforce_rsa_key_usage : 1;
3508
-
3509
3619
  // retain_only_sha256_of_client_certs is true if we should compute the SHA256
3510
3620
  // hash of the peer's certificate and then discard it to save memory and
3511
3621
  // session space. Only effective on the server side.
@@ -3532,15 +3642,6 @@ struct SSL_CONFIG {
3532
3642
  // permute_extensions is whether to permute extensions when sending messages.
3533
3643
  bool permute_extensions : 1;
3534
3644
 
3535
- // aes_hw_override if set indicates we should override checking for aes
3536
- // hardware support, and use the value in aes_hw_override_value instead.
3537
- bool aes_hw_override : 1;
3538
-
3539
- // aes_hw_override_value is used for testing to indicate the support or lack
3540
- // of support for AES hw. The value is only considered if `aes_hw_override` is
3541
- // true.
3542
- bool aes_hw_override_value : 1;
3543
-
3544
3645
  // alps_use_new_codepoint if set indicates we use new ALPS extension codepoint
3545
3646
  // to negotiate and convey application settings.
3546
3647
  bool alps_use_new_codepoint : 1;
@@ -3571,14 +3672,13 @@ bool ssl_get_new_session(SSL_HANDSHAKE *hs);
3571
3672
  // ssl_encrypt_ticket encrypt a ticket for `session` and writes the result to
3572
3673
  // `out`. It returns true on success and false on error. If, on success, nothing
3573
3674
  // was written to `out`, the caller should skip sending a ticket.
3574
- bool ssl_encrypt_ticket(SSL_HANDSHAKE *hs, CBB *out,
3575
- const SSL_SESSION *session);
3675
+ bool ssl_encrypt_ticket(SSL_HANDSHAKE *hs, CBB *out, const SSLSession *session);
3576
3676
 
3577
3677
  bool ssl_ctx_rotate_ticket_encryption_key(SSLContext *ctx);
3578
3678
 
3579
3679
  // ssl_session_new returns a newly-allocated blank `SSL_SESSION` or nullptr on
3580
3680
  // error.
3581
- UniquePtr<SSL_SESSION> ssl_session_new(const SSL_X509_METHOD *x509_method);
3681
+ UniquePtr<SSLSession> ssl_session_new(const SSL_X509_METHOD *x509_method);
3582
3682
 
3583
3683
  // ssl_hash_session_id returns a hash of `session_id`, suitable for a hash table
3584
3684
  // keyed on session IDs.
@@ -3586,13 +3686,14 @@ uint32_t ssl_hash_session_id(Span<const uint8_t> session_id);
3586
3686
 
3587
3687
  // SSL_SESSION_parse parses an `SSL_SESSION` from `cbs` and advances `cbs` over
3588
3688
  // the parsed data.
3589
- OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_parse(
3590
- CBS *cbs, const SSL_X509_METHOD *x509_method, CRYPTO_BUFFER_POOL *pool);
3689
+ UniquePtr<SSLSession> SSL_SESSION_parse(CBS *cbs,
3690
+ const SSL_X509_METHOD *x509_method,
3691
+ CRYPTO_BUFFER_POOL *pool);
3591
3692
 
3592
3693
  // ssl_session_serialize writes `in` to `cbb` as if it were serialising a
3593
3694
  // session for Session-ID resumption. It returns true on success and false on
3594
3695
  // error.
3595
- OPENSSL_EXPORT bool ssl_session_serialize(const SSL_SESSION *in, CBB *cbb);
3696
+ bool ssl_session_serialize(const SSLSession *in, CBB *cbb);
3596
3697
 
3597
3698
  enum class SSLSessionType {
3598
3699
  // The session is not resumable.
@@ -3606,35 +3707,38 @@ enum class SSLSessionType {
3606
3707
  };
3607
3708
 
3608
3709
  // ssl_session_get_type returns the type of `session`.
3609
- SSLSessionType ssl_session_get_type(const SSL_SESSION *session);
3710
+ SSLSessionType ssl_session_get_type(const SSLSession *session);
3610
3711
 
3611
3712
  // ssl_session_is_context_valid returns whether `session`'s session ID context
3612
3713
  // matches the one set on `hs`.
3613
3714
  bool ssl_session_is_context_valid(const SSL_HANDSHAKE *hs,
3614
- const SSL_SESSION *session);
3715
+ const SSLSession *session);
3615
3716
 
3616
3717
  // ssl_session_is_time_valid returns true if `session` is still valid and false
3617
3718
  // if it has expired.
3618
- bool ssl_session_is_time_valid(const SSL *ssl, const SSL_SESSION *session);
3719
+ bool ssl_session_is_time_valid(const SSLImpl *ssl, const SSLSession *session);
3619
3720
 
3620
3721
  // ssl_session_is_resumable returns whether `session` is resumable for `hs`.
3621
3722
  bool ssl_session_is_resumable(const SSL_HANDSHAKE *hs,
3622
- const SSL_SESSION *session);
3723
+ const SSLSession *session);
3623
3724
 
3624
3725
  // ssl_session_protocol_version returns the protocol version associated with
3625
3726
  // `session`. Note that despite the name, this is not the same as
3626
3727
  // `SSL_SESSION_get_protocol_version`. The latter is based on upstream's name.
3627
- uint16_t ssl_session_protocol_version(const SSL_SESSION *session);
3728
+ uint16_t ssl_session_protocol_version(const SSLSession *session);
3628
3729
 
3629
3730
  // ssl_session_get_digest returns the digest used in `session`.
3630
- const EVP_MD *ssl_session_get_digest(const SSL_SESSION *session);
3731
+ const EVP_MD *ssl_session_get_digest(const SSLSession *session);
3631
3732
 
3632
3733
  // ssl_session_has_peer_cred returns whether `session` contains the peer's
3633
3734
  // (non-PSK) credentials (either X.509 cert chain or raw public key, depending
3634
3735
  // on the peer's certificate type) or a valid SHA-256 hash thereof.
3635
- bool ssl_session_has_peer_cred(const SSL_SESSION *session);
3736
+ bool ssl_session_has_peer_cred(const SSLSession *session);
3636
3737
 
3637
- void ssl_set_session(SSL *ssl, SSL_SESSION *session);
3738
+ void ssl_set_session(SSLImpl *ssl, SSLSession *session);
3739
+
3740
+ // ssl_get_session implements `SSL_get_session`.
3741
+ SSLSession *ssl_get_session(const SSLImpl *ssl);
3638
3742
 
3639
3743
  // ssl_get_prev_session looks up the previous session based on `client_hello`.
3640
3744
  // On success, it sets `*out_session` to the session or nullptr if none was
@@ -3643,7 +3747,7 @@ void ssl_set_session(SSL *ssl, SSL_SESSION *session);
3643
3747
  // decrypted immediately it returns `ssl_hs_pending_ticket` and should also
3644
3748
  // be called again. Otherwise, it returns `ssl_hs_error`.
3645
3749
  enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
3646
- UniquePtr<SSL_SESSION> *out_session,
3750
+ UniquePtr<SSLSession> *out_session,
3647
3751
  bool *out_tickets_supported,
3648
3752
  bool *out_renew_ticket,
3649
3753
  const SSL_CLIENT_HELLO *client_hello);
@@ -3658,82 +3762,84 @@ enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
3658
3762
  // SSL_SESSION_dup returns a newly-allocated `SSL_SESSION` with a copy of the
3659
3763
  // fields in `session` or nullptr on error. The new session is non-resumable and
3660
3764
  // must be explicitly marked resumable once it has been filled in.
3661
- OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_dup(
3662
- const SSL_SESSION *session, int dup_flags);
3765
+ UniquePtr<SSLSession> SSL_SESSION_dup(const SSLSession *session, int dup_flags);
3663
3766
 
3664
3767
  // ssl_session_rebase_time updates `session`'s start time to the current time,
3665
3768
  // adjusting the timeout so the expiration time is unchanged.
3666
- void ssl_session_rebase_time(SSL *ssl, SSL_SESSION *session);
3769
+ void ssl_session_rebase_time(SSLImpl *ssl, SSLSession *session);
3667
3770
 
3668
3771
  // ssl_session_renew_timeout calls `ssl_session_rebase_time` and renews
3669
3772
  // `session`'s timeout to `timeout` (measured from the current time). The
3670
3773
  // renewal is clamped to the session's auth_timeout.
3671
- void ssl_session_renew_timeout(SSL *ssl, SSL_SESSION *session,
3774
+ void ssl_session_renew_timeout(SSLImpl *ssl, SSLSession *session,
3672
3775
  uint32_t timeout);
3673
3776
 
3674
- void ssl_update_cache(SSL *ssl);
3777
+ void ssl_update_cache(SSLImpl *ssl);
3675
3778
 
3676
- void ssl_send_alert(SSL *ssl, int level, int desc);
3677
- int ssl_send_alert_impl(SSL *ssl, int level, int desc);
3678
- bool tls_get_message(const SSL *ssl, SSLMessage *out);
3679
- ssl_open_record_t tls_open_handshake(SSL *ssl, size_t *out_consumed,
3779
+ void ssl_send_alert(SSLImpl *ssl, int level, int desc);
3780
+ int ssl_send_alert_impl(SSLImpl *ssl, int level, int desc);
3781
+ bool tls_get_message(const SSLImpl *ssl, SSLMessage *out);
3782
+ ssl_open_record_t tls_open_handshake(SSLImpl *ssl, size_t *out_consumed,
3680
3783
  uint8_t *out_alert, Span<uint8_t> in);
3681
- void tls_next_message(SSL *ssl);
3784
+ void tls_next_message(SSLImpl *ssl);
3682
3785
 
3683
- int tls_dispatch_alert(SSL *ssl);
3684
- ssl_open_record_t tls_open_app_data(SSL *ssl, Span<uint8_t> *out,
3786
+ int tls_dispatch_alert(SSLImpl *ssl);
3787
+ ssl_open_record_t tls_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
3685
3788
  size_t *out_consumed, uint8_t *out_alert,
3686
3789
  Span<uint8_t> in);
3687
- ssl_open_record_t tls_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
3790
+ ssl_open_record_t tls_open_change_cipher_spec(SSLImpl *ssl,
3791
+ size_t *out_consumed,
3688
3792
  uint8_t *out_alert,
3689
3793
  Span<uint8_t> in);
3690
- int tls_write_app_data(SSL *ssl, bool *out_needs_handshake,
3794
+ int tls_write_app_data(SSLImpl *ssl, bool *out_needs_handshake,
3691
3795
  size_t *out_bytes_written, Span<const uint8_t> in);
3692
3796
 
3693
- bool tls_new(SSL *ssl);
3694
- void tls_free(SSL *ssl);
3797
+ bool tls_new(SSLImpl *ssl);
3798
+ void tls_free(SSLImpl *ssl);
3695
3799
 
3696
- bool tls_init_message(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
3697
- bool tls_finish_message(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
3698
- bool tls_add_message(SSL *ssl, Array<uint8_t> msg);
3699
- bool tls_add_change_cipher_spec(SSL *ssl);
3700
- int tls_flush(SSL *ssl);
3800
+ bool tls_init_message(const SSLImpl *ssl, CBB *cbb, CBB *body, uint8_t type);
3801
+ bool tls_finish_message(const SSLImpl *ssl, CBB *cbb, Array<uint8_t> *out_msg);
3802
+ bool tls_add_message(SSLImpl *ssl, Array<uint8_t> msg);
3803
+ bool tls_add_change_cipher_spec(SSLImpl *ssl);
3804
+ int tls_flush(SSLImpl *ssl);
3701
3805
 
3702
- bool dtls1_init_message(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
3703
- bool dtls1_finish_message(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
3704
- bool dtls1_add_message(SSL *ssl, Array<uint8_t> msg);
3705
- bool dtls1_add_change_cipher_spec(SSL *ssl);
3706
- void dtls1_finish_flight(SSL *ssl);
3707
- void dtls1_schedule_ack(SSL *ssl);
3708
- int dtls1_flush(SSL *ssl);
3806
+ bool dtls1_init_message(const SSLImpl *ssl, CBB *cbb, CBB *body, uint8_t type);
3807
+ bool dtls1_finish_message(const SSLImpl *ssl, CBB *cbb,
3808
+ Array<uint8_t> *out_msg);
3809
+ bool dtls1_add_message(SSLImpl *ssl, Array<uint8_t> msg);
3810
+ bool dtls1_add_change_cipher_spec(SSLImpl *ssl);
3811
+ void dtls1_finish_flight(SSLImpl *ssl);
3812
+ void dtls1_schedule_ack(SSLImpl *ssl);
3813
+ int dtls1_flush(SSLImpl *ssl);
3709
3814
 
3710
3815
  // ssl_add_message_cbb finishes the handshake message in `cbb` and adds it to
3711
3816
  // the pending flight. It returns true on success and false on error.
3712
- bool ssl_add_message_cbb(SSL *ssl, CBB *cbb);
3817
+ bool ssl_add_message_cbb(SSLImpl *ssl, CBB *cbb);
3713
3818
 
3714
3819
  // ssl_hash_message incorporates `msg` into the handshake hash. It returns true
3715
3820
  // on success and false on allocation failure.
3716
3821
  bool ssl_hash_message(SSL_HANDSHAKE *hs, const SSLMessage &msg);
3717
3822
 
3718
- ssl_open_record_t dtls1_process_ack(SSL *ssl, uint8_t *out_alert,
3823
+ ssl_open_record_t dtls1_process_ack(SSLImpl *ssl, uint8_t *out_alert,
3719
3824
  DTLSRecordNumber ack_record_number,
3720
3825
  Span<const uint8_t> data);
3721
- ssl_open_record_t dtls1_open_app_data(SSL *ssl, Span<uint8_t> *out,
3826
+ ssl_open_record_t dtls1_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
3722
3827
  size_t *out_consumed, uint8_t *out_alert,
3723
3828
  Span<uint8_t> in);
3724
- ssl_open_record_t dtls1_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
3829
+ ssl_open_record_t dtls1_open_change_cipher_spec(SSLImpl *ssl,
3830
+ size_t *out_consumed,
3725
3831
  uint8_t *out_alert,
3726
3832
  Span<uint8_t> in);
3727
3833
 
3728
- int dtls1_write_app_data(SSL *ssl, bool *out_needs_handshake,
3834
+ int dtls1_write_app_data(SSLImpl *ssl, bool *out_needs_handshake,
3729
3835
  size_t *out_bytes_written, Span<const uint8_t> in);
3730
3836
 
3731
3837
  // dtls1_write_record sends a record. It returns one on success and <= 0 on
3732
3838
  // error.
3733
- int dtls1_write_record(SSL *ssl, int type, Span<const uint8_t> in,
3839
+ int dtls1_write_record(SSLImpl *ssl, int type, Span<const uint8_t> in,
3734
3840
  uint16_t epoch);
3735
3841
 
3736
- bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
3842
+ bool dtls1_parse_fragment(CBS *cbs, DTLSHandshakeHeader *out_hdr,
3737
3843
  CBS *out_body);
3738
3844
 
3739
3845
  // DTLS1_MTU_TIMEOUTS is the maximum number of retransmit timeouts to expire
@@ -3744,30 +3850,30 @@ bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
3744
3850
  // before failing the DTLS handshake.
3745
3851
  #define DTLS1_MAX_TIMEOUTS 12
3746
3852
 
3747
- void dtls1_stop_timer(SSL *ssl);
3853
+ void dtls1_stop_timer(SSLImpl *ssl);
3748
3854
 
3749
3855
  unsigned int dtls1_min_mtu();
3750
3856
 
3751
- bool dtls1_new(SSL *ssl);
3752
- void dtls1_free(SSL *ssl);
3857
+ bool dtls1_new(SSLImpl *ssl);
3858
+ void dtls1_free(SSLImpl *ssl);
3753
3859
 
3754
- bool dtls1_process_handshake_fragments(SSL *ssl, uint8_t *out_alert,
3860
+ bool dtls1_process_handshake_fragments(SSLImpl *ssl, uint8_t *out_alert,
3755
3861
  DTLSRecordNumber record_number,
3756
3862
  Span<const uint8_t> record);
3757
- bool dtls1_get_message(const SSL *ssl, SSLMessage *out);
3758
- ssl_open_record_t dtls1_open_handshake(SSL *ssl, size_t *out_consumed,
3863
+ bool dtls1_get_message(const SSLImpl *ssl, SSLMessage *out);
3864
+ ssl_open_record_t dtls1_open_handshake(SSLImpl *ssl, size_t *out_consumed,
3759
3865
  uint8_t *out_alert, Span<uint8_t> in);
3760
- void dtls1_next_message(SSL *ssl);
3761
- int dtls1_dispatch_alert(SSL *ssl);
3866
+ void dtls1_next_message(SSLImpl *ssl);
3867
+ int dtls1_dispatch_alert(SSLImpl *ssl);
3762
3868
 
3763
3869
  // tls1_configure_aead configures either the read or write direction AEAD (as
3764
3870
  // determined by `direction`) using the keys generated by the TLS KDF. The
3765
3871
  // `key_block_cache` argument is used to store the generated key block, if
3766
3872
  // empty. Otherwise it's assumed that the key block is already contained within
3767
3873
  // it. It returns true on success or false on error.
3768
- bool tls1_configure_aead(SSL *ssl, evp_aead_direction_t direction,
3874
+ bool tls1_configure_aead(SSLImpl *ssl, evp_aead_direction_t direction,
3769
3875
  Array<uint8_t> *key_block_cache,
3770
- const SSL_SESSION *session,
3876
+ const SSLSession *session,
3771
3877
  Span<const uint8_t> iv_override);
3772
3878
 
3773
3879
  bool tls1_change_cipher_state(SSL_HANDSHAKE *hs,
@@ -3818,7 +3924,7 @@ bool ssl_parse_serverhello_tlsext(SSL_HANDSHAKE *hs, const CBS *extensions);
3818
3924
  // If `save_ticket` is true, `*out_session` will have a copy of the ticket saved
3819
3925
  // in its `ticket` field.
3820
3926
  enum ssl_ticket_aead_result_t ssl_process_ticket(
3821
- SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
3927
+ SSL_HANDSHAKE *hs, UniquePtr<SSLSession> *out_session,
3822
3928
  bool *out_renew_ticket, Span<const uint8_t> ticket,
3823
3929
  Span<const uint8_t> session_id, bool save_ticket);
3824
3930
 
@@ -3843,45 +3949,20 @@ bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len);
3843
3949
  bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs);
3844
3950
 
3845
3951
  // ssl_can_write returns whether `ssl` is allowed to write.
3846
- bool ssl_can_write(const SSL *ssl);
3952
+ bool ssl_can_write(const SSLImpl *ssl);
3847
3953
 
3848
3954
  // ssl_can_read returns whether `ssl` is allowed to read.
3849
- bool ssl_can_read(const SSL *ssl);
3955
+ bool ssl_can_read(const SSLImpl *ssl);
3850
3956
 
3851
3957
  OPENSSL_timeval ssl_ctx_get_current_time(const SSLContext *ctx);
3852
3958
 
3853
3959
  // ssl_reset_error_state resets state for `SSL_get_error`.
3854
- void ssl_reset_error_state(SSL *ssl);
3960
+ void ssl_reset_error_state(SSLImpl *ssl);
3855
3961
 
3856
3962
  // ssl_set_read_error sets `ssl`'s read half into an error state, saving the
3857
3963
  // current state of the error queue.
3858
- void ssl_set_read_error(SSL *ssl);
3859
-
3860
- BSSL_NAMESPACE_END
3964
+ void ssl_set_read_error(SSLImpl *ssl);
3861
3965
 
3862
-
3863
- // Opaque C types.
3864
- //
3865
- // The following types are exported to C code as public typedefs, so they must
3866
- // be defined outside of the namespace.
3867
- //
3868
- // TODO(crbug.com/500444613): Move these to the bssl namespace.
3869
-
3870
- // ssl_method_st backs the public `SSL_METHOD` type. It is a compatibility
3871
- // structure to support the legacy version-locked methods.
3872
- struct ssl_method_st {
3873
- // version, if non-zero, is the only protocol version acceptable to an
3874
- // SSL_CTX initialized from this method.
3875
- uint16_t version;
3876
- // method is the underlying SSL_PROTOCOL_METHOD that initializes the
3877
- // SSL_CTX.
3878
- const bssl::SSL_PROTOCOL_METHOD *method;
3879
- // x509_method contains pointers to functions that might deal with `X509`
3880
- // compatibility, or might be a no-op, depending on the application.
3881
- const bssl::SSL_X509_METHOD *x509_method;
3882
- };
3883
-
3884
- BSSL_NAMESPACE_BEGIN
3885
3966
  class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
3886
3967
  public:
3887
3968
  explicit SSLContext(const SSL_METHOD *ssl_method);
@@ -3912,15 +3993,17 @@ class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
3912
3993
  // quic_method is the method table corresponding to the QUIC hooks.
3913
3994
  const SSL_QUIC_METHOD *quic_method = nullptr;
3914
3995
 
3915
- UniquePtr<SSLCipherPreferenceList> cipher_list;
3996
+ UniquePtr<SSLCipherPreferenceList> cipher_list; // for TLS 1.2 ciphers.
3997
+ SSLCipherPreferenceList tls13_cipher_list;
3916
3998
 
3917
3999
  X509_STORE *cert_store = nullptr;
4000
+ // TODO(crbug.com/565766495): Switch this to `SSLSession`.
3918
4001
  LHASH_OF(SSL_SESSION) *sessions = nullptr;
3919
4002
  // Most session-ids that will be cached, default is
3920
4003
  // SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.
3921
4004
  unsigned long session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT;
3922
- SSL_SESSION *session_cache_head = nullptr;
3923
- SSL_SESSION *session_cache_tail = nullptr;
4005
+ SSLSession *session_cache_head = nullptr;
4006
+ SSLSession *session_cache_tail = nullptr;
3924
4007
 
3925
4008
  // handshakes_since_cache_flush is the number of successful handshakes since
3926
4009
  // the last cache flush.
@@ -4172,6 +4255,11 @@ class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
4172
4255
  // grease_enabled is whether GREASE (RFC 8701) is enabled.
4173
4256
  bool grease_enabled : 1;
4174
4257
 
4258
+ // grease_sigalgs_enabled controls whether GREASE signature algorithms may be
4259
+ // sent.
4260
+ // TODO(crbug.com/526597789): Fold into `grease_enabled` once deployed safely.
4261
+ bool grease_sigalgs_enabled : 1;
4262
+
4175
4263
  // permute_extensions is whether to permute extensions when sending messages.
4176
4264
  bool permute_extensions : 1;
4177
4265
 
@@ -4191,15 +4279,6 @@ class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
4191
4279
  // If enable_early_data is true, early data can be sent and accepted.
4192
4280
  bool enable_early_data : 1;
4193
4281
 
4194
- // aes_hw_override if set indicates we should override checking for AES
4195
- // hardware support, and use the value in aes_hw_override_value instead.
4196
- bool aes_hw_override : 1;
4197
-
4198
- // aes_hw_override_value is used for testing to indicate the support or lack
4199
- // of support for AES hardware. The value is only considered if
4200
- // `aes_hw_override` is true.
4201
- bool aes_hw_override_value : 1;
4202
-
4203
4282
  // resumption_across_names_enabled indicates whether a TLS 1.3 server should
4204
4283
  // signal its sessions may be resumed across names in the server certificate.
4205
4284
  bool resumption_across_names_enabled : 1;
@@ -4208,39 +4287,41 @@ class SSLContext : public ssl_ctx_st, public RefCounted<SSLContext> {
4208
4287
  friend RefCounted;
4209
4288
  ~SSLContext();
4210
4289
  };
4211
- BSSL_NAMESPACE_END
4212
4290
 
4213
- struct ssl_st {
4214
- explicit ssl_st(bssl::SSLContext *ctx_arg);
4215
- ssl_st(const ssl_st &) = delete;
4216
- ssl_st &operator=(const ssl_st &) = delete;
4217
- ~ssl_st();
4291
+ class SSLImpl : public ssl_st {
4292
+ public:
4293
+ static constexpr bool kAllowUniquePtr = true;
4294
+
4295
+ explicit SSLImpl(SSLContext *ctx_arg);
4296
+ SSLImpl(const SSLImpl &) = delete;
4297
+ SSLImpl &operator=(const SSLImpl &) = delete;
4298
+ ~SSLImpl();
4218
4299
 
4219
4300
  // method is the method table corresponding to the current protocol (DTLS or
4220
4301
  // TLS).
4221
- const bssl::SSL_PROTOCOL_METHOD *method = nullptr;
4302
+ const SSL_PROTOCOL_METHOD *method = nullptr;
4222
4303
 
4223
4304
  // config is a container for handshake configuration. Accesses to this field
4224
4305
  // should check for nullptr, since configuration may be shed after the
4225
4306
  // handshake completes. (If you have the `SSL_HANDSHAKE` object at hand, use
4226
4307
  // that instead, and skip the null check.)
4227
- bssl::UniquePtr<bssl::SSL_CONFIG> config;
4308
+ UniquePtr<SSL_CONFIG> config;
4228
4309
 
4229
4310
  uint16_t max_send_fragment = 0;
4230
4311
 
4231
4312
  // There are 2 BIO's even though they are normally both the same. This is so
4232
4313
  // data can be read and written to different handlers
4233
4314
 
4234
- bssl::UniquePtr<BIO> rbio; // used by SSL_read
4235
- bssl::UniquePtr<BIO> wbio; // used by SSL_write
4315
+ UniquePtr<BIO> rbio; // used by SSL_read
4316
+ UniquePtr<BIO> wbio; // used by SSL_write
4236
4317
 
4237
4318
  // do_handshake runs the handshake. On completion, it returns `ssl_hs_ok`.
4238
4319
  // Otherwise, it returns a value corresponding to what operation is needed to
4239
4320
  // progress.
4240
- bssl::ssl_hs_wait_t (*do_handshake)(bssl::SSL_HANDSHAKE *hs) = nullptr;
4321
+ ssl_hs_wait_t (*do_handshake)(SSL_HANDSHAKE *hs) = nullptr;
4241
4322
 
4242
- bssl::SSL3_STATE *s3 = nullptr; // TLS variables
4243
- bssl::DTLS1_STATE *d1 = nullptr; // DTLS variables
4323
+ SSL3_STATE *s3 = nullptr; // TLS variables
4324
+ DTLS1_STATE *d1 = nullptr; // DTLS variables
4244
4325
 
4245
4326
  // callback that allows applications to peek at protocol messages
4246
4327
  void (*msg_callback)(int write_p, int version, int content_type,
@@ -4257,15 +4338,15 @@ struct ssl_st {
4257
4338
 
4258
4339
  // session is the configured session to be offered by the client. This session
4259
4340
  // is immutable.
4260
- bssl::UniquePtr<SSL_SESSION> session;
4341
+ UniquePtr<SSLSession> session;
4261
4342
 
4262
4343
  void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
4263
4344
 
4264
- bssl::UniquePtr<bssl::SSLContext> ctx;
4345
+ UniquePtr<SSLContext> ctx;
4265
4346
 
4266
4347
  // session_ctx is the `SSLContext` used for the session cache and related
4267
4348
  // settings.
4268
- bssl::UniquePtr<bssl::SSLContext> session_ctx;
4349
+ UniquePtr<SSLContext> session_ctx;
4269
4350
 
4270
4351
  // extra application data
4271
4352
  CRYPTO_EX_DATA ex_data;
@@ -4273,7 +4354,7 @@ struct ssl_st {
4273
4354
  uint32_t options = 0; // protocol behaviour
4274
4355
  uint32_t mode = 0; // API behaviour
4275
4356
  uint32_t max_cert_list = 0;
4276
- bssl::UniquePtr<char> hostname;
4357
+ UniquePtr<char> hostname;
4277
4358
 
4278
4359
  // quic_method is the method table corresponding to the QUIC hooks.
4279
4360
  const SSL_QUIC_METHOD *quic_method = nullptr;
@@ -4281,7 +4362,7 @@ struct ssl_st {
4281
4362
  // renegotiate_mode controls how peer renegotiation attempts are handled.
4282
4363
  ssl_renegotiate_mode_t renegotiate_mode = ssl_renegotiate_never;
4283
4364
 
4284
- // server is true iff the this SSL* is the server half. Note: before the SSL*
4365
+ // server is true iff this SSL* is the server half. Note: before the SSL*
4285
4366
  // is initialized by either SSL_set_accept_state or SSL_set_connect_state,
4286
4367
  // the side is not determined. In this state, server is always false.
4287
4368
  bool server : 1;
@@ -4298,10 +4379,11 @@ struct ssl_st {
4298
4379
  bool resumption_across_names_enabled : 1;
4299
4380
  };
4300
4381
 
4301
- struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4302
- explicit ssl_session_st(const bssl::SSL_X509_METHOD *method);
4303
- ssl_session_st(const ssl_session_st &) = delete;
4304
- ssl_session_st &operator=(const ssl_session_st &) = delete;
4382
+ class SSLSession : public ssl_session_st, public RefCounted<SSLSession> {
4383
+ public:
4384
+ explicit SSLSession(const SSL_X509_METHOD *method);
4385
+ SSLSession(const SSLSession &) = delete;
4386
+ SSLSession &operator=(const SSLSession &) = delete;
4305
4387
 
4306
4388
  // ssl_version is the (D)TLS version that established the session.
4307
4389
  uint16_t ssl_version = 0;
@@ -4318,22 +4400,22 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4318
4400
  // session. In TLS 1.3 and up, it is the resumption PSK for sessions handed to
4319
4401
  // the caller, but it stores the resumption secret when stored on `SSL`
4320
4402
  // objects.
4321
- bssl::InplaceVector<uint8_t, SSL_MAX_MASTER_KEY_LENGTH> secret;
4403
+ InplaceVector<uint8_t, SSL_MAX_MASTER_KEY_LENGTH> secret;
4322
4404
 
4323
- bssl::InplaceVector<uint8_t, SSL_MAX_SSL_SESSION_ID_LENGTH> session_id;
4405
+ InplaceVector<uint8_t, SSL_MAX_SSL_SESSION_ID_LENGTH> session_id;
4324
4406
 
4325
4407
  // this is used to determine whether the session is being reused in
4326
4408
  // the appropriate context. It is up to the application to set this,
4327
4409
  // via SSL_new
4328
- bssl::InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
4410
+ InplaceVector<uint8_t, SSL_MAX_SID_CTX_LENGTH> sid_ctx;
4329
4411
 
4330
- bssl::UniquePtr<char> psk_identity;
4412
+ UniquePtr<char> psk_identity;
4331
4413
 
4332
4414
  // certs contains the certificate chain from the peer, starting with the leaf
4333
4415
  // certificate. This must be null if `peer_raw_public_key` is non-null.
4334
- bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> certs;
4416
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> certs;
4335
4417
 
4336
- const bssl::SSL_X509_METHOD *x509_method = nullptr;
4418
+ const SSL_X509_METHOD *x509_method = nullptr;
4337
4419
 
4338
4420
  // x509_peer is the peer's certificate. This must be null if
4339
4421
  // `peer_raw_public_key` is non-null.
@@ -4375,14 +4457,19 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4375
4457
 
4376
4458
  // These are used to make removal of session-ids more efficient and to
4377
4459
  // implement a maximum cache size.
4378
- SSL_SESSION *prev = nullptr, *next = nullptr;
4460
+ //
4461
+ // TODO(crbug.com/527997772): At the ends of the list, `prev` and `next` point
4462
+ // to `session_cache_head` and `session_cache_tail` on `SSLContext`. These
4463
+ // sentinel values are not real sessions, so they must never be dereferenced
4464
+ // or converted to `SSL_SESSION`.
4465
+ SSLSession *prev = nullptr, *next = nullptr;
4379
4466
 
4380
- bssl::Array<uint8_t> ticket;
4467
+ Array<uint8_t> ticket;
4381
4468
 
4382
- bssl::UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
4469
+ UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
4383
4470
 
4384
4471
  // The OCSP response that came with the session.
4385
- bssl::UniquePtr<CRYPTO_BUFFER> ocsp_response;
4472
+ UniquePtr<CRYPTO_BUFFER> ocsp_response;
4386
4473
 
4387
4474
  // peer_sha256 contains the SHA-256 hash of the peer's X.509 certificate or
4388
4475
  // raw public key if `peer_sha256_valid` is true. (`peer_cert_type` indicates
@@ -4392,7 +4479,7 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4392
4479
  // original_handshake_hash contains the handshake hash (either SHA-1+MD5 or
4393
4480
  // SHA-2, depending on TLS version) for the original, full handshake that
4394
4481
  // created a session. This is used by Channel IDs during resumption.
4395
- bssl::InplaceVector<uint8_t, SSL_MAX_MD_SIZE> original_handshake_hash;
4482
+ InplaceVector<uint8_t, SSL_MAX_MD_SIZE> original_handshake_hash;
4396
4483
 
4397
4484
  uint32_t ticket_lifetime_hint = 0; // Session lifetime hint in seconds
4398
4485
 
@@ -4406,15 +4493,15 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4406
4493
  // stored for TLS 1.3 and above in order to enforce ALPN matching for 0-RTT
4407
4494
  // resumptions. For the current connection's ALPN protocol, see
4408
4495
  // `alpn_selected` on `SSL3_STATE`.
4409
- bssl::Array<uint8_t> early_alpn;
4496
+ Array<uint8_t> early_alpn;
4410
4497
 
4411
4498
  // local_application_settings, if `has_application_settings` is true, is the
4412
4499
  // local ALPS value for this connection.
4413
- bssl::Array<uint8_t> local_application_settings;
4500
+ Array<uint8_t> local_application_settings;
4414
4501
 
4415
4502
  // peer_application_settings, if `has_application_settings` is true, is the
4416
4503
  // peer ALPS value for this connection.
4417
- bssl::Array<uint8_t> peer_application_settings;
4504
+ Array<uint8_t> peer_application_settings;
4418
4505
 
4419
4506
  // extended_master_secret is whether the master secret in this session was
4420
4507
  // generated using EMS and thus isn't vulnerable to the Triple Handshake
@@ -4446,21 +4533,45 @@ struct ssl_session_st : public bssl::RefCounted<ssl_session_st> {
4446
4533
 
4447
4534
  // quic_early_data_context is used to determine whether early data must be
4448
4535
  // rejected when performing a QUIC handshake.
4449
- bssl::Array<uint8_t> quic_early_data_context;
4536
+ Array<uint8_t> quic_early_data_context;
4450
4537
 
4451
4538
  // peer_cert_type is the peer's cert type (`TLSEXT_cert_type_*` value), which
4452
4539
  // determines the type of Certificate the peer used for this session: which of
4453
4540
  // `certs` xor `peer_raw_public_key` is populated for an authenticated
4454
4541
  // session.
4455
- uint8_t peer_cert_type = bssl::kDefaultCertType;
4542
+ uint8_t peer_cert_type = kDefaultCertType;
4456
4543
 
4457
4544
  // peer_raw_public_key, if non-null, is the raw public key received from the
4458
4545
  // peer. This must be null if `certs` is non-null.
4459
- bssl::UniquePtr<EVP_PKEY> peer_raw_public_key;
4546
+ UniquePtr<EVP_PKEY> peer_raw_public_key;
4460
4547
 
4461
4548
  private:
4462
4549
  friend RefCounted;
4463
- ~ssl_session_st();
4550
+ ~SSLSession();
4551
+ };
4552
+
4553
+ BSSL_NAMESPACE_END
4554
+
4555
+
4556
+ // Opaque C types.
4557
+ //
4558
+ // `SSL_METHOD` is exported to C code as public typedefs, so it must be defined
4559
+ // outside of the namespace. We can switch it to `DECLARE_OPAQUE_STRUCT` if
4560
+ // becomes more complex than a plain struct.
4561
+
4562
+ // ssl_method_st backs the public `SSL_METHOD` type. It is a compatibility
4563
+ // structure to support the legacy version-locked methods.
4564
+ struct ssl_method_st {
4565
+ // version, if non-zero, is the only protocol version acceptable to an
4566
+ // SSL_CTX initialized from this method.
4567
+ uint16_t version;
4568
+ // method is the underlying SSL_PROTOCOL_METHOD that initializes the
4569
+ // SSL_CTX.
4570
+ const bssl::SSL_PROTOCOL_METHOD *method;
4571
+ // x509_method contains pointers to functions that might deal with `X509`
4572
+ // compatibility, or might be a no-op, depending on the application.
4573
+ const bssl::SSL_X509_METHOD *x509_method;
4464
4574
  };
4465
4575
 
4576
+
4466
4577
  #endif // OPENSSL_HEADER_SSL_INTERNAL_H