grpc 1.10.0 → 1.11.0.pre2

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 (762) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +2098 -501
  3. data/include/grpc/byte_buffer.h +2 -0
  4. data/include/grpc/byte_buffer_reader.h +2 -0
  5. data/include/grpc/census.h +2 -0
  6. data/include/grpc/fork.h +2 -0
  7. data/include/grpc/grpc.h +10 -0
  8. data/include/grpc/grpc_cronet.h +2 -0
  9. data/include/grpc/grpc_posix.h +2 -1
  10. data/include/grpc/grpc_security.h +21 -0
  11. data/include/grpc/grpc_security_constants.h +1 -0
  12. data/include/grpc/impl/codegen/byte_buffer.h +2 -0
  13. data/include/grpc/impl/codegen/grpc_types.h +24 -0
  14. data/include/grpc/impl/codegen/slice.h +1 -1
  15. data/include/grpc/impl/codegen/sync.h +1 -0
  16. data/include/grpc/impl/codegen/sync_custom.h +2 -0
  17. data/include/grpc/impl/codegen/sync_generic.h +2 -0
  18. data/include/grpc/impl/codegen/sync_posix.h +2 -0
  19. data/include/grpc/impl/codegen/sync_windows.h +2 -0
  20. data/include/grpc/slice.h +2 -0
  21. data/include/grpc/slice_buffer.h +2 -0
  22. data/include/grpc/status.h +2 -0
  23. data/include/grpc/support/alloc.h +2 -2
  24. data/include/grpc/support/atm.h +2 -0
  25. data/include/grpc/support/atm_gcc_atomic.h +2 -0
  26. data/include/grpc/support/atm_gcc_sync.h +2 -0
  27. data/include/grpc/support/atm_windows.h +2 -0
  28. data/include/grpc/support/log.h +1 -1
  29. data/include/grpc/support/sync.h +2 -0
  30. data/include/grpc/support/sync_custom.h +2 -0
  31. data/include/grpc/support/sync_generic.h +2 -0
  32. data/include/grpc/support/sync_posix.h +2 -0
  33. data/include/grpc/support/sync_windows.h +2 -0
  34. data/include/grpc/support/time.h +2 -0
  35. data/src/boringssl/err_data.c +444 -438
  36. data/src/core/ext/census/grpc_context.cc +2 -0
  37. data/src/core/ext/filters/client_channel/backup_poller.cc +13 -8
  38. data/src/core/ext/filters/client_channel/backup_poller.h +3 -2
  39. data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -0
  40. data/src/core/ext/filters/client_channel/client_channel.cc +1988 -433
  41. data/src/core/ext/filters/client_channel/client_channel.h +2 -0
  42. data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -0
  43. data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -0
  44. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +2 -27
  45. data/src/core/ext/filters/client_channel/connector.cc +2 -0
  46. data/src/core/ext/filters/client_channel/connector.h +2 -0
  47. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -0
  48. data/src/core/ext/filters/client_channel/http_proxy.cc +2 -0
  49. data/src/core/ext/filters/client_channel/lb_policy.cc +2 -0
  50. data/src/core/ext/filters/client_channel/lb_policy.h +2 -0
  51. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +2 -0
  52. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +2 -0
  53. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +96 -78
  54. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +9 -17
  55. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +70 -62
  56. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +2 -0
  57. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -0
  58. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -0
  59. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +2 -0
  60. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +4 -2
  61. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -2
  62. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +2 -0
  63. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +2 -0
  64. data/src/core/ext/filters/client_channel/lb_policy_factory.cc +3 -1
  65. data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -1
  66. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +2 -0
  67. data/src/core/ext/filters/client_channel/lb_policy_registry.h +2 -1
  68. data/src/core/ext/filters/client_channel/method_params.cc +178 -0
  69. data/src/core/ext/filters/client_channel/method_params.h +74 -0
  70. data/src/core/ext/filters/client_channel/parse_address.cc +17 -13
  71. data/src/core/ext/filters/client_channel/parse_address.h +2 -0
  72. data/src/core/ext/filters/client_channel/proxy_mapper.cc +2 -0
  73. data/src/core/ext/filters/client_channel/proxy_mapper.h +2 -0
  74. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +2 -0
  75. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -0
  76. data/src/core/ext/filters/client_channel/resolver.cc +2 -0
  77. data/src/core/ext/filters/client_channel/resolver.h +6 -0
  78. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +24 -5
  79. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -1
  80. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +1 -0
  81. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +55 -1
  82. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +8 -1
  83. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +1 -0
  84. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +30 -3
  85. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -0
  86. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +2 -1
  87. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -0
  88. data/src/core/ext/filters/client_channel/resolver_registry.cc +2 -0
  89. data/src/core/ext/filters/client_channel/resolver_registry.h +2 -0
  90. data/src/core/ext/filters/client_channel/retry_throttle.cc +102 -120
  91. data/src/core/ext/filters/client_channel/retry_throttle.h +52 -25
  92. data/src/core/ext/filters/client_channel/subchannel.cc +14 -4
  93. data/src/core/ext/filters/client_channel/subchannel.h +10 -1
  94. data/src/core/ext/filters/client_channel/subchannel_index.cc +2 -0
  95. data/src/core/ext/filters/client_channel/subchannel_index.h +2 -0
  96. data/src/core/ext/filters/client_channel/uri_parser.cc +2 -1
  97. data/src/core/ext/filters/client_channel/uri_parser.h +2 -1
  98. data/src/core/ext/filters/deadline/deadline_filter.cc +2 -1
  99. data/src/core/ext/filters/deadline/deadline_filter.h +2 -0
  100. data/src/core/ext/filters/http/client/http_client_filter.cc +27 -25
  101. data/src/core/ext/filters/http/client/http_client_filter.h +2 -0
  102. data/src/core/ext/filters/http/client_authority_filter.cc +156 -0
  103. data/src/core/ext/filters/http/client_authority_filter.h +34 -0
  104. data/src/core/ext/filters/http/http_filters_plugin.cc +2 -0
  105. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +21 -22
  106. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +2 -0
  107. data/src/core/ext/filters/http/server/http_server_filter.cc +11 -8
  108. data/src/core/ext/filters/http/server/http_server_filter.h +2 -0
  109. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +2 -0
  110. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +2 -0
  111. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +2 -0
  112. data/src/core/ext/filters/max_age/max_age_filter.cc +2 -0
  113. data/src/core/ext/filters/max_age/max_age_filter.h +2 -0
  114. data/src/core/ext/filters/message_size/message_size_filter.cc +52 -49
  115. data/src/core/ext/filters/message_size/message_size_filter.h +2 -0
  116. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +5 -1
  117. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +2 -0
  118. data/src/core/ext/filters/workarounds/workaround_utils.cc +2 -0
  119. data/src/core/ext/filters/workarounds/workaround_utils.h +2 -0
  120. data/src/core/ext/transport/chttp2/alpn/alpn.cc +3 -1
  121. data/src/core/ext/transport/chttp2/alpn/alpn.h +2 -0
  122. data/src/core/ext/transport/chttp2/client/authority.cc +42 -0
  123. data/src/core/ext/transport/chttp2/client/authority.h +36 -0
  124. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -0
  125. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +2 -0
  126. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +10 -3
  127. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -2
  128. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +37 -25
  129. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +2 -0
  130. data/src/core/ext/transport/chttp2/server/chttp2_server.h +3 -1
  131. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -1
  132. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +2 -1
  133. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +2 -0
  134. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +3 -1
  135. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -0
  136. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +2 -0
  137. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +2 -0
  138. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +2 -0
  139. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +152 -182
  140. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +2 -0
  141. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
  142. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
  143. data/src/core/ext/transport/chttp2/transport/frame.h +2 -1
  144. data/src/core/ext/transport/chttp2/transport/frame_data.cc +15 -19
  145. data/src/core/ext/transport/chttp2/transport/frame_data.h +7 -5
  146. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -0
  147. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
  148. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -0
  149. data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -1
  150. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -0
  151. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
  152. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -0
  153. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
  154. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +2 -0
  155. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -1
  156. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -0
  157. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -1
  158. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -1
  159. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -2
  160. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -0
  161. data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -1
  162. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +2 -0
  163. data/src/core/ext/transport/chttp2/transport/http2_settings.h +2 -0
  164. data/src/core/ext/transport/chttp2/transport/huffsyms.cc +2 -0
  165. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +3 -2
  166. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -0
  167. data/src/core/ext/transport/chttp2/transport/internal.h +60 -24
  168. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -4
  169. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
  170. data/src/core/ext/transport/chttp2/transport/stream_map.cc +2 -0
  171. data/src/core/ext/transport/chttp2/transport/varint.cc +2 -0
  172. data/src/core/ext/transport/chttp2/transport/writing.cc +10 -6
  173. data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -0
  174. data/src/core/ext/transport/inproc/inproc_transport.cc +20 -23
  175. data/src/core/ext/transport/inproc/inproc_transport.h +2 -0
  176. data/src/core/lib/avl/avl.cc +2 -0
  177. data/src/core/lib/avl/avl.h +2 -0
  178. data/src/core/lib/backoff/backoff.cc +2 -0
  179. data/src/core/lib/backoff/backoff.h +2 -0
  180. data/src/core/lib/channel/channel_args.h +2 -0
  181. data/src/core/lib/channel/channel_stack.cc +3 -1
  182. data/src/core/lib/channel/channel_stack.h +2 -0
  183. data/src/core/lib/channel/channel_stack_builder.cc +2 -0
  184. data/src/core/lib/channel/channel_stack_builder.h +2 -0
  185. data/src/core/lib/channel/channel_trace.cc +239 -0
  186. data/src/core/lib/channel/channel_trace.h +133 -0
  187. data/src/core/lib/channel/channel_trace_registry.cc +80 -0
  188. data/src/core/lib/channel/channel_trace_registry.h +43 -0
  189. data/src/core/lib/channel/connected_channel.cc +2 -0
  190. data/src/core/lib/channel/connected_channel.h +2 -0
  191. data/src/core/lib/channel/handshaker.cc +2 -0
  192. data/src/core/lib/channel/handshaker.h +2 -0
  193. data/src/core/lib/channel/handshaker_factory.cc +2 -0
  194. data/src/core/lib/channel/handshaker_factory.h +2 -1
  195. data/src/core/lib/channel/handshaker_registry.cc +2 -0
  196. data/src/core/lib/channel/handshaker_registry.h +2 -1
  197. data/src/core/lib/channel/status_util.cc +100 -0
  198. data/src/core/lib/channel/status_util.h +58 -0
  199. data/src/core/lib/compression/algorithm_metadata.h +2 -0
  200. data/src/core/lib/compression/compression.cc +2 -0
  201. data/src/core/lib/compression/compression_internal.cc +2 -0
  202. data/src/core/lib/compression/compression_internal.h +2 -0
  203. data/src/core/lib/compression/message_compress.cc +2 -0
  204. data/src/core/lib/compression/message_compress.h +2 -0
  205. data/src/core/lib/compression/stream_compression.cc +2 -0
  206. data/src/core/lib/compression/stream_compression.h +2 -0
  207. data/src/core/lib/compression/stream_compression_gzip.cc +2 -0
  208. data/src/core/lib/compression/stream_compression_gzip.h +2 -0
  209. data/src/core/lib/compression/stream_compression_identity.cc +2 -1
  210. data/src/core/lib/compression/stream_compression_identity.h +2 -0
  211. data/src/core/lib/debug/stats.cc +2 -0
  212. data/src/core/lib/debug/stats.h +2 -0
  213. data/src/core/lib/debug/stats_data.cc +3 -1
  214. data/src/core/lib/debug/stats_data.h +2 -0
  215. data/src/core/lib/debug/trace.cc +2 -0
  216. data/src/core/lib/debug/trace.h +2 -1
  217. data/src/core/lib/gpr/alloc.cc +2 -1
  218. data/src/core/lib/gpr/arena.cc +47 -0
  219. data/src/core/lib/gpr/arena.h +2 -0
  220. data/src/core/lib/gpr/atm.cc +2 -0
  221. data/src/core/lib/gpr/cpu_linux.cc +5 -1
  222. data/src/core/lib/gpr/cpu_posix.cc +1 -1
  223. data/src/core/lib/gpr/env.h +2 -0
  224. data/src/core/lib/gpr/fork.cc +2 -0
  225. data/src/core/lib/gpr/host_port.cc +2 -0
  226. data/src/core/lib/gpr/log.cc +2 -1
  227. data/src/core/lib/gpr/log_linux.cc +1 -0
  228. data/src/core/lib/gpr/mpscq.cc +2 -0
  229. data/src/core/lib/gpr/mpscq.h +2 -0
  230. data/src/core/lib/gpr/murmur_hash.cc +2 -0
  231. data/src/core/lib/gpr/spinlock.h +2 -0
  232. data/src/core/lib/gpr/string.cc +2 -1
  233. data/src/core/lib/gpr/string.h +2 -2
  234. data/src/core/lib/gpr/sync.cc +2 -0
  235. data/src/core/lib/gpr/time.cc +2 -0
  236. data/src/core/lib/gpr/time_posix.cc +1 -0
  237. data/src/core/lib/gpr/time_precise.cc +2 -0
  238. data/src/core/lib/gpr/time_precise.h +2 -0
  239. data/src/core/lib/gpr/tls_gcc.h +2 -0
  240. data/src/core/lib/gpr/tls_msvc.h +2 -0
  241. data/src/core/lib/gpr/tls_pthread.h +2 -0
  242. data/src/core/lib/gpr/tmpfile.h +2 -0
  243. data/src/core/lib/gprpp/atomic_with_atm.h +2 -0
  244. data/src/core/lib/gprpp/atomic_with_std.h +2 -0
  245. data/src/core/lib/gprpp/inlined_vector.h +2 -0
  246. data/src/core/lib/gprpp/manual_constructor.h +3 -1
  247. data/src/core/lib/gprpp/memory.h +5 -3
  248. data/src/core/lib/gprpp/orphanable.h +3 -0
  249. data/src/core/lib/gprpp/ref_counted.h +4 -0
  250. data/src/core/lib/gprpp/ref_counted_ptr.h +3 -0
  251. data/src/core/lib/gprpp/thd.h +135 -0
  252. data/src/core/lib/gprpp/thd_posix.cc +209 -0
  253. data/src/core/lib/gprpp/thd_windows.cc +162 -0
  254. data/src/core/lib/http/format_request.cc +2 -0
  255. data/src/core/lib/http/format_request.h +2 -0
  256. data/src/core/lib/http/httpcli.cc +2 -0
  257. data/src/core/lib/http/httpcli.h +2 -0
  258. data/src/core/lib/http/httpcli_security_connector.cc +16 -7
  259. data/src/core/lib/http/parser.cc +2 -0
  260. data/src/core/lib/http/parser.h +2 -1
  261. data/src/core/lib/iomgr/call_combiner.cc +2 -0
  262. data/src/core/lib/iomgr/call_combiner.h +2 -1
  263. data/src/core/lib/iomgr/combiner.cc +2 -0
  264. data/src/core/lib/iomgr/combiner.h +2 -0
  265. data/src/core/lib/iomgr/endpoint.cc +4 -0
  266. data/src/core/lib/iomgr/endpoint.h +2 -0
  267. data/src/core/lib/iomgr/endpoint_pair.h +2 -0
  268. data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -0
  269. data/src/core/lib/iomgr/endpoint_pair_uv.cc +2 -0
  270. data/src/core/lib/iomgr/endpoint_pair_windows.cc +7 -4
  271. data/src/core/lib/iomgr/error.h +2 -0
  272. data/src/core/lib/iomgr/error_internal.h +2 -0
  273. data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -0
  274. data/src/core/lib/iomgr/ev_epoll1_linux.h +2 -0
  275. data/src/core/lib/iomgr/ev_epollex_linux.cc +4 -18
  276. data/src/core/lib/iomgr/ev_epollex_linux.h +2 -0
  277. data/src/core/lib/iomgr/ev_epollsig_linux.cc +2 -0
  278. data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -0
  279. data/src/core/lib/iomgr/ev_poll_posix.cc +61 -31
  280. data/src/core/lib/iomgr/ev_poll_posix.h +2 -0
  281. data/src/core/lib/iomgr/ev_posix.cc +35 -19
  282. data/src/core/lib/iomgr/ev_posix.h +2 -0
  283. data/src/core/lib/iomgr/ev_windows.cc +2 -0
  284. data/src/core/lib/iomgr/exec_ctx.cc +3 -1
  285. data/src/core/lib/iomgr/exec_ctx.h +21 -9
  286. data/src/core/lib/iomgr/executor.cc +13 -11
  287. data/src/core/lib/iomgr/executor.h +2 -0
  288. data/src/core/lib/iomgr/fork_posix.cc +4 -2
  289. data/src/core/lib/iomgr/fork_windows.cc +2 -0
  290. data/src/core/lib/iomgr/gethostname_fallback.cc +2 -0
  291. data/src/core/lib/iomgr/gethostname_host_name_max.cc +2 -0
  292. data/src/core/lib/iomgr/gethostname_sysconf.cc +2 -0
  293. data/src/core/lib/iomgr/iocp_windows.cc +3 -1
  294. data/src/core/lib/iomgr/iocp_windows.h +3 -0
  295. data/src/core/lib/iomgr/iomgr.cc +2 -1
  296. data/src/core/lib/iomgr/iomgr.h +2 -0
  297. data/src/core/lib/iomgr/iomgr_custom.cc +63 -0
  298. data/src/core/lib/iomgr/iomgr_custom.h +47 -0
  299. data/src/core/lib/iomgr/iomgr_internal.cc +43 -0
  300. data/src/core/lib/iomgr/iomgr_internal.h +14 -0
  301. data/src/core/lib/iomgr/iomgr_posix.cc +30 -3
  302. data/src/core/lib/iomgr/iomgr_posix.h +2 -0
  303. data/src/core/lib/iomgr/iomgr_uv.cc +17 -20
  304. data/src/core/lib/iomgr/iomgr_windows.cc +29 -3
  305. data/src/core/lib/iomgr/is_epollexclusive_available.cc +2 -0
  306. data/src/core/lib/iomgr/is_epollexclusive_available.h +2 -0
  307. data/src/core/lib/iomgr/load_file.cc +2 -0
  308. data/src/core/lib/iomgr/load_file.h +2 -0
  309. data/src/core/lib/iomgr/lockfree_event.cc +2 -0
  310. data/src/core/lib/iomgr/lockfree_event.h +14 -1
  311. data/src/core/lib/iomgr/nameser.h +2 -0
  312. data/src/core/lib/iomgr/network_status_tracker.cc +3 -1
  313. data/src/core/lib/iomgr/network_status_tracker.h +2 -0
  314. data/src/core/lib/iomgr/polling_entity.cc +2 -0
  315. data/src/core/lib/iomgr/polling_entity.h +2 -0
  316. data/src/core/lib/iomgr/pollset.cc +56 -0
  317. data/src/core/lib/iomgr/pollset.h +19 -0
  318. data/src/core/lib/iomgr/pollset_custom.cc +106 -0
  319. data/src/core/lib/iomgr/{timer_generic.h → pollset_custom.h} +15 -17
  320. data/src/core/lib/iomgr/pollset_set.cc +55 -0
  321. data/src/core/lib/iomgr/pollset_set.h +13 -0
  322. data/src/core/lib/iomgr/pollset_set_custom.cc +48 -0
  323. data/src/core/lib/iomgr/{pollset_uv.h → pollset_set_custom.h} +6 -7
  324. data/src/core/lib/iomgr/pollset_set_windows.cc +17 -10
  325. data/src/core/lib/iomgr/pollset_set_windows.h +2 -0
  326. data/src/core/lib/iomgr/pollset_uv.cc +42 -105
  327. data/src/core/lib/iomgr/pollset_windows.cc +20 -12
  328. data/src/core/lib/iomgr/pollset_windows.h +2 -0
  329. data/src/core/lib/iomgr/port.h +10 -19
  330. data/src/core/lib/iomgr/resolve_address.cc +50 -0
  331. data/src/core/lib/iomgr/resolve_address.h +39 -10
  332. data/src/core/lib/iomgr/resolve_address_custom.cc +187 -0
  333. data/src/core/lib/iomgr/resolve_address_custom.h +43 -0
  334. data/src/core/lib/iomgr/resolve_address_posix.cc +10 -22
  335. data/src/core/lib/iomgr/resolve_address_windows.cc +10 -22
  336. data/src/core/lib/iomgr/resource_quota.cc +2 -0
  337. data/src/core/lib/iomgr/resource_quota.h +3 -5
  338. data/src/core/lib/iomgr/sockaddr.h +3 -11
  339. data/src/core/lib/iomgr/sockaddr_custom.h +54 -0
  340. data/src/core/lib/iomgr/sockaddr_posix.h +26 -0
  341. data/src/core/lib/iomgr/sockaddr_utils.cc +91 -71
  342. data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
  343. data/src/core/lib/iomgr/sockaddr_windows.h +21 -0
  344. data/src/core/lib/iomgr/socket_factory_posix.cc +2 -0
  345. data/src/core/lib/iomgr/socket_factory_posix.h +2 -0
  346. data/src/core/lib/iomgr/socket_mutator.cc +2 -0
  347. data/src/core/lib/iomgr/socket_mutator.h +2 -0
  348. data/src/core/lib/iomgr/socket_utils.h +11 -0
  349. data/src/core/lib/iomgr/socket_utils_common_posix.cc +15 -6
  350. data/src/core/lib/iomgr/socket_utils_linux.cc +4 -4
  351. data/src/core/lib/iomgr/socket_utils_posix.cc +3 -2
  352. data/src/core/lib/iomgr/socket_utils_posix.h +2 -0
  353. data/src/core/lib/iomgr/socket_utils_uv.cc +13 -2
  354. data/src/core/lib/iomgr/socket_utils_windows.cc +10 -0
  355. data/src/core/lib/iomgr/socket_windows.cc +2 -0
  356. data/src/core/lib/iomgr/socket_windows.h +2 -1
  357. data/src/core/lib/iomgr/sys_epoll_wrapper.h +2 -0
  358. data/src/core/lib/iomgr/tcp_client.cc +36 -0
  359. data/src/core/lib/iomgr/tcp_client.h +13 -0
  360. data/src/core/lib/iomgr/tcp_client_custom.cc +151 -0
  361. data/src/core/lib/iomgr/tcp_client_posix.cc +11 -24
  362. data/src/core/lib/iomgr/tcp_client_posix.h +2 -0
  363. data/src/core/lib/iomgr/tcp_client_windows.cc +10 -23
  364. data/src/core/lib/iomgr/tcp_custom.cc +365 -0
  365. data/src/core/lib/iomgr/tcp_custom.h +81 -0
  366. data/src/core/lib/iomgr/tcp_posix.cc +3 -1
  367. data/src/core/lib/iomgr/tcp_posix.h +2 -0
  368. data/src/core/lib/iomgr/tcp_server.cc +73 -0
  369. data/src/core/lib/iomgr/tcp_server.h +24 -0
  370. data/src/core/lib/iomgr/tcp_server_custom.cc +472 -0
  371. data/src/core/lib/iomgr/tcp_server_posix.cc +41 -23
  372. data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -0
  373. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -7
  374. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +8 -6
  375. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +2 -0
  376. data/src/core/lib/iomgr/tcp_server_windows.cc +43 -21
  377. data/src/core/lib/iomgr/tcp_uv.cc +308 -314
  378. data/src/core/lib/iomgr/tcp_windows.cc +3 -1
  379. data/src/core/lib/iomgr/tcp_windows.h +2 -0
  380. data/src/core/lib/iomgr/time_averaged_stats.cc +2 -0
  381. data/src/core/lib/iomgr/timer.cc +45 -0
  382. data/src/core/lib/iomgr/timer.h +36 -15
  383. data/src/core/lib/iomgr/timer_custom.cc +93 -0
  384. data/src/core/lib/iomgr/timer_custom.h +43 -0
  385. data/src/core/lib/iomgr/timer_generic.cc +12 -10
  386. data/src/core/lib/iomgr/timer_heap.cc +2 -4
  387. data/src/core/lib/iomgr/timer_heap.h +2 -0
  388. data/src/core/lib/iomgr/timer_manager.cc +12 -20
  389. data/src/core/lib/iomgr/timer_manager.h +2 -0
  390. data/src/core/lib/iomgr/timer_uv.cc +15 -49
  391. data/src/core/lib/iomgr/udp_server.cc +271 -230
  392. data/src/core/lib/iomgr/udp_server.h +44 -20
  393. data/src/core/lib/iomgr/unix_sockets_posix.cc +10 -7
  394. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -0
  395. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +2 -0
  396. data/src/core/lib/iomgr/wakeup_fd_cv.cc +3 -1
  397. data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -0
  398. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +2 -0
  399. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +2 -0
  400. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -0
  401. data/src/core/lib/iomgr/wakeup_fd_pipe.h +2 -0
  402. data/src/core/lib/iomgr/wakeup_fd_posix.cc +2 -0
  403. data/src/core/lib/iomgr/wakeup_fd_posix.h +2 -0
  404. data/src/core/lib/json/json.cc +38 -0
  405. data/src/core/lib/json/json.h +22 -1
  406. data/src/core/lib/json/json_reader.cc +2 -2
  407. data/src/core/lib/json/json_reader.h +1 -0
  408. data/src/core/lib/json/json_string.cc +2 -0
  409. data/src/core/lib/json/json_writer.cc +2 -2
  410. data/src/core/lib/json/json_writer.h +2 -0
  411. data/src/core/lib/profiling/basic_timers.cc +11 -9
  412. data/src/core/lib/profiling/timers.h +6 -3
  413. data/src/core/lib/security/context/security_context.cc +2 -0
  414. data/src/core/lib/security/context/security_context.h +2 -0
  415. data/src/core/lib/security/credentials/alts/alts_credentials.cc +119 -0
  416. data/src/core/lib/security/credentials/alts/alts_credentials.h +102 -0
  417. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +72 -0
  418. data/src/core/lib/security/credentials/alts/check_gcp_environment.h +57 -0
  419. data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +67 -0
  420. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +33 -0
  421. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +114 -0
  422. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +126 -0
  423. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc +46 -0
  424. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +112 -0
  425. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +58 -0
  426. data/src/core/lib/security/credentials/composite/composite_credentials.cc +2 -0
  427. data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -0
  428. data/src/core/lib/security/credentials/credentials.cc +2 -0
  429. data/src/core/lib/security/credentials/credentials.h +2 -0
  430. data/src/core/lib/security/credentials/credentials_metadata.cc +2 -0
  431. data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -3
  432. data/src/core/lib/security/credentials/fake/fake_credentials.h +5 -0
  433. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +2 -0
  434. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -0
  435. data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -0
  436. data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -0
  437. data/src/core/lib/security/credentials/jwt/json_token.cc +2 -0
  438. data/src/core/lib/security/credentials/jwt/json_token.h +2 -0
  439. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -0
  440. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
  441. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -0
  442. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -0
  443. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +2 -0
  444. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -0
  445. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  446. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +11 -2
  447. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -0
  448. data/src/core/lib/security/security_connector/alts_security_connector.cc +287 -0
  449. data/src/core/lib/security/security_connector/alts_security_connector.h +69 -0
  450. data/src/core/lib/security/security_connector/security_connector.cc +174 -74
  451. data/src/core/lib/security/security_connector/security_connector.h +41 -7
  452. data/src/core/lib/security/transport/auth_filters.h +2 -0
  453. data/src/core/lib/security/transport/client_auth_filter.cc +14 -28
  454. data/src/core/lib/security/transport/secure_endpoint.cc +2 -0
  455. data/src/core/lib/security/transport/secure_endpoint.h +2 -0
  456. data/src/core/lib/security/transport/security_handshaker.cc +2 -0
  457. data/src/core/lib/security/transport/security_handshaker.h +2 -1
  458. data/src/core/lib/security/transport/server_auth_filter.cc +2 -0
  459. data/src/core/lib/security/transport/target_authority_table.cc +75 -0
  460. data/src/core/lib/security/transport/{lb_targets_info.h → target_authority_table.h} +16 -8
  461. data/src/core/lib/security/transport/tsi_error.cc +2 -0
  462. data/src/core/lib/security/transport/tsi_error.h +2 -0
  463. data/src/core/lib/security/util/json_util.cc +2 -0
  464. data/src/core/lib/security/util/json_util.h +2 -0
  465. data/src/core/lib/slice/b64.cc +2 -0
  466. data/src/core/lib/slice/b64.h +2 -0
  467. data/src/core/lib/slice/percent_encoding.cc +2 -0
  468. data/src/core/lib/slice/percent_encoding.h +2 -0
  469. data/src/core/lib/slice/slice.cc +2 -0
  470. data/src/core/lib/slice/slice_buffer.cc +3 -1
  471. data/src/core/lib/slice/slice_hash_table.h +178 -45
  472. data/src/core/lib/slice/slice_intern.cc +2 -0
  473. data/src/core/lib/slice/slice_internal.h +2 -2
  474. data/src/core/lib/slice/slice_string_helpers.cc +2 -0
  475. data/src/core/lib/slice/slice_string_helpers.h +2 -1
  476. data/src/core/lib/slice/slice_weak_hash_table.h +105 -0
  477. data/src/core/lib/surface/api_trace.cc +3 -1
  478. data/src/core/lib/surface/api_trace.h +2 -0
  479. data/src/core/lib/surface/byte_buffer.cc +3 -0
  480. data/src/core/lib/surface/byte_buffer_reader.cc +3 -0
  481. data/src/core/lib/surface/call.cc +46 -80
  482. data/src/core/lib/surface/call.h +2 -0
  483. data/src/core/lib/surface/call_details.cc +2 -0
  484. data/src/core/lib/surface/call_log_batch.cc +2 -0
  485. data/src/core/lib/surface/call_test_only.h +2 -0
  486. data/src/core/lib/surface/channel.cc +72 -41
  487. data/src/core/lib/surface/channel.h +2 -0
  488. data/src/core/lib/surface/channel_init.cc +2 -0
  489. data/src/core/lib/surface/channel_init.h +2 -0
  490. data/src/core/lib/surface/channel_ping.cc +2 -0
  491. data/src/core/lib/surface/channel_stack_type.cc +3 -2
  492. data/src/core/lib/surface/channel_stack_type.h +2 -0
  493. data/src/core/lib/surface/completion_queue.h +2 -0
  494. data/src/core/lib/surface/completion_queue_factory.cc +3 -1
  495. data/src/core/lib/surface/completion_queue_factory.h +2 -0
  496. data/src/core/lib/surface/event_string.cc +2 -0
  497. data/src/core/lib/surface/event_string.h +2 -0
  498. data/src/core/lib/surface/init.cc +5 -2
  499. data/src/core/lib/surface/init_secure.cc +5 -2
  500. data/src/core/lib/surface/lame_client.cc +7 -5
  501. data/src/core/lib/surface/lame_client.h +2 -0
  502. data/src/core/lib/surface/metadata_array.cc +2 -0
  503. data/src/core/lib/surface/server.cc +2 -0
  504. data/src/core/lib/surface/server.h +2 -0
  505. data/src/core/lib/surface/validate_metadata.cc +2 -1
  506. data/src/core/lib/surface/validate_metadata.h +2 -0
  507. data/src/core/lib/surface/version.cc +4 -2
  508. data/src/core/lib/transport/bdp_estimator.cc +2 -0
  509. data/src/core/lib/transport/byte_stream.cc +94 -116
  510. data/src/core/lib/transport/byte_stream.h +111 -78
  511. data/src/core/lib/transport/connectivity_state.cc +2 -0
  512. data/src/core/lib/transport/connectivity_state.h +3 -1
  513. data/src/core/lib/transport/error_utils.cc +2 -0
  514. data/src/core/lib/transport/error_utils.h +2 -0
  515. data/src/core/lib/transport/metadata.cc +2 -0
  516. data/src/core/lib/transport/metadata.h +3 -1
  517. data/src/core/lib/transport/metadata_batch.cc +26 -0
  518. data/src/core/lib/transport/metadata_batch.h +12 -1
  519. data/src/core/lib/transport/pid_controller.cc +2 -0
  520. data/src/core/lib/transport/pid_controller.h +2 -0
  521. data/src/core/lib/transport/service_config.cc +21 -175
  522. data/src/core/lib/transport/service_config.h +223 -35
  523. data/src/core/lib/transport/static_metadata.cc +310 -294
  524. data/src/core/lib/transport/static_metadata.h +96 -82
  525. data/src/core/lib/transport/status_conversion.cc +2 -0
  526. data/src/core/lib/transport/status_conversion.h +3 -0
  527. data/src/core/lib/transport/status_metadata.cc +54 -0
  528. data/src/core/lib/{iomgr/timer_uv.h → transport/status_metadata.h} +10 -12
  529. data/src/core/lib/transport/timeout_encoding.cc +2 -1
  530. data/src/core/lib/transport/timeout_encoding.h +2 -0
  531. data/src/core/lib/transport/transport.cc +3 -1
  532. data/src/core/lib/transport/transport.h +33 -7
  533. data/src/core/lib/transport/transport_impl.h +2 -0
  534. data/src/core/lib/transport/transport_op_string.cc +10 -3
  535. data/src/core/plugin_registry/grpc_plugin_registry.cc +10 -4
  536. data/src/core/tsi/alts/crypt/aes_gcm.cc +687 -0
  537. data/src/core/tsi/alts/crypt/gsec.cc +189 -0
  538. data/src/core/tsi/alts/crypt/gsec.h +454 -0
  539. data/src/core/tsi/alts/frame_protector/alts_counter.cc +118 -0
  540. data/src/core/tsi/alts/frame_protector/alts_counter.h +98 -0
  541. data/src/core/tsi/alts/frame_protector/alts_crypter.cc +66 -0
  542. data/src/core/tsi/alts/frame_protector/alts_crypter.h +255 -0
  543. data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +407 -0
  544. data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +55 -0
  545. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc +114 -0
  546. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +114 -0
  547. data/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc +105 -0
  548. data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +103 -0
  549. data/src/core/tsi/alts/frame_protector/frame_handler.cc +218 -0
  550. data/src/core/tsi/alts/frame_protector/frame_handler.h +236 -0
  551. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +316 -0
  552. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +137 -0
  553. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc +520 -0
  554. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h +323 -0
  555. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc +143 -0
  556. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +149 -0
  557. data/src/core/tsi/alts/handshaker/alts_tsi_event.cc +73 -0
  558. data/src/core/tsi/alts/handshaker/alts_tsi_event.h +93 -0
  559. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +483 -0
  560. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +83 -0
  561. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +52 -0
  562. data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +58 -0
  563. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +52 -0
  564. data/src/core/tsi/alts/handshaker/altscontext.pb.c +48 -0
  565. data/src/core/tsi/alts/handshaker/altscontext.pb.h +64 -0
  566. data/src/core/tsi/alts/handshaker/handshaker.pb.c +123 -0
  567. data/src/core/tsi/alts/handshaker/handshaker.pb.h +255 -0
  568. data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +50 -0
  569. data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +78 -0
  570. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +196 -0
  571. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +163 -0
  572. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +180 -0
  573. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +52 -0
  574. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +144 -0
  575. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +49 -0
  576. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +91 -0
  577. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +174 -0
  578. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +100 -0
  579. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +476 -0
  580. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +199 -0
  581. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +296 -0
  582. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +52 -0
  583. data/src/core/tsi/alts_transport_security.cc +3 -1
  584. data/src/core/tsi/alts_transport_security.h +4 -2
  585. data/src/core/tsi/fake_transport_security.cc +2 -1
  586. data/src/core/tsi/fake_transport_security.h +2 -0
  587. data/src/core/tsi/ssl/session_cache/ssl_session.h +73 -0
  588. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +58 -0
  589. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +211 -0
  590. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +93 -0
  591. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +76 -0
  592. data/src/core/tsi/ssl_transport_security.cc +266 -62
  593. data/src/core/tsi/ssl_transport_security.h +128 -6
  594. data/src/core/tsi/ssl_types.h +2 -0
  595. data/src/core/tsi/transport_security.cc +2 -0
  596. data/src/core/tsi/transport_security.h +2 -0
  597. data/src/core/tsi/transport_security_adapter.cc +2 -0
  598. data/src/core/tsi/transport_security_adapter.h +2 -0
  599. data/src/core/tsi/transport_security_grpc.cc +2 -0
  600. data/src/core/tsi/transport_security_grpc.h +2 -0
  601. data/src/core/tsi/transport_security_interface.h +2 -0
  602. data/src/ruby/ext/grpc/extconf.rb +1 -2
  603. data/src/ruby/ext/grpc/rb_call.c +1 -13
  604. data/src/ruby/ext/grpc/rb_channel.c +6 -6
  605. data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
  606. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
  607. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
  608. data/src/ruby/lib/grpc/core/time_consts.rb +1 -1
  609. data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -8
  610. data/src/ruby/lib/grpc/generic/client_stub.rb +6 -10
  611. data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
  612. data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
  613. data/src/ruby/lib/grpc/version.rb +1 -1
  614. data/src/ruby/spec/generic/client_stub_spec.rb +133 -0
  615. data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +54 -0
  616. data/src/ruby/spec/pb/package_with_underscore/data.proto +23 -0
  617. data/src/ruby/spec/pb/package_with_underscore/service.proto +23 -0
  618. data/third_party/address_sorting/address_sorting.c +369 -0
  619. data/third_party/address_sorting/address_sorting_internal.h +70 -0
  620. data/third_party/address_sorting/address_sorting_posix.c +97 -0
  621. data/third_party/address_sorting/address_sorting_windows.c +55 -0
  622. data/third_party/address_sorting/include/address_sorting/address_sorting.h +110 -0
  623. data/third_party/boringssl/crypto/asn1/a_enum.c +20 -9
  624. data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +3 -0
  625. data/third_party/boringssl/crypto/asn1/a_int.c +19 -8
  626. data/third_party/boringssl/crypto/asn1/a_object.c +0 -128
  627. data/third_party/boringssl/crypto/asn1/asn1_locl.h +3 -0
  628. data/third_party/boringssl/crypto/asn1/tasn_fre.c +2 -4
  629. data/third_party/boringssl/crypto/asn1/tasn_new.c +3 -2
  630. data/third_party/boringssl/crypto/bn_extra/bn_asn1.c +0 -16
  631. data/third_party/boringssl/crypto/buf/buf.c +14 -0
  632. data/third_party/boringssl/crypto/bytestring/cbb.c +93 -0
  633. data/third_party/boringssl/crypto/conf/conf.c +2 -2
  634. data/third_party/boringssl/crypto/cpu-intel.c +17 -17
  635. data/third_party/boringssl/crypto/crypto.c +16 -4
  636. data/third_party/boringssl/crypto/curve25519/spake25519.c +11 -11
  637. data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +1 -1
  638. data/third_party/boringssl/crypto/dsa/dsa.c +9 -21
  639. data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +2 -2
  640. data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -8
  641. data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +2 -23
  642. data/third_party/boringssl/crypto/ex_data.c +0 -1
  643. data/third_party/boringssl/crypto/fipsmodule/bn/add.c +7 -11
  644. data/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c +19 -16
  645. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +15 -0
  646. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +53 -46
  647. data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +242 -85
  648. data/third_party/boringssl/crypto/fipsmodule/bn/generic.c +42 -47
  649. data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +176 -34
  650. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +118 -65
  651. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +94 -61
  652. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +79 -63
  653. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +26 -28
  654. data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +2 -0
  655. data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +250 -149
  656. data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +0 -27
  657. data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +54 -20
  658. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +3 -3
  659. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +7 -41
  660. data/third_party/boringssl/crypto/fipsmodule/ec/p256-64.c +6 -40
  661. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +17 -122
  662. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +3 -64
  663. data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +27 -9
  664. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +203 -205
  665. data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +14 -15
  666. data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +12 -8
  667. data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +4 -3
  668. data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +25 -36
  669. data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +10 -0
  670. data/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +0 -4
  671. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +2 -0
  672. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +9 -19
  673. data/third_party/boringssl/crypto/lhash/lhash.c +19 -0
  674. data/third_party/boringssl/crypto/obj/obj.c +29 -69
  675. data/third_party/boringssl/crypto/pem/pem_lib.c +2 -2
  676. data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +4 -55
  677. data/third_party/boringssl/crypto/rsa_extra/rsa_asn1.c +3 -22
  678. data/third_party/boringssl/crypto/x509/by_dir.c +1 -3
  679. data/third_party/boringssl/crypto/x509/by_file.c +0 -1
  680. data/third_party/boringssl/crypto/x509/x509_lu.c +0 -1
  681. data/third_party/boringssl/crypto/x509/x509_obj.c +1 -3
  682. data/third_party/boringssl/crypto/x509/x509_txt.c +0 -6
  683. data/third_party/boringssl/crypto/x509/x509_vfy.c +0 -1
  684. data/third_party/boringssl/crypto/x509/x509_vpm.c +0 -1
  685. data/third_party/boringssl/crypto/x509/x_algor.c +2 -2
  686. data/third_party/boringssl/crypto/x509v3/v3_alt.c +3 -4
  687. data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -0
  688. data/third_party/boringssl/crypto/x509v3/v3_info.c +1 -2
  689. data/third_party/boringssl/crypto/x509v3/v3_lib.c +15 -7
  690. data/third_party/boringssl/crypto/x509v3/v3_utl.c +41 -2
  691. data/third_party/boringssl/include/openssl/asn1.h +0 -1
  692. data/third_party/boringssl/include/openssl/base.h +1 -1
  693. data/third_party/boringssl/include/openssl/bio.h +5 -2
  694. data/third_party/boringssl/include/openssl/bn.h +2 -17
  695. data/third_party/boringssl/include/openssl/buf.h +4 -0
  696. data/third_party/boringssl/include/openssl/bytestring.h +11 -0
  697. data/third_party/boringssl/include/openssl/chacha.h +5 -1
  698. data/third_party/boringssl/include/openssl/cipher.h +10 -0
  699. data/third_party/boringssl/include/openssl/conf.h +4 -8
  700. data/third_party/boringssl/include/openssl/dsa.h +2 -18
  701. data/third_party/boringssl/include/openssl/ec.h +5 -5
  702. data/third_party/boringssl/include/openssl/ecdsa.h +10 -28
  703. data/third_party/boringssl/include/openssl/evp.h +0 -4
  704. data/third_party/boringssl/include/openssl/lhash.h +1 -18
  705. data/third_party/boringssl/include/openssl/obj.h +1 -0
  706. data/third_party/boringssl/include/openssl/rsa.h +3 -4
  707. data/third_party/boringssl/include/openssl/ssl.h +35 -54
  708. data/third_party/boringssl/include/openssl/ssl3.h +2 -0
  709. data/third_party/boringssl/include/openssl/stack.h +1 -1
  710. data/third_party/boringssl/include/openssl/tls1.h +1 -16
  711. data/third_party/boringssl/include/openssl/x509.h +3 -2
  712. data/third_party/boringssl/include/openssl/x509_vfy.h +0 -2
  713. data/third_party/boringssl/include/openssl/x509v3.h +1 -0
  714. data/third_party/boringssl/ssl/custom_extensions.cc +1 -1
  715. data/third_party/boringssl/ssl/d1_both.cc +120 -129
  716. data/third_party/boringssl/ssl/d1_lib.cc +23 -21
  717. data/third_party/boringssl/ssl/d1_pkt.cc +39 -143
  718. data/third_party/boringssl/ssl/dtls_method.cc +16 -23
  719. data/third_party/boringssl/ssl/dtls_record.cc +11 -4
  720. data/third_party/boringssl/ssl/handshake.cc +109 -40
  721. data/third_party/boringssl/ssl/handshake_client.cc +104 -96
  722. data/third_party/boringssl/ssl/handshake_server.cc +62 -72
  723. data/third_party/boringssl/ssl/internal.h +397 -318
  724. data/third_party/boringssl/ssl/s3_both.cc +173 -191
  725. data/third_party/boringssl/ssl/s3_lib.cc +26 -34
  726. data/third_party/boringssl/ssl/s3_pkt.cc +105 -247
  727. data/third_party/boringssl/ssl/ssl_asn1.cc +22 -22
  728. data/third_party/boringssl/ssl/ssl_buffer.cc +98 -108
  729. data/third_party/boringssl/ssl/ssl_cert.cc +12 -1
  730. data/third_party/boringssl/ssl/ssl_cipher.cc +23 -28
  731. data/third_party/boringssl/ssl/ssl_key_share.cc +11 -6
  732. data/third_party/boringssl/ssl/ssl_lib.cc +190 -113
  733. data/third_party/boringssl/ssl/ssl_privkey.cc +76 -106
  734. data/third_party/boringssl/ssl/ssl_session.cc +3 -3
  735. data/third_party/boringssl/ssl/ssl_stat.cc +3 -3
  736. data/third_party/boringssl/ssl/ssl_transcript.cc +38 -22
  737. data/third_party/boringssl/ssl/ssl_versions.cc +64 -31
  738. data/third_party/boringssl/ssl/t1_enc.cc +137 -154
  739. data/third_party/boringssl/ssl/t1_lib.cc +463 -478
  740. data/third_party/boringssl/ssl/tls13_both.cc +57 -58
  741. data/third_party/boringssl/ssl/tls13_client.cc +256 -121
  742. data/third_party/boringssl/ssl/tls13_enc.cc +187 -72
  743. data/third_party/boringssl/ssl/tls13_server.cc +187 -86
  744. data/third_party/boringssl/ssl/tls_method.cc +20 -30
  745. data/third_party/boringssl/ssl/tls_record.cc +77 -40
  746. data/third_party/boringssl/third_party/fiat/curve25519.c +5062 -0
  747. data/third_party/boringssl/{crypto/curve25519 → third_party/fiat}/internal.h +40 -27
  748. data/third_party/nanopb/pb.h +1 -1
  749. metadata +147 -45
  750. data/src/core/lib/gpr/thd.cc +0 -49
  751. data/src/core/lib/gpr/thd.h +0 -71
  752. data/src/core/lib/gpr/thd_posix.cc +0 -154
  753. data/src/core/lib/gpr/thd_windows.cc +0 -107
  754. data/src/core/lib/iomgr/iomgr_uv.h +0 -37
  755. data/src/core/lib/iomgr/pollset_set_uv.cc +0 -43
  756. data/src/core/lib/iomgr/resolve_address_uv.cc +0 -284
  757. data/src/core/lib/iomgr/tcp_client_uv.cc +0 -175
  758. data/src/core/lib/iomgr/tcp_server_uv.cc +0 -471
  759. data/src/core/lib/iomgr/tcp_uv.h +0 -51
  760. data/src/core/lib/security/transport/lb_targets_info.cc +0 -59
  761. data/src/core/lib/slice/slice_hash_table.cc +0 -145
  762. data/third_party/boringssl/crypto/curve25519/curve25519.c +0 -4938
