grpc 1.84.1 → 1.86.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1350) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +48 -31
  3. data/etc/roots.pem +0 -583
  4. data/include/grpc/channel_factory.h +78 -0
  5. data/include/grpc/credentials.h +21 -0
  6. data/include/grpc/event_engine/memory_allocator.h +1 -0
  7. data/include/grpc/grpc.h +10 -0
  8. data/include/grpc/grpc_security_constants.h +4 -0
  9. data/include/grpc/impl/channel_arg_names.h +4 -0
  10. data/include/grpc/module.modulemap +1 -0
  11. data/src/core/call/call_filters.cc +4 -1
  12. data/src/core/call/call_filters.h +13 -11
  13. data/src/core/call/call_spine.h +12 -6
  14. data/src/core/call/call_state.h +3 -3
  15. data/src/core/call/client_call.cc +4 -1
  16. data/src/core/call/client_call.h +1 -0
  17. data/src/core/{lib/security/authorization → call}/evaluate_args.cc +34 -12
  18. data/src/core/{lib/security/authorization → call}/evaluate_args.h +19 -5
  19. data/src/core/call/filter_fusion.h +17 -30
  20. data/src/core/call/interception_chain.h +5 -10
  21. data/src/core/call/metadata_batch.cc +6 -0
  22. data/src/core/call/metadata_batch.h +79 -36
  23. data/src/core/call/parsed_metadata.h +3 -3
  24. data/src/core/call/request_buffer.cc +7 -7
  25. data/src/core/call/request_buffer.h +1 -1
  26. data/src/core/call/server_call.cc +3 -3
  27. data/src/core/call/server_call.h +15 -0
  28. data/src/core/channelz/channel_trace.cc +5 -5
  29. data/src/core/channelz/channel_trace.h +1 -1
  30. data/src/core/channelz/channelz.cc +9 -9
  31. data/src/core/channelz/channelz.h +12 -12
  32. data/src/core/channelz/channelz_registry.cc +14 -14
  33. data/src/core/channelz/ztrace_collector.h +16 -7
  34. data/src/core/client_channel/backup_poller.cc +1 -2
  35. data/src/core/client_channel/channel_factory.cc +110 -0
  36. data/src/core/client_channel/channel_factory.h +45 -0
  37. data/src/core/client_channel/client_channel.cc +4 -4
  38. data/src/core/client_channel/client_channel_filter.cc +14 -14
  39. data/src/core/client_channel/global_subchannel_pool.cc +6 -6
  40. data/src/core/client_channel/lame_channel.cc +59 -0
  41. data/src/core/client_channel/lame_channel.h +86 -0
  42. data/src/core/client_channel/subchannel.cc +24 -23
  43. data/src/core/client_channel/subchannel_stream_client.cc +5 -5
  44. data/src/core/credentials/call/external/aws_external_account_credentials.cc +7 -7
  45. data/src/core/credentials/call/external/aws_request_signer.cc +18 -1
  46. data/src/core/credentials/call/external/external_account_credentials.cc +4 -4
  47. data/src/core/credentials/call/external/url_external_account_credentials.cc +6 -17
  48. data/src/core/credentials/call/external/url_external_account_credentials.h +0 -1
  49. data/src/core/credentials/call/jwt/jwt_verifier.cc +25 -13
  50. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +6 -4
  51. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +25 -9
  52. data/src/core/credentials/call/regional_access_boundary_fetcher.h +6 -2
  53. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +4 -4
  54. data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -3
  55. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +1 -1
  56. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +9 -9
  57. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +1 -1
  58. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +6 -6
  59. data/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc +3 -3
  60. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc +14 -0
  61. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.h +12 -2
  62. data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +4 -4
  63. data/src/core/credentials/transport/tls/ssl_utils.cc +30 -0
  64. data/src/core/credentials/transport/tls/ssl_utils.h +4 -0
  65. data/src/core/credentials/transport/tls/tls_security_connector.cc +16 -12
  66. data/src/core/credentials/transport/tls/tls_security_connector.h +6 -6
  67. data/src/core/credentials/transport/tls/tls_utils.h +9 -0
  68. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +1 -1
  69. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +1 -1
  70. data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +2 -2
  71. data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +1 -1
  72. data/src/core/ext/filters/http/message_compress/compression_filter.cc +15 -0
  73. data/src/core/ext/filters/http/server/http_server_filter.cc +6 -1
  74. data/src/core/ext/filters/rbac/rbac_filter.cc +3 -41
  75. data/src/core/ext/filters/rbac/rbac_filter.h +3 -12
  76. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +61 -45
  78. data/src/core/ext/transport/chttp2/server/chttp2_server.h +6 -13
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +80 -110
  80. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -1
  81. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
  82. data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -6
  83. data/src/core/ext/transport/chttp2/transport/flow_control_manager.h +1 -1
  84. data/src/core/ext/transport/chttp2/transport/frame.cc +15 -19
  85. data/src/core/ext/transport/chttp2/transport/frame.h +10 -1
  86. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +18 -61
  87. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +0 -4
  88. data/src/core/ext/transport/chttp2/transport/frame_security.cc +1 -2
  89. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +9 -0
  90. data/src/core/ext/transport/chttp2/transport/goaway.cc +1 -1
  91. data/src/core/ext/transport/chttp2/transport/goaway.h +0 -5
  92. data/src/core/ext/transport/chttp2/transport/header_assembler.h +1 -5
  93. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +3 -0
  94. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +8 -0
  95. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +45 -9
  96. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -2
  97. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +50 -37
  98. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +7 -3
  99. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +407 -267
  100. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +70 -32
  101. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +4 -3
  102. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +21 -57
  103. data/src/core/ext/transport/chttp2/transport/http2_transport.h +4 -35
  104. data/src/core/ext/transport/chttp2/transport/http2_transport_stats.h +60 -0
  105. data/src/core/ext/transport/chttp2/transport/internal.h +8 -3
  106. data/src/core/ext/transport/chttp2/transport/keepalive.h +1 -4
  107. data/src/core/ext/transport/chttp2/transport/parsing.cc +7 -10
  108. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +35 -11
  109. data/src/core/ext/transport/chttp2/transport/ping_promise.h +52 -47
  110. data/src/core/ext/transport/chttp2/transport/read_context.h +115 -8
  111. data/src/core/ext/transport/chttp2/transport/reclaimer.cc +32 -0
  112. data/src/core/ext/transport/chttp2/transport/reclaimer.h +64 -0
  113. data/src/core/ext/transport/chttp2/transport/security_frame.h +15 -14
  114. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +24 -14
  115. data/src/core/ext/transport/chttp2/transport/transport_common.cc +47 -0
  116. data/src/core/ext/transport/chttp2/transport/transport_common.h +29 -0
  117. data/src/core/ext/transport/chttp2/transport/writable_streams.h +1 -1
  118. data/src/core/ext/transport/chttp2/transport/write_cycle.h +23 -3
  119. data/src/core/ext/transport/inproc/inproc_transport.cc +5 -5
  120. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +1 -7
  121. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb.h +16 -0
  122. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb_minitable.c +4 -3
  123. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb.h +129 -81
  124. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb_minitable.c +50 -39
  125. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb.h +411 -163
  126. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.c +95 -44
  127. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.h +3 -0
  128. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb.h +41 -8
  129. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb_minitable.c +8 -5
  130. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb.h +427 -222
  131. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.c +97 -66
  132. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.h +1 -0
  133. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb.h +130 -99
  134. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb_minitable.c +29 -27
  135. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb.h +49 -33
  136. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb_minitable.c +19 -8
  137. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb.h +95 -3
  138. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.c +33 -6
  139. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.h +1 -0
  140. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb.h +93 -11
  141. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb_minitable.c +8 -5
  142. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb.h +656 -134
  143. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.c +117 -51
  144. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.h +2 -0
  145. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb.h +45 -23
  146. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb_minitable.c +19 -10
  147. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb.h +99 -34
  148. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb_minitable.c +12 -7
  149. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb.h +344 -273
  150. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.c +62 -69
  151. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.h +1 -3
  152. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb.h +53 -22
  153. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb_minitable.c +9 -7
  154. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb.h +108 -0
  155. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.c +26 -2
  156. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.h +1 -0
  157. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb.h +809 -231
  158. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.c +183 -77
  159. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.h +3 -0
  160. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb.h +151 -26
  161. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb_minitable.c +17 -9
  162. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb.h +24 -8
  163. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb_minitable.c +6 -5
  164. data/src/core/ext/upb-gen/envoy/data/accesslog/v3/accesslog.upb.h +2 -1
  165. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb.h +224 -16
  166. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.c +83 -10
  167. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.h +2 -0
  168. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +95 -79
  169. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +23 -22
  170. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb.h +34 -18
  171. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb_minitable.c +10 -9
  172. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h +243 -2
  173. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.c +53 -5
  174. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.h +3 -0
  175. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb.h +53 -22
  176. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb_minitable.c +9 -7
  177. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.h +23 -7
  178. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb_minitable.c +9 -4
  179. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +516 -215
  180. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.c +99 -60
  181. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.h +1 -0
  182. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +60 -28
  183. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb_minitable.c +12 -10
  184. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb.h +109 -0
  185. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.c +32 -2
  186. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.h +1 -0
  187. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb.h +37 -4
  188. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb_minitable.c +7 -4
  189. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb.h +65 -47
  190. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb_minitable.c +29 -12
  191. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +20 -4
  192. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb_minitable.c +6 -3
  193. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +776 -88
  194. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +195 -35
  195. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +5 -0
  196. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb.h +23 -7
  197. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb_minitable.c +10 -3
  198. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb.h +44 -0
  199. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.c +11 -2
  200. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.h +1 -0
  201. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb.h +218 -0
  202. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.c +70 -0
  203. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.h +31 -0
  204. data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb.h +137 -73
  205. data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb_minitable.c +45 -25
  206. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb.h +6 -6
  207. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.c +4 -4
  208. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.h +5 -5
  209. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb.h +46 -26
  210. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.c +17 -14
  211. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.h +5 -5
  212. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb.h +5 -5
  213. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.c +3 -3
  214. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.h +5 -5
  215. data/src/core/ext/upb-gen/grpc/health/v1/health.upb.h +329 -0
  216. data/src/core/ext/upb-gen/grpc/health/v1/health.upb_minitable.c +128 -0
  217. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/health/v1/health.upb_minitable.h +8 -5
  218. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb.h +5 -5
  219. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.c +3 -3
  220. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.h +5 -5
  221. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb.h +185 -23
  222. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.c +20 -12
  223. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.h +5 -5
  224. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb.h +58 -42
  225. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.c +17 -12
  226. data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.h +5 -5
  227. data/src/core/ext/upbdefs-gen/envoy/admin/v3/clusters.upbdefs.c +30 -24
  228. data/src/core/ext/upbdefs-gen/envoy/admin/v3/server_info.upbdefs.c +166 -152
  229. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +467 -422
  230. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +15 -0
  231. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +120 -110
  232. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.c +912 -857
  233. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.h +5 -0
  234. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/outlier_detection.upbdefs.c +26 -19
  235. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/address.upbdefs.c +59 -54
  236. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.c +356 -346
  237. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.h +5 -0
  238. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/http_service.upbdefs.c +49 -37
  239. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.c +599 -483
  240. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.h +10 -0
  241. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_option.upbdefs.c +65 -49
  242. data/src/core/ext/upbdefs-gen/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +165 -161
  243. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.c +369 -327
  244. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.h +5 -15
  245. data/src/core/ext/upbdefs-gen/envoy/config/metrics/v3/stats.upbdefs.c +129 -121
  246. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.c +224 -204
  247. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.h +5 -0
  248. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.c +2046 -1932
  249. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.h +15 -0
  250. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/opentelemetry.upbdefs.c +70 -37
  251. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/zipkin.upbdefs.c +7 -3
  252. data/src/core/ext/upbdefs-gen/envoy/data/accesslog/v3/accesslog.upbdefs.c +5 -3
  253. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.c +121 -78
  254. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.h +10 -0
  255. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +165 -160
  256. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +121 -118
  257. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.c +68 -37
  258. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.h +15 -0
  259. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/router/v3/router.upbdefs.c +48 -40
  260. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.c +44 -37
  261. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +919 -870
  262. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
  263. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upbdefs.c +26 -14
  264. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +44 -36
  265. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +372 -371
  266. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c +32 -28
  267. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/address.upbdefs.c +17 -15
  268. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.c +4 -1
  269. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.h +5 -0
  270. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.c +76 -0
  271. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.h +37 -0
  272. data/src/core/ext/upbdefs-gen/envoy/type/v3/token_bucket.upbdefs.c +1 -1
  273. data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +567 -549
  274. data/src/core/ext/upbdefs-gen/grpc/lookup/v1/rls_config.upbdefs.c +182 -0
  275. data/src/core/ext/upbdefs-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upbdefs.h +14 -14
  276. data/src/core/filter/ext_proc/ext_proc_filter.cc +1883 -48
  277. data/src/core/filter/ext_proc/ext_proc_filter.h +88 -22
  278. data/src/core/filter/ext_proc/ext_proc_messages.cc +141 -65
  279. data/src/core/filter/ext_proc/ext_proc_messages.h +55 -16
  280. data/src/core/filter/filter_args.h +5 -60
  281. data/src/core/handshaker/handshaker.cc +4 -4
  282. data/src/core/handshaker/http_connect/http_connect_client_handshaker.cc +4 -4
  283. data/src/core/handshaker/security/pipelined_secure_endpoint.cc +33 -32
  284. data/src/core/handshaker/security/secure_endpoint.cc +29 -29
  285. data/src/core/handshaker/security/security_handshaker.cc +6 -6
  286. data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +4 -4
  287. data/src/core/lib/channel/channel_args.cc +20 -0
  288. data/src/core/lib/channel/channel_args.h +17 -17
  289. data/src/core/lib/channel/channel_stack.cc +0 -12
  290. data/src/core/lib/channel/channel_stack.h +0 -8
  291. data/src/core/lib/channel/promise_based_filter.cc +59 -46
  292. data/src/core/lib/channel/promise_based_filter.h +94 -67
  293. data/src/core/lib/debug/trace_flags.cc +2 -0
  294. data/src/core/lib/debug/trace_flags.h +1 -0
  295. data/src/core/lib/event_engine/ares_resolver.cc +24 -18
  296. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +7 -7
  297. data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +4 -4
  298. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +1 -1
  299. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +3 -3
  300. data/src/core/lib/event_engine/default_event_engine.cc +5 -5
  301. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +10 -14
  302. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +26 -26
  303. data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +8 -22
  304. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +24 -4
  305. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +6 -6
  306. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +7 -7
  307. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +27 -29
  308. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +3 -3
  309. data/src/core/lib/event_engine/posix_engine/posix_interface.h +1 -1
  310. data/src/core/lib/event_engine/posix_engine/timer.cc +7 -7
  311. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +5 -5
  312. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +3 -3
  313. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +1 -1
  314. data/src/core/lib/event_engine/shim.cc +1 -6
  315. data/src/core/lib/event_engine/shim.h +0 -5
  316. data/src/core/lib/event_engine/thread_pool/thread_count.cc +1 -1
  317. data/src/core/lib/event_engine/thread_pool/thread_count.h +3 -3
  318. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +50 -21
  319. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +3 -3
  320. data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +3 -3
  321. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -19
  322. data/src/core/lib/event_engine/windows/windows_listener.cc +7 -7
  323. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +6 -6
  324. data/src/core/lib/experiments/experiments.cc +177 -246
  325. data/src/core/lib/experiments/experiments.h +61 -109
  326. data/src/core/lib/iomgr/buffer_list.cc +3 -3
  327. data/src/core/lib/iomgr/buffer_list.h +1 -1
  328. data/src/core/lib/iomgr/combiner.cc +0 -1
  329. data/src/core/lib/iomgr/ev_apple.cc +4 -4
  330. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +2 -2
  331. data/src/core/lib/iomgr/iomgr_windows.cc +1 -6
  332. data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
  333. data/src/core/lib/iomgr/tcp_posix.cc +28 -28
  334. data/src/core/lib/iomgr/tcp_server_posix.cc +64 -242
  335. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -469
  336. data/src/core/lib/promise/activity.cc +9 -9
  337. data/src/core/lib/promise/activity.h +6 -6
  338. data/src/core/lib/promise/arena_promise.h +7 -7
  339. data/src/core/lib/promise/detail/promise_factory.h +8 -8
  340. data/src/core/lib/promise/detail/promise_like.h +4 -4
  341. data/src/core/lib/promise/inter_activity_latch.h +6 -6
  342. data/src/core/lib/promise/inter_activity_pipe.h +4 -4
  343. data/src/core/lib/promise/observable.h +3 -3
  344. data/src/core/lib/promise/party.cc +6 -6
  345. data/src/core/lib/promise/status_flag.h +7 -2
  346. data/src/core/lib/promise/try_seq.h +2 -2
  347. data/src/core/lib/resource_quota/arena.h +3 -3
  348. data/src/core/lib/resource_quota/memory_quota.cc +18 -18
  349. data/src/core/lib/resource_quota/memory_quota.h +1 -1
  350. data/src/core/lib/resource_quota/thread_quota.cc +3 -3
  351. data/src/core/lib/security/authorization/audit_logging.cc +5 -5
  352. data/src/core/lib/security/authorization/authorization_engine.h +1 -1
  353. data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
  354. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -1
  355. data/src/core/lib/security/authorization/grpc_server_authz_filter.h +1 -1
  356. data/src/core/lib/security/authorization/matchers.h +1 -1
  357. data/src/core/lib/security/authorization/rbac_policy.h +2 -2
  358. data/src/core/lib/surface/call.cc +20 -9
  359. data/src/core/lib/surface/call.h +24 -7
  360. data/src/core/lib/surface/call_utils.h +4 -0
  361. data/src/core/lib/surface/channel.cc +1 -1
  362. data/src/core/lib/surface/channel.h +1 -1
  363. data/src/core/lib/surface/channel_create.cc +7 -1
  364. data/src/core/lib/surface/channel_init.cc +1 -1
  365. data/src/core/lib/surface/channel_init.h +1 -8
  366. data/src/core/lib/surface/filter_stack_call.cc +16 -0
  367. data/src/core/lib/surface/filter_stack_call.h +1 -0
  368. data/src/core/lib/surface/init.cc +10 -10
  369. data/src/core/lib/surface/lame_client.cc +1 -1
  370. data/src/core/lib/surface/legacy_channel.cc +6 -3
  371. data/src/core/lib/surface/version.cc +2 -2
  372. data/src/core/lib/transport/transport.cc +15 -8
  373. data/src/core/lib/transport/transport_framing_endpoint_extension.h +9 -3
  374. data/src/core/load_balancing/autosharding/autosharding.cc +931 -0
  375. data/src/core/load_balancing/autosharding/autosharding.h +78 -0
  376. data/src/core/load_balancing/grpclb/grpclb_client_stats.cc +2 -2
  377. data/src/core/load_balancing/grpclb/load_balancer_api.cc +1 -1
  378. data/src/core/load_balancing/grpclb/load_balancer_api.h +3 -1
  379. data/src/core/load_balancing/health_check_client.cc +7 -7
  380. data/src/core/load_balancing/lb_policy.cc +1 -1
  381. data/src/core/load_balancing/oob_backend_metric.cc +5 -5
  382. data/src/core/load_balancing/outlier_detection/outlier_detection.cc +101 -10
  383. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.cc +38 -0
  384. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.h +55 -0
  385. data/src/core/load_balancing/ring_hash/ring_hash.cc +111 -38
  386. data/src/core/load_balancing/rls/rls.cc +44 -18
  387. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +10 -10
  388. data/src/core/load_balancing/xds/cds.cc +10 -56
  389. data/src/core/load_balancing/xds/xds_cluster_impl.cc +2 -2
  390. data/src/core/load_balancing/xds/xds_override_host.cc +10 -10
  391. data/src/core/mitigation_engine/mitigation_engine.h +28 -4
  392. data/src/core/plugin_registry/grpc_plugin_registry.cc +12 -13
  393. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +0 -7
  394. data/src/core/resolver/dns/dns_resolver.cc +7 -7
  395. data/src/core/resolver/fake/fake_resolver.cc +5 -5
  396. data/src/core/resolver/google_c2p/google_c2p_resolver.cc +38 -30
  397. data/src/core/resolver/xds/xds_resolver.cc +1 -1
  398. data/src/core/server/server.cc +88 -32
  399. data/src/core/server/server.h +4 -3
  400. data/src/core/server/server_config_selector.h +4 -18
  401. data/src/core/server/server_config_selector_filter.cc +20 -146
  402. data/src/core/server/server_config_selector_filter.h +2 -2
  403. data/src/core/server/xds_server_config_fetcher.cc +5 -20
  404. data/src/core/telemetry/default_tcp_tracer.cc +1 -1
  405. data/src/core/telemetry/instrument.cc +30 -16
  406. data/src/core/telemetry/instrument.h +3 -3
  407. data/src/core/transport/auth_context.cc +15 -5
  408. data/src/core/transport/auth_context.h +5 -0
  409. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
  410. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +4 -4
  411. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +2 -2
  412. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +1 -1
  413. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
  414. data/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +5 -5
  415. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +3 -3
  416. data/src/core/tsi/ssl_telemetry_utils.cc +9 -1
  417. data/src/core/tsi/ssl_transport_security.cc +203 -64
  418. data/src/core/tsi/ssl_transport_security.h +25 -2
  419. data/src/core/tsi/ssl_transport_security_utils.cc +139 -18
  420. data/src/core/tsi/ssl_transport_security_utils.h +19 -0
  421. data/src/core/util/event_log.cc +3 -3
  422. data/src/core/util/http_client/httpcli.cc +5 -5
  423. data/src/core/util/http_client/httpcli.h +1 -1
  424. data/src/core/util/json/json_object_loader.cc +7 -0
  425. data/src/core/util/json/json_object_loader.h +17 -2
  426. data/src/core/util/latent_see.cc +188 -39
  427. data/src/core/util/latent_see.h +71 -13
  428. data/src/core/util/linux/cpu.cc +12 -6
  429. data/src/core/util/mpscq.cc +3 -3
  430. data/src/core/util/notification.h +4 -4
  431. data/src/core/util/sync.h +20 -6
  432. data/src/core/util/sync_abseil.cc +3 -3
  433. data/src/core/util/table.h +20 -22
  434. data/src/core/util/trie_lookup.h +5 -1
  435. data/src/core/util/windows/env.cc +1 -0
  436. data/src/core/util/work_serializer.cc +3 -3
  437. data/src/core/xds/grpc/blackboard.cc +4 -3
  438. data/src/core/xds/grpc/certificate_provider_store.cc +2 -2
  439. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +10 -9
  440. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +3 -3
  441. data/src/core/xds/grpc/streaming_call_promise_wrapper.cc +184 -0
  442. data/src/core/xds/grpc/streaming_call_promise_wrapper.h +210 -0
  443. data/src/core/xds/grpc/xds_audit_logger_registry.cc +0 -54
  444. data/src/core/xds/grpc/xds_audit_logger_registry.h +0 -8
  445. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +4 -30
  446. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +0 -20
  447. data/src/core/xds/grpc/xds_client_grpc.cc +12 -12
  448. data/src/core/xds/grpc/xds_client_grpc.h +1 -1
  449. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -1
  450. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +2 -2
  451. data/src/core/xds/grpc/xds_common_types_parser.cc +12 -0
  452. data/src/core/xds/grpc/xds_endpoint.cc +1 -1
  453. data/src/core/xds/grpc/xds_endpoint_parser.cc +14 -3
  454. data/src/core/xds/grpc/xds_grpc_service_parser.cc +12 -10
  455. data/src/core/xds/grpc/xds_http_composite_filter.cc +0 -5
  456. data/src/core/xds/grpc/xds_http_composite_filter.h +1 -27
  457. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +18 -19
  458. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +3 -29
  459. data/src/core/xds/grpc/xds_http_fault_filter.cc +0 -4
  460. data/src/core/xds/grpc/xds_http_fault_filter.h +0 -26
  461. data/src/core/xds/grpc/xds_http_filter.h +1 -63
  462. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +0 -5
  463. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +1 -27
  464. data/src/core/xds/grpc/xds_http_rbac_filter.cc +0 -527
  465. data/src/core/xds/grpc/xds_http_rbac_filter.h +0 -15
  466. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +0 -5
  467. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +0 -26
  468. data/src/core/xds/grpc/xds_listener.cc +0 -2
  469. data/src/core/xds/grpc/xds_listener.h +0 -2
  470. data/src/core/xds/grpc/xds_listener_parser.cc +0 -7
  471. data/src/core/xds/grpc/xds_matcher.cc +17 -11
  472. data/src/core/xds/grpc/xds_matcher.h +4 -3
  473. data/src/core/xds/grpc/xds_matcher_context.cc +11 -0
  474. data/src/core/xds/grpc/xds_matcher_context.h +3 -2
  475. data/src/core/xds/grpc/xds_matcher_input.cc +19 -1
  476. data/src/core/xds/grpc/xds_matcher_parse.cc +3 -2
  477. data/src/core/xds/grpc/xds_route_config.cc +0 -2
  478. data/src/core/xds/grpc/xds_route_config.h +0 -2
  479. data/src/core/xds/grpc/xds_route_config_parser.cc +0 -5
  480. data/src/core/xds/grpc/xds_routing.cc +22 -112
  481. data/src/core/xds/grpc/xds_routing.h +2 -27
  482. data/src/core/xds/grpc/xds_transport_factory_grpc.cc +236 -0
  483. data/src/core/xds/grpc/xds_transport_factory_grpc.h +95 -0
  484. data/src/core/xds/grpc/xds_transport_grpc.cc +176 -299
  485. data/src/core/xds/grpc/xds_transport_grpc.h +60 -55
  486. data/src/core/xds/xds_client/lrs_client.cc +23 -22
  487. data/src/core/xds/xds_client/lrs_client.h +2 -1
  488. data/src/core/xds/xds_client/xds_client.cc +53 -37
  489. data/src/core/xds/xds_client/xds_client.h +6 -5
  490. data/src/core/xds/xds_client/xds_transport.h +113 -65
  491. data/src/core/xds/xds_client/xds_transport_factory.h +43 -0
  492. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  493. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +9 -0
  494. data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
  495. data/src/ruby/lib/grpc/version.rb +1 -1
  496. data/src/ruby/pb/README.md +1 -1
  497. data/src/ruby/pb/generate_proto_ruby.sh +1 -1
  498. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +34 -2
  499. data/third_party/abseil-cpp/absl/algorithm/container.h +345 -147
  500. data/third_party/abseil-cpp/absl/base/attributes.h +67 -44
  501. data/third_party/abseil-cpp/absl/base/call_once.h +1 -0
  502. data/third_party/abseil-cpp/absl/base/casts.cc +61 -0
  503. data/third_party/abseil-cpp/absl/base/casts.h +135 -2
  504. data/third_party/abseil-cpp/absl/base/config.h +63 -41
  505. data/third_party/abseil-cpp/absl/base/fast_type_id.h +30 -2
  506. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +1 -1
  507. data/third_party/abseil-cpp/absl/base/internal/hardening.h +136 -0
  508. data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +6 -2
  509. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +39 -4
  510. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +6 -0
  511. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +77 -15
  512. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +3 -4
  513. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +26 -24
  514. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +74 -29
  515. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -11
  516. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +52 -0
  517. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +5 -1
  518. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +5 -0
  519. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +1 -1
  520. data/third_party/abseil-cpp/absl/base/macros.h +76 -37
  521. data/third_party/abseil-cpp/absl/base/nullability.h +5 -5
  522. data/third_party/abseil-cpp/absl/base/optimization.h +4 -5
  523. data/third_party/abseil-cpp/absl/base/options.h +46 -18
  524. data/third_party/abseil-cpp/absl/base/policy_checks.h +5 -5
  525. data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.cc → throw_delegate.cc} +9 -7
  526. data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.h → throw_delegate.h} +4 -14
  527. data/third_party/abseil-cpp/absl/cleanup/cleanup.h +7 -2
  528. data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -2
  529. data/third_party/abseil-cpp/absl/container/btree_map.h +60 -10
  530. data/third_party/abseil-cpp/absl/container/btree_set.h +61 -15
  531. data/third_party/abseil-cpp/absl/container/fixed_array.h +19 -21
  532. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +49 -27
  533. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +50 -26
  534. data/third_party/abseil-cpp/absl/container/inlined_vector.h +42 -36
  535. data/third_party/abseil-cpp/absl/container/internal/btree.h +32 -24
  536. data/third_party/abseil-cpp/absl/container/internal/btree_container.h +30 -22
  537. data/third_party/abseil-cpp/absl/container/internal/common.h +57 -5
  538. data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
  539. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +40 -36
  540. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +119 -39
  541. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +14 -2
  542. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +14 -22
  543. data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +52 -52
  544. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +7 -7
  545. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +7 -7
  546. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +32 -40
  547. data/third_party/abseil-cpp/absl/container/internal/layout.h +13 -13
  548. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +95 -72
  549. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +633 -365
  550. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1016 -749
  551. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +0 -1
  552. data/third_party/abseil-cpp/absl/container/node_hash_map.h +58 -35
  553. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +23 -6
  554. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.h +7 -1
  555. data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -6
  556. data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +41 -0
  557. data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +0 -16
  558. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_arm_combined.cc +5 -0
  559. data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +304 -188
  560. data/third_party/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +4 -2
  561. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +2 -2
  562. data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.h +8 -0
  563. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +4 -4
  564. data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +15 -1
  565. data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h +7 -1
  566. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +12 -1
  567. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +6 -5
  568. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +13 -11
  569. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +14 -7
  570. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +3 -2
  571. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +6 -1
  572. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +14 -8
  573. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +48 -38
  574. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +4 -0
  575. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +63 -118
  576. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +7 -47
  577. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +20 -2
  578. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +83 -149
  579. data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +4 -17
  580. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +4 -4
  581. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +2 -4
  582. data/third_party/abseil-cpp/absl/flags/commandlineflag.h +8 -6
  583. data/third_party/abseil-cpp/absl/flags/declare.h +9 -0
  584. data/third_party/abseil-cpp/absl/flags/flag.h +2 -1
  585. data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +1 -1
  586. data/third_party/abseil-cpp/absl/flags/internal/flag.cc +19 -18
  587. data/third_party/abseil-cpp/absl/flags/internal/flag.h +33 -34
  588. data/third_party/abseil-cpp/absl/flags/internal/program_name.cc +2 -2
  589. data/third_party/abseil-cpp/absl/flags/marshalling.cc +1 -16
  590. data/third_party/abseil-cpp/absl/flags/marshalling.h +2 -28
  591. data/third_party/abseil-cpp/absl/flags/reflection.cc +11 -7
  592. data/third_party/abseil-cpp/absl/flags/usage_config.cc +2 -2
  593. data/third_party/abseil-cpp/absl/functional/any_invocable.h +22 -19
  594. data/third_party/abseil-cpp/absl/functional/bind_front.h +7 -1
  595. data/third_party/abseil-cpp/absl/functional/function_ref.h +125 -20
  596. data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +43 -31
  597. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +4 -4
  598. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +44 -6
  599. data/third_party/abseil-cpp/absl/hash/hash.h +1 -1
  600. data/third_party/abseil-cpp/absl/hash/internal/city.cc +39 -51
  601. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +379 -14
  602. data/third_party/abseil-cpp/absl/hash/internal/hash.h +457 -353
  603. data/third_party/abseil-cpp/absl/log/absl_vlog_is_on.h +0 -2
  604. data/third_party/abseil-cpp/absl/log/internal/check_impl.h +2 -1
  605. data/third_party/abseil-cpp/absl/log/internal/check_op.cc +4 -0
  606. data/third_party/abseil-cpp/absl/log/internal/check_op.h +128 -50
  607. data/third_party/abseil-cpp/absl/log/internal/conditions.h +38 -35
  608. data/third_party/abseil-cpp/absl/log/internal/log_impl.h +108 -110
  609. data/third_party/abseil-cpp/absl/log/internal/log_message.cc +10 -6
  610. data/third_party/abseil-cpp/absl/log/internal/log_message.h +19 -1
  611. data/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc +4 -4
  612. data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -1
  613. data/third_party/abseil-cpp/absl/log/internal/proto.cc +13 -0
  614. data/third_party/abseil-cpp/absl/log/internal/strip.h +30 -31
  615. data/third_party/abseil-cpp/absl/log/internal/structured_proto.cc +5 -5
  616. data/third_party/abseil-cpp/absl/log/internal/structured_proto.h +6 -5
  617. data/third_party/abseil-cpp/absl/log/internal/vlog_config.cc +30 -30
  618. data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +0 -1
  619. data/third_party/abseil-cpp/absl/log/log.h +2 -2
  620. data/third_party/abseil-cpp/absl/log/log_entry.cc +263 -0
  621. data/third_party/abseil-cpp/absl/log/log_entry.h +2 -0
  622. data/third_party/abseil-cpp/absl/log/vlog_is_on.h +0 -2
  623. data/third_party/abseil-cpp/absl/memory/memory.h +55 -5
  624. data/third_party/abseil-cpp/absl/meta/type_traits.h +161 -56
  625. data/third_party/abseil-cpp/absl/numeric/int128.h +41 -21
  626. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +16 -22
  627. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +5 -7
  628. data/third_party/abseil-cpp/absl/numeric/internal/bits.h +32 -4
  629. data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +9 -9
  630. data/third_party/abseil-cpp/absl/random/beta_distribution.h +2 -2
  631. data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +26 -53
  632. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +1 -1
  633. data/third_party/abseil-cpp/absl/random/distributions.h +17 -17
  634. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +1 -1
  635. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +8 -21
  636. data/third_party/abseil-cpp/absl/random/internal/entropy_pool.cc +2 -2
  637. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +1 -1
  638. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
  639. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +2 -2
  640. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +2 -2
  641. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +6 -6
  642. data/third_party/abseil-cpp/absl/random/internal/platform.h +0 -13
  643. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +6 -6
  644. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +2 -2
  645. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +6 -5
  646. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +5 -31
  647. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +2 -1
  648. data/third_party/abseil-cpp/absl/random/internal/traits.h +21 -0
  649. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +23 -23
  650. data/third_party/abseil-cpp/absl/random/mocking_access.h +74 -0
  651. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +1 -1
  652. data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +63 -18
  653. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +30 -4
  654. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +225 -63
  655. data/third_party/abseil-cpp/absl/status/status.cc +66 -70
  656. data/third_party/abseil-cpp/absl/status/status.h +254 -23
  657. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +3 -2
  658. data/third_party/abseil-cpp/absl/status/statusor.h +117 -137
  659. data/third_party/abseil-cpp/absl/strings/ascii.h +10 -6
  660. data/third_party/abseil-cpp/absl/strings/cord.cc +41 -17
  661. data/third_party/abseil-cpp/absl/strings/cord.h +26 -17
  662. data/third_party/abseil-cpp/absl/strings/cord_buffer.h +4 -2
  663. data/third_party/abseil-cpp/absl/strings/escaping.cc +305 -125
  664. data/third_party/abseil-cpp/absl/strings/escaping.h +12 -2
  665. data/third_party/abseil-cpp/absl/strings/internal/append_and_overwrite.h +93 -0
  666. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +2 -2
  667. data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +6 -6
  668. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +27 -21
  669. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +11 -19
  670. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +6 -0
  671. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +1 -0
  672. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +0 -141
  673. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +2 -24
  674. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +31 -36
  675. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +39 -39
  676. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -22
  677. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +2 -2
  678. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +2 -4
  679. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +921 -231
  680. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +18 -16
  681. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +16 -12
  682. data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.h +12 -0
  683. data/third_party/abseil-cpp/absl/strings/numbers.cc +477 -8
  684. data/third_party/abseil-cpp/absl/strings/numbers.h +29 -12
  685. data/third_party/abseil-cpp/absl/strings/resize_and_overwrite.h +198 -0
  686. data/third_party/abseil-cpp/absl/strings/str_cat.cc +96 -91
  687. data/third_party/abseil-cpp/absl/strings/str_cat.h +53 -13
  688. data/third_party/abseil-cpp/absl/strings/str_split.h +14 -9
  689. data/third_party/abseil-cpp/absl/strings/string_view.h +10 -716
  690. data/third_party/abseil-cpp/absl/strings/substitute.cc +24 -24
  691. data/third_party/abseil-cpp/absl/strings/substitute.h +2 -2
  692. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +1 -1
  693. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +2 -2
  694. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +24 -3
  695. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +30 -33
  696. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -2
  697. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +5 -0
  698. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +41 -29
  699. data/third_party/abseil-cpp/absl/synchronization/mutex.h +199 -94
  700. data/third_party/abseil-cpp/absl/synchronization/notification.cc +5 -5
  701. data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
  702. data/third_party/abseil-cpp/absl/time/clock.cc +29 -30
  703. data/third_party/abseil-cpp/absl/time/clock.h +3 -0
  704. data/third_party/abseil-cpp/absl/time/duration.cc +2 -2
  705. data/third_party/abseil-cpp/absl/time/format.cc +3 -10
  706. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +12 -0
  707. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +131 -91
  708. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +6 -103
  709. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +185 -0
  710. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.h +37 -0
  711. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +10 -15
  712. data/third_party/abseil-cpp/absl/time/time.cc +4 -4
  713. data/third_party/abseil-cpp/absl/time/time.h +14 -13
  714. data/third_party/abseil-cpp/absl/types/compare.h +64 -63
  715. data/third_party/abseil-cpp/absl/types/internal/span.h +6 -6
  716. data/third_party/abseil-cpp/absl/types/optional.h +31 -4
  717. data/third_party/abseil-cpp/absl/types/optional_ref.h +295 -0
  718. data/third_party/{boringssl-with-bazel/crypto/x509/x_val.cc → abseil-cpp/absl/types/source_location.cc} +4 -14
  719. data/third_party/abseil-cpp/absl/types/source_location.h +172 -0
  720. data/third_party/abseil-cpp/absl/types/span.h +67 -38
  721. data/third_party/abseil-cpp/absl/types/variant.h +75 -18
  722. data/third_party/abseil-cpp/absl/utility/utility.h +112 -16
  723. data/third_party/boringssl-with-bazel/crypto/aes/aes.cc +3 -0
  724. data/third_party/boringssl-with-bazel/crypto/armv8_feature_parsing.h +67 -0
  725. data/third_party/boringssl-with-bazel/crypto/asn1/a_bitstr.cc +143 -105
  726. data/third_party/boringssl-with-bazel/crypto/asn1/a_bool.cc +5 -8
  727. data/third_party/boringssl-with-bazel/crypto/asn1/a_d2i_fp.cc +3 -3
  728. data/third_party/boringssl-with-bazel/crypto/asn1/a_dup.cc +6 -6
  729. data/third_party/boringssl-with-bazel/crypto/asn1/a_gentm.cc +33 -12
  730. data/third_party/boringssl-with-bazel/crypto/asn1/a_i2d_fp.cc +7 -6
  731. data/third_party/boringssl-with-bazel/crypto/asn1/a_int.cc +80 -52
  732. data/third_party/boringssl-with-bazel/crypto/asn1/a_mbstr.cc +7 -4
  733. data/third_party/boringssl-with-bazel/crypto/asn1/a_object.cc +70 -72
  734. data/third_party/boringssl-with-bazel/crypto/asn1/a_strex.cc +38 -42
  735. data/third_party/boringssl-with-bazel/crypto/asn1/a_strnid.cc +41 -39
  736. data/third_party/boringssl-with-bazel/crypto/asn1/a_time.cc +59 -35
  737. data/third_party/boringssl-with-bazel/crypto/asn1/a_type.cc +325 -30
  738. data/third_party/boringssl-with-bazel/crypto/asn1/a_utctm.cc +32 -13
  739. data/third_party/boringssl-with-bazel/crypto/asn1/asn1_lib.cc +129 -31
  740. data/third_party/boringssl-with-bazel/crypto/asn1/asn_pack.cc +10 -10
  741. data/third_party/boringssl-with-bazel/crypto/asn1/f_int.cc +1 -1
  742. data/third_party/boringssl-with-bazel/crypto/asn1/f_string.cc +1 -1
  743. data/third_party/boringssl-with-bazel/crypto/asn1/internal.h +307 -115
  744. data/third_party/boringssl-with-bazel/crypto/asn1/posix_time.cc +8 -5
  745. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_dec.cc +376 -728
  746. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_enc.cc +215 -528
  747. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_fre.cc +30 -31
  748. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_new.cc +50 -52
  749. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_typ.cc +18 -6
  750. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_utl.cc +63 -74
  751. data/third_party/boringssl-with-bazel/crypto/base64/base64.cc +14 -15
  752. data/third_party/boringssl-with-bazel/crypto/bcm_support.h +7 -29
  753. data/third_party/boringssl-with-bazel/crypto/bio/bio.cc +234 -177
  754. data/third_party/boringssl-with-bazel/crypto/bio/bio_mem.cc +78 -86
  755. data/third_party/boringssl-with-bazel/crypto/bio/connect.cc +154 -200
  756. data/third_party/boringssl-with-bazel/crypto/bio/errno.cc +3 -1
  757. data/third_party/boringssl-with-bazel/crypto/bio/fd.cc +55 -55
  758. data/third_party/boringssl-with-bazel/crypto/bio/file.cc +69 -78
  759. data/third_party/boringssl-with-bazel/crypto/bio/hexdump.cc +6 -4
  760. data/third_party/boringssl-with-bazel/crypto/bio/internal.h +69 -18
  761. data/third_party/boringssl-with-bazel/crypto/bio/pair.cc +116 -136
  762. data/third_party/boringssl-with-bazel/crypto/bio/printf.cc +1 -1
  763. data/third_party/boringssl-with-bazel/crypto/bio/socket.cc +116 -50
  764. data/third_party/boringssl-with-bazel/crypto/bio/socket_helper.cc +53 -5
  765. data/third_party/boringssl-with-bazel/crypto/blake2/blake2.cc +9 -5
  766. data/third_party/boringssl-with-bazel/crypto/bn/bn_asn1.cc +2 -2
  767. data/third_party/boringssl-with-bazel/crypto/bn/convert.cc +56 -70
  768. data/third_party/boringssl-with-bazel/crypto/bn/div.cc +102 -0
  769. data/third_party/boringssl-with-bazel/crypto/bn/exponentiation.cc +26 -42
  770. data/third_party/boringssl-with-bazel/crypto/bn/sqrt.cc +93 -0
  771. data/third_party/boringssl-with-bazel/crypto/buf/buf.cc +6 -5
  772. data/third_party/boringssl-with-bazel/crypto/bytestring/asn1_compat.cc +6 -5
  773. data/third_party/boringssl-with-bazel/crypto/bytestring/ber.cc +22 -20
  774. data/third_party/boringssl-with-bazel/crypto/bytestring/cbb.cc +182 -97
  775. data/third_party/boringssl-with-bazel/crypto/bytestring/cbs.cc +114 -49
  776. data/third_party/boringssl-with-bazel/crypto/bytestring/internal.h +84 -24
  777. data/third_party/boringssl-with-bazel/crypto/bytestring/unicode.cc +2 -2
  778. data/third_party/boringssl-with-bazel/crypto/chacha/chacha.cc +5 -3
  779. data/third_party/boringssl-with-bazel/crypto/chacha/internal.h +23 -22
  780. data/third_party/boringssl-with-bazel/crypto/cipher/derive_key.cc +14 -18
  781. data/third_party/boringssl-with-bazel/crypto/cipher/e_aesctrhmac.cc +73 -58
  782. data/third_party/boringssl-with-bazel/crypto/cipher/e_aeseax.cc +132 -70
  783. data/third_party/boringssl-with-bazel/crypto/cipher/e_aesgcmsiv.cc +363 -367
  784. data/third_party/boringssl-with-bazel/crypto/cipher/e_chacha20poly1305.cc +200 -137
  785. data/third_party/boringssl-with-bazel/crypto/cipher/e_des.cc +45 -29
  786. data/third_party/boringssl-with-bazel/crypto/cipher/e_null.cc +9 -5
  787. data/third_party/boringssl-with-bazel/crypto/cipher/e_rc2.cc +43 -28
  788. data/third_party/boringssl-with-bazel/crypto/cipher/e_rc4.cc +7 -5
  789. data/third_party/boringssl-with-bazel/crypto/cipher/e_tls.cc +253 -237
  790. data/third_party/boringssl-with-bazel/crypto/cipher/get_cipher.cc +12 -12
  791. data/third_party/boringssl-with-bazel/crypto/cipher/internal.h +217 -58
  792. data/third_party/boringssl-with-bazel/crypto/cipher/tls_cbc.cc +111 -111
  793. data/third_party/boringssl-with-bazel/crypto/cms/cms.cc +48 -42
  794. data/third_party/boringssl-with-bazel/crypto/conf/conf.cc +69 -63
  795. data/third_party/boringssl-with-bazel/crypto/conf/internal.h +11 -12
  796. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_apple.cc +8 -5
  797. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_fuchsia.cc +6 -1
  798. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_linux.cc +7 -1
  799. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_openbsd.cc +7 -21
  800. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_sysreg.cc +15 -41
  801. data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_win.cc +16 -3
  802. data/third_party/boringssl-with-bazel/crypto/cpu_arm_freebsd.cc +4 -2
  803. data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.cc +54 -31
  804. data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.h +79 -101
  805. data/third_party/boringssl-with-bazel/crypto/cpu_intel.cc +51 -45
  806. data/third_party/boringssl-with-bazel/crypto/crypto.cc +26 -55
  807. data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519.cc +323 -41
  808. data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519_tables.h +6 -6
  809. data/third_party/boringssl-with-bazel/crypto/curve25519/internal.h +39 -29
  810. data/third_party/boringssl-with-bazel/crypto/curve25519/spake25519.cc +23 -20
  811. data/third_party/boringssl-with-bazel/crypto/des/des.cc +27 -19
  812. data/third_party/boringssl-with-bazel/crypto/des/internal.h +4 -9
  813. data/third_party/boringssl-with-bazel/crypto/dh/dh_asn1.cc +34 -49
  814. data/third_party/boringssl-with-bazel/crypto/dh/params.cc +45 -42
  815. data/third_party/boringssl-with-bazel/crypto/digest/digest_extra.cc +87 -40
  816. data/third_party/boringssl-with-bazel/crypto/dsa/dsa.cc +237 -260
  817. data/third_party/boringssl-with-bazel/crypto/dsa/dsa_asn1.cc +100 -173
  818. data/third_party/boringssl-with-bazel/crypto/dsa/internal.h +23 -21
  819. data/third_party/boringssl-with-bazel/crypto/ec/ec_asn1.cc +181 -209
  820. data/third_party/boringssl-with-bazel/crypto/ec/ec_derive.cc +26 -28
  821. data/third_party/boringssl-with-bazel/crypto/ec/hash_to_curve.cc +459 -196
  822. data/third_party/boringssl-with-bazel/crypto/ec/internal.h +54 -18
  823. data/third_party/boringssl-with-bazel/crypto/ecdh/ecdh.cc +7 -5
  824. data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_asn1.cc +50 -70
  825. data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_p1363.cc +54 -0
  826. data/third_party/boringssl-with-bazel/crypto/engine/engine.cc +7 -7
  827. data/third_party/boringssl-with-bazel/crypto/err/err.cc +119 -107
  828. data/third_party/boringssl-with-bazel/crypto/err/internal.h +8 -21
  829. data/third_party/boringssl-with-bazel/crypto/evp/evp.cc +241 -166
  830. data/third_party/boringssl-with-bazel/crypto/evp/evp_asn1.cc +202 -234
  831. data/third_party/boringssl-with-bazel/crypto/evp/evp_ctx.cc +260 -159
  832. data/third_party/boringssl-with-bazel/crypto/evp/evp_kem.cc +101 -0
  833. data/third_party/boringssl-with-bazel/crypto/evp/internal.h +296 -137
  834. data/third_party/boringssl-with-bazel/crypto/evp/p_dh.cc +198 -25
  835. data/third_party/boringssl-with-bazel/crypto/evp/p_dsa.cc +333 -0
  836. data/third_party/boringssl-with-bazel/crypto/evp/p_ec.cc +548 -42
  837. data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519.cc +270 -14
  838. data/third_party/boringssl-with-bazel/crypto/evp/p_hkdf.cc +70 -102
  839. data/third_party/boringssl-with-bazel/crypto/evp/p_mldsa.cc +549 -0
  840. data/third_party/boringssl-with-bazel/crypto/evp/p_mlkem.cc +510 -0
  841. data/third_party/boringssl-with-bazel/crypto/evp/p_rsa.cc +734 -158
  842. data/third_party/boringssl-with-bazel/crypto/evp/p_x25519.cc +290 -28
  843. data/third_party/boringssl-with-bazel/crypto/evp/p_xwing.cc +300 -0
  844. data/third_party/boringssl-with-bazel/crypto/evp/pbkdf.cc +14 -7
  845. data/third_party/boringssl-with-bazel/crypto/evp/print.cc +34 -89
  846. data/third_party/boringssl-with-bazel/crypto/evp/scrypt.cc +23 -21
  847. data/third_party/boringssl-with-bazel/crypto/evp/sign.cc +23 -42
  848. data/third_party/boringssl-with-bazel/crypto/ex_data.cc +40 -41
  849. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes.cc.inc +34 -28
  850. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes_nohw.cc.inc +120 -122
  851. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cbc.cc.inc +16 -14
  852. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cfb.cc.inc +12 -10
  853. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ctr.cc.inc +7 -5
  854. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm.cc.inc +41 -31
  855. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm_nohw.cc.inc +15 -13
  856. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/internal.h +193 -177
  857. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/key_wrap.cc.inc +5 -3
  858. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/mode_wrappers.cc.inc +7 -3
  859. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ofb.cc.inc +7 -5
  860. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm.cc +24 -18
  861. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm_interface.h +512 -384
  862. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/add.cc.inc +16 -9
  863. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +64 -45
  864. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bn.cc.inc +40 -37
  865. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bytes.cc.inc +27 -22
  866. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/cmp.cc.inc +9 -7
  867. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/ctx.cc.inc +62 -126
  868. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div.cc.inc +92 -167
  869. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div_extra.cc.inc +15 -12
  870. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/exponentiation.cc.inc +98 -95
  871. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd.cc.inc +73 -92
  872. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd_extra.cc.inc +59 -71
  873. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/generic.cc.inc +54 -57
  874. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/internal.h +339 -255
  875. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/jacobi.cc.inc +13 -20
  876. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery.cc.inc +80 -95
  877. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery_inv.cc.inc +55 -98
  878. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/mul.cc.inc +58 -419
  879. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/prime.cc.inc +167 -216
  880. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/random.cc.inc +27 -26
  881. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.cc.inc +18 -16
  882. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.h +47 -49
  883. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/shift.cc.inc +14 -17
  884. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/sqrt.cc.inc +40 -129
  885. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/aead.cc.inc +429 -105
  886. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/cipher.cc.inc +381 -216
  887. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aes.cc.inc +230 -225
  888. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aesccm.cc.inc +115 -84
  889. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/internal.h +375 -27
  890. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cmac/cmac.cc.inc +28 -23
  891. data/third_party/boringssl-with-bazel/crypto/fipsmodule/delocate.h +36 -40
  892. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/check.cc.inc +68 -78
  893. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/dh.cc.inc +157 -199
  894. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/internal.h +24 -24
  895. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digest.cc.inc +40 -69
  896. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digests.cc.inc +13 -7
  897. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/internal.h +13 -11
  898. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/md32_common.h +86 -81
  899. data/third_party/boringssl-with-bazel/crypto/fipsmodule/digestsign/digestsign.cc.inc +38 -34
  900. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec.cc.inc +254 -203
  901. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_key.cc.inc +196 -154
  902. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_montgomery.cc.inc +78 -138
  903. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/felem.cc.inc +151 -5
  904. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/internal.h +332 -289
  905. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/oct.cc.inc +45 -166
  906. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.cc.inc +44 -45
  907. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.h +18 -18
  908. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256.cc.inc +75 -246
  909. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/scalar.cc.inc +44 -39
  910. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple.cc.inc +73 -106
  911. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple_mul.cc.inc +39 -34
  912. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/util.cc.inc +6 -3
  913. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/wnaf.cc.inc +23 -20
  914. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdh/ecdh.cc.inc +6 -3
  915. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +48 -38
  916. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/internal.h +5 -10
  917. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/internal.h +38 -0
  918. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/jitter.cc.inc +463 -0
  919. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/sha512.cc.inc +329 -0
  920. data/third_party/boringssl-with-bazel/crypto/fipsmodule/fips_shared_support.cc +4 -4
  921. data/third_party/boringssl-with-bazel/crypto/fipsmodule/hkdf/hkdf.cc.inc +8 -6
  922. data/third_party/boringssl-with-bazel/crypto/fipsmodule/hmac/hmac.cc.inc +19 -16
  923. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/internal.h +109 -14
  924. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/keccak.cc.inc +424 -56
  925. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/fips_known_values.inc +5 -5
  926. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/mldsa.cc.inc +1796 -773
  927. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/fips_known_values.inc +5 -5
  928. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/mlkem.cc.inc +902 -443
  929. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/android_entropy_client.cc.inc +82 -0
  930. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/ctrdrbg.cc.inc +240 -53
  931. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/internal.h +41 -26
  932. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/rand.cc.inc +221 -218
  933. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/internal.h +64 -67
  934. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/padding.cc.inc +49 -57
  935. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa.cc.inc +247 -234
  936. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa_impl.cc.inc +395 -695
  937. data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/fips.cc.inc +10 -10
  938. data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/self_check.cc.inc +479 -449
  939. data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/internal.h +34 -11
  940. data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/service_indicator.cc.inc +46 -43
  941. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/internal.h +61 -70
  942. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha1.cc.inc +29 -15
  943. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha256.cc.inc +46 -30
  944. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha512.cc.inc +47 -47
  945. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/address.h +98 -73
  946. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.cc.inc +108 -98
  947. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.h +14 -24
  948. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.cc.inc +94 -91
  949. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.h +19 -31
  950. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/params.h +156 -56
  951. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/slhdsa.cc.inc +318 -132
  952. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.cc.inc +234 -81
  953. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.h +20 -34
  954. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.cc.inc +97 -96
  955. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.h +10 -20
  956. data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/internal.h +2 -16
  957. data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/kdf.cc.inc +26 -26
  958. data/third_party/boringssl-with-bazel/crypto/fuzzer_mode.cc +5 -5
  959. data/third_party/boringssl-with-bazel/crypto/hpke/hpke.cc +531 -112
  960. data/third_party/boringssl-with-bazel/crypto/hrss/hrss.cc +165 -161
  961. data/third_party/boringssl-with-bazel/crypto/hrss/internal.h +9 -13
  962. data/third_party/boringssl-with-bazel/crypto/internal.h +594 -394
  963. data/third_party/boringssl-with-bazel/crypto/lhash/internal.h +38 -37
  964. data/third_party/boringssl-with-bazel/crypto/lhash/lhash.cc +68 -65
  965. data/third_party/boringssl-with-bazel/crypto/md4/md4.cc +19 -6
  966. data/third_party/boringssl-with-bazel/crypto/md5/internal.h +6 -9
  967. data/third_party/boringssl-with-bazel/crypto/md5/md5.cc +18 -6
  968. data/third_party/boringssl-with-bazel/crypto/mem.cc +61 -65
  969. data/third_party/boringssl-with-bazel/crypto/mem_internal.h +706 -0
  970. data/third_party/boringssl-with-bazel/crypto/mldsa/mldsa.cc +238 -32
  971. data/third_party/boringssl-with-bazel/crypto/mlkem/mlkem.cc +21 -65
  972. data/third_party/boringssl-with-bazel/crypto/obj/obj.cc +132 -157
  973. data/third_party/boringssl-with-bazel/crypto/obj/obj_dat.h +175 -1
  974. data/third_party/boringssl-with-bazel/crypto/obj/obj_xref.cc +14 -11
  975. data/third_party/boringssl-with-bazel/crypto/params_internal.h +30 -0
  976. data/third_party/boringssl-with-bazel/crypto/pem/internal.h +106 -15
  977. data/third_party/boringssl-with-bazel/crypto/pem/pem_all.cc +28 -24
  978. data/third_party/boringssl-with-bazel/crypto/pem/pem_info.cc +72 -76
  979. data/third_party/boringssl-with-bazel/crypto/pem/pem_lib.cc +239 -273
  980. data/third_party/boringssl-with-bazel/crypto/pem/pem_oth.cc +6 -6
  981. data/third_party/boringssl-with-bazel/crypto/pem/pem_pk8.cc +16 -13
  982. data/third_party/boringssl-with-bazel/crypto/pem/pem_pkey.cc +21 -15
  983. data/third_party/boringssl-with-bazel/crypto/pem/pem_x509.cc +3 -0
  984. data/third_party/boringssl-with-bazel/crypto/pem/pem_xaux.cc +3 -0
  985. data/third_party/boringssl-with-bazel/crypto/pkcs7/internal.h +12 -17
  986. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7.cc +29 -27
  987. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7_x509.cc +55 -49
  988. data/third_party/boringssl-with-bazel/crypto/pkcs8/internal.h +21 -26
  989. data/third_party/boringssl-with-bazel/crypto/pkcs8/p5_pbev2.cc +33 -31
  990. data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8.cc +73 -81
  991. data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8_x509.cc +140 -139
  992. data/third_party/boringssl-with-bazel/crypto/poly1305/internal.h +20 -7
  993. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305.cc +5 -4
  994. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_arm.cc +43 -59
  995. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_vec.cc +32 -29
  996. data/third_party/boringssl-with-bazel/crypto/pool/internal.h +64 -20
  997. data/third_party/boringssl-with-bazel/crypto/pool/pool.cc +177 -157
  998. data/third_party/boringssl-with-bazel/crypto/rand/deterministic.cc +9 -16
  999. data/third_party/boringssl-with-bazel/crypto/rand/fork_detect.cc +70 -42
  1000. data/third_party/boringssl-with-bazel/crypto/rand/forkunsafe.cc +7 -7
  1001. data/third_party/boringssl-with-bazel/crypto/rand/getentropy.cc +6 -13
  1002. data/third_party/boringssl-with-bazel/crypto/rand/internal.h +16 -4
  1003. data/third_party/boringssl-with-bazel/crypto/rand/ios.cc +4 -11
  1004. data/third_party/boringssl-with-bazel/crypto/rand/rand.cc +11 -9
  1005. data/third_party/boringssl-with-bazel/crypto/rand/trusty.cc +4 -11
  1006. data/third_party/boringssl-with-bazel/crypto/rand/urandom.cc +16 -195
  1007. data/third_party/boringssl-with-bazel/crypto/rand/windows.cc +12 -19
  1008. data/third_party/boringssl-with-bazel/crypto/refcount.cc +7 -17
  1009. data/third_party/boringssl-with-bazel/crypto/rsa/internal.h +22 -7
  1010. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_asn1.cc +199 -78
  1011. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_crypt.cc +49 -50
  1012. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_extra.cc +11 -0
  1013. data/third_party/boringssl-with-bazel/crypto/rsa/rsa_print.cc +4 -6
  1014. data/third_party/boringssl-with-bazel/crypto/sha/sha1.cc +3 -0
  1015. data/third_party/boringssl-with-bazel/crypto/sha/sha256.cc +3 -1
  1016. data/third_party/boringssl-with-bazel/crypto/sha/sha512.cc +6 -4
  1017. data/third_party/boringssl-with-bazel/crypto/siphash/siphash.cc +2 -0
  1018. data/third_party/boringssl-with-bazel/crypto/slhdsa/slhdsa.cc +60 -6
  1019. data/third_party/boringssl-with-bazel/crypto/spake2plus/internal.h +31 -31
  1020. data/third_party/boringssl-with-bazel/crypto/spake2plus/spake2plus.cc +1 -1
  1021. data/third_party/boringssl-with-bazel/crypto/stack/stack.cc +96 -130
  1022. data/third_party/boringssl-with-bazel/crypto/thread.cc +14 -14
  1023. data/third_party/boringssl-with-bazel/crypto/thread_none.cc +10 -13
  1024. data/third_party/boringssl-with-bazel/crypto/thread_pthread.cc +22 -35
  1025. data/third_party/boringssl-with-bazel/crypto/thread_win.cc +29 -40
  1026. data/third_party/boringssl-with-bazel/crypto/trust_token/internal.h +81 -88
  1027. data/third_party/boringssl-with-bazel/crypto/trust_token/pmbtoken.cc +160 -144
  1028. data/third_party/boringssl-with-bazel/crypto/trust_token/trust_token.cc +96 -80
  1029. data/third_party/boringssl-with-bazel/crypto/trust_token/voprf.cc +90 -87
  1030. data/third_party/boringssl-with-bazel/crypto/x509/a_digest.cc +5 -5
  1031. data/third_party/boringssl-with-bazel/crypto/x509/a_sign.cc +51 -48
  1032. data/third_party/boringssl-with-bazel/crypto/x509/a_verify.cc +39 -36
  1033. data/third_party/boringssl-with-bazel/crypto/x509/algorithm.cc +47 -16
  1034. data/third_party/boringssl-with-bazel/crypto/x509/asn1_gen.cc +41 -43
  1035. data/third_party/boringssl-with-bazel/crypto/x509/by_dir.cc +183 -237
  1036. data/third_party/boringssl-with-bazel/crypto/x509/by_file.cc +29 -30
  1037. data/third_party/boringssl-with-bazel/crypto/x509/internal.h +346 -216
  1038. data/third_party/boringssl-with-bazel/crypto/x509/name_print.cc +15 -13
  1039. data/third_party/boringssl-with-bazel/crypto/x509/policy.cc +415 -525
  1040. data/third_party/boringssl-with-bazel/crypto/x509/rsa_pss.cc +95 -272
  1041. data/third_party/boringssl-with-bazel/crypto/x509/t_crl.cc +11 -8
  1042. data/third_party/boringssl-with-bazel/crypto/x509/t_req.cc +26 -23
  1043. data/third_party/boringssl-with-bazel/crypto/x509/t_x509.cc +27 -22
  1044. data/third_party/boringssl-with-bazel/crypto/x509/t_x509a.cc +3 -1
  1045. data/third_party/boringssl-with-bazel/crypto/x509/v3_akey.cc +69 -76
  1046. data/third_party/boringssl-with-bazel/crypto/x509/v3_akeya.cc +2 -2
  1047. data/third_party/boringssl-with-bazel/crypto/x509/v3_alt.cc +112 -69
  1048. data/third_party/boringssl-with-bazel/crypto/x509/v3_bcons.cc +15 -14
  1049. data/third_party/boringssl-with-bazel/crypto/x509/v3_bitst.cc +16 -18
  1050. data/third_party/boringssl-with-bazel/crypto/x509/v3_conf.cc +62 -67
  1051. data/third_party/boringssl-with-bazel/crypto/x509/v3_cpols.cc +143 -170
  1052. data/third_party/boringssl-with-bazel/crypto/x509/v3_crld.cc +123 -209
  1053. data/third_party/boringssl-with-bazel/crypto/x509/v3_enum.cc +13 -12
  1054. data/third_party/boringssl-with-bazel/crypto/x509/v3_extku.cc +17 -34
  1055. data/third_party/boringssl-with-bazel/crypto/x509/v3_genn.cc +20 -10
  1056. data/third_party/boringssl-with-bazel/crypto/x509/v3_ia5.cc +22 -18
  1057. data/third_party/boringssl-with-bazel/crypto/x509/v3_info.cc +45 -47
  1058. data/third_party/boringssl-with-bazel/crypto/x509/v3_int.cc +35 -33
  1059. data/third_party/boringssl-with-bazel/crypto/x509/v3_lib.cc +106 -61
  1060. data/third_party/boringssl-with-bazel/crypto/x509/v3_ncons.cc +642 -358
  1061. data/third_party/boringssl-with-bazel/crypto/x509/v3_ocsp.cc +25 -22
  1062. data/third_party/boringssl-with-bazel/crypto/x509/v3_pcons.cc +15 -14
  1063. data/third_party/boringssl-with-bazel/crypto/x509/v3_pmaps.cc +16 -15
  1064. data/third_party/boringssl-with-bazel/crypto/x509/v3_prn.cc +6 -6
  1065. data/third_party/boringssl-with-bazel/crypto/x509/v3_purp.cc +149 -159
  1066. data/third_party/boringssl-with-bazel/crypto/x509/v3_skey.cc +23 -26
  1067. data/third_party/boringssl-with-bazel/crypto/x509/v3_utl.cc +161 -192
  1068. data/third_party/boringssl-with-bazel/crypto/x509/x509.cc +1 -1
  1069. data/third_party/boringssl-with-bazel/crypto/x509/x509_att.cc +32 -30
  1070. data/third_party/boringssl-with-bazel/crypto/x509/x509_cmp.cc +95 -90
  1071. data/third_party/boringssl-with-bazel/crypto/x509/x509_d2.cc +9 -9
  1072. data/third_party/boringssl-with-bazel/crypto/x509/x509_def.cc +6 -8
  1073. data/third_party/boringssl-with-bazel/crypto/x509/x509_ext.cc +46 -24
  1074. data/third_party/boringssl-with-bazel/crypto/x509/x509_lu.cc +211 -195
  1075. data/third_party/boringssl-with-bazel/crypto/x509/x509_mtc.cc +598 -0
  1076. data/third_party/boringssl-with-bazel/crypto/x509/x509_obj.cc +23 -18
  1077. data/third_party/boringssl-with-bazel/crypto/x509/x509_req.cc +37 -46
  1078. data/third_party/boringssl-with-bazel/crypto/x509/x509_set.cc +58 -90
  1079. data/third_party/boringssl-with-bazel/crypto/x509/x509_trs.cc +18 -13
  1080. data/third_party/boringssl-with-bazel/crypto/x509/x509_v3.cc +33 -33
  1081. data/third_party/boringssl-with-bazel/crypto/x509/x509_vfy.cc +398 -474
  1082. data/third_party/boringssl-with-bazel/crypto/x509/x509_vpm.cc +57 -48
  1083. data/third_party/boringssl-with-bazel/crypto/x509/x509cset.cc +27 -40
  1084. data/third_party/boringssl-with-bazel/crypto/x509/x509name.cc +91 -79
  1085. data/third_party/boringssl-with-bazel/crypto/x509/x509rset.cc +5 -17
  1086. data/third_party/boringssl-with-bazel/crypto/x509/x509spki.cc +13 -13
  1087. data/third_party/boringssl-with-bazel/crypto/x509/x_algor.cc +131 -24
  1088. data/third_party/boringssl-with-bazel/crypto/x509/x_all.cc +73 -39
  1089. data/third_party/boringssl-with-bazel/crypto/x509/x_attrib.cc +10 -4
  1090. data/third_party/boringssl-with-bazel/crypto/x509/x_crl.cc +76 -93
  1091. data/third_party/boringssl-with-bazel/crypto/x509/x_exten.cc +6 -0
  1092. data/third_party/boringssl-with-bazel/crypto/x509/x_name.cc +294 -388
  1093. data/third_party/boringssl-with-bazel/crypto/x509/x_pubkey.cc +113 -84
  1094. data/third_party/boringssl-with-bazel/crypto/x509/x_req.cc +12 -6
  1095. data/third_party/boringssl-with-bazel/crypto/x509/x_sig.cc +4 -4
  1096. data/third_party/boringssl-with-bazel/crypto/x509/x_spki.cc +11 -1
  1097. data/third_party/boringssl-with-bazel/crypto/x509/x_x509.cc +282 -277
  1098. data/third_party/boringssl-with-bazel/crypto/x509/x_x509a.cc +60 -60
  1099. data/third_party/boringssl-with-bazel/crypto/xwing/xwing.cc +257 -0
  1100. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +325 -0
  1101. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +325 -0
  1102. data/third_party/boringssl-with-bazel/gen/crypto/err_data.cc +538 -500
  1103. data/third_party/boringssl-with-bazel/include/openssl/aead.h +279 -119
  1104. data/third_party/boringssl-with-bazel/include/openssl/aes.h +43 -43
  1105. data/third_party/boringssl-with-bazel/include/openssl/asm_base.h +30 -17
  1106. data/third_party/boringssl-with-bazel/include/openssl/asn1.h +641 -635
  1107. data/third_party/boringssl-with-bazel/include/openssl/asn1t.h +7 -9
  1108. data/third_party/boringssl-with-bazel/include/openssl/base.h +76 -69
  1109. data/third_party/boringssl-with-bazel/include/openssl/base64.h +30 -30
  1110. data/third_party/boringssl-with-bazel/include/openssl/bio.h +394 -322
  1111. data/third_party/boringssl-with-bazel/include/openssl/blake2.h +15 -11
  1112. data/third_party/boringssl-with-bazel/include/openssl/blowfish.h +10 -3
  1113. data/third_party/boringssl-with-bazel/include/openssl/bn.h +298 -306
  1114. data/third_party/boringssl-with-bazel/include/openssl/buf.h +14 -14
  1115. data/third_party/boringssl-with-bazel/include/openssl/bytestring.h +305 -208
  1116. data/third_party/boringssl-with-bazel/include/openssl/cast.h +45 -8
  1117. data/third_party/boringssl-with-bazel/include/openssl/chacha.h +3 -3
  1118. data/third_party/boringssl-with-bazel/include/openssl/cipher.h +345 -161
  1119. data/third_party/boringssl-with-bazel/include/openssl/cmac.h +13 -13
  1120. data/third_party/boringssl-with-bazel/include/openssl/cms.h +35 -34
  1121. data/third_party/boringssl-with-bazel/include/openssl/conf.h +15 -14
  1122. data/third_party/boringssl-with-bazel/include/openssl/configuration.h +18 -0
  1123. data/third_party/boringssl-with-bazel/include/openssl/crypto.h +15 -13
  1124. data/third_party/boringssl-with-bazel/include/openssl/ctrdrbg.h +49 -15
  1125. data/third_party/boringssl-with-bazel/include/openssl/curve25519.h +60 -24
  1126. data/third_party/boringssl-with-bazel/include/openssl/des.h +22 -16
  1127. data/third_party/boringssl-with-bazel/include/openssl/dh.h +95 -95
  1128. data/third_party/boringssl-with-bazel/include/openssl/digest.h +144 -75
  1129. data/third_party/boringssl-with-bazel/include/openssl/dsa.h +101 -101
  1130. data/third_party/boringssl-with-bazel/include/openssl/ec.h +178 -120
  1131. data/third_party/boringssl-with-bazel/include/openssl/ec_key.h +99 -99
  1132. data/third_party/boringssl-with-bazel/include/openssl/ecdh.h +9 -9
  1133. data/third_party/boringssl-with-bazel/include/openssl/ecdsa.h +89 -46
  1134. data/third_party/boringssl-with-bazel/include/openssl/engine.h +5 -5
  1135. data/third_party/boringssl-with-bazel/include/openssl/err.h +73 -71
  1136. data/third_party/boringssl-with-bazel/include/openssl/evp.h +941 -344
  1137. data/third_party/boringssl-with-bazel/include/openssl/evp_errors.h +10 -2
  1138. data/third_party/boringssl-with-bazel/include/openssl/ex_data.h +27 -32
  1139. data/third_party/boringssl-with-bazel/include/openssl/hkdf.h +6 -6
  1140. data/third_party/boringssl-with-bazel/include/openssl/hmac.h +33 -33
  1141. data/third_party/boringssl-with-bazel/include/openssl/hpke.h +170 -123
  1142. data/third_party/boringssl-with-bazel/include/openssl/hrss.h +14 -8
  1143. data/third_party/boringssl-with-bazel/include/openssl/kdf.h +20 -19
  1144. data/third_party/boringssl-with-bazel/include/openssl/lhash.h +4 -25
  1145. data/third_party/boringssl-with-bazel/include/openssl/md4.h +14 -7
  1146. data/third_party/boringssl-with-bazel/include/openssl/md5.h +7 -7
  1147. data/third_party/boringssl-with-bazel/include/openssl/mem.h +42 -42
  1148. data/third_party/boringssl-with-bazel/include/openssl/mldsa.h +380 -24
  1149. data/third_party/boringssl-with-bazel/include/openssl/mlkem.h +43 -43
  1150. data/third_party/boringssl-with-bazel/include/openssl/nid.h +1339 -2
  1151. data/third_party/boringssl-with-bazel/include/openssl/obj.h +49 -49
  1152. data/third_party/boringssl-with-bazel/include/openssl/opensslconf.h +30 -0
  1153. data/third_party/boringssl-with-bazel/include/openssl/params.h +42 -0
  1154. data/third_party/boringssl-with-bazel/include/openssl/pem.h +669 -361
  1155. data/third_party/boringssl-with-bazel/include/openssl/pkcs7.h +40 -40
  1156. data/third_party/boringssl-with-bazel/include/openssl/pkcs8.h +69 -63
  1157. data/third_party/boringssl-with-bazel/include/openssl/poly1305.h +8 -5
  1158. data/third_party/boringssl-with-bazel/include/openssl/pool.h +54 -25
  1159. data/third_party/boringssl-with-bazel/include/openssl/posix_time.h +8 -8
  1160. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols.h +7992 -0
  1161. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_S.h +633 -0
  1162. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_c.h +329 -0
  1163. data/third_party/boringssl-with-bazel/include/openssl/rand.h +18 -18
  1164. data/third_party/boringssl-with-bazel/include/openssl/rc4.h +4 -4
  1165. data/third_party/boringssl-with-bazel/include/openssl/ripemd.h +15 -10
  1166. data/third_party/boringssl-with-bazel/include/openssl/rsa.h +272 -235
  1167. data/third_party/boringssl-with-bazel/include/openssl/service_indicator.h +4 -81
  1168. data/third_party/boringssl-with-bazel/include/openssl/sha.h +43 -166
  1169. data/third_party/boringssl-with-bazel/include/openssl/sha2.h +201 -0
  1170. data/third_party/boringssl-with-bazel/include/openssl/slhdsa.h +125 -49
  1171. data/third_party/boringssl-with-bazel/include/openssl/span.h +190 -75
  1172. data/third_party/boringssl-with-bazel/include/openssl/ssl.h +2403 -1633
  1173. data/third_party/boringssl-with-bazel/include/openssl/ssl3.h +11 -69
  1174. data/third_party/boringssl-with-bazel/include/openssl/stack.h +144 -80
  1175. data/third_party/boringssl-with-bazel/include/openssl/target.h +13 -1
  1176. data/third_party/boringssl-with-bazel/include/openssl/thread.h +0 -10
  1177. data/third_party/boringssl-with-bazel/include/openssl/tls1.h +31 -310
  1178. data/third_party/boringssl-with-bazel/include/openssl/tls_prf.h +47 -0
  1179. data/third_party/boringssl-with-bazel/include/openssl/trust_token.h +97 -92
  1180. data/third_party/boringssl-with-bazel/include/openssl/type_check.h +1 -1
  1181. data/third_party/boringssl-with-bazel/include/openssl/types.h +18 -0
  1182. data/third_party/boringssl-with-bazel/include/openssl/x509.h +1839 -1872
  1183. data/third_party/boringssl-with-bazel/include/openssl/x509v3.h +1 -1
  1184. data/third_party/boringssl-with-bazel/include/openssl/xwing.h +115 -0
  1185. data/third_party/boringssl-with-bazel/ssl/bio_ssl.cc +22 -19
  1186. data/third_party/boringssl-with-bazel/ssl/d1_both.cc +202 -135
  1187. data/third_party/boringssl-with-bazel/ssl/d1_lib.cc +84 -68
  1188. data/third_party/boringssl-with-bazel/ssl/d1_pkt.cc +10 -10
  1189. data/third_party/boringssl-with-bazel/ssl/d1_srtp.cc +12 -10
  1190. data/third_party/boringssl-with-bazel/ssl/dtls_method.cc +14 -14
  1191. data/third_party/boringssl-with-bazel/ssl/dtls_record.cc +21 -20
  1192. data/third_party/boringssl-with-bazel/ssl/encrypted_client_hello.cc +102 -96
  1193. data/third_party/boringssl-with-bazel/ssl/extensions.cc +1083 -500
  1194. data/third_party/boringssl-with-bazel/ssl/handoff.cc +154 -100
  1195. data/third_party/boringssl-with-bazel/ssl/handshake.cc +76 -44
  1196. data/third_party/boringssl-with-bazel/ssl/handshake_client.cc +153 -152
  1197. data/third_party/boringssl-with-bazel/ssl/handshake_server.cc +180 -212
  1198. data/third_party/boringssl-with-bazel/ssl/internal.h +1368 -1481
  1199. data/third_party/boringssl-with-bazel/ssl/s3_both.cc +40 -168
  1200. data/third_party/boringssl-with-bazel/ssl/s3_lib.cc +5 -5
  1201. data/third_party/boringssl-with-bazel/ssl/s3_pkt.cc +22 -21
  1202. data/third_party/boringssl-with-bazel/ssl/ssl_aead_ctx.cc +5 -5
  1203. data/third_party/boringssl-with-bazel/ssl/ssl_asn1.cc +123 -68
  1204. data/third_party/boringssl-with-bazel/ssl/ssl_buffer.cc +25 -26
  1205. data/third_party/boringssl-with-bazel/ssl/ssl_cert.cc +156 -84
  1206. data/third_party/boringssl-with-bazel/ssl/ssl_cipher.cc +341 -160
  1207. data/third_party/boringssl-with-bazel/ssl/ssl_credential.cc +349 -124
  1208. data/third_party/boringssl-with-bazel/ssl/ssl_file.cc +134 -225
  1209. data/third_party/boringssl-with-bazel/ssl/ssl_key_share.cc +80 -101
  1210. data/third_party/boringssl-with-bazel/ssl/ssl_lib.cc +1403 -694
  1211. data/third_party/boringssl-with-bazel/ssl/ssl_privkey.cc +173 -105
  1212. data/third_party/boringssl-with-bazel/ssl/ssl_session.cc +287 -235
  1213. data/third_party/boringssl-with-bazel/ssl/ssl_stat.cc +6 -3
  1214. data/third_party/boringssl-with-bazel/ssl/ssl_transcript.cc +4 -4
  1215. data/third_party/boringssl-with-bazel/ssl/ssl_versions.cc +47 -41
  1216. data/third_party/boringssl-with-bazel/ssl/ssl_x509.cc +321 -273
  1217. data/third_party/boringssl-with-bazel/ssl/t1_enc.cc +40 -29
  1218. data/third_party/boringssl-with-bazel/ssl/tls13_both.cc +109 -75
  1219. data/third_party/boringssl-with-bazel/ssl/tls13_client.cc +201 -115
  1220. data/third_party/boringssl-with-bazel/ssl/tls13_enc.cc +179 -124
  1221. data/third_party/boringssl-with-bazel/ssl/tls13_server.cc +241 -158
  1222. data/third_party/boringssl-with-bazel/ssl/tls_method.cc +35 -35
  1223. data/third_party/boringssl-with-bazel/ssl/tls_record.cc +40 -34
  1224. data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_bareminimum.c.inc +47 -0
  1225. data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_platform.c.inc +137 -0
  1226. data/third_party/boringssl-with-bazel/third_party/fiat/curve25519_64_adx.h +37 -33
  1227. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64.h +29 -80
  1228. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64_msvc.h +6 -69
  1229. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field.c.inc +26 -0
  1230. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_32.br.c.inc +71 -0
  1231. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_64.br.c.inc +84 -0
  1232. data/third_party/boringssl-with-bazel/third_party/fiat/p256_point.br.c.inc +112 -0
  1233. data/third_party/cares/cares/include/ares.h +8 -0
  1234. data/third_party/cares/cares/include/ares_dns_record.h +3 -2
  1235. data/third_party/cares/cares/include/ares_version.h +3 -3
  1236. data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +20 -20
  1237. data/third_party/cares/cares/src/lib/ares_cancel.c +17 -8
  1238. data/third_party/cares/cares/src/lib/ares_close_sockets.c +81 -16
  1239. data/third_party/cares/cares/src/lib/ares_conn.c +256 -10
  1240. data/third_party/cares/cares/src/lib/ares_conn.h +40 -3
  1241. data/third_party/cares/cares/src/lib/ares_cookie.c +2 -2
  1242. data/third_party/cares/cares/src/lib/ares_destroy.c +75 -10
  1243. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +85 -10
  1244. data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +5 -0
  1245. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +4 -0
  1246. data/third_party/cares/cares/src/lib/ares_getnameinfo.c +10 -2
  1247. data/third_party/cares/cares/src/lib/ares_hosts_file.c +8 -0
  1248. data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +28 -0
  1249. data/third_party/cares/cares/src/lib/ares_init.c +55 -10
  1250. data/third_party/cares/cares/src/lib/ares_library_init.c +25 -7
  1251. data/third_party/cares/cares/src/lib/ares_options.c +38 -10
  1252. data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +1 -1
  1253. data/third_party/cares/cares/src/lib/ares_private.h +186 -27
  1254. data/third_party/cares/cares/src/lib/ares_process.c +604 -112
  1255. data/third_party/cares/cares/src/lib/ares_qcache.c +200 -36
  1256. data/third_party/cares/cares/src/lib/ares_query.c +5 -0
  1257. data/third_party/cares/cares/src/lib/ares_search.c +10 -0
  1258. data/third_party/cares/cares/src/lib/ares_send.c +81 -10
  1259. data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +3 -1
  1260. data/third_party/cares/cares/src/lib/ares_socket.c +28 -0
  1261. data/third_party/cares/cares/src/lib/ares_socket.h +23 -0
  1262. data/third_party/cares/cares/src/lib/ares_sysconfig.c +6 -3
  1263. data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +33 -11
  1264. data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +132 -80
  1265. data/third_party/cares/cares/src/lib/ares_timeout.c +11 -0
  1266. data/third_party/cares/cares/src/lib/ares_update_servers.c +55 -11
  1267. data/third_party/cares/cares/src/lib/dsa/ares_array.c +20 -5
  1268. data/third_party/cares/cares/src/lib/dsa/ares_htable.c +8 -4
  1269. data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +2 -0
  1270. data/third_party/cares/cares/src/lib/dsa/ares_llist.c +4 -1
  1271. data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +5 -2
  1272. data/third_party/cares/cares/src/lib/event/ares_event_select.c +14 -1
  1273. data/third_party/cares/cares/src/lib/event/ares_event_thread.c +8 -0
  1274. data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +7 -1
  1275. data/third_party/cares/cares/src/lib/event/ares_event_win32.c +3 -0
  1276. data/third_party/cares/cares/src/lib/include/ares_mem.h +3 -0
  1277. data/third_party/cares/cares/src/lib/include/ares_str.h +17 -0
  1278. data/third_party/cares/cares/src/lib/inet_net_pton.c +37 -28
  1279. data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +1 -1
  1280. data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +5 -2
  1281. data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +5 -2
  1282. data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +2 -2
  1283. data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +2 -2
  1284. data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +1 -1
  1285. data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +19 -4
  1286. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +3 -1
  1287. data/third_party/cares/cares/src/lib/record/ares_dns_name.c +67 -4
  1288. data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +62 -34
  1289. data/third_party/cares/cares/src/lib/record/ares_dns_private.h +4 -0
  1290. data/third_party/cares/cares/src/lib/record/ares_dns_record.c +47 -7
  1291. data/third_party/cares/cares/src/lib/record/ares_dns_write.c +13 -5
  1292. data/third_party/cares/cares/src/lib/str/ares_buf.c +33 -16
  1293. data/third_party/cares/cares/src/lib/str/ares_str.c +54 -0
  1294. data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +22 -10
  1295. data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +1 -0
  1296. data/third_party/cares/cares/src/lib/util/ares_math.c +17 -2
  1297. data/third_party/cares/cares/src/lib/util/ares_math.h +32 -7
  1298. data/third_party/cares/cares/src/lib/util/ares_rand.c +4 -4
  1299. data/third_party/cares/cares/src/lib/util/ares_threads.c +1 -2
  1300. data/third_party/cares/cares/src/lib/util/ares_time.h +1 -0
  1301. data/third_party/cares/cares/src/lib/util/ares_uri.c +9 -3
  1302. data/third_party/zlib/compress.c +34 -10
  1303. data/third_party/zlib/crc32.c +49 -115
  1304. data/third_party/zlib/deflate.c +107 -61
  1305. data/third_party/zlib/deflate.h +7 -1
  1306. data/third_party/zlib/gzguts.h +33 -31
  1307. data/third_party/zlib/infback.c +20 -67
  1308. data/third_party/zlib/inffast.c +7 -6
  1309. data/third_party/zlib/inffixed.h +91 -91
  1310. data/third_party/zlib/inflate.c +38 -151
  1311. data/third_party/zlib/inflate.h +1 -1
  1312. data/third_party/zlib/inftrees.c +134 -9
  1313. data/third_party/zlib/inftrees.h +3 -1
  1314. data/third_party/zlib/trees.c +14 -12
  1315. data/third_party/zlib/uncompr.c +39 -23
  1316. data/third_party/zlib/zconf.h +27 -19
  1317. data/third_party/zlib/zlib.h +215 -96
  1318. data/third_party/zlib/zutil.c +49 -35
  1319. data/third_party/zlib/zutil.h +87 -10
  1320. metadata +4095 -4024
  1321. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +0 -916
  1322. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +0 -84
  1323. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +0 -240
  1324. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +0 -56
  1325. data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb.h +0 -157
  1326. data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb_minitable.c +0 -72
  1327. data/src/core/ext/upbdefs-gen/src/proto/grpc/lookup/v1/rls_config.upbdefs.c +0 -181
  1328. data/src/core/server/xds_channel_stack_modifier.cc +0 -108
  1329. data/src/core/server/xds_channel_stack_modifier.h +0 -62
  1330. data/src/core/server/xds_server_config_fetcher_legacy.cc +0 -1340
  1331. data/third_party/abseil-cpp/absl/base/internal/identity.h +0 -39
  1332. data/third_party/abseil-cpp/absl/base/internal/nullability_deprecated.h +0 -106
  1333. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +0 -105
  1334. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +0 -50
  1335. data/third_party/abseil-cpp/absl/strings/string_view.cc +0 -257
  1336. data/third_party/boringssl-with-bazel/crypto/evp/p_dh_asn1.cc +0 -142
  1337. data/third_party/boringssl-with-bazel/crypto/evp/p_dsa_asn1.cc +0 -279
  1338. data/third_party/boringssl-with-bazel/crypto/evp/p_ec_asn1.cc +0 -286
  1339. data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519_asn1.cc +0 -225
  1340. data/third_party/boringssl-with-bazel/crypto/evp/p_rsa_asn1.cc +0 -198
  1341. data/third_party/boringssl-with-bazel/crypto/evp/p_x25519_asn1.cc +0 -237
  1342. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p224-64.cc.inc +0 -1163
  1343. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/blinding.cc.inc +0 -147
  1344. data/third_party/boringssl-with-bazel/crypto/kyber/internal.h +0 -60
  1345. data/third_party/boringssl-with-bazel/crypto/kyber/kyber.cc +0 -869
  1346. data/third_party/boringssl-with-bazel/crypto/rand/getrandom_fillin.h +0 -64
  1347. data/third_party/boringssl-with-bazel/crypto/rand/passive.cc +0 -178
  1348. data/third_party/boringssl-with-bazel/crypto/x509/ext_dat.h +0 -92
  1349. data/third_party/boringssl-with-bazel/include/openssl/bcm_public.h +0 -82
  1350. data/third_party/boringssl-with-bazel/include/openssl/experimental/kyber.h +0 -146
