grpc 1.30.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (1758) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -0
  3. data/Makefile +20074 -0
  4. data/etc/roots.pem +4644 -0
  5. data/include/grpc/byte_buffer.h +27 -0
  6. data/include/grpc/byte_buffer_reader.h +26 -0
  7. data/include/grpc/census.h +40 -0
  8. data/include/grpc/compression.h +75 -0
  9. data/include/grpc/fork.h +26 -0
  10. data/include/grpc/grpc.h +540 -0
  11. data/include/grpc/grpc_cronet.h +38 -0
  12. data/include/grpc/grpc_posix.h +59 -0
  13. data/include/grpc/grpc_security.h +1019 -0
  14. data/include/grpc/grpc_security_constants.h +146 -0
  15. data/include/grpc/impl/codegen/atm.h +95 -0
  16. data/include/grpc/impl/codegen/atm_gcc_atomic.h +91 -0
  17. data/include/grpc/impl/codegen/atm_gcc_sync.h +85 -0
  18. data/include/grpc/impl/codegen/atm_windows.h +128 -0
  19. data/include/grpc/impl/codegen/byte_buffer.h +101 -0
  20. data/include/grpc/impl/codegen/byte_buffer_reader.h +42 -0
  21. data/include/grpc/impl/codegen/compression_types.h +108 -0
  22. data/include/grpc/impl/codegen/connectivity_state.h +44 -0
  23. data/include/grpc/impl/codegen/fork.h +48 -0
  24. data/include/grpc/impl/codegen/gpr_slice.h +69 -0
  25. data/include/grpc/impl/codegen/gpr_types.h +59 -0
  26. data/include/grpc/impl/codegen/grpc_types.h +785 -0
  27. data/include/grpc/impl/codegen/log.h +112 -0
  28. data/include/grpc/impl/codegen/port_platform.h +720 -0
  29. data/include/grpc/impl/codegen/propagation_bits.h +52 -0
  30. data/include/grpc/impl/codegen/slice.h +127 -0
  31. data/include/grpc/impl/codegen/status.h +154 -0
  32. data/include/grpc/impl/codegen/sync.h +65 -0
  33. data/include/grpc/impl/codegen/sync_abseil.h +36 -0
  34. data/include/grpc/impl/codegen/sync_custom.h +38 -0
  35. data/include/grpc/impl/codegen/sync_generic.h +48 -0
  36. data/include/grpc/impl/codegen/sync_posix.h +52 -0
  37. data/include/grpc/impl/codegen/sync_windows.h +36 -0
  38. data/include/grpc/load_reporting.h +48 -0
  39. data/include/grpc/module.modulemap +64 -0
  40. data/include/grpc/slice.h +172 -0
  41. data/include/grpc/slice_buffer.h +84 -0
  42. data/include/grpc/status.h +26 -0
  43. data/include/grpc/support/alloc.h +52 -0
  44. data/include/grpc/support/atm.h +26 -0
  45. data/include/grpc/support/atm_gcc_atomic.h +26 -0
  46. data/include/grpc/support/atm_gcc_sync.h +26 -0
  47. data/include/grpc/support/atm_windows.h +26 -0
  48. data/include/grpc/support/cpu.h +44 -0
  49. data/include/grpc/support/log.h +26 -0
  50. data/include/grpc/support/log_windows.h +38 -0
  51. data/include/grpc/support/port_platform.h +24 -0
  52. data/include/grpc/support/string_util.h +51 -0
  53. data/include/grpc/support/sync.h +282 -0
  54. data/include/grpc/support/sync_abseil.h +26 -0
  55. data/include/grpc/support/sync_custom.h +26 -0
  56. data/include/grpc/support/sync_generic.h +26 -0
  57. data/include/grpc/support/sync_posix.h +26 -0
  58. data/include/grpc/support/sync_windows.h +26 -0
  59. data/include/grpc/support/thd_id.h +44 -0
  60. data/include/grpc/support/time.h +92 -0
  61. data/include/grpc/support/workaround_list.h +31 -0
  62. data/src/core/ext/filters/census/grpc_context.cc +38 -0
  63. data/src/core/ext/filters/client_channel/backend_metric.cc +81 -0
  64. data/src/core/ext/filters/client_channel/backend_metric.h +36 -0
  65. data/src/core/ext/filters/client_channel/backup_poller.cc +181 -0
  66. data/src/core/ext/filters/client_channel/backup_poller.h +41 -0
  67. data/src/core/ext/filters/client_channel/channel_connectivity.cc +264 -0
  68. data/src/core/ext/filters/client_channel/client_channel.cc +4059 -0
  69. data/src/core/ext/filters/client_channel/client_channel.h +82 -0
  70. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +95 -0
  71. data/src/core/ext/filters/client_channel/client_channel_channelz.h +78 -0
  72. data/src/core/ext/filters/client_channel/client_channel_factory.cc +55 -0
  73. data/src/core/ext/filters/client_channel/client_channel_factory.h +47 -0
  74. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +70 -0
  75. data/src/core/ext/filters/client_channel/connector.h +79 -0
  76. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +179 -0
  77. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
  78. data/src/core/ext/filters/client_channel/health/health_check_client.cc +606 -0
  79. data/src/core/ext/filters/client_channel/health/health_check_client.h +175 -0
  80. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +389 -0
  81. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +34 -0
  82. data/src/core/ext/filters/client_channel/http_proxy.cc +216 -0
  83. data/src/core/ext/filters/client_channel/http_proxy.h +28 -0
  84. data/src/core/ext/filters/client_channel/lb_policy.cc +138 -0
  85. data/src/core/ext/filters/client_channel/lb_policy.h +421 -0
  86. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +83 -0
  87. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +99 -0
  88. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +297 -0
  89. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +83 -0
  90. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +157 -0
  91. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +29 -0
  92. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1754 -0
  93. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +43 -0
  94. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
  95. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
  96. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +45 -0
  97. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +121 -0
  98. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +91 -0
  99. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +75 -0
  100. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +193 -0
  101. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +74 -0
  102. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +509 -0
  103. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +871 -0
  104. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +504 -0
  105. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +448 -0
  106. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +734 -0
  107. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +417 -0
  108. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +938 -0
  109. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +528 -0
  110. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +32 -0
  111. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +834 -0
  112. data/src/core/ext/filters/client_channel/lb_policy_factory.h +47 -0
  113. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +182 -0
  114. data/src/core/ext/filters/client_channel/lb_policy_registry.h +65 -0
  115. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
  116. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +57 -0
  117. data/src/core/ext/filters/client_channel/parse_address.cc +238 -0
  118. data/src/core/ext/filters/client_channel/parse_address.h +53 -0
  119. data/src/core/ext/filters/client_channel/proxy_mapper.h +54 -0
  120. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +89 -0
  121. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +50 -0
  122. data/src/core/ext/filters/client_channel/resolver.cc +85 -0
  123. data/src/core/ext/filters/client_channel/resolver.h +144 -0
  124. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +535 -0
  125. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +484 -0
  126. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +104 -0
  127. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +177 -0
  128. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +107 -0
  129. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +897 -0
  130. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +819 -0
  131. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +97 -0
  132. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +68 -0
  133. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +38 -0
  134. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +29 -0
  135. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +34 -0
  136. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
  137. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +29 -0
  138. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +318 -0
  139. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +383 -0
  140. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +93 -0
  141. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +188 -0
  142. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +184 -0
  143. data/src/core/ext/filters/client_channel/resolver_factory.h +73 -0
  144. data/src/core/ext/filters/client_channel/resolver_registry.cc +197 -0
  145. data/src/core/ext/filters/client_channel/resolver_registry.h +89 -0
  146. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +443 -0
  147. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +127 -0
  148. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +348 -0
  149. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +123 -0
  150. data/src/core/ext/filters/client_channel/retry_throttle.cc +191 -0
  151. data/src/core/ext/filters/client_channel/retry_throttle.h +77 -0
  152. data/src/core/ext/filters/client_channel/server_address.cc +48 -0
  153. data/src/core/ext/filters/client_channel/server_address.h +90 -0
  154. data/src/core/ext/filters/client_channel/service_config.cc +221 -0
  155. data/src/core/ext/filters/client_channel/service_config.h +123 -0
  156. data/src/core/ext/filters/client_channel/service_config_call_data.h +68 -0
  157. data/src/core/ext/filters/client_channel/service_config_parser.cc +87 -0
  158. data/src/core/ext/filters/client_channel/service_config_parser.h +89 -0
  159. data/src/core/ext/filters/client_channel/subchannel.cc +1127 -0
  160. data/src/core/ext/filters/client_channel/subchannel.h +427 -0
  161. data/src/core/ext/filters/client_channel/subchannel_interface.h +94 -0
  162. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
  163. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +91 -0
  164. data/src/core/ext/filters/client_channel/xds/xds_api.cc +1906 -0
  165. data/src/core/ext/filters/client_channel/xds/xds_api.h +280 -0
  166. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +342 -0
  167. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +88 -0
  168. data/src/core/ext/filters/client_channel/xds/xds_channel.h +46 -0
  169. data/src/core/ext/filters/client_channel/xds/xds_channel_args.h +26 -0
  170. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +106 -0
  171. data/src/core/ext/filters/client_channel/xds/xds_client.cc +2367 -0
  172. data/src/core/ext/filters/client_channel/xds/xds_client.h +309 -0
  173. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +115 -0
  174. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +211 -0
  175. data/src/core/ext/filters/client_idle/client_idle_filter.cc +440 -0
  176. data/src/core/ext/filters/deadline/deadline_filter.cc +386 -0
  177. data/src/core/ext/filters/deadline/deadline_filter.h +90 -0
  178. data/src/core/ext/filters/http/client/http_client_filter.cc +596 -0
  179. data/src/core/ext/filters/http/client/http_client_filter.h +31 -0
  180. data/src/core/ext/filters/http/client_authority_filter.cc +159 -0
  181. data/src/core/ext/filters/http/client_authority_filter.h +34 -0
  182. data/src/core/ext/filters/http/http_filters_plugin.cc +104 -0
  183. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +546 -0
  184. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +53 -0
  185. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +358 -0
  186. data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +29 -0
  187. data/src/core/ext/filters/http/server/http_server_filter.cc +528 -0
  188. data/src/core/ext/filters/http/server/http_server_filter.h +29 -0
  189. data/src/core/ext/filters/max_age/max_age_filter.cc +556 -0
  190. data/src/core/ext/filters/max_age/max_age_filter.h +26 -0
  191. data/src/core/ext/filters/message_size/message_size_filter.cc +423 -0
  192. data/src/core/ext/filters/message_size/message_size_filter.h +59 -0
  193. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +210 -0
  194. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +27 -0
  195. data/src/core/ext/filters/workarounds/workaround_utils.cc +53 -0
  196. data/src/core/ext/filters/workarounds/workaround_utils.h +39 -0
  197. data/src/core/ext/transport/chttp2/alpn/alpn.cc +44 -0
  198. data/src/core/ext/transport/chttp2/alpn/alpn.h +36 -0
  199. data/src/core/ext/transport/chttp2/client/authority.cc +42 -0
  200. data/src/core/ext/transport/chttp2/client/authority.h +36 -0
  201. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +206 -0
  202. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +58 -0
  203. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +112 -0
  204. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +79 -0
  205. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +225 -0
  206. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +451 -0
  207. data/src/core/ext/transport/chttp2/server/chttp2_server.h +33 -0
  208. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +45 -0
  209. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +75 -0
  210. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +86 -0
  211. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +250 -0
  212. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +56 -0
  213. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +230 -0
  214. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +42 -0
  215. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +37 -0
  216. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3346 -0
  217. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +52 -0
  218. data/src/core/ext/transport/chttp2/transport/context_list.cc +69 -0
  219. data/src/core/ext/transport/chttp2/transport/context_list.h +53 -0
  220. data/src/core/ext/transport/chttp2/transport/flow_control.cc +408 -0
  221. data/src/core/ext/transport/chttp2/transport/flow_control.h +474 -0
  222. data/src/core/ext/transport/chttp2/transport/frame.h +47 -0
  223. data/src/core/ext/transport/chttp2/transport/frame_data.cc +307 -0
  224. data/src/core/ext/transport/chttp2/transport/frame_data.h +82 -0
  225. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +187 -0
  226. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +62 -0
  227. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +133 -0
  228. data/src/core/ext/transport/chttp2/transport/frame_ping.h +44 -0
  229. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +122 -0
  230. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +50 -0
  231. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +242 -0
  232. data/src/core/ext/transport/chttp2/transport/frame_settings.h +60 -0
  233. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +123 -0
  234. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +44 -0
  235. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +900 -0
  236. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +107 -0
  237. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1761 -0
  238. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +117 -0
  239. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +246 -0
  240. data/src/core/ext/transport/chttp2/transport/hpack_table.h +148 -0
  241. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +62 -0
  242. data/src/core/ext/transport/chttp2/transport/http2_settings.h +61 -0
  243. data/src/core/ext/transport/chttp2/transport/huffsyms.cc +92 -0
  244. data/src/core/ext/transport/chttp2/transport/huffsyms.h +32 -0
  245. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +66 -0
  246. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +58 -0
  247. data/src/core/ext/transport/chttp2/transport/internal.h +864 -0
  248. data/src/core/ext/transport/chttp2/transport/parsing.cc +803 -0
  249. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +216 -0
  250. data/src/core/ext/transport/chttp2/transport/stream_map.cc +177 -0
  251. data/src/core/ext/transport/chttp2/transport/stream_map.h +67 -0
  252. data/src/core/ext/transport/chttp2/transport/varint.cc +56 -0
  253. data/src/core/ext/transport/chttp2/transport/varint.h +60 -0
  254. data/src/core/ext/transport/chttp2/transport/writing.cc +706 -0
  255. data/src/core/ext/transport/inproc/inproc_plugin.cc +28 -0
  256. data/src/core/ext/transport/inproc/inproc_transport.cc +1296 -0
  257. data/src/core/ext/transport/inproc/inproc_transport.h +35 -0
  258. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +17 -0
  259. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +30 -0
  260. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +27 -0
  261. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +54 -0
  262. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +21 -0
  263. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +35 -0
  264. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +114 -0
  265. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +418 -0
  266. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +72 -0
  267. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +197 -0
  268. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +105 -0
  269. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +378 -0
  270. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +28 -0
  271. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +53 -0
  272. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +403 -0
  273. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +1447 -0
  274. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +74 -0
  275. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +218 -0
  276. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +35 -0
  277. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +69 -0
  278. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +55 -0
  279. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +305 -0
  280. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +112 -0
  281. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +328 -0
  282. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.c +35 -0
  283. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +78 -0
  284. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +313 -0
  285. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +897 -0
  286. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +96 -0
  287. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +322 -0
  288. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +34 -0
  289. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +72 -0
  290. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +197 -0
  291. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +642 -0
  292. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +172 -0
  293. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +673 -0
  294. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +36 -0
  295. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +80 -0
  296. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +152 -0
  297. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +518 -0
  298. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.c +34 -0
  299. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +89 -0
  300. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +129 -0
  301. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +392 -0
  302. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +31 -0
  303. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +53 -0
  304. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +92 -0
  305. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +240 -0
  306. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +18 -0
  307. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +33 -0
  308. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +91 -0
  309. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +266 -0
  310. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +112 -0
  311. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +324 -0
  312. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +31 -0
  313. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +53 -0
  314. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +109 -0
  315. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +399 -0
  316. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +18 -0
  317. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +33 -0
  318. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +145 -0
  319. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +527 -0
  320. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +43 -0
  321. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +112 -0
  322. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.c +30 -0
  323. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +53 -0
  324. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +63 -0
  325. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +199 -0
  326. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +18 -0
  327. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +33 -0
  328. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +815 -0
  329. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +3032 -0
  330. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +59 -0
  331. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +134 -0
  332. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.c +28 -0
  333. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +53 -0
  334. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +228 -0
  335. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +725 -0
  336. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +316 -0
  337. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +1132 -0
  338. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +33 -0
  339. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +65 -0
  340. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +51 -0
  341. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +125 -0
  342. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +24 -0
  343. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +50 -0
  344. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +54 -0
  345. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +134 -0
  346. data/src/core/ext/upb-generated/envoy/type/http.upb.c +17 -0
  347. data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
  348. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +63 -0
  349. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +144 -0
  350. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +53 -0
  351. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +133 -0
  352. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +88 -0
  353. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +258 -0
  354. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +39 -0
  355. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +87 -0
  356. data/src/core/ext/upb-generated/envoy/type/range.upb.c +50 -0
  357. data/src/core/ext/upb-generated/envoy/type/range.upb.h +112 -0
  358. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +29 -0
  359. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +62 -0
  360. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +89 -0
  361. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +249 -0
  362. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +17 -0
  363. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +30 -0
  364. data/src/core/ext/upb-generated/google/api/annotations.upb.c +18 -0
  365. data/src/core/ext/upb-generated/google/api/annotations.upb.h +30 -0
  366. data/src/core/ext/upb-generated/google/api/http.upb.c +66 -0
  367. data/src/core/ext/upb-generated/google/api/http.upb.h +190 -0
  368. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +27 -0
  369. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +58 -0
  370. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +486 -0
  371. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +1696 -0
  372. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +27 -0
  373. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +58 -0
  374. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +22 -0
  375. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +50 -0
  376. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +79 -0
  377. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +215 -0
  378. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +27 -0
  379. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +58 -0
  380. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +106 -0
  381. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +238 -0
  382. data/src/core/ext/upb-generated/google/rpc/status.upb.c +33 -0
  383. data/src/core/ext/upb-generated/google/rpc/status.upb.h +74 -0
  384. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +49 -0
  385. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +126 -0
  386. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +212 -0
  387. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +693 -0
  388. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +42 -0
  389. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +109 -0
  390. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +36 -0
  391. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +84 -0
  392. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +141 -0
  393. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +393 -0
  394. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +48 -0
  395. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +104 -0
  396. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +17 -0
  397. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +30 -0
  398. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +28 -0
  399. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +65 -0
  400. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +58 -0
  401. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +144 -0
  402. data/src/core/ext/upb-generated/validate/validate.upb.c +448 -0
  403. data/src/core/ext/upb-generated/validate/validate.upb.h +2073 -0
  404. data/src/core/lib/avl/avl.cc +306 -0
  405. data/src/core/lib/avl/avl.h +94 -0
  406. data/src/core/lib/backoff/backoff.cc +78 -0
  407. data/src/core/lib/backoff/backoff.h +89 -0
  408. data/src/core/lib/channel/channel_args.cc +380 -0
  409. data/src/core/lib/channel/channel_args.h +135 -0
  410. data/src/core/lib/channel/channel_stack.cc +252 -0
  411. data/src/core/lib/channel/channel_stack.h +304 -0
  412. data/src/core/lib/channel/channel_stack_builder.cc +323 -0
  413. data/src/core/lib/channel/channel_stack_builder.h +166 -0
  414. data/src/core/lib/channel/channel_trace.cc +194 -0
  415. data/src/core/lib/channel/channel_trace.h +134 -0
  416. data/src/core/lib/channel/channelz.cc +543 -0
  417. data/src/core/lib/channel/channelz.h +334 -0
  418. data/src/core/lib/channel/channelz_registry.cc +267 -0
  419. data/src/core/lib/channel/channelz_registry.h +97 -0
  420. data/src/core/lib/channel/connected_channel.cc +246 -0
  421. data/src/core/lib/channel/connected_channel.h +34 -0
  422. data/src/core/lib/channel/context.h +49 -0
  423. data/src/core/lib/channel/handshaker.cc +262 -0
  424. data/src/core/lib/channel/handshaker.h +179 -0
  425. data/src/core/lib/channel/handshaker_factory.h +42 -0
  426. data/src/core/lib/channel/handshaker_registry.cc +105 -0
  427. data/src/core/lib/channel/handshaker_registry.h +54 -0
  428. data/src/core/lib/channel/status_util.cc +99 -0
  429. data/src/core/lib/channel/status_util.h +58 -0
  430. data/src/core/lib/compression/algorithm_metadata.h +61 -0
  431. data/src/core/lib/compression/compression.cc +179 -0
  432. data/src/core/lib/compression/compression_args.cc +134 -0
  433. data/src/core/lib/compression/compression_args.h +56 -0
  434. data/src/core/lib/compression/compression_internal.cc +280 -0
  435. data/src/core/lib/compression/compression_internal.h +96 -0
  436. data/src/core/lib/compression/message_compress.cc +192 -0
  437. data/src/core/lib/compression/message_compress.h +40 -0
  438. data/src/core/lib/compression/stream_compression.cc +80 -0
  439. data/src/core/lib/compression/stream_compression.h +116 -0
  440. data/src/core/lib/compression/stream_compression_gzip.cc +230 -0
  441. data/src/core/lib/compression/stream_compression_gzip.h +28 -0
  442. data/src/core/lib/compression/stream_compression_identity.cc +92 -0
  443. data/src/core/lib/compression/stream_compression_identity.h +29 -0
  444. data/src/core/lib/debug/stats.cc +172 -0
  445. data/src/core/lib/debug/stats.h +70 -0
  446. data/src/core/lib/debug/stats_data.cc +687 -0
  447. data/src/core/lib/debug/stats_data.h +555 -0
  448. data/src/core/lib/debug/trace.cc +154 -0
  449. data/src/core/lib/debug/trace.h +131 -0
  450. data/src/core/lib/gpr/alloc.cc +74 -0
  451. data/src/core/lib/gpr/alloc.h +28 -0
  452. data/src/core/lib/gpr/arena.h +47 -0
  453. data/src/core/lib/gpr/atm.cc +35 -0
  454. data/src/core/lib/gpr/cpu_iphone.cc +36 -0
  455. data/src/core/lib/gpr/cpu_linux.cc +82 -0
  456. data/src/core/lib/gpr/cpu_posix.cc +83 -0
  457. data/src/core/lib/gpr/cpu_windows.cc +33 -0
  458. data/src/core/lib/gpr/env.h +40 -0
  459. data/src/core/lib/gpr/env_linux.cc +76 -0
  460. data/src/core/lib/gpr/env_posix.cc +47 -0
  461. data/src/core/lib/gpr/env_windows.cc +74 -0
  462. data/src/core/lib/gpr/log.cc +98 -0
  463. data/src/core/lib/gpr/log_android.cc +76 -0
  464. data/src/core/lib/gpr/log_linux.cc +97 -0
  465. data/src/core/lib/gpr/log_posix.cc +95 -0
  466. data/src/core/lib/gpr/log_windows.cc +102 -0
  467. data/src/core/lib/gpr/murmur_hash.cc +80 -0
  468. data/src/core/lib/gpr/murmur_hash.h +29 -0
  469. data/src/core/lib/gpr/spinlock.h +45 -0
  470. data/src/core/lib/gpr/string.cc +341 -0
  471. data/src/core/lib/gpr/string.h +111 -0
  472. data/src/core/lib/gpr/string_posix.cc +72 -0
  473. data/src/core/lib/gpr/string_util_windows.cc +82 -0
  474. data/src/core/lib/gpr/string_windows.cc +69 -0
  475. data/src/core/lib/gpr/string_windows.h +32 -0
  476. data/src/core/lib/gpr/sync.cc +124 -0
  477. data/src/core/lib/gpr/sync_abseil.cc +116 -0
  478. data/src/core/lib/gpr/sync_posix.cc +176 -0
  479. data/src/core/lib/gpr/sync_windows.cc +120 -0
  480. data/src/core/lib/gpr/time.cc +263 -0
  481. data/src/core/lib/gpr/time_posix.cc +186 -0
  482. data/src/core/lib/gpr/time_precise.cc +165 -0
  483. data/src/core/lib/gpr/time_precise.h +66 -0
  484. data/src/core/lib/gpr/time_windows.cc +98 -0
  485. data/src/core/lib/gpr/tls.h +68 -0
  486. data/src/core/lib/gpr/tls_gcc.h +52 -0
  487. data/src/core/lib/gpr/tls_msvc.h +52 -0
  488. data/src/core/lib/gpr/tls_pthread.cc +30 -0
  489. data/src/core/lib/gpr/tls_pthread.h +56 -0
  490. data/src/core/lib/gpr/tmpfile.h +32 -0
  491. data/src/core/lib/gpr/tmpfile_msys.cc +58 -0
  492. data/src/core/lib/gpr/tmpfile_posix.cc +70 -0
  493. data/src/core/lib/gpr/tmpfile_windows.cc +69 -0
  494. data/src/core/lib/gpr/useful.h +65 -0
  495. data/src/core/lib/gpr/wrap_memcpy.cc +42 -0
  496. data/src/core/lib/gprpp/arena.cc +103 -0
  497. data/src/core/lib/gprpp/arena.h +120 -0
  498. data/src/core/lib/gprpp/atomic.h +104 -0
  499. data/src/core/lib/gprpp/debug_location.h +53 -0
  500. data/src/core/lib/gprpp/fork.cc +242 -0
  501. data/src/core/lib/gprpp/fork.h +103 -0
  502. data/src/core/lib/gprpp/global_config.h +96 -0
  503. data/src/core/lib/gprpp/global_config_custom.h +29 -0
  504. data/src/core/lib/gprpp/global_config_env.cc +135 -0
  505. data/src/core/lib/gprpp/global_config_env.h +131 -0
  506. data/src/core/lib/gprpp/global_config_generic.h +44 -0
  507. data/src/core/lib/gprpp/host_port.cc +112 -0
  508. data/src/core/lib/gprpp/host_port.h +56 -0
  509. data/src/core/lib/gprpp/manual_constructor.h +213 -0
  510. data/src/core/lib/gprpp/map.h +53 -0
  511. data/src/core/lib/gprpp/memory.h +51 -0
  512. data/src/core/lib/gprpp/mpscq.cc +108 -0
  513. data/src/core/lib/gprpp/mpscq.h +98 -0
  514. data/src/core/lib/gprpp/orphanable.h +129 -0
  515. data/src/core/lib/gprpp/ref_counted.h +312 -0
  516. data/src/core/lib/gprpp/ref_counted_ptr.h +192 -0
  517. data/src/core/lib/gprpp/sync.h +135 -0
  518. data/src/core/lib/gprpp/thd.h +174 -0
  519. data/src/core/lib/gprpp/thd_posix.cc +204 -0
  520. data/src/core/lib/gprpp/thd_windows.cc +176 -0
  521. data/src/core/lib/http/format_request.cc +103 -0
  522. data/src/core/lib/http/format_request.h +34 -0
  523. data/src/core/lib/http/httpcli.cc +303 -0
  524. data/src/core/lib/http/httpcli.h +126 -0
  525. data/src/core/lib/http/httpcli_security_connector.cc +214 -0
  526. data/src/core/lib/http/parser.cc +372 -0
  527. data/src/core/lib/http/parser.h +113 -0
  528. data/src/core/lib/iomgr/block_annotate.h +57 -0
  529. data/src/core/lib/iomgr/buffer_list.cc +308 -0
  530. data/src/core/lib/iomgr/buffer_list.h +165 -0
  531. data/src/core/lib/iomgr/call_combiner.cc +256 -0
  532. data/src/core/lib/iomgr/call_combiner.h +217 -0
  533. data/src/core/lib/iomgr/cfstream_handle.cc +209 -0
  534. data/src/core/lib/iomgr/cfstream_handle.h +90 -0
  535. data/src/core/lib/iomgr/closure.h +255 -0
  536. data/src/core/lib/iomgr/combiner.cc +339 -0
  537. data/src/core/lib/iomgr/combiner.h +88 -0
  538. data/src/core/lib/iomgr/dualstack_socket_posix.cc +47 -0
  539. data/src/core/lib/iomgr/dynamic_annotations.h +67 -0
  540. data/src/core/lib/iomgr/endpoint.cc +67 -0
  541. data/src/core/lib/iomgr/endpoint.h +106 -0
  542. data/src/core/lib/iomgr/endpoint_cfstream.cc +376 -0
  543. data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
  544. data/src/core/lib/iomgr/endpoint_pair.h +33 -0
  545. data/src/core/lib/iomgr/endpoint_pair_posix.cc +73 -0
  546. data/src/core/lib/iomgr/endpoint_pair_uv.cc +40 -0
  547. data/src/core/lib/iomgr/endpoint_pair_windows.cc +87 -0
  548. data/src/core/lib/iomgr/error.cc +812 -0
  549. data/src/core/lib/iomgr/error.h +276 -0
  550. data/src/core/lib/iomgr/error_cfstream.cc +52 -0
  551. data/src/core/lib/iomgr/error_cfstream.h +31 -0
  552. data/src/core/lib/iomgr/error_internal.h +61 -0
  553. data/src/core/lib/iomgr/ev_apple.cc +356 -0
  554. data/src/core/lib/iomgr/ev_apple.h +43 -0
  555. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1365 -0
  556. data/src/core/lib/iomgr/ev_epoll1_linux.h +31 -0
  557. data/src/core/lib/iomgr/ev_epollex_linux.cc +1656 -0
  558. data/src/core/lib/iomgr/ev_epollex_linux.h +30 -0
  559. data/src/core/lib/iomgr/ev_poll_posix.cc +1427 -0
  560. data/src/core/lib/iomgr/ev_poll_posix.h +29 -0
  561. data/src/core/lib/iomgr/ev_posix.cc +417 -0
  562. data/src/core/lib/iomgr/ev_posix.h +207 -0
  563. data/src/core/lib/iomgr/ev_windows.cc +30 -0
  564. data/src/core/lib/iomgr/exec_ctx.cc +224 -0
  565. data/src/core/lib/iomgr/exec_ctx.h +380 -0
  566. data/src/core/lib/iomgr/executor.cc +469 -0
  567. data/src/core/lib/iomgr/executor.h +122 -0
  568. data/src/core/lib/iomgr/executor/mpmcqueue.cc +183 -0
  569. data/src/core/lib/iomgr/executor/mpmcqueue.h +175 -0
  570. data/src/core/lib/iomgr/executor/threadpool.cc +137 -0
  571. data/src/core/lib/iomgr/executor/threadpool.h +149 -0
  572. data/src/core/lib/iomgr/fork_posix.cc +119 -0
  573. data/src/core/lib/iomgr/fork_windows.cc +41 -0
  574. data/src/core/lib/iomgr/gethostname.h +26 -0
  575. data/src/core/lib/iomgr/gethostname_fallback.cc +30 -0
  576. data/src/core/lib/iomgr/gethostname_host_name_max.cc +40 -0
  577. data/src/core/lib/iomgr/gethostname_sysconf.cc +40 -0
  578. data/src/core/lib/iomgr/grpc_if_nametoindex.h +30 -0
  579. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
  580. data/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc +38 -0
  581. data/src/core/lib/iomgr/internal_errqueue.cc +67 -0
  582. data/src/core/lib/iomgr/internal_errqueue.h +191 -0
  583. data/src/core/lib/iomgr/iocp_windows.cc +157 -0
  584. data/src/core/lib/iomgr/iocp_windows.h +48 -0
  585. data/src/core/lib/iomgr/iomgr.cc +194 -0
  586. data/src/core/lib/iomgr/iomgr.h +60 -0
  587. data/src/core/lib/iomgr/iomgr_custom.cc +79 -0
  588. data/src/core/lib/iomgr/iomgr_custom.h +49 -0
  589. data/src/core/lib/iomgr/iomgr_internal.cc +57 -0
  590. data/src/core/lib/iomgr/iomgr_internal.h +73 -0
  591. data/src/core/lib/iomgr/iomgr_posix.cc +89 -0
  592. data/src/core/lib/iomgr/iomgr_posix.h +26 -0
  593. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +171 -0
  594. data/src/core/lib/iomgr/iomgr_uv.cc +43 -0
  595. data/src/core/lib/iomgr/iomgr_windows.cc +106 -0
  596. data/src/core/lib/iomgr/is_epollexclusive_available.cc +105 -0
  597. data/src/core/lib/iomgr/is_epollexclusive_available.h +36 -0
  598. data/src/core/lib/iomgr/load_file.cc +81 -0
  599. data/src/core/lib/iomgr/load_file.h +35 -0
  600. data/src/core/lib/iomgr/lockfree_event.cc +255 -0
  601. data/src/core/lib/iomgr/lockfree_event.h +72 -0
  602. data/src/core/lib/iomgr/nameser.h +106 -0
  603. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
  604. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
  605. data/src/core/lib/iomgr/polling_entity.cc +96 -0
  606. data/src/core/lib/iomgr/polling_entity.h +68 -0
  607. data/src/core/lib/iomgr/pollset.cc +56 -0
  608. data/src/core/lib/iomgr/pollset.h +99 -0
  609. data/src/core/lib/iomgr/pollset_custom.cc +106 -0
  610. data/src/core/lib/iomgr/pollset_custom.h +35 -0
  611. data/src/core/lib/iomgr/pollset_set.cc +55 -0
  612. data/src/core/lib/iomgr/pollset_set.h +55 -0
  613. data/src/core/lib/iomgr/pollset_set_custom.cc +48 -0
  614. data/src/core/lib/iomgr/pollset_set_custom.h +26 -0
  615. data/src/core/lib/iomgr/pollset_set_windows.cc +51 -0
  616. data/src/core/lib/iomgr/pollset_set_windows.h +26 -0
  617. data/src/core/lib/iomgr/pollset_uv.cc +93 -0
  618. data/src/core/lib/iomgr/pollset_uv.h +32 -0
  619. data/src/core/lib/iomgr/pollset_windows.cc +243 -0
  620. data/src/core/lib/iomgr/pollset_windows.h +70 -0
  621. data/src/core/lib/iomgr/port.h +244 -0
  622. data/src/core/lib/iomgr/python_util.h +46 -0
  623. data/src/core/lib/iomgr/resolve_address.cc +50 -0
  624. data/src/core/lib/iomgr/resolve_address.h +81 -0
  625. data/src/core/lib/iomgr/resolve_address_custom.cc +173 -0
  626. data/src/core/lib/iomgr/resolve_address_custom.h +45 -0
  627. data/src/core/lib/iomgr/resolve_address_posix.cc +178 -0
  628. data/src/core/lib/iomgr/resolve_address_windows.cc +154 -0
  629. data/src/core/lib/iomgr/resource_quota.cc +1013 -0
  630. data/src/core/lib/iomgr/resource_quota.h +177 -0
  631. data/src/core/lib/iomgr/sockaddr.h +32 -0
  632. data/src/core/lib/iomgr/sockaddr_custom.h +54 -0
  633. data/src/core/lib/iomgr/sockaddr_posix.h +55 -0
  634. data/src/core/lib/iomgr/sockaddr_utils.cc +293 -0
  635. data/src/core/lib/iomgr/sockaddr_utils.h +79 -0
  636. data/src/core/lib/iomgr/sockaddr_windows.h +55 -0
  637. data/src/core/lib/iomgr/socket_factory_posix.cc +94 -0
  638. data/src/core/lib/iomgr/socket_factory_posix.h +68 -0
  639. data/src/core/lib/iomgr/socket_mutator.cc +83 -0
  640. data/src/core/lib/iomgr/socket_mutator.h +60 -0
  641. data/src/core/lib/iomgr/socket_utils.h +47 -0
  642. data/src/core/lib/iomgr/socket_utils_common_posix.cc +473 -0
  643. data/src/core/lib/iomgr/socket_utils_linux.cc +42 -0
  644. data/src/core/lib/iomgr/socket_utils_posix.cc +58 -0
  645. data/src/core/lib/iomgr/socket_utils_posix.h +163 -0
  646. data/src/core/lib/iomgr/socket_utils_uv.cc +49 -0
  647. data/src/core/lib/iomgr/socket_utils_windows.cc +47 -0
  648. data/src/core/lib/iomgr/socket_windows.cc +203 -0
  649. data/src/core/lib/iomgr/socket_windows.h +127 -0
  650. data/src/core/lib/iomgr/sys_epoll_wrapper.h +30 -0
  651. data/src/core/lib/iomgr/tcp_client.cc +36 -0
  652. data/src/core/lib/iomgr/tcp_client.h +52 -0
  653. data/src/core/lib/iomgr/tcp_client_cfstream.cc +215 -0
  654. data/src/core/lib/iomgr/tcp_client_custom.cc +163 -0
  655. data/src/core/lib/iomgr/tcp_client_posix.cc +360 -0
  656. data/src/core/lib/iomgr/tcp_client_posix.h +68 -0
  657. data/src/core/lib/iomgr/tcp_client_windows.cc +232 -0
  658. data/src/core/lib/iomgr/tcp_custom.cc +370 -0
  659. data/src/core/lib/iomgr/tcp_custom.h +84 -0
  660. data/src/core/lib/iomgr/tcp_posix.cc +1855 -0
  661. data/src/core/lib/iomgr/tcp_posix.h +60 -0
  662. data/src/core/lib/iomgr/tcp_server.cc +78 -0
  663. data/src/core/lib/iomgr/tcp_server.h +143 -0
  664. data/src/core/lib/iomgr/tcp_server_custom.cc +485 -0
  665. data/src/core/lib/iomgr/tcp_server_posix.cc +638 -0
  666. data/src/core/lib/iomgr/tcp_server_utils_posix.h +125 -0
  667. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +223 -0
  668. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +181 -0
  669. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +36 -0
  670. data/src/core/lib/iomgr/tcp_server_windows.cc +564 -0
  671. data/src/core/lib/iomgr/tcp_uv.cc +419 -0
  672. data/src/core/lib/iomgr/tcp_windows.cc +533 -0
  673. data/src/core/lib/iomgr/tcp_windows.h +53 -0
  674. data/src/core/lib/iomgr/time_averaged_stats.cc +64 -0
  675. data/src/core/lib/iomgr/time_averaged_stats.h +72 -0
  676. data/src/core/lib/iomgr/timer.cc +45 -0
  677. data/src/core/lib/iomgr/timer.h +127 -0
  678. data/src/core/lib/iomgr/timer_custom.cc +95 -0
  679. data/src/core/lib/iomgr/timer_custom.h +43 -0
  680. data/src/core/lib/iomgr/timer_generic.cc +747 -0
  681. data/src/core/lib/iomgr/timer_generic.h +39 -0
  682. data/src/core/lib/iomgr/timer_heap.cc +135 -0
  683. data/src/core/lib/iomgr/timer_heap.h +43 -0
  684. data/src/core/lib/iomgr/timer_manager.cc +363 -0
  685. data/src/core/lib/iomgr/timer_manager.h +41 -0
  686. data/src/core/lib/iomgr/timer_uv.cc +66 -0
  687. data/src/core/lib/iomgr/udp_server.cc +747 -0
  688. data/src/core/lib/iomgr/udp_server.h +101 -0
  689. data/src/core/lib/iomgr/unix_sockets_posix.cc +104 -0
  690. data/src/core/lib/iomgr/unix_sockets_posix.h +43 -0
  691. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +49 -0
  692. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +82 -0
  693. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +38 -0
  694. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +100 -0
  695. data/src/core/lib/iomgr/wakeup_fd_pipe.h +28 -0
  696. data/src/core/lib/iomgr/wakeup_fd_posix.cc +69 -0
  697. data/src/core/lib/iomgr/wakeup_fd_posix.h +96 -0
  698. data/src/core/lib/iomgr/work_serializer.cc +155 -0
  699. data/src/core/lib/iomgr/work_serializer.h +65 -0
  700. data/src/core/lib/json/json.h +240 -0
  701. data/src/core/lib/json/json_reader.cc +855 -0
  702. data/src/core/lib/json/json_writer.cc +337 -0
  703. data/src/core/lib/profiling/basic_timers.cc +293 -0
  704. data/src/core/lib/profiling/stap_timers.cc +50 -0
  705. data/src/core/lib/profiling/timers.h +94 -0
  706. data/src/core/lib/security/context/security_context.cc +321 -0
  707. data/src/core/lib/security/context/security_context.h +150 -0
  708. data/src/core/lib/security/credentials/alts/alts_credentials.cc +110 -0
  709. data/src/core/lib/security/credentials/alts/alts_credentials.h +109 -0
  710. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +72 -0
  711. data/src/core/lib/security/credentials/alts/check_gcp_environment.h +57 -0
  712. data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +68 -0
  713. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +33 -0
  714. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +102 -0
  715. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +127 -0
  716. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc +46 -0
  717. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +75 -0
  718. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +59 -0
  719. data/src/core/lib/security/credentials/composite/composite_credentials.cc +229 -0
  720. data/src/core/lib/security/credentials/composite/composite_credentials.h +106 -0
  721. data/src/core/lib/security/credentials/credentials.cc +162 -0
  722. data/src/core/lib/security/credentials/credentials.h +283 -0
  723. data/src/core/lib/security/credentials/credentials_metadata.cc +62 -0
  724. data/src/core/lib/security/credentials/fake/fake_credentials.cc +112 -0
  725. data/src/core/lib/security/credentials/fake/fake_credentials.h +87 -0
  726. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +41 -0
  727. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +383 -0
  728. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +87 -0
  729. data/src/core/lib/security/credentials/iam/iam_credentials.cc +80 -0
  730. data/src/core/lib/security/credentials/iam/iam_credentials.h +49 -0
  731. data/src/core/lib/security/credentials/jwt/json_token.cc +288 -0
  732. data/src/core/lib/security/credentials/jwt/json_token.h +75 -0
  733. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +172 -0
  734. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +80 -0
  735. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +925 -0
  736. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +122 -0
  737. data/src/core/lib/security/credentials/local/local_credentials.cc +64 -0
  738. data/src/core/lib/security/credentials/local/local_credentials.h +61 -0
  739. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +771 -0
  740. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +171 -0
  741. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +269 -0
  742. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +72 -0
  743. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +364 -0
  744. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +99 -0
  745. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +245 -0
  746. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +313 -0
  747. data/src/core/lib/security/credentials/tls/tls_credentials.cc +128 -0
  748. data/src/core/lib/security/credentials/tls/tls_credentials.h +62 -0
  749. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +301 -0
  750. data/src/core/lib/security/security_connector/alts/alts_security_connector.h +76 -0
  751. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +324 -0
  752. data/src/core/lib/security/security_connector/fake/fake_security_connector.h +45 -0
  753. data/src/core/lib/security/security_connector/load_system_roots.h +29 -0
  754. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +32 -0
  755. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +171 -0
  756. data/src/core/lib/security/security_connector/load_system_roots_linux.h +44 -0
  757. data/src/core/lib/security/security_connector/local/local_security_connector.cc +281 -0
  758. data/src/core/lib/security/security_connector/local/local_security_connector.h +59 -0
  759. data/src/core/lib/security/security_connector/security_connector.cc +129 -0
  760. data/src/core/lib/security/security_connector/security_connector.h +176 -0
  761. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +439 -0
  762. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +77 -0
  763. data/src/core/lib/security/security_connector/ssl_utils.cc +563 -0
  764. data/src/core/lib/security/security_connector/ssl_utils.h +184 -0
  765. data/src/core/lib/security/security_connector/ssl_utils_config.cc +32 -0
  766. data/src/core/lib/security/security_connector/ssl_utils_config.h +30 -0
  767. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +603 -0
  768. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +183 -0
  769. data/src/core/lib/security/transport/auth_filters.h +35 -0
  770. data/src/core/lib/security/transport/client_auth_filter.cc +466 -0
  771. data/src/core/lib/security/transport/secure_endpoint.cc +446 -0
  772. data/src/core/lib/security/transport/secure_endpoint.h +41 -0
  773. data/src/core/lib/security/transport/security_handshaker.cc +574 -0
  774. data/src/core/lib/security/transport/security_handshaker.h +45 -0
  775. data/src/core/lib/security/transport/server_auth_filter.cc +326 -0
  776. data/src/core/lib/security/transport/target_authority_table.cc +75 -0
  777. data/src/core/lib/security/transport/target_authority_table.h +40 -0
  778. data/src/core/lib/security/transport/tsi_error.cc +29 -0
  779. data/src/core/lib/security/transport/tsi_error.h +29 -0
  780. data/src/core/lib/security/util/json_util.cc +73 -0
  781. data/src/core/lib/security/util/json_util.h +44 -0
  782. data/src/core/lib/slice/b64.cc +239 -0
  783. data/src/core/lib/slice/b64.h +50 -0
  784. data/src/core/lib/slice/percent_encoding.cc +169 -0
  785. data/src/core/lib/slice/percent_encoding.h +65 -0
  786. data/src/core/lib/slice/slice.cc +559 -0
  787. data/src/core/lib/slice/slice_buffer.cc +413 -0
  788. data/src/core/lib/slice/slice_hash_table.h +199 -0
  789. data/src/core/lib/slice/slice_intern.cc +375 -0
  790. data/src/core/lib/slice/slice_internal.h +364 -0
  791. data/src/core/lib/slice/slice_string_helpers.cc +127 -0
  792. data/src/core/lib/slice/slice_string_helpers.h +49 -0
  793. data/src/core/lib/slice/slice_utils.h +200 -0
  794. data/src/core/lib/slice/slice_weak_hash_table.h +102 -0
  795. data/src/core/lib/surface/api_trace.cc +24 -0
  796. data/src/core/lib/surface/api_trace.h +52 -0
  797. data/src/core/lib/surface/byte_buffer.cc +92 -0
  798. data/src/core/lib/surface/byte_buffer_reader.cc +101 -0
  799. data/src/core/lib/surface/call.cc +2044 -0
  800. data/src/core/lib/surface/call.h +125 -0
  801. data/src/core/lib/surface/call_details.cc +41 -0
  802. data/src/core/lib/surface/call_log_batch.cc +111 -0
  803. data/src/core/lib/surface/call_test_only.h +43 -0
  804. data/src/core/lib/surface/channel.cc +543 -0
  805. data/src/core/lib/surface/channel.h +158 -0
  806. data/src/core/lib/surface/channel_init.cc +109 -0
  807. data/src/core/lib/surface/channel_init.h +78 -0
  808. data/src/core/lib/surface/channel_ping.cc +64 -0
  809. data/src/core/lib/surface/channel_stack_type.cc +58 -0
  810. data/src/core/lib/surface/channel_stack_type.h +47 -0
  811. data/src/core/lib/surface/completion_queue.cc +1438 -0
  812. data/src/core/lib/surface/completion_queue.h +97 -0
  813. data/src/core/lib/surface/completion_queue_factory.cc +88 -0
  814. data/src/core/lib/surface/completion_queue_factory.h +38 -0
  815. data/src/core/lib/surface/event_string.cc +61 -0
  816. data/src/core/lib/surface/event_string.h +31 -0
  817. data/src/core/lib/surface/init.cc +250 -0
  818. data/src/core/lib/surface/init.h +27 -0
  819. data/src/core/lib/surface/init_secure.cc +81 -0
  820. data/src/core/lib/surface/lame_client.cc +191 -0
  821. data/src/core/lib/surface/lame_client.h +28 -0
  822. data/src/core/lib/surface/metadata_array.cc +36 -0
  823. data/src/core/lib/surface/server.cc +1800 -0
  824. data/src/core/lib/surface/server.h +99 -0
  825. data/src/core/lib/surface/validate_metadata.cc +105 -0
  826. data/src/core/lib/surface/validate_metadata.h +41 -0
  827. data/src/core/lib/surface/version.cc +28 -0
  828. data/src/core/lib/transport/bdp_estimator.cc +87 -0
  829. data/src/core/lib/transport/bdp_estimator.h +94 -0
  830. data/src/core/lib/transport/byte_stream.cc +158 -0
  831. data/src/core/lib/transport/byte_stream.h +165 -0
  832. data/src/core/lib/transport/connectivity_state.cc +180 -0
  833. data/src/core/lib/transport/connectivity_state.h +131 -0
  834. data/src/core/lib/transport/error_utils.cc +141 -0
  835. data/src/core/lib/transport/error_utils.h +46 -0
  836. data/src/core/lib/transport/http2_errors.h +41 -0
  837. data/src/core/lib/transport/metadata.cc +679 -0
  838. data/src/core/lib/transport/metadata.h +446 -0
  839. data/src/core/lib/transport/metadata_batch.cc +392 -0
  840. data/src/core/lib/transport/metadata_batch.h +191 -0
  841. data/src/core/lib/transport/pid_controller.cc +51 -0
  842. data/src/core/lib/transport/pid_controller.h +116 -0
  843. data/src/core/lib/transport/static_metadata.cc +1230 -0
  844. data/src/core/lib/transport/static_metadata.h +597 -0
  845. data/src/core/lib/transport/status_conversion.cc +92 -0
  846. data/src/core/lib/transport/status_conversion.h +38 -0
  847. data/src/core/lib/transport/status_metadata.cc +61 -0
  848. data/src/core/lib/transport/status_metadata.h +48 -0
  849. data/src/core/lib/transport/timeout_encoding.cc +151 -0
  850. data/src/core/lib/transport/timeout_encoding.h +38 -0
  851. data/src/core/lib/transport/transport.cc +259 -0
  852. data/src/core/lib/transport/transport.h +456 -0
  853. data/src/core/lib/transport/transport_impl.h +71 -0
  854. data/src/core/lib/transport/transport_op_string.cc +169 -0
  855. data/src/core/lib/uri/uri_parser.cc +314 -0
  856. data/src/core/lib/uri/uri_parser.h +49 -0
  857. data/src/core/plugin_registry/grpc_plugin_registry.cc +121 -0
  858. data/src/core/tsi/alts/crypt/aes_gcm.cc +687 -0
  859. data/src/core/tsi/alts/crypt/gsec.cc +189 -0
  860. data/src/core/tsi/alts/crypt/gsec.h +454 -0
  861. data/src/core/tsi/alts/frame_protector/alts_counter.cc +118 -0
  862. data/src/core/tsi/alts/frame_protector/alts_counter.h +98 -0
  863. data/src/core/tsi/alts/frame_protector/alts_crypter.cc +66 -0
  864. data/src/core/tsi/alts/frame_protector/alts_crypter.h +255 -0
  865. data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +407 -0
  866. data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +55 -0
  867. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc +114 -0
  868. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +114 -0
  869. data/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc +105 -0
  870. data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +103 -0
  871. data/src/core/tsi/alts/frame_protector/frame_handler.cc +218 -0
  872. data/src/core/tsi/alts/frame_protector/frame_handler.h +236 -0
  873. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +899 -0
  874. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +161 -0
  875. data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +83 -0
  876. data/src/core/tsi/alts/handshaker/alts_shared_resource.h +73 -0
  877. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +674 -0
  878. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +104 -0
  879. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +88 -0
  880. data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +64 -0
  881. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +53 -0
  882. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +223 -0
  883. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +171 -0
  884. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +226 -0
  885. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +54 -0
  886. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +144 -0
  887. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +49 -0
  888. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +91 -0
  889. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +174 -0
  890. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +99 -0
  891. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +476 -0
  892. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +199 -0
  893. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +307 -0
  894. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +57 -0
  895. data/src/core/tsi/fake_transport_security.cc +789 -0
  896. data/src/core/tsi/fake_transport_security.h +47 -0
  897. data/src/core/tsi/local_transport_security.cc +211 -0
  898. data/src/core/tsi/local_transport_security.h +51 -0
  899. data/src/core/tsi/ssl/session_cache/ssl_session.h +71 -0
  900. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +57 -0
  901. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +214 -0
  902. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +90 -0
  903. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +75 -0
  904. data/src/core/tsi/ssl_transport_security.cc +2124 -0
  905. data/src/core/tsi/ssl_transport_security.h +353 -0
  906. data/src/core/tsi/ssl_types.h +42 -0
  907. data/src/core/tsi/transport_security.cc +370 -0
  908. data/src/core/tsi/transport_security.h +127 -0
  909. data/src/core/tsi/transport_security_grpc.cc +73 -0
  910. data/src/core/tsi/transport_security_grpc.h +79 -0
  911. data/src/core/tsi/transport_security_interface.h +476 -0
  912. data/src/ruby/bin/math_client.rb +140 -0
  913. data/src/ruby/bin/math_pb.rb +34 -0
  914. data/src/ruby/bin/math_server.rb +191 -0
  915. data/src/ruby/bin/math_services_pb.rb +51 -0
  916. data/src/ruby/bin/noproto_client.rb +93 -0
  917. data/src/ruby/bin/noproto_server.rb +97 -0
  918. data/src/ruby/ext/grpc/ext-export.clang +1 -0
  919. data/src/ruby/ext/grpc/ext-export.gcc +6 -0
  920. data/src/ruby/ext/grpc/extconf.rb +107 -0
  921. data/src/ruby/ext/grpc/rb_byte_buffer.c +64 -0
  922. data/src/ruby/ext/grpc/rb_byte_buffer.h +35 -0
  923. data/src/ruby/ext/grpc/rb_call.c +1050 -0
  924. data/src/ruby/ext/grpc/rb_call.h +53 -0
  925. data/src/ruby/ext/grpc/rb_call_credentials.c +297 -0
  926. data/src/ruby/ext/grpc/rb_call_credentials.h +31 -0
  927. data/src/ruby/ext/grpc/rb_channel.c +835 -0
  928. data/src/ruby/ext/grpc/rb_channel.h +34 -0
  929. data/src/ruby/ext/grpc/rb_channel_args.c +155 -0
  930. data/src/ruby/ext/grpc/rb_channel_args.h +38 -0
  931. data/src/ruby/ext/grpc/rb_channel_credentials.c +267 -0
  932. data/src/ruby/ext/grpc/rb_channel_credentials.h +32 -0
  933. data/src/ruby/ext/grpc/rb_completion_queue.c +100 -0
  934. data/src/ruby/ext/grpc/rb_completion_queue.h +36 -0
  935. data/src/ruby/ext/grpc/rb_compression_options.c +470 -0
  936. data/src/ruby/ext/grpc/rb_compression_options.h +29 -0
  937. data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
  938. data/src/ruby/ext/grpc/rb_event_thread.c +143 -0
  939. data/src/ruby/ext/grpc/rb_event_thread.h +21 -0
  940. data/src/ruby/ext/grpc/rb_grpc.c +328 -0
  941. data/src/ruby/ext/grpc/rb_grpc.h +76 -0
  942. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +573 -0
  943. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +865 -0
  944. data/src/ruby/ext/grpc/rb_loader.c +57 -0
  945. data/src/ruby/ext/grpc/rb_loader.h +25 -0
  946. data/src/ruby/ext/grpc/rb_server.c +372 -0
  947. data/src/ruby/ext/grpc/rb_server.h +32 -0
  948. data/src/ruby/ext/grpc/rb_server_credentials.c +243 -0
  949. data/src/ruby/ext/grpc/rb_server_credentials.h +32 -0
  950. data/src/ruby/lib/grpc.rb +37 -0
  951. data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
  952. data/src/ruby/lib/grpc/core/time_consts.rb +56 -0
  953. data/src/ruby/lib/grpc/errors.rb +277 -0
  954. data/src/ruby/lib/grpc/generic/active_call.rb +669 -0
  955. data/src/ruby/lib/grpc/generic/bidi_call.rb +233 -0
  956. data/src/ruby/lib/grpc/generic/client_stub.rb +501 -0
  957. data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
  958. data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
  959. data/src/ruby/lib/grpc/generic/rpc_desc.rb +204 -0
  960. data/src/ruby/lib/grpc/generic/rpc_server.rb +551 -0
  961. data/src/ruby/lib/grpc/generic/service.rb +211 -0
  962. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +40 -0
  963. data/src/ruby/lib/grpc/grpc.rb +24 -0
  964. data/src/ruby/lib/grpc/logconfig.rb +44 -0
  965. data/src/ruby/lib/grpc/notifier.rb +45 -0
  966. data/src/ruby/lib/grpc/structs.rb +15 -0
  967. data/src/ruby/lib/grpc/version.rb +18 -0
  968. data/src/ruby/pb/README.md +42 -0
  969. data/src/ruby/pb/generate_proto_ruby.sh +51 -0
  970. data/src/ruby/pb/grpc/health/checker.rb +75 -0
  971. data/src/ruby/pb/grpc/health/v1/health_pb.rb +31 -0
  972. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +62 -0
  973. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +44 -0
  974. data/src/ruby/pb/grpc/testing/metrics_pb.rb +28 -0
  975. data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +49 -0
  976. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +17 -0
  977. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +105 -0
  978. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +16 -0
  979. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +118 -0
  980. data/src/ruby/spec/call_credentials_spec.rb +42 -0
  981. data/src/ruby/spec/call_spec.rb +180 -0
  982. data/src/ruby/spec/channel_connection_spec.rb +126 -0
  983. data/src/ruby/spec/channel_credentials_spec.rb +82 -0
  984. data/src/ruby/spec/channel_spec.rb +234 -0
  985. data/src/ruby/spec/client_auth_spec.rb +126 -0
  986. data/src/ruby/spec/client_server_spec.rb +664 -0
  987. data/src/ruby/spec/compression_options_spec.rb +149 -0
  988. data/src/ruby/spec/debug_message_spec.rb +134 -0
  989. data/src/ruby/spec/error_sanity_spec.rb +49 -0
  990. data/src/ruby/spec/errors_spec.rb +142 -0
  991. data/src/ruby/spec/generic/active_call_spec.rb +672 -0
  992. data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
  993. data/src/ruby/spec/generic/client_stub_spec.rb +1083 -0
  994. data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
  995. data/src/ruby/spec/generic/rpc_desc_spec.rb +374 -0
  996. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +127 -0
  997. data/src/ruby/spec/generic/rpc_server_spec.rb +748 -0
  998. data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
  999. data/src/ruby/spec/generic/service_spec.rb +263 -0
  1000. data/src/ruby/spec/google_rpc_status_utils_spec.rb +282 -0
  1001. data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
  1002. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
  1003. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
  1004. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +41 -0
  1005. data/src/ruby/spec/pb/codegen/package_option_spec.rb +82 -0
  1006. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +57 -0
  1007. data/src/ruby/spec/pb/health/checker_spec.rb +236 -0
  1008. data/src/ruby/spec/server_credentials_spec.rb +79 -0
  1009. data/src/ruby/spec/server_spec.rb +209 -0
  1010. data/src/ruby/spec/spec_helper.rb +61 -0
  1011. data/src/ruby/spec/support/helpers.rb +107 -0
  1012. data/src/ruby/spec/support/services.rb +160 -0
  1013. data/src/ruby/spec/testdata/README +1 -0
  1014. data/src/ruby/spec/testdata/ca.pem +20 -0
  1015. data/src/ruby/spec/testdata/client.key +28 -0
  1016. data/src/ruby/spec/testdata/client.pem +20 -0
  1017. data/src/ruby/spec/testdata/server1.key +28 -0
  1018. data/src/ruby/spec/testdata/server1.pem +22 -0
  1019. data/src/ruby/spec/time_consts_spec.rb +74 -0
  1020. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
  1021. data/third_party/abseil-cpp/absl/base/attributes.h +621 -0
  1022. data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
  1023. data/third_party/abseil-cpp/absl/base/casts.h +184 -0
  1024. data/third_party/abseil-cpp/absl/base/config.h +671 -0
  1025. data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
  1026. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
  1027. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
  1028. data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +200 -0
  1029. data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
  1030. data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
  1031. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
  1032. data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
  1033. data/third_party/abseil-cpp/absl/base/internal/errno_saver.h +43 -0
  1034. data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
  1035. data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
  1036. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
  1037. data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
  1038. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
  1039. data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
  1040. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +240 -0
  1041. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +183 -0
  1042. data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
  1043. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
  1044. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
  1045. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
  1046. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +66 -0
  1047. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
  1048. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
  1049. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
  1050. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
  1051. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +416 -0
  1052. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
  1053. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
  1054. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +152 -0
  1055. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +259 -0
  1056. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
  1057. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
  1058. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
  1059. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
  1060. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +140 -0
  1061. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
  1062. data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
  1063. data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
  1064. data/third_party/abseil-cpp/absl/base/macros.h +220 -0
  1065. data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
  1066. data/third_party/abseil-cpp/absl/base/options.h +211 -0
  1067. data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
  1068. data/third_party/abseil-cpp/absl/base/port.h +26 -0
  1069. data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
  1070. data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
  1071. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
  1072. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
  1073. data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
  1074. data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
  1075. data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
  1076. data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
  1077. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
  1078. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
  1079. data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
  1080. data/third_party/abseil-cpp/absl/strings/ascii.h +242 -0
  1081. data/third_party/abseil-cpp/absl/strings/charconv.cc +984 -0
  1082. data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
  1083. data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
  1084. data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
  1085. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
  1086. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
  1087. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +423 -0
  1088. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
  1089. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
  1090. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
  1091. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
  1092. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
  1093. data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
  1094. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
  1095. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
  1096. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
  1097. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
  1098. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +388 -0
  1099. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +432 -0
  1100. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +245 -0
  1101. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +209 -0
  1102. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +326 -0
  1103. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +51 -0
  1104. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +415 -0
  1105. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +493 -0
  1106. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +23 -0
  1107. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +72 -0
  1108. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +104 -0
  1109. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +334 -0
  1110. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +333 -0
  1111. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
  1112. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
  1113. data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
  1114. data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
  1115. data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
  1116. data/third_party/abseil-cpp/absl/strings/match.h +90 -0
  1117. data/third_party/abseil-cpp/absl/strings/numbers.cc +965 -0
  1118. data/third_party/abseil-cpp/absl/strings/numbers.h +266 -0
  1119. data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
  1120. data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
  1121. data/third_party/abseil-cpp/absl/strings/str_format.h +537 -0
  1122. data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
  1123. data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
  1124. data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
  1125. data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
  1126. data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
  1127. data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
  1128. data/third_party/abseil-cpp/absl/strings/string_view.h +622 -0
  1129. data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
  1130. data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
  1131. data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
  1132. data/third_party/abseil-cpp/absl/time/civil_time.cc +175 -0
  1133. data/third_party/abseil-cpp/absl/time/civil_time.h +538 -0
  1134. data/third_party/abseil-cpp/absl/time/clock.cc +569 -0
  1135. data/third_party/abseil-cpp/absl/time/clock.h +74 -0
  1136. data/third_party/abseil-cpp/absl/time/duration.cc +922 -0
  1137. data/third_party/abseil-cpp/absl/time/format.cc +153 -0
  1138. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +332 -0
  1139. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +622 -0
  1140. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +384 -0
  1141. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +102 -0
  1142. data/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +94 -0
  1143. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +140 -0
  1144. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +52 -0
  1145. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +922 -0
  1146. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +45 -0
  1147. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +76 -0
  1148. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +121 -0
  1149. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +93 -0
  1150. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +958 -0
  1151. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +138 -0
  1152. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +308 -0
  1153. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +55 -0
  1154. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +187 -0
  1155. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +159 -0
  1156. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +132 -0
  1157. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +122 -0
  1158. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +115 -0
  1159. data/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +31 -0
  1160. data/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +24 -0
  1161. data/third_party/abseil-cpp/absl/time/time.cc +499 -0
  1162. data/third_party/abseil-cpp/absl/time/time.h +1584 -0
  1163. data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
  1164. data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
  1165. data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
  1166. data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
  1167. data/third_party/abseil-cpp/absl/types/optional.h +776 -0
  1168. data/third_party/abseil-cpp/absl/types/span.h +713 -0
  1169. data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
  1170. data/third_party/address_sorting/address_sorting.c +375 -0
  1171. data/third_party/address_sorting/address_sorting_internal.h +70 -0
  1172. data/third_party/address_sorting/address_sorting_posix.c +97 -0
  1173. data/third_party/address_sorting/address_sorting_windows.c +95 -0
  1174. data/third_party/address_sorting/include/address_sorting/address_sorting.h +113 -0
  1175. data/third_party/boringssl-with-bazel/err_data.c +1439 -0
  1176. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +271 -0
  1177. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +123 -0
  1178. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +93 -0
  1179. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.c +87 -0
  1180. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +195 -0
  1181. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +261 -0
  1182. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.c +88 -0
  1183. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +420 -0
  1184. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +305 -0
  1185. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +286 -0
  1186. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +77 -0
  1187. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c +93 -0
  1188. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +313 -0
  1189. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +212 -0
  1190. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +151 -0
  1191. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +303 -0
  1192. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +236 -0
  1193. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +446 -0
  1194. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +104 -0
  1195. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +80 -0
  1196. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +105 -0
  1197. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +93 -0
  1198. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +97 -0
  1199. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +91 -0
  1200. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +1244 -0
  1201. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +664 -0
  1202. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +244 -0
  1203. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +387 -0
  1204. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +131 -0
  1205. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +280 -0
  1206. data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +206 -0
  1207. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +466 -0
  1208. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +700 -0
  1209. data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +330 -0
  1210. data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +545 -0
  1211. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +279 -0
  1212. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +317 -0
  1213. data/third_party/boringssl-with-bazel/src/crypto/bio/hexdump.c +192 -0
  1214. data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +111 -0
  1215. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +488 -0
  1216. data/third_party/boringssl-with-bazel/src/crypto/bio/printf.c +115 -0
  1217. data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +206 -0
  1218. data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +118 -0
  1219. data/third_party/boringssl-with-bazel/src/crypto/bn_extra/bn_asn1.c +64 -0
  1220. data/third_party/boringssl-with-bazel/src/crypto/bn_extra/convert.c +470 -0
  1221. data/third_party/boringssl-with-bazel/src/crypto/buf/buf.c +172 -0
  1222. data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.c +52 -0
  1223. data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +265 -0
  1224. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c +719 -0
  1225. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +688 -0
  1226. data/third_party/boringssl-with-bazel/src/crypto/bytestring/internal.h +96 -0
  1227. data/third_party/boringssl-with-bazel/src/crypto/bytestring/unicode.c +155 -0
  1228. data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +184 -0
  1229. data/third_party/boringssl-with-bazel/src/crypto/chacha/internal.h +45 -0
  1230. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +143 -0
  1231. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +152 -0
  1232. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesccm.c +447 -0
  1233. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesctrhmac.c +283 -0
  1234. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesgcmsiv.c +891 -0
  1235. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +418 -0
  1236. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.c +85 -0
  1237. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc2.c +462 -0
  1238. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.c +87 -0
  1239. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +688 -0
  1240. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +128 -0
  1241. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +491 -0
  1242. data/third_party/boringssl-with-bazel/src/crypto/cmac/cmac.c +278 -0
  1243. data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +810 -0
  1244. data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +127 -0
  1245. data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +31 -0
  1246. data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-fuchsia.c +55 -0
  1247. data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-linux.c +62 -0
  1248. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +220 -0
  1249. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.h +201 -0
  1250. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +38 -0
  1251. data/third_party/boringssl-with-bazel/src/crypto/cpu-intel.c +291 -0
  1252. data/third_party/boringssl-with-bazel/src/crypto/cpu-ppc64le.c +38 -0
  1253. data/third_party/boringssl-with-bazel/src/crypto/crypto.c +226 -0
  1254. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +2159 -0
  1255. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +7872 -0
  1256. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +146 -0
  1257. data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +539 -0
  1258. data/third_party/boringssl-with-bazel/src/crypto/dh/check.c +217 -0
  1259. data/third_party/boringssl-with-bazel/src/crypto/dh/dh.c +533 -0
  1260. data/third_party/boringssl-with-bazel/src/crypto/dh/dh_asn1.c +160 -0
  1261. data/third_party/boringssl-with-bazel/src/crypto/dh/params.c +93 -0
  1262. data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +240 -0
  1263. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +980 -0
  1264. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +339 -0
  1265. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +574 -0
  1266. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_derive.c +95 -0
  1267. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +425 -0
  1268. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +78 -0
  1269. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +124 -0
  1270. data/third_party/boringssl-with-bazel/src/crypto/ecdsa_extra/ecdsa_asn1.c +267 -0
  1271. data/third_party/boringssl-with-bazel/src/crypto/engine/engine.c +99 -0
  1272. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +850 -0
  1273. data/third_party/boringssl-with-bazel/src/crypto/err/internal.h +58 -0
  1274. data/third_party/boringssl-with-bazel/src/crypto/evp/digestsign.c +231 -0
  1275. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +443 -0
  1276. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +388 -0
  1277. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_ctx.c +484 -0
  1278. data/third_party/boringssl-with-bazel/src/crypto/evp/internal.h +269 -0
  1279. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +273 -0
  1280. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +286 -0
  1281. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +255 -0
  1282. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519.c +104 -0
  1283. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519_asn1.c +221 -0
  1284. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +648 -0
  1285. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa_asn1.c +194 -0
  1286. data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519.c +110 -0
  1287. data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519_asn1.c +248 -0
  1288. data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c +146 -0
  1289. data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +489 -0
  1290. data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +213 -0
  1291. data/third_party/boringssl-with-bazel/src/crypto/evp/sign.c +151 -0
  1292. data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +261 -0
  1293. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.c +108 -0
  1294. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1282 -0
  1295. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +238 -0
  1296. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/key_wrap.c +236 -0
  1297. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +106 -0
  1298. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +263 -0
  1299. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/add.c +316 -0
  1300. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/asm/x86_64-gcc.c +541 -0
  1301. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +445 -0
  1302. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bytes.c +230 -0
  1303. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/cmp.c +200 -0
  1304. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/ctx.c +236 -0
  1305. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +886 -0
  1306. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div_extra.c +87 -0
  1307. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +1288 -0
  1308. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +378 -0
  1309. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.c +325 -0
  1310. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/generic.c +711 -0
  1311. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +694 -0
  1312. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/jacobi.c +146 -0
  1313. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +502 -0
  1314. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +186 -0
  1315. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +749 -0
  1316. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +1068 -0
  1317. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/random.c +341 -0
  1318. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +226 -0
  1319. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.h +104 -0
  1320. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/shift.c +364 -0
  1321. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +502 -0
  1322. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/aead.c +284 -0
  1323. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +620 -0
  1324. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +1302 -0
  1325. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_des.c +237 -0
  1326. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h +128 -0
  1327. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +89 -0
  1328. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/des.c +785 -0
  1329. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/internal.h +240 -0
  1330. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +271 -0
  1331. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +296 -0
  1332. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/internal.h +112 -0
  1333. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +268 -0
  1334. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +1252 -0
  1335. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +465 -0
  1336. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +524 -0
  1337. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +100 -0
  1338. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +775 -0
  1339. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +328 -0
  1340. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +1178 -0
  1341. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64-table.h +9497 -0
  1342. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +632 -0
  1343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.h +153 -0
  1344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +736 -0
  1345. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +297 -0
  1346. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +175 -0
  1347. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +357 -0
  1348. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +270 -0
  1349. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +255 -0
  1350. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +270 -0
  1351. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +122 -0
  1352. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +328 -0
  1353. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/fips_shared_support.c +32 -0
  1354. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/hmac.c +228 -0
  1355. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +29 -0
  1356. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +256 -0
  1357. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/internal.h +37 -0
  1358. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +301 -0
  1359. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +167 -0
  1360. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +202 -0
  1361. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +200 -0
  1362. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +729 -0
  1363. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +304 -0
  1364. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +441 -0
  1365. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +96 -0
  1366. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +91 -0
  1367. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/ctrdrbg.c +202 -0
  1368. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +137 -0
  1369. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +49 -0
  1370. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +64 -0
  1371. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +163 -0
  1372. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +378 -0
  1373. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +391 -0
  1374. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +243 -0
  1375. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +127 -0
  1376. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +695 -0
  1377. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +898 -0
  1378. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +1358 -0
  1379. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +654 -0
  1380. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/internal.h +53 -0
  1381. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1-altivec.c +361 -0
  1382. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +371 -0
  1383. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +343 -0
  1384. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +544 -0
  1385. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +39 -0
  1386. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +165 -0
  1387. data/third_party/boringssl-with-bazel/src/crypto/hkdf/hkdf.c +112 -0
  1388. data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +2100 -0
  1389. data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +61 -0
  1390. data/third_party/boringssl-with-bazel/src/crypto/internal.h +834 -0
  1391. data/third_party/boringssl-with-bazel/src/crypto/lhash/lhash.c +348 -0
  1392. data/third_party/boringssl-with-bazel/src/crypto/mem.c +359 -0
  1393. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +549 -0
  1394. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +11585 -0
  1395. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_xref.c +122 -0
  1396. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +261 -0
  1397. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c +360 -0
  1398. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +777 -0
  1399. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.c +87 -0
  1400. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +257 -0
  1401. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +218 -0
  1402. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.c +65 -0
  1403. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.c +65 -0
  1404. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/internal.h +49 -0
  1405. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +159 -0
  1406. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +385 -0
  1407. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +131 -0
  1408. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.c +316 -0
  1409. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +530 -0
  1410. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1305 -0
  1411. data/third_party/boringssl-with-bazel/src/crypto/poly1305/internal.h +41 -0
  1412. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +318 -0
  1413. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +305 -0
  1414. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +856 -0
  1415. data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +45 -0
  1416. data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +220 -0
  1417. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +52 -0
  1418. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c +46 -0
  1419. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/fuchsia.c +30 -0
  1420. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +70 -0
  1421. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +69 -0
  1422. data/third_party/boringssl-with-bazel/src/crypto/rc4/rc4.c +98 -0
  1423. data/third_party/boringssl-with-bazel/src/crypto/refcount_c11.c +67 -0
  1424. data/third_party/boringssl-with-bazel/src/crypto/refcount_lock.c +53 -0
  1425. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +325 -0
  1426. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_print.c +22 -0
  1427. data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +82 -0
  1428. data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +431 -0
  1429. data/third_party/boringssl-with-bazel/src/crypto/thread.c +110 -0
  1430. data/third_party/boringssl-with-bazel/src/crypto/thread_none.c +59 -0
  1431. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +210 -0
  1432. data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +260 -0
  1433. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +278 -0
  1434. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +1474 -0
  1435. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +720 -0
  1436. data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.c +96 -0
  1437. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +128 -0
  1438. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +653 -0
  1439. data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +114 -0
  1440. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +153 -0
  1441. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +842 -0
  1442. data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +458 -0
  1443. data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +275 -0
  1444. data/third_party/boringssl-with-bazel/src/crypto/x509/charmap.h +15 -0
  1445. data/third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.c +83 -0
  1446. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +66 -0
  1447. data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +385 -0
  1448. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +125 -0
  1449. data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +244 -0
  1450. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +544 -0
  1451. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +111 -0
  1452. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +71 -0
  1453. data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +157 -0
  1454. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +381 -0
  1455. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +476 -0
  1456. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +106 -0
  1457. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.c +103 -0
  1458. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +206 -0
  1459. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +834 -0
  1460. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +198 -0
  1461. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_r2x.c +116 -0
  1462. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +341 -0
  1463. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +185 -0
  1464. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +326 -0
  1465. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +204 -0
  1466. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +278 -0
  1467. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +2487 -0
  1468. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +671 -0
  1469. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +210 -0
  1470. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +389 -0
  1471. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +81 -0
  1472. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +137 -0
  1473. data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +151 -0
  1474. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +399 -0
  1475. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +111 -0
  1476. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +541 -0
  1477. data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +75 -0
  1478. data/third_party/boringssl-with-bazel/src/crypto/x509/x_info.c +98 -0
  1479. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +554 -0
  1480. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +106 -0
  1481. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +368 -0
  1482. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +109 -0
  1483. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +69 -0
  1484. data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.c +80 -0
  1485. data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +69 -0
  1486. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +334 -0
  1487. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +198 -0
  1488. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +141 -0
  1489. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +56 -0
  1490. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +286 -0
  1491. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +130 -0
  1492. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_int.h +217 -0
  1493. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_lib.c +155 -0
  1494. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +130 -0
  1495. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_node.c +189 -0
  1496. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +842 -0
  1497. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +207 -0
  1498. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akeya.c +72 -0
  1499. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +629 -0
  1500. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bcons.c +133 -0
  1501. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +141 -0
  1502. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +463 -0
  1503. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +503 -0
  1504. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +561 -0
  1505. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +100 -0
  1506. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_extku.c +148 -0
  1507. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +246 -0
  1508. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +122 -0
  1509. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +218 -0
  1510. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_int.c +91 -0
  1511. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +371 -0
  1512. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c +501 -0
  1513. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ocsp.c +68 -0
  1514. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c +288 -0
  1515. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcia.c +57 -0
  1516. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcons.c +139 -0
  1517. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +110 -0
  1518. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pmaps.c +154 -0
  1519. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +229 -0
  1520. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +843 -0
  1521. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +155 -0
  1522. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +274 -0
  1523. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1395 -0
  1524. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +459 -0
  1525. data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +195 -0
  1526. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +121 -0
  1527. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +911 -0
  1528. data/third_party/boringssl-with-bazel/src/include/openssl/asn1_mac.h +18 -0
  1529. data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +892 -0
  1530. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +575 -0
  1531. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +190 -0
  1532. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +933 -0
  1533. data/third_party/boringssl-with-bazel/src/include/openssl/blowfish.h +93 -0
  1534. data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +1057 -0
  1535. data/third_party/boringssl-with-bazel/src/include/openssl/buf.h +137 -0
  1536. data/third_party/boringssl-with-bazel/src/include/openssl/buffer.h +18 -0
  1537. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +561 -0
  1538. data/third_party/boringssl-with-bazel/src/include/openssl/cast.h +96 -0
  1539. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +41 -0
  1540. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +638 -0
  1541. data/third_party/boringssl-with-bazel/src/include/openssl/cmac.h +91 -0
  1542. data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +180 -0
  1543. data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +212 -0
  1544. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +149 -0
  1545. data/third_party/boringssl-with-bazel/src/include/openssl/curve25519.h +201 -0
  1546. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +177 -0
  1547. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +319 -0
  1548. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +331 -0
  1549. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +457 -0
  1550. data/third_party/boringssl-with-bazel/src/include/openssl/dtls1.h +16 -0
  1551. data/third_party/boringssl-with-bazel/src/include/openssl/e_os2.h +18 -0
  1552. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +424 -0
  1553. data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +372 -0
  1554. data/third_party/boringssl-with-bazel/src/include/openssl/ecdh.h +118 -0
  1555. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +205 -0
  1556. data/third_party/boringssl-with-bazel/src/include/openssl/engine.h +109 -0
  1557. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +465 -0
  1558. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +1050 -0
  1559. data/third_party/boringssl-with-bazel/src/include/openssl/ex_data.h +203 -0
  1560. data/third_party/boringssl-with-bazel/src/include/openssl/hkdf.h +64 -0
  1561. data/third_party/boringssl-with-bazel/src/include/openssl/hmac.h +186 -0
  1562. data/third_party/boringssl-with-bazel/src/include/openssl/hrss.h +100 -0
  1563. data/third_party/boringssl-with-bazel/src/include/openssl/is_boringssl.h +16 -0
  1564. data/third_party/boringssl-with-bazel/src/include/openssl/lhash.h +282 -0
  1565. data/third_party/boringssl-with-bazel/src/include/openssl/md4.h +108 -0
  1566. data/third_party/boringssl-with-bazel/src/include/openssl/md5.h +109 -0
  1567. data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +175 -0
  1568. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +4259 -0
  1569. data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +236 -0
  1570. data/third_party/boringssl-with-bazel/src/include/openssl/obj_mac.h +18 -0
  1571. data/third_party/boringssl-with-bazel/src/include/openssl/objects.h +18 -0
  1572. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +67 -0
  1573. data/third_party/boringssl-with-bazel/src/include/openssl/opensslv.h +18 -0
  1574. data/third_party/boringssl-with-bazel/src/include/openssl/ossl_typ.h +18 -0
  1575. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +435 -0
  1576. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs12.h +18 -0
  1577. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +215 -0
  1578. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +269 -0
  1579. data/third_party/boringssl-with-bazel/src/include/openssl/poly1305.h +49 -0
  1580. data/third_party/boringssl-with-bazel/src/include/openssl/pool.h +102 -0
  1581. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +111 -0
  1582. data/third_party/boringssl-with-bazel/src/include/openssl/rc4.h +96 -0
  1583. data/third_party/boringssl-with-bazel/src/include/openssl/ripemd.h +108 -0
  1584. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +818 -0
  1585. data/third_party/boringssl-with-bazel/src/include/openssl/safestack.h +16 -0
  1586. data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +294 -0
  1587. data/third_party/boringssl-with-bazel/src/include/openssl/siphash.h +37 -0
  1588. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +199 -0
  1589. data/third_party/boringssl-with-bazel/src/include/openssl/srtp.h +18 -0
  1590. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +5198 -0
  1591. data/third_party/boringssl-with-bazel/src/include/openssl/ssl3.h +333 -0
  1592. data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +542 -0
  1593. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +191 -0
  1594. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +632 -0
  1595. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +291 -0
  1596. data/third_party/boringssl-with-bazel/src/include/openssl/type_check.h +90 -0
  1597. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +1207 -0
  1598. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +681 -0
  1599. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +831 -0
  1600. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +179 -0
  1601. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +837 -0
  1602. data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +268 -0
  1603. data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +273 -0
  1604. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +232 -0
  1605. data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +200 -0
  1606. data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +353 -0
  1607. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +675 -0
  1608. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +703 -0
  1609. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +1890 -0
  1610. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1805 -0
  1611. data/third_party/boringssl-with-bazel/src/ssl/internal.h +3572 -0
  1612. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +724 -0
  1613. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +221 -0
  1614. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +458 -0
  1615. data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +432 -0
  1616. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +856 -0
  1617. data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +306 -0
  1618. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +1019 -0
  1619. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +1718 -0
  1620. data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +585 -0
  1621. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +397 -0
  1622. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +3015 -0
  1623. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +835 -0
  1624. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +1333 -0
  1625. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +230 -0
  1626. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +277 -0
  1627. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +394 -0
  1628. data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +1358 -0
  1629. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +365 -0
  1630. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +3870 -0
  1631. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +689 -0
  1632. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1017 -0
  1633. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +513 -0
  1634. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +1096 -0
  1635. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +317 -0
  1636. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +703 -0
  1637. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +981 -0
  1638. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +619 -0
  1639. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +3147 -0
  1640. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +1226 -0
  1641. data/third_party/cares/ares_build.h +223 -0
  1642. data/third_party/cares/cares/ares.h +670 -0
  1643. data/third_party/cares/cares/ares__close_sockets.c +61 -0
  1644. data/third_party/cares/cares/ares__get_hostent.c +261 -0
  1645. data/third_party/cares/cares/ares__read_line.c +73 -0
  1646. data/third_party/cares/cares/ares__timeval.c +111 -0
  1647. data/third_party/cares/cares/ares_cancel.c +63 -0
  1648. data/third_party/cares/cares/ares_create_query.c +206 -0
  1649. data/third_party/cares/cares/ares_data.c +222 -0
  1650. data/third_party/cares/cares/ares_data.h +72 -0
  1651. data/third_party/cares/cares/ares_destroy.c +113 -0
  1652. data/third_party/cares/cares/ares_dns.h +103 -0
  1653. data/third_party/cares/cares/ares_expand_name.c +209 -0
  1654. data/third_party/cares/cares/ares_expand_string.c +70 -0
  1655. data/third_party/cares/cares/ares_fds.c +59 -0
  1656. data/third_party/cares/cares/ares_free_hostent.c +41 -0
  1657. data/third_party/cares/cares/ares_free_string.c +25 -0
  1658. data/third_party/cares/cares/ares_getenv.c +30 -0
  1659. data/third_party/cares/cares/ares_getenv.h +26 -0
  1660. data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
  1661. data/third_party/cares/cares/ares_gethostbyname.c +529 -0
  1662. data/third_party/cares/cares/ares_getnameinfo.c +453 -0
  1663. data/third_party/cares/cares/ares_getopt.c +122 -0
  1664. data/third_party/cares/cares/ares_getopt.h +53 -0
  1665. data/third_party/cares/cares/ares_getsock.c +66 -0
  1666. data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
  1667. data/third_party/cares/cares/ares_init.c +2615 -0
  1668. data/third_party/cares/cares/ares_iphlpapi.h +221 -0
  1669. data/third_party/cares/cares/ares_ipv6.h +78 -0
  1670. data/third_party/cares/cares/ares_library_init.c +195 -0
  1671. data/third_party/cares/cares/ares_library_init.h +43 -0
  1672. data/third_party/cares/cares/ares_llist.c +63 -0
  1673. data/third_party/cares/cares/ares_llist.h +39 -0
  1674. data/third_party/cares/cares/ares_mkquery.c +24 -0
  1675. data/third_party/cares/cares/ares_nowarn.c +260 -0
  1676. data/third_party/cares/cares/ares_nowarn.h +61 -0
  1677. data/third_party/cares/cares/ares_options.c +406 -0
  1678. data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
  1679. data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
  1680. data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
  1681. data/third_party/cares/cares/ares_parse_naptr_reply.c +194 -0
  1682. data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
  1683. data/third_party/cares/cares/ares_parse_ptr_reply.c +221 -0
  1684. data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
  1685. data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
  1686. data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
  1687. data/third_party/cares/cares/ares_platform.c +11042 -0
  1688. data/third_party/cares/cares/ares_platform.h +43 -0
  1689. data/third_party/cares/cares/ares_private.h +382 -0
  1690. data/third_party/cares/cares/ares_process.c +1473 -0
  1691. data/third_party/cares/cares/ares_query.c +186 -0
  1692. data/third_party/cares/cares/ares_rules.h +125 -0
  1693. data/third_party/cares/cares/ares_search.c +323 -0
  1694. data/third_party/cares/cares/ares_send.c +137 -0
  1695. data/third_party/cares/cares/ares_setup.h +217 -0
  1696. data/third_party/cares/cares/ares_strcasecmp.c +66 -0
  1697. data/third_party/cares/cares/ares_strcasecmp.h +30 -0
  1698. data/third_party/cares/cares/ares_strdup.c +49 -0
  1699. data/third_party/cares/cares/ares_strdup.h +24 -0
  1700. data/third_party/cares/cares/ares_strerror.c +56 -0
  1701. data/third_party/cares/cares/ares_strsplit.c +174 -0
  1702. data/third_party/cares/cares/ares_strsplit.h +43 -0
  1703. data/third_party/cares/cares/ares_timeout.c +88 -0
  1704. data/third_party/cares/cares/ares_version.c +11 -0
  1705. data/third_party/cares/cares/ares_version.h +24 -0
  1706. data/third_party/cares/cares/ares_writev.c +79 -0
  1707. data/third_party/cares/cares/bitncmp.c +59 -0
  1708. data/third_party/cares/cares/bitncmp.h +26 -0
  1709. data/third_party/cares/cares/config-win32.h +351 -0
  1710. data/third_party/cares/cares/inet_net_pton.c +450 -0
  1711. data/third_party/cares/cares/inet_ntop.c +207 -0
  1712. data/third_party/cares/cares/setup_once.h +554 -0
  1713. data/third_party/cares/cares/windows_port.c +22 -0
  1714. data/third_party/cares/config_darwin/ares_config.h +428 -0
  1715. data/third_party/cares/config_freebsd/ares_config.h +505 -0
  1716. data/third_party/cares/config_linux/ares_config.h +461 -0
  1717. data/third_party/cares/config_openbsd/ares_config.h +505 -0
  1718. data/third_party/upb/upb/decode.c +609 -0
  1719. data/third_party/upb/upb/decode.h +21 -0
  1720. data/third_party/upb/upb/encode.c +378 -0
  1721. data/third_party/upb/upb/encode.h +21 -0
  1722. data/third_party/upb/upb/generated_util.h +105 -0
  1723. data/third_party/upb/upb/msg.c +111 -0
  1724. data/third_party/upb/upb/msg.h +69 -0
  1725. data/third_party/upb/upb/port.c +26 -0
  1726. data/third_party/upb/upb/port_def.inc +150 -0
  1727. data/third_party/upb/upb/port_undef.inc +21 -0
  1728. data/third_party/upb/upb/table.c +913 -0
  1729. data/third_party/upb/upb/table.int.h +507 -0
  1730. data/third_party/upb/upb/upb.c +261 -0
  1731. data/third_party/upb/upb/upb.h +364 -0
  1732. data/third_party/zlib/adler32.c +186 -0
  1733. data/third_party/zlib/compress.c +86 -0
  1734. data/third_party/zlib/crc32.c +442 -0
  1735. data/third_party/zlib/crc32.h +441 -0
  1736. data/third_party/zlib/deflate.c +2163 -0
  1737. data/third_party/zlib/deflate.h +349 -0
  1738. data/third_party/zlib/gzclose.c +25 -0
  1739. data/third_party/zlib/gzguts.h +218 -0
  1740. data/third_party/zlib/gzlib.c +637 -0
  1741. data/third_party/zlib/gzread.c +654 -0
  1742. data/third_party/zlib/gzwrite.c +665 -0
  1743. data/third_party/zlib/infback.c +640 -0
  1744. data/third_party/zlib/inffast.c +323 -0
  1745. data/third_party/zlib/inffast.h +11 -0
  1746. data/third_party/zlib/inffixed.h +94 -0
  1747. data/third_party/zlib/inflate.c +1561 -0
  1748. data/third_party/zlib/inflate.h +125 -0
  1749. data/third_party/zlib/inftrees.c +304 -0
  1750. data/third_party/zlib/inftrees.h +62 -0
  1751. data/third_party/zlib/trees.c +1203 -0
  1752. data/third_party/zlib/trees.h +128 -0
  1753. data/third_party/zlib/uncompr.c +93 -0
  1754. data/third_party/zlib/zconf.h +534 -0
  1755. data/third_party/zlib/zlib.h +1912 -0
  1756. data/third_party/zlib/zutil.c +325 -0
  1757. data/third_party/zlib/zutil.h +271 -0
  1758. metadata +2029 -0