@@ -153,6 +153,7 @@
153
153
 
154
154
  #include <openssl/aead.h>
155
155
  #include <openssl/err.h>
156
+ #include <openssl/lhash.h>
156
157
  #include <openssl/mem.h>
157
158
  #include <openssl/ssl.h>
158
159
  #include <openssl/span.h>
@@ -387,9 +388,17 @@ bool ssl_add_supported_versions(SSL_HANDSHAKE *hs, CBB *cbb);
387
388
  bool ssl_negotiate_version(SSL_HANDSHAKE *hs, uint8_t *out_alert,
388
389
  uint16_t *out_version, const CBS *peer_versions);
389
390
 
390
- // ssl3_protocol_version returns |ssl|'s protocol version. It is an error to
391
+ // ssl_protocol_version returns |ssl|'s protocol version. It is an error to
391
392
  // call this function before the version is determined.
392
- uint16_t ssl3_protocol_version(const SSL *ssl);
393
+ uint16_t ssl_protocol_version(const SSL *ssl);
394
+
395
+ // ssl_is_draft21 returns whether the version corresponds to a draft21 TLS 1.3
396
+ // variant.
397
+ bool ssl_is_draft21(uint16_t version);
398
+
399
+ // ssl_is_draft22 returns whether the version corresponds to a draft22 TLS 1.3
400
+ // variant.
401
+ bool ssl_is_draft22(uint16_t version);
393
402
 