@@ -17,6 +17,8 @@
17
17
  #include <openssl/ssl.h>
18
18
 
19
19
  #include <algorithm>
20
+ #include <iterator>
21
+ #include <utility>
20
22
 
21
23
  #include <assert.h>
22
24
  #include <limits.h>
@@ -26,10 +28,12 @@
26
28
  #include <openssl/bytestring.h>
27
29
  #include <openssl/crypto.h>
28
30
  #include <openssl/err.h>
29
- #include <openssl/lhash.h>
31
+ #include <openssl/evp.h>
30
32
  #include <openssl/mem.h>
33
+ #include <openssl/nid.h>
31
34
  #include <openssl/rand.h>
32
35
 
36
+ #include "../crypto/bytestring/internal.h"
33
37
  #include "../crypto/internal.h"
34
38
  #include "internal.h"
35
39
 
@@ -47,7 +51,7 @@ static_assert(SSL3_RT_MAX_ENCRYPTED_OVERHEAD >=
47
51
  SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD,
48
52
  "max overheads are inconsistent");
49
53
 
50
- // |SSL_R_UNKNOWN_PROTOCOL| is no longer emitted, but continue to define it
54
+ // `SSL_R_UNKNOWN_PROTOCOL` is no longer emitted, but continue to define it
51
55
  // to avoid downstream churn.