@@ -0,0 +1,3572 @@
1
+ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2
+ * All rights reserved.
3
+ *
4
+ * This package is an SSL implementation written
5
+ * by Eric Young (eay@cryptsoft.com).
6
+ * The implementation was written so as to conform with Netscapes SSL.
7
+ *
8
+ * This library is free for commercial and non-commercial use as long as
9
+ * the following conditions are aheared to. The following conditions
10
+ * apply to all code found in this distribution, be it the RC4, RSA,
11
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12
+ * included with this distribution is covered by the same copyright terms
13
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14
+ *
15
+ * Copyright remains Eric Young's, and as such any Copyright notices in
16
+ * the code are not to be removed.
17
+ * If this package is used in a product, Eric Young should be given attribution
18
+ * as the author of the parts of the library used.
19
+ * This can be in the form of a textual message at program startup or
20
+ * in documentation (online or textual) provided with the package.
21
+ *
22
+ * Redistribution and use in source and binary forms, with or without
23
+ * modification, are permitted provided that the following conditions
24
+ * are met:
25
+ * 1. Redistributions of source code must retain the copyright
26
+ * notice, this list of conditions and the following disclaimer.
27
+ * 2. Redistributions in binary form must reproduce the above copyright
28
+ * notice, this list of conditions and the following disclaimer in the
29
+ * documentation and/or other materials provided with the distribution.
30
+ * 3. All advertising materials mentioning features or use of this software
31
+ * must display the following acknowledgement:
32
+ * "This product includes cryptographic software written by
33
+ * Eric Young (eay@cryptsoft.com)"
34
+ * The word 'cryptographic' can be left out if the rouines from the library
35
+ * being used are not cryptographic related :-).
36
+ * 4. If you include any Windows specific code (or a derivative thereof) from
37
+ * the apps directory (application code) you must include an acknowledgement:
38
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39
+ *
40
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50
+ * SUCH DAMAGE.
51
+ *
52
+ * The licence and distribution terms for any publically available version or
53
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
54
+ * copied and put under another distribution licence
55
+ * [including the GNU Public Licence.]
56
+ */
57
+ /* ====================================================================
58
+ * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
59
+ *
60
+ * Redistribution and use in source and binary forms, with or without
61
+ * modification, are permitted provided that the following conditions
62
+ * are met:
63
+ *
64
+ * 1. Redistributions of source code must retain the above copyright
65
+ * notice, this list of conditions and the following disclaimer.
66
+ *
67
+ * 2. Redistributions in binary form must reproduce the above copyright
68
+ * notice, this list of conditions and the following disclaimer in
69
+ * the documentation and/or other materials provided with the
70
+ * distribution.
71
+ *
72
+ * 3. All advertising materials mentioning features or use of this
73
+ * software must display the following acknowledgment:
74
+ * "This product includes software developed by the OpenSSL Project
75
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
76
+ *
77
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
78
+ * endorse or promote products derived from this software without
79
+ * prior written permission. For written permission, please contact
80
+ * openssl-core@openssl.org.
81
+ *
82
+ * 5. Products derived from this software may not be called "OpenSSL"
83
+ * nor may "OpenSSL" appear in their names without prior written
84
+ * permission of the OpenSSL Project.
85
+ *
86
+ * 6. Redistributions of any form whatsoever must retain the following
87
+ * acknowledgment:
88
+ * "This product includes software developed by the OpenSSL Project
89
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
90
+ *
91
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
92
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
94
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
95
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
97
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
98
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
99
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
100
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
101
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
102
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
103
+ * ====================================================================
104
+ *
105
+ * This product includes cryptographic software written by Eric Young
106
+ * (eay@cryptsoft.com). This product includes software written by Tim
107
+ * Hudson (tjh@cryptsoft.com).
108
+ *
109
+ */
110
+ /* ====================================================================
111
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
112
+ * ECC cipher suite support in OpenSSL originally developed by
113
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
114
+ */
115
+ /* ====================================================================
116
+ * Copyright 2005 Nokia. All rights reserved.
117
+ *
118
+ * The portions of the attached software ("Contribution") is developed by
119
+ * Nokia Corporation and is licensed pursuant to the OpenSSL open source
120
+ * license.
121
+ *
122
+ * The Contribution, originally written by Mika Kousa and Pasi Eronen of
123
+ * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
124
+ * support (see RFC 4279) to OpenSSL.
125
+ *
126
+ * No patent licenses or other rights except those expressly stated in
127
+ * the OpenSSL open source license shall be deemed granted or received
128
+ * expressly, by implication, estoppel, or otherwise.
129
+ *
130
+ * No assurances are provided by Nokia that the Contribution does not
131
+ * infringe the patent or other intellectual property rights of any third
132
+ * party or that the license provides you with all the necessary rights
133
+ * to make use of the Contribution.
134
+ *
135
+ * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
136
+ * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
137
+ * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
138
+ * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
139
+ * OTHERWISE.
140
+ */
141
+
142
+ #ifndef OPENSSL_HEADER_SSL_INTERNAL_H
143
+ #define OPENSSL_HEADER_SSL_INTERNAL_H
144
+
145
+ #include <openssl/base.h>
146
+
147
+ #include <stdlib.h>
148
+
149
+ #include <limits>
150
+ #include <new>
151
+ #include <type_traits>
152
+ #include <utility>
153
+
154
+ #include <openssl/aead.h>
155
+ #include <openssl/err.h>
156
+ #include <openssl/lhash.h>
157
+ #include <openssl/mem.h>
158
+ #include <openssl/span.h>
159
+ #include <openssl/ssl.h>
160
+ #include <openssl/stack.h>
161
+
162
+ #include "../crypto/err/internal.h"
163
+ #include "../crypto/internal.h"
164
+
165
+
166
+ #if defined(OPENSSL_WINDOWS)
167
+ // Windows defines struct timeval in winsock2.h.
168
+ OPENSSL_MSVC_PRAGMA(warning(push, 3))
169
+ #include <winsock2.h>
170
+ OPENSSL_MSVC_PRAGMA(warning(pop))
171
+ #else
172
+ #include <sys/time.h>
173
+ #endif
174
+
175
+
176
+ BSSL_NAMESPACE_BEGIN
177
+
178
+ struct SSL_CONFIG;
179
+ struct SSL_HANDSHAKE;
180
+ struct SSL_PROTOCOL_METHOD;
181
+ struct SSL_X509_METHOD;
182
+
183
+ // C++ utilities.
184
+
185
+ // New behaves like |new| but uses |OPENSSL_malloc| for memory allocation. It
186
+ // returns nullptr on allocation error. It only implements single-object
187
+ // allocation and not new T[n].
188
+ //
189
+ // Note: unlike |new|, this does not support non-public constructors.
190
+ template <typename T, typename... Args>
191
+ T *New(Args &&... args) {
192
+ void *t = OPENSSL_malloc(sizeof(T));
193
+ if (t == nullptr) {
194
+ OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
195
+ return nullptr;
196
+ }
197
+ return new (t) T(std::forward<Args>(args)...);
198
+ }
199
+
200
+ // Delete behaves like |delete| but uses |OPENSSL_free| to release memory.
201
+ //
202
+ // Note: unlike |delete| this does not support non-public destructors.
203
+ template <typename T>
204
+ void Delete(T *t) {
205
+ if (t != nullptr) {
206
+ t->~T();
207
+ OPENSSL_free(t);
208
+ }
209
+ }
210
+
211
+ // All types with kAllowUniquePtr set may be used with UniquePtr. Other types
212
+ // may be C structs which require a |BORINGSSL_MAKE_DELETER| registration.
213
+ namespace internal {
214
+ template <typename T>
215
+ struct DeleterImpl<T, typename std::enable_if<T::kAllowUniquePtr>::type> {
216
+ static void Free(T *t) { Delete(t); }
217
+ };
218
+ } // namespace internal
219
+
220
+ // MakeUnique behaves like |std::make_unique| but returns nullptr on allocation
221
+ // error.
222
+ template <typename T, typename... Args>
223
+ UniquePtr<T> MakeUnique(Args &&... args) {
224
+ return UniquePtr<T>(New<T>(std::forward<Args>(args)...));
225
+ }
226
+
227
+ #if defined(BORINGSSL_ALLOW_CXX_RUNTIME)
228
+ #define HAS_VIRTUAL_DESTRUCTOR
229
+ #define PURE_VIRTUAL = 0
230
+ #else
231
+ // HAS_VIRTUAL_DESTRUCTOR should be declared in any base class which defines a
232
+ // virtual destructor. This avoids a dependency on |_ZdlPv| and prevents the
233
+ // class from being used with |delete|.
234
+ #define HAS_VIRTUAL_DESTRUCTOR \
235
+ void operator delete(void *) { abort(); }
236
+
237
+ // PURE_VIRTUAL should be used instead of = 0 when defining pure-virtual
238
+ // functions. This avoids a dependency on |__cxa_pure_virtual| but loses
239
+ // compile-time checking.
240
+ #define PURE_VIRTUAL \
241
+ { abort(); }
242
+ #endif
243
+
244
+ // CONSTEXPR_ARRAY works around a VS 2015 bug where ranged for loops don't work
245
+ // on constexpr arrays.
246
+ #if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER < 1910
247
+ #define CONSTEXPR_ARRAY const
248
+ #else
249
+ #define CONSTEXPR_ARRAY constexpr
250
+ #endif
251
+
252
+ // Array<T> is an owning array of elements of |T|.
253
+ template <typename T>
254
+ class Array {
255
+ public:
256
+ // Array's default constructor creates an empty array.
257
+ Array() {}
258
+ Array(const Array &) = delete;
259
+ Array(Array &&other) { *this = std::move(other); }
260
+
261
+ ~Array() { Reset(); }
262
+
263
+ Array &operator=(const Array &) = delete;
264
+ Array &operator=(Array &&other) {
265
+ Reset();
266
+ other.Release(&data_, &size_);
267
+ return *this;
268
+ }
269
+
270
+ const T *data() const { return data_; }
271
+ T *data() { return data_; }
272
+ size_t size() const { return size_; }
273
+ bool empty() const { return size_ == 0; }
274
+
275
+ const T &operator[](size_t i) const { return data_[i]; }
276
+ T &operator[](size_t i) { return data_[i]; }
277
+
278
+ T *begin() { return data_; }
279
+ const T *cbegin() const { return data_; }
280
+ T *end() { return data_ + size_; }
281
+ const T *cend() const { return data_ + size_; }
282
+
283
+ void Reset() { Reset(nullptr, 0); }
284
+
285
+ // Reset releases the current contents of the array and takes ownership of the
286
+ // raw pointer supplied by the caller.
287
+ void Reset(T *new_data, size_t new_size) {
288
+ for (size_t i = 0; i < size_; i++) {
289
+ data_[i].~T();
290
+ }
291
+ OPENSSL_free(data_);
292
+ data_ = new_data;
293
+ size_ = new_size;
294
+ }
295
+
296
+ // Release releases ownership of the array to a raw pointer supplied by the
297
+ // caller.
298
+ void Release(T **out, size_t *out_size) {
299
+ *out = data_;
300
+ *out_size = size_;
301
+ data_ = nullptr;
302
+ size_ = 0;
303
+ }
304
+
305
+ // Init replaces the array with a newly-allocated array of |new_size|
306
+ // default-constructed copies of |T|. It returns true on success and false on
307
+ // error.
308
+ //
309
+ // Note that if |T| is a primitive type like |uint8_t|, it is uninitialized.
310
+ bool Init(size_t new_size) {
311
+ Reset();
312
+ if (new_size == 0) {
313
+ return true;
314
+ }
315
+
316
+ if (new_size > std::numeric_limits<size_t>::max() / sizeof(T)) {
317
+ OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
318
+ return false;
319
+ }
320
+ data_ = reinterpret_cast<T *>(OPENSSL_malloc(new_size * sizeof(T)));
321
+ if (data_ == nullptr) {
322
+ OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
323
+ return false;
324
+ }
325
+ size_ = new_size;
326
+ for (size_t i = 0; i < size_; i++) {
327
+ new (&data_[i]) T;
328
+ }
329
+ return true;
330
+ }
331
+
332
+ // CopyFrom replaces the array with a newly-allocated copy of |in|. It returns
333
+ // true on success and false on error.
334
+ bool CopyFrom(Span<const T> in) {
335
+ if (!Init(in.size())) {
336
+ return false;
337
+ }
338
+ OPENSSL_memcpy(data_, in.data(), sizeof(T) * in.size());
339
+ return true;
340
+ }
341
+
342
+ // Shrink shrinks the stored size of the array to |new_size|. It crashes if
343
+ // the new size is larger. Note this does not shrink the allocation itself.
344
+ void Shrink(size_t new_size) {
345
+ if (new_size > size_) {
346
+ abort();
347
+ }
348
+ size_ = new_size;
349
+ }
350
+
351
+ private:
352
+ T *data_ = nullptr;
353
+ size_t size_ = 0;
354
+ };
355
+
356
+ // GrowableArray<T> is an array that owns elements of |T|, backed by an
357
+ // Array<T>. When necessary, pushing will automatically trigger a resize.
358
+ //
359
+ // Note, for simplicity, this class currently differs from |std::vector| in that
360
+ // |T| must be efficiently default-constructible. Allocated elements beyond the
361
+ // end of the array are constructed and destructed.
362
+ template <typename T>
363
+ class GrowableArray {
364
+ public:
365
+ GrowableArray() = default;
366
+ GrowableArray(const GrowableArray &) = delete;
367
+ GrowableArray(GrowableArray &&other) { *this = std::move(other); }
368
+ ~GrowableArray() {}
369
+
370
+ GrowableArray &operator=(const GrowableArray &) = delete;
371
+ GrowableArray &operator=(GrowableArray &&other) {
372
+ size_ = other.size_;
373
+ other.size_ = 0;
374
+ array_ = std::move(other.array_);
375
+ return *this;
376
+ }
377
+
378
+ size_t size() const { return size_; }
379
+ bool empty() const { return size_ == 0; }
380
+
381
+ const T &operator[](size_t i) const { return array_[i]; }
382
+ T &operator[](size_t i) { return array_[i]; }
383
+
384
+ T *begin() { return array_.data(); }
385
+ const T *cbegin() const { return array_.data(); }
386
+ T *end() { return array_.data() + size_; }
387
+ const T *cend() const { return array_.data() + size_; }
388
+
389
+ // Push adds |elem| at the end of the internal array, growing if necessary. It
390
+ // returns false when allocation fails.
391
+ bool Push(T elem) {
392
+ if (!MaybeGrow()) {
393
+ return false;
394
+ }
395
+ array_[size_] = std::move(elem);
396
+ size_++;
397
+ return true;
398
+ }
399
+
400
+ // CopyFrom replaces the contents of the array with a copy of |in|. It returns
401
+ // true on success and false on allocation error.
402
+ bool CopyFrom(Span<const T> in) {
403
+ if (!array_.CopyFrom(in)) {
404
+ return false;
405
+ }
406
+ size_ = in.size();
407
+ return true;
408
+ }
409
+
410
+ private:
411
+ // If there is no room for one more element, creates a new backing array with
412
+ // double the size of the old one and copies elements over.
413
+ bool MaybeGrow() {
414
+ if (array_.size() == 0) {
415
+ return array_.Init(kDefaultSize);
416
+ }
417
+ // No need to grow if we have room for one more T.
418
+ if (size_ < array_.size()) {
419
+ return true;
420
+ }
421
+ // Double the array's size if it's safe to do so.
422
+ if (array_.size() > std::numeric_limits<size_t>::max() / 2) {
423
+ OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
424
+ return false;
425
+ }
426
+ Array<T> new_array;
427
+ if (!new_array.Init(array_.size() * 2)) {
428
+ return false;
429
+ }
430
+ for (size_t i = 0; i < array_.size(); i++) {
431
+ new_array[i] = std::move(array_[i]);
432
+ }
433
+ array_ = std::move(new_array);
434
+
435
+ return true;
436
+ }
437
+
438
+ // |size_| is the number of elements stored in this GrowableArray.
439
+ size_t size_ = 0;
440
+ // |array_| is the backing array. Note that |array_.size()| is this
441
+ // GrowableArray's current capacity and that |size_ <= array_.size()|.
442
+ Array<T> array_;
443
+ // |kDefaultSize| is the default initial size of the backing array.
444
+ static constexpr size_t kDefaultSize = 16;
445
+ };
446
+
447
+ // CBBFinishArray behaves like |CBB_finish| but stores the result in an Array.
448
+ OPENSSL_EXPORT bool CBBFinishArray(CBB *cbb, Array<uint8_t> *out);
449
+
450
+
451
+ // Protocol versions.
452
+ //
453
+ // Due to DTLS's historical wire version differences, we maintain two notions of
454
+ // version.
455
+ //
456
+ // The "version" or "wire version" is the actual 16-bit value that appears on
457
+ // the wire. It uniquely identifies a version and is also used at API
458
+ // boundaries. The set of supported versions differs between TLS and DTLS. Wire
459
+ // versions are opaque values and may not be compared numerically.
460
+ //
461
+ // The "protocol version" identifies the high-level handshake variant being
462
+ // used. DTLS versions map to the corresponding TLS versions. Protocol versions
463
+ // are sequential and may be compared numerically.
464
+
465
+ // ssl_protocol_version_from_wire sets |*out| to the protocol version
466
+ // corresponding to wire version |version| and returns true. If |version| is not
467
+ // a valid TLS or DTLS version, it returns false.
468
+ //
469
+ // Note this simultaneously handles both DTLS and TLS. Use one of the
470
+ // higher-level functions below for most operations.
471
+ bool ssl_protocol_version_from_wire(uint16_t *out, uint16_t version);
472
+
473
+ // ssl_get_version_range sets |*out_min_version| and |*out_max_version| to the
474
+ // minimum and maximum enabled protocol versions, respectively.
475
+ bool ssl_get_version_range(const SSL_HANDSHAKE *hs, uint16_t *out_min_version,
476
+ uint16_t *out_max_version);
477
+
478
+ // ssl_supports_version returns whether |hs| supports |version|.
479
+ bool ssl_supports_version(SSL_HANDSHAKE *hs, uint16_t version);
480
+
481
+ // ssl_method_supports_version returns whether |method| supports |version|.
482
+ bool ssl_method_supports_version(const SSL_PROTOCOL_METHOD *method,
483
+ uint16_t version);
484
+
485
+ // ssl_add_supported_versions writes the supported versions of |hs| to |cbb|, in
486
+ // decreasing preference order.
487
+ bool ssl_add_supported_versions(SSL_HANDSHAKE *hs, CBB *cbb);
488
+
489
+ // ssl_negotiate_version negotiates a common version based on |hs|'s preferences
490
+ // and the peer preference list in |peer_versions|. On success, it returns true
491
+ // and sets |*out_version| to the selected version. Otherwise, it returns false
492
+ // and sets |*out_alert| to an alert to send.
493
+ bool ssl_negotiate_version(SSL_HANDSHAKE *hs, uint8_t *out_alert,
494
+ uint16_t *out_version, const CBS *peer_versions);
495
+
496
+ // ssl_protocol_version returns |ssl|'s protocol version. It is an error to
497
+ // call this function before the version is determined.
498
+ uint16_t ssl_protocol_version(const SSL *ssl);
499
+
500
+ // Cipher suites.
501
+
502
+ BSSL_NAMESPACE_END
503
+
504
+ struct ssl_cipher_st {
505
+ // name is the OpenSSL name for the cipher.
506
+ const char *name;
507
+ // standard_name is the IETF name for the cipher.
508
+ const char *standard_name;
509
+ // id is the cipher suite value bitwise OR-d with 0x03000000.
510
+ uint32_t id;
511
+
512
+ // algorithm_* determine the cipher suite. See constants below for the values.
513
+ uint32_t algorithm_mkey;
514
+ uint32_t algorithm_auth;
515
+ uint32_t algorithm_enc;
516
+ uint32_t algorithm_mac;
517
+ uint32_t algorithm_prf;
518
+ };
519
+
520
+ BSSL_NAMESPACE_BEGIN
521
+
522
+ // Bits for |algorithm_mkey| (key exchange algorithm).
523
+ #define SSL_kRSA 0x00000001u
524
+ #define SSL_kECDHE 0x00000002u
525
+ // SSL_kPSK is only set for plain PSK, not ECDHE_PSK.
526
+ #define SSL_kPSK 0x00000004u
527
+ #define SSL_kGENERIC 0x00000008u
528
+
529
+ // Bits for |algorithm_auth| (server authentication).
530
+ #define SSL_aRSA 0x00000001u
531
+ #define SSL_aECDSA 0x00000002u
532
+ // SSL_aPSK is set for both PSK and ECDHE_PSK.
533
+ #define SSL_aPSK 0x00000004u
534
+ #define SSL_aGENERIC 0x00000008u
535
+
536
+ #define SSL_aCERT (SSL_aRSA | SSL_aECDSA)
537
+
538
+ // Bits for |algorithm_enc| (symmetric encryption).
539
+ #define SSL_3DES 0x00000001u
540
+ #define SSL_AES128 0x00000002u
541
+ #define SSL_AES256 0x00000004u
542
+ #define SSL_AES128GCM 0x00000008u
543
+ #define SSL_AES256GCM 0x00000010u
544
+ #define SSL_eNULL 0x00000020u
545
+ #define SSL_CHACHA20POLY1305 0x00000040u
546
+
547
+ #define SSL_AES (SSL_AES128 | SSL_AES256 | SSL_AES128GCM | SSL_AES256GCM)
548
+
549
+ // Bits for |algorithm_mac| (symmetric authentication).
550
+ #define SSL_SHA1 0x00000001u
551
+ // SSL_AEAD is set for all AEADs.
552
+ #define SSL_AEAD 0x00000002u
553
+
554
+ // Bits for |algorithm_prf| (handshake digest).
555
+ #define SSL_HANDSHAKE_MAC_DEFAULT 0x1
556
+ #define SSL_HANDSHAKE_MAC_SHA256 0x2
557
+ #define SSL_HANDSHAKE_MAC_SHA384 0x4
558
+
559
+ // SSL_MAX_MD_SIZE is size of the largest hash function used in TLS, SHA-384.
560
+ #define SSL_MAX_MD_SIZE 48
561
+
562
+ // An SSLCipherPreferenceList contains a list of SSL_CIPHERs with equal-
563
+ // preference groups. For TLS clients, the groups are moot because the server
564
+ // picks the cipher and groups cannot be expressed on the wire. However, for
565
+ // servers, the equal-preference groups allow the client's preferences to be
566
+ // partially respected. (This only has an effect with
567
+ // SSL_OP_CIPHER_SERVER_PREFERENCE).
568
+ //
569
+ // The equal-preference groups are expressed by grouping SSL_CIPHERs together.
570
+ // All elements of a group have the same priority: no ordering is expressed
571
+ // within a group.
572
+ //
573
+ // The values in |ciphers| are in one-to-one correspondence with
574
+ // |in_group_flags|. (That is, sk_SSL_CIPHER_num(ciphers) is the number of
575
+ // bytes in |in_group_flags|.) The bytes in |in_group_flags| are either 1, to
576
+ // indicate that the corresponding SSL_CIPHER is not the last element of a
577
+ // group, or 0 to indicate that it is.
578
+ //
579
+ // For example, if |in_group_flags| contains all zeros then that indicates a
580
+ // traditional, fully-ordered preference. Every SSL_CIPHER is the last element
581
+ // of the group (i.e. they are all in a one-element group).
582
+ //
583
+ // For a more complex example, consider:
584
+ // ciphers: A B C D E F
585
+ // in_group_flags: 1 1 0 0 1 0
586
+ //
587
+ // That would express the following, order:
588
+ //
589
+ // A E
590
+ // B -> D -> F
591
+ // C
592
+ struct SSLCipherPreferenceList {
593
+ static constexpr bool kAllowUniquePtr = true;
594
+
595
+ SSLCipherPreferenceList() = default;
596
+ ~SSLCipherPreferenceList();
597
+
598
+ bool Init(UniquePtr<STACK_OF(SSL_CIPHER)> ciphers,
599
+ Span<const bool> in_group_flags);
600
+ bool Init(const SSLCipherPreferenceList &);
601
+
602
+ void Remove(const SSL_CIPHER *cipher);
603
+
604
+ UniquePtr<STACK_OF(SSL_CIPHER)> ciphers;
605
+ bool *in_group_flags = nullptr;
606
+ };
607
+
608
+ // AllCiphers returns an array of all supported ciphers, sorted by id.
609
+ Span<const SSL_CIPHER> AllCiphers();
610
+
611
+ // ssl_cipher_get_evp_aead sets |*out_aead| to point to the correct EVP_AEAD
612
+ // object for |cipher| protocol version |version|. It sets |*out_mac_secret_len|
613
+ // and |*out_fixed_iv_len| to the MAC key length and fixed IV length,
614
+ // respectively. The MAC key length is zero except for legacy block and stream
615
+ // ciphers. It returns true on success and false on error.
616
+ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
617
+ size_t *out_mac_secret_len,
618
+ size_t *out_fixed_iv_len, const SSL_CIPHER *cipher,
619
+ uint16_t version, bool is_dtls);
620
+
621
+ // ssl_get_handshake_digest returns the |EVP_MD| corresponding to |version| and
622
+ // |cipher|.
623
+ const EVP_MD *ssl_get_handshake_digest(uint16_t version,
624
+ const SSL_CIPHER *cipher);
625
+
626
+ // ssl_create_cipher_list evaluates |rule_str|. It sets |*out_cipher_list| to a
627
+ // newly-allocated |SSLCipherPreferenceList| containing the result. It returns
628
+ // true on success and false on failure. If |strict| is true, nonsense will be
629
+ // rejected. If false, nonsense will be silently ignored. An empty result is
630
+ // considered an error regardless of |strict|.
631
+ bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
632
+ const char *rule_str, bool strict);
633
+
634
+ // ssl_cipher_get_value returns the cipher suite id of |cipher|.
635
+ uint16_t ssl_cipher_get_value(const SSL_CIPHER *cipher);
636
+
637
+ // ssl_cipher_auth_mask_for_key returns the mask of cipher |algorithm_auth|
638
+ // values suitable for use with |key| in TLS 1.2 and below.
639
+ uint32_t ssl_cipher_auth_mask_for_key(const EVP_PKEY *key);
640
+
641
+ // ssl_cipher_uses_certificate_auth returns whether |cipher| authenticates the
642
+ // server and, optionally, the client with a certificate.
643
+ bool ssl_cipher_uses_certificate_auth(const SSL_CIPHER *cipher);
644
+
645
+ // ssl_cipher_requires_server_key_exchange returns whether |cipher| requires a
646
+ // ServerKeyExchange message.
647
+ //
648
+ // This function may return false while still allowing |cipher| an optional
649
+ // ServerKeyExchange. This is the case for plain PSK ciphers.
650
+ bool ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
651
+
652
+ // ssl_cipher_get_record_split_len, for TLS 1.0 CBC mode ciphers, returns the
653
+ // length of an encrypted 1-byte record, for use in record-splitting. Otherwise
654
+ // it returns zero.
655
+ size_t ssl_cipher_get_record_split_len(const SSL_CIPHER *cipher);
656
+
657
+ // ssl_choose_tls13_cipher returns an |SSL_CIPHER| corresponding with the best
658
+ // available from |cipher_suites| compatible with |version| and |group_id|. It
659
+ // returns NULL if there isn't a compatible cipher.
660
+ const SSL_CIPHER *ssl_choose_tls13_cipher(CBS cipher_suites, uint16_t version,
661
+ uint16_t group_id);
662
+
663
+
664
+ // Transcript layer.
665
+
666
+ // SSLTranscript maintains the handshake transcript as a combination of a
667
+ // buffer and running hash.
668
+ class SSLTranscript {
669
+ public:
670
+ SSLTranscript();
671
+ ~SSLTranscript();
672
+
673
+ // Init initializes the handshake transcript. If called on an existing
674
+ // transcript, it resets the transcript and hash. It returns true on success
675
+ // and false on failure.
676
+ bool Init();
677
+
678
+ // InitHash initializes the handshake hash based on the PRF and contents of
679
+ // the handshake transcript. Subsequent calls to |Update| will update the
680
+ // rolling hash. It returns one on success and zero on failure. It is an error
681
+ // to call this function after the handshake buffer is released.
682
+ bool InitHash(uint16_t version, const SSL_CIPHER *cipher);
683
+
684
+ // UpdateForHelloRetryRequest resets the rolling hash with the
685
+ // HelloRetryRequest construction. It returns true on success and false on
686
+ // failure. It is an error to call this function before the handshake buffer
687
+ // is released.
688
+ bool UpdateForHelloRetryRequest();
689
+
690
+ // CopyToHashContext initializes |ctx| with |digest| and the data thus far in
691
+ // the transcript. It returns true on success and false on failure. If the
692
+ // handshake buffer is still present, |digest| may be any supported digest.
693
+ // Otherwise, |digest| must match the transcript hash.
694
+ bool CopyToHashContext(EVP_MD_CTX *ctx, const EVP_MD *digest);
695
+
696
+ Span<const uint8_t> buffer() {
697
+ return MakeConstSpan(reinterpret_cast<const uint8_t *>(buffer_->data),
698
+ buffer_->length);
699
+ }
700
+
701
+ // FreeBuffer releases the handshake buffer. Subsequent calls to
702
+ // |Update| will not update the handshake buffer.
703
+ void FreeBuffer();
704
+
705
+ // DigestLen returns the length of the PRF hash.
706
+ size_t DigestLen() const;
707
+
708
+ // Digest returns the PRF hash. For TLS 1.1 and below, this is
709
+ // |EVP_md5_sha1|.
710
+ const EVP_MD *Digest() const;
711
+
712
+ // Update adds |in| to the handshake buffer and handshake hash, whichever is
713
+ // enabled. It returns true on success and false on failure.
714
+ bool Update(Span<const uint8_t> in);
715
+
716
+ // GetHash writes the handshake hash to |out| which must have room for at
717
+ // least |DigestLen| bytes. On success, it returns true and sets |*out_len| to
718
+ // the number of bytes written. Otherwise, it returns false.
719
+ bool GetHash(uint8_t *out, size_t *out_len);
720
+
721
+ // GetFinishedMAC computes the MAC for the Finished message into the bytes
722
+ // pointed by |out| and writes the number of bytes to |*out_len|. |out| must
723
+ // have room for |EVP_MAX_MD_SIZE| bytes. It returns true on success and false
724
+ // on failure.
725
+ bool GetFinishedMAC(uint8_t *out, size_t *out_len, const SSL_SESSION *session,
726
+ bool from_server);
727
+
728
+ private:
729
+ // buffer_, if non-null, contains the handshake transcript.
730
+ UniquePtr<BUF_MEM> buffer_;
731
+ // hash, if initialized with an |EVP_MD|, maintains the handshake hash.
732
+ ScopedEVP_MD_CTX hash_;
733
+ };
734
+
735
+ // tls1_prf computes the PRF function for |ssl|. It fills |out|, using |secret|
736
+ // as the secret and |label| as the label. |seed1| and |seed2| are concatenated
737
+ // to form the seed parameter. It returns true on success and false on failure.
738
+ bool tls1_prf(const EVP_MD *digest, Span<uint8_t> out,
739
+ Span<const uint8_t> secret, Span<const char> label,
740
+ Span<const uint8_t> seed1, Span<const uint8_t> seed2);
741
+
742
+
743
+ // Encryption layer.
744
+
745
+ // SSLAEADContext contains information about an AEAD that is being used to
746
+ // encrypt an SSL connection.
747
+ class SSLAEADContext {
748
+ public:
749
+ SSLAEADContext(uint16_t version, bool is_dtls, const SSL_CIPHER *cipher);
750
+ ~SSLAEADContext();
751
+ static constexpr bool kAllowUniquePtr = true;
752
+
753
+ SSLAEADContext(const SSLAEADContext &&) = delete;
754
+ SSLAEADContext &operator=(const SSLAEADContext &&) = delete;
755
+
756
+ // CreateNullCipher creates an |SSLAEADContext| for the null cipher.
757
+ static UniquePtr<SSLAEADContext> CreateNullCipher(bool is_dtls);
758
+
759
+ // Create creates an |SSLAEADContext| using the supplied key material. It
760
+ // returns nullptr on error. Only one of |Open| or |Seal| may be used with the
761
+ // resulting object, depending on |direction|. |version| is the normalized
762
+ // protocol version, so DTLS 1.0 is represented as 0x0301, not 0xffef.
763
+ static UniquePtr<SSLAEADContext> Create(enum evp_aead_direction_t direction,
764
+ uint16_t version, bool is_dtls,
765
+ const SSL_CIPHER *cipher,
766
+ Span<const uint8_t> enc_key,
767
+ Span<const uint8_t> mac_key,
768
+ Span<const uint8_t> fixed_iv);
769
+
770
+ // CreatePlaceholderForQUIC creates a placeholder |SSLAEADContext| for the
771
+ // given cipher and version. The resulting object can be queried for various
772
+ // properties but cannot encrypt or decrypt data.
773
+ static UniquePtr<SSLAEADContext> CreatePlaceholderForQUIC(
774
+ uint16_t version, const SSL_CIPHER *cipher);
775
+
776
+ // SetVersionIfNullCipher sets the version the SSLAEADContext for the null
777
+ // cipher, to make version-specific determinations in the record layer prior
778
+ // to a cipher being selected.
779
+ void SetVersionIfNullCipher(uint16_t version);
780
+
781
+ // ProtocolVersion returns the protocol version associated with this
782
+ // SSLAEADContext. It can only be called once |version_| has been set to a
783
+ // valid value.
784
+ uint16_t ProtocolVersion() const;
785
+
786
+ // RecordVersion returns the record version that should be used with this
787
+ // SSLAEADContext for record construction and crypto.
788
+ uint16_t RecordVersion() const;
789
+
790
+ const SSL_CIPHER *cipher() const { return cipher_; }
791
+
792
+ // is_null_cipher returns true if this is the null cipher.
793
+ bool is_null_cipher() const { return !cipher_; }
794
+
795
+ // ExplicitNonceLen returns the length of the explicit nonce.
796
+ size_t ExplicitNonceLen() const;
797
+
798
+ // MaxOverhead returns the maximum overhead of calling |Seal|.
799
+ size_t MaxOverhead() const;
800
+
801
+ // SuffixLen calculates the suffix length written by |SealScatter| and writes
802
+ // it to |*out_suffix_len|. It returns true on success and false on error.
803
+ // |in_len| and |extra_in_len| should equal the argument of the same names
804
+ // passed to |SealScatter|.
805
+ bool SuffixLen(size_t *out_suffix_len, size_t in_len,
806
+ size_t extra_in_len) const;
807
+
808
+ // CiphertextLen calculates the total ciphertext length written by
809
+ // |SealScatter| and writes it to |*out_len|. It returns true on success and
810
+ // false on error. |in_len| and |extra_in_len| should equal the argument of
811
+ // the same names passed to |SealScatter|.
812
+ bool CiphertextLen(size_t *out_len, size_t in_len, size_t extra_in_len) const;
813
+
814
+ // Open authenticates and decrypts |in| in-place. On success, it sets |*out|
815
+ // to the plaintext in |in| and returns true. Otherwise, it returns
816
+ // false. The output will always be |ExplicitNonceLen| bytes ahead of |in|.
817
+ bool Open(Span<uint8_t> *out, uint8_t type, uint16_t record_version,
818
+ const uint8_t seqnum[8], Span<const uint8_t> header,
819
+ Span<uint8_t> in);
820
+
821
+ // Seal encrypts and authenticates |in_len| bytes from |in| and writes the
822
+ // result to |out|. It returns true on success and false on error.
823
+ //
824
+ // If |in| and |out| alias then |out| + |ExplicitNonceLen| must be == |in|.
825
+ bool Seal(uint8_t *out, size_t *out_len, size_t max_out, uint8_t type,
826
+ uint16_t record_version, const uint8_t seqnum[8],
827
+ Span<const uint8_t> header, const uint8_t *in, size_t in_len);
828
+
829
+ // SealScatter encrypts and authenticates |in_len| bytes from |in| and splits
830
+ // the result between |out_prefix|, |out| and |out_suffix|. It returns one on
831
+ // success and zero on error.
832
+ //
833
+ // On successful return, exactly |ExplicitNonceLen| bytes are written to
834
+ // |out_prefix|, |in_len| bytes to |out|, and |SuffixLen| bytes to
835
+ // |out_suffix|.
836
+ //
837
+ // |extra_in| may point to an additional plaintext buffer. If present,
838
+ // |extra_in_len| additional bytes are encrypted and authenticated, and the
839
+ // ciphertext is written to the beginning of |out_suffix|. |SuffixLen| should
840
+ // be used to size |out_suffix| accordingly.
841
+ //
842
+ // If |in| and |out| alias then |out| must be == |in|. Other arguments may not
843
+ // alias anything.
844
+ bool SealScatter(uint8_t *out_prefix, uint8_t *out, uint8_t *out_suffix,
845
+ uint8_t type, uint16_t record_version,
846
+ const uint8_t seqnum[8], Span<const uint8_t> header,
847
+ const uint8_t *in, size_t in_len, const uint8_t *extra_in,
848
+ size_t extra_in_len);
849
+
850
+ bool GetIV(const uint8_t **out_iv, size_t *out_iv_len) const;
851
+
852
+ private:
853
+ // GetAdditionalData returns the additional data, writing into |storage| if
854
+ // necessary.
855
+ Span<const uint8_t> GetAdditionalData(uint8_t storage[13], uint8_t type,
856
+ uint16_t record_version,
857
+ const uint8_t seqnum[8],
858
+ size_t plaintext_len,
859
+ Span<const uint8_t> header);
860
+
861
+ const SSL_CIPHER *cipher_;
862
+ ScopedEVP_AEAD_CTX ctx_;
863
+ // fixed_nonce_ contains any bytes of the nonce that are fixed for all
864
+ // records.
865
+ uint8_t fixed_nonce_[12];
866
+ uint8_t fixed_nonce_len_ = 0, variable_nonce_len_ = 0;
867
+ // version_ is the wire version that should be used with this AEAD.
868
+ uint16_t version_;
869
+ // is_dtls_ is whether DTLS is being used with this AEAD.
870
+ bool is_dtls_;
871
+ // variable_nonce_included_in_record_ is true if the variable nonce
872
+ // for a record is included as a prefix before the ciphertext.
873
+ bool variable_nonce_included_in_record_ : 1;
874
+ // random_variable_nonce_ is true if the variable nonce is
875
+ // randomly generated, rather than derived from the sequence
876
+ // number.
877
+ bool random_variable_nonce_ : 1;
878
+ // xor_fixed_nonce_ is true if the fixed nonce should be XOR'd into the
879
+ // variable nonce rather than prepended.
880
+ bool xor_fixed_nonce_ : 1;
881
+ // omit_length_in_ad_ is true if the length should be omitted in the
882
+ // AEAD's ad parameter.
883
+ bool omit_length_in_ad_ : 1;
884
+ // ad_is_header_ is true if the AEAD's ad parameter is the record header.
885
+ bool ad_is_header_ : 1;
886
+ };
887
+
888
+
889
+ // DTLS replay bitmap.
890
+
891
+ // DTLS1_BITMAP maintains a sliding window of 64 sequence numbers to detect
892
+ // replayed packets. It should be initialized by zeroing every field.
893
+ struct DTLS1_BITMAP {
894
+ // map is a bit mask of the last 64 sequence numbers. Bit
895
+ // |1<<i| corresponds to |max_seq_num - i|.
896
+ uint64_t map = 0;
897
+ // max_seq_num is the largest sequence number seen so far as a 64-bit
898
+ // integer.
899
+ uint64_t max_seq_num = 0;
900
+ };
901
+
902
+
903
+ // Record layer.
904
+
905
+ // ssl_record_sequence_update increments the sequence number in |seq|. It
906
+ // returns true on success and false on wraparound.
907
+ bool ssl_record_sequence_update(uint8_t *seq, size_t seq_len);
908
+
909
+ // ssl_record_prefix_len returns the length of the prefix before the ciphertext
910
+ // of a record for |ssl|.
911
+ //
912
+ // TODO(davidben): Expose this as part of public API once the high-level
913
+ // buffer-free APIs are available.
914
+ size_t ssl_record_prefix_len(const SSL *ssl);
915
+
916
+ enum ssl_open_record_t {
917
+ ssl_open_record_success,
918
+ ssl_open_record_discard,
919
+ ssl_open_record_partial,
920
+ ssl_open_record_close_notify,
921
+ ssl_open_record_error,
922
+ };
923
+
924
+ // tls_open_record decrypts a record from |in| in-place.
925
+ //
926
+ // If the input did not contain a complete record, it returns
927
+ // |ssl_open_record_partial|. It sets |*out_consumed| to the total number of
928
+ // bytes necessary. It is guaranteed that a successful call to |tls_open_record|
929
+ // will consume at least that many bytes.
930
+ //
931
+ // Otherwise, it sets |*out_consumed| to the number of bytes of input
932
+ // consumed. Note that input may be consumed on all return codes if a record was
933
+ // decrypted.
934
+ //
935
+ // On success, it returns |ssl_open_record_success|. It sets |*out_type| to the
936
+ // record type and |*out| to the record body in |in|. Note that |*out| may be
937
+ // empty.
938
+ //
939
+ // If a record was successfully processed but should be discarded, it returns
940
+ // |ssl_open_record_discard|.
941
+ //
942
+ // If a record was successfully processed but is a close_notify, it returns
943
+ // |ssl_open_record_close_notify|.
944
+ //
945
+ // On failure or fatal alert, it returns |ssl_open_record_error| and sets
946
+ // |*out_alert| to an alert to emit, or zero if no alert should be emitted.
947
+ enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type,
948
+ Span<uint8_t> *out, size_t *out_consumed,
949
+ uint8_t *out_alert, Span<uint8_t> in);
950
+
951
+ // dtls_open_record implements |tls_open_record| for DTLS. It only returns
952
+ // |ssl_open_record_partial| if |in| was empty and sets |*out_consumed| to
953
+ // zero. The caller should read one packet and try again.
954
+ enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
955
+ Span<uint8_t> *out,
956
+ size_t *out_consumed,
957
+ uint8_t *out_alert, Span<uint8_t> in);
958
+
959
+ // ssl_seal_align_prefix_len returns the length of the prefix before the start
960
+ // of the bulk of the ciphertext when sealing a record with |ssl|. Callers may
961
+ // use this to align buffers.
962
+ //
963
+ // Note when TLS 1.0 CBC record-splitting is enabled, this includes the one byte
964
+ // record and is the offset into second record's ciphertext. Thus sealing a
965
+ // small record may result in a smaller output than this value.
966
+ //
967
+ // TODO(davidben): Is this alignment valuable? Record-splitting makes this a
968
+ // mess.
969
+ size_t ssl_seal_align_prefix_len(const SSL *ssl);
970
+
971
+ // tls_seal_record seals a new record of type |type| and body |in| and writes it
972
+ // to |out|. At most |max_out| bytes will be written. It returns true on success
973
+ // and false on error. If enabled, |tls_seal_record| implements TLS 1.0 CBC
974
+ // 1/n-1 record splitting and may write two records concatenated.
975
+ //
976
+ // For a large record, the bulk of the ciphertext will begin
977
+ // |ssl_seal_align_prefix_len| bytes into out. Aligning |out| appropriately may
978
+ // improve performance. It writes at most |in_len| + |SSL_max_seal_overhead|
979
+ // bytes to |out|.
980
+ //
981
+ // |in| and |out| may not alias.
982
+ bool tls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
983
+ uint8_t type, const uint8_t *in, size_t in_len);
984
+
985
+ enum dtls1_use_epoch_t {
986
+ dtls1_use_previous_epoch,
987
+ dtls1_use_current_epoch,
988
+ };
989
+
990
+ // dtls_max_seal_overhead returns the maximum overhead, in bytes, of sealing a
991
+ // record.
992
+ size_t dtls_max_seal_overhead(const SSL *ssl, enum dtls1_use_epoch_t use_epoch);
993
+
994
+ // dtls_seal_prefix_len returns the number of bytes of prefix to reserve in
995
+ // front of the plaintext when sealing a record in-place.
996
+ size_t dtls_seal_prefix_len(const SSL *ssl, enum dtls1_use_epoch_t use_epoch);
997
+
998
+ // dtls_seal_record implements |tls_seal_record| for DTLS. |use_epoch| selects
999
+ // which epoch's cipher state to use. Unlike |tls_seal_record|, |in| and |out|
1000
+ // may alias but, if they do, |in| must be exactly |dtls_seal_prefix_len| bytes
1001
+ // ahead of |out|.
1002
+ bool dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
1003
+ uint8_t type, const uint8_t *in, size_t in_len,
1004
+ enum dtls1_use_epoch_t use_epoch);
1005
+
1006
+ // ssl_process_alert processes |in| as an alert and updates |ssl|'s shutdown
1007
+ // state. It returns one of |ssl_open_record_discard|, |ssl_open_record_error|,
1008
+ // |ssl_open_record_close_notify|, or |ssl_open_record_fatal_alert| as
1009
+ // appropriate.
1010
+ enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert,
1011
+ Span<const uint8_t> in);
1012
+
1013
+
1014
+ // Private key operations.
1015
+
1016
+ // ssl_has_private_key returns whether |hs| has a private key configured.
1017
+ bool ssl_has_private_key(const SSL_HANDSHAKE *hs);
1018
+
1019
+ // ssl_private_key_* perform the corresponding operation on
1020
+ // |SSL_PRIVATE_KEY_METHOD|. If there is a custom private key configured, they
1021
+ // call the corresponding function or |complete| depending on whether there is a
1022
+ // pending operation. Otherwise, they implement the operation with
1023
+ // |EVP_PKEY|.
1024
+
1025
+ enum ssl_private_key_result_t ssl_private_key_sign(
1026
+ SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
1027
+ uint16_t sigalg, Span<const uint8_t> in);
1028
+
1029
+ enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
1030
+ uint8_t *out,
1031
+ size_t *out_len,
1032
+ size_t max_out,
1033
+ Span<const uint8_t> in);
1034
+
1035
+ // ssl_private_key_supports_signature_algorithm returns whether |hs|'s private
1036
+ // key supports |sigalg|.
1037
+ bool ssl_private_key_supports_signature_algorithm(SSL_HANDSHAKE *hs,
1038
+ uint16_t sigalg);
1039
+
1040
+ // ssl_public_key_verify verifies that the |signature| is valid for the public
1041
+ // key |pkey| and input |in|, using the signature algorithm |sigalg|.
1042
+ bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature,
1043
+ uint16_t sigalg, EVP_PKEY *pkey,
1044
+ Span<const uint8_t> in);
1045
+
1046
+
1047
+ // Key shares.
1048
+
1049
+ // SSLKeyShare abstracts over Diffie-Hellman-like key exchanges.
1050
+ class SSLKeyShare {
1051
+ public:
1052
+ virtual ~SSLKeyShare() {}
1053
+ static constexpr bool kAllowUniquePtr = true;
1054
+ HAS_VIRTUAL_DESTRUCTOR
1055
+
1056
+ // Create returns a SSLKeyShare instance for use with group |group_id| or
1057
+ // nullptr on error.
1058
+ static UniquePtr<SSLKeyShare> Create(uint16_t group_id);
1059
+
1060
+ // Create deserializes an SSLKeyShare instance previously serialized by
1061
+ // |Serialize|.
1062
+ static UniquePtr<SSLKeyShare> Create(CBS *in);
1063
+
1064
+ // GroupID returns the group ID.
1065
+ virtual uint16_t GroupID() const PURE_VIRTUAL;
1066
+
1067
+ // Offer generates a keypair and writes the public value to
1068
+ // |out_public_key|. It returns true on success and false on error.
1069
+ virtual bool Offer(CBB *out_public_key) PURE_VIRTUAL;
1070
+
1071
+ // Accept performs a key exchange against the |peer_key| generated by |Offer|.
1072
+ // On success, it returns true, writes the public value to |out_public_key|,
1073
+ // and sets |*out_secret| to the shared secret. On failure, it returns false
1074
+ // and sets |*out_alert| to an alert to send to the peer.
1075
+ //
1076
+ // The default implementation calls |Offer| and then |Finish|, assuming a key
1077
+ // exchange protocol where the peers are symmetric.
1078
+ virtual bool Accept(CBB *out_public_key, Array<uint8_t> *out_secret,
1079
+ uint8_t *out_alert, Span<const uint8_t> peer_key);
1080
+
1081
+ // Finish performs a key exchange against the |peer_key| generated by
1082
+ // |Accept|. On success, it returns true and sets |*out_secret| to the shared
1083
+ // secret. On failure, it returns false and sets |*out_alert| to an alert to
1084
+ // send to the peer.
1085
+ virtual bool Finish(Array<uint8_t> *out_secret, uint8_t *out_alert,
1086
+ Span<const uint8_t> peer_key) PURE_VIRTUAL;
1087
+
1088
+ // Serialize writes the state of the key exchange to |out|, returning true if
1089
+ // successful and false otherwise.
1090
+ virtual bool Serialize(CBB *out) { return false; }
1091
+
1092
+ // Deserialize initializes the state of the key exchange from |in|, returning
1093
+ // true if successful and false otherwise. It is called by |Create|.
1094
+ virtual bool Deserialize(CBS *in) { return false; }
1095
+ };
1096
+
1097
+ struct NamedGroup {
1098
+ int nid;
1099
+ uint16_t group_id;
1100
+ const char name[8], alias[11];
1101
+ };
1102
+
1103
+ // NamedGroups returns all supported groups.
1104
+ Span<const NamedGroup> NamedGroups();
1105
+
1106
+ // ssl_nid_to_group_id looks up the group corresponding to |nid|. On success, it
1107
+ // sets |*out_group_id| to the group ID and returns true. Otherwise, it returns
1108
+ // false.
1109
+ bool ssl_nid_to_group_id(uint16_t *out_group_id, int nid);
1110
+
1111
+ // ssl_name_to_group_id looks up the group corresponding to the |name| string of
1112
+ // length |len|. On success, it sets |*out_group_id| to the group ID and returns
1113
+ // true. Otherwise, it returns false.
1114
+ bool ssl_name_to_group_id(uint16_t *out_group_id, const char *name, size_t len);
1115
+
1116
+
1117
+ // Handshake messages.
1118
+
1119
+ struct SSLMessage {
1120
+ bool is_v2_hello;
1121
+ uint8_t type;
1122
+ CBS body;
1123
+ // raw is the entire serialized handshake message, including the TLS or DTLS
1124
+ // message header.
1125
+ CBS raw;
1126
+ };
1127
+
1128
+ // SSL_MAX_HANDSHAKE_FLIGHT is the number of messages, including
1129
+ // ChangeCipherSpec, in the longest handshake flight. Currently this is the
1130
+ // client's second leg in a full handshake when client certificates, NPN, and
1131
+ // Channel ID, are all enabled.
1132
+ #define SSL_MAX_HANDSHAKE_FLIGHT 7
1133
+
1134
+ extern const uint8_t kHelloRetryRequest[SSL3_RANDOM_SIZE];
1135
+ extern const uint8_t kTLS12DowngradeRandom[8];
1136
+ extern const uint8_t kTLS13DowngradeRandom[8];
1137
+ extern const uint8_t kJDK11DowngradeRandom[8];
1138
+
1139
+ // ssl_max_handshake_message_len returns the maximum number of bytes permitted
1140
+ // in a handshake message for |ssl|.
1141
+ size_t ssl_max_handshake_message_len(const SSL *ssl);
1142
+
1143
+ // tls_can_accept_handshake_data returns whether |ssl| is able to accept more
1144
+ // data into handshake buffer.
1145
+ bool tls_can_accept_handshake_data(const SSL *ssl, uint8_t *out_alert);
1146
+
1147
+ // tls_has_unprocessed_handshake_data returns whether there is buffered
1148
+ // handshake data that has not been consumed by |get_message|.
1149
+ bool tls_has_unprocessed_handshake_data(const SSL *ssl);
1150
+
1151
+ // tls_append_handshake_data appends |data| to the handshake buffer. It returns
1152
+ // true on success and false on allocation failure.
1153
+ bool tls_append_handshake_data(SSL *ssl, Span<const uint8_t> data);
1154
+
1155
+ // dtls_has_unprocessed_handshake_data behaves like
1156
+ // |tls_has_unprocessed_handshake_data| for DTLS.
1157
+ bool dtls_has_unprocessed_handshake_data(const SSL *ssl);
1158
+
1159
+ // tls_flush_pending_hs_data flushes any handshake plaintext data.
1160
+ bool tls_flush_pending_hs_data(SSL *ssl);
1161
+
1162
+ struct DTLS_OUTGOING_MESSAGE {
1163
+ DTLS_OUTGOING_MESSAGE() {}
1164
+ DTLS_OUTGOING_MESSAGE(const DTLS_OUTGOING_MESSAGE &) = delete;
1165
+ DTLS_OUTGOING_MESSAGE &operator=(const DTLS_OUTGOING_MESSAGE &) = delete;
1166
+ ~DTLS_OUTGOING_MESSAGE() { Clear(); }
1167
+
1168
+ void Clear();
1169
+
1170
+ uint8_t *data = nullptr;
1171
+ uint32_t len = 0;
1172
+ uint16_t epoch = 0;
1173
+ bool is_ccs = false;
1174
+ };
1175
+
1176
+ // dtls_clear_outgoing_messages releases all buffered outgoing messages.
1177
+ void dtls_clear_outgoing_messages(SSL *ssl);
1178
+
1179
+
1180
+ // Callbacks.
1181
+
1182
+ // ssl_do_info_callback calls |ssl|'s info callback, if set.
1183
+ void ssl_do_info_callback(const SSL *ssl, int type, int value);
1184
+
1185
+ // ssl_do_msg_callback calls |ssl|'s message callback, if set.
1186
+ void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type,
1187
+ Span<const uint8_t> in);
1188
+
1189
+
1190
+ // Transport buffers.
1191
+
1192
+ class SSLBuffer {
1193
+ public:
1194
+ SSLBuffer() {}
1195
+ ~SSLBuffer() { Clear(); }
1196
+
1197
+ SSLBuffer(const SSLBuffer &) = delete;
1198
+ SSLBuffer &operator=(const SSLBuffer &) = delete;
1199
+
1200
+ uint8_t *data() { return buf_ + offset_; }
1201
+ size_t size() const { return size_; }
1202
+ bool empty() const { return size_ == 0; }
1203
+ size_t cap() const { return cap_; }
1204
+
1205
+ Span<uint8_t> span() { return MakeSpan(data(), size()); }
1206
+
1207
+ Span<uint8_t> remaining() {
1208
+ return MakeSpan(data() + size(), cap() - size());
1209
+ }
1210
+
1211
+ // Clear releases the buffer.
1212
+ void Clear();
1213
+
1214
+ // EnsureCap ensures the buffer has capacity at least |new_cap|, aligned such
1215
+ // that data written after |header_len| is aligned to a
1216
+ // |SSL3_ALIGN_PAYLOAD|-byte boundary. It returns true on success and false
1217
+ // on error.
1218
+ bool EnsureCap(size_t header_len, size_t new_cap);
1219
+
1220
+ // DidWrite extends the buffer by |len|. The caller must have filled in to
1221
+ // this point.
1222
+ void DidWrite(size_t len);
1223
+
1224
+ // Consume consumes |len| bytes from the front of the buffer. The memory
1225
+ // consumed will remain valid until the next call to |DiscardConsumed| or
1226
+ // |Clear|.
1227
+ void Consume(size_t len);
1228
+
1229
+ // DiscardConsumed discards the consumed bytes from the buffer. If the buffer
1230
+ // is now empty, it releases memory used by it.
1231
+ void DiscardConsumed();
1232
+
1233
+ private:
1234
+ // buf_ is the memory allocated for this buffer.
1235
+ uint8_t *buf_ = nullptr;
1236
+ // offset_ is the offset into |buf_| which the buffer contents start at.
1237
+ uint16_t offset_ = 0;
1238
+ // size_ is the size of the buffer contents from |buf_| + |offset_|.
1239
+ uint16_t size_ = 0;
1240
+ // cap_ is how much memory beyond |buf_| + |offset_| is available.
1241
+ uint16_t cap_ = 0;
1242
+ // inline_buf_ is a static buffer for short reads.
1243
+ uint8_t inline_buf_[SSL3_RT_HEADER_LENGTH];
1244
+ // buf_allocated_ is true if |buf_| points to allocated data and must be freed
1245
+ // or false if it points into |inline_buf_|.
1246
+ bool buf_allocated_ = false;
1247
+ };
1248
+
1249
+ // ssl_read_buffer_extend_to extends the read buffer to the desired length. For
1250
+ // TLS, it reads to the end of the buffer until the buffer is |len| bytes
1251
+ // long. For DTLS, it reads a new packet and ignores |len|. It returns one on
1252
+ // success, zero on EOF, and a negative number on error.
1253
+ //
1254
+ // It is an error to call |ssl_read_buffer_extend_to| in DTLS when the buffer is
1255
+ // non-empty.
1256
+ int ssl_read_buffer_extend_to(SSL *ssl, size_t len);
1257
+
1258
+ // ssl_handle_open_record handles the result of passing |ssl->s3->read_buffer|
1259
+ // to a record-processing function. If |ret| is a success or if the caller
1260
+ // should retry, it returns one and sets |*out_retry|. Otherwise, it returns <=
1261
+ // 0.
1262
+ int ssl_handle_open_record(SSL *ssl, bool *out_retry, ssl_open_record_t ret,
1263
+ size_t consumed, uint8_t alert);
1264
+
1265
+ // ssl_write_buffer_flush flushes the write buffer to the transport. It returns
1266
+ // one on success and <= 0 on error. For DTLS, whether or not the write
1267
+ // succeeds, the write buffer will be cleared.
1268
+ int ssl_write_buffer_flush(SSL *ssl);
1269
+
1270
+
1271
+ // Certificate functions.
1272
+
1273
+ // ssl_has_certificate returns whether a certificate and private key are
1274
+ // configured.
1275
+ bool ssl_has_certificate(const SSL_HANDSHAKE *hs);
1276
+
1277
+ // ssl_parse_cert_chain parses a certificate list from |cbs| in the format used
1278
+ // by a TLS Certificate message. On success, it advances |cbs| and returns
1279
+ // true. Otherwise, it returns false and sets |*out_alert| to an alert to send
1280
+ // to the peer.
1281
+ //
1282
+ // If the list is non-empty then |*out_chain| and |*out_pubkey| will be set to
1283
+ // the certificate chain and the leaf certificate's public key
1284
+ // respectively. Otherwise, both will be set to nullptr.
1285
+ //
1286
+ // If the list is non-empty and |out_leaf_sha256| is non-NULL, it writes the
1287
+ // SHA-256 hash of the leaf to |out_leaf_sha256|.
1288
+ bool ssl_parse_cert_chain(uint8_t *out_alert,
1289
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> *out_chain,
1290
+ UniquePtr<EVP_PKEY> *out_pubkey,
1291
+ uint8_t *out_leaf_sha256, CBS *cbs,
1292
+ CRYPTO_BUFFER_POOL *pool);
1293
+
1294
+ // ssl_add_cert_chain adds |hs->ssl|'s certificate chain to |cbb| in the format
1295
+ // used by a TLS Certificate message. If there is no certificate chain, it emits
1296
+ // an empty certificate list. It returns true on success and false on error.
1297
+ bool ssl_add_cert_chain(SSL_HANDSHAKE *hs, CBB *cbb);
1298
+
1299
+ enum ssl_key_usage_t {
1300
+ key_usage_digital_signature = 0,
1301
+ key_usage_encipherment = 2,
1302
+ };
1303
+
1304
+ // ssl_cert_check_key_usage parses the DER-encoded, X.509 certificate in |in|
1305
+ // and returns true if doesn't specify a key usage or, if it does, if it
1306
+ // includes |bit|. Otherwise it pushes to the error queue and returns false.
1307
+ bool ssl_cert_check_key_usage(const CBS *in, enum ssl_key_usage_t bit);
1308
+
1309
+ // ssl_cert_parse_pubkey extracts the public key from the DER-encoded, X.509
1310
+ // certificate in |in|. It returns an allocated |EVP_PKEY| or else returns
1311
+ // nullptr and pushes to the error queue.
1312
+ UniquePtr<EVP_PKEY> ssl_cert_parse_pubkey(const CBS *in);
1313
+
1314
+ // ssl_parse_client_CA_list parses a CA list from |cbs| in the format used by a
1315
+ // TLS CertificateRequest message. On success, it returns a newly-allocated
1316
+ // |CRYPTO_BUFFER| list and advances |cbs|. Otherwise, it returns nullptr and
1317
+ // sets |*out_alert| to an alert to send to the peer.
1318
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> ssl_parse_client_CA_list(SSL *ssl,
1319
+ uint8_t *out_alert,
1320
+ CBS *cbs);
1321
+
1322
+ // ssl_has_client_CAs returns there are configured CAs.
1323
+ bool ssl_has_client_CAs(const SSL_CONFIG *cfg);
1324
+
1325
+ // ssl_add_client_CA_list adds the configured CA list to |cbb| in the format
1326
+ // used by a TLS CertificateRequest message. It returns true on success and
1327
+ // false on error.
1328
+ bool ssl_add_client_CA_list(SSL_HANDSHAKE *hs, CBB *cbb);
1329
+
1330
+ // ssl_check_leaf_certificate returns one if |pkey| and |leaf| are suitable as
1331
+ // a server's leaf certificate for |hs|. Otherwise, it returns zero and pushes
1332
+ // an error on the error queue.
1333
+ bool ssl_check_leaf_certificate(SSL_HANDSHAKE *hs, EVP_PKEY *pkey,
1334
+ const CRYPTO_BUFFER *leaf);
1335
+
1336
+ // ssl_on_certificate_selected is called once the certificate has been selected.
1337
+ // It finalizes the certificate and initializes |hs->local_pubkey|. It returns
1338
+ // true on success and false on error.
1339
+ bool ssl_on_certificate_selected(SSL_HANDSHAKE *hs);
1340
+
1341
+
1342
+ // TLS 1.3 key derivation.
1343
+
1344
+ // tls13_init_key_schedule initializes the handshake hash and key derivation
1345
+ // state, and incorporates the PSK. The cipher suite and PRF hash must have been
1346
+ // selected at this point. It returns true on success and false on error.
1347
+ bool tls13_init_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> psk);
1348
+
1349
+ // tls13_init_early_key_schedule initializes the handshake hash and key
1350
+ // derivation state from the resumption secret and incorporates the PSK to
1351
+ // derive the early secrets. It returns one on success and zero on error.
1352
+ bool tls13_init_early_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> psk);
1353
+
1354
+ // tls13_advance_key_schedule incorporates |in| into the key schedule with
1355
+ // HKDF-Extract. It returns true on success and false on error.
1356
+ bool tls13_advance_key_schedule(SSL_HANDSHAKE *hs, Span<const uint8_t> in);
1357
+
1358
+ // tls13_set_traffic_key sets the read or write traffic keys to
1359
+ // |traffic_secret|. The version and cipher suite are determined from |session|.
1360
+ // It returns true on success and false on error.
1361
+ bool tls13_set_traffic_key(SSL *ssl, enum ssl_encryption_level_t level,
1362
+ enum evp_aead_direction_t direction,
1363
+ const SSL_SESSION *session,
1364
+ Span<const uint8_t> traffic_secret);
1365
+
1366
+ // tls13_derive_early_secret derives the early traffic secret. It returns true
1367
+ // on success and false on error.
1368
+ bool tls13_derive_early_secret(SSL_HANDSHAKE *hs);
1369
+
1370
+ // tls13_derive_handshake_secrets derives the handshake traffic secret. It
1371
+ // returns true on success and false on error.
1372
+ bool tls13_derive_handshake_secrets(SSL_HANDSHAKE *hs);
1373
+
1374
+ // tls13_rotate_traffic_key derives the next read or write traffic secret. It
1375
+ // returns true on success and false on error.
1376
+ bool tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction);
1377
+
1378
+ // tls13_derive_application_secrets derives the initial application data traffic
1379
+ // and exporter secrets based on the handshake transcripts and |master_secret|.
1380
+ // It returns true on success and false on error.
1381
+ bool tls13_derive_application_secrets(SSL_HANDSHAKE *hs);
1382
+
1383
+ // tls13_derive_resumption_secret derives the |resumption_secret|.
1384
+ bool tls13_derive_resumption_secret(SSL_HANDSHAKE *hs);
1385
+
1386
+ // tls13_export_keying_material provides an exporter interface to use the
1387
+ // |exporter_secret|.
1388
+ bool tls13_export_keying_material(SSL *ssl, Span<uint8_t> out,
1389
+ Span<const uint8_t> secret,
1390
+ Span<const char> label,
1391
+ Span<const uint8_t> context);
1392
+
1393
+ // tls13_finished_mac calculates the MAC of the handshake transcript to verify
1394
+ // the integrity of the Finished message, and stores the result in |out| and
1395
+ // length in |out_len|. |is_server| is true if this is for the Server Finished
1396
+ // and false for the Client Finished.
1397
+ bool tls13_finished_mac(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len,
1398
+ bool is_server);
1399
+
1400
+ // tls13_derive_session_psk calculates the PSK for this session based on the
1401
+ // resumption master secret and |nonce|. It returns true on success, and false
1402
+ // on failure.
1403
+ bool tls13_derive_session_psk(SSL_SESSION *session, Span<const uint8_t> nonce);
1404
+
1405
+ // tls13_write_psk_binder calculates the PSK binder value and replaces the last
1406
+ // bytes of |msg| with the resulting value. It returns true on success, and
1407
+ // false on failure.
1408
+ bool tls13_write_psk_binder(SSL_HANDSHAKE *hs, Span<uint8_t> msg);
1409
+
1410
+ // tls13_verify_psk_binder verifies that the handshake transcript, truncated up
1411
+ // to the binders has a valid signature using the value of |session|'s
1412
+ // resumption secret. It returns true on success, and false on failure.
1413
+ bool tls13_verify_psk_binder(SSL_HANDSHAKE *hs, SSL_SESSION *session,
1414
+ const SSLMessage &msg, CBS *binders);
1415
+
1416
+
1417
+ // Handshake functions.
1418
+
1419
+ enum ssl_hs_wait_t {
1420
+ ssl_hs_error,
1421
+ ssl_hs_ok,
1422
+ ssl_hs_read_server_hello,
1423
+ ssl_hs_read_message,
1424
+ ssl_hs_flush,
1425
+ ssl_hs_certificate_selection_pending,
1426
+ ssl_hs_handoff,
1427
+ ssl_hs_handback,
1428
+ ssl_hs_x509_lookup,
1429
+ ssl_hs_channel_id_lookup,
1430
+ ssl_hs_private_key_operation,
1431
+ ssl_hs_pending_session,
1432
+ ssl_hs_pending_ticket,
1433
+ ssl_hs_early_return,
1434
+ ssl_hs_early_data_rejected,
1435
+ ssl_hs_read_end_of_early_data,
1436
+ ssl_hs_read_change_cipher_spec,
1437
+ ssl_hs_certificate_verify,
1438
+ };
1439
+
1440
+ enum ssl_grease_index_t {
1441
+ ssl_grease_cipher = 0,
1442
+ ssl_grease_group,
1443
+ ssl_grease_extension1,
1444
+ ssl_grease_extension2,
1445
+ ssl_grease_version,
1446
+ ssl_grease_ticket_extension,
1447
+ ssl_grease_last_index = ssl_grease_ticket_extension,
1448
+ };
1449
+
1450
+ enum tls12_server_hs_state_t {
1451
+ state12_start_accept = 0,
1452
+ state12_read_client_hello,
1453
+ state12_select_certificate,
1454
+ state12_tls13,
1455
+ state12_select_parameters,
1456
+ state12_send_server_hello,
1457
+ state12_send_server_certificate,
1458
+ state12_send_server_key_exchange,
1459
+ state12_send_server_hello_done,
1460
+ state12_read_client_certificate,
1461
+ state12_verify_client_certificate,
1462
+ state12_read_client_key_exchange,
1463
+ state12_read_client_certificate_verify,
1464
+ state12_read_change_cipher_spec,
1465
+ state12_process_change_cipher_spec,
1466
+ state12_read_next_proto,
1467
+ state12_read_channel_id,
1468
+ state12_read_client_finished,
1469
+ state12_send_server_finished,
1470
+ state12_finish_server_handshake,
1471
+ state12_done,
1472
+ };
1473
+
1474
+ enum tls13_server_hs_state_t {
1475
+ state13_select_parameters = 0,
1476
+ state13_select_session,
1477
+ state13_send_hello_retry_request,
1478
+ state13_read_second_client_hello,
1479
+ state13_send_server_hello,
1480
+ state13_send_server_certificate_verify,
1481
+ state13_send_server_finished,
1482
+ state13_send_half_rtt_ticket,
1483
+ state13_read_second_client_flight,
1484
+ state13_process_end_of_early_data,
1485
+ state13_read_client_certificate,
1486
+ state13_read_client_certificate_verify,
1487
+ state13_read_channel_id,
1488
+ state13_read_client_finished,
1489
+ state13_send_new_session_ticket,
1490
+ state13_done,
1491
+ };
1492
+
1493
+ // handback_t lists the points in the state machine where a handback can occur.
1494
+ // These are the different points at which key material is no longer needed.
1495
+ enum handback_t {
1496
+ handback_after_session_resumption = 0,
1497
+ handback_after_ecdhe = 1,
1498
+ handback_after_handshake = 2,
1499
+ handback_tls13 = 3,
1500
+ handback_max_value = handback_tls13,
1501
+ };
1502
+
1503
+
1504
+ // Delegated credentials.
1505
+
1506
+ // This structure stores a delegated credential (DC) as defined by
1507
+ // draft-ietf-tls-subcerts-03.
1508
+ struct DC {
1509
+ static constexpr bool kAllowUniquePtr = true;
1510
+ ~DC();
1511
+
1512
+ // Dup returns a copy of this DC and takes references to |raw| and |pkey|.
1513
+ UniquePtr<DC> Dup();
1514
+
1515
+ // Parse parses the delegated credential stored in |in|. If successful it
1516
+ // returns the parsed structure, otherwise it returns |nullptr| and sets
1517
+ // |*out_alert|.
1518
+ static UniquePtr<DC> Parse(CRYPTO_BUFFER *in, uint8_t *out_alert);
1519
+
1520
+ // raw is the delegated credential encoded as specified in draft-ietf-tls-
1521
+ // subcerts-03.
1522
+ UniquePtr<CRYPTO_BUFFER> raw;
1523
+
1524
+ // expected_cert_verify_algorithm is the signature scheme of the DC public
1525
+ // key.
1526
+ uint16_t expected_cert_verify_algorithm = 0;
1527
+
1528
+ // pkey is the public key parsed from |public_key|.
1529
+ UniquePtr<EVP_PKEY> pkey;
1530
+
1531
+ private:
1532
+ friend DC* New<DC>();
1533
+ DC();
1534
+ };
1535
+
1536
+ // ssl_signing_with_dc returns true if the peer has indicated support for
1537
+ // delegated credentials and this host has sent a delegated credential in
1538
+ // response. If this is true then we've committed to using the DC in the
1539
+ // handshake.
1540
+ bool ssl_signing_with_dc(const SSL_HANDSHAKE *hs);
1541
+
1542
+
1543
+ struct SSL_HANDSHAKE {
1544
+ explicit SSL_HANDSHAKE(SSL *ssl);
1545
+ ~SSL_HANDSHAKE();
1546
+ static constexpr bool kAllowUniquePtr = true;
1547
+
1548
+ // ssl is a non-owning pointer to the parent |SSL| object.
1549
+ SSL *ssl;
1550
+
1551
+ // config is a non-owning pointer to the handshake configuration.
1552
+ SSL_CONFIG *config;
1553
+
1554
+ // wait contains the operation the handshake is currently blocking on or
1555
+ // |ssl_hs_ok| if none.
1556
+ enum ssl_hs_wait_t wait = ssl_hs_ok;
1557
+
1558
+ // state is the internal state for the TLS 1.2 and below handshake. Its
1559
+ // values depend on |do_handshake| but the starting state is always zero.
1560
+ int state = 0;
1561
+
1562
+ // tls13_state is the internal state for the TLS 1.3 handshake. Its values
1563
+ // depend on |do_handshake| but the starting state is always zero.
1564
+ int tls13_state = 0;
1565
+
1566
+ // min_version is the minimum accepted protocol version, taking account both
1567
+ // |SSL_OP_NO_*| and |SSL_CTX_set_min_proto_version| APIs.
1568
+ uint16_t min_version = 0;
1569
+
1570
+ // max_version is the maximum accepted protocol version, taking account both
1571
+ // |SSL_OP_NO_*| and |SSL_CTX_set_max_proto_version| APIs.
1572
+ uint16_t max_version = 0;
1573
+
1574
+ private:
1575
+ size_t hash_len_ = 0;
1576
+ uint8_t secret_[SSL_MAX_MD_SIZE] = {0};
1577
+ uint8_t early_traffic_secret_[SSL_MAX_MD_SIZE] = {0};
1578
+ uint8_t client_handshake_secret_[SSL_MAX_MD_SIZE] = {0};
1579
+ uint8_t server_handshake_secret_[SSL_MAX_MD_SIZE] = {0};
1580
+ uint8_t client_traffic_secret_0_[SSL_MAX_MD_SIZE] = {0};
1581
+ uint8_t server_traffic_secret_0_[SSL_MAX_MD_SIZE] = {0};
1582
+ uint8_t expected_client_finished_[SSL_MAX_MD_SIZE] = {0};
1583
+
1584
+ public:
1585
+ void ResizeSecrets(size_t hash_len);
1586
+
1587
+ Span<uint8_t> secret() { return MakeSpan(secret_, hash_len_); }
1588
+ Span<uint8_t> early_traffic_secret() {
1589
+ return MakeSpan(early_traffic_secret_, hash_len_);
1590
+ }
1591
+ Span<uint8_t> client_handshake_secret() {
1592
+ return MakeSpan(client_handshake_secret_, hash_len_);
1593
+ }
1594
+ Span<uint8_t> server_handshake_secret() {
1595
+ return MakeSpan(server_handshake_secret_, hash_len_);
1596
+ }
1597
+ Span<uint8_t> client_traffic_secret_0() {
1598
+ return MakeSpan(client_traffic_secret_0_, hash_len_);
1599
+ }
1600
+ Span<uint8_t> server_traffic_secret_0() {
1601
+ return MakeSpan(server_traffic_secret_0_, hash_len_);
1602
+ }
1603
+ Span<uint8_t> expected_client_finished() {
1604
+ return MakeSpan(expected_client_finished_, hash_len_);
1605
+ }
1606
+
1607
+ union {
1608
+ // sent is a bitset where the bits correspond to elements of kExtensions
1609
+ // in t1_lib.c. Each bit is set if that extension was sent in a
1610
+ // ClientHello. It's not used by servers.
1611
+ uint32_t sent = 0;
1612
+ // received is a bitset, like |sent|, but is used by servers to record
1613
+ // which extensions were received from a client.
1614
+ uint32_t received;
1615
+ } extensions;
1616
+
1617
+ // retry_group is the group ID selected by the server in HelloRetryRequest in
1618
+ // TLS 1.3.
1619
+ uint16_t retry_group = 0;
1620
+
1621
+ // error, if |wait| is |ssl_hs_error|, is the error the handshake failed on.
1622
+ UniquePtr<ERR_SAVE_STATE> error;
1623
+
1624
+ // key_shares are the current key exchange instances. The second is only used
1625
+ // as a client if we believe that we should offer two key shares in a
1626
+ // ClientHello.
1627
+ UniquePtr<SSLKeyShare> key_shares[2];
1628
+
1629
+ // transcript is the current handshake transcript.
1630
+ SSLTranscript transcript;
1631
+
1632
+ // cookie is the value of the cookie received from the server, if any.
1633
+ Array<uint8_t> cookie;
1634
+
1635
+ // key_share_bytes is the value of the previously sent KeyShare extension by
1636
+ // the client in TLS 1.3.
1637
+ Array<uint8_t> key_share_bytes;
1638
+
1639
+ // ecdh_public_key, for servers, is the key share to be sent to the client in
1640
+ // TLS 1.3.
1641
+ Array<uint8_t> ecdh_public_key;
1642
+
1643
+ // peer_sigalgs are the signature algorithms that the peer supports. These are
1644
+ // taken from the contents of the signature algorithms extension for a server
1645
+ // or from the CertificateRequest for a client.
1646
+ Array<uint16_t> peer_sigalgs;
1647
+
1648
+ // peer_supported_group_list contains the supported group IDs advertised by
1649
+ // the peer. This is only set on the server's end. The server does not
1650
+ // advertise this extension to the client.
1651
+ Array<uint16_t> peer_supported_group_list;
1652
+
1653
+ // peer_key is the peer's ECDH key for a TLS 1.2 client.
1654
+ Array<uint8_t> peer_key;
1655
+
1656
+ // negotiated_token_binding_version is used by a server to store the
1657
+ // on-the-wire encoding of the Token Binding protocol version to advertise in
1658
+ // the ServerHello/EncryptedExtensions if the Token Binding extension is to be
1659
+ // sent.
1660
+ uint16_t negotiated_token_binding_version;
1661
+
1662
+ // cert_compression_alg_id, for a server, contains the negotiated certificate
1663
+ // compression algorithm for this client. It is only valid if
1664
+ // |cert_compression_negotiated| is true.
1665
+ uint16_t cert_compression_alg_id;
1666
+
1667
+ // server_params, in a TLS 1.2 server, stores the ServerKeyExchange
1668
+ // parameters. It has client and server randoms prepended for signing
1669
+ // convenience.
1670
+ Array<uint8_t> server_params;
1671
+
1672
+ // peer_psk_identity_hint, on the client, is the psk_identity_hint sent by the
1673
+ // server when using a TLS 1.2 PSK key exchange.
1674
+ UniquePtr<char> peer_psk_identity_hint;
1675
+
1676
+ // ca_names, on the client, contains the list of CAs received in a
1677
+ // CertificateRequest message.
1678
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> ca_names;
1679
+
1680
+ // cached_x509_ca_names contains a cache of parsed versions of the elements of
1681
+ // |ca_names|. This pointer is left non-owning so only
1682
+ // |ssl_crypto_x509_method| needs to link against crypto/x509.
1683
+ STACK_OF(X509_NAME) *cached_x509_ca_names = nullptr;
1684
+
1685
+ // certificate_types, on the client, contains the set of certificate types
1686
+ // received in a CertificateRequest message.
1687
+ Array<uint8_t> certificate_types;
1688
+
1689
+ // local_pubkey is the public key we are authenticating as.
1690
+ UniquePtr<EVP_PKEY> local_pubkey;
1691
+
1692
+ // peer_pubkey is the public key parsed from the peer's leaf certificate.
1693
+ UniquePtr<EVP_PKEY> peer_pubkey;
1694
+
1695
+ // new_session is the new mutable session being established by the current
1696
+ // handshake. It should not be cached.
1697
+ UniquePtr<SSL_SESSION> new_session;
1698
+
1699
+ // early_session is the session corresponding to the current 0-RTT state on
1700
+ // the client if |in_early_data| is true.
1701
+ UniquePtr<SSL_SESSION> early_session;
1702
+
1703
+ // new_cipher is the cipher being negotiated in this handshake.
1704
+ const SSL_CIPHER *new_cipher = nullptr;
1705
+
1706
+ // key_block is the record-layer key block for TLS 1.2 and earlier.
1707
+ Array<uint8_t> key_block;
1708
+
1709
+ // scts_requested is true if the SCT extension is in the ClientHello.
1710
+ bool scts_requested : 1;
1711
+
1712
+ // needs_psk_binder is true if the ClientHello has a placeholder PSK binder to
1713
+ // be filled in.
1714
+ bool needs_psk_binder : 1;
1715
+
1716
+ // handshake_finalized is true once the handshake has completed, at which
1717
+ // point accessors should use the established state.
1718
+ bool handshake_finalized : 1;
1719
+
1720
+ // accept_psk_mode stores whether the client's PSK mode is compatible with our
1721
+ // preferences.
1722
+ bool accept_psk_mode : 1;
1723
+
1724
+ // cert_request is true if a client certificate was requested.
1725
+ bool cert_request : 1;
1726
+
1727
+ // certificate_status_expected is true if OCSP stapling was negotiated and the
1728
+ // server is expected to send a CertificateStatus message. (This is used on
1729
+ // both the client and server sides.)
1730
+ bool certificate_status_expected : 1;
1731
+
1732
+ // ocsp_stapling_requested is true if a client requested OCSP stapling.
1733
+ bool ocsp_stapling_requested : 1;
1734
+
1735
+ // delegated_credential_requested is true if the peer indicated support for
1736
+ // the delegated credential extension.
1737
+ bool delegated_credential_requested : 1;
1738
+
1739
+ // should_ack_sni is used by a server and indicates that the SNI extension
1740
+ // should be echoed in the ServerHello.
1741
+ bool should_ack_sni : 1;
1742
+
1743
+ // in_false_start is true if there is a pending client handshake in False
1744
+ // Start. The client may write data at this point.
1745
+ bool in_false_start : 1;
1746
+
1747
+ // in_early_data is true if there is a pending handshake that has progressed
1748
+ // enough to send and receive early data.
1749
+ bool in_early_data : 1;
1750
+
1751
+ // early_data_offered is true if the client sent the early_data extension.
1752
+ bool early_data_offered : 1;
1753
+
1754
+ // can_early_read is true if application data may be read at this point in the
1755
+ // handshake.
1756
+ bool can_early_read : 1;
1757
+
1758
+ // can_early_write is true if application data may be written at this point in
1759
+ // the handshake.
1760
+ bool can_early_write : 1;
1761
+
1762
+ // next_proto_neg_seen is one of NPN was negotiated.
1763
+ bool next_proto_neg_seen : 1;
1764
+
1765
+ // ticket_expected is true if a TLS 1.2 NewSessionTicket message is to be sent
1766
+ // or received.
1767
+ bool ticket_expected : 1;
1768
+
1769
+ // extended_master_secret is true if the extended master secret extension is
1770
+ // negotiated in this handshake.
1771
+ bool extended_master_secret : 1;
1772
+
1773
+ // pending_private_key_op is true if there is a pending private key operation
1774
+ // in progress.
1775
+ bool pending_private_key_op : 1;
1776
+
1777
+ // grease_seeded is true if |grease_seed| has been initialized.
1778
+ bool grease_seeded : 1;
1779
+
1780
+ // handback indicates that a server should pause the handshake after
1781
+ // finishing operations that require private key material, in such a way that
1782
+ // |SSL_get_error| returns |SSL_ERROR_HANDBACK|. It is set by
1783
+ // |SSL_apply_handoff|.
1784
+ bool handback : 1;
1785
+
1786
+ // cert_compression_negotiated is true iff |cert_compression_alg_id| is valid.
1787
+ bool cert_compression_negotiated : 1;
1788
+
1789
+ // apply_jdk11_workaround is true if the peer is probably a JDK 11 client
1790
+ // which implemented TLS 1.3 incorrectly.
1791
+ bool apply_jdk11_workaround : 1;
1792
+
1793
+ // client_version is the value sent or received in the ClientHello version.
1794
+ uint16_t client_version = 0;
1795
+
1796
+ // early_data_read is the amount of early data that has been read by the
1797
+ // record layer.
1798
+ uint16_t early_data_read = 0;
1799
+
1800
+ // early_data_written is the amount of early data that has been written by the
1801
+ // record layer.
1802
+ uint16_t early_data_written = 0;
1803
+
1804
+ // session_id is the session ID in the ClientHello.
1805
+ uint8_t session_id[SSL_MAX_SSL_SESSION_ID_LENGTH] = {0};
1806
+ uint8_t session_id_len = 0;
1807
+
1808
+ // grease_seed is the entropy for GREASE values. It is valid if
1809
+ // |grease_seeded| is true.
1810
+ uint8_t grease_seed[ssl_grease_last_index + 1] = {0};
1811
+ };
1812
+
1813
+ UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSL *ssl);
1814
+
1815
+ // ssl_check_message_type checks if |msg| has type |type|. If so it returns
1816
+ // one. Otherwise, it sends an alert and returns zero.
1817
+ bool ssl_check_message_type(SSL *ssl, const SSLMessage &msg, int type);
1818
+
1819
+ // ssl_run_handshake runs the TLS handshake. It returns one on success and <= 0
1820
+ // on error. It sets |out_early_return| to one if we've completed the handshake
1821
+ // early.
1822
+ int ssl_run_handshake(SSL_HANDSHAKE *hs, bool *out_early_return);
1823
+
1824
+ // The following are implementations of |do_handshake| for the client and
1825
+ // server.
1826
+ enum ssl_hs_wait_t ssl_client_handshake(SSL_HANDSHAKE *hs);
1827
+ enum ssl_hs_wait_t ssl_server_handshake(SSL_HANDSHAKE *hs);
1828
+ enum ssl_hs_wait_t tls13_client_handshake(SSL_HANDSHAKE *hs);
1829
+ enum ssl_hs_wait_t tls13_server_handshake(SSL_HANDSHAKE *hs);
1830
+
1831
+ // The following functions return human-readable representations of the TLS
1832
+ // handshake states for debugging.
1833
+ const char *ssl_client_handshake_state(SSL_HANDSHAKE *hs);
1834
+ const char *ssl_server_handshake_state(SSL_HANDSHAKE *hs);
1835
+ const char *tls13_client_handshake_state(SSL_HANDSHAKE *hs);
1836
+ const char *tls13_server_handshake_state(SSL_HANDSHAKE *hs);
1837
+
1838
+ // tls13_add_key_update queues a KeyUpdate message on |ssl|. The
1839
+ // |update_requested| argument must be one of |SSL_KEY_UPDATE_REQUESTED| or
1840
+ // |SSL_KEY_UPDATE_NOT_REQUESTED|.
1841
+ bool tls13_add_key_update(SSL *ssl, int update_requested);
1842
+
1843
+ // tls13_post_handshake processes a post-handshake message. It returns true on
1844
+ // success and false on failure.
1845
+ bool tls13_post_handshake(SSL *ssl, const SSLMessage &msg);
1846
+
1847
+ bool tls13_process_certificate(SSL_HANDSHAKE *hs, const SSLMessage &msg,
1848
+ bool allow_anonymous);
1849
+ bool tls13_process_certificate_verify(SSL_HANDSHAKE *hs, const SSLMessage &msg);
1850
+
1851
+ // tls13_process_finished processes |msg| as a Finished message from the
1852
+ // peer. If |use_saved_value| is true, the verify_data is compared against
1853
+ // |hs->expected_client_finished| rather than computed fresh.
1854
+ bool tls13_process_finished(SSL_HANDSHAKE *hs, const SSLMessage &msg,
1855
+ bool use_saved_value);
1856
+
1857
+ bool tls13_add_certificate(SSL_HANDSHAKE *hs);
1858
+
1859
+ // tls13_add_certificate_verify adds a TLS 1.3 CertificateVerify message to the
1860
+ // handshake. If it returns |ssl_private_key_retry|, it should be called again
1861
+ // to retry when the signing operation is completed.
1862
+ enum ssl_private_key_result_t tls13_add_certificate_verify(SSL_HANDSHAKE *hs);
1863
+
1864
+ bool tls13_add_finished(SSL_HANDSHAKE *hs);
1865
+ bool tls13_process_new_session_ticket(SSL *ssl, const SSLMessage &msg);
1866
+
1867
+ bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
1868
+ Array<uint8_t> *out_secret,
1869
+ uint8_t *out_alert, CBS *contents);
1870
+ bool ssl_ext_key_share_parse_clienthello(SSL_HANDSHAKE *hs, bool *out_found,
1871
+ Array<uint8_t> *out_secret,
1872
+ uint8_t *out_alert, CBS *contents);
1873
+ bool ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
1874
+
1875
+ bool ssl_ext_pre_shared_key_parse_serverhello(SSL_HANDSHAKE *hs,
1876
+ uint8_t *out_alert,
1877
+ CBS *contents);
1878
+ bool ssl_ext_pre_shared_key_parse_clienthello(
1879
+ SSL_HANDSHAKE *hs, CBS *out_ticket, CBS *out_binders,
1880
+ uint32_t *out_obfuscated_ticket_age, uint8_t *out_alert,
1881
+ const SSL_CLIENT_HELLO *client_hello, CBS *contents);
1882
+ bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
1883
+
1884
+ // ssl_is_sct_list_valid does a shallow parse of the SCT list in |contents| and
1885
+ // returns whether it's valid.
1886
+ bool ssl_is_sct_list_valid(const CBS *contents);
1887
+
1888
+ bool ssl_write_client_hello(SSL_HANDSHAKE *hs);
1889
+
1890
+ enum ssl_cert_verify_context_t {
1891
+ ssl_cert_verify_server,
1892
+ ssl_cert_verify_client,
1893
+ ssl_cert_verify_channel_id,
1894
+ };
1895
+
1896
+ // tls13_get_cert_verify_signature_input generates the message to be signed for
1897
+ // TLS 1.3's CertificateVerify message. |cert_verify_context| determines the
1898
+ // type of signature. It sets |*out| to a newly allocated buffer containing the
1899
+ // result. This function returns true on success and false on failure.
1900
+ bool tls13_get_cert_verify_signature_input(
1901
+ SSL_HANDSHAKE *hs, Array<uint8_t> *out,
1902
+ enum ssl_cert_verify_context_t cert_verify_context);
1903
+
1904
+ // ssl_is_alpn_protocol_allowed returns whether |protocol| is a valid server
1905
+ // selection for |hs->ssl|'s client preferences.
1906
+ bool ssl_is_alpn_protocol_allowed(const SSL_HANDSHAKE *hs,
1907
+ Span<const uint8_t> protocol);
1908
+
1909
+ // ssl_negotiate_alpn negotiates the ALPN extension, if applicable. It returns
1910
+ // true on successful negotiation or if nothing was negotiated. It returns false
1911
+ // and sets |*out_alert| to an alert on error.
1912
+ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1913
+ const SSL_CLIENT_HELLO *client_hello);
1914
+
1915
+ struct SSL_EXTENSION_TYPE {
1916
+ uint16_t type;
1917
+ bool *out_present;
1918
+ CBS *out_data;
1919
+ };
1920
+
1921
+ // ssl_parse_extensions parses a TLS extensions block out of |cbs| and advances
1922
+ // it. It writes the parsed extensions to pointers denoted by |ext_types|. On
1923
+ // success, it fills in the |out_present| and |out_data| fields and returns one.
1924
+ // Otherwise, it sets |*out_alert| to an alert to send and returns zero. Unknown
1925
+ // extensions are rejected unless |ignore_unknown| is 1.
1926
+ int ssl_parse_extensions(const CBS *cbs, uint8_t *out_alert,
1927
+ const SSL_EXTENSION_TYPE *ext_types,
1928
+ size_t num_ext_types, int ignore_unknown);
1929
+
1930
+ // ssl_verify_peer_cert verifies the peer certificate for |hs|.
1931
+ enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs);
1932
+ // ssl_reverify_peer_cert verifies the peer certificate for |hs| when resuming a
1933
+ // session.
1934
+ enum ssl_verify_result_t ssl_reverify_peer_cert(SSL_HANDSHAKE *hs,
1935
+ bool send_alert);
1936
+
1937
+ enum ssl_hs_wait_t ssl_get_finished(SSL_HANDSHAKE *hs);
1938
+ bool ssl_send_finished(SSL_HANDSHAKE *hs);
1939
+ bool ssl_output_cert_chain(SSL_HANDSHAKE *hs);
1940
+
1941
+ // SSLKEYLOGFILE functions.
1942
+
1943
+ // ssl_log_secret logs |secret| with label |label|, if logging is enabled for
1944
+ // |ssl|. It returns true on success and false on failure.
1945
+ bool ssl_log_secret(const SSL *ssl, const char *label,
1946
+ Span<const uint8_t> secret);
1947
+
1948
+
1949
+ // ClientHello functions.
1950
+
1951
+ bool ssl_client_hello_init(const SSL *ssl, SSL_CLIENT_HELLO *out,
1952
+ const SSLMessage &msg);
1953
+
1954
+ bool ssl_client_hello_get_extension(const SSL_CLIENT_HELLO *client_hello,
1955
+ CBS *out, uint16_t extension_type);
1956
+
1957
+ bool ssl_client_cipher_list_contains_cipher(
1958
+ const SSL_CLIENT_HELLO *client_hello, uint16_t id);
1959
+
1960
+
1961
+ // GREASE.
1962
+
1963
+ // ssl_get_grease_value returns a GREASE value for |hs|. For a given
1964
+ // connection, the values for each index will be deterministic. This allows the
1965
+ // same ClientHello be sent twice for a HelloRetryRequest or the same group be
1966
+ // advertised in both supported_groups and key_shares.
1967
+ uint16_t ssl_get_grease_value(SSL_HANDSHAKE *hs, enum ssl_grease_index_t index);
1968
+
1969
+
1970
+ // Signature algorithms.
1971
+
1972
+ // tls1_parse_peer_sigalgs parses |sigalgs| as the list of peer signature
1973
+ // algorithms and saves them on |hs|. It returns true on success and false on
1974
+ // error.
1975
+ bool tls1_parse_peer_sigalgs(SSL_HANDSHAKE *hs, const CBS *sigalgs);
1976
+
1977
+ // tls1_get_legacy_signature_algorithm sets |*out| to the signature algorithm
1978
+ // that should be used with |pkey| in TLS 1.1 and earlier. It returns true on
1979
+ // success and false if |pkey| may not be used at those versions.
1980
+ bool tls1_get_legacy_signature_algorithm(uint16_t *out, const EVP_PKEY *pkey);
1981
+
1982
+ // tls1_choose_signature_algorithm sets |*out| to a signature algorithm for use
1983
+ // with |hs|'s private key based on the peer's preferences and the algorithms
1984
+ // supported. It returns true on success and false on error.
1985
+ bool tls1_choose_signature_algorithm(SSL_HANDSHAKE *hs, uint16_t *out);
1986
+
1987
+ // tls1_get_peer_verify_algorithms returns the signature schemes for which the
1988
+ // peer indicated support.
1989
+ //
1990
+ // NOTE: The related function |SSL_get0_peer_verify_algorithms| only has
1991
+ // well-defined behavior during the callbacks set by |SSL_CTX_set_cert_cb| and
1992
+ // |SSL_CTX_set_client_cert_cb|, or when the handshake is paused because of
1993
+ // them.
1994
+ Span<const uint16_t> tls1_get_peer_verify_algorithms(const SSL_HANDSHAKE *hs);
1995
+
1996
+ // tls12_add_verify_sigalgs adds the signature algorithms acceptable for the
1997
+ // peer signature to |out|. It returns true on success and false on error.
1998
+ bool tls12_add_verify_sigalgs(const SSL_HANDSHAKE *hs, CBB *out);
1999
+
2000
+ // tls12_check_peer_sigalg checks if |sigalg| is acceptable for the peer
2001
+ // signature. It returns true on success and false on error, setting
2002
+ // |*out_alert| to an alert to send.
2003
+ bool tls12_check_peer_sigalg(const SSL_HANDSHAKE *hs, uint8_t *out_alert,
2004
+ uint16_t sigalg);
2005
+
2006
+
2007
+ // Underdocumented functions.
2008
+ //
2009
+ // Functions below here haven't been touched up and may be underdocumented.
2010
+
2011
+ #define TLSEXT_CHANNEL_ID_SIZE 128
2012
+
2013
+ // From RFC4492, used in encoding the curve type in ECParameters
2014
+ #define NAMED_CURVE_TYPE 3
2015
+
2016
+ struct CERT {
2017
+ static constexpr bool kAllowUniquePtr = true;
2018
+
2019
+ explicit CERT(const SSL_X509_METHOD *x509_method);
2020
+ ~CERT();
2021
+
2022
+ UniquePtr<EVP_PKEY> privatekey;
2023
+
2024
+ // chain contains the certificate chain, with the leaf at the beginning. The
2025
+ // first element of |chain| may be NULL to indicate that the leaf certificate
2026
+ // has not yet been set.
2027
+ // If |chain| != NULL -> len(chain) >= 1
2028
+ // If |chain[0]| == NULL -> len(chain) >= 2.
2029
+ // |chain[1..]| != NULL
2030
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> chain;
2031
+
2032
+ // x509_chain may contain a parsed copy of |chain[1..]|. This is only used as
2033
+ // a cache in order to implement “get0” functions that return a non-owning
2034
+ // pointer to the certificate chain.
2035
+ STACK_OF(X509) *x509_chain = nullptr;
2036
+
2037
+ // x509_leaf may contain a parsed copy of the first element of |chain|. This
2038
+ // is only used as a cache in order to implement “get0” functions that return
2039
+ // a non-owning pointer to the certificate chain.
2040
+ X509 *x509_leaf = nullptr;
2041
+
2042
+ // x509_stash contains the last |X509| object append to the chain. This is a
2043
+ // workaround for some third-party code that continue to use an |X509| object
2044
+ // even after passing ownership with an “add0” function.
2045
+ X509 *x509_stash = nullptr;
2046
+
2047
+ // key_method, if non-NULL, is a set of callbacks to call for private key
2048
+ // operations.
2049
+ const SSL_PRIVATE_KEY_METHOD *key_method = nullptr;
2050
+
2051
+ // x509_method contains pointers to functions that might deal with |X509|
2052
+ // compatibility, or might be a no-op, depending on the application.
2053
+ const SSL_X509_METHOD *x509_method = nullptr;
2054
+
2055
+ // sigalgs, if non-empty, is the set of signature algorithms supported by
2056
+ // |privatekey| in decreasing order of preference.
2057
+ Array<uint16_t> sigalgs;
2058
+
2059
+ // Certificate setup callback: if set is called whenever a
2060
+ // certificate may be required (client or server). the callback
2061
+ // can then examine any appropriate parameters and setup any
2062
+ // certificates required. This allows advanced applications
2063
+ // to select certificates on the fly: for example based on
2064
+ // supported signature algorithms or curves.
2065
+ int (*cert_cb)(SSL *ssl, void *arg) = nullptr;
2066
+ void *cert_cb_arg = nullptr;
2067
+
2068
+ // Optional X509_STORE for certificate validation. If NULL the parent SSL_CTX
2069
+ // store is used instead.
2070
+ X509_STORE *verify_store = nullptr;
2071
+
2072
+ // Signed certificate timestamp list to be sent to the client, if requested
2073
+ UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
2074
+
2075
+ // OCSP response to be sent to the client, if requested.
2076
+ UniquePtr<CRYPTO_BUFFER> ocsp_response;
2077
+
2078
+ // sid_ctx partitions the session space within a shared session cache or
2079
+ // ticket key. Only sessions with a matching value will be accepted.
2080
+ uint8_t sid_ctx_length = 0;
2081
+ uint8_t sid_ctx[SSL_MAX_SID_CTX_LENGTH] = {0};
2082
+
2083
+ // Delegated credentials.
2084
+
2085
+ // dc is the delegated credential to send to the peer (if requested).
2086
+ UniquePtr<DC> dc = nullptr;
2087
+
2088
+ // dc_privatekey is used instead of |privatekey| or |key_method| to
2089
+ // authenticate the host if a delegated credential is used in the handshake.
2090
+ UniquePtr<EVP_PKEY> dc_privatekey = nullptr;
2091
+
2092
+ // dc_key_method, if not NULL, is used instead of |dc_privatekey| to
2093
+ // authenticate the host.
2094
+ const SSL_PRIVATE_KEY_METHOD *dc_key_method = nullptr;
2095
+ };
2096
+
2097
+ // |SSL_PROTOCOL_METHOD| abstracts between TLS and DTLS.
2098
+ struct SSL_PROTOCOL_METHOD {
2099
+ bool is_dtls;
2100
+ bool (*ssl_new)(SSL *ssl);
2101
+ void (*ssl_free)(SSL *ssl);
2102
+ // get_message sets |*out| to the current handshake message and returns true
2103
+ // if one has been received. It returns false if more input is needed.
2104
+ bool (*get_message)(const SSL *ssl, SSLMessage *out);
2105
+ // next_message is called to release the current handshake message.
2106
+ void (*next_message)(SSL *ssl);
2107
+ // has_unprocessed_handshake_data returns whether there is buffered
2108
+ // handshake data that has not been consumed by |get_message|.
2109
+ bool (*has_unprocessed_handshake_data)(const SSL *ssl);
2110
+ // Use the |ssl_open_handshake| wrapper.
2111
+ ssl_open_record_t (*open_handshake)(SSL *ssl, size_t *out_consumed,
2112
+ uint8_t *out_alert, Span<uint8_t> in);
2113
+ // Use the |ssl_open_change_cipher_spec| wrapper.
2114
+ ssl_open_record_t (*open_change_cipher_spec)(SSL *ssl, size_t *out_consumed,
2115
+ uint8_t *out_alert,
2116
+ Span<uint8_t> in);
2117
+ // Use the |ssl_open_app_data| wrapper.
2118
+ ssl_open_record_t (*open_app_data)(SSL *ssl, Span<uint8_t> *out,
2119
+ size_t *out_consumed, uint8_t *out_alert,
2120
+ Span<uint8_t> in);
2121
+ int (*write_app_data)(SSL *ssl, bool *out_needs_handshake, const uint8_t *buf,
2122
+ int len);
2123
+ int (*dispatch_alert)(SSL *ssl);
2124
+ // init_message begins a new handshake message of type |type|. |cbb| is the
2125
+ // root CBB to be passed into |finish_message|. |*body| is set to a child CBB
2126
+ // the caller should write to. It returns true on success and false on error.
2127
+ bool (*init_message)(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2128
+ // finish_message finishes a handshake message. It sets |*out_msg| to the
2129
+ // serialized message. It returns true on success and false on error.
2130
+ bool (*finish_message)(SSL *ssl, CBB *cbb, bssl::Array<uint8_t> *out_msg);
2131
+ // add_message adds a handshake message to the pending flight. It returns
2132
+ // true on success and false on error.
2133
+ bool (*add_message)(SSL *ssl, bssl::Array<uint8_t> msg);
2134
+ // add_change_cipher_spec adds a ChangeCipherSpec record to the pending
2135
+ // flight. It returns true on success and false on error.
2136
+ bool (*add_change_cipher_spec)(SSL *ssl);
2137
+ // flush_flight flushes the pending flight to the transport. It returns one on
2138
+ // success and <= 0 on error.
2139
+ int (*flush_flight)(SSL *ssl);
2140
+ // on_handshake_complete is called when the handshake is complete.
2141
+ void (*on_handshake_complete)(SSL *ssl);
2142
+ // set_read_state sets |ssl|'s read cipher state and level to |aead_ctx| and
2143
+ // |level|. In QUIC, |aead_ctx| is a placeholder object and |secret_for_quic|
2144
+ // is the original secret. This function returns true on success and false on
2145
+ // error.
2146
+ bool (*set_read_state)(SSL *ssl, ssl_encryption_level_t level,
2147
+ UniquePtr<SSLAEADContext> aead_ctx,
2148
+ Span<const uint8_t> secret_for_quic);
2149
+ // set_write_state sets |ssl|'s write cipher state and level to |aead_ctx| and
2150
+ // |level|. In QUIC, |aead_ctx| is a placeholder object and |secret_for_quic|
2151
+ // is the original secret. This function returns true on success and false on
2152
+ // error.
2153
+ bool (*set_write_state)(SSL *ssl, ssl_encryption_level_t level,
2154
+ UniquePtr<SSLAEADContext> aead_ctx,
2155
+ Span<const uint8_t> secret_for_quic);
2156
+ };
2157
+
2158
+ // The following wrappers call |open_*| but handle |read_shutdown| correctly.
2159
+
2160
+ // ssl_open_handshake processes a record from |in| for reading a handshake
2161
+ // message.
2162
+ ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
2163
+ uint8_t *out_alert, Span<uint8_t> in);
2164
+
2165
+ // ssl_open_change_cipher_spec processes a record from |in| for reading a
2166
+ // ChangeCipherSpec.
2167
+ ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2168
+ uint8_t *out_alert,
2169
+ Span<uint8_t> in);
2170
+
2171
+ // ssl_open_app_data processes a record from |in| for reading application data.
2172
+ // On success, it returns |ssl_open_record_success| and sets |*out| to the
2173
+ // input. If it encounters a post-handshake message, it returns
2174
+ // |ssl_open_record_discard|. The caller should then retry, after processing any
2175
+ // messages received with |get_message|.
2176
+ ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
2177
+ size_t *out_consumed, uint8_t *out_alert,
2178
+ Span<uint8_t> in);
2179
+
2180
+ struct SSL_X509_METHOD {
2181
+ // check_client_CA_list returns one if |names| is a good list of X.509
2182
+ // distinguished names and zero otherwise. This is used to ensure that we can
2183
+ // reject unparsable values at handshake time when using crypto/x509.
2184
+ bool (*check_client_CA_list)(STACK_OF(CRYPTO_BUFFER) *names);
2185
+
2186
+ // cert_clear frees and NULLs all X509 certificate-related state.
2187
+ void (*cert_clear)(CERT *cert);
2188
+ // cert_free frees all X509-related state.
2189
+ void (*cert_free)(CERT *cert);
2190
+ // cert_flush_cached_chain drops any cached |X509|-based certificate chain
2191
+ // from |cert|.
2192
+ // cert_dup duplicates any needed fields from |cert| to |new_cert|.
2193
+ void (*cert_dup)(CERT *new_cert, const CERT *cert);
2194
+ void (*cert_flush_cached_chain)(CERT *cert);
2195
+ // cert_flush_cached_chain drops any cached |X509|-based leaf certificate
2196
+ // from |cert|.
2197
+ void (*cert_flush_cached_leaf)(CERT *cert);
2198
+
2199
+ // session_cache_objects fills out |sess->x509_peer| and |sess->x509_chain|
2200
+ // from |sess->certs| and erases |sess->x509_chain_without_leaf|. It returns
2201
+ // true on success or false on error.
2202
+ bool (*session_cache_objects)(SSL_SESSION *session);
2203
+ // session_dup duplicates any needed fields from |session| to |new_session|.
2204
+ // It returns true on success or false on error.
2205
+ bool (*session_dup)(SSL_SESSION *new_session, const SSL_SESSION *session);
2206
+ // session_clear frees any X509-related state from |session|.
2207
+ void (*session_clear)(SSL_SESSION *session);
2208
+ // session_verify_cert_chain verifies the certificate chain in |session|,
2209
+ // sets |session->verify_result| and returns true on success or false on
2210
+ // error.
2211
+ bool (*session_verify_cert_chain)(SSL_SESSION *session, SSL_HANDSHAKE *ssl,
2212
+ uint8_t *out_alert);
2213
+
2214
+ // hs_flush_cached_ca_names drops any cached |X509_NAME|s from |hs|.
2215
+ void (*hs_flush_cached_ca_names)(SSL_HANDSHAKE *hs);
2216
+ // ssl_new does any necessary initialisation of |hs|. It returns true on
2217
+ // success or false on error.
2218
+ bool (*ssl_new)(SSL_HANDSHAKE *hs);
2219
+ // ssl_free frees anything created by |ssl_new|.
2220
+ void (*ssl_config_free)(SSL_CONFIG *cfg);
2221
+ // ssl_flush_cached_client_CA drops any cached |X509_NAME|s from |ssl|.
2222
+ void (*ssl_flush_cached_client_CA)(SSL_CONFIG *cfg);
2223
+ // ssl_auto_chain_if_needed runs the deprecated auto-chaining logic if
2224
+ // necessary. On success, it updates |ssl|'s certificate configuration as
2225
+ // needed and returns true. Otherwise, it returns false.
2226
+ bool (*ssl_auto_chain_if_needed)(SSL_HANDSHAKE *hs);
2227
+ // ssl_ctx_new does any necessary initialisation of |ctx|. It returns true on
2228
+ // success or false on error.
2229
+ bool (*ssl_ctx_new)(SSL_CTX *ctx);
2230
+ // ssl_ctx_free frees anything created by |ssl_ctx_new|.
2231
+ void (*ssl_ctx_free)(SSL_CTX *ctx);
2232
+ // ssl_ctx_flush_cached_client_CA drops any cached |X509_NAME|s from |ctx|.
2233
+ void (*ssl_ctx_flush_cached_client_CA)(SSL_CTX *ssl);
2234
+ };
2235
+
2236
+ // ssl_crypto_x509_method provides the |SSL_X509_METHOD| functions using
2237
+ // crypto/x509.
2238
+ extern const SSL_X509_METHOD ssl_crypto_x509_method;
2239
+
2240
+ // ssl_noop_x509_method provides the |SSL_X509_METHOD| functions that avoid
2241
+ // crypto/x509.
2242
+ extern const SSL_X509_METHOD ssl_noop_x509_method;
2243
+
2244
+ struct TicketKey {
2245
+ static constexpr bool kAllowUniquePtr = true;
2246
+
2247
+ uint8_t name[SSL_TICKET_KEY_NAME_LEN] = {0};
2248
+ uint8_t hmac_key[16] = {0};
2249
+ uint8_t aes_key[16] = {0};
2250
+ // next_rotation_tv_sec is the time (in seconds from the epoch) when the
2251
+ // current key should be superseded by a new key, or the time when a previous
2252
+ // key should be dropped. If zero, then the key should not be automatically
2253
+ // rotated.
2254
+ uint64_t next_rotation_tv_sec = 0;
2255
+ };
2256
+
2257
+ struct CertCompressionAlg {
2258
+ static constexpr bool kAllowUniquePtr = true;
2259
+
2260
+ ssl_cert_compression_func_t compress = nullptr;
2261
+ ssl_cert_decompression_func_t decompress = nullptr;
2262
+ uint16_t alg_id = 0;
2263
+ };
2264
+
2265
+ BSSL_NAMESPACE_END
2266
+
2267
+ DEFINE_LHASH_OF(SSL_SESSION)
2268
+
2269
+ BSSL_NAMESPACE_BEGIN
2270
+
2271
+ // An ssl_shutdown_t describes the shutdown state of one end of the connection,
2272
+ // whether it is alive or has been shutdown via close_notify or fatal alert.
2273
+ enum ssl_shutdown_t {
2274
+ ssl_shutdown_none = 0,
2275
+ ssl_shutdown_close_notify = 1,
2276
+ ssl_shutdown_error = 2,
2277
+ };
2278
+
2279
+ struct SSL3_STATE {
2280
+ static constexpr bool kAllowUniquePtr = true;
2281
+
2282
+ SSL3_STATE();
2283
+ ~SSL3_STATE();
2284
+
2285
+ uint8_t read_sequence[8] = {0};
2286
+ uint8_t write_sequence[8] = {0};
2287
+
2288
+ uint8_t server_random[SSL3_RANDOM_SIZE] = {0};
2289
+ uint8_t client_random[SSL3_RANDOM_SIZE] = {0};
2290
+
2291
+ // read_buffer holds data from the transport to be processed.
2292
+ SSLBuffer read_buffer;
2293
+ // write_buffer holds data to be written to the transport.
2294
+ SSLBuffer write_buffer;
2295
+
2296
+ // pending_app_data is the unconsumed application data. It points into
2297
+ // |read_buffer|.
2298
+ Span<uint8_t> pending_app_data;
2299
+
2300
+ // partial write - check the numbers match
2301
+ unsigned int wnum = 0; // number of bytes sent so far
2302
+ int wpend_tot = 0; // number bytes written
2303
+ int wpend_type = 0;
2304
+ int wpend_ret = 0; // number of bytes submitted
2305
+ const uint8_t *wpend_buf = nullptr;
2306
+
2307
+ // read_shutdown is the shutdown state for the read half of the connection.
2308
+ enum ssl_shutdown_t read_shutdown = ssl_shutdown_none;
2309
+
2310
+ // write_shutdown is the shutdown state for the write half of the connection.
2311
+ enum ssl_shutdown_t write_shutdown = ssl_shutdown_none;
2312
+
2313
+ // read_error, if |read_shutdown| is |ssl_shutdown_error|, is the error for
2314
+ // the receive half of the connection.
2315
+ UniquePtr<ERR_SAVE_STATE> read_error;
2316
+
2317
+ int total_renegotiations = 0;
2318
+
2319
+ // This holds a variable that indicates what we were doing when a 0 or -1 is
2320
+ // returned. This is needed for non-blocking IO so we know what request
2321
+ // needs re-doing when in SSL_accept or SSL_connect
2322
+ int rwstate = SSL_ERROR_NONE;
2323
+
2324
+ enum ssl_encryption_level_t read_level = ssl_encryption_initial;
2325
+ enum ssl_encryption_level_t write_level = ssl_encryption_initial;
2326
+
2327
+ // early_data_skipped is the amount of early data that has been skipped by the
2328
+ // record layer.
2329
+ uint16_t early_data_skipped = 0;
2330
+
2331
+ // empty_record_count is the number of consecutive empty records received.
2332
+ uint8_t empty_record_count = 0;
2333
+
2334
+ // warning_alert_count is the number of consecutive warning alerts
2335
+ // received.
2336
+ uint8_t warning_alert_count = 0;
2337
+
2338
+ // key_update_count is the number of consecutive KeyUpdates received.
2339
+ uint8_t key_update_count = 0;
2340
+
2341
+ // The negotiated Token Binding key parameter. Only valid if
2342
+ // |token_binding_negotiated| is set.
2343
+ uint8_t negotiated_token_binding_param = 0;
2344
+
2345
+ // skip_early_data instructs the record layer to skip unexpected early data
2346
+ // messages when 0RTT is rejected.
2347
+ bool skip_early_data : 1;
2348
+
2349
+ // have_version is true if the connection's final version is known. Otherwise
2350
+ // the version has not been negotiated yet.
2351
+ bool have_version : 1;
2352
+
2353
+ // v2_hello_done is true if the peer's V2ClientHello, if any, has been handled
2354
+ // and future messages should use the record layer.
2355
+ bool v2_hello_done : 1;
2356
+
2357
+ // is_v2_hello is true if the current handshake message was derived from a
2358
+ // V2ClientHello rather than received from the peer directly.
2359
+ bool is_v2_hello : 1;
2360
+
2361
+ // has_message is true if the current handshake message has been returned
2362
+ // at least once by |get_message| and false otherwise.
2363
+ bool has_message : 1;
2364
+
2365
+ // initial_handshake_complete is true if the initial handshake has
2366
+ // completed.
2367
+ bool initial_handshake_complete : 1;
2368
+
2369
+ // session_reused indicates whether a session was resumed.
2370
+ bool session_reused : 1;
2371
+
2372
+ // delegated_credential_used is whether we presented a delegated credential to
2373
+ // the peer.
2374
+ bool delegated_credential_used : 1;
2375
+
2376
+ bool send_connection_binding : 1;
2377
+
2378
+ // In a client, this means that the server supported Channel ID and that a
2379
+ // Channel ID was sent. In a server it means that we echoed support for
2380
+ // Channel IDs and that |channel_id| will be valid after the handshake.
2381
+ bool channel_id_valid : 1;
2382
+
2383
+ // key_update_pending is true if we have a KeyUpdate acknowledgment
2384
+ // outstanding.
2385
+ bool key_update_pending : 1;
2386
+
2387
+ // wpend_pending is true if we have a pending write outstanding.
2388
+ bool wpend_pending : 1;
2389
+
2390
+ // early_data_accepted is true if early data was accepted by the server.
2391
+ bool early_data_accepted : 1;
2392
+
2393
+ // tls13_downgrade is whether the TLS 1.3 anti-downgrade logic fired.
2394
+ bool tls13_downgrade : 1;
2395
+
2396
+ // token_binding_negotiated is set if Token Binding was negotiated.
2397
+ bool token_binding_negotiated : 1;
2398
+
2399
+ // alert_dispatch is true there is an alert in |send_alert| to be sent.
2400
+ bool alert_dispatch : 1;
2401
+
2402
+ // renegotiate_pending is whether the read half of the channel is blocked on a
2403
+ // HelloRequest.
2404
+ bool renegotiate_pending : 1;
2405
+
2406
+ // used_hello_retry_request is whether the handshake used a TLS 1.3
2407
+ // HelloRetryRequest message.
2408
+ bool used_hello_retry_request : 1;
2409
+
2410
+ // hs_buf is the buffer of handshake data to process.
2411
+ UniquePtr<BUF_MEM> hs_buf;
2412
+
2413
+ // pending_hs_data contains the pending handshake data that has not yet
2414
+ // been encrypted to |pending_flight|. This allows packing the handshake into
2415
+ // fewer records.
2416
+ UniquePtr<BUF_MEM> pending_hs_data;
2417
+
2418
+ // pending_flight is the pending outgoing flight. This is used to flush each
2419
+ // handshake flight in a single write. |write_buffer| must be written out
2420
+ // before this data.
2421
+ UniquePtr<BUF_MEM> pending_flight;
2422
+
2423
+ // pending_flight_offset is the number of bytes of |pending_flight| which have
2424
+ // been successfully written.
2425
+ uint32_t pending_flight_offset = 0;
2426
+
2427
+ // ticket_age_skew is the difference, in seconds, between the client-sent
2428
+ // ticket age and the server-computed value in TLS 1.3 server connections
2429
+ // which resumed a session.
2430
+ int32_t ticket_age_skew = 0;
2431
+
2432
+ // ssl_early_data_reason stores details on why 0-RTT was accepted or rejected.
2433
+ enum ssl_early_data_reason_t early_data_reason = ssl_early_data_unknown;
2434
+
2435
+ // aead_read_ctx is the current read cipher state.
2436
+ UniquePtr<SSLAEADContext> aead_read_ctx;
2437
+
2438
+ // aead_write_ctx is the current write cipher state.
2439
+ UniquePtr<SSLAEADContext> aead_write_ctx;
2440
+
2441
+ // hs is the handshake state for the current handshake or NULL if there isn't
2442
+ // one.
2443
+ UniquePtr<SSL_HANDSHAKE> hs;
2444
+
2445
+ uint8_t write_traffic_secret[SSL_MAX_MD_SIZE] = {0};
2446
+ uint8_t read_traffic_secret[SSL_MAX_MD_SIZE] = {0};
2447
+ uint8_t exporter_secret[SSL_MAX_MD_SIZE] = {0};
2448
+ uint8_t write_traffic_secret_len = 0;
2449
+ uint8_t read_traffic_secret_len = 0;
2450
+ uint8_t exporter_secret_len = 0;
2451
+
2452
+ // Connection binding to prevent renegotiation attacks
2453
+ uint8_t previous_client_finished[12] = {0};
2454
+ uint8_t previous_client_finished_len = 0;
2455
+ uint8_t previous_server_finished_len = 0;
2456
+ uint8_t previous_server_finished[12] = {0};
2457
+
2458
+ uint8_t send_alert[2] = {0};
2459
+
2460
+ // established_session is the session established by the connection. This
2461
+ // session is only filled upon the completion of the handshake and is
2462
+ // immutable.
2463
+ UniquePtr<SSL_SESSION> established_session;
2464
+
2465
+ // Next protocol negotiation. For the client, this is the protocol that we
2466
+ // sent in NextProtocol and is set when handling ServerHello extensions.
2467
+ //
2468
+ // For a server, this is the client's selected_protocol from NextProtocol and
2469
+ // is set when handling the NextProtocol message, before the Finished
2470
+ // message.
2471
+ Array<uint8_t> next_proto_negotiated;
2472
+
2473
+ // ALPN information
2474
+ // (we are in the process of transitioning from NPN to ALPN.)
2475
+
2476
+ // In a server these point to the selected ALPN protocol after the
2477
+ // ClientHello has been processed. In a client these contain the protocol
2478
+ // that the server selected once the ServerHello has been processed.
2479
+ Array<uint8_t> alpn_selected;
2480
+
2481
+ // hostname, on the server, is the value of the SNI extension.
2482
+ UniquePtr<char> hostname;
2483
+
2484
+ // For a server:
2485
+ // If |channel_id_valid| is true, then this contains the
2486
+ // verified Channel ID from the client: a P256 point, (x,y), where
2487
+ // each are big-endian values.
2488
+ uint8_t channel_id[64] = {0};
2489
+
2490
+ // Contains the QUIC transport params received by the peer.
2491
+ Array<uint8_t> peer_quic_transport_params;
2492
+
2493
+ // srtp_profile is the selected SRTP protection profile for
2494
+ // DTLS-SRTP.
2495
+ const SRTP_PROTECTION_PROFILE *srtp_profile = nullptr;
2496
+ };
2497
+
2498
+ // lengths of messages
2499
+ #define DTLS1_COOKIE_LENGTH 256
2500
+
2501
+ #define DTLS1_RT_HEADER_LENGTH 13
2502
+
2503
+ #define DTLS1_HM_HEADER_LENGTH 12
2504
+
2505
+ #define DTLS1_CCS_HEADER_LENGTH 1
2506
+
2507
+ #define DTLS1_AL_HEADER_LENGTH 2
2508
+
2509
+ struct hm_header_st {
2510
+ uint8_t type;
2511
+ uint32_t msg_len;
2512
+ uint16_t seq;
2513
+ uint32_t frag_off;
2514
+ uint32_t frag_len;
2515
+ };
2516
+
2517
+ // An hm_fragment is an incoming DTLS message, possibly not yet assembled.
2518
+ struct hm_fragment {
2519
+ static constexpr bool kAllowUniquePtr = true;
2520
+
2521
+ hm_fragment() {}
2522
+ hm_fragment(const hm_fragment &) = delete;
2523
+ hm_fragment &operator=(const hm_fragment &) = delete;
2524
+
2525
+ ~hm_fragment();
2526
+
2527
+ // type is the type of the message.
2528
+ uint8_t type = 0;
2529
+ // seq is the sequence number of this message.
2530
+ uint16_t seq = 0;
2531
+ // msg_len is the length of the message body.
2532
+ uint32_t msg_len = 0;
2533
+ // data is a pointer to the message, including message header. It has length
2534
+ // |DTLS1_HM_HEADER_LENGTH| + |msg_len|.
2535
+ uint8_t *data = nullptr;
2536
+ // reassembly is a bitmask of |msg_len| bits corresponding to which parts of
2537
+ // the message have been received. It is NULL if the message is complete.
2538
+ uint8_t *reassembly = nullptr;
2539
+ };
2540
+
2541
+ struct OPENSSL_timeval {
2542
+ uint64_t tv_sec;
2543
+ uint32_t tv_usec;
2544
+ };
2545
+
2546
+ struct DTLS1_STATE {
2547
+ static constexpr bool kAllowUniquePtr = true;
2548
+
2549
+ DTLS1_STATE();
2550
+ ~DTLS1_STATE();
2551
+
2552
+ // has_change_cipher_spec is true if we have received a ChangeCipherSpec from
2553
+ // the peer in this epoch.
2554
+ bool has_change_cipher_spec : 1;
2555
+
2556
+ // outgoing_messages_complete is true if |outgoing_messages| has been
2557
+ // completed by an attempt to flush it. Future calls to |add_message| and
2558
+ // |add_change_cipher_spec| will start a new flight.
2559
+ bool outgoing_messages_complete : 1;
2560
+
2561
+ // flight_has_reply is true if the current outgoing flight is complete and has
2562
+ // processed at least one message. This is used to detect whether we or the
2563
+ // peer sent the final flight.
2564
+ bool flight_has_reply : 1;
2565
+
2566
+ uint8_t cookie[DTLS1_COOKIE_LENGTH] = {0};
2567
+ size_t cookie_len = 0;
2568
+
2569
+ // The current data and handshake epoch. This is initially undefined, and
2570
+ // starts at zero once the initial handshake is completed.
2571
+ uint16_t r_epoch = 0;
2572
+ uint16_t w_epoch = 0;
2573
+
2574
+ // records being received in the current epoch
2575
+ DTLS1_BITMAP bitmap;
2576
+
2577
+ uint16_t handshake_write_seq = 0;
2578
+ uint16_t handshake_read_seq = 0;
2579
+
2580
+ // save last sequence number for retransmissions
2581
+ uint8_t last_write_sequence[8] = {0};
2582
+ UniquePtr<SSLAEADContext> last_aead_write_ctx;
2583
+
2584
+ // incoming_messages is a ring buffer of incoming handshake messages that have
2585
+ // yet to be processed. The front of the ring buffer is message number
2586
+ // |handshake_read_seq|, at position |handshake_read_seq| %
2587
+ // |SSL_MAX_HANDSHAKE_FLIGHT|.
2588
+ UniquePtr<hm_fragment> incoming_messages[SSL_MAX_HANDSHAKE_FLIGHT];
2589
+
2590
+ // outgoing_messages is the queue of outgoing messages from the last handshake
2591
+ // flight.
2592
+ DTLS_OUTGOING_MESSAGE outgoing_messages[SSL_MAX_HANDSHAKE_FLIGHT];
2593
+ uint8_t outgoing_messages_len = 0;
2594
+
2595
+ // outgoing_written is the number of outgoing messages that have been
2596
+ // written.
2597
+ uint8_t outgoing_written = 0;
2598
+ // outgoing_offset is the number of bytes of the next outgoing message have
2599
+ // been written.
2600
+ uint32_t outgoing_offset = 0;
2601
+
2602
+ unsigned mtu = 0; // max DTLS packet size
2603
+
2604
+ // num_timeouts is the number of times the retransmit timer has fired since
2605
+ // the last time it was reset.
2606
+ unsigned num_timeouts = 0;
2607
+
2608
+ // Indicates when the last handshake msg or heartbeat sent will
2609
+ // timeout.
2610
+ struct OPENSSL_timeval next_timeout = {0, 0};
2611
+
2612
+ // timeout_duration_ms is the timeout duration in milliseconds.
2613
+ unsigned timeout_duration_ms = 0;
2614
+ };
2615
+
2616
+ // SSL_CONFIG contains configuration bits that can be shed after the handshake
2617
+ // completes. Objects of this type are not shared; they are unique to a
2618
+ // particular |SSL|.
2619
+ //
2620
+ // See SSL_shed_handshake_config() for more about the conditions under which
2621
+ // configuration can be shed.
2622
+ struct SSL_CONFIG {
2623
+ static constexpr bool kAllowUniquePtr = true;
2624
+
2625
+ explicit SSL_CONFIG(SSL *ssl_arg);
2626
+ ~SSL_CONFIG();
2627
+
2628
+ // ssl is a non-owning pointer to the parent |SSL| object.
2629
+ SSL *const ssl = nullptr;
2630
+
2631
+ // conf_max_version is the maximum acceptable version configured by
2632
+ // |SSL_set_max_proto_version|. Note this version is not normalized in DTLS
2633
+ // and is further constrained by |SSL_OP_NO_*|.
2634
+ uint16_t conf_max_version = 0;
2635
+
2636
+ // conf_min_version is the minimum acceptable version configured by
2637
+ // |SSL_set_min_proto_version|. Note this version is not normalized in DTLS
2638
+ // and is further constrained by |SSL_OP_NO_*|.
2639
+ uint16_t conf_min_version = 0;
2640
+
2641
+ X509_VERIFY_PARAM *param = nullptr;
2642
+
2643
+ // crypto
2644
+ UniquePtr<SSLCipherPreferenceList> cipher_list;
2645
+
2646
+ // This is used to hold the local certificate used (i.e. the server
2647
+ // certificate for a server or the client certificate for a client).
2648
+ UniquePtr<CERT> cert;
2649
+
2650
+ int (*verify_callback)(int ok,
2651
+ X509_STORE_CTX *ctx) =
2652
+ nullptr; // fail if callback returns 0
2653
+
2654
+ enum ssl_verify_result_t (*custom_verify_callback)(
2655
+ SSL *ssl, uint8_t *out_alert) = nullptr;
2656
+ // Server-only: psk_identity_hint is the identity hint to send in
2657
+ // PSK-based key exchanges.
2658
+ UniquePtr<char> psk_identity_hint;
2659
+
2660
+ unsigned (*psk_client_callback)(SSL *ssl, const char *hint, char *identity,
2661
+ unsigned max_identity_len, uint8_t *psk,
2662
+ unsigned max_psk_len) = nullptr;
2663
+ unsigned (*psk_server_callback)(SSL *ssl, const char *identity, uint8_t *psk,
2664
+ unsigned max_psk_len) = nullptr;
2665
+
2666
+ // for server side, keep the list of CA_dn we can use
2667
+ UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
2668
+
2669
+ // cached_x509_client_CA is a cache of parsed versions of the elements of
2670
+ // |client_CA|.
2671
+ STACK_OF(X509_NAME) *cached_x509_client_CA = nullptr;
2672
+
2673
+ Array<uint16_t> supported_group_list; // our list
2674
+
2675
+ // The client's Channel ID private key.
2676
+ UniquePtr<EVP_PKEY> channel_id_private;
2677
+
2678
+ // For a client, this contains the list of supported protocols in wire
2679
+ // format.
2680
+ Array<uint8_t> alpn_client_proto_list;
2681
+
2682
+ // Contains a list of supported Token Binding key parameters.
2683
+ Array<uint8_t> token_binding_params;
2684
+
2685
+ // Contains the QUIC transport params that this endpoint will send.
2686
+ Array<uint8_t> quic_transport_params;
2687
+
2688
+ // Contains the context used to decide whether to accept early data in QUIC.
2689
+ Array<uint8_t> quic_early_data_context;
2690
+
2691
+ // verify_sigalgs, if not empty, is the set of signature algorithms
2692
+ // accepted from the peer in decreasing order of preference.
2693
+ Array<uint16_t> verify_sigalgs;
2694
+
2695
+ // srtp_profiles is the list of configured SRTP protection profiles for
2696
+ // DTLS-SRTP.
2697
+ UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> srtp_profiles;
2698
+
2699
+ // verify_mode is a bitmask of |SSL_VERIFY_*| values.
2700
+ uint8_t verify_mode = SSL_VERIFY_NONE;
2701
+
2702
+ // Enable signed certificate time stamps. Currently client only.
2703
+ bool signed_cert_timestamps_enabled : 1;
2704
+
2705
+ // ocsp_stapling_enabled is only used by client connections and indicates
2706
+ // whether OCSP stapling will be requested.
2707
+ bool ocsp_stapling_enabled : 1;
2708
+
2709
+ // channel_id_enabled is copied from the |SSL_CTX|. For a server, means that
2710
+ // we'll accept Channel IDs from clients. For a client, means that we'll
2711
+ // advertise support.
2712
+ bool channel_id_enabled : 1;
2713
+
2714
+ // If enforce_rsa_key_usage is true, the handshake will fail if the
2715
+ // keyUsage extension is present and incompatible with the TLS usage.
2716
+ // This field is not read until after certificate verification.
2717
+ bool enforce_rsa_key_usage : 1;
2718
+
2719
+ // retain_only_sha256_of_client_certs is true if we should compute the SHA256
2720
+ // hash of the peer's certificate and then discard it to save memory and
2721
+ // session space. Only effective on the server side.
2722
+ bool retain_only_sha256_of_client_certs : 1;
2723
+
2724
+ // handoff indicates that a server should stop after receiving the
2725
+ // ClientHello and pause the handshake in such a way that |SSL_get_error|
2726
+ // returns |SSL_ERROR_HANDOFF|. This is copied in |SSL_new| from the |SSL_CTX|
2727
+ // element of the same name and may be cleared if the handoff is declined.
2728
+ bool handoff : 1;
2729
+
2730
+ // shed_handshake_config indicates that the handshake config (this object!)
2731
+ // should be freed after the handshake completes.
2732
+ bool shed_handshake_config : 1;
2733
+
2734
+ // ignore_tls13_downgrade is whether the connection should continue when the
2735
+ // server random signals a downgrade.
2736
+ bool ignore_tls13_downgrade : 1;
2737
+
2738
+ // jdk11_workaround is whether to disable TLS 1.3 for JDK 11 clients, as a
2739
+ // workaround for https://bugs.openjdk.java.net/browse/JDK-8211806.
2740
+ bool jdk11_workaround : 1;
2741
+ };
2742
+
2743
+ // Computes a SHA-256 hash of the transport parameters and early data context
2744
+ // for QUIC, putting the hash in |SHA256_DIGEST_LENGTH| bytes at |hash_out|.
2745
+ bool compute_quic_early_data_hash(const SSL_CONFIG *config,
2746
+ uint8_t hash_out[SHA256_DIGEST_LENGTH]);
2747
+
2748
+ // From RFC 8446, used in determining PSK modes.
2749
+ #define SSL_PSK_DHE_KE 0x1
2750
+
2751
+ // kMaxEarlyDataAccepted is the advertised number of plaintext bytes of early
2752
+ // data that will be accepted. This value should be slightly below
2753
+ // kMaxEarlyDataSkipped in tls_record.c, which is measured in ciphertext.
2754
+ static const size_t kMaxEarlyDataAccepted = 14336;
2755
+
2756
+ UniquePtr<CERT> ssl_cert_dup(CERT *cert);
2757
+ void ssl_cert_clear_certs(CERT *cert);
2758
+ bool ssl_set_cert(CERT *cert, UniquePtr<CRYPTO_BUFFER> buffer);
2759
+ bool ssl_is_key_type_supported(int key_type);
2760
+ // ssl_compare_public_and_private_key returns true if |pubkey| is the public
2761
+ // counterpart to |privkey|. Otherwise it returns false and pushes a helpful
2762
+ // message on the error queue.
2763
+ bool ssl_compare_public_and_private_key(const EVP_PKEY *pubkey,
2764
+ const EVP_PKEY *privkey);
2765
+ bool ssl_cert_check_private_key(const CERT *cert, const EVP_PKEY *privkey);
2766
+ int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server);
2767
+ int ssl_encrypt_ticket(SSL_HANDSHAKE *hs, CBB *out, const SSL_SESSION *session);
2768
+ int ssl_ctx_rotate_ticket_encryption_key(SSL_CTX *ctx);
2769
+
2770
+ // ssl_session_new returns a newly-allocated blank |SSL_SESSION| or nullptr on
2771
+ // error.
2772
+ UniquePtr<SSL_SESSION> ssl_session_new(const SSL_X509_METHOD *x509_method);
2773
+
2774
+ // ssl_hash_session_id returns a hash of |session_id|, suitable for a hash table
2775
+ // keyed on session IDs.
2776
+ uint32_t ssl_hash_session_id(Span<const uint8_t> session_id);
2777
+
2778
+ // SSL_SESSION_parse parses an |SSL_SESSION| from |cbs| and advances |cbs| over
2779
+ // the parsed data.
2780
+ OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_parse(
2781
+ CBS *cbs, const SSL_X509_METHOD *x509_method, CRYPTO_BUFFER_POOL *pool);
2782
+
2783
+ // ssl_session_serialize writes |in| to |cbb| as if it were serialising a
2784
+ // session for Session-ID resumption. It returns one on success and zero on
2785
+ // error.
2786
+ OPENSSL_EXPORT int ssl_session_serialize(const SSL_SESSION *in, CBB *cbb);
2787
+
2788
+ // ssl_session_is_context_valid returns one if |session|'s session ID context
2789
+ // matches the one set on |hs| and zero otherwise.
2790
+ int ssl_session_is_context_valid(const SSL_HANDSHAKE *hs,
2791
+ const SSL_SESSION *session);
2792
+
2793
+ // ssl_session_is_time_valid returns one if |session| is still valid and zero if
2794
+ // it has expired.
2795
+ int ssl_session_is_time_valid(const SSL *ssl, const SSL_SESSION *session);
2796
+
2797
+ // ssl_session_is_resumable returns one if |session| is resumable for |hs| and
2798
+ // zero otherwise.
2799
+ int ssl_session_is_resumable(const SSL_HANDSHAKE *hs,
2800
+ const SSL_SESSION *session);
2801
+
2802
+ // ssl_session_protocol_version returns the protocol version associated with
2803
+ // |session|. Note that despite the name, this is not the same as
2804
+ // |SSL_SESSION_get_protocol_version|. The latter is based on upstream's name.
2805
+ uint16_t ssl_session_protocol_version(const SSL_SESSION *session);
2806
+
2807
+ // ssl_session_get_digest returns the digest used in |session|.
2808
+ const EVP_MD *ssl_session_get_digest(const SSL_SESSION *session);
2809
+
2810
+ void ssl_set_session(SSL *ssl, SSL_SESSION *session);
2811
+
2812
+ // ssl_get_prev_session looks up the previous session based on |client_hello|.
2813
+ // On success, it sets |*out_session| to the session or nullptr if none was
2814
+ // found. If the session could not be looked up synchronously, it returns
2815
+ // |ssl_hs_pending_session| and should be called again. If a ticket could not be
2816
+ // decrypted immediately it returns |ssl_hs_pending_ticket| and should also
2817
+ // be called again. Otherwise, it returns |ssl_hs_error|.
2818
+ enum ssl_hs_wait_t ssl_get_prev_session(SSL_HANDSHAKE *hs,
2819
+ UniquePtr<SSL_SESSION> *out_session,
2820
+ bool *out_tickets_supported,
2821
+ bool *out_renew_ticket,
2822
+ const SSL_CLIENT_HELLO *client_hello);
2823
+
2824
+ // The following flags determine which parts of the session are duplicated.
2825
+ #define SSL_SESSION_DUP_AUTH_ONLY 0x0
2826
+ #define SSL_SESSION_INCLUDE_TICKET 0x1
2827
+ #define SSL_SESSION_INCLUDE_NONAUTH 0x2
2828
+ #define SSL_SESSION_DUP_ALL \
2829
+ (SSL_SESSION_INCLUDE_TICKET | SSL_SESSION_INCLUDE_NONAUTH)
2830
+
2831
+ // SSL_SESSION_dup returns a newly-allocated |SSL_SESSION| with a copy of the
2832
+ // fields in |session| or nullptr on error. The new session is non-resumable and
2833
+ // must be explicitly marked resumable once it has been filled in.
2834
+ OPENSSL_EXPORT UniquePtr<SSL_SESSION> SSL_SESSION_dup(SSL_SESSION *session,
2835
+ int dup_flags);
2836
+
2837
+ // ssl_session_rebase_time updates |session|'s start time to the current time,
2838
+ // adjusting the timeout so the expiration time is unchanged.
2839
+ void ssl_session_rebase_time(SSL *ssl, SSL_SESSION *session);
2840
+
2841
+ // ssl_session_renew_timeout calls |ssl_session_rebase_time| and renews
2842
+ // |session|'s timeout to |timeout| (measured from the current time). The
2843
+ // renewal is clamped to the session's auth_timeout.
2844
+ void ssl_session_renew_timeout(SSL *ssl, SSL_SESSION *session,
2845
+ uint32_t timeout);
2846
+
2847
+ void ssl_update_cache(SSL_HANDSHAKE *hs, int mode);
2848
+
2849
+ void ssl_send_alert(SSL *ssl, int level, int desc);
2850
+ int ssl_send_alert_impl(SSL *ssl, int level, int desc);
2851
+ bool tls_get_message(const SSL *ssl, SSLMessage *out);
2852
+ ssl_open_record_t tls_open_handshake(SSL *ssl, size_t *out_consumed,
2853
+ uint8_t *out_alert, Span<uint8_t> in);
2854
+ void tls_next_message(SSL *ssl);
2855
+
2856
+ int tls_dispatch_alert(SSL *ssl);
2857
+ ssl_open_record_t tls_open_app_data(SSL *ssl, Span<uint8_t> *out,
2858
+ size_t *out_consumed, uint8_t *out_alert,
2859
+ Span<uint8_t> in);
2860
+ ssl_open_record_t tls_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2861
+ uint8_t *out_alert,
2862
+ Span<uint8_t> in);
2863
+ int tls_write_app_data(SSL *ssl, bool *out_needs_handshake, const uint8_t *buf,
2864
+ int len);
2865
+
2866
+ bool tls_new(SSL *ssl);
2867
+ void tls_free(SSL *ssl);
2868
+
2869
+ bool tls_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2870
+ bool tls_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2871
+ bool tls_add_message(SSL *ssl, Array<uint8_t> msg);
2872
+ bool tls_add_change_cipher_spec(SSL *ssl);
2873
+ int tls_flush_flight(SSL *ssl);
2874
+
2875
+ bool dtls1_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2876
+ bool dtls1_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2877
+ bool dtls1_add_message(SSL *ssl, Array<uint8_t> msg);
2878
+ bool dtls1_add_change_cipher_spec(SSL *ssl);
2879
+ int dtls1_flush_flight(SSL *ssl);
2880
+
2881
+ // ssl_add_message_cbb finishes the handshake message in |cbb| and adds it to
2882
+ // the pending flight. It returns true on success and false on error.
2883
+ bool ssl_add_message_cbb(SSL *ssl, CBB *cbb);
2884
+
2885
+ // ssl_hash_message incorporates |msg| into the handshake hash. It returns true
2886
+ // on success and false on allocation failure.
2887
+ bool ssl_hash_message(SSL_HANDSHAKE *hs, const SSLMessage &msg);
2888
+
2889
+ ssl_open_record_t dtls1_open_app_data(SSL *ssl, Span<uint8_t> *out,
2890
+ size_t *out_consumed, uint8_t *out_alert,
2891
+ Span<uint8_t> in);
2892
+ ssl_open_record_t dtls1_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2893
+ uint8_t *out_alert,
2894
+ Span<uint8_t> in);
2895
+
2896
+ int dtls1_write_app_data(SSL *ssl, bool *out_needs_handshake,
2897
+ const uint8_t *buf, int len);
2898
+
2899
+ // dtls1_write_record sends a record. It returns one on success and <= 0 on
2900
+ // error.
2901
+ int dtls1_write_record(SSL *ssl, int type, const uint8_t *buf, size_t len,
2902
+ enum dtls1_use_epoch_t use_epoch);
2903
+
2904
+ int dtls1_retransmit_outgoing_messages(SSL *ssl);
2905
+ bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
2906
+ CBS *out_body);
2907
+ bool dtls1_check_timeout_num(SSL *ssl);
2908
+
2909
+ void dtls1_start_timer(SSL *ssl);
2910
+ void dtls1_stop_timer(SSL *ssl);
2911
+ bool dtls1_is_timer_expired(SSL *ssl);
2912
+ unsigned int dtls1_min_mtu(void);
2913
+
2914
+ bool dtls1_new(SSL *ssl);
2915
+ void dtls1_free(SSL *ssl);
2916
+
2917
+ bool dtls1_get_message(const SSL *ssl, SSLMessage *out);
2918
+ ssl_open_record_t dtls1_open_handshake(SSL *ssl, size_t *out_consumed,
2919
+ uint8_t *out_alert, Span<uint8_t> in);
2920
+ void dtls1_next_message(SSL *ssl);
2921
+ int dtls1_dispatch_alert(SSL *ssl);
2922
+
2923
+ // tls1_configure_aead configures either the read or write direction AEAD (as
2924
+ // determined by |direction|) using the keys generated by the TLS KDF. The
2925
+ // |key_block_cache| argument is used to store the generated key block, if
2926
+ // empty. Otherwise it's assumed that the key block is already contained within
2927
+ // it. Returns one on success or zero on error.
2928
+ int tls1_configure_aead(SSL *ssl, evp_aead_direction_t direction,
2929
+ Array<uint8_t> *key_block_cache,
2930
+ const SSL_CIPHER *cipher,
2931
+ Span<const uint8_t> iv_override);
2932
+
2933
+ int tls1_change_cipher_state(SSL_HANDSHAKE *hs, evp_aead_direction_t direction);
2934
+ int tls1_generate_master_secret(SSL_HANDSHAKE *hs, uint8_t *out,
2935
+ Span<const uint8_t> premaster);
2936
+
2937
+ // tls1_get_grouplist returns the locally-configured group preference list.
2938
+ Span<const uint16_t> tls1_get_grouplist(const SSL_HANDSHAKE *ssl);
2939
+
2940
+ // tls1_check_group_id returns whether |group_id| is consistent with locally-
2941
+ // configured group preferences.
2942
+ bool tls1_check_group_id(const SSL_HANDSHAKE *ssl, uint16_t group_id);
2943
+
2944
+ // tls1_get_shared_group sets |*out_group_id| to the first preferred shared
2945
+ // group between client and server preferences and returns true. If none may be
2946
+ // found, it returns false.
2947
+ bool tls1_get_shared_group(SSL_HANDSHAKE *hs, uint16_t *out_group_id);
2948
+
2949
+ // tls1_set_curves converts the array of NIDs in |curves| into a newly allocated
2950
+ // array of TLS group IDs. On success, the function returns true and writes the
2951
+ // array to |*out_group_ids|. Otherwise, it returns false.
2952
+ bool tls1_set_curves(Array<uint16_t> *out_group_ids, Span<const int> curves);
2953
+
2954
+ // tls1_set_curves_list converts the string of curves pointed to by |curves|
2955
+ // into a newly allocated array of TLS group IDs. On success, the function
2956
+ // returns true and writes the array to |*out_group_ids|. Otherwise, it returns
2957
+ // false.
2958
+ bool tls1_set_curves_list(Array<uint16_t> *out_group_ids, const char *curves);
2959
+
2960
+ // ssl_add_clienthello_tlsext writes ClientHello extensions to |out|. It returns
2961
+ // true on success and false on failure. The |header_len| argument is the length
2962
+ // of the ClientHello written so far and is used to compute the padding length.
2963
+ // (It does not include the record header.)
2964
+ bool ssl_add_clienthello_tlsext(SSL_HANDSHAKE *hs, CBB *out, size_t header_len);
2965
+
2966
+ bool ssl_add_serverhello_tlsext(SSL_HANDSHAKE *hs, CBB *out);
2967
+ bool ssl_parse_clienthello_tlsext(SSL_HANDSHAKE *hs,
2968
+ const SSL_CLIENT_HELLO *client_hello);
2969
+ bool ssl_parse_serverhello_tlsext(SSL_HANDSHAKE *hs, CBS *cbs);
2970
+
2971
+ #define tlsext_tick_md EVP_sha256
2972
+
2973
+ // ssl_process_ticket processes a session ticket from the client. It returns
2974
+ // one of:
2975
+ // |ssl_ticket_aead_success|: |*out_session| is set to the parsed session and
2976
+ // |*out_renew_ticket| is set to whether the ticket should be renewed.
2977
+ // |ssl_ticket_aead_ignore_ticket|: |*out_renew_ticket| is set to whether a
2978
+ // fresh ticket should be sent, but the given ticket cannot be used.
2979
+ // |ssl_ticket_aead_retry|: the ticket could not be immediately decrypted.
2980
+ // Retry later.
2981
+ // |ssl_ticket_aead_error|: an error occured that is fatal to the connection.
2982
+ enum ssl_ticket_aead_result_t ssl_process_ticket(
2983
+ SSL_HANDSHAKE *hs, UniquePtr<SSL_SESSION> *out_session,
2984
+ bool *out_renew_ticket, Span<const uint8_t> ticket,
2985
+ Span<const uint8_t> session_id);
2986
+
2987
+ // tls1_verify_channel_id processes |msg| as a Channel ID message, and verifies
2988
+ // the signature. If the key is valid, it saves the Channel ID and returns true.
2989
+ // Otherwise, it returns false.
2990
+ bool tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg);
2991
+
2992
+ // tls1_write_channel_id generates a Channel ID message and puts the output in
2993
+ // |cbb|. |ssl->channel_id_private| must already be set before calling. This
2994
+ // function returns true on success and false on error.
2995
+ bool tls1_write_channel_id(SSL_HANDSHAKE *hs, CBB *cbb);
2996
+
2997
+ // tls1_channel_id_hash computes the hash to be signed by Channel ID and writes
2998
+ // it to |out|, which must contain at least |EVP_MAX_MD_SIZE| bytes. It returns
2999
+ // true on success and false on failure.
3000
+ bool tls1_channel_id_hash(SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len);
3001
+
3002
+ // tls1_record_handshake_hashes_for_channel_id records the current handshake
3003
+ // hashes in |hs->new_session| so that Channel ID resumptions can sign that
3004
+ // data.
3005
+ bool tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs);
3006
+
3007
+ // ssl_do_channel_id_callback checks runs |hs->ssl->ctx->channel_id_cb| if
3008
+ // necessary. It returns true on success and false on fatal error. Note that, on
3009
+ // success, |hs->ssl->channel_id_private| may be unset, in which case the
3010
+ // operation should be retried later.
3011
+ bool ssl_do_channel_id_callback(SSL_HANDSHAKE *hs);
3012
+
3013
+ // ssl_can_write returns whether |ssl| is allowed to write.
3014
+ bool ssl_can_write(const SSL *ssl);
3015
+
3016
+ // ssl_can_read returns wheter |ssl| is allowed to read.
3017
+ bool ssl_can_read(const SSL *ssl);
3018
+
3019
+ void ssl_get_current_time(const SSL *ssl, struct OPENSSL_timeval *out_clock);
3020
+ void ssl_ctx_get_current_time(const SSL_CTX *ctx,
3021
+ struct OPENSSL_timeval *out_clock);
3022
+
3023
+ // ssl_reset_error_state resets state for |SSL_get_error|.
3024
+ void ssl_reset_error_state(SSL *ssl);
3025
+
3026
+ // ssl_set_read_error sets |ssl|'s read half into an error state, saving the
3027
+ // current state of the error queue.
3028
+ void ssl_set_read_error(SSL *ssl);
3029
+
3030
+ BSSL_NAMESPACE_END
3031
+
3032
+
3033
+ // Opaque C types.
3034
+ //
3035
+ // The following types are exported to C code as public typedefs, so they must
3036
+ // be defined outside of the namespace.
3037
+
3038
+ // ssl_method_st backs the public |SSL_METHOD| type. It is a compatibility
3039
+ // structure to support the legacy version-locked methods.
3040
+ struct ssl_method_st {
3041
+ // version, if non-zero, is the only protocol version acceptable to an
3042
+ // SSL_CTX initialized from this method.
3043
+ uint16_t version;
3044
+ // method is the underlying SSL_PROTOCOL_METHOD that initializes the
3045
+ // SSL_CTX.
3046
+ const bssl::SSL_PROTOCOL_METHOD *method;
3047
+ // x509_method contains pointers to functions that might deal with |X509|
3048
+ // compatibility, or might be a no-op, depending on the application.
3049
+ const bssl::SSL_X509_METHOD *x509_method;
3050
+ };
3051
+
3052
+ struct ssl_ctx_st {
3053
+ explicit ssl_ctx_st(const SSL_METHOD *ssl_method);
3054
+ ssl_ctx_st(const ssl_ctx_st &) = delete;
3055
+ ssl_ctx_st &operator=(const ssl_ctx_st &) = delete;
3056
+
3057
+ const bssl::SSL_PROTOCOL_METHOD *method = nullptr;
3058
+ const bssl::SSL_X509_METHOD *x509_method = nullptr;
3059
+
3060
+ // lock is used to protect various operations on this object.
3061
+ CRYPTO_MUTEX lock;
3062
+
3063
+ // conf_max_version is the maximum acceptable protocol version configured by
3064
+ // |SSL_CTX_set_max_proto_version|. Note this version is normalized in DTLS
3065
+ // and is further constrainted by |SSL_OP_NO_*|.
3066
+ uint16_t conf_max_version = 0;
3067
+
3068
+ // conf_min_version is the minimum acceptable protocol version configured by
3069
+ // |SSL_CTX_set_min_proto_version|. Note this version is normalized in DTLS
3070
+ // and is further constrainted by |SSL_OP_NO_*|.
3071
+ uint16_t conf_min_version = 0;
3072
+
3073
+ // quic_method is the method table corresponding to the QUIC hooks.
3074
+ const SSL_QUIC_METHOD *quic_method = nullptr;
3075
+
3076
+ bssl::UniquePtr<bssl::SSLCipherPreferenceList> cipher_list;
3077
+
3078
+ X509_STORE *cert_store = nullptr;
3079
+ LHASH_OF(SSL_SESSION) *sessions = nullptr;
3080
+ // Most session-ids that will be cached, default is
3081
+ // SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.
3082
+ unsigned long session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT;
3083
+ SSL_SESSION *session_cache_head = nullptr;
3084
+ SSL_SESSION *session_cache_tail = nullptr;
3085
+
3086
+ // handshakes_since_cache_flush is the number of successful handshakes since
3087
+ // the last cache flush.
3088
+ int handshakes_since_cache_flush = 0;
3089
+
3090
+ // This can have one of 2 values, ored together,
3091
+ // SSL_SESS_CACHE_CLIENT,
3092
+ // SSL_SESS_CACHE_SERVER,
3093
+ // Default is SSL_SESSION_CACHE_SERVER, which means only
3094
+ // SSL_accept which cache SSL_SESSIONS.
3095
+ int session_cache_mode = SSL_SESS_CACHE_SERVER;
3096
+
3097
+ // session_timeout is the default lifetime for new sessions in TLS 1.2 and
3098
+ // earlier, in seconds.
3099
+ uint32_t session_timeout = SSL_DEFAULT_SESSION_TIMEOUT;
3100
+
3101
+ // session_psk_dhe_timeout is the default lifetime for new sessions in TLS
3102
+ // 1.3, in seconds.
3103
+ uint32_t session_psk_dhe_timeout = SSL_DEFAULT_SESSION_PSK_DHE_TIMEOUT;
3104
+
3105
+ // If this callback is not null, it will be called each time a session id is
3106
+ // added to the cache. If this function returns 1, it means that the
3107
+ // callback will do a SSL_SESSION_free() when it has finished using it.
3108
+ // Otherwise, on 0, it means the callback has finished with it. If
3109
+ // remove_session_cb is not null, it will be called when a session-id is
3110
+ // removed from the cache. After the call, OpenSSL will SSL_SESSION_free()
3111
+ // it.
3112
+ int (*new_session_cb)(SSL *ssl, SSL_SESSION *sess) = nullptr;
3113
+ void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *sess) = nullptr;
3114
+ SSL_SESSION *(*get_session_cb)(SSL *ssl, const uint8_t *data, int len,
3115
+ int *copy) = nullptr;
3116
+
3117
+ CRYPTO_refcount_t references = 1;
3118
+
3119
+ // if defined, these override the X509_verify_cert() calls
3120
+ int (*app_verify_callback)(X509_STORE_CTX *store_ctx, void *arg) = nullptr;
3121
+ void *app_verify_arg = nullptr;
3122
+
3123
+ ssl_verify_result_t (*custom_verify_callback)(SSL *ssl,
3124
+ uint8_t *out_alert) = nullptr;
3125
+
3126
+ // Default password callback.
3127
+ pem_password_cb *default_passwd_callback = nullptr;
3128
+
3129
+ // Default password callback user data.
3130
+ void *default_passwd_callback_userdata = nullptr;
3131
+
3132
+ // get client cert callback
3133
+ int (*client_cert_cb)(SSL *ssl, X509 **out_x509,
3134
+ EVP_PKEY **out_pkey) = nullptr;
3135
+
3136
+ // get channel id callback
3137
+ void (*channel_id_cb)(SSL *ssl, EVP_PKEY **out_pkey) = nullptr;
3138
+
3139
+ CRYPTO_EX_DATA ex_data;
3140
+
3141
+ // Default values used when no per-SSL value is defined follow
3142
+
3143
+ void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
3144
+
3145
+ // what we put in client cert requests
3146
+ bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> client_CA;
3147
+
3148
+ // cached_x509_client_CA is a cache of parsed versions of the elements of
3149
+ // |client_CA|.
3150
+ STACK_OF(X509_NAME) *cached_x509_client_CA = nullptr;
3151
+
3152
+
3153
+ // Default values to use in SSL structures follow (these are copied by
3154
+ // SSL_new)
3155
+
3156
+ uint32_t options = 0;
3157
+ // Disable the auto-chaining feature by default. wpa_supplicant relies on this
3158
+ // feature, but require callers opt into it.
3159
+ uint32_t mode = SSL_MODE_NO_AUTO_CHAIN;
3160
+ uint32_t max_cert_list = SSL_MAX_CERT_LIST_DEFAULT;
3161
+
3162
+ bssl::UniquePtr<bssl::CERT> cert;
3163
+
3164
+ // callback that allows applications to peek at protocol messages
3165
+ void (*msg_callback)(int write_p, int version, int content_type,
3166
+ const void *buf, size_t len, SSL *ssl,
3167
+ void *arg) = nullptr;
3168
+ void *msg_callback_arg = nullptr;
3169
+
3170
+ int verify_mode = SSL_VERIFY_NONE;
3171
+ int (*default_verify_callback)(int ok, X509_STORE_CTX *ctx) =
3172
+ nullptr; // called 'verify_callback' in the SSL
3173
+
3174
+ X509_VERIFY_PARAM *param = nullptr;
3175
+
3176
+ // select_certificate_cb is called before most ClientHello processing and
3177
+ // before the decision whether to resume a session is made. See
3178
+ // |ssl_select_cert_result_t| for details of the return values.
3179
+ ssl_select_cert_result_t (*select_certificate_cb)(const SSL_CLIENT_HELLO *) =
3180
+ nullptr;
3181
+
3182
+ // dos_protection_cb is called once the resumption decision for a ClientHello
3183
+ // has been made. It returns one to continue the handshake or zero to
3184
+ // abort.
3185
+ int (*dos_protection_cb)(const SSL_CLIENT_HELLO *) = nullptr;
3186
+
3187
+ // Controls whether to verify certificates when resuming connections. They
3188
+ // were already verified when the connection was first made, so the default is
3189
+ // false. For now, this is only respected on clients, not servers.
3190
+ bool reverify_on_resume = false;
3191
+
3192
+ // Maximum amount of data to send in one fragment. actual record size can be
3193
+ // more than this due to padding and MAC overheads.
3194
+ uint16_t max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;
3195
+
3196
+ // TLS extensions servername callback
3197
+ int (*servername_callback)(SSL *, int *, void *) = nullptr;
3198
+ void *servername_arg = nullptr;
3199
+
3200
+ // RFC 4507 session ticket keys. |ticket_key_current| may be NULL before the
3201
+ // first handshake and |ticket_key_prev| may be NULL at any time.
3202
+ // Automatically generated ticket keys are rotated as needed at handshake
3203
+ // time. Hence, all access must be synchronized through |lock|.
3204
+ bssl::UniquePtr<bssl::TicketKey> ticket_key_current;
3205
+ bssl::UniquePtr<bssl::TicketKey> ticket_key_prev;
3206
+
3207
+ // Callback to support customisation of ticket key setting
3208
+ int (*ticket_key_cb)(SSL *ssl, uint8_t *name, uint8_t *iv,
3209
+ EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc) = nullptr;
3210
+
3211
+ // Server-only: psk_identity_hint is the default identity hint to send in
3212
+ // PSK-based key exchanges.
3213
+ bssl::UniquePtr<char> psk_identity_hint;
3214
+
3215
+ unsigned (*psk_client_callback)(SSL *ssl, const char *hint, char *identity,
3216
+ unsigned max_identity_len, uint8_t *psk,
3217
+ unsigned max_psk_len) = nullptr;
3218
+ unsigned (*psk_server_callback)(SSL *ssl, const char *identity, uint8_t *psk,
3219
+ unsigned max_psk_len) = nullptr;
3220
+
3221
+
3222
+ // Next protocol negotiation information
3223
+ // (for experimental NPN extension).
3224
+
3225
+ // For a server, this contains a callback function by which the set of
3226
+ // advertised protocols can be provided.
3227
+ int (*next_protos_advertised_cb)(SSL *ssl, const uint8_t **out,
3228
+ unsigned *out_len, void *arg) = nullptr;
3229
+ void *next_protos_advertised_cb_arg = nullptr;
3230
+ // For a client, this contains a callback function that selects the
3231
+ // next protocol from the list provided by the server.
3232
+ int (*next_proto_select_cb)(SSL *ssl, uint8_t **out, uint8_t *out_len,
3233
+ const uint8_t *in, unsigned in_len,
3234
+ void *arg) = nullptr;
3235
+ void *next_proto_select_cb_arg = nullptr;
3236
+
3237
+ // ALPN information
3238
+ // (we are in the process of transitioning from NPN to ALPN.)
3239
+
3240
+ // For a server, this contains a callback function that allows the
3241
+ // server to select the protocol for the connection.
3242
+ // out: on successful return, this must point to the raw protocol
3243
+ // name (without the length prefix).
3244
+ // outlen: on successful return, this contains the length of |*out|.
3245
+ // in: points to the client's list of supported protocols in
3246
+ // wire-format.
3247
+ // inlen: the length of |in|.
3248
+ int (*alpn_select_cb)(SSL *ssl, const uint8_t **out, uint8_t *out_len,
3249
+ const uint8_t *in, unsigned in_len,
3250
+ void *arg) = nullptr;
3251
+ void *alpn_select_cb_arg = nullptr;
3252
+
3253
+ // For a client, this contains the list of supported protocols in wire
3254
+ // format.
3255
+ bssl::Array<uint8_t> alpn_client_proto_list;
3256
+
3257
+ // SRTP profiles we are willing to do from RFC 5764
3258
+ bssl::UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> srtp_profiles;
3259
+
3260
+ // Defined compression algorithms for certificates.
3261
+ bssl::GrowableArray<bssl::CertCompressionAlg> cert_compression_algs;
3262
+
3263
+ // Supported group values inherited by SSL structure
3264
+ bssl::Array<uint16_t> supported_group_list;
3265
+
3266
+ // The client's Channel ID private key.
3267
+ bssl::UniquePtr<EVP_PKEY> channel_id_private;
3268
+
3269
+ // keylog_callback, if not NULL, is the key logging callback. See
3270
+ // |SSL_CTX_set_keylog_callback|.
3271
+ void (*keylog_callback)(const SSL *ssl, const char *line) = nullptr;
3272
+
3273
+ // current_time_cb, if not NULL, is the function to use to get the current
3274
+ // time. It sets |*out_clock| to the current time. The |ssl| argument is
3275
+ // always NULL. See |SSL_CTX_set_current_time_cb|.
3276
+ void (*current_time_cb)(const SSL *ssl, struct timeval *out_clock) = nullptr;
3277
+
3278
+ // pool is used for all |CRYPTO_BUFFER|s in case we wish to share certificate
3279
+ // memory.
3280
+ CRYPTO_BUFFER_POOL *pool = nullptr;
3281
+
3282
+ // ticket_aead_method contains function pointers for opening and sealing
3283
+ // session tickets.
3284
+ const SSL_TICKET_AEAD_METHOD *ticket_aead_method = nullptr;
3285
+
3286
+ // legacy_ocsp_callback implements an OCSP-related callback for OpenSSL
3287
+ // compatibility.
3288
+ int (*legacy_ocsp_callback)(SSL *ssl, void *arg) = nullptr;
3289
+ void *legacy_ocsp_callback_arg = nullptr;
3290
+
3291
+ // verify_sigalgs, if not empty, is the set of signature algorithms
3292
+ // accepted from the peer in decreasing order of preference.
3293
+ bssl::Array<uint16_t> verify_sigalgs;
3294
+
3295
+ // retain_only_sha256_of_client_certs is true if we should compute the SHA256
3296
+ // hash of the peer's certificate and then discard it to save memory and
3297
+ // session space. Only effective on the server side.
3298
+ bool retain_only_sha256_of_client_certs : 1;
3299
+
3300
+ // quiet_shutdown is true if the connection should not send a close_notify on
3301
+ // shutdown.
3302
+ bool quiet_shutdown : 1;
3303
+
3304
+ // ocsp_stapling_enabled is only used by client connections and indicates
3305
+ // whether OCSP stapling will be requested.
3306
+ bool ocsp_stapling_enabled : 1;
3307
+
3308
+ // If true, a client will request certificate timestamps.
3309
+ bool signed_cert_timestamps_enabled : 1;
3310
+
3311
+ // channel_id_enabled is whether Channel ID is enabled. For a server, means
3312
+ // that we'll accept Channel IDs from clients. For a client, means that we'll
3313
+ // advertise support.
3314
+ bool channel_id_enabled : 1;
3315
+
3316
+ // grease_enabled is whether draft-davidben-tls-grease-01 is enabled.
3317
+ bool grease_enabled : 1;
3318
+
3319
+ // allow_unknown_alpn_protos is whether the client allows unsolicited ALPN
3320
+ // protocols from the peer.
3321
+ bool allow_unknown_alpn_protos : 1;
3322
+
3323
+ // false_start_allowed_without_alpn is whether False Start (if
3324
+ // |SSL_MODE_ENABLE_FALSE_START| is enabled) is allowed without ALPN.
3325
+ bool false_start_allowed_without_alpn : 1;
3326
+
3327
+ // ignore_tls13_downgrade is whether a connection should continue when the
3328
+ // server random signals a downgrade.
3329
+ bool ignore_tls13_downgrade:1;
3330
+
3331
+ // handoff indicates that a server should stop after receiving the
3332
+ // ClientHello and pause the handshake in such a way that |SSL_get_error|
3333
+ // returns |SSL_ERROR_HANDOFF|.
3334
+ bool handoff : 1;
3335
+
3336
+ // If enable_early_data is true, early data can be sent and accepted.
3337
+ bool enable_early_data : 1;
3338
+
3339
+ private:
3340
+ ~ssl_ctx_st();
3341
+ friend void SSL_CTX_free(SSL_CTX *);
3342
+ };
3343
+
3344
+ struct ssl_st {
3345
+ explicit ssl_st(SSL_CTX *ctx_arg);
3346
+ ssl_st(const ssl_st &) = delete;
3347
+ ssl_st &operator=(const ssl_st &) = delete;
3348
+ ~ssl_st();
3349
+
3350
+ // method is the method table corresponding to the current protocol (DTLS or
3351
+ // TLS).
3352
+ const bssl::SSL_PROTOCOL_METHOD *method = nullptr;
3353
+
3354
+ // config is a container for handshake configuration. Accesses to this field
3355
+ // should check for nullptr, since configuration may be shed after the
3356
+ // handshake completes. (If you have the |SSL_HANDSHAKE| object at hand, use
3357
+ // that instead, and skip the null check.)
3358
+ bssl::UniquePtr<bssl::SSL_CONFIG> config;
3359
+
3360
+ // version is the protocol version.
3361
+ uint16_t version = 0;
3362
+
3363
+ uint16_t max_send_fragment = 0;
3364
+
3365
+ // There are 2 BIO's even though they are normally both the same. This is so
3366
+ // data can be read and written to different handlers
3367
+
3368
+ bssl::UniquePtr<BIO> rbio; // used by SSL_read
3369
+ bssl::UniquePtr<BIO> wbio; // used by SSL_write
3370
+
3371
+ // do_handshake runs the handshake. On completion, it returns |ssl_hs_ok|.
3372
+ // Otherwise, it returns a value corresponding to what operation is needed to
3373
+ // progress.
3374
+ bssl::ssl_hs_wait_t (*do_handshake)(bssl::SSL_HANDSHAKE *hs) = nullptr;
3375
+
3376
+ bssl::SSL3_STATE *s3 = nullptr; // TLS variables
3377
+ bssl::DTLS1_STATE *d1 = nullptr; // DTLS variables
3378
+
3379
+ // callback that allows applications to peek at protocol messages
3380
+ void (*msg_callback)(int write_p, int version, int content_type,
3381
+ const void *buf, size_t len, SSL *ssl,
3382
+ void *arg) = nullptr;
3383
+ void *msg_callback_arg = nullptr;
3384
+
3385
+ // session info
3386
+
3387
+ // initial_timeout_duration_ms is the default DTLS timeout duration in
3388
+ // milliseconds. It's used to initialize the timer any time it's restarted.
3389
+ //
3390
+ // RFC 6347 states that implementations SHOULD use an initial timer value of 1
3391
+ // second.
3392
+ unsigned initial_timeout_duration_ms = 1000;
3393
+
3394
+ // session is the configured session to be offered by the client. This session
3395
+ // is immutable.
3396
+ bssl::UniquePtr<SSL_SESSION> session;
3397
+
3398
+ void (*info_callback)(const SSL *ssl, int type, int value) = nullptr;
3399
+
3400
+ bssl::UniquePtr<SSL_CTX> ctx;
3401
+
3402
+ // session_ctx is the |SSL_CTX| used for the session cache and related
3403
+ // settings.
3404
+ bssl::UniquePtr<SSL_CTX> session_ctx;
3405
+
3406
+ // extra application data
3407
+ CRYPTO_EX_DATA ex_data;
3408
+
3409
+ uint32_t options = 0; // protocol behaviour
3410
+ uint32_t mode = 0; // API behaviour
3411
+ uint32_t max_cert_list = 0;
3412
+ bssl::UniquePtr<char> hostname;
3413
+
3414
+ // quic_method is the method table corresponding to the QUIC hooks.
3415
+ const SSL_QUIC_METHOD *quic_method = nullptr;
3416
+
3417
+ // renegotiate_mode controls how peer renegotiation attempts are handled.
3418
+ ssl_renegotiate_mode_t renegotiate_mode = ssl_renegotiate_never;
3419
+
3420
+ // server is true iff the this SSL* is the server half. Note: before the SSL*
3421
+ // is initialized by either SSL_set_accept_state or SSL_set_connect_state,
3422
+ // the side is not determined. In this state, server is always false.
3423
+ bool server : 1;
3424
+
3425
+ // quiet_shutdown is true if the connection should not send a close_notify on
3426
+ // shutdown.
3427
+ bool quiet_shutdown : 1;
3428
+
3429
+ // If enable_early_data is true, early data can be sent and accepted.
3430
+ bool enable_early_data : 1;
3431
+ };
3432
+
3433
+ struct ssl_session_st {
3434
+ explicit ssl_session_st(const bssl::SSL_X509_METHOD *method);
3435
+ ssl_session_st(const ssl_session_st &) = delete;
3436
+ ssl_session_st &operator=(const ssl_session_st &) = delete;
3437
+
3438
+ CRYPTO_refcount_t references = 1;
3439
+
3440
+ // ssl_version is the (D)TLS version that established the session.
3441
+ uint16_t ssl_version = 0;
3442
+
3443
+ // group_id is the ID of the ECDH group used to establish this session or zero
3444
+ // if not applicable or unknown.
3445
+ uint16_t group_id = 0;
3446
+
3447
+ // peer_signature_algorithm is the signature algorithm used to authenticate
3448
+ // the peer, or zero if not applicable or unknown.
3449
+ uint16_t peer_signature_algorithm = 0;
3450
+
3451
+ // master_key, in TLS 1.2 and below, is the master secret associated with the
3452
+ // session. In TLS 1.3 and up, it is the resumption secret.
3453
+ int master_key_length = 0;
3454
+ uint8_t master_key[SSL_MAX_MASTER_KEY_LENGTH] = {0};
3455
+
3456
+ // session_id - valid?
3457
+ unsigned session_id_length = 0;
3458
+ uint8_t session_id[SSL_MAX_SSL_SESSION_ID_LENGTH] = {0};
3459
+ // this is used to determine whether the session is being reused in
3460
+ // the appropriate context. It is up to the application to set this,
3461
+ // via SSL_new
3462
+ uint8_t sid_ctx_length = 0;
3463
+ uint8_t sid_ctx[SSL_MAX_SID_CTX_LENGTH] = {0};
3464
+
3465
+ bssl::UniquePtr<char> psk_identity;
3466
+
3467
+ // certs contains the certificate chain from the peer, starting with the leaf
3468
+ // certificate.
3469
+ bssl::UniquePtr<STACK_OF(CRYPTO_BUFFER)> certs;
3470
+
3471
+ const bssl::SSL_X509_METHOD *x509_method = nullptr;
3472
+
3473
+ // x509_peer is the peer's certificate.
3474
+ X509 *x509_peer = nullptr;
3475
+
3476
+ // x509_chain is the certificate chain sent by the peer. NOTE: for historical
3477
+ // reasons, when a client (so the peer is a server), the chain includes
3478
+ // |peer|, but when a server it does not.
3479
+ STACK_OF(X509) *x509_chain = nullptr;
3480
+
3481
+ // x509_chain_without_leaf is a lazily constructed copy of |x509_chain| that
3482
+ // omits the leaf certificate. This exists because OpenSSL, historically,
3483
+ // didn't include the leaf certificate in the chain for a server, but did for
3484
+ // a client. The |x509_chain| always includes it and, if an API call requires
3485
+ // a chain without, it is stored here.
3486
+ STACK_OF(X509) *x509_chain_without_leaf = nullptr;
3487
+
3488
+ // verify_result is the result of certificate verification in the case of
3489
+ // non-fatal certificate errors.
3490
+ long verify_result = X509_V_ERR_INVALID_CALL;
3491
+
3492
+ // timeout is the lifetime of the session in seconds, measured from |time|.
3493
+ // This is renewable up to |auth_timeout|.
3494
+ uint32_t timeout = SSL_DEFAULT_SESSION_TIMEOUT;
3495
+
3496
+ // auth_timeout is the non-renewable lifetime of the session in seconds,
3497
+ // measured from |time|.
3498
+ uint32_t auth_timeout = SSL_DEFAULT_SESSION_TIMEOUT;
3499
+
3500
+ // time is the time the session was issued, measured in seconds from the UNIX
3501
+ // epoch.
3502
+ uint64_t time = 0;
3503
+
3504
+ const SSL_CIPHER *cipher = nullptr;
3505
+
3506
+ CRYPTO_EX_DATA ex_data; // application specific data
3507
+
3508
+ // These are used to make removal of session-ids more efficient and to
3509
+ // implement a maximum cache size.
3510
+ SSL_SESSION *prev = nullptr, *next = nullptr;
3511
+
3512
+ bssl::Array<uint8_t> ticket;
3513
+
3514
+ bssl::UniquePtr<CRYPTO_BUFFER> signed_cert_timestamp_list;
3515
+
3516
+ // The OCSP response that came with the session.
3517
+ bssl::UniquePtr<CRYPTO_BUFFER> ocsp_response;
3518
+
3519
+ // peer_sha256 contains the SHA-256 hash of the peer's certificate if
3520
+ // |peer_sha256_valid| is true.
3521
+ uint8_t peer_sha256[SHA256_DIGEST_LENGTH] = {0};
3522
+
3523
+ // original_handshake_hash contains the handshake hash (either SHA-1+MD5 or
3524
+ // SHA-2, depending on TLS version) for the original, full handshake that
3525
+ // created a session. This is used by Channel IDs during resumption.
3526
+ uint8_t original_handshake_hash[EVP_MAX_MD_SIZE] = {0};
3527
+ uint8_t original_handshake_hash_len = 0;
3528
+
3529
+ uint32_t ticket_lifetime_hint = 0; // Session lifetime hint in seconds
3530
+
3531
+ uint32_t ticket_age_add = 0;
3532
+
3533
+ // ticket_max_early_data is the maximum amount of data allowed to be sent as
3534
+ // early data. If zero, 0-RTT is disallowed.
3535
+ uint32_t ticket_max_early_data = 0;
3536
+
3537
+ // early_alpn is the ALPN protocol from the initial handshake. This is only
3538
+ // stored for TLS 1.3 and above in order to enforce ALPN matching for 0-RTT
3539
+ // resumptions.
3540
+ bssl::Array<uint8_t> early_alpn;
3541
+
3542
+ // extended_master_secret is whether the master secret in this session was
3543
+ // generated using EMS and thus isn't vulnerable to the Triple Handshake
3544
+ // attack.
3545
+ bool extended_master_secret : 1;
3546
+
3547
+ // peer_sha256_valid is whether |peer_sha256| is valid.
3548
+ bool peer_sha256_valid : 1; // Non-zero if peer_sha256 is valid
3549
+
3550
+ // not_resumable is used to indicate that session resumption is disallowed.
3551
+ bool not_resumable : 1;
3552
+
3553
+ // ticket_age_add_valid is whether |ticket_age_add| is valid.
3554
+ bool ticket_age_add_valid : 1;
3555
+
3556
+ // is_server is whether this session was created by a server.
3557
+ bool is_server : 1;
3558
+
3559
+ // is_quic indicates whether this session was created using QUIC.
3560
+ bool is_quic : 1;
3561
+
3562
+ // quic_early_data_hash is used to determine whether early data must be
3563
+ // rejected when performing a QUIC handshake.
3564
+ bssl::Array<uint8_t> quic_early_data_hash;
3565
+
3566
+ private:
3567
+ ~ssl_session_st();
3568
+ friend void SSL_SESSION_free(SSL_SESSION *);
3569
+ };
3570
+
3571
+
3572
+ #endif // OPENSSL_HEADER_SSL_INTERNAL_H