394
403
  // ssl_is_resumption_experiment returns whether the version corresponds to a
395
404
  // TLS 1.3 resumption experiment.
@@ -489,14 +498,12 @@ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
489
498
  const EVP_MD *ssl_get_handshake_digest(uint16_t version,
490
499
  const SSL_CIPHER *cipher);
491
500
 
492
- // ssl_create_cipher_list evaluates |rule_str| according to the ciphers in
493
- // |ssl_method|. It sets |*out_cipher_list| to a newly-allocated
494
- // |ssl_cipher_preference_list_st| containing the result. It returns true on
495
- // success and false on failure. If |strict| is true, nonsense will be
496
- // rejected. If false, nonsense will be silently ignored. An empty result is
497
- // considered an error regardless of |strict|.
501
+ // ssl_create_cipher_list evaluates |rule_str|. It sets |*out_cipher_list| to a
502
+ // newly-allocated |ssl_cipher_preference_list_st| containing the result. It
503
+ // returns true on success and false on failure. If |strict| is true, nonsense
504
+ // will be rejected. If false, nonsense will be silently ignored. An empty
505
+ // result is considered an error regardless of |strict|.
498
506
  bool ssl_create_cipher_list(
499
- const SSL_PROTOCOL_METHOD *ssl_method,
500
507
  struct ssl_cipher_preference_list_st **out_cipher_list,
501
508
  const char *rule_str, bool strict);