52
56
  OPENSSL_DECLARE_ERROR_REASON(SSL, UNKNOWN_PROTOCOL)
53
57
 
@@ -65,36 +69,23 @@ static_assert(SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ==
65
69
  // kMaxHandshakeSize is the maximum size, in bytes, of a handshake message.
66
70
  static const size_t kMaxHandshakeSize = (1u << 24) - 1;
67
71
 
68
- static CRYPTO_EX_DATA_CLASS g_ex_data_class_ssl =
69
- CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA;
70
- static CRYPTO_EX_DATA_CLASS g_ex_data_class_ssl_ctx =
71
- CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA;
72
+ static ExDataClass g_ex_data_class_ssl(/*with_app_data=*/true);
73
+ static ExDataClass g_ex_data_class_ssl_ctx(/*with_app_data=*/true);
72
74
 
73
- bool CBBFinishArray(CBB *cbb, Array<uint8_t> *out) {
74
- uint8_t *ptr;
75
- size_t len;
76
- if (!CBB_finish(cbb, &ptr, &len)) {
77
- OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
78
- return false;
79
- }
80
- out->Reset(ptr, len);
81
- return true;
82
- }
83
-
84
- void ssl_reset_error_state(SSL *ssl) {
85
- // Functions which use |SSL_get_error| must reset I/O and error state on
75
+ void ssl_reset_error_state(SSLImpl *ssl) {
76
+ // Functions which use `SSL_get_error` must reset I/O and error state on
86
77
  // entry.
87
78
  ssl->s3->rwstate = SSL_ERROR_NONE;
88
79
  ERR_clear_error();
89
80
  ERR_clear_system_error();
90
81
  }
91
82
 
92
- void ssl_set_read_error(SSL *ssl) {
83
+ void ssl_set_read_error(SSLImpl *ssl) {
93
84
  ssl->s3->read_shutdown = ssl_shutdown_error;
94
85
  ssl->s3->read_error.reset(ERR_save_state());
95
86
  }
96
87
 
97
- static bool check_read_error(const SSL *ssl) {
88
+ static bool check_read_error(const SSLImpl *ssl) {
98
89
  if (ssl->s3->read_shutdown == ssl_shutdown_error) {
99
90
  ERR_restore_state(ssl->s3->read_error.get());
100
91
  return false;
@@ -102,15 +93,15 @@ static bool check_read_error(const SSL *ssl) {
102
93
  return true;
103
94
  }
104
95
 
105
- bool ssl_can_write(const SSL *ssl) {
96
+ bool ssl_can_write(const SSLImpl *ssl) {
106
97
  return !SSL_in_init(ssl) || ssl->s3->hs->can_early_write;
107
98
  }
108
99
 
109
- bool ssl_can_read(const SSL *ssl) {
100
+ bool ssl_can_read(const SSLImpl *ssl) {
110
101
  return !SSL_in_init(ssl) || ssl->s3->hs->can_early_read;
111
102
  }
112
103
 
113
- ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
104
+ ssl_open_record_t ssl_open_handshake(SSLImpl *ssl, size_t *out_consumed,
114
105
  uint8_t *out_alert, Span<uint8_t> in) {
115
106
  *out_consumed = 0;
116
107
  if (!check_read_error(ssl)) {
@@ -124,7 +115,8 @@ ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
124
115
  return ret;
125
116
  }
126
117
 
127
- ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
118
+ ssl_open_record_t ssl_open_change_cipher_spec(SSLImpl *ssl,
119
+ size_t *out_consumed,
128
120
  uint8_t *out_alert,
129
121
  Span<uint8_t> in) {
130
122
  *out_consumed = 0;
@@ -140,7 +132,7 @@ ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
140
132
  return ret;
141
133
  }
142
134
 
143
- ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
135
+ ssl_open_record_t ssl_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
144
136
  size_t *out_consumed, uint8_t *out_alert,
145
137
  Span<uint8_t> in) {
146
138
  *out_consumed = 0;
@@ -175,9 +167,9 @@ static bool cbb_add_hex_consttime(CBB *cbb, Span<const uint8_t> in) {
175
167
  return true;
176
168
  }
177
169
 
178
- bool ssl_log_secret(const SSL *ssl, const char *label,
170
+ bool ssl_log_secret(const SSLImpl *ssl, const char *label,
179
171
  Span<const uint8_t> secret) {
180
- if (ssl->ctx->keylog_callback == NULL) {
172
+ if (ssl->ctx->keylog_callback == nullptr) {
181
173
  return true;
182
174
  }
183
175
 
@@ -190,7 +182,7 @@ bool ssl_log_secret(const SSL *ssl, const char *label,
190
182
  !CBB_add_u8(cbb.get(), ' ') ||
191
183
  !cbb_add_hex_consttime(cbb.get(), ssl->s3->client_random) ||
192
184
  !CBB_add_u8(cbb.get(), ' ') ||
193
- // Convert to hex in constant time to avoid leaking |secret|. If the
185
+ // Convert to hex in constant time to avoid leaking `secret`. If the
194
186
  // callback discards the data, we should not introduce side channels.
195
187
  !cbb_add_hex_consttime(cbb.get(), secret) ||
196
188
  !CBB_add_u8(cbb.get(), 0 /* NUL */) ||
@@ -202,26 +194,26 @@ bool ssl_log_secret(const SSL *ssl, const char *label,
202
194
  return true;
203
195
  }
204
196
 
205
- void ssl_do_info_callback(const SSL *ssl, int type, int value) {
206
- void (*cb)(const SSL *ssl, int type, int value) = NULL;
207
- if (ssl->info_callback != NULL) {
197
+ void ssl_do_info_callback(const SSLImpl *ssl, int type, int value) {
198
+ void (*cb)(const SSL *ssl, int type, int value) = nullptr;
199
+ if (ssl->info_callback != nullptr) {
208
200
  cb = ssl->info_callback;
209
- } else if (ssl->ctx->info_callback != NULL) {
201
+ } else if (ssl->ctx->info_callback != nullptr) {
210
202
  cb = ssl->ctx->info_callback;
211
203
  }
212
204
 
213
- if (cb != NULL) {
205
+ if (cb != nullptr) {
214
206
  cb(ssl, type, value);
215
207
  }
216
208
  }
217
209
 
218
- void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type,
210
+ void ssl_do_msg_callback(const SSLImpl *ssl, int is_write, int content_type,
219
211
  Span<const uint8_t> in) {
220
- if (ssl->msg_callback == NULL) {
212
+ if (ssl->msg_callback == nullptr) {
221
213
  return;
222
214
  }
223
215
 
224
- // |version| is zero when calling for |SSL3_RT_HEADER| and |SSL2_VERSION| for
216
+ // `version` is zero when calling for `SSL3_RT_HEADER` and `SSL2_VERSION` for
225
217
  // a V2ClientHello.
226
218
  int version;
227
219
  switch (content_type) {
@@ -237,11 +229,11 @@ void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type,
237
229
  }
238
230
 
239
231
  ssl->msg_callback(is_write, version, content_type, in.data(), in.size(),
240
- const_cast<SSL *>(ssl), ssl->msg_callback_arg);
232
+ const_cast<SSLImpl *>(ssl), ssl->msg_callback_arg);
241
233
  }
242
234
 
243
- OPENSSL_timeval ssl_ctx_get_current_time(const SSL_CTX *ctx) {
244
- if (ctx->current_time_cb != NULL) {
235
+ OPENSSL_timeval ssl_ctx_get_current_time(const SSLContext *ctx) {
236
+ if (ctx->current_time_cb != nullptr) {
245
237
  // TODO(davidben): Update current_time_cb to use OPENSSL_timeval. See
246
238
  // https://crbug.com/boringssl/155.
247
239
  struct timeval clock;
@@ -267,7 +259,7 @@ OPENSSL_timeval ssl_ctx_get_current_time(const SSL_CTX *ctx) {
267
259
  }
268
260
  #else
269
261
  struct timeval clock;
270
- gettimeofday(&clock, NULL);
262
+ gettimeofday(&clock, nullptr);
271
263
  if (clock.tv_sec < 0) {
272
264
  assert(0);
273
265
  return {0, 0};
@@ -278,9 +270,11 @@ OPENSSL_timeval ssl_ctx_get_current_time(const SSL_CTX *ctx) {
278
270
  #endif
279
271
  }
280
272
 
281
- void SSL_CTX_set_handoff_mode(SSL_CTX *ctx, bool on) { ctx->handoff = on; }
273
+ void SSL_CTX_set_handoff_mode(SSL_CTX *ctx, bool on) {
274
+ FromOpaque(ctx)->handoff = on;
275
+ }
282
276
 
283
- static bool ssl_can_renegotiate(const SSL *ssl) {
277
+ static bool ssl_can_renegotiate(const SSLImpl *ssl) {
284
278
  if (ssl->server || SSL_is_dtls(ssl)) {
285
279
  return false;
286
280
  }
@@ -311,7 +305,7 @@ static bool ssl_can_renegotiate(const SSL *ssl) {
311
305
  return false;
312
306
  }
313
307
 
314
- static void ssl_maybe_shed_handshake_config(SSL *ssl) {
308
+ static void ssl_maybe_shed_handshake_config(SSLImpl *ssl) {
315
309
  if (ssl->s3->hs != nullptr || //
316
310
  ssl->config == nullptr || //
317
311
  !ssl->config->shed_handshake_config || //
@@ -323,68 +317,61 @@ static void ssl_maybe_shed_handshake_config(SSL *ssl) {
323
317
  }
324
318
 
325
319
  void SSL_set_handoff_mode(SSL *ssl, bool on) {
326
- if (!ssl->config) {
320
+ auto *ssl_impl = FromOpaque(ssl);
321
+ if (!ssl_impl->config) {
327
322
  return;
328
323
  }
329
- ssl->config->handoff = on;
324
+ ssl_impl->config->handoff = on;
330
325
  }
331
326
 
332
327
  bool SSL_get_traffic_secrets(const SSL *ssl,
333
328
  Span<const uint8_t> *out_read_traffic_secret,
334
329
  Span<const uint8_t> *out_write_traffic_secret) {
330
+ const auto *ssl_impl = FromOpaque(ssl);
335
331
  // This API is not well-defined for DTLS, where multiple epochs may be alive
336
- // at once. Callers should use |SSL_get_dtls_*_traffic_secret| instead. In
332
+ // at once. Callers should use `SSL_get_dtls_*_traffic_secret` instead. In
337
333
  // QUIC, the application is already handed the traffic secret.
338
- if (SSL_is_dtls(ssl) || SSL_is_quic(ssl)) {
334
+ if (SSL_is_dtls(ssl_impl) || SSL_is_quic(ssl_impl)) {
339
335
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
340
336
  return false;
341
337
  }
342
338
 
343
- if (!ssl->s3->initial_handshake_complete) {
339
+ if (!ssl_impl->s3->initial_handshake_complete) {
344
340
  OPENSSL_PUT_ERROR(SSL, SSL_R_HANDSHAKE_NOT_COMPLETE);
345
341
  return false;
346
342
  }
347
343
 
348
- if (SSL_version(ssl) < TLS1_3_VERSION) {
344
+ if (SSL_version(ssl_impl) < TLS1_3_VERSION) {
349
345
  OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_SSL_VERSION);
350
346
  return false;
351
347
  }
352
348
 
353
- *out_read_traffic_secret = ssl->s3->read_traffic_secret;
354
- *out_write_traffic_secret = ssl->s3->write_traffic_secret;
349
+ *out_read_traffic_secret = ssl_impl->s3->read_traffic_secret;
350
+ *out_write_traffic_secret = ssl_impl->s3->write_traffic_secret;
355
351
  return true;
356
352
  }
357
353
 
358
- void SSL_CTX_set_aes_hw_override_for_testing(SSL_CTX *ctx,
359
- bool override_value) {
360
- ctx->aes_hw_override = true;
361
- ctx->aes_hw_override_value = override_value;
362
- }
363
-
364
- void SSL_set_aes_hw_override_for_testing(SSL *ssl, bool override_value) {
365
- ssl->config->aes_hw_override = true;
366
- ssl->config->aes_hw_override_value = override_value;
367
- }
368
-
369
354
  BSSL_NAMESPACE_END
370
355
 
371
356
  using namespace bssl;
372
357
 
373
- int SSL_library_init(void) { return 1; }
358
+ int SSL_library_init() { return 1; }
374
359
 
375
360
  int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) {
376
361
  return 1;
377
362
  }
378
363
 
364
+ // TODO(crbug.com/565766495): Take `SSLSession` when the lhash does.
379
365
  static uint32_t ssl_session_hash(const SSL_SESSION *sess) {
380
- return ssl_hash_session_id(sess->session_id);
366
+ return ssl_hash_session_id(FromOpaque(sess)->session_id);
381
367
  }
382
368
 
369
+ // TODO(crbug.com/565766495): Take `SSLSession` when the lhash does.
383
370
  static int ssl_session_cmp(const SSL_SESSION *a, const SSL_SESSION *b) {
384
- return Span(a->session_id) == b->session_id ? 0 : 1;
371
+ return Span(FromOpaque(a)->session_id) == FromOpaque(b)->session_id ? 0 : 1;
385
372
  }
386
373
 
387
- ssl_ctx_st::ssl_ctx_st(const SSL_METHOD *ssl_method)
374
+ bssl::SSLContext::SSLContext(const SSL_METHOD *ssl_method)
388
375
  : RefCounted(CheckSubClass()),
389
376
  method(ssl_method->method),
390
377
  x509_method(ssl_method->x509_method),
@@ -394,38 +381,35 @@ ssl_ctx_st::ssl_ctx_st(const SSL_METHOD *ssl_method)
394
381
  signed_cert_timestamps_enabled(false),
395
382
  channel_id_enabled(false),
396
383
  grease_enabled(false),
384
+ grease_sigalgs_enabled(false),
397
385
  permute_extensions(false),
398
386
  allow_unknown_alpn_protos(false),
399
387
  false_start_allowed_without_alpn(false),
400
388
  handoff(false),
401
389
  enable_early_data(false),
402
- aes_hw_override(false),
403
- aes_hw_override_value(false),
404
390
  resumption_across_names_enabled(false) {
405
- CRYPTO_MUTEX_init(&lock);
406
391
  CRYPTO_new_ex_data(&ex_data);
407
392
  }
408
393
 
409
- ssl_ctx_st::~ssl_ctx_st() {
394
+ bssl::SSLContext::~SSLContext() {
410
395
  // Free the internal session cache. Note that this calls the caller-supplied
411
396
  // remove callback, so we must do it before clearing ex_data. (See ticket
412
397
  // [openssl.org #212].)
413
398
  SSL_CTX_flush_sessions(this, 0);
414
399
 
415
- CRYPTO_free_ex_data(&g_ex_data_class_ssl_ctx, this, &ex_data);
400
+ CRYPTO_free_ex_data(&g_ex_data_class_ssl_ctx, &ex_data);
416
401
 
417
- CRYPTO_MUTEX_cleanup(&lock);
418
402
  lh_SSL_SESSION_free(sessions);
419
403
  x509_method->ssl_ctx_free(this);
420
404
  }
421
405
 
422
406
  SSL_CTX *SSL_CTX_new(const SSL_METHOD *method) {
423
- if (method == NULL) {
407
+ if (method == nullptr) {
424
408
  OPENSSL_PUT_ERROR(SSL, SSL_R_NULL_SSL_METHOD_PASSED);
425
409
  return nullptr;
426
410
  }
427
411
 
428
- UniquePtr<SSL_CTX> ret = MakeUnique<SSL_CTX>(method);
412
+ UniquePtr<SSLContext> ret = MakeUnique<SSLContext>(method);
429
413
  if (!ret) {
430
414
  return nullptr;
431
415
  }
@@ -444,6 +428,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *method) {
444
428
  }
445
429
 
446
430
  if (!SSL_CTX_set_strict_cipher_list(ret.get(), SSL_DEFAULT_CIPHER_LIST) ||
431
+ !ssl_create_default_tls13_cipher_list(&ret->tls13_cipher_list) ||
447
432
  // Lock the SSL_CTX to the specified version, for compatibility with
448
433
  // legacy uses of SSL_METHOD.
449
434
  !SSL_CTX_set_max_proto_version(ret.get(), method->version) ||
@@ -452,21 +437,29 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *method) {
452
437
  return nullptr;
453
438
  }
454
439
 
440
+ if (!ret->supported_group_list.CopyFrom(DefaultSupportedGroupIds())) {
441
+ return nullptr;
442
+ }
443
+ if (!ret->supported_group_list_flags.Init(ret->supported_group_list.size())) {
444
+ return nullptr;
445
+ }
446
+ ret->accepted_peer_cert_types.PushBack(kDefaultCertType);
447
+
455
448
  return ret.release();
456
449
  }
457
450
 
458
451
  int SSL_CTX_up_ref(SSL_CTX *ctx) {
459
- ctx->UpRefInternal();
452
+ FromOpaque(ctx)->UpRefInternal();
460
453
  return 1;
461
454
  }
462
455
 
463
456
  void SSL_CTX_free(SSL_CTX *ctx) {
464
457
  if (ctx != nullptr) {
465
- ctx->DecRefInternal();
458
+ FromOpaque(ctx)->DecRefInternal();
466
459
  }
467
460
  }
468
461
 
469
- ssl_st::ssl_st(SSL_CTX *ctx_arg)
462
+ bssl::SSLImpl::SSLImpl(SSLContext *ctx_arg)
470
463
  : method(ctx_arg->method),
471
464
  max_send_fragment(ctx_arg->max_send_fragment),
472
465
  msg_callback(ctx_arg->msg_callback),
@@ -483,22 +476,23 @@ ssl_st::ssl_st(SSL_CTX *ctx_arg)
483
476
  CRYPTO_new_ex_data(&ex_data);
484
477
  }
485
478
 
486
- ssl_st::~ssl_st() {
487
- CRYPTO_free_ex_data(&g_ex_data_class_ssl, this, &ex_data);
488
- // |config| refers to |this|, so we must release it earlier.
479
+ bssl::SSLImpl::~SSLImpl() {
480
+ CRYPTO_free_ex_data(&g_ex_data_class_ssl, &ex_data);
481
+ // `config` refers to `this`, so we must release it earlier.
489
482
  config.reset();
490
- if (method != NULL) {
483
+ if (method != nullptr) {
491
484
  method->ssl_free(this);
492
485
  }
493
486
  }
494
487
 
495
488
  SSL *SSL_new(SSL_CTX *ctx) {
496
- if (ctx == nullptr) {
489
+ auto *ctx_impl = FromOpaque(ctx);
490
+ if (ctx_impl == nullptr) {
497
491
  OPENSSL_PUT_ERROR(SSL, SSL_R_NULL_SSL_CTX);
498
492
  return nullptr;
499
493
  }
500
494
 
501
- UniquePtr<SSL> ssl = MakeUnique<SSL>(ctx);
495
+ UniquePtr<SSLImpl> ssl = MakeUnique<SSLImpl>(ctx_impl);
502
496
  if (ssl == nullptr) {
503
497
  return nullptr;
504
498
  }
@@ -507,57 +501,66 @@ SSL *SSL_new(SSL_CTX *ctx) {
507
501
  if (ssl->config == nullptr) {
508
502
  return nullptr;
509
503
  }
510
- ssl->config->conf_min_version = ctx->conf_min_version;
511
- ssl->config->conf_max_version = ctx->conf_max_version;
504
+ ssl->config->conf_min_version = ctx_impl->conf_min_version;
505
+ ssl->config->conf_max_version = ctx_impl->conf_max_version;
512
506
 
513
- ssl->config->cert = ssl_cert_dup(ctx->cert.get());
507
+ ssl->config->cert = ssl_cert_dup(ctx_impl->cert.get());
514
508
  if (ssl->config->cert == nullptr) {
515
509
  return nullptr;
516
510
  }
517
511
 
518
- ssl->config->verify_mode = ctx->verify_mode;
519
- ssl->config->verify_callback = ctx->default_verify_callback;
520
- ssl->config->custom_verify_callback = ctx->custom_verify_callback;
512
+ ssl->config->verify_mode = ctx_impl->verify_mode;
513
+ ssl->config->verify_callback = ctx_impl->default_verify_callback;
514
+ ssl->config->custom_verify_callback = ctx_impl->custom_verify_callback;
521
515
  ssl->config->retain_only_sha256_of_client_certs =
522
- ctx->retain_only_sha256_of_client_certs;
523
- ssl->config->permute_extensions = ctx->permute_extensions;
524
- ssl->config->aes_hw_override = ctx->aes_hw_override;
525
- ssl->config->aes_hw_override_value = ctx->aes_hw_override_value;
526
- ssl->config->compliance_policy = ctx->compliance_policy;
516
+ ctx_impl->retain_only_sha256_of_client_certs;
517
+ ssl->config->permute_extensions = ctx_impl->permute_extensions;
518
+ ssl->config->compliance_policy = ctx_impl->compliance_policy;
519
+
520
+ if (!ssl->config->tls13_cipher_list.CopyFrom(ctx_impl->tls13_cipher_list)) {
521
+ return nullptr;
522
+ }
527
523
 
528
- if (!ssl->config->supported_group_list.CopyFrom(ctx->supported_group_list) ||
524
+ if (!ssl->config->supported_group_list.CopyFrom(
525
+ ctx_impl->supported_group_list) ||
526
+ !ssl->config->supported_group_list_flags.CopyFrom(
527
+ ctx_impl->supported_group_list_flags) ||
529
528
  !ssl->config->alpn_client_proto_list.CopyFrom(
530
- ctx->alpn_client_proto_list) ||
531
- !ssl->config->verify_sigalgs.CopyFrom(ctx->verify_sigalgs)) {
529
+ ctx_impl->alpn_client_proto_list) ||
530
+ !ssl->config->verify_sigalgs.CopyFrom(ctx_impl->verify_sigalgs) ||
531
+ !ssl->config->accepted_peer_cert_types.TryCopyFrom(
532
+ ctx_impl->accepted_peer_cert_types) ||
533
+ !ssl->config->available_client_cert_types.TryCopyFrom(
534
+ ctx_impl->available_client_cert_types)) {
532
535
  return nullptr;
533
536
  }
534
537
 
535
- if (ctx->requested_trust_anchors) {
538
+ if (ctx_impl->requested_trust_anchors) {
536
539
  ssl->config->requested_trust_anchors.emplace();
537
540
  if (!ssl->config->requested_trust_anchors->CopyFrom(
538
- *ctx->requested_trust_anchors)) {
541
+ *ctx_impl->requested_trust_anchors)) {
539
542
  return nullptr;
540
543
  }
541
544
  }
542
545
 
543
- if (ctx->psk_identity_hint) {
546
+ if (ctx_impl->psk_identity_hint) {
544
547
  ssl->config->psk_identity_hint.reset(
545
- OPENSSL_strdup(ctx->psk_identity_hint.get()));
548
+ OPENSSL_strdup(ctx_impl->psk_identity_hint.get()));
546
549
  if (ssl->config->psk_identity_hint == nullptr) {
547
550
  return nullptr;
548
551
  }
549
552
  }
550
- ssl->config->psk_client_callback = ctx->psk_client_callback;
551
- ssl->config->psk_server_callback = ctx->psk_server_callback;
553
+ ssl->config->psk_client_callback = ctx_impl->psk_client_callback;
554
+ ssl->config->psk_server_callback = ctx_impl->psk_server_callback;
552
555
 
553
- ssl->config->channel_id_enabled = ctx->channel_id_enabled;
554
- ssl->config->channel_id_private = UpRef(ctx->channel_id_private);
556
+ ssl->config->channel_id_enabled = ctx_impl->channel_id_enabled;
557
+ ssl->config->channel_id_private = UpRef(ctx_impl->channel_id_private);
555
558
 
556
559
  ssl->config->signed_cert_timestamps_enabled =
557
- ctx->signed_cert_timestamps_enabled;
558
- ssl->config->ocsp_stapling_enabled = ctx->ocsp_stapling_enabled;
559
- ssl->config->handoff = ctx->handoff;
560
- ssl->quic_method = ctx->quic_method;
560
+ ctx_impl->signed_cert_timestamps_enabled;
561
+ ssl->config->ocsp_stapling_enabled = ctx_impl->ocsp_stapling_enabled;
562
+ ssl->config->handoff = ctx_impl->handoff;
563
+ ssl->quic_method = ctx_impl->quic_method;
561
564
 
562
565
  if (!ssl->method->ssl_new(ssl.get()) ||
563
566
  !ssl->ctx->x509_method->ssl_new(ssl->s3->hs.get())) {
@@ -567,20 +570,21 @@ SSL *SSL_new(SSL_CTX *ctx) {
567
570
  return ssl.release();
568
571
  }
569
572
 
570
- SSL_CONFIG::SSL_CONFIG(SSL *ssl_arg)
573
+ SSL_CONFIG::SSL_CONFIG(SSLImpl *ssl_arg)
571
574
  : ssl(ssl_arg),
572
575
  ech_grease_enabled(false),
576
+ reject_unusable_ech_config(false),
573
577
  signed_cert_timestamps_enabled(false),
574
578
  ocsp_stapling_enabled(false),
575
579
  channel_id_enabled(false),
576
- enforce_rsa_key_usage(true),
577
580
  retain_only_sha256_of_client_certs(false),
578
581
  handoff(false),
579
582
  shed_handshake_config(false),
580
583
  jdk11_workaround(false),
581
584
  quic_use_legacy_codepoint(false),
582
585
  permute_extensions(false),
583
- alps_use_new_codepoint(true) {
586
+ alps_use_new_codepoint(true),
587
+ server_padding_enabled(false) {
584
588
  assert(ssl);
585
589
  }
586
590
 
@@ -590,21 +594,23 @@ SSL_CONFIG::~SSL_CONFIG() {
590
594
  }
591
595
  }
592
596
 
593
- void SSL_free(SSL *ssl) { Delete(ssl); }
597
+ void SSL_free(SSL *ssl) { Delete(FromOpaque(ssl)); }
594
598
 
595
599
  void SSL_set_connect_state(SSL *ssl) {
596
- ssl->server = false;
597
- ssl->do_handshake = ssl_client_handshake;
600
+ auto *ssl_impl = FromOpaque(ssl);
601
+ ssl_impl->server = false;
602
+ ssl_impl->do_handshake = ssl_client_handshake;
598
603
  }
599
604
 
600
605
  void SSL_set_accept_state(SSL *ssl) {
601
- ssl->server = true;
602
- ssl->do_handshake = ssl_server_handshake;
606
+ auto *ssl_impl = FromOpaque(ssl);
607
+ ssl_impl->server = true;
608
+ ssl_impl->do_handshake = ssl_server_handshake;
603
609
  }
604
610
 
605
- void SSL_set0_rbio(SSL *ssl, BIO *rbio) { ssl->rbio.reset(rbio); }
611
+ void SSL_set0_rbio(SSL *ssl, BIO *rbio) { FromOpaque(ssl)->rbio.reset(rbio); }
606
612
 
607
- void SSL_set0_wbio(SSL *ssl, BIO *wbio) { ssl->wbio.reset(wbio); }
613
+ void SSL_set0_wbio(SSL *ssl, BIO *wbio) { FromOpaque(ssl)->wbio.reset(wbio); }
608
614
 
609
615
  void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio) {
610
616
  // For historical reasons, this function has many different cases in ownership
@@ -617,7 +623,7 @@ void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio) {
617
623
 
618
624
  // If the two arguments are equal, one fewer reference is granted than
619
625
  // taken.
620
- if (rbio != NULL && rbio == wbio) {
626
+ if (rbio != nullptr && rbio == wbio) {
621
627
  BIO_up_ref(rbio);
622
628
  }
623
629
 
@@ -640,12 +646,13 @@ void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio) {
640
646
  SSL_set0_wbio(ssl, wbio);
641
647
  }
642
648
 
643
- BIO *SSL_get_rbio(const SSL *ssl) { return ssl->rbio.get(); }
649
+ BIO *SSL_get_rbio(const SSL *ssl) { return FromOpaque(ssl)->rbio.get(); }
644
650
 
645
- BIO *SSL_get_wbio(const SSL *ssl) { return ssl->wbio.get(); }
651
+ BIO *SSL_get_wbio(const SSL *ssl) { return FromOpaque(ssl)->wbio.get(); }
646
652
 
647
653
  size_t SSL_quic_max_handshake_flight_len(const SSL *ssl,
648
654
  enum ssl_encryption_level_t level) {
655
+ const auto *ssl_impl = FromOpaque(ssl);
649
656
  // Limits flights to 16K by default when there are no large
650
657
  // (certificate-carrying) messages.
651
658
  static const size_t kDefaultLimit = 16384;
@@ -657,18 +664,18 @@ size_t SSL_quic_max_handshake_flight_len(const SSL *ssl,
657
664
  // QUIC does not send EndOfEarlyData.
658
665
  return 0;
659
666
  case ssl_encryption_handshake:
660
- if (ssl->server) {
667
+ if (ssl_impl->server) {
661
668
  // Servers may receive Certificate message if configured to request
662
669
  // client certificates.
663
- if (!!(ssl->config->verify_mode & SSL_VERIFY_PEER) &&
664
- ssl->max_cert_list > kDefaultLimit) {
665
- return ssl->max_cert_list;
670
+ if (!!(ssl_impl->config->verify_mode & SSL_VERIFY_PEER) &&
671
+ ssl_impl->max_cert_list > kDefaultLimit) {
672
+ return ssl_impl->max_cert_list;
666
673
  }
667
674
  } else {
668
675
  // Clients may receive both Certificate message and a CertificateRequest
669
676
  // message.
670
- if (2 * ssl->max_cert_list > kDefaultLimit) {
671
- return 2 * ssl->max_cert_list;
677
+ if (2 * ssl_impl->max_cert_list > kDefaultLimit) {
678
+ return 2 * ssl_impl->max_cert_list;
672
679
  }
673
680
  }
674
681
  return kDefaultLimit;
@@ -684,70 +691,74 @@ size_t SSL_quic_max_handshake_flight_len(const SSL *ssl,
684
691
 
685
692
  enum ssl_encryption_level_t SSL_quic_read_level(const SSL *ssl) {
686
693
  assert(SSL_is_quic(ssl));
687
- return ssl->s3->quic_read_level;
694
+ return FromOpaque(ssl)->s3->quic_read_level;
688
695
  }
689
696
 
690
697
  enum ssl_encryption_level_t SSL_quic_write_level(const SSL *ssl) {
691
698
  assert(SSL_is_quic(ssl));
692
- return ssl->s3->quic_write_level;
699
+ return FromOpaque(ssl)->s3->quic_write_level;
693
700
  }
694
701
 
695
702
  int SSL_provide_quic_data(SSL *ssl, enum ssl_encryption_level_t level,
696
703
  const uint8_t *data, size_t len) {
697
- if (!SSL_is_quic(ssl)) {
704
+ auto *ssl_impl = FromOpaque(ssl);
705
+ if (!SSL_is_quic(ssl_impl)) {
698
706
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
699
707
  return 0;
700
708
  }
701
709
 
702
- if (level != ssl->s3->quic_read_level) {
710
+ if (level != ssl_impl->s3->quic_read_level) {
703
711
  OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
704
712
  return 0;
705
713
  }
706
714
 
707
- size_t new_len = (ssl->s3->hs_buf ? ssl->s3->hs_buf->length : 0) + len;
715
+ size_t new_len =
716
+ (ssl_impl->s3->hs_buf ? ssl_impl->s3->hs_buf->length : 0) + len;
708
717
  if (new_len < len ||
709
- new_len > SSL_quic_max_handshake_flight_len(ssl, level)) {
718
+ new_len > SSL_quic_max_handshake_flight_len(ssl_impl, level)) {
710
719
  OPENSSL_PUT_ERROR(SSL, SSL_R_EXCESSIVE_MESSAGE_SIZE);
711
720
  return 0;
712
721
  }
713
722
 
714
- return tls_append_handshake_data(ssl, Span(data, len));
723
+ return tls_append_handshake_data(ssl_impl, Span(data, len));
715
724
  }
716
725
 
717
726
  int SSL_do_handshake(SSL *ssl) {
718
- ssl_reset_error_state(ssl);
727
+ auto *ssl_impl = FromOpaque(ssl);
728
+ ssl_reset_error_state(ssl_impl);
719
729
 
720
- if (ssl->do_handshake == NULL) {
730
+ if (ssl_impl->do_handshake == nullptr) {
721
731
  OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_TYPE_NOT_SET);
722
732
  return -1;
723
733
  }
724
734
 
725
- if (!SSL_in_init(ssl)) {
735
+ if (!SSL_in_init(ssl_impl)) {
726
736
  return 1;
727
737
  }
728
738
 
729
739
  // Run the handshake.
730
- SSL_HANDSHAKE *hs = ssl->s3->hs.get();
740
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
731
741
 
732
742
  bool early_return = false;
733
743
  int ret = ssl_run_handshake(hs, &early_return);
734
744
  ssl_do_info_callback(
735
- ssl, ssl->server ? SSL_CB_ACCEPT_EXIT : SSL_CB_CONNECT_EXIT, ret);
745
+ ssl_impl, ssl_impl->server ? SSL_CB_ACCEPT_EXIT : SSL_CB_CONNECT_EXIT,
746
+ ret);
736
747
  if (ret <= 0) {
737
748
  return ret;
738
749
  }
739
750
 
740
751
  // Destroy the handshake object if the handshake has completely finished.
741
752
  if (!early_return) {
742
- ssl->s3->hs.reset();
743
- ssl_maybe_shed_handshake_config(ssl);
753
+ ssl_impl->s3->hs.reset();
754
+ ssl_maybe_shed_handshake_config(ssl_impl);
744
755
  }
745
756
 
746
757
  return 1;
747
758
  }
748
759
 
749
760
  int SSL_connect(SSL *ssl) {
750
- if (ssl->do_handshake == NULL) {
761
+ if (FromOpaque(ssl)->do_handshake == nullptr) {
751
762
  // Not properly initialized yet
752
763
  SSL_set_connect_state(ssl);
753
764
  }
@@ -756,7 +767,7 @@ int SSL_connect(SSL *ssl) {
756
767
  }
757
768
 
758
769
  int SSL_accept(SSL *ssl) {
759
- if (ssl->do_handshake == NULL) {
770
+ if (FromOpaque(ssl)->do_handshake == nullptr) {
760
771
  // Not properly initialized yet
761
772
  SSL_set_accept_state(ssl);
762
773
  }
@@ -764,7 +775,7 @@ int SSL_accept(SSL *ssl) {
764
775
  return SSL_do_handshake(ssl);
765
776
  }
766
777
 
767
- static int ssl_do_post_handshake(SSL *ssl, const SSLMessage &msg) {
778
+ static int ssl_do_post_handshake(SSLImpl *ssl, const SSLMessage &msg) {
768
779
  if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
769
780
  return tls13_post_handshake(ssl, msg);
770
781
  }
@@ -801,36 +812,37 @@ static int ssl_do_post_handshake(SSL *ssl, const SSLMessage &msg) {
801
812
  }
802
813
 
803
814
  int SSL_process_quic_post_handshake(SSL *ssl) {
804
- ssl_reset_error_state(ssl);
815
+ auto *ssl_impl = FromOpaque(ssl);
816
+ ssl_reset_error_state(ssl_impl);
805
817
 
806
- if (!SSL_is_quic(ssl) || SSL_in_init(ssl)) {
818
+ if (!SSL_is_quic(ssl_impl) || SSL_in_init(ssl_impl)) {
807
819
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
808
820
  return 0;
809
821
  }
810
822
 
811
823
  // Replay post-handshake message errors.
812
- if (!check_read_error(ssl)) {
824
+ if (!check_read_error(ssl_impl)) {
813
825
  return 0;
814
826
  }
815
827
 
816
828
  // Process any buffered post-handshake messages.
817
829
  SSLMessage msg;
818
- while (ssl->method->get_message(ssl, &msg)) {
830
+ while (ssl_impl->method->get_message(ssl_impl, &msg)) {
819
831
  // Handle the post-handshake message and try again.
820
- if (!ssl_do_post_handshake(ssl, msg)) {
821
- ssl_set_read_error(ssl);
832
+ if (!ssl_do_post_handshake(ssl_impl, msg)) {
833
+ ssl_set_read_error(ssl_impl);
822
834
  return 0;
823
835
  }
824
- ssl->method->next_message(ssl);
836
+ ssl_impl->method->next_message(ssl_impl);
825
837
  }
826
838
 
827
839
  return 1;
828
840
  }
829
841
 
830
- static int ssl_read_impl(SSL *ssl) {
842
+ static int ssl_read_impl(SSLImpl *ssl) {
831
843
  ssl_reset_error_state(ssl);
832
844
 
833
- if (ssl->do_handshake == NULL) {
845
+ if (ssl->do_handshake == nullptr) {
834
846
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
835
847
  return -1;
836
848
  }
@@ -856,7 +868,7 @@ static int ssl_read_impl(SSL *ssl) {
856
868
  }
857
869
 
858
870
  // Complete the current handshake, if any. False Start will cause
859
- // |SSL_do_handshake| to return mid-handshake, so this may require multiple
871
+ // `SSL_do_handshake` to return mid-handshake, so this may require multiple
860
872
  // iterations.
861
873
  while (!ssl_can_read(ssl)) {
862
874
  int ret = SSL_do_handshake(ssl);
@@ -907,27 +919,29 @@ static int ssl_read_impl(SSL *ssl) {
907
919
  }
908
920
 
909
921
  int SSL_read(SSL *ssl, void *buf, int num) {
910
- int ret = SSL_peek(ssl, buf, num);
922
+ auto *ssl_impl = FromOpaque(ssl);
923
+ int ret = SSL_peek(ssl_impl, buf, num);
911
924
  if (ret <= 0) {
912
925
  return ret;
913
926
  }
914
927
  // TODO(davidben): In DTLS, should the rest of the record be discarded? DTLS
915
928
  // is not a stream. See https://crbug.com/boringssl/65.
916
- ssl->s3->pending_app_data =
917
- ssl->s3->pending_app_data.subspan(static_cast<size_t>(ret));
918
- if (ssl->s3->pending_app_data.empty()) {
919
- ssl->s3->read_buffer.DiscardConsumed();
929
+ ssl_impl->s3->pending_app_data =
930
+ ssl_impl->s3->pending_app_data.subspan(static_cast<size_t>(ret));
931
+ if (ssl_impl->s3->pending_app_data.empty()) {
932
+ ssl_impl->s3->read_buffer.DiscardConsumed();
920
933
  }
921
934
  return ret;
922
935
  }
923
936
 
924
937
  int SSL_peek(SSL *ssl, void *buf, int num) {
925
- if (SSL_is_quic(ssl)) {
938
+ auto *ssl_impl = FromOpaque(ssl);
939
+ if (SSL_is_quic(ssl_impl)) {
926
940
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
927
941
  return -1;
928
942
  }
929
943
 
930
- int ret = ssl_read_impl(ssl);
944
+ int ret = ssl_read_impl(ssl_impl);
931
945
  if (ret <= 0) {
932
946
  return ret;
933
947
  }
@@ -935,20 +949,21 @@ int SSL_peek(SSL *ssl, void *buf, int num) {
935
949
  return num;
936
950
  }
937
951
  size_t todo =
938
- std::min(ssl->s3->pending_app_data.size(), static_cast<size_t>(num));
939
- OPENSSL_memcpy(buf, ssl->s3->pending_app_data.data(), todo);
952
+ std::min(ssl_impl->s3->pending_app_data.size(), static_cast<size_t>(num));
953
+ OPENSSL_memcpy(buf, ssl_impl->s3->pending_app_data.data(), todo);
940
954
  return static_cast<int>(todo);
941
955
  }
942
956
 
943
957
  int SSL_write(SSL *ssl, const void *buf, int num) {
944
- ssl_reset_error_state(ssl);
958
+ auto *ssl_impl = FromOpaque(ssl);
959
+ ssl_reset_error_state(ssl_impl);
945
960
 
946
- if (SSL_is_quic(ssl)) {
961
+ if (SSL_is_quic(ssl_impl)) {
947
962
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
948
963
  return -1;
949
964
  }
950
965
 
951
- if (ssl->do_handshake == NULL) {
966
+ if (ssl_impl->do_handshake == nullptr) {
952
967
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
953
968
  return -1;
954
969
  }
@@ -958,8 +973,8 @@ int SSL_write(SSL *ssl, const void *buf, int num) {
958
973
  bool needs_handshake = false;
959
974
  do {
960
975
  // If necessary, complete the handshake implicitly.
961
- if (!ssl_can_write(ssl)) {
962
- ret = SSL_do_handshake(ssl);
976
+ if (!ssl_can_write(ssl_impl)) {
977
+ ret = SSL_do_handshake(ssl_impl);
963
978
  if (ret < 0) {
964
979
  return ret;
965
980
  }
@@ -973,58 +988,60 @@ int SSL_write(SSL *ssl, const void *buf, int num) {
973
988
  OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_LENGTH);
974
989
  return -1;
975
990
  }
976
- ret = ssl->method->write_app_data(
977
- ssl, &needs_handshake, &bytes_written,
991
+ ret = ssl_impl->method->write_app_data(
992
+ ssl_impl, &needs_handshake, &bytes_written,
978
993
  Span(static_cast<const uint8_t *>(buf), static_cast<size_t>(num)));
979
994
  } while (needs_handshake);
980
995
  return ret <= 0 ? ret : static_cast<int>(bytes_written);
981
996
  }
982
997
 
983
998
  int SSL_key_update(SSL *ssl, int request_type) {
984
- ssl_reset_error_state(ssl);
999
+ auto *ssl_impl = FromOpaque(ssl);
1000
+ ssl_reset_error_state(ssl_impl);
985
1001
 
986
- if (ssl->do_handshake == NULL) {
1002
+ if (ssl_impl->do_handshake == nullptr) {
987
1003
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
988
1004
  return 0;
989
1005
  }
990
1006
 
991
- if (SSL_is_quic(ssl)) {
1007
+ if (SSL_is_quic(ssl_impl)) {
992
1008
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
993
1009
  return 0;
994
1010
  }
995
1011
 
996
- if (!ssl->s3->initial_handshake_complete) {
1012
+ if (!ssl_impl->s3->initial_handshake_complete) {
997
1013
  OPENSSL_PUT_ERROR(SSL, SSL_R_HANDSHAKE_NOT_COMPLETE);
998
1014
  return 0;
999
1015
  }
1000
1016
 
1001
- if (ssl_protocol_version(ssl) < TLS1_3_VERSION) {
1017
+ if (ssl_protocol_version(ssl_impl) < TLS1_3_VERSION) {
1002
1018
  OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_SSL_VERSION);
1003
1019
  return 0;
1004
1020
  }
1005
1021
 
1006
- return tls13_add_key_update(ssl, request_type);
1022
+ return tls13_add_key_update(ssl_impl, request_type);
1007
1023
  }
1008
1024
 
1009
1025
  int SSL_shutdown(SSL *ssl) {
1010
- ssl_reset_error_state(ssl);
1026
+ auto *ssl_impl = FromOpaque(ssl);
1027
+ ssl_reset_error_state(ssl_impl);
1011
1028
 
1012
- if (ssl->do_handshake == NULL) {
1029
+ if (ssl_impl->do_handshake == nullptr) {
1013
1030
  OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
1014
1031
  return -1;
1015
1032
  }
1016
1033
 
1017
1034
  // If we are in the middle of a handshake, silently succeed. Consumers often
1018
- // call this function before |SSL_free|, whether the handshake succeeded or
1035
+ // call this function before `SSL_free`, whether the handshake succeeded or
1019
1036
  // not. We assume the caller has already handled failed handshakes.
1020
- if (SSL_in_init(ssl)) {
1037
+ if (SSL_in_init(ssl_impl)) {
1021
1038
  return 1;
1022
1039
  }
1023
1040
 
1024
- if (ssl->quiet_shutdown) {
1041
+ if (ssl_impl->quiet_shutdown) {
1025
1042
  // Do nothing if configured not to send a close_notify.
1026
- ssl->s3->write_shutdown = ssl_shutdown_close_notify;
1027
- ssl->s3->read_shutdown = ssl_shutdown_close_notify;
1043
+ ssl_impl->s3->write_shutdown = ssl_shutdown_close_notify;
1044
+ ssl_impl->s3->read_shutdown = ssl_shutdown_close_notify;
1028
1045
  return 1;
1029
1046
  }
1030
1047
 
@@ -1032,99 +1049,106 @@ int SSL_shutdown(SSL *ssl) {
1032
1049
  // waits for a close_notify to come in. Perform exactly one action and return
1033
1050
  // whether or not it succeeds.
1034
1051
 
1035
- if (ssl->s3->write_shutdown != ssl_shutdown_close_notify) {
1052
+ if (ssl_impl->s3->write_shutdown != ssl_shutdown_close_notify) {
1036
1053
  // Send a close_notify.
1037
- if (ssl_send_alert_impl(ssl, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY) <= 0) {
1054
+ if (ssl_send_alert_impl(ssl_impl, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY) <=
1055
+ 0) {
1038
1056
  return -1;
1039
1057
  }
1040
- } else if (ssl->s3->alert_dispatch) {
1058
+ } else if (ssl_impl->s3->alert_dispatch) {
1041
1059
  // Finish sending the close_notify.
1042
- if (ssl->method->dispatch_alert(ssl) <= 0) {
1060
+ if (ssl_impl->method->dispatch_alert(ssl_impl) <= 0) {
1043
1061
  return -1;
1044
1062
  }
1045
- } else if (ssl->s3->read_shutdown != ssl_shutdown_close_notify) {
1046
- if (SSL_is_dtls(ssl)) {
1063
+ } else if (ssl_impl->s3->read_shutdown != ssl_shutdown_close_notify) {
1064
+ if (SSL_is_dtls(ssl_impl)) {
1047
1065
  // Bidirectional shutdown doesn't make sense for an unordered
1048
1066
  // transport. DTLS alerts also aren't delivered reliably, so we may even
1049
1067
  // time out because the peer never received our close_notify. Report to
1050
1068
  // the caller that the channel has fully shut down.
1051
- if (ssl->s3->read_shutdown == ssl_shutdown_error) {
1052
- ERR_restore_state(ssl->s3->read_error.get());
1069
+ if (ssl_impl->s3->read_shutdown == ssl_shutdown_error) {
1070
+ ERR_restore_state(ssl_impl->s3->read_error.get());
1053
1071
  return -1;
1054
1072
  }
1055
- ssl->s3->read_shutdown = ssl_shutdown_close_notify;
1073
+ ssl_impl->s3->read_shutdown = ssl_shutdown_close_notify;
1056
1074
  } else {
1057
1075
  // Process records until an error, close_notify, or application data.
1058
- if (ssl_read_impl(ssl) > 0) {
1076
+ if (ssl_read_impl(ssl_impl) > 0) {
1059
1077
  // We received some unexpected application data.
1060
1078
  OPENSSL_PUT_ERROR(SSL, SSL_R_APPLICATION_DATA_ON_SHUTDOWN);
1061
1079
  return -1;
1062
1080
  }
1063
- if (ssl->s3->read_shutdown != ssl_shutdown_close_notify) {
1081
+ if (ssl_impl->s3->read_shutdown != ssl_shutdown_close_notify) {
1064
1082
  return -1;
1065
1083
  }
1066
1084
  }
1067
1085
  }
1068
1086
 
1069
1087
  // Return 0 for unidirectional shutdown and 1 for bidirectional shutdown.
1070
- return ssl->s3->read_shutdown == ssl_shutdown_close_notify;
1088
+ return ssl_impl->s3->read_shutdown == ssl_shutdown_close_notify;
1071
1089
  }
1072
1090
 
1073
1091
  int SSL_send_fatal_alert(SSL *ssl, uint8_t alert) {
1074
- if (ssl->s3->alert_dispatch) {
1075
- if (ssl->s3->send_alert[0] != SSL3_AL_FATAL ||
1076
- ssl->s3->send_alert[1] != alert) {
1092
+ auto *ssl_impl = FromOpaque(ssl);
1093
+ if (ssl_impl->s3->alert_dispatch) {
1094
+ if (ssl_impl->s3->send_alert[0] != SSL3_AL_FATAL ||
1095
+ ssl_impl->s3->send_alert[1] != alert) {
1077
1096
  // We are already attempting to write a different alert.
1078
1097
  OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN);
1079
1098
  return -1;
1080
1099
  }
1081
- return ssl->method->dispatch_alert(ssl);
1100
+ return ssl_impl->method->dispatch_alert(ssl_impl);
1082
1101
  }
1083
1102
 
1084
- return ssl_send_alert_impl(ssl, SSL3_AL_FATAL, alert);
1103
+ return ssl_send_alert_impl(ssl_impl, SSL3_AL_FATAL, alert);
1085
1104
  }
1086
1105
 
1087
1106
  int SSL_set_quic_transport_params(SSL *ssl, const uint8_t *params,
1088
1107
  size_t params_len) {
1089
- return ssl->config &&
1090
- ssl->config->quic_transport_params.CopyFrom(Span(params, params_len));
1108
+ auto *ssl_impl = FromOpaque(ssl);
1109
+ return ssl_impl->config && ssl_impl->config->quic_transport_params.CopyFrom(
1110
+ Span(params, params_len));
1091
1111
  }
1092
1112
 
1093
1113
  void SSL_get_peer_quic_transport_params(const SSL *ssl,
1094
1114
  const uint8_t **out_params,
1095
1115
  size_t *out_params_len) {
1096
- *out_params = ssl->s3->peer_quic_transport_params.data();
1097
- *out_params_len = ssl->s3->peer_quic_transport_params.size();
1116
+ const auto *ssl_impl = FromOpaque(ssl);
1117
+ *out_params = ssl_impl->s3->peer_quic_transport_params.data();
1118
+ *out_params_len = ssl_impl->s3->peer_quic_transport_params.size();
1098
1119
  }
1099
1120
 
1100
1121
  int SSL_set_quic_early_data_context(SSL *ssl, const uint8_t *context,
1101
1122
  size_t context_len) {
1102
- return ssl->config && ssl->config->quic_early_data_context.CopyFrom(
1103
- Span(context, context_len));
1123
+ auto *ssl_impl = FromOpaque(ssl);
1124
+ return ssl_impl->config && ssl_impl->config->quic_early_data_context.CopyFrom(
1125
+ Span(context, context_len));
1104
1126
  }
1105
1127
 
1106
1128
  void SSL_CTX_set_early_data_enabled(SSL_CTX *ctx, int enabled) {
1107
- ctx->enable_early_data = !!enabled;
1129
+ FromOpaque(ctx)->enable_early_data = !!enabled;
1108
1130
  }
1109
1131
 
1110
1132
  void SSL_set_early_data_enabled(SSL *ssl, int enabled) {
1111
- ssl->enable_early_data = !!enabled;
1133
+ FromOpaque(ssl)->enable_early_data = !!enabled;
1112
1134
  }
1113
1135
 
1114
1136
  int SSL_in_early_data(const SSL *ssl) {
1115
- if (ssl->s3->hs == NULL) {
1137
+ const auto *ssl_impl = FromOpaque(ssl);
1138
+ if (ssl_impl->s3->hs == nullptr) {
1116
1139
  return 0;
1117
1140
  }
1118
- return ssl->s3->hs->in_early_data;
1141
+ return ssl_impl->s3->hs->in_early_data;
1119
1142
  }
1120
1143
 
1121
1144
  int SSL_early_data_accepted(const SSL *ssl) {
1122
- return ssl->s3->early_data_accepted;
1145
+ return FromOpaque(ssl)->s3->early_data_accepted;
1123
1146
  }
1124
1147
 
1125
1148
  void SSL_reset_early_data_reject(SSL *ssl) {
1126
- SSL_HANDSHAKE *hs = ssl->s3->hs.get();
1127
- if (hs == NULL || //
1149
+ auto *ssl_impl = FromOpaque(ssl);
1150
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
1151
+ if (hs == nullptr || //
1128
1152
  hs->wait != ssl_hs_early_data_rejected) {
1129
1153
  abort();
1130
1154
  }
@@ -1133,14 +1157,15 @@ void SSL_reset_early_data_reject(SSL *ssl) {
1133
1157
  hs->in_early_data = false;
1134
1158
  hs->early_session.reset();
1135
1159
 
1136
- // Discard any unfinished writes from the perspective of |SSL_write|'s
1160
+ // Discard any unfinished writes from the perspective of `SSL_write`'s
1137
1161
  // retry. The handshake will transparently flush out the pending record
1138
1162
  // (discarded by the server) to keep the framing correct.
1139
- ssl->s3->pending_write = {};
1163
+ ssl_impl->s3->pending_write = {};
1164
+ ssl_impl->s3->unreported_bytes_written = 0;
1140
1165
  }
1141
1166
 
1142
1167
  enum ssl_early_data_reason_t SSL_get_early_data_reason(const SSL *ssl) {
1143
- return ssl->s3->early_data_reason;
1168
+ return FromOpaque(ssl)->s3->early_data_reason;
1144
1169
  }
1145
1170
 
1146
1171
  const char *SSL_early_data_reason_string(enum ssl_early_data_reason_t reason) {
@@ -1190,6 +1215,7 @@ static int bio_retry_reason_to_error(int reason) {
1190
1215
  }
1191
1216
 
1192
1217
  int SSL_get_error(const SSL *ssl, int ret_code) {
1218
+ const auto *ssl_impl = FromOpaque(ssl);
1193
1219
  if (ret_code > 0) {
1194
1220
  return SSL_ERROR_NONE;
1195
1221
  }
@@ -1205,7 +1231,7 @@ int SSL_get_error(const SSL *ssl, int ret_code) {
1205
1231
  }
1206
1232
 
1207
1233
  if (ret_code == 0) {
1208
- if (ssl->s3->rwstate == SSL_ERROR_ZERO_RETURN) {
1234
+ if (ssl_impl->s3->rwstate == SSL_ERROR_ZERO_RETURN) {
1209
1235
  return SSL_ERROR_ZERO_RETURN;
1210
1236
  }
1211
1237
  // An EOF was observed which violates the protocol, and the underlying
@@ -1214,7 +1240,7 @@ int SSL_get_error(const SSL *ssl, int ret_code) {
1214
1240
  return SSL_ERROR_SYSCALL;
1215
1241
  }
1216
1242
 
1217
- switch (ssl->s3->rwstate) {
1243
+ switch (ssl_impl->s3->rwstate) {
1218
1244
  case SSL_ERROR_PENDING_SESSION:
1219
1245
  case SSL_ERROR_PENDING_CERTIFICATE:
1220
1246
  case SSL_ERROR_HANDOFF:
@@ -1226,13 +1252,13 @@ int SSL_get_error(const SSL *ssl, int ret_code) {
1226
1252
  case SSL_ERROR_WANT_CERTIFICATE_VERIFY:
1227
1253
  case SSL_ERROR_WANT_RENEGOTIATE:
1228
1254
  case SSL_ERROR_HANDSHAKE_HINTS_READY:
1229
- return ssl->s3->rwstate;
1255
+ return ssl_impl->s3->rwstate;
1230
1256
 
1231
1257
  case SSL_ERROR_WANT_READ: {
1232
- if (SSL_is_quic(ssl)) {
1258
+ if (SSL_is_quic(ssl_impl)) {
1233
1259
  return SSL_ERROR_WANT_READ;
1234
1260
  }
1235
- BIO *bio = SSL_get_rbio(ssl);
1261
+ BIO *bio = SSL_get_rbio(ssl_impl);
1236
1262
  if (BIO_should_read(bio)) {
1237
1263
  return SSL_ERROR_WANT_READ;
1238
1264
  }
@@ -1251,7 +1277,7 @@ int SSL_get_error(const SSL *ssl, int ret_code) {
1251
1277
  }
1252
1278
 
1253
1279
  case SSL_ERROR_WANT_WRITE: {
1254
- BIO *bio = SSL_get_wbio(ssl);
1280
+ BIO *bio = SSL_get_wbio(ssl_impl);
1255
1281
  if (BIO_should_write(bio)) {
1256
1282
  return SSL_ERROR_WANT_WRITE;
1257
1283
  }
@@ -1319,78 +1345,98 @@ const char *SSL_error_description(int err) {
1319
1345
  }
1320
1346
 
1321
1347
  uint32_t SSL_CTX_set_options(SSL_CTX *ctx, uint32_t options) {
1322
- ctx->options |= options;
1323
- return ctx->options;
1348
+ auto *ctx_impl = FromOpaque(ctx);
1349
+ ctx_impl->options |= options;
1350
+ return ctx_impl->options;
1324
1351
  }
1325
1352
 
1326
1353
  uint32_t SSL_CTX_clear_options(SSL_CTX *ctx, uint32_t options) {
1327
- ctx->options &= ~options;
1328
- return ctx->options;
1354
+ auto *ctx_impl = FromOpaque(ctx);
1355
+ ctx_impl->options &= ~options;
1356
+ return ctx_impl->options;
1329
1357
  }
1330
1358
 
1331
- uint32_t SSL_CTX_get_options(const SSL_CTX *ctx) { return ctx->options; }
1359
+ uint32_t SSL_CTX_get_options(const SSL_CTX *ctx) {
1360
+ return FromOpaque(ctx)->options;
1361
+ }
1332
1362
 
1333
1363
  uint32_t SSL_set_options(SSL *ssl, uint32_t options) {
1334
- ssl->options |= options;
1335
- return ssl->options;
1364
+ auto *ssl_impl = FromOpaque(ssl);
1365
+ ssl_impl->options |= options;
1366
+ return ssl_impl->options;
1336
1367
  }
1337
1368
 
1338
1369
  uint32_t SSL_clear_options(SSL *ssl, uint32_t options) {
1339
- ssl->options &= ~options;
1340
- return ssl->options;
1370
+ auto *ssl_impl = FromOpaque(ssl);
1371
+ ssl_impl->options &= ~options;
1372
+ return ssl_impl->options;
1341
1373
  }
1342
1374
 
1343
- uint32_t SSL_get_options(const SSL *ssl) { return ssl->options; }
1375
+ uint32_t SSL_get_options(const SSL *ssl) { return FromOpaque(ssl)->options; }
1344
1376
 
1345
1377
  uint32_t SSL_CTX_set_mode(SSL_CTX *ctx, uint32_t mode) {
1346
- ctx->mode |= mode;
1347
- return ctx->mode;
1378
+ auto *ctx_impl = FromOpaque(ctx);
1379
+ ctx_impl->mode |= mode;
1380
+ return ctx_impl->mode;
1348
1381
  }
1349
1382
 
1350
1383
  uint32_t SSL_CTX_clear_mode(SSL_CTX *ctx, uint32_t mode) {
1351
- ctx->mode &= ~mode;
1352
- return ctx->mode;
1384
+ auto *ctx_impl = FromOpaque(ctx);
1385
+ ctx_impl->mode &= ~mode;
1386
+ return ctx_impl->mode;
1353
1387
  }
1354
1388
 
1355
- uint32_t SSL_CTX_get_mode(const SSL_CTX *ctx) { return ctx->mode; }
1389
+ uint32_t SSL_CTX_get_mode(const SSL_CTX *ctx) { return FromOpaque(ctx)->mode; }
1356
1390
 
1357
1391
  uint32_t SSL_set_mode(SSL *ssl, uint32_t mode) {
1358
- ssl->mode |= mode;
1359
- return ssl->mode;
1392
+ auto *ssl_impl = FromOpaque(ssl);
1393
+ ssl_impl->mode |= mode;
1394
+ return ssl_impl->mode;
1360
1395
  }
1361
1396
 
1362
1397
  uint32_t SSL_clear_mode(SSL *ssl, uint32_t mode) {
1363
- ssl->mode &= ~mode;
1364
- return ssl->mode;
1398
+ auto *ssl_impl = FromOpaque(ssl);
1399
+ ssl_impl->mode &= ~mode;
1400
+ return ssl_impl->mode;
1365
1401
  }
1366
1402
 
1367
- uint32_t SSL_get_mode(const SSL *ssl) { return ssl->mode; }
1403
+ uint32_t SSL_get_mode(const SSL *ssl) { return FromOpaque(ssl)->mode; }
1404
+
1405
+ void SSL_CTX_set1_buffer_pool(SSL_CTX *ctx, CRYPTO_BUFFER_POOL *pool) {
1406
+ FromOpaque(ctx)->pool = UpRef(pool);
1407
+ }
1368
1408
 
1369
1409
  void SSL_CTX_set0_buffer_pool(SSL_CTX *ctx, CRYPTO_BUFFER_POOL *pool) {
1370
- ctx->pool = pool;
1410
+ // Historically, `CRYPTO_BUFFER_POOL` was not reference-counted and this
1411
+ // function saved a non-owning pointer, expecting the caller to maintain a
1412
+ // lifetime relationship between the two objects. Now that pools are
1413
+ // reference-counted, the compatible behavior is to treat it as set0 rather
1414
+ // than ownership-transfering.
1415
+ return SSL_CTX_set1_buffer_pool(ctx, pool);
1371
1416
  }
1372
1417
 
1373
1418
  int SSL_get_tls_unique(const SSL *ssl, uint8_t *out, size_t *out_len,
1374
1419
  size_t max_out) {
1420
+ const auto *ssl_impl = FromOpaque(ssl);
1375
1421
  *out_len = 0;
1376
1422
  OPENSSL_memset(out, 0, max_out);
1377
1423
 
1378
1424
  // tls-unique is not defined for TLS 1.3.
1379
- if (!ssl->s3->initial_handshake_complete ||
1380
- ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
1425
+ if (!ssl_impl->s3->initial_handshake_complete ||
1426
+ ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
1381
1427
  return 0;
1382
1428
  }
1383
1429
 
1384
1430
  // The tls-unique value is the first Finished message in the handshake, which
1385
1431
  // is the client's in a full handshake and the server's for a resumption. See
1386
1432
  // https://tools.ietf.org/html/rfc5929#section-3.1.
1387
- Span<const uint8_t> finished = ssl->s3->previous_client_finished;
1388
- if (ssl->session != NULL) {
1433
+ Span<const uint8_t> finished = ssl_impl->s3->previous_client_finished;
1434
+ if (ssl_impl->session != nullptr) {
1389
1435
  // tls-unique is broken for resumed sessions unless EMS is used.
1390
- if (!ssl->session->extended_master_secret) {
1436
+ if (!ssl_impl->session->extended_master_secret) {
1391
1437
  return 0;
1392
1438
  }
1393
- finished = ssl->s3->previous_server_finished;
1439
+ finished = ssl_impl->s3->previous_server_finished;
1394
1440
  }
1395
1441
 
1396
1442
  *out_len = finished.size();
@@ -1414,25 +1460,29 @@ static int set_session_id_context(CERT *cert, const uint8_t *sid_ctx,
1414
1460
 
1415
1461
  int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const uint8_t *sid_ctx,
1416
1462
  size_t sid_ctx_len) {
1417
- return set_session_id_context(ctx->cert.get(), sid_ctx, sid_ctx_len);
1463
+ return set_session_id_context(FromOpaque(ctx)->cert.get(), sid_ctx,
1464
+ sid_ctx_len);
1418
1465
  }
1419
1466
 
1420
1467
  int SSL_set_session_id_context(SSL *ssl, const uint8_t *sid_ctx,
1421
1468
  size_t sid_ctx_len) {
1422
- if (!ssl->config) {
1469
+ auto *ssl_impl = FromOpaque(ssl);
1470
+ if (!ssl_impl->config) {
1423
1471
  return 0;
1424
1472
  }
1425
- return set_session_id_context(ssl->config->cert.get(), sid_ctx, sid_ctx_len);
1473
+ return set_session_id_context(ssl_impl->config->cert.get(), sid_ctx,
1474
+ sid_ctx_len);
1426
1475
  }
1427
1476
 
1428
1477
  const uint8_t *SSL_get0_session_id_context(const SSL *ssl, size_t *out_len) {
1429
- if (!ssl->config) {
1430
- assert(ssl->config);
1478
+ const auto *ssl_impl = FromOpaque(ssl);
1479
+ if (!ssl_impl->config) {
1480
+ assert(ssl_impl->config);
1431
1481
  *out_len = 0;
1432
- return NULL;
1482
+ return nullptr;
1433
1483
  }
1434
- *out_len = ssl->config->cert->sid_ctx.size();
1435
- return ssl->config->cert->sid_ctx.data();
1484
+ *out_len = ssl_impl->config->cert->sid_ctx.size();
1485
+ return ssl_impl->config->cert->sid_ctx.data();
1436
1486
  }
1437
1487
 
1438
1488
  int SSL_get_fd(const SSL *ssl) { return SSL_get_rfd(ssl); }
@@ -1440,7 +1490,7 @@ int SSL_get_fd(const SSL *ssl) { return SSL_get_rfd(ssl); }
1440
1490
  int SSL_get_rfd(const SSL *ssl) {
1441
1491
  int ret = -1;
1442
1492
  BIO *b = BIO_find_type(SSL_get_rbio(ssl), BIO_TYPE_DESCRIPTOR);
1443
- if (b != NULL) {
1493
+ if (b != nullptr) {
1444
1494
  BIO_get_fd(b, &ret);
1445
1495
  }
1446
1496
  return ret;
@@ -1449,7 +1499,7 @@ int SSL_get_rfd(const SSL *ssl) {
1449
1499
  int SSL_get_wfd(const SSL *ssl) {
1450
1500
  int ret = -1;
1451
1501
  BIO *b = BIO_find_type(SSL_get_wbio(ssl), BIO_TYPE_DESCRIPTOR);
1452
- if (b != NULL) {
1502
+ if (b != nullptr) {
1453
1503
  BIO_get_fd(b, &ret);
1454
1504
  }
1455
1505
  return ret;
@@ -1458,7 +1508,7 @@ int SSL_get_wfd(const SSL *ssl) {
1458
1508
  #if !defined(OPENSSL_NO_SOCK)
1459
1509
  int SSL_set_fd(SSL *ssl, int fd) {
1460
1510
  BIO *bio = BIO_new(BIO_s_socket());
1461
- if (bio == NULL) {
1511
+ if (bio == nullptr) {
1462
1512
  OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
1463
1513
  return 0;
1464
1514
  }
@@ -1469,10 +1519,10 @@ int SSL_set_fd(SSL *ssl, int fd) {
1469
1519
 
1470
1520
  int SSL_set_wfd(SSL *ssl, int fd) {
1471
1521
  BIO *rbio = SSL_get_rbio(ssl);
1472
- if (rbio == NULL || BIO_method_type(rbio) != BIO_TYPE_SOCKET ||
1473
- BIO_get_fd(rbio, NULL) != fd) {
1522
+ if (rbio == nullptr || BIO_method_type(rbio) != BIO_TYPE_SOCKET ||
1523
+ BIO_get_fd(rbio, nullptr) != fd) {
1474
1524
  BIO *bio = BIO_new(BIO_s_socket());
1475
- if (bio == NULL) {
1525
+ if (bio == nullptr) {
1476
1526
  OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
1477
1527
  return 0;
1478
1528
  }
@@ -1489,10 +1539,10 @@ int SSL_set_wfd(SSL *ssl, int fd) {
1489
1539
 
1490
1540
  int SSL_set_rfd(SSL *ssl, int fd) {
1491
1541
  BIO *wbio = SSL_get_wbio(ssl);
1492
- if (wbio == NULL || BIO_method_type(wbio) != BIO_TYPE_SOCKET ||
1493
- BIO_get_fd(wbio, NULL) != fd) {
1542
+ if (wbio == nullptr || BIO_method_type(wbio) != BIO_TYPE_SOCKET ||
1543
+ BIO_get_fd(wbio, nullptr) != fd) {
1494
1544
  BIO *bio = BIO_new(BIO_s_socket());
1495
- if (bio == NULL) {
1545
+ if (bio == nullptr) {
1496
1546
  OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
1497
1547
  return 0;
1498
1548
  }
@@ -1516,57 +1566,61 @@ static size_t copy_finished(void *out, size_t out_len, Span<const uint8_t> in) {
1516
1566
  }
1517
1567
 
1518
1568
  size_t SSL_get_finished(const SSL *ssl, void *buf, size_t count) {
1519
- if (!ssl->s3->initial_handshake_complete ||
1520
- ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
1569
+ const auto *ssl_impl = FromOpaque(ssl);
1570
+ if (!ssl_impl->s3->initial_handshake_complete ||
1571
+ ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
1521
1572
  return 0;
1522
1573
  }
1523
1574
 
1524
- if (ssl->server) {
1525
- return copy_finished(buf, count, ssl->s3->previous_server_finished);
1575
+ if (ssl_impl->server) {
1576
+ return copy_finished(buf, count, ssl_impl->s3->previous_server_finished);
1526
1577
  }
1527
1578
 
1528
- return copy_finished(buf, count, ssl->s3->previous_client_finished);
1579
+ return copy_finished(buf, count, ssl_impl->s3->previous_client_finished);
1529
1580
  }
1530
1581
 
1531
1582
  size_t SSL_get_peer_finished(const SSL *ssl, void *buf, size_t count) {
1532
- if (!ssl->s3->initial_handshake_complete ||
1533
- ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
1583
+ const auto *ssl_impl = FromOpaque(ssl);
1584
+ if (!ssl_impl->s3->initial_handshake_complete ||
1585
+ ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
1534
1586
  return 0;
1535
1587
  }
1536
1588
 
1537
- if (ssl->server) {
1538
- return copy_finished(buf, count, ssl->s3->previous_client_finished);
1589
+ if (ssl_impl->server) {
1590
+ return copy_finished(buf, count, ssl_impl->s3->previous_client_finished);
1539
1591
  }
1540
1592
 
1541
- return copy_finished(buf, count, ssl->s3->previous_server_finished);
1593
+ return copy_finished(buf, count, ssl_impl->s3->previous_server_finished);
1542
1594
  }
1543
1595
 
1544
1596
  int SSL_get_verify_mode(const SSL *ssl) {
1545
- if (!ssl->config) {
1546
- assert(ssl->config);
1597
+ const auto *ssl_impl = FromOpaque(ssl);
1598
+ if (!ssl_impl->config) {
1599
+ assert(ssl_impl->config);
1547
1600
  return -1;
1548
1601
  }
1549
- return ssl->config->verify_mode;
1602
+ return ssl_impl->config->verify_mode;
1550
1603
  }
1551
1604
 
1552
1605
  int SSL_get_extms_support(const SSL *ssl) {
1606
+ const auto *ssl_impl = FromOpaque(ssl);
1553
1607
  // TLS 1.3 does not require extended master secret and always reports as
1554
1608
  // supporting it.
1555
- if (ssl->s3->version == 0) {
1609
+ if (ssl_impl->s3->version == 0) {
1556
1610
  return 0;
1557
1611
  }
1558
- if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
1612
+ if (ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
1559
1613
  return 1;
1560
1614
  }
1561
1615
 
1562
1616
  // If the initial handshake completed, query the established session.
1563
- if (ssl->s3->established_session != NULL) {
1564
- return ssl->s3->established_session->extended_master_secret;
1617
+ if (ssl_impl->s3->established_session != nullptr) {
1618
+ return ssl_impl->s3->established_session->extended_master_secret;
1565
1619
  }
1566
1620
 
1567
1621
  // Otherwise, query the in-progress handshake.
1568
- if (ssl->s3->hs != NULL) {
1569
- return ssl->s3->hs->extended_master_secret;
1622
+ if (ssl_impl->s3->hs != nullptr) {
1623
+ return ssl_impl->s3->hs->extended_master_secret;
1570
1624
  }
1571
1625
  assert(0);
1572
1626
  return 0;
@@ -1581,15 +1635,15 @@ int SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes) { return 1; }
1581
1635
  int SSL_set_read_ahead(SSL *ssl, int yes) { return 1; }
1582
1636
 
1583
1637
  int SSL_pending(const SSL *ssl) {
1584
- return static_cast<int>(ssl->s3->pending_app_data.size());
1638
+ return static_cast<int>(FromOpaque(ssl)->s3->pending_app_data.size());
1585
1639
  }
1586
1640
 
1587
1641
  int SSL_has_pending(const SSL *ssl) {
1588
- return SSL_pending(ssl) != 0 || !ssl->s3->read_buffer.empty();
1642
+ return SSL_pending(ssl) != 0 || !FromOpaque(ssl)->s3->read_buffer.empty();
1589
1643
  }
1590
1644
 
1591
- static bool has_cert_and_key(const SSL_CREDENTIAL *cred) {
1592
- // TODO(davidben): If |cred->key_method| is set, that should be fine too.
1645
+ static bool has_cert_and_key(const SSLCredential *cred) {
1646
+ // TODO(davidben): If `cred->key_method` is set, that should be fine too.
1593
1647
  if (cred->privkey == nullptr) {
1594
1648
  OPENSSL_PUT_ERROR(SSL, SSL_R_NO_PRIVATE_KEY_ASSIGNED);
1595
1649
  return false;
@@ -1607,17 +1661,18 @@ static bool has_cert_and_key(const SSL_CREDENTIAL *cred) {
1607
1661
  int SSL_CTX_check_private_key(const SSL_CTX *ctx) {
1608
1662
  // There is no need to actually check consistency because inconsistent values
1609
1663
  // can never be configured.
1610
- return has_cert_and_key(ctx->cert->legacy_credential.get());
1664
+ return has_cert_and_key(FromOpaque(ctx)->cert->legacy_credential.get());
1611
1665
  }
1612
1666
 
1613
1667
  int SSL_check_private_key(const SSL *ssl) {
1614
- if (!ssl->config) {
1668
+ const auto *ssl_impl = FromOpaque(ssl);
1669
+ if (!ssl_impl->config) {
1615
1670
  return 0;
1616
1671
  }
1617
1672
 
1618
1673
  // There is no need to actually check consistency because inconsistent values
1619
1674
  // can never be configured.
1620
- return has_cert_and_key(ssl->config->cert->legacy_credential.get());
1675
+ return has_cert_and_key(ssl_impl->config->cert->legacy_credential.get());
1621
1676
  }
1622
1677
 
1623
1678
  long SSL_get_default_timeout(const SSL *ssl) {
@@ -1625,71 +1680,74 @@ long SSL_get_default_timeout(const SSL *ssl) {
1625
1680
  }
1626
1681
 
1627
1682
  int SSL_renegotiate(SSL *ssl) {
1683
+ auto *ssl_impl = FromOpaque(ssl);
1628
1684
  // Caller-initiated renegotiation is not supported.
1629
- if (!ssl->s3->renegotiate_pending) {
1685
+ if (!ssl_impl->s3->renegotiate_pending) {
1630
1686
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1631
1687
  return 0;
1632
1688
  }
1633
1689
 
1634
- if (!ssl_can_renegotiate(ssl)) {
1690
+ if (!ssl_can_renegotiate(ssl_impl)) {
1635
1691
  OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION);
1636
1692
  return 0;
1637
1693
  }
1638
1694
 
1639
1695
  // We should not have told the caller to release the private key.
1640
- assert(!SSL_can_release_private_key(ssl));
1696
+ assert(!SSL_can_release_private_key(ssl_impl));
1641
1697
 
1642
1698
  // Renegotiation is only supported at quiescent points in the application
1643
1699
  // protocol, namely in HTTPS, just before reading the HTTP response.
1644
1700
  // Require the record-layer be idle and avoid complexities of sending a
1645
1701
  // handshake record while an application_data record is being written.
1646
- if (!ssl->s3->write_buffer.empty() ||
1647
- ssl->s3->write_shutdown != ssl_shutdown_none) {
1702
+ if (!ssl_impl->s3->write_buffer.empty() ||
1703
+ ssl_impl->s3->write_shutdown != ssl_shutdown_none) {
1648
1704
  OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION);
1649
1705
  return 0;
1650
1706
  }
1651
1707
 
1652
1708
  // Begin a new handshake.
1653
- if (ssl->s3->hs != nullptr) {
1709
+ if (ssl_impl->s3->hs != nullptr) {
1654
1710
  OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
1655
1711
  return 0;
1656
1712
  }
1657
- ssl->s3->hs = ssl_handshake_new(ssl);
1658
- if (ssl->s3->hs == nullptr) {
1713
+ ssl_impl->s3->hs = ssl_handshake_new(ssl_impl);
1714
+ if (ssl_impl->s3->hs == nullptr) {
1659
1715
  return 0;
1660
1716
  }
1661
1717
 
1662
- ssl->s3->renegotiate_pending = false;
1663
- ssl->s3->total_renegotiations++;
1718
+ ssl_impl->s3->renegotiate_pending = false;
1719
+ ssl_impl->s3->total_renegotiations++;
1664
1720
  return 1;
1665
1721
  }
1666
1722
 
1667
1723
  int SSL_renegotiate_pending(SSL *ssl) {
1668
- return SSL_in_init(ssl) && ssl->s3->initial_handshake_complete;
1724
+ return SSL_in_init(ssl) && FromOpaque(ssl)->s3->initial_handshake_complete;
1669
1725
  }
1670
1726
 
1671
1727
  int SSL_total_renegotiations(const SSL *ssl) {
1672
- return ssl->s3->total_renegotiations;
1728
+ return FromOpaque(ssl)->s3->total_renegotiations;
1673
1729
  }
1674
1730
 
1675
1731
  size_t SSL_CTX_get_max_cert_list(const SSL_CTX *ctx) {
1676
- return ctx->max_cert_list;
1732
+ return FromOpaque(ctx)->max_cert_list;
1677
1733
  }
1678
1734
 
1679
1735
  void SSL_CTX_set_max_cert_list(SSL_CTX *ctx, size_t max_cert_list) {
1680
1736
  if (max_cert_list > kMaxHandshakeSize) {
1681
1737
  max_cert_list = kMaxHandshakeSize;
1682
1738
  }
1683
- ctx->max_cert_list = (uint32_t)max_cert_list;
1739
+ FromOpaque(ctx)->max_cert_list = (uint32_t)max_cert_list;
1684
1740
  }
1685
1741
 
1686
- size_t SSL_get_max_cert_list(const SSL *ssl) { return ssl->max_cert_list; }
1742
+ size_t SSL_get_max_cert_list(const SSL *ssl) {
1743
+ return FromOpaque(ssl)->max_cert_list;
1744
+ }
1687
1745
 
1688
1746
  void SSL_set_max_cert_list(SSL *ssl, size_t max_cert_list) {
1689
1747
  if (max_cert_list > kMaxHandshakeSize) {
1690
1748
  max_cert_list = kMaxHandshakeSize;
1691
1749
  }
1692
- ssl->max_cert_list = (uint32_t)max_cert_list;
1750
+ FromOpaque(ssl)->max_cert_list = (uint32_t)max_cert_list;
1693
1751
  }
1694
1752
 
1695
1753
  int SSL_CTX_set_max_send_fragment(SSL_CTX *ctx, size_t max_send_fragment) {
@@ -1699,7 +1757,7 @@ int SSL_CTX_set_max_send_fragment(SSL_CTX *ctx, size_t max_send_fragment) {
1699
1757
  if (max_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) {
1700
1758
  max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;
1701
1759
  }
1702
- ctx->max_send_fragment = (uint16_t)max_send_fragment;
1760
+ FromOpaque(ctx)->max_send_fragment = (uint16_t)max_send_fragment;
1703
1761
 
1704
1762
  return 1;
1705
1763
  }
@@ -1711,7 +1769,7 @@ int SSL_set_max_send_fragment(SSL *ssl, size_t max_send_fragment) {
1711
1769
  if (max_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) {
1712
1770
  max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;
1713
1771
  }
1714
- ssl->max_send_fragment = (uint16_t)max_send_fragment;
1772
+ FromOpaque(ssl)->max_send_fragment = (uint16_t)max_send_fragment;
1715
1773
 
1716
1774
  return 1;
1717
1775
  }
@@ -1720,46 +1778,45 @@ int SSL_set_mtu(SSL *ssl, unsigned mtu) {
1720
1778
  if (!SSL_is_dtls(ssl) || mtu < dtls1_min_mtu()) {
1721
1779
  return 0;
1722
1780
  }
1723
- ssl->d1->mtu = mtu;
1781
+ FromOpaque(ssl)->d1->mtu = mtu;
1724
1782
  return 1;
1725
1783
  }
1726
1784
 
1727
1785
  int SSL_get_secure_renegotiation_support(const SSL *ssl) {
1728
- if (ssl->s3->version == 0) {
1786
+ const auto *ssl_impl = FromOpaque(ssl);
1787
+ if (ssl_impl->s3->version == 0) {
1729
1788
  return 0;
1730
1789
  }
1731
- return ssl_protocol_version(ssl) >= TLS1_3_VERSION ||
1732
- ssl->s3->send_connection_binding;
1790
+ return ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION ||
1791
+ ssl_impl->s3->send_connection_binding;
1733
1792
  }
1734
1793
 
1735
1794
  size_t SSL_CTX_sess_number(const SSL_CTX *ctx) {
1736
- MutexReadLock lock(const_cast<CRYPTO_MUTEX *>(&ctx->lock));
1737
- return lh_SSL_SESSION_num_items(ctx->sessions);
1795
+ auto *ctx_impl = FromOpaque(ctx);
1796
+ MutexReadLock lock(&ctx_impl->lock);
1797
+ return lh_SSL_SESSION_num_items(ctx_impl->sessions);
1738
1798
  }
1739
1799
 
1740
1800
  unsigned long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, unsigned long size) {
1741
- unsigned long ret = ctx->session_cache_size;
1742
- ctx->session_cache_size = size;
1743
- return ret;
1801
+ return std::exchange(FromOpaque(ctx)->session_cache_size, size);
1744
1802
  }
1745
1803
 
1746
1804
  unsigned long SSL_CTX_sess_get_cache_size(const SSL_CTX *ctx) {
1747
- return ctx->session_cache_size;
1805
+ return FromOpaque(ctx)->session_cache_size;
1748
1806
  }
1749
1807
 
1750
1808
  int SSL_CTX_set_session_cache_mode(SSL_CTX *ctx, int mode) {
1751
- int ret = ctx->session_cache_mode;
1752
- ctx->session_cache_mode = mode;
1753
- return ret;
1809
+ return std::exchange(FromOpaque(ctx)->session_cache_mode, mode);
1754
1810
  }
1755
1811
 
1756
1812
  int SSL_CTX_get_session_cache_mode(const SSL_CTX *ctx) {
1757
- return ctx->session_cache_mode;
1813
+ return FromOpaque(ctx)->session_cache_mode;
1758
1814
  }
1759
1815
 
1760
1816
 
1761
1817
  int SSL_CTX_get_tlsext_ticket_keys(SSL_CTX *ctx, void *out, size_t len) {
1762
- if (out == NULL) {
1818
+ auto *ctx_impl = FromOpaque(ctx);
1819
+ if (out == nullptr) {
1763
1820
  return 48;
1764
1821
  }
1765
1822
  if (len != 48) {
@@ -1769,20 +1826,21 @@ int SSL_CTX_get_tlsext_ticket_keys(SSL_CTX *ctx, void *out, size_t len) {
1769
1826
 
1770
1827
  // The default ticket keys are initialized lazily. Trigger a key
1771
1828
  // rotation to initialize them.
1772
- if (!ssl_ctx_rotate_ticket_encryption_key(ctx)) {
1829
+ if (!ssl_ctx_rotate_ticket_encryption_key(ctx_impl)) {
1773
1830
  return 0;
1774
1831
  }
1775
1832
 
1776
1833
  uint8_t *out_bytes = reinterpret_cast<uint8_t *>(out);
1777
- MutexReadLock lock(&ctx->lock);
1778
- OPENSSL_memcpy(out_bytes, ctx->ticket_key_current->name, 16);
1779
- OPENSSL_memcpy(out_bytes + 16, ctx->ticket_key_current->hmac_key, 16);
1780
- OPENSSL_memcpy(out_bytes + 32, ctx->ticket_key_current->aes_key, 16);
1834
+ MutexReadLock lock(&ctx_impl->lock);
1835
+ OPENSSL_memcpy(out_bytes, ctx_impl->ticket_key_current->name, 16);
1836
+ OPENSSL_memcpy(out_bytes + 16, ctx_impl->ticket_key_current->hmac_key, 16);
1837
+ OPENSSL_memcpy(out_bytes + 32, ctx_impl->ticket_key_current->aes_key, 16);
1781
1838
  return 1;
1782
1839
  }
1783
1840
 
1784
1841
  int SSL_CTX_set_tlsext_ticket_keys(SSL_CTX *ctx, const void *in, size_t len) {
1785
- if (in == NULL) {
1842
+ auto *ctx_impl = FromOpaque(ctx);
1843
+ if (in == nullptr) {
1786
1844
  return 48;
1787
1845
  }
1788
1846
  if (len != 48) {
@@ -1800,8 +1858,8 @@ int SSL_CTX_set_tlsext_ticket_keys(SSL_CTX *ctx, const void *in, size_t len) {
1800
1858
  // Disable automatic key rotation for manually-configured keys. This is now
1801
1859
  // the caller's responsibility.
1802
1860
  key->next_rotation_tv_sec = 0;
1803
- ctx->ticket_key_current = std::move(key);
1804
- ctx->ticket_key_prev.reset();
1861
+ ctx_impl->ticket_key_current = std::move(key);
1862
+ ctx_impl->ticket_key_prev.reset();
1805
1863
  return 1;
1806
1864
  }
1807
1865
 
@@ -1809,10 +1867,25 @@ int SSL_CTX_set_tlsext_ticket_key_cb(
1809
1867
  SSL_CTX *ctx,
1810
1868
  int (*callback)(SSL *ssl, uint8_t *key_name, uint8_t *iv,
1811
1869
  EVP_CIPHER_CTX *ctx, HMAC_CTX *hmac_ctx, int encrypt)) {
1812
- ctx->ticket_key_cb = callback;
1870
+ FromOpaque(ctx)->ticket_key_cb = callback;
1813
1871
  return 1;
1814
1872
  }
1815
1873
 
1874
+ static bool check_no_duplicates(Span<const uint16_t> list, int reason) {
1875
+ if (list.size() < 2) {
1876
+ return true;
1877
+ }
1878
+ for (size_t i = 0; i < list.size() - 1; ++i) {
1879
+ for (size_t j = i + 1; j < list.size(); ++j) {
1880
+ if (list[i] == list[j]) {
1881
+ OPENSSL_PUT_ERROR(SSL, reason);
1882
+ return false;
1883
+ }
1884
+ }
1885
+ }
1886
+ return true;
1887
+ }
1888
+
1816
1889
  static bool check_group_ids(Span<const uint16_t> group_ids) {
1817
1890
  for (uint16_t group_id : group_ids) {
1818
1891
  if (ssl_group_id_to_nid(group_id) == NID_undef) {
@@ -1820,27 +1893,182 @@ static bool check_group_ids(Span<const uint16_t> group_ids) {
1820
1893
  return false;
1821
1894
  }
1822
1895
  }
1823
- return true;
1896
+ return check_no_duplicates(group_ids, SSL_R_DUPLICATE_GROUP);
1897
+ }
1898
+
1899
+ // validate_key_shares returns whether the `requested_key_shares` are free of
1900
+ // duplicates and are a (correctly ordered) subsequence of the supported
1901
+ // `groups`.
1902
+ static bool validate_key_shares(Span<const uint16_t> requested_key_shares,
1903
+ Span<const uint16_t> groups) {
1904
+ if (!check_no_duplicates(requested_key_shares, SSL_R_DUPLICATE_GROUP)) {
1905
+ return false;
1906
+ }
1907
+ if (requested_key_shares.size() > groups.size()) {
1908
+ return false;
1909
+ }
1910
+ size_t key_shares_idx = 0u, groups_idx = 0u;
1911
+ while (key_shares_idx < requested_key_shares.size() &&
1912
+ groups_idx < groups.size()) {
1913
+ if (requested_key_shares[key_shares_idx] == groups[groups_idx++]) {
1914
+ ++key_shares_idx;
1915
+ }
1916
+ }
1917
+ return key_shares_idx == requested_key_shares.size();
1918
+ }
1919
+
1920
+ static void clear_key_shares_if_invalid(SSL_CONFIG *config) {
1921
+ if (!config->client_key_share_selections) {
1922
+ return;
1923
+ }
1924
+ if (!validate_key_shares(*(config->client_key_share_selections),
1925
+ config->supported_group_list)) {
1926
+ config->client_key_share_selections.reset();
1927
+ }
1928
+ }
1929
+
1930
+ static bool check_group_flags(Span<const uint32_t> flags) {
1931
+ if (flags.empty()) {
1932
+ return true;
1933
+ }
1934
+ // The last element must not have the "equal preference with next" flag,
1935
+ // because there is no next element.
1936
+ return (flags.back() & SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT) == 0;
1937
+ }
1938
+
1939
+ static bool set_group_ids_and_flags(const uint16_t *group_ids,
1940
+ const uint32_t *flags, size_t num_group_ids,
1941
+ Array<uint16_t> *groups_out,
1942
+ Array<uint32_t> *flags_out) {
1943
+ Span<const uint16_t> groups_span = num_group_ids == 0
1944
+ ? DefaultSupportedGroupIds()
1945
+ : Span(group_ids, num_group_ids);
1946
+ if (!check_group_ids(groups_span)) {
1947
+ return false;
1948
+ }
1949
+ // If using default groups, always use default flags.
1950
+ if (flags == nullptr || num_group_ids == 0) {
1951
+ return groups_out->CopyFrom(groups_span) &&
1952
+ flags_out->Init(groups_span.size());
1953
+ }
1954
+ Span<const uint32_t> flags_span = Span(flags, num_group_ids);
1955
+ if (!check_group_flags(flags_span)) {
1956
+ return false;
1957
+ }
1958
+ return groups_out->CopyFrom(groups_span) && flags_out->CopyFrom(flags_span);
1824
1959
  }
1825
1960
 
1826
1961
  int SSL_CTX_set1_group_ids(SSL_CTX *ctx, const uint16_t *group_ids,
1827
1962
  size_t num_group_ids) {
1828
- auto span = Span(group_ids, num_group_ids);
1829
- return check_group_ids(span) && ctx->supported_group_list.CopyFrom(span);
1963
+ return SSL_CTX_set1_group_ids_with_flags(ctx, group_ids, /*flags=*/nullptr,
1964
+ num_group_ids);
1965
+ }
1966
+
1967
+ int SSL_CTX_set1_group_ids_with_flags(SSL_CTX *ctx, const uint16_t *group_ids,
1968
+ const uint32_t *flags,
1969
+ size_t num_group_ids) {
1970
+ auto *ctx_impl = FromOpaque(ctx);
1971
+ return set_group_ids_and_flags(group_ids, flags, num_group_ids,
1972
+ &ctx_impl->supported_group_list,
1973
+ &ctx_impl->supported_group_list_flags);
1830
1974
  }
1831
1975
 
1832
1976
  int SSL_set1_group_ids(SSL *ssl, const uint16_t *group_ids,
1833
1977
  size_t num_group_ids) {
1834
- if (!ssl->config) {
1978
+ return SSL_set1_group_ids_with_flags(ssl, group_ids, /*flags=*/nullptr,
1979
+ num_group_ids);
1980
+ }
1981
+
1982
+ int SSL_set1_group_ids_with_flags(SSL *ssl, const uint16_t *group_ids,
1983
+ const uint32_t *flags, size_t num_group_ids) {
1984
+ auto *ssl_impl = FromOpaque(ssl);
1985
+ if (!ssl_impl->config) {
1986
+ return 0;
1987
+ }
1988
+ if (set_group_ids_and_flags(group_ids, flags, num_group_ids,
1989
+ &ssl_impl->config->supported_group_list,
1990
+ &ssl_impl->config->supported_group_list_flags)) {
1991
+ clear_key_shares_if_invalid(ssl_impl->config.get());
1992
+ return 1;
1993
+ }
1994
+ return 0;
1995
+ }
1996
+
1997
+ static bool check_tls13_cipher_flags(Span<const uint32_t> flags) {
1998
+ if (flags.empty()) {
1999
+ return true;
2000
+ }
2001
+ // The last element must not have the "equal preference with next" flag,
2002
+ // because there is no next element.
2003
+ if ((flags.back() & SSL_CIPHER_FLAG_EQUAL_PREFERENCE_WITH_NEXT) != 0) {
2004
+ OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_CIPHER_FLAGS);
2005
+ return false;
2006
+ }
2007
+ return true;
2008
+ }
2009
+
2010
+ static bool check_tls13_cipher_ids(Span<const uint16_t> cipher_ids) {
2011
+ for (uint16_t cipher_id : cipher_ids) {
2012
+ const SSL_CIPHER *cipher = SSL_get_cipher_by_value(cipher_id);
2013
+ if (cipher == nullptr ||
2014
+ SSL_CIPHER_get_min_version(cipher) != TLS1_3_VERSION) {
2015
+ OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CIPHER_TYPE);
2016
+ return false;
2017
+ }
2018
+ }
2019
+ return check_no_duplicates(cipher_ids, SSL_R_DUPLICATE_CIPHER);
2020
+ }
2021
+
2022
+ static bool set_tls13_ciphers(const uint16_t *cipher_ids, const uint32_t *flags,
2023
+ size_t num_cipher_ids,
2024
+ SSLCipherPreferenceList *out) {
2025
+ if (num_cipher_ids == 0) {
2026
+ return ssl_create_default_tls13_cipher_list(out);
2027
+ }
2028
+ Span<const uint16_t> ciphers_span(cipher_ids, num_cipher_ids);
2029
+ if (!check_tls13_cipher_ids(ciphers_span)) {
2030
+ return false;
2031
+ }
2032
+ Array<bool> in_group_flags;
2033
+ if (!in_group_flags.Init(num_cipher_ids)) {
2034
+ return false;
2035
+ }
2036
+ if (flags == nullptr) {
2037
+ return out->Init(ciphers_span, in_group_flags);
2038
+ }
2039
+ Span<const uint32_t> flags_span = Span(flags, num_cipher_ids);
2040
+ if (!check_tls13_cipher_flags(flags_span)) {
2041
+ return false;
2042
+ }
2043
+ for (size_t i = 0; i < flags_span.size(); ++i) {
2044
+ in_group_flags[i] =
2045
+ (flags_span[i] & SSL_CIPHER_FLAG_EQUAL_PREFERENCE_WITH_NEXT) != 0;
2046
+ }
2047
+ return out->Init(ciphers_span, in_group_flags);
2048
+ }
2049
+
2050
+ int SSL_CTX_set1_tls13_ciphers(SSL_CTX *ctx, const uint16_t *cipher_ids,
2051
+ const uint32_t *flags, size_t num_cipher_ids) {
2052
+ auto *ctx_impl = FromOpaque(ctx);
2053
+ return set_tls13_ciphers(cipher_ids, flags, num_cipher_ids,
2054
+ &ctx_impl->tls13_cipher_list);
2055
+ }
2056
+
2057
+ int SSL_set1_tls13_ciphers(SSL *ssl, const uint16_t *cipher_ids,
2058
+ const uint32_t *flags, size_t num_cipher_ids) {
2059
+ auto *ssl_impl = FromOpaque(ssl);
2060
+ if (!ssl_impl->config) {
1835
2061
  return 0;
1836
2062
  }
1837
- auto span = Span(group_ids, num_group_ids);
1838
- return check_group_ids(span) &&
1839
- ssl->config->supported_group_list.CopyFrom(span);
2063
+ return set_tls13_ciphers(cipher_ids, flags, num_cipher_ids,
2064
+ &ssl_impl->config->tls13_cipher_list);
1840
2065
  }
1841
2066
 
1842
2067
  static bool ssl_nids_to_group_ids(Array<uint16_t> *out_group_ids,
1843
2068
  Span<const int> nids) {
2069
+ if (nids.empty()) {
2070
+ return out_group_ids->CopyFrom(DefaultSupportedGroupIds());
2071
+ }
1844
2072
  Array<uint16_t> group_ids;
1845
2073
  if (!group_ids.InitForOverwrite(nids.size())) {
1846
2074
  return false;
@@ -1852,22 +2080,35 @@ static bool ssl_nids_to_group_ids(Array<uint16_t> *out_group_ids,
1852
2080
  return false;
1853
2081
  }
1854
2082
  }
2083
+ if (!check_no_duplicates(group_ids, SSL_R_DUPLICATE_GROUP)) {
2084
+ return false;
2085
+ }
1855
2086
 
1856
2087
  *out_group_ids = std::move(group_ids);
1857
2088
  return true;
1858
2089
  }
1859
2090
 
1860
2091
  int SSL_CTX_set1_groups(SSL_CTX *ctx, const int *groups, size_t num_groups) {
1861
- return ssl_nids_to_group_ids(&ctx->supported_group_list,
1862
- Span(groups, num_groups));
2092
+ auto *ctx_impl = FromOpaque(ctx);
2093
+ return ssl_nids_to_group_ids(&ctx_impl->supported_group_list,
2094
+ Span(groups, num_groups)) &&
2095
+ ctx_impl->supported_group_list_flags.Init(
2096
+ ctx_impl->supported_group_list.size());
1863
2097
  }
1864
2098
 
1865
2099
  int SSL_set1_groups(SSL *ssl, const int *groups, size_t num_groups) {
1866
- if (!ssl->config) {
2100
+ auto *ssl_impl = FromOpaque(ssl);
2101
+ if (!ssl_impl->config) {
1867
2102
  return 0;
1868
2103
  }
1869
- return ssl_nids_to_group_ids(&ssl->config->supported_group_list,
1870
- Span(groups, num_groups));
2104
+ if (ssl_nids_to_group_ids(&ssl_impl->config->supported_group_list,
2105
+ Span(groups, num_groups)) &&
2106
+ ssl_impl->config->supported_group_list_flags.Init(
2107
+ ssl_impl->config->supported_group_list.size())) {
2108
+ clear_key_shares_if_invalid(ssl_impl->config.get());
2109
+ return 1;
2110
+ }
2111
+ return 0;
1871
2112
  }
1872
2113
 
1873
2114
  static bool ssl_str_to_group_ids(Array<uint16_t> *out_group_ids,
@@ -1903,24 +2144,37 @@ static bool ssl_str_to_group_ids(Array<uint16_t> *out_group_ids,
1903
2144
  } while (col);
1904
2145
 
1905
2146
  assert(i == count);
2147
+ if (!check_no_duplicates(group_ids, SSL_R_DUPLICATE_GROUP)) {
2148
+ return false;
2149
+ }
1906
2150
  *out_group_ids = std::move(group_ids);
1907
2151
  return true;
1908
2152
  }
1909
2153
 
1910
2154
  int SSL_CTX_set1_groups_list(SSL_CTX *ctx, const char *groups) {
1911
- return ssl_str_to_group_ids(&ctx->supported_group_list, groups);
2155
+ auto *ctx_impl = FromOpaque(ctx);
2156
+ return ssl_str_to_group_ids(&ctx_impl->supported_group_list, groups) &&
2157
+ ctx_impl->supported_group_list_flags.Init(
2158
+ ctx_impl->supported_group_list.size());
1912
2159
  }
1913
2160
 
1914
2161
  int SSL_set1_groups_list(SSL *ssl, const char *groups) {
1915
- if (!ssl->config) {
2162
+ auto *ssl_impl = FromOpaque(ssl);
2163
+ if (!ssl_impl->config) {
1916
2164
  return 0;
1917
2165
  }
1918
- return ssl_str_to_group_ids(&ssl->config->supported_group_list, groups);
2166
+ if (ssl_str_to_group_ids(&ssl_impl->config->supported_group_list, groups) &&
2167
+ ssl_impl->config->supported_group_list_flags.Init(
2168
+ ssl_impl->config->supported_group_list.size())) {
2169
+ clear_key_shares_if_invalid(ssl_impl->config.get());
2170
+ return 1;
2171
+ }
2172
+ return 0;
1919
2173
  }
1920
2174
 
1921
2175
  uint16_t SSL_get_group_id(const SSL *ssl) {
1922
- SSL_SESSION *session = SSL_get_session(ssl);
1923
- if (session == NULL) {
2176
+ SSLSession *session = ssl_get_session(FromOpaque(ssl));
2177
+ if (session == nullptr) {
1924
2178
  return 0;
1925
2179
  }
1926
2180
 
@@ -1935,104 +2189,131 @@ int SSL_get_negotiated_group(const SSL *ssl) {
1935
2189
  return ssl_group_id_to_nid(group_id);
1936
2190
  }
1937
2191
 
2192
+ int SSL_set1_client_key_shares(SSL *ssl, const uint16_t *group_ids,
2193
+ size_t num_group_ids) {
2194
+ auto *ssl_impl = FromOpaque(ssl);
2195
+ if (!ssl_impl->config) {
2196
+ return 0;
2197
+ }
2198
+ auto requested_key_shares = Span(group_ids, num_group_ids);
2199
+ if (!validate_key_shares(requested_key_shares,
2200
+ ssl_impl->config->supported_group_list)) {
2201
+ return 0;
2202
+ }
2203
+
2204
+ assert(requested_key_shares.size() <= kNumNamedGroups);
2205
+ ssl_impl->config->client_key_share_selections.emplace();
2206
+ ssl_impl->config->client_key_share_selections->CopyFrom(requested_key_shares);
2207
+ return 1;
2208
+ }
2209
+
2210
+ int SSL_set1_server_supported_groups_hint(SSL *ssl,
2211
+ const uint16_t *server_groups,
2212
+ size_t num_server_groups) {
2213
+ auto *ssl_impl = FromOpaque(ssl);
2214
+ if (!ssl_impl->config) {
2215
+ return 0;
2216
+ }
2217
+ auto span = Span(server_groups, num_server_groups);
2218
+ return ssl_impl->config->server_supported_groups_hint.CopyFrom(span);
2219
+ }
2220
+
1938
2221
  int SSL_CTX_set_tmp_dh(SSL_CTX *ctx, const DH *dh) { return 1; }
1939
2222
 
1940
2223
  int SSL_set_tmp_dh(SSL *ssl, const DH *dh) { return 1; }
1941
2224
 
1942
2225
  STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx) {
1943
- return ctx->cipher_list->ciphers.get();
2226
+ return FromOpaque(ctx)->cipher_list->ciphers();
1944
2227
  }
1945
2228
 
1946
2229
  int SSL_CTX_cipher_in_group(const SSL_CTX *ctx, size_t i) {
1947
- if (i >= sk_SSL_CIPHER_num(ctx->cipher_list->ciphers.get())) {
2230
+ auto *ctx_impl = FromOpaque(ctx);
2231
+ if (i >= sk_SSL_CIPHER_num(ctx_impl->cipher_list->ciphers())) {
1948
2232
  return 0;
1949
2233
  }
1950
- return ctx->cipher_list->in_group_flags[i];
2234
+ return ctx_impl->cipher_list->in_group_flags()[i];
1951
2235
  }
1952
2236
 
1953
2237
  STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl) {
1954
- if (ssl == NULL) {
1955
- return NULL;
2238
+ if (ssl == nullptr) {
2239
+ return nullptr;
1956
2240
  }
1957
- if (ssl->config == NULL) {
1958
- assert(ssl->config);
1959
- return NULL;
2241
+ const auto *ssl_impl = FromOpaque(ssl);
2242
+ if (ssl_impl->config == nullptr) {
2243
+ assert(ssl_impl->config);
2244
+ return nullptr;
1960
2245
  }
1961
2246
 
1962
- return ssl->config->cipher_list ? ssl->config->cipher_list->ciphers.get()
1963
- : ssl->ctx->cipher_list->ciphers.get();
2247
+ return ssl_impl->config->cipher_list
2248
+ ? ssl_impl->config->cipher_list->ciphers()
2249
+ : ssl_impl->ctx->cipher_list->ciphers();
1964
2250
  }
1965
2251
 
1966
2252
  const char *SSL_get_cipher_list(const SSL *ssl, int n) {
1967
- if (ssl == NULL) {
1968
- return NULL;
2253
+ if (ssl == nullptr) {
2254
+ return nullptr;
1969
2255
  }
1970
2256
 
1971
- STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
1972
- if (sk == NULL || n < 0 || (size_t)n >= sk_SSL_CIPHER_num(sk)) {
1973
- return NULL;
2257
+ const STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
2258
+ if (sk == nullptr || n < 0 ||
2259
+ static_cast<size_t>(n) >= sk_SSL_CIPHER_num(sk)) {
2260
+ return nullptr;
1974
2261
  }
1975
2262
 
1976
2263
  const SSL_CIPHER *c = sk_SSL_CIPHER_value(sk, n);
1977
- if (c == NULL) {
1978
- return NULL;
2264
+ if (c == nullptr) {
2265
+ return nullptr;
1979
2266
  }
1980
2267
 
1981
2268
  return c->name;
1982
2269
  }
1983
2270
 
1984
2271
  int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
1985
- const bool has_aes_hw = ctx->aes_hw_override ? ctx->aes_hw_override_value
1986
- : EVP_has_aes_hardware();
1987
- return ssl_create_cipher_list(&ctx->cipher_list, has_aes_hw, str,
2272
+ auto *ctx_impl = FromOpaque(ctx);
2273
+ return ssl_create_cipher_list(&ctx_impl->cipher_list, str,
1988
2274
  false /* not strict */);
1989
2275
  }
1990
2276
 
1991
2277
  int SSL_CTX_set_strict_cipher_list(SSL_CTX *ctx, const char *str) {
1992
- const bool has_aes_hw = ctx->aes_hw_override ? ctx->aes_hw_override_value
1993
- : EVP_has_aes_hardware();
1994
- return ssl_create_cipher_list(&ctx->cipher_list, has_aes_hw, str,
1995
- true /* strict */);
2278
+ auto *ctx_impl = FromOpaque(ctx);
2279
+ return ssl_create_cipher_list(&ctx_impl->cipher_list, str, true /* strict */);
1996
2280
  }
1997
2281
 
1998
2282
  int SSL_set_cipher_list(SSL *ssl, const char *str) {
1999
- if (!ssl->config) {
2283
+ auto *ssl_impl = FromOpaque(ssl);
2284
+ if (!ssl_impl->config) {
2000
2285
  return 0;
2001
2286
  }
2002
- const bool has_aes_hw = ssl->config->aes_hw_override
2003
- ? ssl->config->aes_hw_override_value
2004
- : EVP_has_aes_hardware();
2005
- return ssl_create_cipher_list(&ssl->config->cipher_list, has_aes_hw, str,
2287
+ return ssl_create_cipher_list(&ssl_impl->config->cipher_list, str,
2006
2288
  false /* not strict */);
2007
2289
  }
2008
2290
 
2009
2291
  int SSL_set_strict_cipher_list(SSL *ssl, const char *str) {
2010
- if (!ssl->config) {
2292
+ auto *ssl_impl = FromOpaque(ssl);
2293
+ if (!ssl_impl->config) {
2011
2294
  return 0;
2012
2295
  }
2013
- const bool has_aes_hw = ssl->config->aes_hw_override
2014
- ? ssl->config->aes_hw_override_value
2015
- : EVP_has_aes_hardware();
2016
- return ssl_create_cipher_list(&ssl->config->cipher_list, has_aes_hw, str,
2296
+ return ssl_create_cipher_list(&ssl_impl->config->cipher_list, str,
2017
2297
  true /* strict */);
2018
2298
  }
2019
2299
 
2020
2300
  const char *SSL_get_servername(const SSL *ssl, const int type) {
2021
2301
  if (type != TLSEXT_NAMETYPE_host_name) {
2022
- return NULL;
2302
+ return nullptr;
2023
2303
  }
2024
2304
 
2025
- // Historically, |SSL_get_servername| was also the configuration getter
2026
- // corresponding to |SSL_set_tlsext_host_name|.
2027
- if (ssl->hostname != nullptr) {
2028
- return ssl->hostname.get();
2305
+ const auto *ssl_impl = FromOpaque(ssl);
2306
+ // Historically, `SSL_get_servername` was also the configuration getter
2307
+ // corresponding to `SSL_set_tlsext_host_name`.
2308
+ if (ssl_impl->hostname != nullptr) {
2309
+ return ssl_impl->hostname.get();
2029
2310
  }
2030
2311
 
2031
- return ssl->s3->hostname.get();
2312
+ return ssl_impl->s3->hostname.get();
2032
2313
  }
2033
2314
 
2034
2315
  int SSL_get_servername_type(const SSL *ssl) {
2035
- if (SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name) == NULL) {
2316
+ if (SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name) == nullptr) {
2036
2317
  return -1;
2037
2318
  }
2038
2319
  return TLSEXT_NAMETYPE_host_name;
@@ -2041,48 +2322,53 @@ int SSL_get_servername_type(const SSL *ssl) {
2041
2322
  void SSL_CTX_set_custom_verify(
2042
2323
  SSL_CTX *ctx, int mode,
2043
2324
  enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)) {
2044
- ctx->verify_mode = mode;
2045
- ctx->custom_verify_callback = callback;
2325
+ auto *ctx_impl = FromOpaque(ctx);
2326
+ ctx_impl->verify_mode = mode;
2327
+ ctx_impl->custom_verify_callback = callback;
2046
2328
  }
2047
2329
 
2048
2330
  void SSL_set_custom_verify(
2049
2331
  SSL *ssl, int mode,
2050
2332
  enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)) {
2051
- if (!ssl->config) {
2333
+ auto *ssl_impl = FromOpaque(ssl);
2334
+ if (!ssl_impl->config) {
2052
2335
  return;
2053
2336
  }
2054
- ssl->config->verify_mode = mode;
2055
- ssl->config->custom_verify_callback = callback;
2337
+ ssl_impl->config->verify_mode = mode;
2338
+ ssl_impl->config->custom_verify_callback = callback;
2056
2339
  }
2057
2340
 
2058
2341
  void SSL_CTX_enable_signed_cert_timestamps(SSL_CTX *ctx) {
2059
- ctx->signed_cert_timestamps_enabled = true;
2342
+ FromOpaque(ctx)->signed_cert_timestamps_enabled = true;
2060
2343
  }
2061
2344
 
2062
2345
  void SSL_enable_signed_cert_timestamps(SSL *ssl) {
2063
- if (!ssl->config) {
2346
+ auto *ssl_impl = FromOpaque(ssl);
2347
+ if (!ssl_impl->config) {
2064
2348
  return;
2065
2349
  }
2066
- ssl->config->signed_cert_timestamps_enabled = true;
2350
+ ssl_impl->config->signed_cert_timestamps_enabled = true;
2067
2351
  }
2068
2352
 
2069
2353
  void SSL_CTX_enable_ocsp_stapling(SSL_CTX *ctx) {
2070
- ctx->ocsp_stapling_enabled = true;
2354
+ FromOpaque(ctx)->ocsp_stapling_enabled = true;
2071
2355
  }
2072
2356
 
2073
2357
  void SSL_enable_ocsp_stapling(SSL *ssl) {
2074
- if (!ssl->config) {
2358
+ auto *ssl_impl = FromOpaque(ssl);
2359
+ if (!ssl_impl->config) {
2075
2360
  return;
2076
2361
  }
2077
- ssl->config->ocsp_stapling_enabled = true;
2362
+ ssl_impl->config->ocsp_stapling_enabled = true;
2078
2363
  }
2079
2364
 
2080
2365
  void SSL_get0_signed_cert_timestamp_list(const SSL *ssl, const uint8_t **out,
2081
2366
  size_t *out_len) {
2082
- SSL_SESSION *session = SSL_get_session(ssl);
2083
- if (ssl->server || !session || !session->signed_cert_timestamp_list) {
2367
+ SSLSession *session = ssl_get_session(FromOpaque(ssl));
2368
+ if (FromOpaque(ssl)->server || !session ||
2369
+ !session->signed_cert_timestamp_list) {
2084
2370
  *out_len = 0;
2085
- *out = NULL;
2371
+ *out = nullptr;
2086
2372
  return;
2087
2373
  }
2088
2374
 
@@ -2092,10 +2378,10 @@ void SSL_get0_signed_cert_timestamp_list(const SSL *ssl, const uint8_t **out,
2092
2378
 
2093
2379
  void SSL_get0_ocsp_response(const SSL *ssl, const uint8_t **out,
2094
2380
  size_t *out_len) {
2095
- SSL_SESSION *session = SSL_get_session(ssl);
2096
- if (ssl->server || !session || !session->ocsp_response) {
2381
+ SSLSession *session = ssl_get_session(FromOpaque(ssl));
2382
+ if (FromOpaque(ssl)->server || !session || !session->ocsp_response) {
2097
2383
  *out_len = 0;
2098
- *out = NULL;
2384
+ *out = nullptr;
2099
2385
  return;
2100
2386
  }
2101
2387
 
@@ -2104,7 +2390,8 @@ void SSL_get0_ocsp_response(const SSL *ssl, const uint8_t **out,
2104
2390
  }
2105
2391
 
2106
2392
  int SSL_set_tlsext_host_name(SSL *ssl, const char *name) {
2107
- ssl->hostname.reset();
2393
+ auto *ssl_impl = FromOpaque(ssl);
2394
+ ssl_impl->hostname.reset();
2108
2395
  if (name == nullptr) {
2109
2396
  return 1;
2110
2397
  }
@@ -2114,8 +2401,8 @@ int SSL_set_tlsext_host_name(SSL *ssl, const char *name) {
2114
2401
  OPENSSL_PUT_ERROR(SSL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
2115
2402
  return 0;
2116
2403
  }
2117
- ssl->hostname.reset(OPENSSL_strdup(name));
2118
- if (ssl->hostname == nullptr) {
2404
+ ssl_impl->hostname.reset(OPENSSL_strdup(name));
2405
+ if (ssl_impl->hostname == nullptr) {
2119
2406
  return 0;
2120
2407
  }
2121
2408
  return 1;
@@ -2123,12 +2410,12 @@ int SSL_set_tlsext_host_name(SSL *ssl, const char *name) {
2123
2410
 
2124
2411
  int SSL_CTX_set_tlsext_servername_callback(
2125
2412
  SSL_CTX *ctx, int (*callback)(SSL *ssl, int *out_alert, void *arg)) {
2126
- ctx->servername_callback = callback;
2413
+ FromOpaque(ctx)->servername_callback = callback;
2127
2414
  return 1;
2128
2415
  }
2129
2416
 
2130
2417
  int SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg) {
2131
- ctx->servername_arg = arg;
2418
+ FromOpaque(ctx)->servername_arg = arg;
2132
2419
  return 1;
2133
2420
  }
2134
2421
 
@@ -2138,7 +2425,7 @@ int SSL_select_next_proto(uint8_t **out, uint8_t *out_len, const uint8_t *peer,
2138
2425
  *out = nullptr;
2139
2426
  *out_len = 0;
2140
2427
 
2141
- // Both |peer| and |supported| must be valid protocol lists, but |peer| may be
2428
+ // Both `peer` and `supported` must be valid protocol lists, but `peer` may be
2142
2429
  // empty in NPN.
2143
2430
  auto peer_span = Span(peer, peer_len);
2144
2431
  auto supported_span = Span(supported, supported_len);
@@ -2159,7 +2446,7 @@ int SSL_select_next_proto(uint8_t **out, uint8_t *out_len, const uint8_t *peer,
2159
2446
  // This function is not const-correct for compatibility with existing
2160
2447
  // callers.
2161
2448
  *out = const_cast<uint8_t *>(CBS_data(&proto));
2162
- // A u8 length prefix will fit in |uint8_t|.
2449
+ // A u8 length prefix will fit in `uint8_t`.
2163
2450
  *out_len = static_cast<uint8_t>(CBS_len(&proto));
2164
2451
  return OPENSSL_NPN_NEGOTIATED;
2165
2452
  }
@@ -2182,18 +2469,20 @@ int SSL_select_next_proto(uint8_t **out, uint8_t *out_len, const uint8_t *peer,
2182
2469
 
2183
2470
  void SSL_get0_next_proto_negotiated(const SSL *ssl, const uint8_t **out_data,
2184
2471
  unsigned *out_len) {
2185
- // NPN protocols have one-byte lengths, so they must fit in |unsigned|.
2186
- assert(ssl->s3->next_proto_negotiated.size() <= UINT_MAX);
2187
- *out_data = ssl->s3->next_proto_negotiated.data();
2188
- *out_len = static_cast<unsigned>(ssl->s3->next_proto_negotiated.size());
2472
+ const auto *ssl_impl = FromOpaque(ssl);
2473
+ // NPN protocols have one-byte lengths, so they must fit in `unsigned`.
2474
+ assert(ssl_impl->s3->next_proto_negotiated.size() <= UINT_MAX);
2475
+ *out_data = ssl_impl->s3->next_proto_negotiated.data();
2476
+ *out_len = static_cast<unsigned>(ssl_impl->s3->next_proto_negotiated.size());
2189
2477
  }
2190
2478
 
2191
2479
  void SSL_CTX_set_next_protos_advertised_cb(
2192
2480
  SSL_CTX *ctx,
2193
2481
  int (*cb)(SSL *ssl, const uint8_t **out, unsigned *out_len, void *arg),
2194
2482
  void *arg) {
2195
- ctx->next_protos_advertised_cb = cb;
2196
- ctx->next_protos_advertised_cb_arg = arg;
2483
+ auto *ctx_impl = FromOpaque(ctx);
2484
+ ctx_impl->next_protos_advertised_cb = cb;
2485
+ ctx_impl->next_protos_advertised_cb_arg = arg;
2197
2486
  }
2198
2487
 
2199
2488
  void SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx,
@@ -2202,8 +2491,9 @@ void SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx,
2202
2491
  const uint8_t *in,
2203
2492
  unsigned in_len, void *arg),
2204
2493
  void *arg) {
2205
- ctx->next_proto_select_cb = cb;
2206
- ctx->next_proto_select_cb_arg = arg;
2494
+ auto *ctx_impl = FromOpaque(ctx);
2495
+ ctx_impl->next_proto_select_cb = cb;
2496
+ ctx_impl->next_proto_select_cb_arg = arg;
2207
2497
  }
2208
2498
 
2209
2499
  int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const uint8_t *protos,
@@ -2214,12 +2504,13 @@ int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const uint8_t *protos,
2214
2504
  OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_ALPN_PROTOCOL_LIST);
2215
2505
  return 1;
2216
2506
  }
2217
- return ctx->alpn_client_proto_list.CopyFrom(span) ? 0 : 1;
2507
+ return FromOpaque(ctx)->alpn_client_proto_list.CopyFrom(span) ? 0 : 1;
2218
2508
  }
2219
2509
 
2220
2510
  int SSL_set_alpn_protos(SSL *ssl, const uint8_t *protos, size_t protos_len) {
2221
2511
  // Note this function's return value is backwards.
2222
- if (!ssl->config) {
2512
+ auto *ssl_impl = FromOpaque(ssl);
2513
+ if (!ssl_impl->config) {
2223
2514
  return 1;
2224
2515
  }
2225
2516
  auto span = Span(protos, protos_len);
@@ -2227,7 +2518,7 @@ int SSL_set_alpn_protos(SSL *ssl, const uint8_t *protos, size_t protos_len) {
2227
2518
  OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_ALPN_PROTOCOL_LIST);
2228
2519
  return 1;
2229
2520
  }
2230
- return ssl->config->alpn_client_proto_list.CopyFrom(span) ? 0 : 1;
2521
+ return ssl_impl->config->alpn_client_proto_list.CopyFrom(span) ? 0 : 1;
2231
2522
  }
2232
2523
 
2233
2524
  void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
@@ -2235,38 +2526,41 @@ void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
2235
2526
  uint8_t *out_len, const uint8_t *in,
2236
2527
  unsigned in_len, void *arg),
2237
2528
  void *arg) {
2238
- ctx->alpn_select_cb = cb;
2239
- ctx->alpn_select_cb_arg = arg;
2529
+ auto *ctx_impl = FromOpaque(ctx);
2530
+ ctx_impl->alpn_select_cb = cb;
2531
+ ctx_impl->alpn_select_cb_arg = arg;
2240
2532
  }
2241
2533
 
2242
2534
  void SSL_get0_alpn_selected(const SSL *ssl, const uint8_t **out_data,
2243
2535
  unsigned *out_len) {
2536
+ const auto *ssl_impl = FromOpaque(ssl);
2244
2537
  Span<const uint8_t> protocol;
2245
- if (SSL_in_early_data(ssl) && !ssl->server) {
2246
- protocol = ssl->s3->hs->early_session->early_alpn;
2538
+ if (SSL_in_early_data(ssl_impl) && !ssl_impl->server) {
2539
+ protocol = ssl_impl->s3->hs->early_session->early_alpn;
2247
2540
  } else {
2248
- protocol = ssl->s3->alpn_selected;
2541
+ protocol = ssl_impl->s3->alpn_selected;
2249
2542
  }
2250
- // ALPN protocols have one-byte lengths, so they must fit in |unsigned|.
2543
+ // ALPN protocols have one-byte lengths, so they must fit in `unsigned`.
2251
2544
  assert(protocol.size() < UINT_MAX);
2252
2545
  *out_data = protocol.data();
2253
2546
  *out_len = static_cast<unsigned>(protocol.size());
2254
2547
  }
2255
2548
 
2256
2549
  void SSL_CTX_set_allow_unknown_alpn_protos(SSL_CTX *ctx, int enabled) {
2257
- ctx->allow_unknown_alpn_protos = !!enabled;
2550
+ FromOpaque(ctx)->allow_unknown_alpn_protos = !!enabled;
2258
2551
  }
2259
2552
 
2260
2553
  int SSL_add_application_settings(SSL *ssl, const uint8_t *proto,
2261
2554
  size_t proto_len, const uint8_t *settings,
2262
2555
  size_t settings_len) {
2263
- if (!ssl->config) {
2556
+ auto *ssl_impl = FromOpaque(ssl);
2557
+ if (!ssl_impl->config) {
2264
2558
  return 0;
2265
2559
  }
2266
2560
  ALPSConfig config;
2267
2561
  if (!config.protocol.CopyFrom(Span(proto, proto_len)) ||
2268
2562
  !config.settings.CopyFrom(Span(settings, settings_len)) ||
2269
- !ssl->config->alps_configs.Push(std::move(config))) {
2563
+ !ssl_impl->config->alps_configs.Push(std::move(config))) {
2270
2564
  return 0;
2271
2565
  }
2272
2566
  return 1;
@@ -2275,7 +2569,7 @@ int SSL_add_application_settings(SSL *ssl, const uint8_t *proto,
2275
2569
  void SSL_get0_peer_application_settings(const SSL *ssl,
2276
2570
  const uint8_t **out_data,
2277
2571
  size_t *out_len) {
2278
- const SSL_SESSION *session = SSL_get_session(ssl);
2572
+ const SSLSession *session = ssl_get_session(FromOpaque(ssl));
2279
2573
  Span<const uint8_t> settings =
2280
2574
  session ? session->peer_application_settings : Span<const uint8_t>();
2281
2575
  *out_data = settings.data();
@@ -2283,15 +2577,16 @@ void SSL_get0_peer_application_settings(const SSL *ssl,
2283
2577
  }
2284
2578
 
2285
2579
  int SSL_has_application_settings(const SSL *ssl) {
2286
- const SSL_SESSION *session = SSL_get_session(ssl);
2580
+ const SSLSession *session = ssl_get_session(FromOpaque(ssl));
2287
2581
  return session && session->has_application_settings;
2288
2582
  }
2289
2583
 
2290
2584
  void SSL_set_alps_use_new_codepoint(SSL *ssl, int use_new) {
2291
- if (!ssl->config) {
2585
+ auto *ssl_impl = FromOpaque(ssl);
2586
+ if (!ssl_impl->config) {
2292
2587
  return;
2293
2588
  }
2294
- ssl->config->alps_use_new_codepoint = !!use_new;
2589
+ ssl_impl->config->alps_use_new_codepoint = !!use_new;
2295
2590
  }
2296
2591
 
2297
2592
  int SSL_CTX_add_cert_compression_alg(SSL_CTX *ctx, uint16_t alg_id,
@@ -2299,7 +2594,8 @@ int SSL_CTX_add_cert_compression_alg(SSL_CTX *ctx, uint16_t alg_id,
2299
2594
  ssl_cert_decompression_func_t decompress) {
2300
2595
  assert(compress != nullptr || decompress != nullptr);
2301
2596
 
2302
- for (const auto &alg : ctx->cert_compression_algs) {
2597
+ auto *ctx_impl = FromOpaque(ctx);
2598
+ for (const auto &alg : ctx_impl->cert_compression_algs) {
2303
2599
  if (alg.alg_id == alg_id) {
2304
2600
  return 0;
2305
2601
  }
@@ -2309,11 +2605,11 @@ int SSL_CTX_add_cert_compression_alg(SSL_CTX *ctx, uint16_t alg_id,
2309
2605
  alg.alg_id = alg_id;
2310
2606
  alg.compress = compress;
2311
2607
  alg.decompress = decompress;
2312
- return ctx->cert_compression_algs.Push(alg);
2608
+ return ctx_impl->cert_compression_algs.Push(alg);
2313
2609
  }
2314
2610
 
2315
2611
  void SSL_CTX_set_tls_channel_id_enabled(SSL_CTX *ctx, int enabled) {
2316
- ctx->channel_id_enabled = !!enabled;
2612
+ FromOpaque(ctx)->channel_id_enabled = !!enabled;
2317
2613
  }
2318
2614
 
2319
2615
  int SSL_CTX_enable_tls_channel_id(SSL_CTX *ctx) {
@@ -2322,10 +2618,11 @@ int SSL_CTX_enable_tls_channel_id(SSL_CTX *ctx) {
2322
2618
  }
2323
2619
 
2324
2620
  void SSL_set_tls_channel_id_enabled(SSL *ssl, int enabled) {
2325
- if (!ssl->config) {
2621
+ auto *ssl_impl = FromOpaque(ssl);
2622
+ if (!ssl_impl->config) {
2326
2623
  return;
2327
2624
  }
2328
- ssl->config->channel_id_enabled = !!enabled;
2625
+ ssl_impl->config->channel_id_enabled = !!enabled;
2329
2626
  }
2330
2627
 
2331
2628
  int SSL_enable_tls_channel_id(SSL *ssl) {
@@ -2333,47 +2630,44 @@ int SSL_enable_tls_channel_id(SSL *ssl) {
2333
2630
  return 1;
2334
2631
  }
2335
2632
 
2336
- static int is_p256_key(EVP_PKEY *private_key) {
2337
- const EC_KEY *ec_key = EVP_PKEY_get0_EC_KEY(private_key);
2338
- return ec_key != NULL && EC_GROUP_get_curve_name(EC_KEY_get0_group(ec_key)) ==
2339
- NID_X9_62_prime256v1;
2340
- }
2341
-
2342
2633
  int SSL_CTX_set1_tls_channel_id(SSL_CTX *ctx, EVP_PKEY *private_key) {
2343
- if (!is_p256_key(private_key)) {
2634
+ if (EVP_PKEY_get_ec_curve_nid(private_key) != NID_X9_62_prime256v1) {
2344
2635
  OPENSSL_PUT_ERROR(SSL, SSL_R_CHANNEL_ID_NOT_P256);
2345
2636
  return 0;
2346
2637
  }
2347
2638
 
2348
- ctx->channel_id_private = UpRef(private_key);
2639
+ FromOpaque(ctx)->channel_id_private = UpRef(private_key);
2349
2640
  return 1;
2350
2641
  }
2351
2642
 
2352
2643
  int SSL_set1_tls_channel_id(SSL *ssl, EVP_PKEY *private_key) {
2353
- if (!ssl->config) {
2644
+ auto *ssl_impl = FromOpaque(ssl);
2645
+ if (!ssl_impl->config) {
2354
2646
  return 0;
2355
2647
  }
2356
- if (!is_p256_key(private_key)) {
2648
+ if (EVP_PKEY_get_ec_curve_nid(private_key) != NID_X9_62_prime256v1) {
2357
2649
  OPENSSL_PUT_ERROR(SSL, SSL_R_CHANNEL_ID_NOT_P256);
2358
2650
  return 0;
2359
2651
  }
2360
2652
 
2361
- ssl->config->channel_id_private = UpRef(private_key);
2653
+ ssl_impl->config->channel_id_private = UpRef(private_key);
2362
2654
  return 1;
2363
2655
  }
2364
2656
 
2365
2657
  size_t SSL_get_tls_channel_id(SSL *ssl, uint8_t *out, size_t max_out) {
2366
- if (!ssl->s3->channel_id_valid) {
2658
+ const auto *ssl_impl = FromOpaque(ssl);
2659
+ if (!ssl_impl->s3->channel_id_valid) {
2367
2660
  return 0;
2368
2661
  }
2369
- OPENSSL_memcpy(out, ssl->s3->channel_id, (max_out < 64) ? max_out : 64);
2662
+ OPENSSL_memcpy(out, ssl_impl->s3->channel_id, (max_out < 64) ? max_out : 64);
2370
2663
  return 64;
2371
2664
  }
2372
2665
 
2373
2666
  size_t SSL_get0_certificate_types(const SSL *ssl, const uint8_t **out_types) {
2667
+ const auto *ssl_impl = FromOpaque(ssl);
2374
2668
  Span<const uint8_t> types;
2375
- if (!ssl->server && ssl->s3->hs != nullptr) {
2376
- types = ssl->s3->hs->certificate_types;
2669
+ if (!ssl_impl->server && ssl_impl->s3->hs != nullptr) {
2670
+ types = ssl_impl->s3->hs->certificate_types;
2377
2671
  }
2378
2672
  *out_types = types.data();
2379
2673
  return types.size();
@@ -2381,9 +2675,10 @@ size_t SSL_get0_certificate_types(const SSL *ssl, const uint8_t **out_types) {
2381
2675
 
2382
2676
  size_t SSL_get0_peer_verify_algorithms(const SSL *ssl,
2383
2677
  const uint16_t **out_sigalgs) {
2678
+ const auto *ssl_impl = FromOpaque(ssl);
2384
2679
  Span<const uint16_t> sigalgs;
2385
- if (ssl->s3->hs != nullptr) {
2386
- sigalgs = ssl->s3->hs->peer_sigalgs;
2680
+ if (ssl_impl->s3->hs != nullptr) {
2681
+ sigalgs = ssl_impl->s3->hs->peer_sigalgs;
2387
2682
  }
2388
2683
  *out_sigalgs = sigalgs.data();
2389
2684
  return sigalgs.size();
@@ -2391,121 +2686,131 @@ size_t SSL_get0_peer_verify_algorithms(const SSL *ssl,
2391
2686
 
2392
2687
  size_t SSL_get0_peer_delegation_algorithms(const SSL *ssl,
2393
2688
  const uint16_t **out_sigalgs) {
2689
+ const auto *ssl_impl = FromOpaque(ssl);
2394
2690
  Span<const uint16_t> sigalgs;
2395
- if (ssl->s3->hs != nullptr) {
2396
- sigalgs = ssl->s3->hs->peer_delegated_credential_sigalgs;
2691
+ if (ssl_impl->s3->hs != nullptr) {
2692
+ sigalgs = ssl_impl->s3->hs->peer_delegated_credential_sigalgs;
2397
2693
  }
2398
2694
  *out_sigalgs = sigalgs.data();
2399
2695
  return sigalgs.size();
2400
2696
  }
2401
2697
 
2402
2698
  EVP_PKEY *SSL_get_privatekey(const SSL *ssl) {
2403
- if (!ssl->config) {
2404
- assert(ssl->config);
2699
+ const auto *ssl_impl = FromOpaque(ssl);
2700
+ if (!ssl_impl->config) {
2701
+ assert(ssl_impl->config);
2405
2702
  return nullptr;
2406
2703
  }
2407
- return ssl->config->cert->legacy_credential->privkey.get();
2704
+ return ssl_impl->config->cert->legacy_credential->privkey.get();
2408
2705
  }
2409
2706
 
2410
2707
  EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx) {
2411
- return ctx->cert->legacy_credential->privkey.get();
2708
+ return FromOpaque(ctx)->cert->legacy_credential->privkey.get();
2412
2709
  }
2413
2710
 
2414
2711
  const SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl) {
2415
- const SSL_SESSION *session = SSL_get_session(ssl);
2712
+ const SSLSession *session = ssl_get_session(FromOpaque(ssl));
2416
2713
  return session == nullptr ? nullptr : session->cipher;
2417
2714
  }
2418
2715
 
2419
2716
  int SSL_session_reused(const SSL *ssl) {
2420
- return ssl->s3->session_reused || SSL_in_early_data(ssl);
2717
+ return FromOpaque(ssl)->s3->session_reused || SSL_in_early_data(ssl);
2421
2718
  }
2422
2719
 
2423
- const COMP_METHOD *SSL_get_current_compression(SSL *ssl) { return NULL; }
2720
+ const COMP_METHOD *SSL_get_current_compression(SSL *ssl) { return nullptr; }
2424
2721
 
2425
- const COMP_METHOD *SSL_get_current_expansion(SSL *ssl) { return NULL; }
2722
+ const COMP_METHOD *SSL_get_current_expansion(SSL *ssl) { return nullptr; }
2426
2723
 
2427
2724
  int SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key) { return 0; }
2428
2725
 
2726
+ int SSL_get_peer_tmp_key(SSL *ssl, EVP_PKEY **out_key) { return 0; }
2727
+
2429
2728
  void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode) {
2430
- ctx->quiet_shutdown = (mode != 0);
2729
+ FromOpaque(ctx)->quiet_shutdown = (mode != 0);
2431
2730
  }
2432
2731
 
2433
2732
  int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx) {
2434
- return ctx->quiet_shutdown;
2733
+ return FromOpaque(ctx)->quiet_shutdown;
2435
2734
  }
2436
2735
 
2437
2736
  void SSL_set_quiet_shutdown(SSL *ssl, int mode) {
2438
- ssl->quiet_shutdown = (mode != 0);
2737
+ FromOpaque(ssl)->quiet_shutdown = (mode != 0);
2439
2738
  }
2440
2739
 
2441
- int SSL_get_quiet_shutdown(const SSL *ssl) { return ssl->quiet_shutdown; }
2740
+ int SSL_get_quiet_shutdown(const SSL *ssl) {
2741
+ return FromOpaque(ssl)->quiet_shutdown;
2742
+ }
2442
2743
 
2443
2744
  void SSL_set_shutdown(SSL *ssl, int mode) {
2745
+ auto *ssl_impl = FromOpaque(ssl);
2444
2746
  // It is an error to clear any bits that have already been set. (We can't try
2445
2747
  // to get a second close_notify or send two.)
2446
2748
  assert((SSL_get_shutdown(ssl) & mode) == SSL_get_shutdown(ssl));
2447
2749
 
2448
2750
  if (mode & SSL_RECEIVED_SHUTDOWN &&
2449
- ssl->s3->read_shutdown == ssl_shutdown_none) {
2450
- ssl->s3->read_shutdown = ssl_shutdown_close_notify;
2751
+ ssl_impl->s3->read_shutdown == ssl_shutdown_none) {
2752
+ ssl_impl->s3->read_shutdown = ssl_shutdown_close_notify;
2451
2753
  }
2452
2754
 
2453
2755
  if (mode & SSL_SENT_SHUTDOWN &&
2454
- ssl->s3->write_shutdown == ssl_shutdown_none) {
2455
- ssl->s3->write_shutdown = ssl_shutdown_close_notify;
2756
+ ssl_impl->s3->write_shutdown == ssl_shutdown_none) {
2757
+ ssl_impl->s3->write_shutdown = ssl_shutdown_close_notify;
2456
2758
  }
2457
2759
  }
2458
2760
 
2459
2761
  int SSL_get_shutdown(const SSL *ssl) {
2762
+ const auto *ssl_impl = FromOpaque(ssl);
2460
2763
  int ret = 0;
2461
- if (ssl->s3->read_shutdown != ssl_shutdown_none) {
2462
- // Historically, OpenSSL set |SSL_RECEIVED_SHUTDOWN| on both close_notify
2764
+ if (ssl_impl->s3->read_shutdown != ssl_shutdown_none) {
2765
+ // Historically, OpenSSL set `SSL_RECEIVED_SHUTDOWN` on both close_notify
2463
2766
  // and fatal alert.
2464
2767
  ret |= SSL_RECEIVED_SHUTDOWN;
2465
2768
  }
2466
- if (ssl->s3->write_shutdown == ssl_shutdown_close_notify) {
2467
- // Historically, OpenSSL set |SSL_SENT_SHUTDOWN| on only close_notify.
2769
+ if (ssl_impl->s3->write_shutdown == ssl_shutdown_close_notify) {
2770
+ // Historically, OpenSSL set `SSL_SENT_SHUTDOWN` on only close_notify.
2468
2771
  ret |= SSL_SENT_SHUTDOWN;
2469
2772
  }
2470
2773
  return ret;
2471
2774
  }
2472
2775
 
2473
- SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) { return ssl->ctx.get(); }
2776
+ SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) { return FromOpaque(ssl)->ctx.get(); }
2474
2777
 
2475
2778
  SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) {
2476
- if (!ssl->config) {
2477
- return NULL;
2779
+ auto *ssl_impl = FromOpaque(ssl);
2780
+ if (!ssl_impl->config) {
2781
+ return nullptr;
2478
2782
  }
2479
- if (ssl->ctx.get() == ctx) {
2480
- return ssl->ctx.get();
2783
+ if (ssl_impl->ctx.get() == ctx) {
2784
+ return ssl_impl->ctx.get();
2481
2785
  }
2482
2786
 
2483
2787
  // One cannot change the X.509 callbacks during a connection.
2484
- if (ssl->ctx->x509_method != ctx->x509_method) {
2788
+ auto *ctx_impl = FromOpaque(ctx);
2789
+ if (ssl_impl->ctx->x509_method != ctx_impl->x509_method) {
2485
2790
  assert(0);
2486
- return NULL;
2791
+ return nullptr;
2487
2792
  }
2488
2793
 
2489
- UniquePtr<CERT> new_cert = ssl_cert_dup(ctx->cert.get());
2794
+ UniquePtr<CERT> new_cert = ssl_cert_dup(ctx_impl->cert.get());
2490
2795
  if (!new_cert) {
2491
2796
  return nullptr;
2492
2797
  }
2493
2798
 
2494
- ssl->config->cert = std::move(new_cert);
2495
- ssl->ctx = UpRef(ctx);
2496
- ssl->enable_early_data = ssl->ctx->enable_early_data;
2799
+ ssl_impl->config->cert = std::move(new_cert);
2800
+ ssl_impl->ctx = UpRef(ctx_impl);
2801
+ ssl_impl->enable_early_data = ssl_impl->ctx->enable_early_data;
2497
2802
 
2498
- return ssl->ctx.get();
2803
+ return ssl_impl->ctx.get();
2499
2804
  }
2500
2805
 
2501
2806
  void SSL_set_info_callback(SSL *ssl,
2502
2807
  void (*cb)(const SSL *ssl, int type, int value)) {
2503
- ssl->info_callback = cb;
2808
+ FromOpaque(ssl)->info_callback = cb;
2504
2809
  }
2505
2810
 
2506
2811
  void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type,
2507
2812
  int value) {
2508
- return ssl->info_callback;
2813
+ return FromOpaque(ssl)->info_callback;
2509
2814
  }
2510
2815
 
2511
2816
  int SSL_state(const SSL *ssl) {
@@ -2516,7 +2821,7 @@ void SSL_set_state(SSL *ssl, int state) {}
2516
2821
 
2517
2822
  char *SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len) {
2518
2823
  if (len <= 0) {
2519
- return NULL;
2824
+ return nullptr;
2520
2825
  }
2521
2826
  buf[0] = '\0';
2522
2827
  return buf;
@@ -2528,18 +2833,20 @@ int SSL_get_shared_sigalgs(SSL *ssl, int idx, int *psign, int *phash,
2528
2833
  }
2529
2834
 
2530
2835
  int SSL_CTX_set_quic_method(SSL_CTX *ctx, const SSL_QUIC_METHOD *quic_method) {
2531
- if (ctx->method->is_dtls) {
2836
+ auto *ctx_impl = FromOpaque(ctx);
2837
+ if (ctx_impl->method->is_dtls) {
2532
2838
  return 0;
2533
2839
  }
2534
- ctx->quic_method = quic_method;
2840
+ ctx_impl->quic_method = quic_method;
2535
2841
  return 1;
2536
2842
  }
2537
2843
 
2538
2844
  int SSL_set_quic_method(SSL *ssl, const SSL_QUIC_METHOD *quic_method) {
2539
- if (ssl->method->is_dtls) {
2845
+ auto *ssl_impl = FromOpaque(ssl);
2846
+ if (ssl_impl->method->is_dtls) {
2540
2847
  return 0;
2541
2848
  }
2542
- ssl->quic_method = quic_method;
2849
+ ssl_impl->quic_method = quic_method;
2543
2850
  return 1;
2544
2851
  }
2545
2852
 
@@ -2550,11 +2857,11 @@ int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
2550
2857
  }
2551
2858
 
2552
2859
  int SSL_set_ex_data(SSL *ssl, int idx, void *data) {
2553
- return CRYPTO_set_ex_data(&ssl->ex_data, idx, data);
2860
+ return CRYPTO_set_ex_data(&FromOpaque(ssl)->ex_data, idx, data);
2554
2861
  }
2555
2862
 
2556
2863
  void *SSL_get_ex_data(const SSL *ssl, int idx) {
2557
- return CRYPTO_get_ex_data(&ssl->ex_data, idx);
2864
+ return CRYPTO_get_ex_data(&FromOpaque(ssl)->ex_data, idx);
2558
2865
  }
2559
2866
 
2560
2867
  int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
@@ -2565,19 +2872,20 @@ int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
2565
2872
  }
2566
2873
 
2567
2874
  int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *data) {
2568
- return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
2875
+ return CRYPTO_set_ex_data(&FromOpaque(ctx)->ex_data, idx, data);
2569
2876
  }
2570
2877
 
2571
2878
  void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx) {
2572
- return CRYPTO_get_ex_data(&ctx->ex_data, idx);
2879
+ return CRYPTO_get_ex_data(&FromOpaque(ctx)->ex_data, idx);
2573
2880
  }
2574
2881
 
2575
2882
  int SSL_want(const SSL *ssl) {
2576
- // Historically, OpenSSL did not track |SSL_ERROR_ZERO_RETURN| as an |rwstate|
2577
- // value. We do, but map it back to |SSL_ERROR_NONE| to preserve the original
2883
+ const auto *ssl_impl = FromOpaque(ssl);
2884
+ // Historically, OpenSSL did not track `SSL_ERROR_ZERO_RETURN` as an `rwstate`
2885
+ // value. We do, but map it back to `SSL_ERROR_NONE` to preserve the original
2578
2886
  // behavior.
2579
- return ssl->s3->rwstate == SSL_ERROR_ZERO_RETURN ? SSL_ERROR_NONE
2580
- : ssl->s3->rwstate;
2887
+ return ssl_impl->s3->rwstate == SSL_ERROR_ZERO_RETURN ? SSL_ERROR_NONE
2888
+ : ssl_impl->s3->rwstate;
2581
2889
  }
2582
2890
 
2583
2891
  void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
@@ -2596,7 +2904,8 @@ void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*cb)(SSL *ssl, int is_export,
2596
2904
 
2597
2905
  static int use_psk_identity_hint(UniquePtr<char> *out,
2598
2906
  const char *identity_hint) {
2599
- if (identity_hint != NULL && strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) {
2907
+ if (identity_hint != nullptr &&
2908
+ strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) {
2600
2909
  OPENSSL_PUT_ERROR(SSL, SSL_R_DATA_LENGTH_TOO_LONG);
2601
2910
  return 0;
2602
2911
  }
@@ -2608,7 +2917,7 @@ static int use_psk_identity_hint(UniquePtr<char> *out,
2608
2917
  // send either no hint (omit ServerKeyExchange) or an empty hint, while
2609
2918
  // ECDHE_PSK can only spell empty hint. Having different capabilities is odd,
2610
2919
  // so we interpret empty and missing as identical.
2611
- if (identity_hint != NULL && identity_hint[0] != '\0') {
2920
+ if (identity_hint != nullptr && identity_hint[0] != '\0') {
2612
2921
  out->reset(OPENSSL_strdup(identity_hint));
2613
2922
  if (*out == nullptr) {
2614
2923
  return 0;
@@ -2619,34 +2928,38 @@ static int use_psk_identity_hint(UniquePtr<char> *out,
2619
2928
  }
2620
2929
 
2621
2930
  int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint) {
2622
- return use_psk_identity_hint(&ctx->psk_identity_hint, identity_hint);
2931
+ return use_psk_identity_hint(&FromOpaque(ctx)->psk_identity_hint,
2932
+ identity_hint);
2623
2933
  }
2624
2934
 
2625
2935
  int SSL_use_psk_identity_hint(SSL *ssl, const char *identity_hint) {
2626
- if (!ssl->config) {
2936
+ auto *ssl_impl = FromOpaque(ssl);
2937
+ if (!ssl_impl->config) {
2627
2938
  return 0;
2628
2939
  }
2629
- return use_psk_identity_hint(&ssl->config->psk_identity_hint, identity_hint);
2940
+ return use_psk_identity_hint(&ssl_impl->config->psk_identity_hint,
2941
+ identity_hint);
2630
2942
  }
2631
2943
 
2632
2944
  const char *SSL_get_psk_identity_hint(const SSL *ssl) {
2633
- if (ssl == NULL) {
2634
- return NULL;
2945
+ if (ssl == nullptr) {
2946
+ return nullptr;
2635
2947
  }
2636
- if (ssl->config == NULL) {
2637
- assert(ssl->config);
2638
- return NULL;
2948
+ const auto *ssl_impl = FromOpaque(ssl);
2949
+ if (ssl_impl->config == nullptr) {
2950
+ assert(ssl_impl->config);
2951
+ return nullptr;
2639
2952
  }
2640
- return ssl->config->psk_identity_hint.get();
2953
+ return ssl_impl->config->psk_identity_hint.get();
2641
2954
  }
2642
2955
 
2643
2956
  const char *SSL_get_psk_identity(const SSL *ssl) {
2644
- if (ssl == NULL) {
2645
- return NULL;
2957
+ if (ssl == nullptr) {
2958
+ return nullptr;
2646
2959
  }
2647
- SSL_SESSION *session = SSL_get_session(ssl);
2648
- if (session == NULL) {
2649
- return NULL;
2960
+ SSLSession *session = ssl_get_session(FromOpaque(ssl));
2961
+ if (session == nullptr) {
2962
+ return nullptr;
2650
2963
  }
2651
2964
  return session->psk_identity.get();
2652
2965
  }
@@ -2655,82 +2968,85 @@ void SSL_set_psk_client_callback(
2655
2968
  SSL *ssl, unsigned (*cb)(SSL *ssl, const char *hint, char *identity,
2656
2969
  unsigned max_identity_len, uint8_t *psk,
2657
2970
  unsigned max_psk_len)) {
2658
- if (!ssl->config) {
2971
+ auto *ssl_impl = FromOpaque(ssl);
2972
+ if (!ssl_impl->config) {
2659
2973
  return;
2660
2974
  }
2661
- ssl->config->psk_client_callback = cb;
2975
+ ssl_impl->config->psk_client_callback = cb;
2662
2976
  }
2663
2977
 
2664
2978
  void SSL_CTX_set_psk_client_callback(
2665
2979
  SSL_CTX *ctx, unsigned (*cb)(SSL *ssl, const char *hint, char *identity,
2666
2980
  unsigned max_identity_len, uint8_t *psk,
2667
2981
  unsigned max_psk_len)) {
2668
- ctx->psk_client_callback = cb;
2982
+ FromOpaque(ctx)->psk_client_callback = cb;
2669
2983
  }
2670
2984
 
2671
2985
  void SSL_set_psk_server_callback(SSL *ssl,
2672
2986
  unsigned (*cb)(SSL *ssl, const char *identity,
2673
2987
  uint8_t *psk,
2674
2988
  unsigned max_psk_len)) {
2675
- if (!ssl->config) {
2989
+ auto *ssl_impl = FromOpaque(ssl);
2990
+ if (!ssl_impl->config) {
2676
2991
  return;
2677
2992
  }
2678
- ssl->config->psk_server_callback = cb;
2993
+ ssl_impl->config->psk_server_callback = cb;
2679
2994
  }
2680
2995
 
2681
2996
  void SSL_CTX_set_psk_server_callback(
2682
2997
  SSL_CTX *ctx, unsigned (*cb)(SSL *ssl, const char *identity, uint8_t *psk,
2683
2998
  unsigned max_psk_len)) {
2684
- ctx->psk_server_callback = cb;
2999
+ FromOpaque(ctx)->psk_server_callback = cb;
2685
3000
  }
2686
3001
 
2687
3002
  void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
2688
3003
  void (*cb)(int write_p, int version,
2689
3004
  int content_type, const void *buf,
2690
3005
  size_t len, SSL *ssl, void *arg)) {
2691
- ctx->msg_callback = cb;
3006
+ FromOpaque(ctx)->msg_callback = cb;
2692
3007
  }
2693
3008
 
2694
3009
  void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg) {
2695
- ctx->msg_callback_arg = arg;
3010
+ FromOpaque(ctx)->msg_callback_arg = arg;
2696
3011
  }
2697
3012
 
2698
3013
  void SSL_set_msg_callback(SSL *ssl,
2699
3014
  void (*cb)(int write_p, int version, int content_type,
2700
3015
  const void *buf, size_t len, SSL *ssl,
2701
3016
  void *arg)) {
2702
- ssl->msg_callback = cb;
3017
+ FromOpaque(ssl)->msg_callback = cb;
2703
3018
  }
2704
3019
 
2705
3020
  void SSL_set_msg_callback_arg(SSL *ssl, void *arg) {
2706
- ssl->msg_callback_arg = arg;
3021
+ FromOpaque(ssl)->msg_callback_arg = arg;
2707
3022
  }
2708
3023
 
2709
3024
  void SSL_CTX_set_keylog_callback(SSL_CTX *ctx,
2710
3025
  void (*cb)(const SSL *ssl, const char *line)) {
2711
- ctx->keylog_callback = cb;
3026
+ FromOpaque(ctx)->keylog_callback = cb;
2712
3027
  }
2713
3028
 
2714
3029
  void (*SSL_CTX_get_keylog_callback(const SSL_CTX *ctx))(const SSL *ssl,
2715
3030
  const char *line) {
2716
- return ctx->keylog_callback;
3031
+ return FromOpaque(ctx)->keylog_callback;
2717
3032
  }
2718
3033
 
2719
3034
  void SSL_CTX_set_current_time_cb(SSL_CTX *ctx,
2720
3035
  void (*cb)(const SSL *ssl,
2721
3036
  struct timeval *out_clock)) {
2722
- ctx->current_time_cb = cb;
3037
+ FromOpaque(ctx)->current_time_cb = cb;
2723
3038
  }
2724
3039
 
2725
3040
  int SSL_can_release_private_key(const SSL *ssl) {
2726
- if (ssl_can_renegotiate(ssl)) {
3041
+ const auto *ssl_impl = FromOpaque(ssl);
3042
+ if (ssl_can_renegotiate(ssl_impl)) {
2727
3043
  // If the connection can renegotiate (client only), the private key may be
2728
3044
  // used in a future handshake.
2729
3045
  return 0;
2730
3046
  }
2731
3047
 
2732
3048
  // Otherwise, this is determined by the current handshake.
2733
- return !ssl->s3->hs || ssl->s3->hs->can_release_private_key;
3049
+ return !ssl_impl->s3->hs || ssl_impl->s3->hs->can_release_private_key;
2734
3050
  }
2735
3051
 
2736
3052
  int SSL_is_init_finished(const SSL *ssl) { return !SSL_in_init(ssl); }
@@ -2739,58 +3055,52 @@ int SSL_in_init(const SSL *ssl) {
2739
3055
  // This returns false once all the handshake state has been finalized, to
2740
3056
  // allow callbacks and getters based on SSL_in_init to return the correct
2741
3057
  // values.
2742
- SSL_HANDSHAKE *hs = ssl->s3->hs.get();
3058
+ const auto *ssl_impl = FromOpaque(ssl);
3059
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
2743
3060
  return hs != nullptr && !hs->handshake_finalized;
2744
3061
  }
2745
3062
 
2746
3063
  int SSL_in_false_start(const SSL *ssl) {
2747
- if (ssl->s3->hs == NULL) {
3064
+ const auto *ssl_impl = FromOpaque(ssl);
3065
+ if (ssl_impl->s3->hs == nullptr) {
2748
3066
  return 0;
2749
3067
  }
2750
- return ssl->s3->hs->in_false_start;
3068
+ return ssl_impl->s3->hs->in_false_start;
2751
3069
  }
2752
3070
 
2753
3071
  int SSL_cutthrough_complete(const SSL *ssl) { return SSL_in_false_start(ssl); }
2754
3072
 
2755
- int SSL_is_server(const SSL *ssl) { return ssl->server; }
3073
+ int SSL_is_server(const SSL *ssl) { return FromOpaque(ssl)->server; }
2756
3074
 
2757
- int SSL_is_dtls(const SSL *ssl) { return ssl->method->is_dtls; }
3075
+ int SSL_is_dtls(const SSL *ssl) { return FromOpaque(ssl)->method->is_dtls; }
2758
3076
 
2759
- int SSL_is_quic(const SSL *ssl) { return ssl->quic_method != nullptr; }
3077
+ int SSL_is_quic(const SSL *ssl) {
3078
+ return FromOpaque(ssl)->quic_method != nullptr;
3079
+ }
2760
3080
 
2761
3081
  void SSL_CTX_set_select_certificate_cb(
2762
3082
  SSL_CTX *ctx,
2763
3083
  enum ssl_select_cert_result_t (*cb)(const SSL_CLIENT_HELLO *)) {
2764
- ctx->select_certificate_cb = cb;
3084
+ FromOpaque(ctx)->select_certificate_cb = cb;
2765
3085
  }
2766
3086
 
2767
3087
  void SSL_CTX_set_dos_protection_cb(SSL_CTX *ctx,
2768
3088
  int (*cb)(const SSL_CLIENT_HELLO *)) {
2769
- ctx->dos_protection_cb = cb;
3089
+ FromOpaque(ctx)->dos_protection_cb = cb;
2770
3090
  }
2771
3091
 
2772
3092
  void SSL_CTX_set_reverify_on_resume(SSL_CTX *ctx, int enabled) {
2773
- ctx->reverify_on_resume = !!enabled;
2774
- }
2775
-
2776
- void SSL_set_enforce_rsa_key_usage(SSL *ssl, int enabled) {
2777
- if (!ssl->config) {
2778
- return;
2779
- }
2780
- ssl->config->enforce_rsa_key_usage = !!enabled;
2781
- }
2782
-
2783
- int SSL_was_key_usage_invalid(const SSL *ssl) {
2784
- return ssl->s3->was_key_usage_invalid;
3093
+ FromOpaque(ctx)->reverify_on_resume = !!enabled;
2785
3094
  }
2786
3095
 
2787
3096
  void SSL_set_renegotiate_mode(SSL *ssl, enum ssl_renegotiate_mode_t mode) {
2788
- ssl->renegotiate_mode = mode;
3097
+ auto *ssl_impl = FromOpaque(ssl);
3098
+ ssl_impl->renegotiate_mode = mode;
2789
3099
 
2790
- // Check if |ssl_can_renegotiate| has changed and the configuration may now be
3100
+ // Check if `ssl_can_renegotiate` has changed and the configuration may now be
2791
3101
  // shed. HTTP clients may initially allow renegotiation for HTTP/1.1, and then
2792
3102
  // disable after the handshake once the ALPN protocol is known to be HTTP/2.
2793
- ssl_maybe_shed_handshake_config(ssl);
3103
+ ssl_maybe_shed_handshake_config(ssl_impl);
2794
3104
  }
2795
3105
 
2796
3106
  int SSL_get_ivs(const SSL *ssl, const uint8_t **out_read_iv,
@@ -2802,9 +3112,10 @@ int SSL_get_ivs(const SSL *ssl, const uint8_t **out_read_iv,
2802
3112
  return 0;
2803
3113
  }
2804
3114
 
3115
+ const auto *ssl_impl = FromOpaque(ssl);
2805
3116
  size_t write_iv_len;
2806
- if (!ssl->s3->aead_read_ctx->GetIV(out_read_iv, out_iv_len) ||
2807
- !ssl->s3->aead_write_ctx->GetIV(out_write_iv, &write_iv_len) ||
3117
+ if (!ssl_impl->s3->aead_read_ctx->GetIV(out_read_iv, out_iv_len) ||
3118
+ !ssl_impl->s3->aead_write_ctx->GetIV(out_write_iv, &write_iv_len) ||
2808
3119
  *out_iv_len != write_iv_len) {
2809
3120
  return 0;
2810
3121
  }
@@ -2813,14 +3124,15 @@ int SSL_get_ivs(const SSL *ssl, const uint8_t **out_read_iv,
2813
3124
  }
2814
3125
 
2815
3126
  uint64_t SSL_get_read_sequence(const SSL *ssl) {
3127
+ const auto *ssl_impl = FromOpaque(ssl);
2816
3128
  if (SSL_is_dtls(ssl)) {
2817
3129
  // TODO(crbug.com/42290608): This API should not be implemented for DTLS or
2818
3130
  // QUIC. In QUIC we do not maintain a sequence number.
2819
- const DTLSReadEpoch *read_epoch = &ssl->d1->read_epoch;
3131
+ const DTLSReadEpoch *read_epoch = &ssl_impl->d1->read_epoch;
2820
3132
  return DTLSRecordNumber(read_epoch->epoch, read_epoch->bitmap.max_seq_num())
2821
3133
  .combined();
2822
3134
  }
2823
- return ssl->s3->read_sequence;
3135
+ return ssl_impl->s3->read_sequence;
2824
3136
  }
2825
3137
 
2826
3138
  uint64_t SSL_get_write_sequence(const SSL *ssl) {
@@ -2828,60 +3140,66 @@ uint64_t SSL_get_write_sequence(const SSL *ssl) {
2828
3140
  // QUIC. In QUIC we do not maintain a sequence number. In DTLS, this API isn't
2829
3141
  // harmful per se, but the caller already needs to use a DTLS-specific API on
2830
3142
  // the read side.
3143
+ const auto *ssl_impl = FromOpaque(ssl);
2831
3144
  if (SSL_is_dtls(ssl)) {
2832
- return ssl->d1->write_epoch.next_record.combined();
3145
+ return ssl_impl->d1->write_epoch.next_record.combined();
2833
3146
  }
2834
3147
 
2835
- return ssl->s3->write_sequence;
3148
+ return ssl_impl->s3->write_sequence;
2836
3149
  }
2837
3150
 
2838
3151
  int SSL_is_dtls_handshake_idle(const SSL *ssl) {
2839
3152
  BSSL_CHECK(SSL_is_dtls(ssl));
3153
+ const auto *ssl_impl = FromOpaque(ssl);
2840
3154
 
2841
3155
  return !SSL_in_init(ssl) &&
2842
3156
  // No unacknowledged messages in DTLS 1.3. In DTLS 1.2, there no ACKs
2843
- // and we currently never clear |outgoing_messages| on the side that
3157
+ // and we currently never clear `outgoing_messages` on the side that
2844
3158
  // speaks last.
2845
- (ssl_protocol_version(ssl) < TLS1_3_VERSION ||
2846
- ssl->d1->outgoing_messages.empty()) &&
3159
+ (ssl_protocol_version(ssl_impl) < TLS1_3_VERSION ||
3160
+ ssl_impl->d1->outgoing_messages.empty()) &&
2847
3161
  // No partial or out-of-order messages.
2848
- std::all_of(std::begin(ssl->d1->incoming_messages),
2849
- std::end(ssl->d1->incoming_messages),
3162
+ std::all_of(std::begin(ssl_impl->d1->incoming_messages),
3163
+ std::end(ssl_impl->d1->incoming_messages),
2850
3164
  [](const auto &msg) { return msg == nullptr; }) &&
2851
3165
  // Not trying to send a KeyUpdate.
2852
- !ssl->s3->key_update_pending &&
2853
- ssl->d1->queued_key_update == bssl::QueuedKeyUpdate::kNone;
3166
+ !ssl_impl->s3->key_update_pending &&
3167
+ ssl_impl->d1->queued_key_update == bssl::QueuedKeyUpdate::kNone;
2854
3168
  }
2855
3169
 
2856
3170
  uint32_t SSL_get_dtls_handshake_read_seq(const SSL *ssl) {
2857
3171
  BSSL_CHECK(SSL_is_dtls(ssl));
2858
- return ssl->d1->handshake_read_overflow
3172
+ const auto *ssl_impl = FromOpaque(ssl);
3173
+ return ssl_impl->d1->handshake_read_overflow
2859
3174
  ? uint32_t{0x10000}
2860
- : uint32_t{ssl->d1->handshake_read_seq};
3175
+ : uint32_t{ssl_impl->d1->handshake_read_seq};
2861
3176
  }
2862
3177
 
2863
3178
  uint32_t SSL_get_dtls_handshake_write_seq(const SSL *ssl) {
2864
3179
  BSSL_CHECK(SSL_is_dtls(ssl));
2865
- return ssl->d1->handshake_write_overflow
3180
+ const auto *ssl_impl = FromOpaque(ssl);
3181
+ return ssl_impl->d1->handshake_write_overflow
2866
3182
  ? uint32_t{0x10000}
2867
- : uint32_t{ssl->d1->handshake_write_seq};
3183
+ : uint32_t{ssl_impl->d1->handshake_write_seq};
2868
3184
  }
2869
3185
 
2870
3186
  uint16_t SSL_get_dtls_read_epoch(const SSL *ssl) {
2871
3187
  BSSL_CHECK(SSL_is_dtls(ssl));
3188
+ const auto *ssl_impl = FromOpaque(ssl);
2872
3189
  // Return the highest available epoch.
2873
- return ssl->d1->next_read_epoch ? ssl->d1->next_read_epoch->epoch
2874
- : ssl->d1->read_epoch.epoch;
3190
+ return ssl_impl->d1->next_read_epoch ? ssl_impl->d1->next_read_epoch->epoch
3191
+ : ssl_impl->d1->read_epoch.epoch;
2875
3192
  }
2876
3193
 
2877
3194
  uint16_t SSL_get_dtls_write_epoch(const SSL *ssl) {
2878
3195
  BSSL_CHECK(SSL_is_dtls(ssl));
2879
- return ssl->d1->write_epoch.epoch();
3196
+ return FromOpaque(ssl)->d1->write_epoch.epoch();
2880
3197
  }
2881
3198
 
2882
3199
  uint64_t SSL_get_dtls_read_sequence(const SSL *ssl, uint16_t epoch) {
2883
3200
  BSSL_CHECK(SSL_is_dtls(ssl));
2884
- const DTLSReadEpoch *read_epoch = dtls_get_read_epoch(ssl, epoch);
3201
+ const auto *ssl_impl = FromOpaque(ssl);
3202
+ const DTLSReadEpoch *read_epoch = dtls_get_read_epoch(ssl_impl, epoch);
2885
3203
  if (read_epoch == nullptr) {
2886
3204
  return UINT64_MAX;
2887
3205
  }
@@ -2891,7 +3209,7 @@ uint64_t SSL_get_dtls_read_sequence(const SSL *ssl, uint16_t epoch) {
2891
3209
  // Increment to get to an available sequence number.
2892
3210
  max_seq_num++;
2893
3211
  } else {
2894
- // If |max_seq_num| was available, the bitmap must have been empty.
3212
+ // If `max_seq_num` was available, the bitmap must have been empty.
2895
3213
  assert(max_seq_num == 0);
2896
3214
  }
2897
3215
  return max_seq_num;
@@ -2899,7 +3217,8 @@ uint64_t SSL_get_dtls_read_sequence(const SSL *ssl, uint16_t epoch) {
2899
3217
 
2900
3218
  uint64_t SSL_get_dtls_write_sequence(const SSL *ssl, uint16_t epoch) {
2901
3219
  BSSL_CHECK(SSL_is_dtls(ssl));
2902
- const DTLSWriteEpoch *write_epoch = dtls_get_write_epoch(ssl, epoch);
3220
+ const auto *ssl_impl = FromOpaque(ssl);
3221
+ const DTLSWriteEpoch *write_epoch = dtls_get_write_epoch(ssl_impl, epoch);
2903
3222
  if (write_epoch == nullptr) {
2904
3223
  return UINT64_MAX;
2905
3224
  }
@@ -2908,7 +3227,7 @@ uint64_t SSL_get_dtls_write_sequence(const SSL *ssl, uint16_t epoch) {
2908
3227
 
2909
3228
  template <typename EpochState>
2910
3229
  static int get_dtls_traffic_secret(
2911
- const SSL *ssl, EpochState *(*get_epoch)(const SSL *, uint16_t),
3230
+ const SSLImpl *ssl, EpochState *(*get_epoch)(const SSLImpl *, uint16_t),
2912
3231
  const uint8_t **out_data, size_t *out_len, uint16_t epoch) {
2913
3232
  BSSL_CHECK(SSL_is_dtls(ssl));
2914
3233
  // This function only applies to encrypted DTLS 1.3 epochs.
@@ -2928,19 +3247,19 @@ static int get_dtls_traffic_secret(
2928
3247
 
2929
3248
  int SSL_get_dtls_read_traffic_secret(const SSL *ssl, const uint8_t **out_data,
2930
3249
  size_t *out_len, uint16_t epoch) {
2931
- return get_dtls_traffic_secret(ssl, dtls_get_read_epoch, out_data, out_len,
2932
- epoch);
3250
+ return get_dtls_traffic_secret(FromOpaque(ssl), dtls_get_read_epoch, out_data,
3251
+ out_len, epoch);
2933
3252
  }
2934
3253
 
2935
3254
  int SSL_get_dtls_write_traffic_secret(const SSL *ssl, const uint8_t **out_data,
2936
3255
  size_t *out_len, uint16_t epoch) {
2937
- return get_dtls_traffic_secret(ssl, dtls_get_write_epoch, out_data, out_len,
2938
- epoch);
3256
+ return get_dtls_traffic_secret(FromOpaque(ssl), dtls_get_write_epoch,
3257
+ out_data, out_len, epoch);
2939
3258
  }
2940
3259
 
2941
3260
  uint16_t SSL_get_peer_signature_algorithm(const SSL *ssl) {
2942
- SSL_SESSION *session = SSL_get_session(ssl);
2943
- if (session == NULL) {
3261
+ SSLSession *session = ssl_get_session(FromOpaque(ssl));
3262
+ if (session == nullptr) {
2944
3263
  return 0;
2945
3264
  }
2946
3265
 
@@ -2948,105 +3267,127 @@ uint16_t SSL_get_peer_signature_algorithm(const SSL *ssl) {
2948
3267
  }
2949
3268
 
2950
3269
  size_t SSL_get_client_random(const SSL *ssl, uint8_t *out, size_t max_out) {
3270
+ const auto *ssl_impl = FromOpaque(ssl);
2951
3271
  if (max_out == 0) {
2952
- return sizeof(ssl->s3->client_random);
3272
+ return sizeof(ssl_impl->s3->client_random);
2953
3273
  }
2954
- if (max_out > sizeof(ssl->s3->client_random)) {
2955
- max_out = sizeof(ssl->s3->client_random);
3274
+ if (max_out > sizeof(ssl_impl->s3->client_random)) {
3275
+ max_out = sizeof(ssl_impl->s3->client_random);
2956
3276
  }
2957
- OPENSSL_memcpy(out, ssl->s3->client_random, max_out);
3277
+ OPENSSL_memcpy(out, ssl_impl->s3->client_random, max_out);
2958
3278
  return max_out;
2959
3279
  }
2960
3280
 
2961
3281
  size_t SSL_get_server_random(const SSL *ssl, uint8_t *out, size_t max_out) {
3282
+ const auto *ssl_impl = FromOpaque(ssl);
2962
3283
  if (max_out == 0) {
2963
- return sizeof(ssl->s3->server_random);
3284
+ return sizeof(ssl_impl->s3->server_random);
2964
3285
  }
2965
- if (max_out > sizeof(ssl->s3->server_random)) {
2966
- max_out = sizeof(ssl->s3->server_random);
3286
+ if (max_out > sizeof(ssl_impl->s3->server_random)) {
3287
+ max_out = sizeof(ssl_impl->s3->server_random);
2967
3288
  }
2968
- OPENSSL_memcpy(out, ssl->s3->server_random, max_out);
3289
+ OPENSSL_memcpy(out, ssl_impl->s3->server_random, max_out);
2969
3290
  return max_out;
2970
3291
  }
2971
3292
 
3293
+ uint16_t SSL_get_signature_algorithm_used(const SSL *ssl) {
3294
+ const auto *ssl_impl = FromOpaque(ssl);
3295
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
3296
+ if (hs == nullptr) {
3297
+ return 0;
3298
+ }
3299
+ return hs->signature_algorithm;
3300
+ }
3301
+
2972
3302
  const SSL_CIPHER *SSL_get_pending_cipher(const SSL *ssl) {
2973
- SSL_HANDSHAKE *hs = ssl->s3->hs.get();
2974
- if (hs == NULL) {
2975
- return NULL;
3303
+ const auto *ssl_impl = FromOpaque(ssl);
3304
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
3305
+ if (hs == nullptr) {
3306
+ return nullptr;
2976
3307
  }
2977
3308
  return hs->new_cipher;
2978
3309
  }
2979
3310
 
2980
3311
  void SSL_set_retain_only_sha256_of_client_certs(SSL *ssl, int enabled) {
2981
- if (!ssl->config) {
3312
+ auto *ssl_impl = FromOpaque(ssl);
3313
+ if (!ssl_impl->config) {
2982
3314
  return;
2983
3315
  }
2984
- ssl->config->retain_only_sha256_of_client_certs = !!enabled;
3316
+ ssl_impl->config->retain_only_sha256_of_client_certs = !!enabled;
2985
3317
  }
2986
3318
 
2987
3319
  void SSL_CTX_set_retain_only_sha256_of_client_certs(SSL_CTX *ctx, int enabled) {
2988
- ctx->retain_only_sha256_of_client_certs = !!enabled;
3320
+ FromOpaque(ctx)->retain_only_sha256_of_client_certs = !!enabled;
2989
3321
  }
2990
3322
 
2991
3323
  void SSL_CTX_set_grease_enabled(SSL_CTX *ctx, int enabled) {
2992
- ctx->grease_enabled = !!enabled;
3324
+ FromOpaque(ctx)->grease_enabled = !!enabled;
3325
+ }
3326
+
3327
+ void SSL_CTX_set_grease_sigalgs_enabled(SSL_CTX *ctx, int enabled) {
3328
+ FromOpaque(ctx)->grease_sigalgs_enabled = !!enabled;
2993
3329
  }
2994
3330
 
2995
3331
  void SSL_CTX_set_permute_extensions(SSL_CTX *ctx, int enabled) {
2996
- ctx->permute_extensions = !!enabled;
3332
+ FromOpaque(ctx)->permute_extensions = !!enabled;
2997
3333
  }
2998
3334
 
2999
3335
  void SSL_set_permute_extensions(SSL *ssl, int enabled) {
3000
- if (!ssl->config) {
3336
+ auto *ssl_impl = FromOpaque(ssl);
3337
+ if (!ssl_impl->config) {
3001
3338
  return;
3002
3339
  }
3003
- ssl->config->permute_extensions = !!enabled;
3340
+ ssl_impl->config->permute_extensions = !!enabled;
3004
3341
  }
3005
3342
 
3006
3343
  int32_t SSL_get_ticket_age_skew(const SSL *ssl) {
3007
- return ssl->s3->ticket_age_skew;
3344
+ return FromOpaque(ssl)->s3->ticket_age_skew;
3008
3345
  }
3009
3346
 
3010
3347
  void SSL_CTX_set_false_start_allowed_without_alpn(SSL_CTX *ctx, int allowed) {
3011
- ctx->false_start_allowed_without_alpn = !!allowed;
3348
+ FromOpaque(ctx)->false_start_allowed_without_alpn = !!allowed;
3012
3349
  }
3013
3350
 
3014
3351
  int SSL_used_hello_retry_request(const SSL *ssl) {
3015
- return ssl->s3->used_hello_retry_request;
3352
+ return FromOpaque(ssl)->s3->used_hello_retry_request;
3016
3353
  }
3017
3354
 
3018
3355
  void SSL_set_shed_handshake_config(SSL *ssl, int enable) {
3019
- if (!ssl->config) {
3356
+ auto *ssl_impl = FromOpaque(ssl);
3357
+ if (!ssl_impl->config) {
3020
3358
  return;
3021
3359
  }
3022
- ssl->config->shed_handshake_config = !!enable;
3360
+ ssl_impl->config->shed_handshake_config = !!enable;
3023
3361
  }
3024
3362
 
3025
3363
  void SSL_set_jdk11_workaround(SSL *ssl, int enable) {
3026
- if (!ssl->config) {
3364
+ auto *ssl_impl = FromOpaque(ssl);
3365
+ if (!ssl_impl->config) {
3027
3366
  return;
3028
3367
  }
3029
- ssl->config->jdk11_workaround = !!enable;
3368
+ ssl_impl->config->jdk11_workaround = !!enable;
3030
3369
  }
3031
3370
 
3032
3371
  void SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy) {
3033
- if (!ssl->config) {
3372
+ auto *ssl_impl = FromOpaque(ssl);
3373
+ if (!ssl_impl->config) {
3034
3374
  return;
3035
3375
  }
3036
- ssl->config->quic_use_legacy_codepoint = !!use_legacy;
3376
+ ssl_impl->config->quic_use_legacy_codepoint = !!use_legacy;
3037
3377
  }
3038
3378
 
3039
3379
  int SSL_clear(SSL *ssl) {
3040
- if (!ssl->config) {
3380
+ auto *ssl_impl = FromOpaque(ssl);
3381
+ if (!ssl_impl->config) {
3041
3382
  return 0; // SSL_clear may not be used after shedding config.
3042
3383
  }
3043
3384
 
3044
- // In OpenSSL, reusing a client |SSL| with |SSL_clear| causes the previously
3385
+ // In OpenSSL, reusing a client `SSL` with `SSL_clear` causes the previously
3045
3386
  // established session to be offered the next time around. wpa_supplicant
3046
3387
  // depends on this behavior, so emulate it.
3047
- UniquePtr<SSL_SESSION> session;
3048
- if (!ssl->server && ssl->s3->established_session != NULL) {
3049
- session = UpRef(ssl->s3->established_session);
3388
+ UniquePtr<SSLSession> session;
3389
+ if (!ssl_impl->server && ssl_impl->s3->established_session != nullptr) {
3390
+ session = UpRef(ssl_impl->s3->established_session);
3050
3391
  }
3051
3392
 
3052
3393
  // The ssl->d1->mtu is simultaneously configuration (preserved across
@@ -3054,17 +3395,17 @@ int SSL_clear(SSL *ssl) {
3054
3395
  //
3055
3396
  // TODO(davidben): Avoid this.
3056
3397
  unsigned mtu = 0;
3057
- if (ssl->d1 != NULL) {
3058
- mtu = ssl->d1->mtu;
3398
+ if (ssl_impl->d1 != nullptr) {
3399
+ mtu = ssl_impl->d1->mtu;
3059
3400
  }
3060
3401
 
3061
- ssl->method->ssl_free(ssl);
3062
- if (!ssl->method->ssl_new(ssl)) {
3402
+ ssl_impl->method->ssl_free(ssl_impl);
3403
+ if (!ssl_impl->method->ssl_new(ssl_impl)) {
3063
3404
  return 0;
3064
3405
  }
3065
3406
 
3066
3407
  if (SSL_is_dtls(ssl) && (SSL_get_options(ssl) & SSL_OP_NO_QUERY_MTU)) {
3067
- ssl->d1->mtu = mtu;
3408
+ ssl_impl->d1->mtu = mtu;
3068
3409
  }
3069
3410
 
3070
3411
  if (session != nullptr) {
@@ -3094,12 +3435,12 @@ int SSL_CTX_need_tmp_RSA(const SSL_CTX *ctx) { return 0; }
3094
3435
  int SSL_need_tmp_RSA(const SSL *ssl) { return 0; }
3095
3436
  int SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, const RSA *rsa) { return 1; }
3096
3437
  int SSL_set_tmp_rsa(SSL *ssl, const RSA *rsa) { return 1; }
3097
- void ERR_load_SSL_strings(void) {}
3098
- void SSL_load_error_strings(void) {}
3438
+ void ERR_load_SSL_strings() {}
3439
+ void SSL_load_error_strings() {}
3099
3440
  int SSL_cache_hit(SSL *ssl) { return SSL_session_reused(ssl); }
3100
3441
 
3101
3442
  int SSL_CTX_set_tmp_ecdh(SSL_CTX *ctx, const EC_KEY *ec_key) {
3102
- if (ec_key == NULL || EC_KEY_get0_group(ec_key) == NULL) {
3443
+ if (ec_key == nullptr || EC_KEY_get0_group(ec_key) == nullptr) {
3103
3444
  OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
3104
3445
  return 0;
3105
3446
  }
@@ -3108,7 +3449,7 @@ int SSL_CTX_set_tmp_ecdh(SSL_CTX *ctx, const EC_KEY *ec_key) {
3108
3449
  }
3109
3450
 
3110
3451
  int SSL_set_tmp_ecdh(SSL *ssl, const EC_KEY *ec_key) {
3111
- if (ec_key == NULL || EC_KEY_get0_group(ec_key) == NULL) {
3452
+ if (ec_key == nullptr || EC_KEY_get0_group(ec_key) == nullptr) {
3112
3453
  OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
3113
3454
  return 0;
3114
3455
  }
@@ -3118,14 +3459,15 @@ int SSL_set_tmp_ecdh(SSL *ssl, const EC_KEY *ec_key) {
3118
3459
 
3119
3460
  void SSL_CTX_set_ticket_aead_method(SSL_CTX *ctx,
3120
3461
  const SSL_TICKET_AEAD_METHOD *aead_method) {
3121
- ctx->ticket_aead_method = aead_method;
3462
+ FromOpaque(ctx)->ticket_aead_method = aead_method;
3122
3463
  }
3123
3464
 
3124
3465
  SSL_SESSION *SSL_process_tls13_new_session_ticket(SSL *ssl, const uint8_t *buf,
3125
3466
  size_t buf_len) {
3126
- if (SSL_in_init(ssl) || //
3127
- ssl_protocol_version(ssl) != TLS1_3_VERSION || //
3128
- ssl->server) {
3467
+ auto *ssl_impl = FromOpaque(ssl);
3468
+ if (SSL_in_init(ssl_impl) || //
3469
+ ssl_protocol_version(ssl_impl) != TLS1_3_VERSION || //
3470
+ ssl_impl->server) {
3129
3471
  // Only TLS 1.3 clients are supported.
3130
3472
  OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3131
3473
  return nullptr;
@@ -3141,9 +3483,10 @@ SSL_SESSION *SSL_process_tls13_new_session_ticket(SSL *ssl, const uint8_t *buf,
3141
3483
  return nullptr;
3142
3484
  }
3143
3485
 
3144
- UniquePtr<SSL_SESSION> session = tls13_create_session_with_ticket(ssl, &body);
3486
+ UniquePtr<SSLSession> session =
3487
+ tls13_create_session_with_ticket(ssl_impl, &body);
3145
3488
  if (!session) {
3146
- // |tls13_create_session_with_ticket| puts the correct error.
3489
+ // `tls13_create_session_with_ticket` puts the correct error.
3147
3490
  return nullptr;
3148
3491
  }
3149
3492
  return session.release();
@@ -3152,29 +3495,33 @@ SSL_SESSION *SSL_process_tls13_new_session_ticket(SSL *ssl, const uint8_t *buf,
3152
3495
  int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets) {
3153
3496
  num_tickets = std::min(num_tickets, kMaxTickets);
3154
3497
  static_assert(kMaxTickets <= 0xff, "Too many tickets.");
3155
- ctx->num_tickets = static_cast<uint8_t>(num_tickets);
3498
+ FromOpaque(ctx)->num_tickets = static_cast<uint8_t>(num_tickets);
3156
3499
  return 1;
3157
3500
  }
3158
3501
 
3159
- size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx) { return ctx->num_tickets; }
3502
+ size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx) {
3503
+ return FromOpaque(ctx)->num_tickets;
3504
+ }
3160
3505
 
3161
3506
  int SSL_set_tlsext_status_type(SSL *ssl, int type) {
3162
- if (!ssl->config) {
3507
+ auto *ssl_impl = FromOpaque(ssl);
3508
+ if (!ssl_impl->config) {
3163
3509
  return 0;
3164
3510
  }
3165
- ssl->config->ocsp_stapling_enabled = type == TLSEXT_STATUSTYPE_ocsp;
3511
+ ssl_impl->config->ocsp_stapling_enabled = type == TLSEXT_STATUSTYPE_ocsp;
3166
3512
  return 1;
3167
3513
  }
3168
3514
 
3169
3515
  int SSL_get_tlsext_status_type(const SSL *ssl) {
3170
- if (ssl->server) {
3171
- SSL_HANDSHAKE *hs = ssl->s3->hs.get();
3516
+ const auto *ssl_impl = FromOpaque(ssl);
3517
+ if (ssl_impl->server) {
3518
+ SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
3172
3519
  return hs != nullptr && hs->ocsp_stapling_requested
3173
3520
  ? TLSEXT_STATUSTYPE_ocsp
3174
3521
  : TLSEXT_STATUSTYPE_nothing;
3175
3522
  }
3176
3523
 
3177
- return ssl->config != nullptr && ssl->config->ocsp_stapling_enabled
3524
+ return ssl_impl->config != nullptr && ssl_impl->config->ocsp_stapling_enabled
3178
3525
  ? TLSEXT_STATUSTYPE_ocsp
3179
3526
  : TLSEXT_STATUSTYPE_nothing;
3180
3527
  }
@@ -3195,12 +3542,12 @@ size_t SSL_get_tlsext_status_ocsp_resp(const SSL *ssl, const uint8_t **out) {
3195
3542
 
3196
3543
  int SSL_CTX_set_tlsext_status_cb(SSL_CTX *ctx,
3197
3544
  int (*callback)(SSL *ssl, void *arg)) {
3198
- ctx->legacy_ocsp_callback = callback;
3545
+ FromOpaque(ctx)->legacy_ocsp_callback = callback;
3199
3546
  return 1;
3200
3547
  }
3201
3548
 
3202
3549
  int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg) {
3203
- ctx->legacy_ocsp_callback_arg = arg;
3550
+ FromOpaque(ctx)->legacy_ocsp_callback_arg = arg;
3204
3551
  return 1;
3205
3552
  }
3206
3553
 
@@ -3262,7 +3609,16 @@ static const char kTLS12Ciphers[] =
3262
3609
  "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
3263
3610
  "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
3264
3611
 
3265
- static int Configure(SSL_CTX *ctx) {
3612
+ static const uint16_t kTLS13Ciphers[] = {
3613
+ SSL_CIPHER_AES_128_GCM_SHA256,
3614
+ SSL_CIPHER_AES_256_GCM_SHA384,
3615
+ };
3616
+ static const bool kTLS13CiphersInGroup[] = {
3617
+ true,
3618
+ false,
3619
+ };
3620
+
3621
+ static int Configure(SSLContext *ctx) {
3266
3622
  ctx->compliance_policy = ssl_compliance_policy_fips_202205;
3267
3623
 
3268
3624
  return
@@ -3278,29 +3634,120 @@ static int Configure(SSL_CTX *ctx) {
3278
3634
  // Encrypt-then-MAC extension is required for all CBC cipher suites and so
3279
3635
  // it's easier to drop them.
3280
3636
  SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
3281
- SSL_CTX_set1_group_ids(ctx, kGroups, OPENSSL_ARRAY_SIZE(kGroups)) &&
3282
- SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
3283
- OPENSSL_ARRAY_SIZE(kSigAlgs)) &&
3284
- SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs,
3285
- OPENSSL_ARRAY_SIZE(kSigAlgs));
3637
+ ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3638
+ Span(kTLS13CiphersInGroup)) &&
3639
+ SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
3640
+ SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs)) &&
3641
+ SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
3286
3642
  }
3287
3643
 
3288
- static int Configure(SSL *ssl) {
3644
+ static int Configure(SSLImpl *ssl) {
3289
3645
  ssl->config->compliance_policy = ssl_compliance_policy_fips_202205;
3290
3646
 
3291
- // See |Configure(SSL_CTX)|, above, for reasoning.
3647
+ // See `Configure(SSL_CTX)`, above, for reasoning.
3292
3648
  return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
3293
3649
  SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
3294
3650
  SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
3295
- SSL_set1_group_ids(ssl, kGroups, OPENSSL_ARRAY_SIZE(kGroups)) &&
3296
- SSL_set_signing_algorithm_prefs(ssl, kSigAlgs,
3297
- OPENSSL_ARRAY_SIZE(kSigAlgs)) &&
3298
- SSL_set_verify_algorithm_prefs(ssl, kSigAlgs,
3299
- OPENSSL_ARRAY_SIZE(kSigAlgs));
3651
+ ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3652
+ Span(kTLS13CiphersInGroup)) &&
3653
+ SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
3654
+ SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
3655
+ SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
3300
3656
  }
3301
3657
 
3302
3658
  } // namespace fips202205
3303
3659
 
3660
+ namespace fips202609 {
3661
+
3662
+ // (References are to SP 800-52r2):
3663
+
3664
+ static const uint16_t kGroups[] = {
3665
+ SSL_GROUP_X25519_MLKEM768,
3666
+ SSL_GROUP_MLKEM1024,
3667
+ SSL_GROUP_SECP256R1,
3668
+ SSL_GROUP_SECP384R1,
3669
+ };
3670
+ static const uint32_t kGroupsFlags[] = {
3671
+ SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT,
3672
+ 0,
3673
+ 0,
3674
+ 0,
3675
+ };
3676
+
3677
+ // Prefer post-quantum groups equally if the client supports them.
3678
+ static const uint32_t kOptions = SSL_OP_CIPHER_SERVER_PREFERENCE;
3679
+
3680
+ static const uint16_t kSigAlgs[] = {
3681
+ SSL_SIGN_RSA_PKCS1_SHA256,
3682
+ SSL_SIGN_RSA_PKCS1_SHA384,
3683
+ SSL_SIGN_RSA_PKCS1_SHA512,
3684
+ // Table 4.1:
3685
+ // "The curve should be P-256 or P-384"
3686
+ SSL_SIGN_ECDSA_SECP256R1_SHA256,
3687
+ SSL_SIGN_ECDSA_SECP384R1_SHA384,
3688
+ SSL_SIGN_RSA_PSS_RSAE_SHA256,
3689
+ SSL_SIGN_RSA_PSS_RSAE_SHA384,
3690
+ SSL_SIGN_RSA_PSS_RSAE_SHA512,
3691
+ };
3692
+
3693
+ static const char kTLS12Ciphers[] =
3694
+ "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:"
3695
+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:"
3696
+ "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
3697
+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
3698
+
3699
+ static const uint16_t kTLS13Ciphers[] = {
3700
+ SSL_CIPHER_AES_128_GCM_SHA256,
3701
+ SSL_CIPHER_AES_256_GCM_SHA384,
3702
+ };
3703
+ static const bool kTLS13CiphersInGroup[] = {
3704
+ true,
3705
+ false,
3706
+ };
3707
+
3708
+ static int Configure(SSLContext *ctx) {
3709
+ ctx->compliance_policy = ssl_compliance_policy_fips_202609;
3710
+
3711
+ return
3712
+ // Section 3.1:
3713
+ // "Servers that support government-only applications shall be
3714
+ // configured to use TLS 1.2 and should be configured to use TLS 1.3
3715
+ // as well. These servers should not be configured to use TLS 1.1 and
3716
+ // shall not use TLS 1.0, SSL 3.0, or SSL 2.0.
3717
+ SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
3718
+ SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
3719
+ // Sections 3.3.1.1.1 and 3.3.1.1.2 are ambiguous about whether
3720
+ // HMAC-SHA-1 cipher suites are permitted with TLS 1.2. However, later the
3721
+ // Encrypt-then-MAC extension is required for all CBC cipher suites and so
3722
+ // it's easier to drop them.
3723
+ SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
3724
+ ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3725
+ Span(kTLS13CiphersInGroup)) &&
3726
+ SSL_CTX_set1_group_ids_with_flags(ctx, kGroups, kGroupsFlags,
3727
+ std::size(kGroups)) &&
3728
+ SSL_CTX_set_options(ctx, kOptions) &&
3729
+ SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs)) &&
3730
+ SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
3731
+ }
3732
+
3733
+ static int Configure(SSLImpl *ssl) {
3734
+ ssl->config->compliance_policy = ssl_compliance_policy_fips_202609;
3735
+
3736
+ // See `Configure(SSL_CTX)`, above, for reasoning.
3737
+ return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
3738
+ SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
3739
+ SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
3740
+ ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3741
+ Span(kTLS13CiphersInGroup)) &&
3742
+ SSL_set1_group_ids_with_flags(ssl, kGroups, kGroupsFlags,
3743
+ std::size(kGroups)) &&
3744
+ SSL_set_options(ssl, kOptions) &&
3745
+ SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
3746
+ SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
3747
+ }
3748
+
3749
+ } // namespace fips202609
3750
+
3304
3751
  namespace wpa202304 {
3305
3752
 
3306
3753
  // See WPA version 3.1, section 3.5.
@@ -3319,97 +3766,260 @@ static const char kTLS12Ciphers[] =
3319
3766
  "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
3320
3767
  "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
3321
3768
 
3322
- static int Configure(SSL_CTX *ctx) {
3769
+ static const uint16_t kTLS13Ciphers[] = {
3770
+ SSL_CIPHER_AES_256_GCM_SHA384,
3771
+ };
3772
+ static const bool kTLS13CiphersInGroup[] = {
3773
+ false,
3774
+ };
3775
+
3776
+ static int Configure(SSLContext *ctx) {
3323
3777
  ctx->compliance_policy = ssl_compliance_policy_wpa3_192_202304;
3324
3778
 
3325
3779
  return SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
3326
3780
  SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
3327
3781
  SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
3328
- SSL_CTX_set1_group_ids(ctx, kGroups, OPENSSL_ARRAY_SIZE(kGroups)) &&
3782
+ SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
3783
+ ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3784
+ Span(kTLS13CiphersInGroup)) &&
3329
3785
  SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
3330
- OPENSSL_ARRAY_SIZE(kSigAlgs)) &&
3331
- SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs,
3332
- OPENSSL_ARRAY_SIZE(kSigAlgs));
3786
+ std::size(kSigAlgs)) &&
3787
+ SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
3333
3788
  }
3334
3789
 
3335
- static int Configure(SSL *ssl) {
3790
+ static int Configure(SSLImpl *ssl) {
3336
3791
  ssl->config->compliance_policy = ssl_compliance_policy_wpa3_192_202304;
3337
3792
 
3338
3793
  return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
3339
3794
  SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
3340
3795
  SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
3341
- SSL_set1_group_ids(ssl, kGroups, OPENSSL_ARRAY_SIZE(kGroups)) &&
3342
- SSL_set_signing_algorithm_prefs(ssl, kSigAlgs,
3343
- OPENSSL_ARRAY_SIZE(kSigAlgs)) &&
3344
- SSL_set_verify_algorithm_prefs(ssl, kSigAlgs,
3345
- OPENSSL_ARRAY_SIZE(kSigAlgs));
3796
+ ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3797
+ Span(kTLS13CiphersInGroup)) &&
3798
+ SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
3799
+ SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
3800
+ SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
3346
3801
  }
3347
3802
 
3348
3803
  } // namespace wpa202304
3349
3804
 
3350
3805
  namespace cnsa202407 {
3351
3806
 
3352
- static int Configure(SSL_CTX *ctx) {
3807
+ static const uint16_t kTLS13Ciphers[] = {
3808
+ SSL_CIPHER_AES_256_GCM_SHA384,
3809
+ SSL_CIPHER_AES_128_GCM_SHA256,
3810
+ SSL_CIPHER_CHACHA20_POLY1305_SHA256,
3811
+ };
3812
+ static const bool kTLS13CiphersInGroup[] = {
3813
+ false,
3814
+ false,
3815
+ false,
3816
+ };
3817
+
3818
+ static int Configure(SSLContext *ctx) {
3353
3819
  ctx->compliance_policy = ssl_compliance_policy_cnsa_202407;
3354
- return 1;
3820
+ return ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3821
+ Span(kTLS13CiphersInGroup));
3355
3822
  }
3356
3823
 
3357
- static int Configure(SSL *ssl) {
3824
+ static int Configure(SSLImpl *ssl) {
3358
3825
  ssl->config->compliance_policy = ssl_compliance_policy_cnsa_202407;
3359
- return 1;
3826
+ return ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3827
+ Span(kTLS13CiphersInGroup));
3360
3828
  }
3361
3829
 
3362
3830
  } // namespace cnsa202407
3363
3831
 
3832
+ namespace cnsa1_202603 {
3833
+
3834
+ // Approximates CNSA 1.0 (RFC 9151).
3835
+
3836
+ static const uint16_t kGroups[] = {SSL_GROUP_MLKEM1024, SSL_GROUP_SECP384R1};
3837
+
3838
+ // Prefer ML-KEM-1024 if the client supports it.
3839
+ static const uint32_t kOptions = SSL_OP_CIPHER_SERVER_PREFERENCE;
3840
+
3841
+ static const uint16_t kSigAlgs[] = {
3842
+ SSL_SIGN_ECDSA_SECP384R1_SHA384,
3843
+ SSL_SIGN_RSA_PSS_RSAE_SHA384,
3844
+ SSL_SIGN_RSA_PKCS1_SHA384,
3845
+ };
3846
+
3847
+ static const char kTLS12Ciphers[] =
3848
+ "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
3849
+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:"
3850
+ "TLS_RSA_WITH_AES_256_GCM_SHA384";
3851
+
3852
+ static const uint16_t kTLS13Ciphers[] = {
3853
+ SSL_CIPHER_AES_256_GCM_SHA384,
3854
+ };
3855
+ static const bool kTLS13CiphersInGroup[] = {
3856
+ false,
3857
+ };
3858
+
3859
+ static int Configure(SSLContext *ctx) {
3860
+ ctx->compliance_policy = ssl_compliance_policy_cnsa1_202603;
3861
+
3862
+ return SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
3863
+ SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
3864
+ SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
3865
+ ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3866
+ Span(kTLS13CiphersInGroup)) &&
3867
+ SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
3868
+ SSL_CTX_set_options(ctx, kOptions) &&
3869
+ SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
3870
+ std::size(kSigAlgs)) &&
3871
+ SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
3872
+ }
3873
+
3874
+ static int Configure(SSLImpl *ssl) {
3875
+ ssl->config->compliance_policy = ssl_compliance_policy_cnsa1_202603;
3876
+
3877
+ return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
3878
+ SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
3879
+ SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
3880
+ ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3881
+ Span(kTLS13CiphersInGroup)) &&
3882
+ SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
3883
+ SSL_set_options(ssl, kOptions) &&
3884
+ SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
3885
+ SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
3886
+ }
3887
+
3888
+ } // namespace cnsa1_202603
3889
+
3890
+ namespace cnsa2_202603 {
3891
+
3892
+ // Approximates CNSA 2.0 (draft-becker-cnsa2-tls-profile).
3893
+
3894
+ static const uint16_t kGroups[] = {SSL_GROUP_MLKEM1024};
3895
+
3896
+ static const uint16_t kSigAlgs[] = {
3897
+ SSL_SIGN_ECDSA_SECP384R1_SHA384,
3898
+ SSL_SIGN_RSA_PSS_RSAE_SHA384,
3899
+ SSL_SIGN_RSA_PKCS1_SHA384,
3900
+ };
3901
+
3902
+ static const uint16_t kTLS13Ciphers[] = {
3903
+ SSL_CIPHER_AES_256_GCM_SHA384,
3904
+ };
3905
+ static const bool kTLS13CiphersInGroup[] = {
3906
+ false,
3907
+ };
3908
+
3909
+ static int Configure(SSLContext *ctx) {
3910
+ ctx->compliance_policy = ssl_compliance_policy_cnsa2_202603;
3911
+
3912
+ return SSL_CTX_set_min_proto_version(ctx, TLS1_3_VERSION) &&
3913
+ SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
3914
+ ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3915
+ Span(kTLS13CiphersInGroup)) &&
3916
+ SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
3917
+ SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
3918
+ std::size(kSigAlgs)) &&
3919
+ SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
3920
+ }
3921
+
3922
+ static int Configure(SSLImpl *ssl) {
3923
+ ssl->config->compliance_policy = ssl_compliance_policy_cnsa2_202603;
3924
+
3925
+ return SSL_set_min_proto_version(ssl, TLS1_3_VERSION) &&
3926
+ SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
3927
+ ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
3928
+ Span(kTLS13CiphersInGroup)) &&
3929
+ SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
3930
+ SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
3931
+ SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
3932
+ }
3933
+
3934
+ } // namespace cnsa2_202603
3935
+
3364
3936
  int SSL_CTX_set_compliance_policy(SSL_CTX *ctx,
3365
3937
  enum ssl_compliance_policy_t policy) {
3938
+ auto *ctx_impl = FromOpaque(ctx);
3366
3939
  switch (policy) {
3367
3940
  case ssl_compliance_policy_fips_202205:
3368
- return fips202205::Configure(ctx);
3941
+ return fips202205::Configure(ctx_impl);
3942
+ case ssl_compliance_policy_fips_202609:
3943
+ return fips202609::Configure(ctx_impl);
3369
3944
  case ssl_compliance_policy_wpa3_192_202304:
3370
- return wpa202304::Configure(ctx);
3945
+ return wpa202304::Configure(ctx_impl);
3371
3946
  case ssl_compliance_policy_cnsa_202407:
3372
- return cnsa202407::Configure(ctx);
3947
+ return cnsa202407::Configure(ctx_impl);
3948
+ case ssl_compliance_policy_cnsa1_202603:
3949
+ return cnsa1_202603::Configure(ctx_impl);
3950
+ case ssl_compliance_policy_cnsa2_202603:
3951
+ return cnsa2_202603::Configure(ctx_impl);
3373
3952
  default:
3374
3953
  return 0;
3375
3954
  }
3376
3955
  }
3377
3956
 
3378
3957
  enum ssl_compliance_policy_t SSL_CTX_get_compliance_policy(const SSL_CTX *ctx) {
3379
- return ctx->compliance_policy;
3958
+ return FromOpaque(ctx)->compliance_policy;
3380
3959
  }
3381
3960
 
3382
3961
  int SSL_set_compliance_policy(SSL *ssl, enum ssl_compliance_policy_t policy) {
3962
+ auto *ssl_impl = FromOpaque(ssl);
3383
3963
  switch (policy) {
3384
3964
  case ssl_compliance_policy_fips_202205:
3385
- return fips202205::Configure(ssl);
3965
+ return fips202205::Configure(ssl_impl);
3966
+ case ssl_compliance_policy_fips_202609:
3967
+ return fips202609::Configure(ssl_impl);
3386
3968
  case ssl_compliance_policy_wpa3_192_202304:
3387
- return wpa202304::Configure(ssl);
3969
+ return wpa202304::Configure(ssl_impl);
3388
3970
  case ssl_compliance_policy_cnsa_202407:
3389
- return cnsa202407::Configure(ssl);
3971
+ return cnsa202407::Configure(ssl_impl);
3972
+ case ssl_compliance_policy_cnsa1_202603:
3973
+ return cnsa1_202603::Configure(ssl_impl);
3974
+ case ssl_compliance_policy_cnsa2_202603:
3975
+ return cnsa2_202603::Configure(ssl_impl);
3390
3976
  default:
3391
3977
  return 0;
3392
3978
  }
3393
3979
  }
3394
3980
 
3395
3981
  enum ssl_compliance_policy_t SSL_get_compliance_policy(const SSL *ssl) {
3396
- return ssl->config->compliance_policy;
3982
+ return FromOpaque(ssl)->config->compliance_policy;
3397
3983
  }
3398
3984
 
3399
3985
  int SSL_peer_matched_trust_anchor(const SSL *ssl) {
3400
- return ssl->s3->hs != nullptr && ssl->s3->hs->peer_matched_trust_anchor;
3986
+ return FromOpaque(ssl)->s3->hs != nullptr &&
3987
+ FromOpaque(ssl)->s3->hs->peer_matched_trust_anchor;
3401
3988
  }
3402
3989
 
3403
3990
  void SSL_get0_peer_available_trust_anchors(const SSL *ssl, const uint8_t **out,
3404
3991
  size_t *out_len) {
3405
3992
  Span<const uint8_t> ret;
3406
- if (SSL_HANDSHAKE *hs = ssl->s3->hs.get(); hs != nullptr) {
3993
+ if (SSL_HANDSHAKE *hs = FromOpaque(ssl)->s3->hs.get(); hs != nullptr) {
3407
3994
  ret = hs->peer_available_trust_anchors;
3408
3995
  }
3409
3996
  *out = ret.data();
3410
3997
  *out_len = ret.size();
3411
3998
  }
3412
3999
 
4000
+ int SSL_CTX_set1_available_trust_anchors(SSL_CTX *ctx, const uint8_t *ids,
4001
+ size_t ids_len) {
4002
+ auto span = Span(ids, ids_len);
4003
+ if (span.empty() || !ssl_is_valid_trust_anchor_list(span)) {
4004
+ OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TRUST_ANCHOR_LIST);
4005
+ return 0;
4006
+ }
4007
+ return FromOpaque(ctx)->cert->available_trust_anchors.CopyFrom(span);
4008
+ }
4009
+
4010
+ int SSL_set1_available_trust_anchors(SSL *ssl, const uint8_t *ids,
4011
+ size_t ids_len) {
4012
+ if (!FromOpaque(ssl)->config) {
4013
+ return 0;
4014
+ }
4015
+ auto span = Span(ids, ids_len);
4016
+ if (span.empty() || !ssl_is_valid_trust_anchor_list(span)) {
4017
+ OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TRUST_ANCHOR_LIST);
4018
+ return 0;
4019
+ }
4020
+ return FromOpaque(ssl)->config->cert->available_trust_anchors.CopyFrom(span);
4021
+ }
4022
+
3413
4023
  int SSL_CTX_set1_requested_trust_anchors(SSL_CTX *ctx, const uint8_t *ids,
3414
4024
  size_t ids_len) {
3415
4025
  auto span = Span(ids, ids_len);
@@ -3421,13 +4031,13 @@ int SSL_CTX_set1_requested_trust_anchors(SSL_CTX *ctx, const uint8_t *ids,
3421
4031
  if (!copy.CopyFrom(span)) {
3422
4032
  return 0;
3423
4033
  }
3424
- ctx->requested_trust_anchors = std::move(copy);
4034
+ FromOpaque(ctx)->requested_trust_anchors = std::move(copy);
3425
4035
  return 1;
3426
4036
  }
3427
4037
 
3428
4038
  int SSL_set1_requested_trust_anchors(SSL *ssl, const uint8_t *ids,
3429
4039
  size_t ids_len) {
3430
- if (!ssl->config) {
4040
+ if (!FromOpaque(ssl)->config) {
3431
4041
  return 0;
3432
4042
  }
3433
4043
  auto span = Span(ids, ids_len);
@@ -3439,6 +4049,105 @@ int SSL_set1_requested_trust_anchors(SSL *ssl, const uint8_t *ids,
3439
4049
  if (!copy.CopyFrom(span)) {
3440
4050
  return 0;
3441
4051
  }
3442
- ssl->config->requested_trust_anchors = std::move(copy);
4052
+ FromOpaque(ssl)->config->requested_trust_anchors = std::move(copy);
3443
4053
  return 1;
3444
4054
  }
4055
+
4056
+ int SSL_CTX_get_security_level(const SSL_CTX *ctx) { return 0; }
4057
+
4058
+ static bool is_valid_cert_types_list(Span<const uint8_t> list) {
4059
+ if (list.empty() || list.size() > kNumCertTypes) {
4060
+ return false;
4061
+ }
4062
+ for (size_t i = 0u; i < list.size(); ++i) {
4063
+ // Check that each value is a recognized cert type.
4064
+ if (std::find(std::begin(kAllCertTypes), std::end(kAllCertTypes),
4065
+ list[i]) == std::end(kAllCertTypes)) {
4066
+ return false;
4067
+ }
4068
+ // Reject duplicates.
4069
+ for (size_t j = 0u; j < i; ++j) {
4070
+ if (list[i] == list[j]) {
4071
+ return false;
4072
+ }
4073
+ }
4074
+ }
4075
+ return true;
4076
+ }
4077
+
4078
+ static bool set1_cert_types(InplaceVector<uint8_t, kNumCertTypes> *out,
4079
+ Span<const uint8_t> values) {
4080
+ if (!is_valid_cert_types_list(values)) {
4081
+ OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_CERT_TYPES_LIST);
4082
+ return false;
4083
+ }
4084
+ out->CopyFrom(values);
4085
+ return true;
4086
+ }
4087
+
4088
+ int SSL_CTX_set1_accepted_peer_cert_types(SSL_CTX *ctx, const uint8_t *values,
4089
+ size_t num_values) {
4090
+ return set1_cert_types(&FromOpaque(ctx)->accepted_peer_cert_types,
4091
+ Span(values, num_values));
4092
+ }
4093
+
4094
+ int SSL_set1_accepted_peer_cert_types(SSL *ssl, const uint8_t *values,
4095
+ size_t num_values) {
4096
+ if (!FromOpaque(ssl)->config) {
4097
+ return 0;
4098
+ }
4099
+ return set1_cert_types(&FromOpaque(ssl)->config->accepted_peer_cert_types,
4100
+ Span(values, num_values));
4101
+ }
4102
+
4103
+ int SSL_CTX_set1_available_client_cert_types(SSL_CTX *ctx,
4104
+ const uint8_t *values,
4105
+ size_t num_values) {
4106
+ return set1_cert_types(&FromOpaque(ctx)->available_client_cert_types,
4107
+ Span(values, num_values));
4108
+ }
4109
+
4110
+ int SSL_set1_available_client_cert_types(SSL *ssl, const uint8_t *values,
4111
+ size_t num_values) {
4112
+ if (!FromOpaque(ssl)->config) {
4113
+ return 0;
4114
+ }
4115
+ return set1_cert_types(&FromOpaque(ssl)->config->available_client_cert_types,
4116
+ Span(values, num_values));
4117
+ }
4118
+
4119
+ int SSL_get_peer_cert_type(const SSL *ssl) {
4120
+ if (const SSLSession *session = ssl_get_session(FromOpaque(ssl));
4121
+ session != nullptr) {
4122
+ return session->peer_cert_type;
4123
+ }
4124
+ return kDefaultCertType;
4125
+ }
4126
+
4127
+ EVP_PKEY *SSL_get0_peer_rpk(const SSL *ssl) {
4128
+ if (const SSLSession *session = ssl_get_session(FromOpaque(ssl));
4129
+ session != nullptr) {
4130
+ return session->peer_raw_public_key.get();
4131
+ }
4132
+ return nullptr;
4133
+ }
4134
+
4135
+ void SSL_set_server_padding_request(SSL *ssl, uint16_t num_bytes) {
4136
+ if (!FromOpaque(ssl)->config) {
4137
+ return;
4138
+ }
4139
+
4140
+ FromOpaque(ssl)->config->server_padding_request = num_bytes;
4141
+ }
4142
+
4143
+ void SSL_set_server_padding_enabled(SSL *ssl, int enabled) {
4144
+ if (!FromOpaque(ssl)->config) {
4145
+ return;
4146
+ }
4147
+
4148
+ FromOpaque(ssl)->config->server_padding_enabled = enabled;
4149
+ }
4150
+
4151
+ int SSL_server_sent_requested_padding(const SSL *ssl) {
4152
+ return FromOpaque(ssl)->s3->server_sent_requested_padding;
4153
+ }