grpc 1.24.0 → 1.25.0.pre1

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 (504) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +306 -243
  3. data/etc/roots.pem +0 -100
  4. data/include/grpc/grpc_security.h +44 -18
  5. data/include/grpc/impl/codegen/grpc_types.h +15 -0
  6. data/include/grpc/impl/codegen/port_platform.h +27 -11
  7. data/include/grpc/impl/codegen/sync_generic.h +1 -1
  8. data/src/boringssl/err_data.c +695 -650
  9. data/src/core/ext/filters/client_channel/client_channel.cc +257 -179
  10. data/src/core/ext/filters/client_channel/client_channel.h +24 -0
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
  12. data/src/core/ext/filters/client_channel/client_channel_factory.h +1 -5
  13. data/src/core/ext/filters/client_channel/health/health_check_client.cc +18 -45
  14. data/src/core/ext/filters/client_channel/health/health_check_client.h +5 -13
  15. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  16. data/src/core/ext/filters/client_channel/lb_policy.cc +2 -3
  17. data/src/core/ext/filters/client_channel/lb_policy.h +65 -55
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -14
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +113 -36
  20. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +14 -19
  21. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +36 -13
  22. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +3 -10
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +814 -1589
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +2 -5
  25. data/src/core/ext/filters/client_channel/lb_policy_factory.h +3 -6
  26. data/src/core/ext/filters/client_channel/resolver.cc +1 -2
  27. data/src/core/ext/filters/client_channel/resolver.h +8 -16
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +25 -8
  29. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +46 -12
  30. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +10 -17
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +7 -8
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -4
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +111 -44
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +22 -14
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
  37. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +29 -10
  38. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +27 -36
  39. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +7 -10
  40. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +60 -16
  41. data/src/core/ext/filters/client_channel/resolver_factory.h +4 -8
  42. data/src/core/ext/filters/client_channel/resolver_registry.cc +1 -1
  43. data/src/core/ext/filters/client_channel/resolver_registry.h +1 -1
  44. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -10
  45. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +7 -8
  46. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -1
  47. data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -5
  48. data/src/core/ext/filters/client_channel/retry_throttle.h +1 -4
  49. data/src/core/ext/filters/client_channel/service_config.h +8 -8
  50. data/src/core/ext/filters/client_channel/subchannel.cc +53 -86
  51. data/src/core/ext/filters/client_channel/subchannel.h +7 -9
  52. data/src/core/ext/filters/client_channel/subchannel_interface.h +9 -13
  53. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +3 -6
  54. data/src/core/ext/filters/client_channel/{lb_policy/xds/xds_load_balancer_api.cc → xds/xds_api.cc} +169 -52
  55. data/src/core/ext/filters/client_channel/xds/xds_api.h +171 -0
  56. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +450 -0
  57. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +99 -0
  58. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel.h +8 -6
  59. data/src/core/ext/filters/client_channel/xds/xds_channel_args.h +26 -0
  60. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel_secure.cc +28 -11
  61. data/src/core/ext/filters/client_channel/xds/xds_client.cc +1413 -0
  62. data/src/core/ext/filters/client_channel/xds/xds_client.h +221 -0
  63. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.cc +1 -5
  64. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.h +3 -4
  65. data/src/core/ext/filters/deadline/deadline_filter.cc +20 -20
  66. data/src/core/ext/filters/http/client/http_client_filter.cc +15 -15
  67. data/src/core/ext/filters/http/client_authority_filter.cc +14 -14
  68. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +12 -12
  69. data/src/core/ext/filters/max_age/max_age_filter.cc +59 -50
  70. data/src/core/ext/filters/message_size/message_size_filter.cc +18 -18
  71. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -14
  72. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +233 -175
  73. data/src/core/ext/transport/chttp2/transport/flow_control.h +21 -24
  74. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +253 -163
  75. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +24 -12
  76. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -3
  77. data/src/core/ext/transport/chttp2/transport/internal.h +13 -15
  78. data/src/core/ext/transport/chttp2/transport/writing.cc +3 -0
  79. data/src/core/ext/transport/inproc/inproc_transport.cc +20 -13
  80. data/src/core/lib/channel/channel_args.cc +16 -0
  81. data/src/core/lib/channel/channel_args.h +22 -0
  82. data/src/core/lib/channel/channelz.cc +5 -6
  83. data/src/core/lib/channel/channelz.h +1 -1
  84. data/src/core/lib/channel/connected_channel.cc +20 -20
  85. data/src/core/lib/channel/handshaker.h +3 -4
  86. data/src/core/lib/channel/handshaker_factory.h +1 -3
  87. data/src/core/lib/debug/trace.h +3 -2
  88. data/src/core/lib/gprpp/arena.cc +3 -3
  89. data/src/core/lib/gprpp/arena.h +2 -3
  90. data/src/core/lib/gprpp/inlined_vector.h +9 -0
  91. data/src/core/lib/gprpp/map.h +3 -501
  92. data/src/core/lib/gprpp/memory.h +45 -41
  93. data/src/core/lib/gprpp/mpscq.cc +108 -0
  94. data/src/core/lib/gprpp/mpscq.h +98 -0
  95. data/src/core/lib/gprpp/orphanable.h +6 -11
  96. data/src/core/lib/gprpp/ref_counted.h +25 -19
  97. data/src/core/lib/gprpp/set.h +33 -0
  98. data/src/core/lib/gprpp/thd.h +2 -4
  99. data/src/core/lib/http/httpcli.cc +1 -1
  100. data/src/core/lib/http/httpcli_security_connector.cc +15 -11
  101. data/src/core/lib/http/parser.cc +1 -1
  102. data/src/core/lib/iomgr/buffer_list.cc +4 -5
  103. data/src/core/lib/iomgr/buffer_list.h +5 -6
  104. data/src/core/lib/iomgr/call_combiner.cc +4 -5
  105. data/src/core/lib/iomgr/call_combiner.h +2 -2
  106. data/src/core/lib/iomgr/cfstream_handle.h +3 -5
  107. data/src/core/lib/iomgr/closure.h +8 -3
  108. data/src/core/lib/iomgr/combiner.cc +45 -82
  109. data/src/core/lib/iomgr/combiner.h +32 -8
  110. data/src/core/lib/iomgr/endpoint_cfstream.cc +5 -3
  111. data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -15
  112. data/src/core/lib/iomgr/exec_ctx.h +4 -3
  113. data/src/core/lib/iomgr/executor.cc +4 -2
  114. data/src/core/lib/iomgr/executor.h +3 -0
  115. data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -6
  116. data/src/core/lib/iomgr/executor/threadpool.cc +1 -2
  117. data/src/core/lib/iomgr/executor/threadpool.h +7 -11
  118. data/src/core/lib/iomgr/resource_quota.cc +55 -51
  119. data/src/core/lib/iomgr/resource_quota.h +13 -9
  120. data/src/core/lib/iomgr/socket_utils_common_posix.cc +13 -0
  121. data/src/core/lib/iomgr/socket_utils_posix.h +4 -0
  122. data/src/core/lib/iomgr/tcp_client_posix.cc +4 -11
  123. data/src/core/lib/iomgr/tcp_custom.cc +9 -7
  124. data/src/core/lib/iomgr/tcp_posix.cc +20 -16
  125. data/src/core/lib/iomgr/tcp_server.h +1 -4
  126. data/src/core/lib/iomgr/tcp_server_custom.cc +5 -5
  127. data/src/core/lib/iomgr/tcp_server_posix.cc +1 -1
  128. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -11
  129. data/src/core/lib/iomgr/timer_custom.cc +2 -2
  130. data/src/core/lib/iomgr/udp_server.cc +3 -2
  131. data/src/core/lib/iomgr/udp_server.h +6 -12
  132. data/src/core/lib/json/json.h +1 -1
  133. data/src/core/lib/json/json_string.cc +2 -2
  134. data/src/core/lib/profiling/basic_timers.cc +2 -2
  135. data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -2
  136. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +1 -1
  137. data/src/core/lib/security/credentials/credentials.h +4 -20
  138. data/src/core/lib/security/credentials/fake/fake_credentials.cc +4 -4
  139. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -3
  140. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +64 -0
  141. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +4 -4
  142. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +9 -7
  143. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -0
  144. data/src/core/lib/security/security_connector/local/local_security_connector.cc +4 -4
  145. data/src/core/lib/security/security_connector/security_connector.cc +1 -0
  146. data/src/core/lib/security/security_connector/security_connector.h +19 -17
  147. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +8 -5
  148. data/src/core/lib/security/security_connector/ssl_utils.cc +2 -2
  149. data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
  150. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -6
  151. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -2
  152. data/src/core/lib/security/transport/client_auth_filter.cc +17 -17
  153. data/src/core/lib/security/transport/security_handshaker.cc +29 -13
  154. data/src/core/lib/security/transport/security_handshaker.h +4 -2
  155. data/src/core/lib/security/transport/server_auth_filter.cc +14 -14
  156. data/src/core/lib/slice/slice.cc +2 -10
  157. data/src/core/lib/slice/slice_hash_table.h +4 -6
  158. data/src/core/lib/slice/slice_intern.cc +42 -39
  159. data/src/core/lib/slice/slice_internal.h +3 -3
  160. data/src/core/lib/slice/slice_utils.h +21 -4
  161. data/src/core/lib/slice/slice_weak_hash_table.h +4 -6
  162. data/src/core/lib/surface/call.cc +3 -3
  163. data/src/core/lib/surface/channel.cc +7 -0
  164. data/src/core/lib/surface/completion_queue.cc +12 -11
  165. data/src/core/lib/surface/completion_queue.h +4 -2
  166. data/src/core/lib/surface/init.cc +1 -0
  167. data/src/core/lib/surface/lame_client.cc +33 -18
  168. data/src/core/lib/surface/server.cc +77 -76
  169. data/src/core/lib/surface/version.cc +1 -1
  170. data/src/core/lib/transport/byte_stream.h +3 -7
  171. data/src/core/lib/transport/connectivity_state.cc +112 -98
  172. data/src/core/lib/transport/connectivity_state.h +100 -50
  173. data/src/core/lib/transport/static_metadata.cc +276 -288
  174. data/src/core/lib/transport/static_metadata.h +73 -76
  175. data/src/core/lib/transport/status_conversion.cc +1 -1
  176. data/src/core/lib/transport/status_metadata.cc +1 -1
  177. data/src/core/lib/transport/transport.cc +2 -2
  178. data/src/core/lib/transport/transport.h +12 -4
  179. data/src/core/lib/transport/transport_op_string.cc +14 -11
  180. data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +1 -1
  181. data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +1 -1
  182. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +5 -5
  183. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -2
  184. data/src/core/tsi/fake_transport_security.cc +7 -5
  185. data/src/core/tsi/grpc_shadow_boringssl.h +2918 -2627
  186. data/src/core/tsi/local_transport_security.cc +8 -6
  187. data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -3
  188. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -2
  189. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +7 -5
  190. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -6
  191. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -2
  192. data/src/core/tsi/ssl_transport_security.cc +12 -12
  193. data/src/core/tsi/ssl_transport_security.h +2 -2
  194. data/src/core/tsi/transport_security_grpc.cc +7 -0
  195. data/src/core/tsi/transport_security_grpc.h +6 -0
  196. data/src/ruby/ext/grpc/extconf.rb +1 -0
  197. data/src/ruby/ext/grpc/rb_call.c +1 -1
  198. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  199. data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
  200. data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
  201. data/src/ruby/lib/grpc/version.rb +1 -1
  202. data/src/ruby/spec/google_rpc_status_utils_spec.rb +2 -2
  203. data/third_party/boringssl/crypto/asn1/a_bool.c +18 -5
  204. data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +17 -221
  205. data/third_party/boringssl/crypto/asn1/a_dup.c +0 -24
  206. data/third_party/boringssl/crypto/asn1/a_enum.c +2 -2
  207. data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +10 -72
  208. data/third_party/boringssl/crypto/asn1/a_int.c +12 -71
  209. data/third_party/boringssl/crypto/asn1/a_mbstr.c +110 -216
  210. data/third_party/boringssl/crypto/asn1/a_object.c +16 -5
  211. data/third_party/boringssl/crypto/asn1/a_strnid.c +1 -0
  212. data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -1
  213. data/third_party/boringssl/crypto/asn1/tasn_enc.c +3 -1
  214. data/third_party/boringssl/crypto/base64/base64.c +2 -2
  215. data/third_party/boringssl/crypto/bio/bio.c +73 -9
  216. data/third_party/boringssl/crypto/bio/connect.c +4 -0
  217. data/third_party/boringssl/crypto/bio/fd.c +4 -0
  218. data/third_party/boringssl/crypto/bio/file.c +5 -2
  219. data/third_party/boringssl/crypto/bio/socket.c +4 -0
  220. data/third_party/boringssl/crypto/bio/socket_helper.c +4 -0
  221. data/third_party/boringssl/crypto/bn_extra/convert.c +11 -7
  222. data/third_party/boringssl/crypto/bytestring/ber.c +8 -4
  223. data/third_party/boringssl/crypto/bytestring/cbb.c +19 -7
  224. data/third_party/boringssl/crypto/bytestring/cbs.c +28 -15
  225. data/third_party/boringssl/crypto/bytestring/internal.h +28 -7
  226. data/third_party/boringssl/crypto/bytestring/unicode.c +155 -0
  227. data/third_party/boringssl/crypto/chacha/chacha.c +36 -19
  228. data/third_party/boringssl/crypto/chacha/internal.h +45 -0
  229. data/third_party/boringssl/crypto/cipher_extra/cipher_extra.c +29 -0
  230. data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +269 -25
  231. data/third_party/boringssl/crypto/cipher_extra/e_aesctrhmac.c +16 -14
  232. data/third_party/boringssl/crypto/cipher_extra/e_aesgcmsiv.c +54 -38
  233. data/third_party/boringssl/crypto/cipher_extra/e_chacha20poly1305.c +133 -41
  234. data/third_party/boringssl/crypto/cipher_extra/e_tls.c +23 -15
  235. data/third_party/boringssl/crypto/cipher_extra/tls_cbc.c +24 -15
  236. data/third_party/boringssl/crypto/cmac/cmac.c +62 -25
  237. data/third_party/boringssl/crypto/conf/conf.c +7 -0
  238. data/third_party/boringssl/crypto/cpu-arm-linux.c +4 -148
  239. data/third_party/boringssl/crypto/cpu-arm-linux.h +201 -0
  240. data/third_party/boringssl/crypto/cpu-intel.c +45 -51
  241. data/third_party/boringssl/crypto/crypto.c +39 -22
  242. data/third_party/boringssl/crypto/curve25519/spake25519.c +1 -1
  243. data/third_party/boringssl/crypto/dsa/dsa.c +77 -53
  244. data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +20 -8
  245. data/third_party/boringssl/crypto/ec_extra/ec_derive.c +96 -0
  246. data/third_party/boringssl/crypto/{ecdh/ecdh.c → ecdh_extra/ecdh_extra.c} +20 -58
  247. data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -9
  248. data/third_party/boringssl/crypto/engine/engine.c +2 -1
  249. data/third_party/boringssl/crypto/err/err.c +2 -0
  250. data/third_party/boringssl/crypto/err/internal.h +2 -2
  251. data/third_party/boringssl/crypto/evp/evp.c +89 -8
  252. data/third_party/boringssl/crypto/evp/evp_asn1.c +56 -5
  253. data/third_party/boringssl/crypto/evp/evp_ctx.c +52 -14
  254. data/third_party/boringssl/crypto/evp/internal.h +18 -1
  255. data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +5 -0
  256. data/third_party/boringssl/crypto/evp/p_ec.c +51 -3
  257. data/third_party/boringssl/crypto/evp/p_ec_asn1.c +6 -7
  258. data/third_party/boringssl/crypto/evp/p_ed25519.c +36 -3
  259. data/third_party/boringssl/crypto/evp/p_ed25519_asn1.c +76 -45
  260. data/third_party/boringssl/crypto/evp/p_rsa.c +3 -1
  261. data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +5 -0
  262. data/third_party/boringssl/crypto/evp/p_x25519.c +110 -0
  263. data/third_party/boringssl/crypto/evp/p_x25519_asn1.c +249 -0
  264. data/third_party/boringssl/crypto/evp/scrypt.c +6 -2
  265. data/third_party/boringssl/crypto/fipsmodule/aes/aes.c +34 -274
  266. data/third_party/boringssl/crypto/fipsmodule/aes/internal.h +161 -21
  267. data/third_party/boringssl/crypto/fipsmodule/aes/key_wrap.c +111 -13
  268. data/third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.c +17 -21
  269. data/third_party/boringssl/crypto/fipsmodule/bcm.c +119 -7
  270. data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +19 -2
  271. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +2 -2
  272. data/third_party/boringssl/crypto/fipsmodule/bn/ctx.c +93 -160
  273. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +48 -57
  274. data/third_party/boringssl/crypto/fipsmodule/bn/div_extra.c +87 -0
  275. data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +143 -211
  276. data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +0 -305
  277. data/third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.c +325 -0
  278. data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +168 -50
  279. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +68 -92
  280. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +7 -6
  281. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +11 -14
  282. data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +358 -443
  283. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +25 -35
  284. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +20 -25
  285. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +76 -5
  286. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +14 -14
  287. data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +7 -2
  288. data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +383 -516
  289. data/third_party/boringssl/crypto/fipsmodule/cipher/e_des.c +4 -0
  290. data/third_party/boringssl/crypto/fipsmodule/cipher/internal.h +3 -4
  291. data/third_party/boringssl/crypto/fipsmodule/delocate.h +3 -2
  292. data/third_party/boringssl/crypto/fipsmodule/digest/digest.c +32 -17
  293. data/third_party/boringssl/crypto/fipsmodule/digest/md32_common.h +3 -3
  294. data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +228 -122
  295. data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +34 -8
  296. data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +311 -98
  297. data/third_party/boringssl/crypto/fipsmodule/ec/felem.c +82 -0
  298. data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +263 -97
  299. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +22 -59
  300. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +317 -234
  301. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +9473 -9475
  302. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +313 -109
  303. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h +36 -0
  304. data/third_party/boringssl/crypto/fipsmodule/ec/scalar.c +96 -0
  305. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +126 -792
  306. data/third_party/boringssl/crypto/fipsmodule/ec/simple_mul.c +84 -0
  307. data/third_party/boringssl/crypto/fipsmodule/ec/util.c +163 -12
  308. data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +84 -211
  309. data/third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.c +122 -0
  310. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +60 -205
  311. data/third_party/boringssl/crypto/fipsmodule/fips_shared_support.c +32 -0
  312. data/third_party/boringssl/crypto/fipsmodule/is_fips.c +2 -0
  313. data/third_party/boringssl/crypto/fipsmodule/md4/md4.c +3 -1
  314. data/third_party/boringssl/crypto/fipsmodule/md5/internal.h +37 -0
  315. data/third_party/boringssl/crypto/fipsmodule/md5/md5.c +11 -8
  316. data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +35 -79
  317. data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +7 -39
  318. data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +7 -27
  319. data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +123 -309
  320. data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +189 -126
  321. data/third_party/boringssl/crypto/fipsmodule/modes/ofb.c +3 -2
  322. data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +2 -2
  323. data/third_party/boringssl/crypto/fipsmodule/rand/internal.h +35 -0
  324. data/third_party/boringssl/crypto/fipsmodule/rand/rand.c +24 -19
  325. data/third_party/boringssl/crypto/fipsmodule/rand/urandom.c +256 -77
  326. data/third_party/boringssl/crypto/fipsmodule/rsa/padding.c +10 -7
  327. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +5 -1
  328. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +131 -14
  329. data/third_party/boringssl/crypto/fipsmodule/self_check/self_check.c +83 -10
  330. data/third_party/boringssl/crypto/fipsmodule/sha/internal.h +53 -0
  331. data/third_party/boringssl/crypto/fipsmodule/sha/sha1.c +9 -13
  332. data/third_party/boringssl/crypto/fipsmodule/sha/sha256.c +18 -12
  333. data/third_party/boringssl/crypto/fipsmodule/sha/sha512.c +95 -168
  334. data/third_party/boringssl/crypto/hrss/hrss.c +2201 -0
  335. data/third_party/boringssl/crypto/hrss/internal.h +62 -0
  336. data/third_party/boringssl/crypto/internal.h +95 -20
  337. data/third_party/boringssl/crypto/lhash/lhash.c +45 -33
  338. data/third_party/boringssl/crypto/mem.c +39 -2
  339. data/third_party/boringssl/crypto/obj/obj.c +4 -4
  340. data/third_party/boringssl/crypto/obj/obj_dat.h +6181 -875
  341. data/third_party/boringssl/crypto/pem/pem_all.c +2 -3
  342. data/third_party/boringssl/crypto/pem/pem_info.c +144 -162
  343. data/third_party/boringssl/crypto/pem/pem_lib.c +53 -52
  344. data/third_party/boringssl/crypto/pem/pem_pkey.c +13 -21
  345. data/third_party/boringssl/crypto/pkcs7/pkcs7.c +15 -22
  346. data/third_party/boringssl/crypto/pkcs7/pkcs7_x509.c +168 -16
  347. data/third_party/boringssl/crypto/pkcs8/internal.h +11 -0
  348. data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +24 -15
  349. data/third_party/boringssl/crypto/pkcs8/pkcs8.c +42 -25
  350. data/third_party/boringssl/crypto/pkcs8/pkcs8_x509.c +559 -43
  351. data/third_party/boringssl/crypto/pool/internal.h +1 -1
  352. data/third_party/boringssl/crypto/pool/pool.c +21 -0
  353. data/third_party/boringssl/crypto/rand_extra/deterministic.c +8 -0
  354. data/third_party/boringssl/crypto/rand_extra/fuchsia.c +1 -14
  355. data/third_party/boringssl/crypto/refcount_lock.c +2 -2
  356. data/third_party/boringssl/crypto/rsa_extra/rsa_print.c +22 -0
  357. data/third_party/boringssl/crypto/siphash/siphash.c +80 -0
  358. data/third_party/boringssl/crypto/stack/stack.c +83 -32
  359. data/third_party/boringssl/crypto/thread_none.c +2 -2
  360. data/third_party/boringssl/crypto/thread_pthread.c +2 -2
  361. data/third_party/boringssl/crypto/thread_win.c +38 -19
  362. data/third_party/boringssl/crypto/x509/a_strex.c +22 -2
  363. data/third_party/boringssl/crypto/x509/asn1_gen.c +2 -1
  364. data/third_party/boringssl/crypto/x509/by_dir.c +7 -0
  365. data/third_party/boringssl/crypto/x509/by_file.c +12 -10
  366. data/third_party/boringssl/crypto/x509/t_crl.c +5 -8
  367. data/third_party/boringssl/crypto/x509/t_req.c +1 -3
  368. data/third_party/boringssl/crypto/x509/t_x509.c +5 -8
  369. data/third_party/boringssl/crypto/x509/x509_cmp.c +1 -1
  370. data/third_party/boringssl/crypto/x509/x509_def.c +1 -1
  371. data/third_party/boringssl/crypto/x509/x509_lu.c +114 -5
  372. data/third_party/boringssl/crypto/x509/x509_req.c +20 -0
  373. data/third_party/boringssl/crypto/x509/x509_set.c +5 -0
  374. data/third_party/boringssl/crypto/x509/x509_trs.c +1 -0
  375. data/third_party/boringssl/crypto/x509/x509_txt.c +4 -5
  376. data/third_party/boringssl/crypto/x509/x509_vfy.c +145 -138
  377. data/third_party/boringssl/crypto/x509/x509_vpm.c +2 -0
  378. data/third_party/boringssl/crypto/x509/x509cset.c +40 -0
  379. data/third_party/boringssl/crypto/x509/x509name.c +2 -3
  380. data/third_party/boringssl/crypto/x509/x_all.c +109 -210
  381. data/third_party/boringssl/crypto/x509/x_x509.c +6 -0
  382. data/third_party/boringssl/crypto/x509v3/ext_dat.h +1 -3
  383. data/third_party/boringssl/crypto/x509v3/internal.h +56 -0
  384. data/third_party/boringssl/crypto/x509v3/pcy_cache.c +2 -0
  385. data/third_party/boringssl/crypto/x509v3/pcy_node.c +1 -0
  386. data/third_party/boringssl/crypto/x509v3/pcy_tree.c +4 -2
  387. data/third_party/boringssl/crypto/x509v3/v3_akey.c +5 -2
  388. data/third_party/boringssl/crypto/x509v3/v3_alt.c +19 -13
  389. data/third_party/boringssl/crypto/x509v3/v3_conf.c +2 -1
  390. data/third_party/boringssl/crypto/x509v3/v3_cpols.c +3 -2
  391. data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -6
  392. data/third_party/boringssl/crypto/x509v3/v3_lib.c +1 -0
  393. data/third_party/boringssl/crypto/x509v3/v3_ocsp.c +68 -0
  394. data/third_party/boringssl/crypto/x509v3/v3_pci.c +2 -1
  395. data/third_party/boringssl/crypto/x509v3/v3_purp.c +47 -69
  396. data/third_party/boringssl/crypto/x509v3/v3_skey.c +5 -2
  397. data/third_party/boringssl/crypto/x509v3/v3_utl.c +69 -25
  398. data/third_party/boringssl/include/openssl/aead.h +45 -19
  399. data/third_party/boringssl/include/openssl/aes.h +32 -7
  400. data/third_party/boringssl/include/openssl/asn1.h +7 -77
  401. data/third_party/boringssl/include/openssl/base.h +120 -6
  402. data/third_party/boringssl/include/openssl/base64.h +4 -1
  403. data/third_party/boringssl/include/openssl/bio.h +112 -81
  404. data/third_party/boringssl/include/openssl/blowfish.h +3 -3
  405. data/third_party/boringssl/include/openssl/bn.h +55 -29
  406. data/third_party/boringssl/include/openssl/buf.h +2 -2
  407. data/third_party/boringssl/include/openssl/bytestring.h +54 -32
  408. data/third_party/boringssl/include/openssl/cast.h +2 -2
  409. data/third_party/boringssl/include/openssl/cipher.h +46 -16
  410. data/third_party/boringssl/include/openssl/cmac.h +6 -2
  411. data/third_party/boringssl/include/openssl/conf.h +3 -6
  412. data/third_party/boringssl/include/openssl/cpu.h +25 -9
  413. data/third_party/boringssl/include/openssl/crypto.h +32 -10
  414. data/third_party/boringssl/include/openssl/curve25519.h +4 -4
  415. data/third_party/boringssl/include/openssl/dh.h +3 -2
  416. data/third_party/boringssl/include/openssl/digest.h +21 -7
  417. data/third_party/boringssl/include/openssl/dsa.h +8 -2
  418. data/third_party/boringssl/include/openssl/e_os2.h +18 -0
  419. data/third_party/boringssl/include/openssl/ec.h +25 -21
  420. data/third_party/boringssl/include/openssl/ec_key.h +36 -8
  421. data/third_party/boringssl/include/openssl/ecdh.h +17 -0
  422. data/third_party/boringssl/include/openssl/ecdsa.h +3 -3
  423. data/third_party/boringssl/include/openssl/engine.h +4 -4
  424. data/third_party/boringssl/include/openssl/err.h +3 -0
  425. data/third_party/boringssl/include/openssl/evp.h +199 -42
  426. data/third_party/boringssl/include/openssl/hmac.h +4 -4
  427. data/third_party/boringssl/include/openssl/hrss.h +100 -0
  428. data/third_party/boringssl/include/openssl/lhash.h +131 -23
  429. data/third_party/boringssl/include/openssl/md4.h +6 -4
  430. data/third_party/boringssl/include/openssl/md5.h +6 -4
  431. data/third_party/boringssl/include/openssl/mem.h +6 -2
  432. data/third_party/boringssl/include/openssl/nid.h +3 -0
  433. data/third_party/boringssl/include/openssl/obj.h +3 -0
  434. data/third_party/boringssl/include/openssl/pem.h +102 -64
  435. data/third_party/boringssl/include/openssl/pkcs7.h +136 -3
  436. data/third_party/boringssl/include/openssl/pkcs8.h +42 -3
  437. data/third_party/boringssl/include/openssl/pool.h +13 -2
  438. data/third_party/boringssl/include/openssl/ripemd.h +5 -4
  439. data/third_party/boringssl/include/openssl/rsa.h +46 -15
  440. data/third_party/boringssl/include/openssl/sha.h +40 -28
  441. data/third_party/boringssl/include/openssl/siphash.h +37 -0
  442. data/third_party/boringssl/include/openssl/span.h +17 -9
  443. data/third_party/boringssl/include/openssl/ssl.h +766 -393
  444. data/third_party/boringssl/include/openssl/ssl3.h +4 -3
  445. data/third_party/boringssl/include/openssl/stack.h +134 -77
  446. data/third_party/boringssl/include/openssl/thread.h +1 -1
  447. data/third_party/boringssl/include/openssl/tls1.h +25 -9
  448. data/third_party/boringssl/include/openssl/type_check.h +14 -15
  449. data/third_party/boringssl/include/openssl/x509.h +28 -3
  450. data/third_party/boringssl/include/openssl/x509_vfy.h +98 -32
  451. data/third_party/boringssl/include/openssl/x509v3.h +17 -13
  452. data/third_party/boringssl/ssl/d1_both.cc +9 -18
  453. data/third_party/boringssl/ssl/d1_lib.cc +4 -3
  454. data/third_party/boringssl/ssl/d1_pkt.cc +4 -4
  455. data/third_party/boringssl/ssl/d1_srtp.cc +15 -15
  456. data/third_party/boringssl/ssl/dtls_method.cc +0 -1
  457. data/third_party/boringssl/ssl/dtls_record.cc +28 -28
  458. data/third_party/boringssl/ssl/handoff.cc +295 -91
  459. data/third_party/boringssl/ssl/handshake.cc +133 -72
  460. data/third_party/boringssl/ssl/handshake_client.cc +218 -189
  461. data/third_party/boringssl/ssl/handshake_server.cc +399 -272
  462. data/third_party/boringssl/ssl/internal.h +1413 -928
  463. data/third_party/boringssl/ssl/s3_both.cc +175 -36
  464. data/third_party/boringssl/ssl/s3_lib.cc +9 -13
  465. data/third_party/boringssl/ssl/s3_pkt.cc +63 -29
  466. data/third_party/boringssl/ssl/ssl_aead_ctx.cc +55 -35
  467. data/third_party/boringssl/ssl/ssl_asn1.cc +57 -73
  468. data/third_party/boringssl/ssl/ssl_buffer.cc +13 -12
  469. data/third_party/boringssl/ssl/ssl_cert.cc +313 -210
  470. data/third_party/boringssl/ssl/ssl_cipher.cc +159 -221
  471. data/third_party/boringssl/ssl/ssl_file.cc +2 -0
  472. data/third_party/boringssl/ssl/ssl_key_share.cc +164 -19
  473. data/third_party/boringssl/ssl/ssl_lib.cc +847 -555
  474. data/third_party/boringssl/ssl/ssl_privkey.cc +441 -111
  475. data/third_party/boringssl/ssl/ssl_session.cc +230 -178
  476. data/third_party/boringssl/ssl/ssl_transcript.cc +21 -142
  477. data/third_party/boringssl/ssl/ssl_versions.cc +88 -93
  478. data/third_party/boringssl/ssl/ssl_x509.cc +279 -218
  479. data/third_party/boringssl/ssl/t1_enc.cc +5 -96
  480. data/third_party/boringssl/ssl/t1_lib.cc +931 -678
  481. data/third_party/boringssl/ssl/tls13_both.cc +251 -121
  482. data/third_party/boringssl/ssl/tls13_client.cc +129 -73
  483. data/third_party/boringssl/ssl/tls13_enc.cc +350 -282
  484. data/third_party/boringssl/ssl/tls13_server.cc +259 -192
  485. data/third_party/boringssl/ssl/tls_method.cc +26 -21
  486. data/third_party/boringssl/ssl/tls_record.cc +42 -47
  487. data/third_party/boringssl/third_party/fiat/curve25519.c +261 -1324
  488. data/third_party/boringssl/third_party/fiat/curve25519_32.h +911 -0
  489. data/third_party/boringssl/third_party/fiat/curve25519_64.h +559 -0
  490. data/third_party/boringssl/third_party/fiat/p256.c +238 -999
  491. data/third_party/boringssl/third_party/fiat/p256_32.h +3226 -0
  492. data/third_party/boringssl/third_party/fiat/p256_64.h +1217 -0
  493. data/third_party/upb/upb/port_def.inc +1 -1
  494. data/third_party/upb/upb/table.c +2 -1
  495. metadata +71 -43
  496. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +0 -127
  497. data/src/core/lib/gpr/mpscq.cc +0 -117
  498. data/src/core/lib/gpr/mpscq.h +0 -88
  499. data/src/core/lib/gprpp/abstract.h +0 -47
  500. data/src/core/lib/gprpp/pair.h +0 -38
  501. data/third_party/boringssl/crypto/cipher_extra/e_ssl3.c +0 -460
  502. data/third_party/boringssl/crypto/fipsmodule/modes/ccm.c +0 -256
  503. data/third_party/boringssl/include/openssl/lhash_macros.h +0 -174
  504. data/third_party/boringssl/ssl/custom_extensions.cc +0 -265