502
509
 
@@ -544,10 +551,20 @@ class SSLTranscript {
544
551
  // to call this function after the handshake buffer is released.
545
552
  bool InitHash(uint16_t version, const SSL_CIPHER *cipher);
546
553
 
547
- const uint8_t *buffer_data() const {
548
- return reinterpret_cast<const uint8_t *>(buffer_->data);
554
+ // UpdateForHelloRetryRequest resets the rolling hash with the
555
+ // HelloRetryRequest construction. It returns true on success and false on
556
+ // failure. It is an error to call this function before the handshake buffer
557
+ // is released.
558
+ bool UpdateForHelloRetryRequest();
559
+
560
+ // CopyHashContext copies the hash context into |ctx| and returns true on
561
+ // success.
562
+ bool CopyHashContext(EVP_MD_CTX *ctx);
563
+
564
+ Span<const uint8_t> buffer() {
565
+ return MakeConstSpan(reinterpret_cast<const uint8_t *>(buffer_->data),
566
+ buffer_->length);
549
567
  }
550
- size_t buffer_len() const { return buffer_->length; }
551
568
 
552
569
  // FreeBuffer releases the handshake buffer. Subsequent calls to
553
570
  // |Update| will not update the handshake buffer.
@@ -562,7 +579,7 @@ class SSLTranscript {
562
579
 
563
580
  // Update adds |in| to the handshake buffer and handshake hash, whichever is
564
581
  // enabled. It returns true on success and false on failure.
565
- bool Update(const uint8_t *in, size_t in_len);
582
+ bool Update(Span<const uint8_t> in);
566
583
 
567
584
  // GetHash writes the handshake hash to |out| which must have room for at
568
585
  // least |DigestLen| bytes. On success, it returns true and sets |*out_len| to
@@ -595,14 +612,12 @@ class SSLTranscript {
595
612
  ScopedEVP_MD_CTX md5_;
596
613
  };
597
614
 
598
- // tls1_prf computes the PRF function for |ssl|. It writes |out_len| bytes to
599
- // |out|, using |secret| as the secret and |label| as the label. |seed1| and
600
- // |seed2| are concatenated to form the seed parameter. It returns one on
601
- // success and zero on failure.
602
- int tls1_prf(const EVP_MD *digest, uint8_t *out, size_t out_len,
603
- const uint8_t *secret, size_t secret_len, const char *label,
604
- size_t label_len, const uint8_t *seed1, size_t seed1_len,
605
- const uint8_t *seed2, size_t seed2_len);
615
+ // tls1_prf computes the PRF function for |ssl|. It fills |out|, using |secret|
616
+ // as the secret and |label| as the label. |seed1| and |seed2| are concatenated
617
+ // to form the seed parameter. It returns true on success and false on failure.
618
+ bool tls1_prf(const EVP_MD *digest, Span<uint8_t> out,
619
+ Span<const uint8_t> secret, Span<const char> label,
620
+ Span<const uint8_t> seed1, Span<const uint8_t> seed2);
606
621
 
607
622
 
608
623
  // Encryption layer.
@@ -745,10 +760,10 @@ class SSLAEADContext {
745
760
  struct DTLS1_BITMAP {
746
761
  // map is a bit mask of the last 64 sequence numbers. Bit
747
762
  // |1<<i| corresponds to |max_seq_num - i|.
748
- uint64_t map;
763
+ uint64_t map = 0;
749
764
  // max_seq_num is the largest sequence number seen so far as a 64-bit
750
765
  // integer.
751
- uint64_t max_seq_num;
766
+ uint64_t max_seq_num = 0;
752
767
  };
753
768
 
754
769
 
@@ -800,8 +815,9 @@ enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type,
800
815
  Span<uint8_t> *out, size_t *out_consumed,
801
816
  uint8_t *out_alert, Span<uint8_t> in);
802
817
 
803
- // dtls_open_record implements |tls_open_record| for DTLS. It never returns
804
- // |ssl_open_record_partial| but otherwise behaves analogously.
818
+ // dtls_open_record implements |tls_open_record| for DTLS. It only returns
819
+ // |ssl_open_record_partial| if |in| was empty and sets |*out_consumed| to
820
+ // zero. The caller should read one packet and try again.
805
821
  enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
806
822
  Span<uint8_t> *out,
807
823
  size_t *out_consumed,
@@ -876,22 +892,24 @@ int ssl_has_private_key(const SSL *ssl);
876
892
 
877
893
  enum ssl_private_key_result_t ssl_private_key_sign(
878
894
  SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
879
- uint16_t sigalg, const uint8_t *in, size_t in_len);
895
+ uint16_t sigalg, Span<const uint8_t> in);
880
896
 
881
- enum ssl_private_key_result_t ssl_private_key_decrypt(
882
- SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
883
- const uint8_t *in, size_t in_len);
897
+ enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
898
+ uint8_t *out,
899
+ size_t *out_len,
900
+ size_t max_out,
901
+ Span<const uint8_t> in);
884
902
 
885
- // ssl_private_key_supports_signature_algorithm returns one if |hs|'s private
886
- // key supports |sigalg| and zero otherwise.
887
- int ssl_private_key_supports_signature_algorithm(SSL_HANDSHAKE *hs,
903
+ // ssl_private_key_supports_signature_algorithm returns whether |hs|'s private
904
+ // key supports |sigalg|.
905
+ bool ssl_private_key_supports_signature_algorithm(SSL_HANDSHAKE *hs,
888
906
  uint16_t sigalg);
889
907
 
890
908
  // ssl_public_key_verify verifies that the |signature| is valid for the public
891
909
  // key |pkey| and input |in|, using the signature algorithm |sigalg|.
892
- int ssl_public_key_verify(SSL *ssl, const uint8_t *signature,
893
- size_t signature_len, uint16_t sigalg, EVP_PKEY *pkey,
894
- const uint8_t *in, size_t in_len);
910
+ bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature,
911
+ uint16_t sigalg, EVP_PKEY *pkey,
912
+ Span<const uint8_t> in);
895
913
 
896
914
 
897
915
  // Custom extensions
@@ -990,22 +1008,36 @@ struct SSLMessage {
990
1008
  // Channel ID, are all enabled.
991
1009
  #define SSL_MAX_HANDSHAKE_FLIGHT 7
992
1010
 
1011
+ extern const uint8_t kHelloRetryRequest[SSL3_RANDOM_SIZE];
1012
+
993
1013
  // ssl_max_handshake_message_len returns the maximum number of bytes permitted
994
1014
  // in a handshake message for |ssl|.
995
1015
  size_t ssl_max_handshake_message_len(const SSL *ssl);
996
1016
 
997
- // dtls_clear_incoming_messages releases all buffered incoming messages.
998
- void dtls_clear_incoming_messages(SSL *ssl);
1017
+ // tls_can_accept_handshake_data returns whether |ssl| is able to accept more
1018
+ // data into handshake buffer.
1019
+ bool tls_can_accept_handshake_data(const SSL *ssl, uint8_t *out_alert);
1020
+
1021
+ // tls_has_unprocessed_handshake_data returns whether there is buffered
1022
+ // handshake data that has not been consumed by |get_message|.
1023
+ bool tls_has_unprocessed_handshake_data(const SSL *ssl);
999
1024
 
1000
- // dtls_has_incoming_messages returns one if there are buffered incoming
1001
- // messages ahead of the current message and zero otherwise.
1002
- int dtls_has_incoming_messages(const SSL *ssl);
1025
+ // dtls_has_unprocessed_handshake_data behaves like
1026
+ // |tls_has_unprocessed_handshake_data| for DTLS.
1027
+ bool dtls_has_unprocessed_handshake_data(const SSL *ssl);
1003
1028
 
1004
1029
  struct DTLS_OUTGOING_MESSAGE {
1005
- uint8_t *data;
1006
- uint32_t len;
1007
- uint16_t epoch;
1008
- char is_ccs;
1030
+ DTLS_OUTGOING_MESSAGE() {}
1031
+ DTLS_OUTGOING_MESSAGE(const DTLS_OUTGOING_MESSAGE &) = delete;
1032
+ DTLS_OUTGOING_MESSAGE &operator=(const DTLS_OUTGOING_MESSAGE &) = delete;
1033
+ ~DTLS_OUTGOING_MESSAGE() { Clear(); }
1034
+
1035
+ void Clear();
1036
+
1037
+ uint8_t *data = nullptr;
1038
+ uint32_t len = 0;
1039
+ uint16_t epoch = 0;
1040
+ bool is_ccs = false;
1009
1041
  };
1010
1042
 
1011
1043
  // dtls_clear_outgoing_messages releases all buffered outgoing messages.
@@ -1024,8 +1056,57 @@ void ssl_do_msg_callback(SSL *ssl, int is_write, int content_type,
1024
1056
 
1025
1057
  // Transport buffers.
1026
1058
 
1027
- // ssl_read_buffer returns the current read buffer.
1028
- Span<uint8_t> ssl_read_buffer(SSL *ssl);
1059
+ class SSLBuffer {
1060
+ public:
1061
+ SSLBuffer() {}
1062
+ ~SSLBuffer() { Clear(); }
1063
+
1064
+ SSLBuffer(const SSLBuffer &) = delete;
1065
+ SSLBuffer &operator=(const SSLBuffer &) = delete;
1066
+
1067
+ uint8_t *data() { return buf_ + offset_; }
1068
+ size_t size() const { return size_; }
1069
+ bool empty() const { return size_ == 0; }
1070
+ size_t cap() const { return cap_; }
1071
+
1072
+ Span<uint8_t> span() { return MakeSpan(data(), size()); }
1073
+
1074
+ Span<uint8_t> remaining() {
1075
+ return MakeSpan(data() + size(), cap() - size());
1076
+ }
1077
+
1078
+ // Clear releases the buffer.
1079
+ void Clear();
1080
+
1081
+ // EnsureCap ensures the buffer has capacity at least |new_cap|, aligned such
1082
+ // that data written after |header_len| is aligned to a
1083
+ // |SSL3_ALIGN_PAYLOAD|-byte boundary. It returns true on success and false
1084
+ // on error.
1085
+ bool EnsureCap(size_t header_len, size_t new_cap);
1086
+
1087
+ // DidWrite extends the buffer by |len|. The caller must have filled in to
1088
+ // this point.
1089
+ void DidWrite(size_t len);
1090
+
1091
+ // Consume consumes |len| bytes from the front of the buffer. The memory
1092
+ // consumed will remain valid until the next call to |DiscardConsumed| or
1093
+ // |Clear|.
1094
+ void Consume(size_t len);
1095
+
1096
+ // DiscardConsumed discards the consumed bytes from the buffer. If the buffer
1097
+ // is now empty, it releases memory used by it.
1098
+ void DiscardConsumed();
1099
+
1100
+ private:
1101
+ // buf_ is the memory allocated for this buffer.
1102
+ uint8_t *buf_ = nullptr;
1103
+ // offset_ is the offset into |buf_| which the buffer contents start at.
1104
+ uint16_t offset_ = 0;
1105
+ // size_ is the size of the buffer contents from |buf_| + |offset_|.
1106
+ uint16_t size_ = 0;
1107
+ // cap_ is how much memory beyond |buf_| + |offset_| is available.
1108
+ uint16_t cap_ = 0;
1109
+ };
1029
1110
 
1030
1111
  // ssl_read_buffer_extend_to extends the read buffer to the desired length. For
1031
1112
  // TLS, it reads to the end of the buffer until the buffer is |len| bytes
@@ -1036,43 +1117,18 @@ Span<uint8_t> ssl_read_buffer(SSL *ssl);
1036
1117
  // non-empty.
1037
1118
  int ssl_read_buffer_extend_to(SSL *ssl, size_t len);
1038
1119
 
1039
- // ssl_read_buffer_consume consumes |len| bytes from the read buffer. It
1040
- // advances the data pointer and decrements the length. The memory consumed will
1041
- // remain valid until the next call to |ssl_read_buffer_extend| or it is
1042
- // discarded with |ssl_read_buffer_discard|.
1043
- void ssl_read_buffer_consume(SSL *ssl, size_t len);
1044
-
1045
- // ssl_read_buffer_discard discards the consumed bytes from the read buffer. If
1046
- // the buffer is now empty, it releases memory used by it.
1047
- void ssl_read_buffer_discard(SSL *ssl);
1048
-
1049
- // ssl_read_buffer_clear releases all memory associated with the read buffer and
1050
- // zero-initializes it.
1051
- void ssl_read_buffer_clear(SSL *ssl);
1052
-
1053
- // ssl_write_buffer_is_pending returns one if the write buffer has pending data
1054
- // and zero if is empty.
1055
- int ssl_write_buffer_is_pending(const SSL *ssl);
1056
-
1057
- // ssl_write_buffer_init initializes the write buffer. On success, it sets
1058
- // |*out_ptr| to the start of the write buffer with space for up to |max_len|
1059
- // bytes. It returns one on success and zero on failure. Call
1060
- // |ssl_write_buffer_set_len| to complete initialization.
1061
- int ssl_write_buffer_init(SSL *ssl, uint8_t **out_ptr, size_t max_len);
1062
-
1063
- // ssl_write_buffer_set_len is called after |ssl_write_buffer_init| to complete
1064
- // initialization after |len| bytes are written to the buffer.
1065
- void ssl_write_buffer_set_len(SSL *ssl, size_t len);
1120
+ // ssl_handle_open_record handles the result of passing |ssl->s3->read_buffer|
1121
+ // to a record-processing function. If |ret| is a success or if the caller
1122
+ // should retry, it returns one and sets |*out_retry|. Otherwise, it returns <=
1123
+ // 0.
1124
+ int ssl_handle_open_record(SSL *ssl, bool *out_retry, ssl_open_record_t ret,
1125
+ size_t consumed, uint8_t alert);
1066
1126
 
1067
1127
  // ssl_write_buffer_flush flushes the write buffer to the transport. It returns
1068
1128
  // one on success and <= 0 on error. For DTLS, whether or not the write
1069
1129
  // succeeds, the write buffer will be cleared.
1070
1130
  int ssl_write_buffer_flush(SSL *ssl);
1071
1131
 
1072
- // ssl_write_buffer_clear releases all memory associated with the write buffer
1073
- // and zero-initializes it.
1074
- void ssl_write_buffer_clear(SSL *ssl);
1075
-
1076
1132
 
1077
1133
  // Certificate functions.
1078
1134
 
@@ -1121,6 +1177,9 @@ UniquePtr<STACK_OF(CRYPTO_BUFFER)> ssl_parse_client_CA_list(SSL *ssl,
1121
1177
  uint8_t *out_alert,
1122
1178
  CBS *cbs);
1123
1179
 
1180
+ // ssl_has_client_CAs returns there are configured CAs.
1181
+ bool ssl_has_client_CAs(SSL *ssl);
1182
+
1124
1183
  // ssl_add_client_CA_list adds the configured CA list to |cbb| in the format
1125
1184
  // used by a TLS CertificateRequest message. It returns one on success and zero
1126
1185
  // on error.
@@ -1141,14 +1200,16 @@ int ssl_on_certificate_selected(SSL_HANDSHAKE *hs);
1141
1200
  // TLS 1.3 key derivation.
1142
1201
 
1143
1202
  // tls13_init_key_schedule initializes the handshake hash and key derivation
1144
- // state. The cipher suite and PRF hash must have been selected at this point.
1145
- // It returns one on success and zero on error.
1146
- int tls13_init_key_schedule(SSL_HANDSHAKE *hs);
1203
+ // state, and incorporates the PSK. The cipher suite and PRF hash must have been
1204
+ // selected at this point. It returns one on success and zero on error.
1205
+ int tls13_init_key_schedule(SSL_HANDSHAKE *hs, const uint8_t *psk,
1206
+ size_t psk_len);
1147
1207
 
1148
1208
  // tls13_init_early_key_schedule initializes the handshake hash and key
1149
- // derivation state from the resumption secret to derive the early secrets. It
1150
- // returns one on success and zero on error.
1151
- int tls13_init_early_key_schedule(SSL_HANDSHAKE *hs);
1209
+ // derivation state from the resumption secret and incorporates the PSK to
1210
+ // derive the early secrets. It returns one on success and zero on error.
1211
+ int tls13_init_early_key_schedule(SSL_HANDSHAKE *hs, const uint8_t *psk,
1212
+ size_t psk_len);
1152
1213
 
1153
1214
  // tls13_advance_key_schedule incorporates |in| into the key schedule with
1154
1215
  // HKDF-Extract. It returns one on success and zero on error.
@@ -1195,6 +1256,11 @@ int tls13_export_keying_material(SSL *ssl, uint8_t *out, size_t out_len,
1195
1256
  int tls13_finished_mac(SSL_HANDSHAKE *hs, uint8_t *out,
1196
1257
  size_t *out_len, int is_server);
1197
1258
 
1259
+ // tls13_derive_session_psk calculates the PSK for this session based on the
1260
+ // resumption master secret and |nonce|. It returns true on success, and false
1261
+ // on failure.
1262
+ bool tls13_derive_session_psk(SSL_SESSION *session, Span<const uint8_t> nonce);
1263
+
1198
1264
  // tls13_write_psk_binder calculates the PSK binder value and replaces the last
1199
1265
  // bytes of |msg| with the resulting value. It returns 1 on success, and 0 on
1200
1266
  // failure.
@@ -1378,6 +1444,7 @@ struct SSL_HANDSHAKE {
1378
1444
  bool needs_psk_binder:1;
1379
1445
 
1380
1446
  bool received_hello_retry_request:1;
1447
+ bool sent_hello_retry_request:1;
1381
1448
 
1382
1449
  bool received_custom_extension:1;
1383
1450
 
@@ -1450,14 +1517,11 @@ struct SSL_HANDSHAKE {
1450
1517
  uint16_t early_data_written = 0;
1451
1518
  };
1452
1519
 
1453
- SSL_HANDSHAKE *ssl_handshake_new(SSL *ssl);
1454
-
1455
- // ssl_handshake_free releases all memory associated with |hs|.
1456
- void ssl_handshake_free(SSL_HANDSHAKE *hs);
1520
+ UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSL *ssl);
1457
1521
 
1458
1522
  // ssl_check_message_type checks if |msg| has type |type|. If so it returns
1459
1523
  // one. Otherwise, it sends an alert and returns zero.
1460
- int ssl_check_message_type(SSL *ssl, const SSLMessage &msg, int type);
1524
+ bool ssl_check_message_type(SSL *ssl, const SSLMessage &msg, int type);
1461
1525
 
1462
1526
  // ssl_run_handshake runs the TLS handshake. It returns one on success and <= 0
1463
1527
  // on error. It sets |out_early_return| to one if we've completed the handshake
@@ -1502,20 +1566,21 @@ enum ssl_private_key_result_t tls13_add_certificate_verify(SSL_HANDSHAKE *hs);
1502
1566
  int tls13_add_finished(SSL_HANDSHAKE *hs);
1503
1567
  int tls13_process_new_session_ticket(SSL *ssl, const SSLMessage &msg);
1504
1568
 
1505
- int ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
1506
- Array<uint8_t> *out_secret,
1507
- uint8_t *out_alert, CBS *contents);
1508
- int ssl_ext_key_share_parse_clienthello(SSL_HANDSHAKE *hs, bool *out_found,
1509
- Array<uint8_t> *out_secret,
1510
- uint8_t *out_alert, CBS *contents);
1511
- int ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
1512
-
1513
- int ssl_ext_pre_shared_key_parse_serverhello(SSL_HANDSHAKE *hs,
1514
- uint8_t *out_alert, CBS *contents);
1515
- int ssl_ext_pre_shared_key_parse_clienthello(
1569
+ bool ssl_ext_key_share_parse_serverhello(SSL_HANDSHAKE *hs,
1570
+ Array<uint8_t> *out_secret,
1571
+ uint8_t *out_alert, CBS *contents);
1572
+ bool ssl_ext_key_share_parse_clienthello(SSL_HANDSHAKE *hs, bool *out_found,
1573
+ Array<uint8_t> *out_secret,
1574
+ uint8_t *out_alert, CBS *contents);
1575
+ bool ssl_ext_key_share_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
1576
+
1577
+ bool ssl_ext_pre_shared_key_parse_serverhello(SSL_HANDSHAKE *hs,
1578
+ uint8_t *out_alert,
1579
+ CBS *contents);
1580
+ bool ssl_ext_pre_shared_key_parse_clienthello(
1516
1581
  SSL_HANDSHAKE *hs, CBS *out_ticket, CBS *out_binders,
1517
1582
  uint32_t *out_obfuscated_ticket_age, uint8_t *out_alert, CBS *contents);
1518
- int ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
1583
+ bool ssl_ext_pre_shared_key_add_serverhello(SSL_HANDSHAKE *hs, CBB *out);
1519
1584
 
1520
1585
  // ssl_is_sct_list_valid does a shallow parse of the SCT list in |contents| and
1521
1586
  // returns one iff it's valid.
@@ -1531,18 +1596,21 @@ enum ssl_cert_verify_context_t {
1531
1596
 
1532
1597
  // tls13_get_cert_verify_signature_input generates the message to be signed for
1533
1598
  // TLS 1.3's CertificateVerify message. |cert_verify_context| determines the
1534
- // type of signature. It sets |*out| and |*out_len| to a newly allocated buffer
1535
- // containing the result. The caller must free it with |OPENSSL_free| to release
1536
- // it. This function returns one on success and zero on failure.
1537
- int tls13_get_cert_verify_signature_input(
1538
- SSL_HANDSHAKE *hs, uint8_t **out, size_t *out_len,
1599
+ // type of signature. It sets |*out| to a newly allocated buffer containing the
1600
+ // result. This function returns true on success and false on failure.
1601
+ bool tls13_get_cert_verify_signature_input(
1602
+ SSL_HANDSHAKE *hs, Array<uint8_t> *out,
1539
1603
  enum ssl_cert_verify_context_t cert_verify_context);
1540
1604
 
1605
+ // ssl_is_alpn_protocol_allowed returns whether |protocol| is a valid server
1606
+ // selection for |ssl|'s client preferences.
1607
+ bool ssl_is_alpn_protocol_allowed(const SSL *ssl, Span<const uint8_t> protocol);
1608
+
1541
1609
  // ssl_negotiate_alpn negotiates the ALPN extension, if applicable. It returns
1542
- // one on successful negotiation or if nothing was negotiated. It returns zero
1610
+ // true on successful negotiation or if nothing was negotiated. It returns false
1543
1611
  // and sets |*out_alert| to an alert on error.
1544
- int ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1545
- const SSL_CLIENT_HELLO *client_hello);
1612
+ bool ssl_negotiate_alpn(SSL_HANDSHAKE *hs, uint8_t *out_alert,
1613
+ const SSL_CLIENT_HELLO *client_hello);
1546
1614
 
1547
1615
  struct SSL_EXTENSION_TYPE {
1548
1616
  uint16_t type;
@@ -1562,6 +1630,10 @@ int ssl_parse_extensions(const CBS *cbs, uint8_t *out_alert,
1562
1630
  // ssl_verify_peer_cert verifies the peer certificate for |hs|.
1563
1631
  enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs);
1564
1632
 
1633
+ enum ssl_hs_wait_t ssl_get_finished(SSL_HANDSHAKE *hs);
1634
+ bool ssl_send_finished(SSL_HANDSHAKE *hs);
1635
+ bool ssl_output_cert_chain(SSL *ssl);
1636
+
1565
1637
 
1566
1638
  // SSLKEYLOGFILE functions.
1567
1639
 
@@ -1706,64 +1778,81 @@ struct CERT {
1706
1778
 
1707
1779
  // |SSL_PROTOCOL_METHOD| abstracts between TLS and DTLS.
1708
1780
  struct SSL_PROTOCOL_METHOD {
1709
- // is_dtls is one if the protocol is DTLS and zero otherwise.
1710
- char is_dtls;
1711
- int (*ssl_new)(SSL *ssl);
1781
+ bool is_dtls;
1782
+ bool (*ssl_new)(SSL *ssl);
1712
1783
  void (*ssl_free)(SSL *ssl);
1713
1784
  // get_message sets |*out| to the current handshake message and returns true
1714
1785
  // if one has been received. It returns false if more input is needed.
1715
1786
  bool (*get_message)(SSL *ssl, SSLMessage *out);
1716
- // read_message reads additional handshake data for |get_message|. On success,
1717
- // it returns one. Otherwise, it returns <= 0.
1718
- int (*read_message)(SSL *ssl);
1719
1787
  // next_message is called to release the current handshake message.
1720
1788
  void (*next_message)(SSL *ssl);
1721
- // read_app_data reads up to |len| bytes of application data into |buf|. On
1722
- // success, it returns the number of bytes read. Otherwise, it returns <= 0
1723
- // and sets |*out_got_handshake| to whether the failure was due to a
1724
- // post-handshake handshake message. If so, any handshake messages consumed
1725
- // may be read with |get_message|.
1726
- int (*read_app_data)(SSL *ssl, bool *out_got_handshake, uint8_t *buf, int len,
1727
- int peek);
1728
- int (*read_change_cipher_spec)(SSL *ssl);
1729
- void (*read_close_notify)(SSL *ssl);
1789
+ // Use the |ssl_open_handshake| wrapper.
1790
+ ssl_open_record_t (*open_handshake)(SSL *ssl, size_t *out_consumed,
1791
+ uint8_t *out_alert, Span<uint8_t> in);
1792
+ // Use the |ssl_open_change_cipher_spec| wrapper.
1793
+ ssl_open_record_t (*open_change_cipher_spec)(SSL *ssl, size_t *out_consumed,
1794
+ uint8_t *out_alert,
1795
+ Span<uint8_t> in);
1796
+ // Use the |ssl_open_app_data| wrapper.
1797
+ ssl_open_record_t (*open_app_data)(SSL *ssl, Span<uint8_t> *out,
1798
+ size_t *out_consumed, uint8_t *out_alert,
1799
+ Span<uint8_t> in);
1730
1800
  int (*write_app_data)(SSL *ssl, bool *out_needs_handshake, const uint8_t *buf,
1731
1801
  int len);
1732
1802
  int (*dispatch_alert)(SSL *ssl);
1733
- // supports_cipher returns one if |cipher| is supported by this protocol and
1734
- // zero otherwise.
1735
- int (*supports_cipher)(const SSL_CIPHER *cipher);
1736
1803
  // init_message begins a new handshake message of type |type|. |cbb| is the
1737
1804
  // root CBB to be passed into |finish_message|. |*body| is set to a child CBB
1738
- // the caller should write to. It returns one on success and zero on error.
1739
- int (*init_message)(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
1805
+ // the caller should write to. It returns true on success and false on error.
1806
+ bool (*init_message)(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
1740
1807
  // finish_message finishes a handshake message. It sets |*out_msg| to the
1741
- // serialized message. It returns one on success and zero on error.
1742
- int (*finish_message)(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
1743
- // add_message adds a handshake message to the pending flight. It returns one
1744
- // on success and zero on error.
1745
- int (*add_message)(SSL *ssl, Array<uint8_t> msg);
1808
+ // serialized message. It returns true on success and false on error.
1809
+ bool (*finish_message)(SSL *ssl, CBB *cbb, bssl::Array<uint8_t> *out_msg);
1810
+ // add_message adds a handshake message to the pending flight. It returns
1811
+ // true on success and false on error.
1812
+ bool (*add_message)(SSL *ssl, bssl::Array<uint8_t> msg);
1746
1813
  // add_change_cipher_spec adds a ChangeCipherSpec record to the pending
1747
- // flight. It returns one on success and zero on error.
1748
- int (*add_change_cipher_spec)(SSL *ssl);
1749
- // add_alert adds an alert to the pending flight. It returns one on success
1750
- // and zero on error.
1751
- int (*add_alert)(SSL *ssl, uint8_t level, uint8_t desc);
1814
+ // flight. It returns true on success and false on error.
1815
+ bool (*add_change_cipher_spec)(SSL *ssl);
1816
+ // add_alert adds an alert to the pending flight. It returns true on success
1817
+ // and false on error.
1818
+ bool (*add_alert)(SSL *ssl, uint8_t level, uint8_t desc);
1752
1819
  // flush_flight flushes the pending flight to the transport. It returns one on
1753
1820
  // success and <= 0 on error.
1754
1821
  int (*flush_flight)(SSL *ssl);
1755
1822
  // on_handshake_complete is called when the handshake is complete.
1756
1823
  void (*on_handshake_complete)(SSL *ssl);
1757
1824
  // set_read_state sets |ssl|'s read cipher state to |aead_ctx|. It returns
1758
- // one on success and zero if changing the read state is forbidden at this
1825
+ // true on success and false if changing the read state is forbidden at this
1759
1826
  // point.
1760
- int (*set_read_state)(SSL *ssl, UniquePtr<SSLAEADContext> aead_ctx);
1827
+ bool (*set_read_state)(SSL *ssl, UniquePtr<SSLAEADContext> aead_ctx);
1761
1828
  // set_write_state sets |ssl|'s write cipher state to |aead_ctx|. It returns
1762
- // one on success and zero if changing the write state is forbidden at this
1829
+ // true on success and false if changing the write state is forbidden at this
1763
1830
  // point.
1764
- int (*set_write_state)(SSL *ssl, UniquePtr<SSLAEADContext> aead_ctx);
1831
+ bool (*set_write_state)(SSL *ssl, UniquePtr<SSLAEADContext> aead_ctx);
1765
1832
  };
1766
1833
 
1834
+ // The following wrappers call |open_*| but handle |read_shutdown| correctly.
1835
+
1836
+ // ssl_open_handshake processes a record from |in| for reading a handshake
1837
+ // message.
1838
+ ssl_open_record_t ssl_open_handshake(SSL *ssl, size_t *out_consumed,
1839
+ uint8_t *out_alert, Span<uint8_t> in);
1840
+
1841
+ // ssl_open_change_cipher_spec processes a record from |in| for reading a
1842
+ // ChangeCipherSpec.
1843
+ ssl_open_record_t ssl_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
1844
+ uint8_t *out_alert,
1845
+ Span<uint8_t> in);
1846
+
1847
+ // ssl_open_app_data processes a record from |in| for reading application data.
1848
+ // On success, it returns |ssl_open_record_success| and sets |*out| to the
1849
+ // input. If it encounters a post-handshake message, it returns
1850
+ // |ssl_open_record_discard|. The caller should then retry, after processing any
1851
+ // messages received with |get_message|.
1852
+ ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
1853
+ size_t *out_consumed, uint8_t *out_alert,
1854
+ Span<uint8_t> in);
1855
+
1767
1856
  // ssl_crypto_x509_method provides the |SSL_X509_METHOD| functions using
1768
1857
  // crypto/x509.
1769
1858
  extern const SSL_X509_METHOD ssl_crypto_x509_method;
@@ -1820,6 +1909,12 @@ struct tlsext_ticket_key {
1820
1909
  uint64_t next_rotation_tv_sec;
1821
1910
  };
1822
1911
 
1912
+ } // namespace bssl
1913
+
1914
+ DECLARE_LHASH_OF(SSL_SESSION)
1915
+
1916
+ namespace bssl {
1917
+
1823
1918
  // SSLContext backs the public |SSL_CTX| type. Due to compatibility constraints,
1824
1919
  // it is a base class for |ssl_ctx_st|.
1825
1920
  struct SSLContext {
@@ -1988,11 +2083,6 @@ struct SSLContext {
1988
2083
  uint8_t *psk, unsigned int max_psk_len);
1989
2084
 
1990
2085
 
1991
- // retain_only_sha256_of_client_certs is true if we should compute the SHA256
1992
- // hash of the peer's certificate and then discard it to save memory and
1993
- // session space. Only effective on the server side.
1994
- char retain_only_sha256_of_client_certs;
1995
-
1996
2086
  // Next protocol negotiation information
1997
2087
  // (for experimental NPN extension).
1998
2088
 
@@ -2059,52 +2149,37 @@ struct SSLContext {
2059
2149
  uint16_t *verify_sigalgs;
2060
2150
  size_t num_verify_sigalgs;
2061
2151
 
2152
+ // retain_only_sha256_of_client_certs is true if we should compute the SHA256
2153
+ // hash of the peer's certificate and then discard it to save memory and
2154
+ // session space. Only effective on the server side.
2155
+ bool retain_only_sha256_of_client_certs:1;
2156
+
2062
2157
  // quiet_shutdown is true if the connection should not send a close_notify on
2063
2158
  // shutdown.
2064
- unsigned quiet_shutdown:1;
2159
+ bool quiet_shutdown:1;
2065
2160
 
2066
2161
  // ocsp_stapling_enabled is only used by client connections and indicates
2067
2162
  // whether OCSP stapling will be requested.
2068
- unsigned ocsp_stapling_enabled:1;
2163
+ bool ocsp_stapling_enabled:1;
2069
2164
 
2070
2165
  // If true, a client will request certificate timestamps.
2071
- unsigned signed_cert_timestamps_enabled:1;
2166
+ bool signed_cert_timestamps_enabled:1;
2072
2167
 
2073
2168
  // tlsext_channel_id_enabled is one if Channel ID is enabled and zero
2074
2169
  // otherwise. For a server, means that we'll accept Channel IDs from clients.
2075
2170
  // For a client, means that we'll advertise support.
2076
- unsigned tlsext_channel_id_enabled:1;
2171
+ bool tlsext_channel_id_enabled:1;
2077
2172
 
2078
2173
  // grease_enabled is one if draft-davidben-tls-grease-01 is enabled and zero
2079
2174
  // otherwise.
2080
- unsigned grease_enabled:1;
2175
+ bool grease_enabled:1;
2081
2176
 
2082
2177
  // allow_unknown_alpn_protos is one if the client allows unsolicited ALPN
2083
2178
  // protocols from the peer.
2084
- unsigned allow_unknown_alpn_protos:1;
2179
+ bool allow_unknown_alpn_protos:1;
2085
2180
 
2086
2181
  // ed25519_enabled is one if Ed25519 is advertised in the handshake.
2087
- unsigned ed25519_enabled:1;
2088
- };
2089
-
2090
- struct SSL3_RECORD {
2091
- // type is the record type.
2092
- uint8_t type;
2093
- // length is the number of unconsumed bytes in the record.
2094
- uint16_t length;
2095
- // data is a non-owning pointer to the first unconsumed byte of the record.
2096
- uint8_t *data;
2097
- };
2098
-
2099
- struct SSL3_BUFFER {
2100
- // buf is the memory allocated for this buffer.
2101
- uint8_t *buf;
2102
- // offset is the offset into |buf| which the buffer contents start at.
2103
- uint16_t offset;
2104
- // len is the length of the buffer contents from |buf| + |offset|.
2105
- uint16_t len;
2106
- // cap is how much memory beyond |buf| + |offset| is available.
2107
- uint16_t cap;
2182
+ bool ed25519_enabled:1;
2108
2183
  };
2109
2184
 
2110
2185
  // An ssl_shutdown_t describes the shutdown state of one end of the connection,
@@ -2112,53 +2187,69 @@ struct SSL3_BUFFER {
2112
2187
  enum ssl_shutdown_t {
2113
2188
  ssl_shutdown_none = 0,
2114
2189
  ssl_shutdown_close_notify = 1,
2115
- ssl_shutdown_fatal_alert = 2,
2190
+ ssl_shutdown_error = 2,
2116
2191
  };
2117
2192
 
2118
2193
  struct SSL3_STATE {
2119
- uint8_t read_sequence[8];
2120
- uint8_t write_sequence[8];
2194
+ static constexpr bool kAllowUniquePtr = true;
2195
+
2196
+ SSL3_STATE();
2197
+ ~SSL3_STATE();
2121
2198
 
2122
- uint8_t server_random[SSL3_RANDOM_SIZE];
2123
- uint8_t client_random[SSL3_RANDOM_SIZE];
2199
+ uint8_t read_sequence[8] = {0};
2200
+ uint8_t write_sequence[8] = {0};
2201
+
2202
+ uint8_t server_random[SSL3_RANDOM_SIZE] = {0};
2203
+ uint8_t client_random[SSL3_RANDOM_SIZE] = {0};
2124
2204
 
2125
2205
  // read_buffer holds data from the transport to be processed.
2126
- SSL3_BUFFER read_buffer;
2206
+ SSLBuffer read_buffer;
2127
2207
  // write_buffer holds data to be written to the transport.
2128
- SSL3_BUFFER write_buffer;
2208
+ SSLBuffer write_buffer;
2129
2209
 
2130
- SSL3_RECORD rrec; // each decoded record goes in here
2210
+ // pending_app_data is the unconsumed application data. It points into
2211
+ // |read_buffer|.
2212
+ Span<uint8_t> pending_app_data;
2131
2213
 
2132
2214
  // partial write - check the numbers match
2133
- unsigned int wnum; // number of bytes sent so far
2134
- int wpend_tot; // number bytes written
2135
- int wpend_type;
2136
- int wpend_ret; // number of bytes submitted
2137
- const uint8_t *wpend_buf;
2215
+ unsigned int wnum = 0; // number of bytes sent so far
2216
+ int wpend_tot = 0; // number bytes written
2217
+ int wpend_type = 0;
2218
+ int wpend_ret = 0; // number of bytes submitted
2219
+ const uint8_t *wpend_buf = nullptr;
2138
2220
 
2139
2221
  // read_shutdown is the shutdown state for the read half of the connection.
2140
- enum ssl_shutdown_t read_shutdown;
2222
+ enum ssl_shutdown_t read_shutdown = ssl_shutdown_none;
2141
2223
 
2142
2224
  // write_shutdown is the shutdown state for the write half of the connection.
2143
- enum ssl_shutdown_t write_shutdown;
2225
+ enum ssl_shutdown_t write_shutdown = ssl_shutdown_none;
2226
+
2227
+ // read_error, if |read_shutdown| is |ssl_shutdown_error|, is the error for
2228
+ // the receive half of the connection.
2229
+ UniquePtr<ERR_SAVE_STATE> read_error;
2230
+
2231
+ int alert_dispatch = 0;
2144
2232
 
2145
- int alert_dispatch;
2233
+ int total_renegotiations = 0;
2146
2234
 
2147
- int total_renegotiations;
2235
+ // This holds a variable that indicates what we were doing when a 0 or -1 is
2236
+ // returned. This is needed for non-blocking IO so we know what request
2237
+ // needs re-doing when in SSL_accept or SSL_connect
2238
+ int rwstate = SSL_NOTHING;
2148
2239
 
2149
2240
  // early_data_skipped is the amount of early data that has been skipped by the
2150
2241
  // record layer.
2151
- uint16_t early_data_skipped;
2242
+ uint16_t early_data_skipped = 0;
2152
2243
 
2153
2244
  // empty_record_count is the number of consecutive empty records received.
2154
- uint8_t empty_record_count;
2245
+ uint8_t empty_record_count = 0;
2155
2246
 
2156
2247
  // warning_alert_count is the number of consecutive warning alerts
2157
2248
  // received.
2158
- uint8_t warning_alert_count;
2249
+ uint8_t warning_alert_count = 0;
2159
2250
 
2160
2251
  // key_update_count is the number of consecutive KeyUpdates received.
2161
- uint8_t key_update_count;
2252
+ uint8_t key_update_count = 0;
2162
2253
 
2163
2254
  // skip_early_data instructs the record layer to skip unexpected early data
2164
2255
  // messages when 0RTT is rejected.
@@ -2202,56 +2293,49 @@ struct SSL3_STATE {
2202
2293
  // wpend_pending is true if we have a pending write outstanding.
2203
2294
  bool wpend_pending:1;
2204
2295
 
2205
- uint8_t send_alert[2];
2296
+ uint8_t send_alert[2] = {0};
2297
+
2298
+ // hs_buf is the buffer of handshake data to process.
2299
+ UniquePtr<BUF_MEM> hs_buf;
2206
2300
 
2207
2301
  // pending_flight is the pending outgoing flight. This is used to flush each
2208
2302
  // handshake flight in a single write. |write_buffer| must be written out
2209
2303
  // before this data.
2210
- BUF_MEM *pending_flight;
2304
+ UniquePtr<BUF_MEM> pending_flight;
2211
2305
 
2212
2306
  // pending_flight_offset is the number of bytes of |pending_flight| which have
2213
2307
  // been successfully written.
2214
- uint32_t pending_flight_offset;
2308
+ uint32_t pending_flight_offset = 0;
2215
2309
 
2216
2310
  // aead_read_ctx is the current read cipher state.
2217
- SSLAEADContext *aead_read_ctx;
2311
+ UniquePtr<SSLAEADContext> aead_read_ctx;
2218
2312
 
2219
2313
  // aead_write_ctx is the current write cipher state.
2220
- SSLAEADContext *aead_write_ctx;
2314
+ UniquePtr<SSLAEADContext> aead_write_ctx;
2221
2315
 
2222
2316
  // hs is the handshake state for the current handshake or NULL if there isn't
2223
2317
  // one.
2224
- SSL_HANDSHAKE *hs;
2318
+ UniquePtr<SSL_HANDSHAKE> hs;
2225
2319
 
2226
- uint8_t write_traffic_secret[EVP_MAX_MD_SIZE];
2227
- uint8_t read_traffic_secret[EVP_MAX_MD_SIZE];
2228
- uint8_t exporter_secret[EVP_MAX_MD_SIZE];
2229
- uint8_t early_exporter_secret[EVP_MAX_MD_SIZE];
2230
- uint8_t write_traffic_secret_len;
2231
- uint8_t read_traffic_secret_len;
2232
- uint8_t exporter_secret_len;
2233
- uint8_t early_exporter_secret_len;
2320
+ uint8_t write_traffic_secret[EVP_MAX_MD_SIZE] = {0};
2321
+ uint8_t read_traffic_secret[EVP_MAX_MD_SIZE] = {0};
2322
+ uint8_t exporter_secret[EVP_MAX_MD_SIZE] = {0};
2323
+ uint8_t early_exporter_secret[EVP_MAX_MD_SIZE] = {0};
2324
+ uint8_t write_traffic_secret_len = 0;
2325
+ uint8_t read_traffic_secret_len = 0;
2326
+ uint8_t exporter_secret_len = 0;
2327
+ uint8_t early_exporter_secret_len = 0;
2234
2328
 
2235
2329
  // Connection binding to prevent renegotiation attacks
2236
- uint8_t previous_client_finished[12];
2237
- uint8_t previous_client_finished_len;
2238
- uint8_t previous_server_finished_len;
2239
- uint8_t previous_server_finished[12];
2240
-
2241
- // State pertaining to the pending handshake.
2242
- //
2243
- // TODO(davidben): Move everything not needed after the handshake completes to
2244
- // |hs| and remove this.
2245
- struct {
2246
- uint8_t new_mac_secret_len;
2247
- uint8_t new_key_len;
2248
- uint8_t new_fixed_iv_len;
2249
- } tmp;
2330
+ uint8_t previous_client_finished[12] = {0};
2331
+ uint8_t previous_client_finished_len = 0;
2332
+ uint8_t previous_server_finished_len = 0;
2333
+ uint8_t previous_server_finished[12] = {0};
2250
2334
 
2251
2335
  // established_session is the session established by the connection. This
2252
2336
  // session is only filled upon the completion of the handshake and is
2253
2337
  // immutable.
2254
- SSL_SESSION *established_session;
2338
+ UniquePtr<SSL_SESSION> established_session;
2255
2339
 
2256
2340
  // Next protocol negotiation. For the client, this is the protocol that we
2257
2341
  // sent in NextProtocol and is set when handling ServerHello extensions.
@@ -2259,8 +2343,7 @@ struct SSL3_STATE {
2259
2343
  // For a server, this is the client's selected_protocol from NextProtocol and
2260
2344
  // is set when handling the NextProtocol message, before the Finished
2261
2345
  // message.
2262
- uint8_t *next_proto_negotiated;
2263
- size_t next_proto_negotiated_len;
2346
+ Array<uint8_t> next_proto_negotiated;
2264
2347
 
2265
2348
  // ALPN information
2266
2349
  // (we are in the process of transitioning from NPN to ALPN.)
@@ -2268,22 +2351,21 @@ struct SSL3_STATE {
2268
2351
  // In a server these point to the selected ALPN protocol after the
2269
2352
  // ClientHello has been processed. In a client these contain the protocol
2270
2353
  // that the server selected once the ServerHello has been processed.
2271
- uint8_t *alpn_selected;
2272
- size_t alpn_selected_len;
2354
+ Array<uint8_t> alpn_selected;
2273
2355
 
2274
2356
  // hostname, on the server, is the value of the SNI extension.
2275
- char *hostname;
2357
+ UniquePtr<char> hostname;
2276
2358
 
2277
2359
  // For a server:
2278
2360
  // If |tlsext_channel_id_valid| is true, then this contains the
2279
2361
  // verified Channel ID from the client: a P256 point, (x,y), where
2280
2362
  // each are big-endian values.
2281
- uint8_t tlsext_channel_id[64];
2363
+ uint8_t tlsext_channel_id[64] = {0};
2282
2364
 
2283
2365
  // ticket_age_skew is the difference, in seconds, between the client-sent
2284
2366
  // ticket age and the server-computed value in TLS 1.3 server connections
2285
2367
  // which resumed a session.
2286
- int32_t ticket_age_skew;
2368
+ int32_t ticket_age_skew = 0;
2287
2369
  };
2288
2370
 
2289
2371
  // lengths of messages
@@ -2307,18 +2389,26 @@ struct hm_header_st {
2307
2389
 
2308
2390
  // An hm_fragment is an incoming DTLS message, possibly not yet assembled.
2309
2391
  struct hm_fragment {
2392
+ static constexpr bool kAllowUniquePtr = true;
2393
+
2394
+ hm_fragment() {}
2395
+ hm_fragment(const hm_fragment &) = delete;
2396
+ hm_fragment &operator=(const hm_fragment &) = delete;
2397
+
2398
+ ~hm_fragment();
2399
+
2310
2400
  // type is the type of the message.
2311
- uint8_t type;
2401
+ uint8_t type = 0;
2312
2402
  // seq is the sequence number of this message.
2313
- uint16_t seq;
2403
+ uint16_t seq = 0;
2314
2404
  // msg_len is the length of the message body.
2315
- uint32_t msg_len;
2405
+ uint32_t msg_len = 0;
2316
2406
  // data is a pointer to the message, including message header. It has length
2317
2407
  // |DTLS1_HM_HEADER_LENGTH| + |msg_len|.
2318
- uint8_t *data;
2408
+ uint8_t *data = nullptr;
2319
2409
  // reassembly is a bitmask of |msg_len| bits corresponding to which parts of
2320
2410
  // the message have been received. It is NULL if the message is complete.
2321
- uint8_t *reassembly;
2411
+ uint8_t *reassembly = nullptr;
2322
2412
  };
2323
2413
 
2324
2414
  struct OPENSSL_timeval {
@@ -2327,6 +2417,11 @@ struct OPENSSL_timeval {
2327
2417
  };
2328
2418
 
2329
2419
  struct DTLS1_STATE {
2420
+ static constexpr bool kAllowUniquePtr = true;
2421
+
2422
+ DTLS1_STATE();
2423
+ ~DTLS1_STATE();
2424
+
2330
2425
  // has_change_cipher_spec is true if we have received a ChangeCipherSpec from
2331
2426
  // the peer in this epoch.
2332
2427
  bool has_change_cipher_spec:1;
@@ -2341,54 +2436,54 @@ struct DTLS1_STATE {
2341
2436
  // peer sent the final flight.
2342
2437
  bool flight_has_reply:1;
2343
2438
 
2344
- uint8_t cookie[DTLS1_COOKIE_LENGTH];
2345
- size_t cookie_len;
2439
+ uint8_t cookie[DTLS1_COOKIE_LENGTH] = {0};
2440
+ size_t cookie_len = 0;
2346
2441
 
2347
2442
  // The current data and handshake epoch. This is initially undefined, and
2348
2443
  // starts at zero once the initial handshake is completed.
2349
- uint16_t r_epoch;
2350
- uint16_t w_epoch;
2444
+ uint16_t r_epoch = 0;
2445
+ uint16_t w_epoch = 0;
2351
2446
 
2352
2447
  // records being received in the current epoch
2353
2448
  DTLS1_BITMAP bitmap;
2354
2449
 
2355
- uint16_t handshake_write_seq;
2356
- uint16_t handshake_read_seq;
2450
+ uint16_t handshake_write_seq = 0;
2451
+ uint16_t handshake_read_seq = 0;
2357
2452
 
2358
2453
  // save last sequence number for retransmissions
2359
- uint8_t last_write_sequence[8];
2360
- SSLAEADContext *last_aead_write_ctx;
2454
+ uint8_t last_write_sequence[8] = {0};
2455
+ UniquePtr<SSLAEADContext> last_aead_write_ctx;
2361
2456
 
2362
2457
  // incoming_messages is a ring buffer of incoming handshake messages that have
2363
2458
  // yet to be processed. The front of the ring buffer is message number
2364
2459
  // |handshake_read_seq|, at position |handshake_read_seq| %
2365
2460
  // |SSL_MAX_HANDSHAKE_FLIGHT|.
2366
- hm_fragment *incoming_messages[SSL_MAX_HANDSHAKE_FLIGHT];
2461
+ UniquePtr<hm_fragment> incoming_messages[SSL_MAX_HANDSHAKE_FLIGHT];
2367
2462
 
2368
2463
  // outgoing_messages is the queue of outgoing messages from the last handshake
2369
2464
  // flight.
2370
2465
  DTLS_OUTGOING_MESSAGE outgoing_messages[SSL_MAX_HANDSHAKE_FLIGHT];
2371
- uint8_t outgoing_messages_len;
2466
+ uint8_t outgoing_messages_len = 0;
2372
2467
 
2373
2468
  // outgoing_written is the number of outgoing messages that have been
2374
2469
  // written.
2375
- uint8_t outgoing_written;
2470
+ uint8_t outgoing_written = 0;
2376
2471
  // outgoing_offset is the number of bytes of the next outgoing message have
2377
2472
  // been written.
2378
- uint32_t outgoing_offset;
2473
+ uint32_t outgoing_offset = 0;
2379
2474
 
2380
- unsigned int mtu; // max DTLS packet size
2475
+ unsigned mtu = 0; // max DTLS packet size
2381
2476
 
2382
2477
  // num_timeouts is the number of times the retransmit timer has fired since
2383
2478
  // the last time it was reset.
2384
- unsigned int num_timeouts;
2479
+ unsigned num_timeouts = 0;
2385
2480
 
2386
2481
  // Indicates when the last handshake msg or heartbeat sent will
2387
2482
  // timeout.
2388
- struct OPENSSL_timeval next_timeout;
2483
+ struct OPENSSL_timeval next_timeout = {0, 0};
2389
2484
 
2390
2485
  // timeout_duration_ms is the timeout duration in milliseconds.
2391
- unsigned timeout_duration_ms;
2486
+ unsigned timeout_duration_ms = 0;
2392
2487
  };
2393
2488
 
2394
2489
  // SSLConnection backs the public |SSL| type. Due to compatibility constraints,
@@ -2428,8 +2523,6 @@ struct SSLConnection {
2428
2523
  // progress.
2429
2524
  enum ssl_hs_wait_t (*do_handshake)(SSL_HANDSHAKE *hs);
2430
2525
 
2431
- BUF_MEM *init_buf; // buffer used during init
2432
-
2433
2526
  SSL3_STATE *s3; // SSLv3 variables
2434
2527
  DTLS1_STATE *d1; // DTLSv1 variables
2435
2528
 
@@ -2449,11 +2542,6 @@ struct SSLConnection {
2449
2542
  // This is used to hold the server certificate used
2450
2543
  CERT *cert;
2451
2544
 
2452
- // This holds a variable that indicates what we were doing when a 0 or -1 is
2453
- // returned. This is needed for non-blocking IO so we know what request
2454
- // needs re-doing when in SSL_accept or SSL_connect
2455
- int rwstate;
2456
-
2457
2545
  // initial_timeout_duration_ms is the default DTLS timeout duration in
2458
2546
  // milliseconds. It's used to initialize the timer any time it's restarted.
2459
2547
  unsigned initial_timeout_duration_ms;
@@ -2529,35 +2617,34 @@ struct SSLConnection {
2529
2617
  // server is true iff the this SSL* is the server half. Note: before the SSL*
2530
2618
  // is initialized by either SSL_set_accept_state or SSL_set_connect_state,
2531
2619
  // the side is not determined. In this state, server is always false.
2532
- unsigned server:1;
2620
+ bool server:1;
2533
2621
 
2534
2622
  // quiet_shutdown is true if the connection should not send a close_notify on
2535
2623
  // shutdown.
2536
- unsigned quiet_shutdown:1;
2624
+ bool quiet_shutdown:1;
2537
2625
 
2538
2626
  // Enable signed certificate time stamps. Currently client only.
2539
- unsigned signed_cert_timestamps_enabled:1;
2627
+ bool signed_cert_timestamps_enabled:1;
2540
2628
 
2541
2629
  // ocsp_stapling_enabled is only used by client connections and indicates
2542
2630
  // whether OCSP stapling will be requested.
2543
- unsigned ocsp_stapling_enabled:1;
2631
+ bool ocsp_stapling_enabled:1;
2544
2632
 
2545
2633
  // tlsext_channel_id_enabled is copied from the |SSL_CTX|. For a server,
2546
2634
  // means that we'll accept Channel IDs from clients. For a client, means that
2547
2635
  // we'll advertise support.
2548
- unsigned tlsext_channel_id_enabled:1;
2636
+ bool tlsext_channel_id_enabled:1;
2549
2637
 
2550
2638
  // retain_only_sha256_of_client_certs is true if we should compute the SHA256
2551
2639
  // hash of the peer's certificate and then discard it to save memory and
2552
2640
  // session space. Only effective on the server side.
2553
- unsigned retain_only_sha256_of_client_certs:1;
2641
+ bool retain_only_sha256_of_client_certs:1;
2554
2642
 
2555
2643
  // early_data_accepted is true if early data was accepted by the server.
2556
- unsigned early_data_accepted:1;
2644
+ bool early_data_accepted:1;
2557
2645
  };
2558
2646
 
2559
2647
  // From draft-ietf-tls-tls13-18, used in determining PSK modes.
2560
- #define SSL_PSK_KE 0x0
2561
2648
  #define SSL_PSK_DHE_KE 0x1
2562
2649
 
2563
2650
  // From draft-ietf-tls-tls13-16, used in determining whether to respond with a
@@ -2664,57 +2751,53 @@ const struct ssl_cipher_preference_list_st *ssl_get_cipher_preferences(
2664
2751
 
2665
2752
  void ssl_update_cache(SSL_HANDSHAKE *hs, int mode);
2666
2753
 
2667
- enum ssl_hs_wait_t ssl_get_finished(SSL_HANDSHAKE *hs);
2668
- int ssl3_send_alert(SSL *ssl, int level, int desc);
2754
+ int ssl_send_alert(SSL *ssl, int level, int desc);
2669
2755
  bool ssl3_get_message(SSL *ssl, SSLMessage *out);
2670
- int ssl3_read_message(SSL *ssl);
2756
+ ssl_open_record_t ssl3_open_handshake(SSL *ssl, size_t *out_consumed,
2757
+ uint8_t *out_alert, Span<uint8_t> in);
2671
2758
  void ssl3_next_message(SSL *ssl);
2672
2759
 
2673
- int ssl3_send_finished(SSL_HANDSHAKE *hs);
2674
2760
  int ssl3_dispatch_alert(SSL *ssl);
2675
- int ssl3_read_app_data(SSL *ssl, bool *out_got_handshake, uint8_t *buf, int len,
2676
- int peek);
2677
- int ssl3_read_change_cipher_spec(SSL *ssl);
2678
- void ssl3_read_close_notify(SSL *ssl);
2679
- int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len);
2761
+ ssl_open_record_t ssl3_open_app_data(SSL *ssl, Span<uint8_t> *out,
2762
+ size_t *out_consumed, uint8_t *out_alert,
2763
+ Span<uint8_t> in);
2764
+ ssl_open_record_t ssl3_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2765
+ uint8_t *out_alert,
2766
+ Span<uint8_t> in);
2680
2767
  int ssl3_write_app_data(SSL *ssl, bool *out_needs_handshake, const uint8_t *buf,
2681
2768
  int len);
2682
- int ssl3_output_cert_chain(SSL *ssl);
2683
2769
 
2684
- int ssl3_new(SSL *ssl);
2770
+ bool ssl3_new(SSL *ssl);
2685
2771
  void ssl3_free(SSL *ssl);
2686
2772
 
2687
- int ssl3_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2688
- int ssl3_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2689
- int ssl3_add_message(SSL *ssl, Array<uint8_t> msg);
2690
- int ssl3_add_change_cipher_spec(SSL *ssl);
2691
- int ssl3_add_alert(SSL *ssl, uint8_t level, uint8_t desc);
2773
+ bool ssl3_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2774
+ bool ssl3_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2775
+ bool ssl3_add_message(SSL *ssl, Array<uint8_t> msg);
2776
+ bool ssl3_add_change_cipher_spec(SSL *ssl);
2777
+ bool ssl3_add_alert(SSL *ssl, uint8_t level, uint8_t desc);
2692
2778
  int ssl3_flush_flight(SSL *ssl);
2693
2779
 
2694
- int dtls1_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2695
- int dtls1_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2696
- int dtls1_add_message(SSL *ssl, Array<uint8_t> msg);
2697
- int dtls1_add_change_cipher_spec(SSL *ssl);
2698
- int dtls1_add_alert(SSL *ssl, uint8_t level, uint8_t desc);
2780
+ bool dtls1_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
2781
+ bool dtls1_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg);
2782
+ bool dtls1_add_message(SSL *ssl, Array<uint8_t> msg);
2783
+ bool dtls1_add_change_cipher_spec(SSL *ssl);
2784
+ bool dtls1_add_alert(SSL *ssl, uint8_t level, uint8_t desc);
2699
2785
  int dtls1_flush_flight(SSL *ssl);
2700
2786
 
2701
2787
  // ssl_add_message_cbb finishes the handshake message in |cbb| and adds it to
2702
- // the pending flight. It returns one on success and zero on error.
2703
- int ssl_add_message_cbb(SSL *ssl, CBB *cbb);
2788
+ // the pending flight. It returns true on success and false on error.
2789
+ bool ssl_add_message_cbb(SSL *ssl, CBB *cbb);
2704
2790
 
2705
- // ssl_hash_message incorporates |msg| into the handshake hash. It returns one
2706
- // on success and zero on allocation failure.
2791
+ // ssl_hash_message incorporates |msg| into the handshake hash. It returns true
2792
+ // on success and false on allocation failure.
2707
2793
  bool ssl_hash_message(SSL_HANDSHAKE *hs, const SSLMessage &msg);
2708
2794
 
2709
- // dtls1_get_record reads a new input record. On success, it places it in
2710
- // |ssl->s3->rrec| and returns one. Otherwise it returns <= 0 on error or if
2711
- // more data is needed.
2712
- int dtls1_get_record(SSL *ssl);
2713
-
2714
- int dtls1_read_app_data(SSL *ssl, bool *out_got_handshake, uint8_t *buf,
2715
- int len, int peek);
2716
- int dtls1_read_change_cipher_spec(SSL *ssl);
2717
- void dtls1_read_close_notify(SSL *ssl);
2795
+ ssl_open_record_t dtls1_open_app_data(SSL *ssl, Span<uint8_t> *out,
2796
+ size_t *out_consumed, uint8_t *out_alert,
2797
+ Span<uint8_t> in);
2798
+ ssl_open_record_t dtls1_open_change_cipher_spec(SSL *ssl, size_t *out_consumed,
2799
+ uint8_t *out_alert,
2800
+ Span<uint8_t> in);
2718
2801
 
2719
2802
  int dtls1_write_app_data(SSL *ssl, bool *out_needs_handshake,
2720
2803
  const uint8_t *buf, int len);
@@ -2724,32 +2807,28 @@ int dtls1_write_app_data(SSL *ssl, bool *out_needs_handshake,
2724
2807
  int dtls1_write_record(SSL *ssl, int type, const uint8_t *buf, size_t len,
2725
2808
  enum dtls1_use_epoch_t use_epoch);
2726
2809
 
2727
- int dtls1_send_finished(SSL *ssl, int a, int b, const char *sender, int slen);
2728
2810
  int dtls1_retransmit_outgoing_messages(SSL *ssl);
2729
- void dtls1_clear_record_buffer(SSL *ssl);
2730
- int dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
2811
+ bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
2731
2812
  CBS *out_body);
2732
- int dtls1_check_timeout_num(SSL *ssl);
2733
- int dtls1_handshake_write(SSL *ssl);
2813
+ bool dtls1_check_timeout_num(SSL *ssl);
2734
2814
 
2735
2815
  void dtls1_start_timer(SSL *ssl);
2736
2816
  void dtls1_stop_timer(SSL *ssl);
2737
- int dtls1_is_timer_expired(SSL *ssl);
2817
+ bool dtls1_is_timer_expired(SSL *ssl);
2738
2818
  unsigned int dtls1_min_mtu(void);
2739
2819
 
2740
- int dtls1_new(SSL *ssl);
2741
- int dtls1_accept(SSL *ssl);
2742
- int dtls1_connect(SSL *ssl);
2820
+ bool dtls1_new(SSL *ssl);
2743
2821
  void dtls1_free(SSL *ssl);
2744
2822
 
2745
2823
  bool dtls1_get_message(SSL *ssl, SSLMessage *out);
2746
- int dtls1_read_message(SSL *ssl);
2824
+ ssl_open_record_t dtls1_open_handshake(SSL *ssl, size_t *out_consumed,
2825
+ uint8_t *out_alert, Span<uint8_t> in);
2747
2826
  void dtls1_next_message(SSL *ssl);
2748
2827
  int dtls1_dispatch_alert(SSL *ssl);
2749
2828
 
2750
2829
  int tls1_change_cipher_state(SSL_HANDSHAKE *hs, evp_aead_direction_t direction);
2751
2830
  int tls1_generate_master_secret(SSL_HANDSHAKE *hs, uint8_t *out,
2752
- const uint8_t *premaster, size_t premaster_len);
2831
+ Span<const uint8_t> premaster);
2753
2832
 
2754
2833
  // tls1_get_grouplist returns the locally-configured group preference list.
2755
2834
  Span<const uint16_t> tls1_get_grouplist(const SSL *ssl);
@@ -2811,8 +2890,8 @@ int tls1_verify_channel_id(SSL_HANDSHAKE *hs, const SSLMessage &msg);
2811
2890
 
2812
2891
  // tls1_write_channel_id generates a Channel ID message and puts the output in
2813
2892
  // |cbb|. |ssl->tlsext_channel_id_private| must already be set before calling.
2814
- // This function returns one on success and zero on error.
2815
- int tls1_write_channel_id(SSL_HANDSHAKE *hs, CBB *cbb);
2893
+ // This function returns true on success and false on error.
2894
+ bool tls1_write_channel_id(SSL_HANDSHAKE *hs, CBB *cbb);
2816
2895
 
2817
2896
  // tls1_channel_id_hash computes the hash to be signed by Channel ID and writes
2818
2897
  // it to |out|, which must contain at least |EVP_MAX_MD_SIZE| bytes. It returns
@@ -2827,10 +2906,6 @@ int tls1_record_handshake_hashes_for_channel_id(SSL_HANDSHAKE *hs);
2827
2906
  // operation should be retried later.
2828
2907
  int ssl_do_channel_id_callback(SSL *ssl);
2829
2908
 
2830
- // ssl3_can_false_start returns one if |ssl| is allowed to False Start and zero
2831
- // otherwise.
2832
- int ssl3_can_false_start(const SSL *ssl);
2833
-
2834
2909
  // ssl_can_write returns one if |ssl| is allowed to write and zero otherwise.
2835
2910
  int ssl_can_write(const SSL *ssl);
2836
2911
 
@@ -2844,6 +2919,10 @@ void ssl_ctx_get_current_time(const SSL_CTX *ctx,
2844
2919
  // ssl_reset_error_state resets state for |SSL_get_error|.
2845
2920
  void ssl_reset_error_state(SSL *ssl);
2846
2921
 
2922
+ // ssl_set_read_error sets |ssl|'s read half into an error state, saving the
2923
+ // current state of the error queue.
2924
+ void ssl_set_read_error(SSL* ssl);
2925
+
2847
2926
  } // namespace bssl
2848
2927
 
2849
2928