@@ -68,7 +68,7 @@
68
68
  #include "internal.h"
69
69
 
70
70
 
71
- namespace bssl {
71
+ BSSL_NAMESPACE_BEGIN
72
72
 
73
73
  // DTLS1_MTU_TIMEOUTS is the maximum number of timeouts to expire
74
74
  // before starting to decrease the MTU.
@@ -171,7 +171,8 @@ bool dtls1_check_timeout_num(SSL *ssl) {
171
171
  // Reduce MTU after 2 unsuccessful retransmissions
172
172
  if (ssl->d1->num_timeouts > DTLS1_MTU_TIMEOUTS &&
173
173
  !(SSL_get_options(ssl) & SSL_OP_NO_QUERY_MTU)) {
174
- long mtu = BIO_ctrl(ssl->wbio, BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL);
174
+ long mtu =
175
+ BIO_ctrl(ssl->wbio.get(), BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, nullptr);
175
176
  if (mtu >= 0 && mtu <= (1 << 30) && (unsigned)mtu >= dtls1_min_mtu()) {
176
177
  ssl->d1->mtu = (unsigned)mtu;
177
178
  }
@@ -186,7 +187,7 @@ bool dtls1_check_timeout_num(SSL *ssl) {
186
187
  return true;
187
188
  }
188
189
 
189
- } // namespace bssl
190
+ BSSL_NAMESPACE_END
190
191
 
191
192
  using namespace bssl;
192
193
 
@@ -126,7 +126,7 @@
126
126
  #include "internal.h"
127
127
 
128
128
 
129
- namespace bssl {
129
+ BSSL_NAMESPACE_BEGIN
130
130
 
131
131
  ssl_open_record_t dtls1_open_app_data(SSL *ssl, Span<uint8_t> *out,
132
132
  size_t *out_consumed, uint8_t *out_alert,
@@ -256,11 +256,11 @@ int dtls1_dispatch_alert(SSL *ssl) {
256
256
  if (ret <= 0) {
257
257
  return ret;
258
258
  }
259
- ssl->s3->alert_dispatch = 0;
259
+ ssl->s3->alert_dispatch = false;
260
260
 
261
261
  // If the alert is fatal, flush the BIO now.
262
262
  if (ssl->s3->send_alert[0] == SSL3_AL_FATAL) {
263
- BIO_flush(ssl->wbio);
263
+ BIO_flush(ssl->wbio.get());
264
264
  }
265
265
 
266
266
  ssl_do_msg_callback(ssl, 1 /* write */, SSL3_RT_ALERT, ssl->s3->send_alert);
@@ -271,4 +271,4 @@ int dtls1_dispatch_alert(SSL *ssl) {
271
271
  return 1;
272
272
  }
273
273
 
274
- } // namespace bssl
274
+ BSSL_NAMESPACE_END
@@ -158,8 +158,9 @@ static int find_profile_by_name(const char *profile_name,
158
158
  return 0;
159
159
  }
160
160
 
161
- static int ssl_ctx_make_profiles(const char *profiles_string,
162
- STACK_OF(SRTP_PROTECTION_PROFILE) **out) {
161
+ static int ssl_ctx_make_profiles(
162
+ const char *profiles_string,
163
+ UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> *out) {
163
164
  UniquePtr<STACK_OF(SRTP_PROTECTION_PROFILE)> profiles(
164
165
  sk_SRTP_PROTECTION_PROFILE_new_null());
165
166
  if (profiles == nullptr) {
@@ -188,8 +189,7 @@ static int ssl_ctx_make_profiles(const char *profiles_string,
188
189
  }
189
190
  } while (col);
190
191
 
191
- sk_SRTP_PROTECTION_PROFILE_free(*out);
192
- *out = profiles.release();
192
+ *out = std::move(profiles);
193
193
  return 1;
194
194
  }
195
195
 
@@ -198,27 +198,27 @@ int SSL_CTX_set_srtp_profiles(SSL_CTX *ctx, const char *profiles) {
198
198
  }
199
199
 
200
200
  int SSL_set_srtp_profiles(SSL *ssl, const char *profiles) {
201
- return ssl_ctx_make_profiles(profiles, &ssl->srtp_profiles);
201
+ return ssl->config != nullptr &&
202
+ ssl_ctx_make_profiles(profiles, &ssl->config->srtp_profiles);
202
203
  }
203
204
 
204
205
  STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl) {
205
- if (ssl == NULL) {
206
- return NULL;
206
+ if (ssl == nullptr) {
207
+ return nullptr;
207
208
  }
208
209
 
209
- if (ssl->srtp_profiles != NULL) {
210
- return ssl->srtp_profiles;
210
+ if (ssl->config == nullptr) {
211
+ assert(0);
212
+ return nullptr;
211
213
  }
212
214
 
213
- if (ssl->ctx->srtp_profiles != NULL) {
214
- return ssl->ctx->srtp_profiles;
215
- }
216
-
217
- return NULL;
215
+ return ssl->config->srtp_profiles != nullptr
216
+ ? ssl->config->srtp_profiles.get()
217
+ : ssl->ctx->srtp_profiles.get();
218
218
  }
219
219
 
220
220
  const SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *ssl) {
221
- return ssl->srtp_profile;
221
+ return ssl->s3->srtp_profile;
222
222
  }
223
223
 
224
224
  int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles) {
@@ -121,7 +121,6 @@ static const SSL_PROTOCOL_METHOD kDTLSProtocolMethod = {
121
121
  dtls1_finish_message,
122
122
  dtls1_add_message,
123
123
  dtls1_add_change_cipher_spec,
124
- dtls1_add_alert,
125
124
  dtls1_flush_flight,
126
125
  dtls1_on_handshake_complete,
127
126
  dtls1_set_read_state,
@@ -121,7 +121,7 @@
121
121
  #include "../crypto/internal.h"
122
122
 
123
123
 
124
- namespace bssl {
124
+ BSSL_NAMESPACE_BEGIN
125
125
 
126
126
  // to_u64_be treats |in| as a 8-byte big-endian integer and returns the value as
127
127
  // a |uint64_t|.
@@ -137,13 +137,13 @@ static uint64_t to_u64_be(const uint8_t in[8]) {
137
137
 
138
138
  // dtls1_bitmap_should_discard returns one if |seq_num| has been seen in
139
139
  // |bitmap| or is stale. Otherwise it returns zero.
140
- static int dtls1_bitmap_should_discard(DTLS1_BITMAP *bitmap,
141
- const uint8_t seq_num[8]) {
140
+ static bool dtls1_bitmap_should_discard(DTLS1_BITMAP *bitmap,
141
+ const uint8_t seq_num[8]) {
142
142
  const unsigned kWindowSize = sizeof(bitmap->map) * 8;
143
143
 
144
144
  uint64_t seq_num_u = to_u64_be(seq_num);
145
145
  if (seq_num_u > bitmap->max_seq_num) {
146
- return 0;
146
+ return false;
147
147
  }
148
148
  uint64_t idx = bitmap->max_seq_num - seq_num_u;
149
149
  return idx >= kWindowSize || (bitmap->map & (((uint64_t)1) << idx));
@@ -219,8 +219,8 @@ enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
219
219
  return ssl_open_record_discard;
220
220
  }
221
221
 
222
- ssl_do_msg_callback(ssl, 0 /* read */, SSL3_RT_HEADER,
223
- in.subspan(0, DTLS1_RT_HEADER_LENGTH));
222
+ Span<const uint8_t> header = in.subspan(0, DTLS1_RT_HEADER_LENGTH);
223
+ ssl_do_msg_callback(ssl, 0 /* read */, SSL3_RT_HEADER, header);
224
224
 
225
225
  uint16_t epoch = (((uint16_t)sequence[0]) << 8) | sequence[1];
226
226
  if (epoch != ssl->d1->r_epoch ||
@@ -235,7 +235,7 @@ enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type,
235
235
 
236
236
  // discard the body in-place.
237
237
  if (!ssl->s3->aead_read_ctx->Open(
238
- out, type, version, sequence,
238
+ out, type, version, sequence, header,
239
239
  MakeSpan(const_cast<uint8_t *>(CBS_data(&body)), CBS_len(&body)))) {
240
240
  // Bad packets are silently dropped in DTLS. See section 4.2.1 of RFC 6347.
241
241
  // Clear the error queue of any errors decryption may have added. Drop the
@@ -291,14 +291,14 @@ size_t dtls_seal_prefix_len(const SSL *ssl, enum dtls1_use_epoch_t use_epoch) {
291
291
  get_write_aead(ssl, use_epoch)->ExplicitNonceLen();
292
292
  }
293
293
 
294
- int dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
295
- uint8_t type, const uint8_t *in, size_t in_len,
296
- enum dtls1_use_epoch_t use_epoch) {
294
+ bool dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
295
+ uint8_t type, const uint8_t *in, size_t in_len,
296
+ enum dtls1_use_epoch_t use_epoch) {
297
297
  const size_t prefix = dtls_seal_prefix_len(ssl, use_epoch);
298
298
  if (buffers_alias(in, in_len, out, max_out) &&
299
299
  (max_out < prefix || out + prefix != in)) {
300
300
  OPENSSL_PUT_ERROR(SSL, SSL_R_OUTPUT_ALIASES_INPUT);
301
- return 0;
301
+ return false;
302
302
  }
303
303
 
304
304
  // Determine the parameters for the current epoch.
@@ -314,7 +314,7 @@ int dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
314
314
 
315
315
  if (max_out < DTLS1_RT_HEADER_LENGTH) {
316
316
  OPENSSL_PUT_ERROR(SSL, SSL_R_BUFFER_TOO_SMALL);
317
- return 0;
317
+ return false;
318
318
  }
319
319
 
320
320
  out[0] = type;
@@ -328,26 +328,26 @@ int dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
328
328
  OPENSSL_memcpy(&out[5], &seq[2], 6);
329
329
 
330
330
  size_t ciphertext_len;
331
- if (!aead->Seal(out + DTLS1_RT_HEADER_LENGTH, &ciphertext_len,
332
- max_out - DTLS1_RT_HEADER_LENGTH, type, record_version,
333
- &out[3] /* seq */, in, in_len) ||
334
- !ssl_record_sequence_update(&seq[2], 6)) {
335
- return 0;
336
- }
337
-
338
- if (ciphertext_len >= 1 << 16) {
339
- OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
340
- return 0;
331
+ if (!aead->CiphertextLen(&ciphertext_len, in_len, 0)) {
332
+ OPENSSL_PUT_ERROR(SSL, SSL_R_RECORD_TOO_LARGE);
333
+ return false;
341
334
  }
342
335
  out[11] = ciphertext_len >> 8;
343
336
  out[12] = ciphertext_len & 0xff;
337
+ Span<const uint8_t> header = MakeConstSpan(out, DTLS1_RT_HEADER_LENGTH);
344
338
 
345
- *out_len = DTLS1_RT_HEADER_LENGTH + ciphertext_len;
346
-
347
- ssl_do_msg_callback(ssl, 1 /* write */, SSL3_RT_HEADER,
348
- MakeSpan(out, DTLS1_RT_HEADER_LENGTH));
339
+ size_t len_copy;
340
+ if (!aead->Seal(out + DTLS1_RT_HEADER_LENGTH, &len_copy,
341
+ max_out - DTLS1_RT_HEADER_LENGTH, type, record_version,
342
+ &out[3] /* seq */, header, in, in_len) ||
343
+ !ssl_record_sequence_update(&seq[2], 6)) {
344
+ return false;
345
+ }
346
+ assert(ciphertext_len == len_copy);
349
347
 
350
- return 1;
348
+ *out_len = DTLS1_RT_HEADER_LENGTH + ciphertext_len;
349
+ ssl_do_msg_callback(ssl, 1 /* write */, SSL3_RT_HEADER, header);
350
+ return true;
351
351
  }
352
352
 
353
- } // namespace bssl
353
+ BSSL_NAMESPACE_END
@@ -19,20 +19,47 @@
19
19
  #include "internal.h"
20
20
 
21
21
 
22
- namespace bssl {
22
+ BSSL_NAMESPACE_BEGIN
23
23
 
24
24
  constexpr int kHandoffVersion = 0;
25
25
  constexpr int kHandbackVersion = 0;
26
26
 
27
- bool SSL_serialize_handoff(const SSL *ssl, CBB *out) {
27
+ // serialize_features adds a description of features supported by this binary to
28
+ // |out|. Returns true on success and false on error.
29
+ static bool serialize_features(CBB *out) {
30
+ CBB ciphers;
31
+ if (!CBB_add_asn1(out, &ciphers, CBS_ASN1_OCTETSTRING)) {
32
+ return false;
33
+ }
34
+ Span<const SSL_CIPHER> all_ciphers = AllCiphers();
35
+ for (const SSL_CIPHER& cipher : all_ciphers) {
36
+ if (!CBB_add_u16(&ciphers, static_cast<uint16_t>(cipher.id))) {
37
+ return false;
38
+ }
39
+ }
40
+ CBB curves;
41
+ if (!CBB_add_asn1(out, &curves, CBS_ASN1_OCTETSTRING)) {
42
+ return false;
43
+ }
44
+ for (const NamedGroup& g : NamedGroups()) {
45
+ if (!CBB_add_u16(&curves, g.group_id)) {
46
+ return false;
47
+ }
48
+ }
49
+ return CBB_flush(out);
50
+ }
51
+
52
+ bool SSL_serialize_handoff(const SSL *ssl, CBB *out,
53
+ SSL_CLIENT_HELLO *out_hello) {
28
54
  const SSL3_STATE *const s3 = ssl->s3;
29
55
  if (!ssl->server ||
30
56
  s3->hs == nullptr ||
31
- s3->rwstate != SSL_HANDOFF) {
57
+ s3->rwstate != SSL_ERROR_HANDOFF) {
32
58
  return false;
33
59
  }
34
60
 
35
61
  CBB seq;
62
+ SSLMessage msg;
36
63
  Span<const uint8_t> transcript = s3->hs->transcript.buffer();
37
64
  if (!CBB_add_asn1(out, &seq, CBS_ASN1_SEQUENCE) ||
38
65
  !CBB_add_asn1_uint64(&seq, kHandoffVersion) ||
@@ -40,7 +67,10 @@ bool SSL_serialize_handoff(const SSL *ssl, CBB *out) {
40
67
  !CBB_add_asn1_octet_string(&seq,
41
68
  reinterpret_cast<uint8_t *>(s3->hs_buf->data),
42
69
  s3->hs_buf->length) ||
43
- !CBB_flush(out)) {
70
+ !serialize_features(&seq) ||
71
+ !CBB_flush(out) ||
72
+ !ssl->method->get_message(ssl, &msg) ||
73
+ !ssl_client_hello_init(ssl, out_hello, msg)) {
44
74
  return false;
45
75
  }
46
76
 
@@ -51,11 +81,103 @@ bool SSL_decline_handoff(SSL *ssl) {
51
81
  const SSL3_STATE *const s3 = ssl->s3;
52
82
  if (!ssl->server ||
53
83
  s3->hs == nullptr ||
54
- s3->rwstate != SSL_HANDOFF) {
84
+ s3->rwstate != SSL_ERROR_HANDOFF) {
55
85
  return false;
56
86
  }
57
87
 
58
- ssl->handoff = false;
88
+ s3->hs->config->handoff = false;
89
+ return true;
90
+ }
91
+
92
+ // apply_remote_features reads a list of supported features from |in| and
93
+ // (possibly) reconfigures |ssl| to disallow the negotation of features whose
94
+ // support has not been indicated. (This prevents the the handshake from
95
+ // committing to features that are not supported on the handoff/handback side.)
96
+ static bool apply_remote_features(SSL *ssl, CBS *in) {
97
+ CBS ciphers;
98
+ if (!CBS_get_asn1(in, &ciphers, CBS_ASN1_OCTETSTRING)) {
99
+ return false;
100
+ }
101
+ bssl::UniquePtr<STACK_OF(SSL_CIPHER)> supported(sk_SSL_CIPHER_new_null());
102
+ while (CBS_len(&ciphers)) {
103
+ uint16_t id;
104
+ if (!CBS_get_u16(&ciphers, &id)) {
105
+ return false;
106
+ }
107
+ const SSL_CIPHER *cipher = SSL_get_cipher_by_value(id);
108
+ if (!cipher) {
109
+ continue;
110
+ }
111
+ if (!sk_SSL_CIPHER_push(supported.get(), cipher)) {
112
+ return false;
113
+ }
114
+ }
115
+ STACK_OF(SSL_CIPHER) *configured =
116
+ ssl->config->cipher_list ? ssl->config->cipher_list->ciphers.get()
117
+ : ssl->ctx->cipher_list->ciphers.get();
118
+ bssl::UniquePtr<STACK_OF(SSL_CIPHER)> unsupported(sk_SSL_CIPHER_new_null());
119
+ for (const SSL_CIPHER *configured_cipher : configured) {
120
+ if (sk_SSL_CIPHER_find(supported.get(), nullptr, configured_cipher)) {
121
+ continue;
122
+ }
123
+ if (!sk_SSL_CIPHER_push(unsupported.get(), configured_cipher)) {
124
+ return false;
125
+ }
126
+ }
127
+ if (sk_SSL_CIPHER_num(unsupported.get()) && !ssl->config->cipher_list) {
128
+ ssl->config->cipher_list = bssl::MakeUnique<SSLCipherPreferenceList>();
129
+ if (!ssl->config->cipher_list->Init(*ssl->ctx->cipher_list)) {
130
+ return false;
131
+ }
132
+ }
133
+ for (const SSL_CIPHER *unsupported_cipher : unsupported.get()) {
134
+ ssl->config->cipher_list->Remove(unsupported_cipher);
135
+ }
136
+ if (sk_SSL_CIPHER_num(SSL_get_ciphers(ssl)) == 0) {
137
+ return false;
138
+ }
139
+
140
+ CBS curves;
141
+ if (!CBS_get_asn1(in, &curves, CBS_ASN1_OCTETSTRING)) {
142
+ return false;
143
+ }
144
+ Array<uint16_t> supported_curves;
145
+ if (!supported_curves.Init(CBS_len(&curves) / 2)) {
146
+ return false;
147
+ }
148
+ size_t idx = 0;
149
+ while (CBS_len(&curves)) {
150
+ uint16_t curve;
151
+ if (!CBS_get_u16(&curves, &curve)) {
152
+ return false;
153
+ }
154
+ supported_curves[idx++] = curve;
155
+ }
156
+ Span<const uint16_t> configured_curves =
157
+ tls1_get_grouplist(ssl->s3->hs.get());
158
+ Array<uint16_t> new_configured_curves;
159
+ if (!new_configured_curves.Init(configured_curves.size())) {
160
+ return false;
161
+ }
162
+ idx = 0;
163
+ for (uint16_t configured_curve : configured_curves) {
164
+ bool ok = false;
165
+ for (uint16_t supported_curve : supported_curves) {
166
+ if (supported_curve == configured_curve) {
167
+ ok = true;
168
+ break;
169
+ }
170
+ }
171
+ if (ok) {
172
+ new_configured_curves[idx++] = configured_curve;
173
+ }
174
+ }
175
+ if (idx == 0) {
176
+ return false;
177
+ }
178
+ new_configured_curves.Shrink(idx);
179
+ ssl->config->supported_group_list = std::move(new_configured_curves);
180
+
59
181
  return true;
60
182
  }
61
183
 
@@ -74,7 +196,8 @@ bool SSL_apply_handoff(SSL *ssl, Span<const uint8_t> handoff) {
74
196
 
75
197
  CBS transcript, hs_buf;
76
198
  if (!CBS_get_asn1(&seq, &transcript, CBS_ASN1_OCTETSTRING) ||
77
- !CBS_get_asn1(&seq, &hs_buf, CBS_ASN1_OCTETSTRING)) {
199
+ !CBS_get_asn1(&seq, &hs_buf, CBS_ASN1_OCTETSTRING) ||
200
+ !apply_remote_features(ssl, &seq)) {
78
201
  return false;
79
202
  }
80
203
 
@@ -93,19 +216,30 @@ bool SSL_apply_handoff(SSL *ssl, Span<const uint8_t> handoff) {
93
216
  if (CBS_len(&transcript) != 0) {
94
217
  s3->hs->transcript.Update(transcript);
95
218
  s3->is_v2_hello = true;
96
- ssl_do_msg_callback(ssl, 0 /* read */, 0 /* V2ClientHello */, transcript);
97
219
  }
220
+ s3->hs->handback = true;
98
221
 
99
222
  return true;
100
223
  }
101
224
 
102
225
  bool SSL_serialize_handback(const SSL *ssl, CBB *out) {
103
- if (!ssl->server ||
104
- !ssl->s3->initial_handshake_complete ||
105
- ssl->method->is_dtls ||
106
- ssl->version < TLS1_VERSION) {
226
+ if (!ssl->server || ssl->method->is_dtls) {
107
227
  return false;
108
228
  }
229
+ handback_t type;
230
+ switch (ssl->s3->hs->state) {
231
+ case state12_read_change_cipher_spec:
232
+ type = handback_after_session_resumption;
233
+ break;
234
+ case state12_read_client_certificate:
235
+ type = handback_after_ecdhe;
236
+ break;
237
+ case state12_finish_server_handshake:
238
+ type = handback_after_handshake;
239
+ break;
240
+ default:
241
+ return false;
242
+ }
109
243
 
110
244
  const SSL3_STATE *const s3 = ssl->s3;
111
245
  size_t hostname_len = 0;
@@ -113,22 +247,36 @@ bool SSL_serialize_handback(const SSL *ssl, CBB *out) {
113
247
  hostname_len = strlen(s3->hostname.get());
114
248
  }
115
249
 
116
- size_t iv_len = 0;
117
- const uint8_t *read_iv = nullptr, *write_iv = nullptr;
118
- if (ssl->version == TLS1_VERSION &&
119
- SSL_CIPHER_is_block_cipher(s3->aead_read_ctx->cipher()) &&
120
- (!s3->aead_read_ctx->GetIV(&read_iv, &iv_len) ||
121
- !s3->aead_write_ctx->GetIV(&write_iv, &iv_len))) {
250
+ Span<const uint8_t> transcript;
251
+ if (type == handback_after_ecdhe ||
252
+ type == handback_after_session_resumption) {
253
+ transcript = s3->hs->transcript.buffer();
254
+ }
255
+ size_t write_iv_len = 0;
256
+ const uint8_t *write_iv = nullptr;
257
+ if ((type == handback_after_session_resumption ||
258
+ type == handback_after_handshake) &&
259
+ ssl->version == TLS1_VERSION &&
260
+ SSL_CIPHER_is_block_cipher(s3->aead_write_ctx->cipher()) &&
261
+ !s3->aead_write_ctx->GetIV(&write_iv, &write_iv_len)) {
122
262
  return false;
123
263
  }
264
+ size_t read_iv_len = 0;
265
+ const uint8_t *read_iv = nullptr;
266
+ if (type == handback_after_handshake &&
267
+ ssl->version == TLS1_VERSION &&
268
+ SSL_CIPHER_is_block_cipher(s3->aead_read_ctx->cipher()) &&
269
+ !s3->aead_read_ctx->GetIV(&read_iv, &read_iv_len)) {
270
+ return false;
271
+ }
124
272
 
125
- CBB seq;
273
+ // TODO(mab): make sure everything is serialized.
274
+ CBB seq, key_share;
275
+ const SSL_SESSION *session =
276
+ s3->session_reused ? ssl->session.get() : s3->hs->new_session.get();
126
277
  if (!CBB_add_asn1(out, &seq, CBS_ASN1_SEQUENCE) ||
127
278
  !CBB_add_asn1_uint64(&seq, kHandbackVersion) ||
128
- !CBB_add_asn1_uint64(&seq, ssl->version) ||
129
- !CBB_add_asn1_uint64(&seq, ssl->conf_max_version) ||
130
- !CBB_add_asn1_uint64(&seq, ssl->conf_min_version) ||
131
- !CBB_add_asn1_uint64(&seq, ssl->max_send_fragment) ||
279
+ !CBB_add_asn1_uint64(&seq, type) ||
132
280
  !CBB_add_asn1_octet_string(&seq, s3->read_sequence,
133
281
  sizeof(s3->read_sequence)) ||
134
282
  !CBB_add_asn1_octet_string(&seq, s3->write_sequence,
@@ -137,12 +285,11 @@ bool SSL_serialize_handback(const SSL *ssl, CBB *out) {
137
285
  sizeof(s3->server_random)) ||
138
286
  !CBB_add_asn1_octet_string(&seq, s3->client_random,
139
287
  sizeof(s3->client_random)) ||
140
- !CBB_add_asn1_octet_string(&seq, read_iv, iv_len) ||
141
- !CBB_add_asn1_octet_string(&seq, write_iv, iv_len) ||
288
+ !CBB_add_asn1_octet_string(&seq, read_iv, read_iv_len) ||
289
+ !CBB_add_asn1_octet_string(&seq, write_iv, write_iv_len) ||
142
290
  !CBB_add_asn1_bool(&seq, s3->session_reused) ||
143
- !CBB_add_asn1_bool(&seq, s3->send_connection_binding) ||
144
- !CBB_add_asn1_bool(&seq, s3->tlsext_channel_id_valid) ||
145
- !ssl_session_serialize(s3->established_session.get(), &seq) ||
291
+ !CBB_add_asn1_bool(&seq, s3->channel_id_valid) ||
292
+ !ssl_session_serialize(session, &seq) ||
146
293
  !CBB_add_asn1_octet_string(&seq, s3->next_proto_negotiated.data(),
147
294
  s3->next_proto_negotiated.size()) ||
148
295
  !CBB_add_asn1_octet_string(&seq, s3->alpn_selected.data(),
@@ -150,19 +297,24 @@ bool SSL_serialize_handback(const SSL *ssl, CBB *out) {
150
297
  !CBB_add_asn1_octet_string(
151
298
  &seq, reinterpret_cast<uint8_t *>(s3->hostname.get()),
152
299
  hostname_len) ||
153
- !CBB_add_asn1_octet_string(&seq, s3->tlsext_channel_id,
154
- sizeof(s3->tlsext_channel_id)) ||
155
- !CBB_add_asn1_uint64(&seq, ssl->options) ||
156
- !CBB_add_asn1_uint64(&seq, ssl->mode) ||
157
- !CBB_add_asn1_uint64(&seq, ssl->max_cert_list) ||
158
- !CBB_add_asn1_bool(&seq, ssl->quiet_shutdown) ||
159
- !CBB_add_asn1_bool(&seq, ssl->tlsext_channel_id_enabled) ||
160
- !CBB_add_asn1_bool(&seq, ssl->retain_only_sha256_of_client_certs) ||
161
- !CBB_flush(out)) {
300
+ !CBB_add_asn1_octet_string(&seq, s3->channel_id,
301
+ sizeof(s3->channel_id)) ||
302
+ !CBB_add_asn1_bool(&seq, ssl->s3->token_binding_negotiated) ||
303
+ !CBB_add_asn1_uint64(&seq, ssl->s3->negotiated_token_binding_param) ||
304
+ !CBB_add_asn1_bool(&seq, s3->hs->next_proto_neg_seen) ||
305
+ !CBB_add_asn1_bool(&seq, s3->hs->cert_request) ||
306
+ !CBB_add_asn1_bool(&seq, s3->hs->extended_master_secret) ||
307
+ !CBB_add_asn1_bool(&seq, s3->hs->ticket_expected) ||
308
+ !CBB_add_asn1_uint64(&seq, SSL_CIPHER_get_id(s3->hs->new_cipher)) ||
309
+ !CBB_add_asn1_octet_string(&seq, transcript.data(), transcript.size()) ||
310
+ !CBB_add_asn1(&seq, &key_share, CBS_ASN1_SEQUENCE)) {
162
311
  return false;
163
312
  }
164
-
165
- return true;
313
+ if (type == handback_after_ecdhe &&
314
+ !s3->hs->key_shares[0]->Serialize(&key_share)) {
315
+ return false;
316
+ }
317
+ return CBB_flush(out);
166
318
  }
167
319
 
168
320
  bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback) {
@@ -172,25 +324,23 @@ bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback) {
172
324
  }
173
325
 
174
326
  SSL3_STATE *const s3 = ssl->s3;
175
- uint64_t handback_version, version, conf_max_version, conf_min_version,
176
- max_send_fragment, options, mode, max_cert_list;
327
+ uint64_t handback_version, negotiated_token_binding_param, cipher, type;
328
+
177
329
  CBS seq, read_seq, write_seq, server_rand, client_rand, read_iv, write_iv,
178
- next_proto, alpn, hostname, channel_id;
179
- int session_reused, send_connection_binding, channel_id_valid,
180
- quiet_shutdown, channel_id_enabled, retain_only_sha256;
330
+ next_proto, alpn, hostname, channel_id, transcript, key_share;
331
+ int session_reused, channel_id_valid, cert_request, extended_master_secret,
332
+ ticket_expected, token_binding_negotiated, next_proto_neg_seen;
333
+ SSL_SESSION *session = nullptr;
181
334
 
182
335
  CBS handback_cbs(handback);
183
336
  if (!CBS_get_asn1(&handback_cbs, &seq, CBS_ASN1_SEQUENCE) ||
184
337
  !CBS_get_asn1_uint64(&seq, &handback_version) ||
185
- handback_version != kHandbackVersion) {
338
+ handback_version != kHandbackVersion ||
339
+ !CBS_get_asn1_uint64(&seq, &type)) {
186
340
  return false;
187
341
  }
188
342
 
189
- if (!CBS_get_asn1_uint64(&seq, &version) ||
190
- !CBS_get_asn1_uint64(&seq, &conf_max_version) ||
191
- !CBS_get_asn1_uint64(&seq, &conf_min_version) ||
192
- !CBS_get_asn1_uint64(&seq, &max_send_fragment) ||
193
- !CBS_get_asn1(&seq, &read_seq, CBS_ASN1_OCTETSTRING) ||
343
+ if (!CBS_get_asn1(&seq, &read_seq, CBS_ASN1_OCTETSTRING) ||
194
344
  CBS_len(&read_seq) != sizeof(s3->read_sequence) ||
195
345
  !CBS_get_asn1(&seq, &write_seq, CBS_ASN1_OCTETSTRING) ||
196
346
  CBS_len(&write_seq) != sizeof(s3->write_sequence) ||
@@ -205,47 +355,77 @@ bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback) {
205
355
  !CBS_get_asn1(&seq, &read_iv, CBS_ASN1_OCTETSTRING) ||
206
356
  !CBS_get_asn1(&seq, &write_iv, CBS_ASN1_OCTETSTRING) ||
207
357
  !CBS_get_asn1_bool(&seq, &session_reused) ||
208
- !CBS_get_asn1_bool(&seq, &send_connection_binding) ||
209
358
  !CBS_get_asn1_bool(&seq, &channel_id_valid)) {
210
359
  return false;
211
360
  }
212
361
 
213
- s3->established_session =
214
- SSL_SESSION_parse(&seq, ssl->ctx->x509_method, ssl->ctx->pool);
362
+ s3->hs = ssl_handshake_new(ssl);
363
+ if (session_reused) {
364
+ ssl->session =
365
+ SSL_SESSION_parse(&seq, ssl->ctx->x509_method, ssl->ctx->pool);
366
+ session = ssl->session.get();
367
+ } else {
368
+ s3->hs->new_session =
369
+ SSL_SESSION_parse(&seq, ssl->ctx->x509_method, ssl->ctx->pool);
370
+ session = s3->hs->new_session.get();
371
+ }
215
372
 
216
- if (!s3->established_session ||
217
- !CBS_get_asn1(&seq, &next_proto, CBS_ASN1_OCTETSTRING) ||
373
+ if (!session || !CBS_get_asn1(&seq, &next_proto, CBS_ASN1_OCTETSTRING) ||
218
374
  !CBS_get_asn1(&seq, &alpn, CBS_ASN1_OCTETSTRING) ||
219
375
  !CBS_get_asn1(&seq, &hostname, CBS_ASN1_OCTETSTRING) ||
220
376
  !CBS_get_asn1(&seq, &channel_id, CBS_ASN1_OCTETSTRING) ||
221
- CBS_len(&channel_id) != sizeof(s3->tlsext_channel_id) ||
222
- !CBS_copy_bytes(&channel_id, s3->tlsext_channel_id,
223
- sizeof(s3->tlsext_channel_id)) ||
224
- !CBS_get_asn1_uint64(&seq, &options) ||
225
- !CBS_get_asn1_uint64(&seq, &mode) ||
226
- !CBS_get_asn1_uint64(&seq, &max_cert_list) ||
227
- !CBS_get_asn1_bool(&seq, &quiet_shutdown) ||
228
- !CBS_get_asn1_bool(&seq, &channel_id_enabled) ||
229
- !CBS_get_asn1_bool(&seq, &retain_only_sha256)) {
377
+ CBS_len(&channel_id) != sizeof(s3->channel_id) ||
378
+ !CBS_copy_bytes(&channel_id, s3->channel_id,
379
+ sizeof(s3->channel_id)) ||
380
+ !CBS_get_asn1_bool(&seq, &token_binding_negotiated) ||
381
+ !CBS_get_asn1_uint64(&seq, &negotiated_token_binding_param) ||
382
+ !CBS_get_asn1_bool(&seq, &next_proto_neg_seen) ||
383
+ !CBS_get_asn1_bool(&seq, &cert_request) ||
384
+ !CBS_get_asn1_bool(&seq, &extended_master_secret) ||
385
+ !CBS_get_asn1_bool(&seq, &ticket_expected) ||
386
+ !CBS_get_asn1_uint64(&seq, &cipher)) {
387
+ return false;
388
+ }
389
+ if ((s3->hs->new_cipher =
390
+ SSL_get_cipher_by_value(static_cast<uint16_t>(cipher))) == nullptr) {
391
+ return false;
392
+ }
393
+ if (!CBS_get_asn1(&seq, &transcript, CBS_ASN1_OCTETSTRING) ||
394
+ !CBS_get_asn1(&seq, &key_share, CBS_ASN1_SEQUENCE)) {
230
395
  return false;
231
396
  }
232
397
 
233
- ssl->version = version;
234
- ssl->conf_max_version = conf_max_version;
235
- ssl->conf_min_version = conf_min_version;
236
- ssl->max_send_fragment = max_send_fragment;
398
+ ssl->version = session->ssl_version;
399
+ s3->have_version = true;
400
+ if (!ssl_method_supports_version(ssl->method, ssl->version) ||
401
+ session->cipher != s3->hs->new_cipher ||
402
+ ssl_protocol_version(ssl) < SSL_CIPHER_get_min_version(session->cipher) ||
403
+ SSL_CIPHER_get_max_version(session->cipher) < ssl_protocol_version(ssl)) {
404
+ return false;
405
+ }
237
406
  ssl->do_handshake = ssl_server_handshake;
238
407
  ssl->server = true;
239
- ssl->options = options;
240
- ssl->mode = mode;
241
- ssl->max_cert_list = max_cert_list;
242
-
243
- s3->hs.reset();
244
- s3->have_version = true;
245
- s3->initial_handshake_complete = true;
408
+ switch (type) {
409
+ case handback_after_session_resumption:
410
+ ssl->s3->hs->state = state12_read_change_cipher_spec;
411
+ if (!session_reused) {
412
+ return false;
413
+ }
414
+ break;
415
+ case handback_after_ecdhe:
416
+ ssl->s3->hs->state = state12_read_client_certificate;
417
+ if (session_reused) {
418
+ return false;
419
+ }
420
+ break;
421
+ case handback_after_handshake:
422
+ ssl->s3->hs->state = state12_finish_server_handshake;
423
+ break;
424
+ default:
425
+ return false;
426
+ }
246
427
  s3->session_reused = session_reused;
247
- s3->send_connection_binding = send_connection_binding;
248
- s3->tlsext_channel_id_valid = channel_id_valid;
428
+ s3->channel_id_valid = channel_id_valid;
249
429
  s3->next_proto_negotiated.CopyFrom(next_proto);
250
430
  s3->alpn_selected.CopyFrom(alpn);
251
431
 
@@ -260,26 +440,50 @@ bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback) {
260
440
  s3->hostname.reset(hostname_str);
261
441
  }
262
442
 
263
- ssl->quiet_shutdown = quiet_shutdown;
264
- ssl->tlsext_channel_id_enabled = channel_id_enabled;
265
- ssl->retain_only_sha256_of_client_certs = retain_only_sha256;
443
+ s3->token_binding_negotiated = token_binding_negotiated;
444
+ s3->negotiated_token_binding_param =
445
+ static_cast<uint8_t>(negotiated_token_binding_param);
446
+ s3->hs->next_proto_neg_seen = next_proto_neg_seen;
447
+ s3->hs->wait = ssl_hs_flush;
448
+ s3->hs->extended_master_secret = extended_master_secret;
449
+ s3->hs->ticket_expected = ticket_expected;
450
+ s3->aead_write_ctx->SetVersionIfNullCipher(ssl->version);
451
+ s3->hs->cert_request = cert_request;
452
+
453
+ // TODO(davidben): When handoff for TLS 1.3 is added, serialize
454
+ // |early_data_reason| and stabilize the constants.
455
+ s3->early_data_reason = ssl_early_data_protocol_version;
266
456
 
267
457
  Array<uint8_t> key_block;
268
- if (!tls1_configure_aead(ssl, evp_aead_open, &key_block,
269
- s3->established_session->cipher, read_iv) ||
270
- !tls1_configure_aead(ssl, evp_aead_seal, &key_block,
271
- s3->established_session->cipher, write_iv)) {
458
+ if ((type == handback_after_session_resumption ||
459
+ type == handback_after_handshake) &&
460
+ (!tls1_configure_aead(ssl, evp_aead_seal, &key_block, session->cipher,
461
+ write_iv) ||
462
+ !CBS_copy_bytes(&write_seq, s3->write_sequence,
463
+ sizeof(s3->write_sequence)))) {
272
464
  return false;
273
465
  }
274
-
275
- if (!CBS_copy_bytes(&read_seq, s3->read_sequence,
276
- sizeof(s3->read_sequence)) ||
277
- !CBS_copy_bytes(&write_seq, s3->write_sequence,
278
- sizeof(s3->write_sequence))) {
466
+ if (type == handback_after_handshake &&
467
+ (!tls1_configure_aead(ssl, evp_aead_open, &key_block, session->cipher,
468
+ read_iv) ||
469
+ !CBS_copy_bytes(&read_seq, s3->read_sequence,
470
+ sizeof(s3->read_sequence)))) {
471
+ return false;
472
+ }
473
+ if ((type == handback_after_ecdhe ||
474
+ type == handback_after_session_resumption) &&
475
+ (!s3->hs->transcript.Init() ||
476
+ !s3->hs->transcript.InitHash(ssl_protocol_version(ssl),
477
+ s3->hs->new_cipher) ||
478
+ !s3->hs->transcript.Update(transcript))) {
479
+ return false;
480
+ }
481
+ if (type == handback_after_ecdhe &&
482
+ (s3->hs->key_shares[0] = SSLKeyShare::Create(&key_share)) == nullptr) {
279
483
  return false;
280
484
  }
281
485
 
282
- return true;
486
+ return CBS_len(&seq) == 0;
283
487
  }
284
488
 
285
- } // namespace bssl
489
+ BSSL_NAMESPACE_END