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
@@ -79,20 +79,22 @@ OPENSSL_EXPORT int SHA1_Init(SHA_CTX *sha);
79
79
  // SHA1_Update adds |len| bytes from |data| to |sha| and returns one.
80
80
  OPENSSL_EXPORT int SHA1_Update(SHA_CTX *sha, const void *data, size_t len);
81
81
 
82
- // SHA1_Final adds the final padding to |sha| and writes the resulting digest
83
- // to |md|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It
82
+ // SHA1_Final adds the final padding to |sha| and writes the resulting digest to
83
+ // |out|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It
84
84
  // returns one.
85
- OPENSSL_EXPORT int SHA1_Final(uint8_t *md, SHA_CTX *sha);
85
+ OPENSSL_EXPORT int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *sha);
86
86
 
87
87
  // SHA1 writes the digest of |len| bytes from |data| to |out| and returns
88
88
  // |out|. There must be at least |SHA_DIGEST_LENGTH| bytes of space in
89
89
  // |out|.
90
- OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out);
90
+ OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len,
91
+ uint8_t out[SHA_DIGEST_LENGTH]);
91
92
 
92
93
  // SHA1_Transform is a low-level function that performs a single, SHA-1 block
93
94
  // transformation using the state from |sha| and |SHA_CBLOCK| bytes from
94
95
  // |block|.
95
- OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha, const uint8_t *block);
96
+ OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha,
97
+ const uint8_t block[SHA_CBLOCK]);
96
98
 
97
99
  struct sha_state_st {
98
100
  #if defined(OPENSSL_WINDOWS)
@@ -132,14 +134,16 @@ OPENSSL_EXPORT int SHA224_Init(SHA256_CTX *sha);
132
134
  OPENSSL_EXPORT int SHA224_Update(SHA256_CTX *sha, const void *data, size_t len);
133
135
 
134
136
  // SHA224_Final adds the final padding to |sha| and writes the resulting digest
135
- // to |md|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It
137
+ // to |out|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It
136
138
  // returns one on success and zero on programmer error.
137
- OPENSSL_EXPORT int SHA224_Final(uint8_t *md, SHA256_CTX *sha);
139
+ OPENSSL_EXPORT int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH],
140
+ SHA256_CTX *sha);
138
141
 
139
142
  // SHA224 writes the digest of |len| bytes from |data| to |out| and returns
140
143
  // |out|. There must be at least |SHA224_DIGEST_LENGTH| bytes of space in
141
144
  // |out|.
142
- OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out);
145
+ OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len,
146
+ uint8_t out[SHA224_DIGEST_LENGTH]);
143
147
 
144
148
 
145
149
  // SHA-256.
@@ -157,19 +161,30 @@ OPENSSL_EXPORT int SHA256_Init(SHA256_CTX *sha);
157
161
  OPENSSL_EXPORT int SHA256_Update(SHA256_CTX *sha, const void *data, size_t len);
158
162
 
159
163
  // SHA256_Final adds the final padding to |sha| and writes the resulting digest
160
- // to |md|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It
164
+ // to |out|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It
161
165
  // returns one on success and zero on programmer error.
162
- OPENSSL_EXPORT int SHA256_Final(uint8_t *md, SHA256_CTX *sha);
166
+ OPENSSL_EXPORT int SHA256_Final(uint8_t out[SHA256_DIGEST_LENGTH],
167
+ SHA256_CTX *sha);
163
168
 
164
169
  // SHA256 writes the digest of |len| bytes from |data| to |out| and returns
165
170
  // |out|. There must be at least |SHA256_DIGEST_LENGTH| bytes of space in
166
171
  // |out|.
167
- OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out);
172
+ OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len,
173
+ uint8_t out[SHA256_DIGEST_LENGTH]);
168
174
 
169
175
  // SHA256_Transform is a low-level function that performs a single, SHA-256
170
176
  // block transformation using the state from |sha| and |SHA256_CBLOCK| bytes
171
177
  // from |block|.
172
- OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha, const uint8_t *block);
178
+ OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha,
179
+ const uint8_t block[SHA256_CBLOCK]);
180
+
181
+ // SHA256_TransformBlocks is a low-level function that takes |num_blocks| *
182
+ // |SHA256_CBLOCK| bytes of data and performs SHA-256 transforms on it to update
183
+ // |state|. You should not use this function unless you are implementing a
184
+ // derivative of SHA-256.
185
+ OPENSSL_EXPORT void SHA256_TransformBlocks(uint32_t state[8],
186
+ const uint8_t *data,
187
+ size_t num_blocks);
173
188
 
174
189
  struct sha256_state_st {
175
190
  uint32_t h[8];
@@ -194,19 +209,16 @@ OPENSSL_EXPORT int SHA384_Init(SHA512_CTX *sha);
194
209
  OPENSSL_EXPORT int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len);
195
210
 
196
211
  // SHA384_Final adds the final padding to |sha| and writes the resulting digest
197
- // to |md|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It
212
+ // to |out|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It
198
213
  // returns one on success and zero on programmer error.
199
- OPENSSL_EXPORT int SHA384_Final(uint8_t *md, SHA512_CTX *sha);
214
+ OPENSSL_EXPORT int SHA384_Final(uint8_t out[SHA384_DIGEST_LENGTH],
215
+ SHA512_CTX *sha);
200
216
 
201
217
  // SHA384 writes the digest of |len| bytes from |data| to |out| and returns
202
218
  // |out|. There must be at least |SHA384_DIGEST_LENGTH| bytes of space in
203
219
  // |out|.
204
- OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out);
205
-
206
- // SHA384_Transform is a low-level function that performs a single, SHA-384
207
- // block transformation using the state from |sha| and |SHA384_CBLOCK| bytes
208
- // from |block|.
209
- OPENSSL_EXPORT void SHA384_Transform(SHA512_CTX *sha, const uint8_t *block);
220
+ OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len,
221
+ uint8_t out[SHA384_DIGEST_LENGTH]);
210
222
 
211
223
 
212
224
  // SHA-512.
@@ -224,27 +236,27 @@ OPENSSL_EXPORT int SHA512_Init(SHA512_CTX *sha);
224
236
  OPENSSL_EXPORT int SHA512_Update(SHA512_CTX *sha, const void *data, size_t len);
225
237
 
226
238
  // SHA512_Final adds the final padding to |sha| and writes the resulting digest
227
- // to |md|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It
239
+ // to |out|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It
228
240
  // returns one on success and zero on programmer error.
229
- OPENSSL_EXPORT int SHA512_Final(uint8_t *md, SHA512_CTX *sha);
241
+ OPENSSL_EXPORT int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH],
242
+ SHA512_CTX *sha);
230
243
 
231
244
  // SHA512 writes the digest of |len| bytes from |data| to |out| and returns
232
245
  // |out|. There must be at least |SHA512_DIGEST_LENGTH| bytes of space in
233
246
  // |out|.
234
- OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out);
247
+ OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len,
248
+ uint8_t out[SHA512_DIGEST_LENGTH]);
235
249
 
236
250
  // SHA512_Transform is a low-level function that performs a single, SHA-512
237
251
  // block transformation using the state from |sha| and |SHA512_CBLOCK| bytes
238
252
  // from |block|.
239
- OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha, const uint8_t *block);
253
+ OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha,
254
+ const uint8_t block[SHA512_CBLOCK]);
240
255
 
241
256
  struct sha512_state_st {
242
257
  uint64_t h[8];
243
258
  uint64_t Nl, Nh;
244
- union {
245
- uint64_t d[16];
246
- uint8_t p[128];
247
- } u;
259
+ uint8_t p[128];
248
260
  unsigned num, md_len;
249
261
  };
250
262
 
@@ -0,0 +1,37 @@
1
+ /* Copyright (c) 2019, Google Inc.
2
+ *
3
+ * Permission to use, copy, modify, and/or distribute this software for any
4
+ * purpose with or without fee is hereby granted, provided that the above
5
+ * copyright notice and this permission notice appear in all copies.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
+
15
+ #ifndef OPENSSL_HEADER_SIPHASH_H
16
+ #define OPENSSL_HEADER_SIPHASH_H
17
+
18
+ #include <openssl/base.h>
19
+
20
+ #if defined(__cplusplus)
21
+ extern "C" {
22
+ #endif
23
+
24
+
25
+ // SipHash is a fast, secure PRF that is often used for hash tables.
26
+
27
+
28
+ // SIPHASH_24 implements SipHash-2-4. See https://131002.net/siphash/siphash.pdf
29
+ OPENSSL_EXPORT uint64_t SIPHASH_24(const uint64_t key[2], const uint8_t *input,
30
+ size_t input_len);
31
+
32
+
33
+ #if defined(__cplusplus)
34
+ } // extern C
35
+ #endif
36
+
37
+ #endif // OPENSSL_HEADER_SIPHASH_H
@@ -22,11 +22,10 @@
22
22
  extern "C++" {
23
23
 
24
24
  #include <algorithm>
25
- #include <cassert>
26
25
  #include <cstdlib>
27
26
  #include <type_traits>
28
27
 
29
- namespace bssl {
28
+ BSSL_NAMESPACE_BEGIN
30
29
 
31
30
  template <typename T>
32
31
  class Span;
@@ -132,20 +131,29 @@ class Span : private internal::SpanBase<const T> {
132
131
 
133
132
  T *begin() const { return data_; }
134
133
  const T *cbegin() const { return data_; }
135
- T *end() const { return data_ + size_; };
136
- const T *cend() const { return end(); };
134
+ T *end() const { return data_ + size_; }
135
+ const T *cend() const { return end(); }
137
136
 
138
137
  T &front() const {
139
- assert(size_ != 0);
138
+ if (size_ == 0) {
139
+ abort();
140
+ }
140
141
  return data_[0];
141
142
  }
142
143
  T &back() const {
143
- assert(size_ != 0);
144
+ if (size_ == 0) {
145
+ abort();
146
+ }
144
147
  return data_[size_ - 1];
145
148
  }
146
149
 
147
- T &operator[](size_t i) const { return data_[i]; }
148
- T &at(size_t i) const { return data_[i]; }
150
+ T &operator[](size_t i) const {
151
+ if (i >= size_) {
152
+ abort();
153
+ }
154
+ return data_[i];
155
+ }
156
+ T &at(size_t i) const { return (*this)[i]; }
149
157
 
150
158
  Span subspan(size_t pos = 0, size_t len = npos) const {
151
159
  if (pos > size_) {
@@ -182,7 +190,7 @@ auto MakeConstSpan(const C &c) -> decltype(MakeConstSpan(c.data(), c.size())) {
182
190
  return MakeConstSpan(c.data(), c.size());
183
191
  }
184
192
 
185
- } // namespace bssl
193
+ BSSL_NAMESPACE_END
186
194
 
187
195
  } // extern C++
188
196
 
@@ -185,7 +185,7 @@ extern "C" {
185
185
  // multiple threads. Once shared, functions which change the |SSL_CTX|'s
186
186
  // configuration may not be used.
187
187
 
188
- // TLS_method is the |SSL_METHOD| used for TLS (and SSLv3) connections.
188
+ // TLS_method is the |SSL_METHOD| used for TLS connections.
189
189
  OPENSSL_EXPORT const SSL_METHOD *TLS_method(void);
190
190
 
191
191
  // DTLS_method is the |SSL_METHOD| used for DTLS connections.
@@ -394,20 +394,43 @@ OPENSSL_EXPORT int SSL_pending(const SSL *ssl);
394
394
  // https://crbug.com/466303.
395
395
  OPENSSL_EXPORT int SSL_write(SSL *ssl, const void *buf, int num);
396
396
 
397
- // SSL_shutdown shuts down |ssl|. On success, it completes in two stages. First,
398
- // it returns 0 if |ssl| completed uni-directional shutdown; close_notify has
399
- // been sent, but the peer's close_notify has not been received. Most callers
400
- // may stop at this point. For bi-directional shutdown, call |SSL_shutdown|
401
- // again. It returns 1 if close_notify has been both sent and received.
402
- //
403
- // If the peer's close_notify arrived first, the first stage is skipped.
404
- // |SSL_shutdown| will return 1 once close_notify is sent and skip 0. Callers
405
- // only interested in uni-directional shutdown must therefore allow for the
406
- // first stage returning either 0 or 1.
397
+ // SSL_KEY_UPDATE_REQUESTED indicates that the peer should reply to a KeyUpdate
398
+ // message with its own, thus updating traffic secrets for both directions on
399
+ // the connection.
400
+ #define SSL_KEY_UPDATE_REQUESTED 1
401
+
402
+ // SSL_KEY_UPDATE_NOT_REQUESTED indicates that the peer should not reply with
403
+ // it's own KeyUpdate message.
404
+ #define SSL_KEY_UPDATE_NOT_REQUESTED 0
405
+
406
+ // SSL_key_update queues a TLS 1.3 KeyUpdate message to be sent on |ssl|
407
+ // if one is not already queued. The |request_type| argument must one of the
408
+ // |SSL_KEY_UPDATE_*| values. This function requires that |ssl| have completed a
409
+ // TLS >= 1.3 handshake. It returns one on success or zero on error.
410
+ //
411
+ // Note that this function does not _send_ the message itself. The next call to
412
+ // |SSL_write| will cause the message to be sent. |SSL_write| may be called with
413
+ // a zero length to flush a KeyUpdate message when no application data is
414
+ // pending.
415
+ OPENSSL_EXPORT int SSL_key_update(SSL *ssl, int request_type);
416
+
417
+ // SSL_shutdown shuts down |ssl|. It runs in two stages. First, it sends
418
+ // close_notify and returns zero or one on success or -1 on failure. Zero
419
+ // indicates that close_notify was sent, but not received, and one additionally
420
+ // indicates that the peer's close_notify had already been received.
421
+ //
422
+ // To then wait for the peer's close_notify, run |SSL_shutdown| to completion a
423
+ // second time. This returns 1 on success and -1 on failure. Application data
424
+ // is considered a fatal error at this point. To process or discard it, read
425
+ // until close_notify with |SSL_read| instead.
426
+ //
427
+ // In both cases, on failure, pass the return value into |SSL_get_error| to
428
+ // determine how to proceed.
407
429
  //
408
- // |SSL_shutdown| returns -1 on failure. The caller should pass the return value
409
- // into |SSL_get_error| to determine how to proceed. If the underlying |BIO| is
410
- // non-blocking, both stages may require retry.
430
+ // Most callers should stop at the first stage. Reading for close_notify is
431
+ // primarily used for uncommon protocols where the underlying transport is
432
+ // reused after TLS completes. Additionally, DTLS uses an unordered transport
433
+ // and is unordered, so the second stage is a no-op in DTLS.
411
434
  OPENSSL_EXPORT int SSL_shutdown(SSL *ssl);
412
435
 
413
436
  // SSL_CTX_set_quiet_shutdown sets quiet shutdown on |ctx| to |mode|. If
@@ -535,6 +558,19 @@ OPENSSL_EXPORT int SSL_get_error(const SSL *ssl, int ret_code);
535
558
  #define SSL_ERROR_WANT_CERTIFICATE_VERIFY 16
536
559
 
537
560
  #define SSL_ERROR_HANDOFF 17
561
+ #define SSL_ERROR_HANDBACK 18
562
+
563
+ // SSL_ERROR_WANT_RENEGOTIATE indicates the operation is pending a response to
564
+ // a renegotiation request from the server. The caller may call
565
+ // |SSL_renegotiate| to schedule a renegotiation and retry the operation.
566
+ //
567
+ // See also |ssl_renegotiate_explicit|.
568
+ #define SSL_ERROR_WANT_RENEGOTIATE 19
569
+
570
+ // SSL_error_description returns a string representation of |err|, where |err|
571
+ // is one of the |SSL_ERROR_*| constants returned by |SSL_get_error|, or NULL
572
+ // if the value is unrecognized.
573
+ OPENSSL_EXPORT const char *SSL_error_description(int err);
538
574
 
539
575
  // SSL_set_mtu sets the |ssl|'s MTU in DTLS to |mtu|. It returns one on success
540
576
  // and zero on failure.
@@ -595,8 +631,6 @@ OPENSSL_EXPORT int DTLSv1_handle_timeout(SSL *ssl);
595
631
  #define DTLS1_VERSION 0xfeff
596
632
  #define DTLS1_2_VERSION 0xfefd
597
633
 
598
- #define TLS1_3_DRAFT23_VERSION 0x7f17
599
-
600
634
  // SSL_CTX_set_min_proto_version sets the minimum protocol version for |ctx| to
601
635
  // |version|. If |version| is zero, the default minimum version is used. It
602
636
  // returns one on success and zero if |version| is invalid.
@@ -609,6 +643,12 @@ OPENSSL_EXPORT int SSL_CTX_set_min_proto_version(SSL_CTX *ctx,
609
643
  OPENSSL_EXPORT int SSL_CTX_set_max_proto_version(SSL_CTX *ctx,
610
644
  uint16_t version);
611
645
 
646
+ // SSL_CTX_get_min_proto_version returns the minimum protocol version for |ctx|
647
+ OPENSSL_EXPORT uint16_t SSL_CTX_get_min_proto_version(const SSL_CTX *ctx);
648
+
649
+ // SSL_CTX_get_max_proto_version returns the maximum protocol version for |ctx|
650
+ OPENSSL_EXPORT uint16_t SSL_CTX_get_max_proto_version(const SSL_CTX *ctx);
651
+
612
652
  // SSL_set_min_proto_version sets the minimum protocol version for |ssl| to
613
653
  // |version|. If |version| is zero, the default minimum version is used. It
614
654
  // returns one on success and zero if |version| is invalid.
@@ -619,6 +659,14 @@ OPENSSL_EXPORT int SSL_set_min_proto_version(SSL *ssl, uint16_t version);
619
659
  // returns one on success and zero if |version| is invalid.
620
660
  OPENSSL_EXPORT int SSL_set_max_proto_version(SSL *ssl, uint16_t version);
621
661
 
662
+ // SSL_get_min_proto_version returns the minimum protocol version for |ssl|. If
663
+ // the connection's configuration has been shed, 0 is returned.
664
+ OPENSSL_EXPORT uint16_t SSL_get_min_proto_version(const SSL *ssl);
665
+
666
+ // SSL_get_max_proto_version returns the maximum protocol version for |ssl|. If
667
+ // the connection's configuration has been shed, 0 is returned.
668
+ OPENSSL_EXPORT uint16_t SSL_get_max_proto_version(const SSL *ssl);
669
+
622
670
  // SSL_version returns the TLS or DTLS protocol version used by |ssl|, which is
623
671
  // one of the |*_VERSION| values. (E.g. |TLS1_2_VERSION|.) Before the version
624
672
  // is negotiated, the result is undefined.
@@ -644,7 +692,6 @@ OPENSSL_EXPORT int SSL_version(const SSL *ssl);
644
692
  // The following flags toggle individual protocol versions. This is deprecated.
645
693
  // Use |SSL_CTX_set_min_proto_version| and |SSL_CTX_set_max_proto_version|
646
694
  // instead.
647
- #define SSL_OP_NO_SSLv3 0x02000000L
648
695
  #define SSL_OP_NO_TLSv1 0x04000000L
649
696
  #define SSL_OP_NO_TLSv1_2 0x08000000L
650
697
  #define SSL_OP_NO_TLSv1_1 0x10000000L
@@ -715,10 +762,10 @@ OPENSSL_EXPORT uint32_t SSL_get_options(const SSL *ssl);
715
762
  // and |SSL_CB_HANDSHAKE_DONE| from |SSL_CTX_set_info_callback|.
716
763
  #define SSL_MODE_ENABLE_FALSE_START 0x00000080L
717
764
 
718
- // SSL_MODE_CBC_RECORD_SPLITTING causes multi-byte CBC records in SSL 3.0 and
719
- // TLS 1.0 to be split in two: the first record will contain a single byte and
720
- // the second will contain the remainder. This effectively randomises the IV and
721
- // prevents BEAST attacks.
765
+ // SSL_MODE_CBC_RECORD_SPLITTING causes multi-byte CBC records in TLS 1.0 to be
766
+ // split in two: the first record will contain a single byte and the second will
767
+ // contain the remainder. This effectively randomises the IV and prevents BEAST
768
+ // attacks.
722
769
  #define SSL_MODE_CBC_RECORD_SPLITTING 0x00000100L
723
770
 
724
771
  // SSL_MODE_NO_SESSION_CREATION will cause any attempts to create a session to
@@ -860,8 +907,9 @@ OPENSSL_EXPORT int SSL_clear_chain_certs(SSL *ssl);
860
907
  // |SSL_get_client_CA_list| for information on the server's certificate
861
908
  // request.
862
909
  //
863
- // On the server, the callback will be called on non-resumption handshakes,
864
- // after extensions have been processed.
910
+ // On the server, the callback will be called after extensions have been
911
+ // processed, but before the resumption decision has been made. This differs
912
+ // from OpenSSL which handles resumption before selecting the certificate.
865
913
  OPENSSL_EXPORT void SSL_CTX_set_cert_cb(SSL_CTX *ctx,
866
914
  int (*cb)(SSL *ssl, void *arg),
867
915
  void *arg);
@@ -874,19 +922,37 @@ OPENSSL_EXPORT void SSL_CTX_set_cert_cb(SSL_CTX *ctx,
874
922
  // On the client, the callback may call |SSL_get0_certificate_types| and
875
923
  // |SSL_get_client_CA_list| for information on the server's certificate
876
924
  // request.
925
+ //
926
+ // On the server, the callback will be called after extensions have been
927
+ // processed, but before the resumption decision has been made. This differs
928
+ // from OpenSSL which handles resumption before selecting the certificate.
877
929
  OPENSSL_EXPORT void SSL_set_cert_cb(SSL *ssl, int (*cb)(SSL *ssl, void *arg),
878
930
  void *arg);
879
931
 
880
932
  // SSL_get0_certificate_types, for a client, sets |*out_types| to an array
881
933
  // containing the client certificate types requested by a server. It returns the
882
- // length of the array.
934
+ // length of the array. Note this list is always empty in TLS 1.3. The server
935
+ // will instead send signature algorithms. See
936
+ // |SSL_get0_peer_verify_algorithms|.
883
937
  //
884
938
  // The behavior of this function is undefined except during the callbacks set by
885
939
  // by |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb| or when the
886
940
  // handshake is paused because of them.
887
- OPENSSL_EXPORT size_t SSL_get0_certificate_types(SSL *ssl,
941
+ OPENSSL_EXPORT size_t SSL_get0_certificate_types(const SSL *ssl,
888
942
  const uint8_t **out_types);
889
943
 
944
+ // SSL_get0_peer_verify_algorithms sets |*out_sigalgs| to an array containing
945
+ // the signature algorithms the peer is able to verify. It returns the length of
946
+ // the array. Note these values are only sent starting TLS 1.2 and only
947
+ // mandatory starting TLS 1.3. If not sent, the empty array is returned. For the
948
+ // historical client certificate types list, see |SSL_get0_certificate_types|.
949
+ //
950
+ // The behavior of this function is undefined except during the callbacks set by
951
+ // by |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb| or when the
952
+ // handshake is paused because of them.
953
+ OPENSSL_EXPORT size_t
954
+ SSL_get0_peer_verify_algorithms(const SSL *ssl, const uint16_t **out_sigalgs);
955
+
890
956
  // SSL_certs_clear resets the private key, leaf certificate, and certificate
891
957
  // chain of |ssl|.
892
958
  OPENSSL_EXPORT void SSL_certs_clear(SSL *ssl);
@@ -968,9 +1034,9 @@ OPENSSL_EXPORT int SSL_set_ocsp_response(SSL *ssl,
968
1034
  #define SSL_SIGN_ECDSA_SECP256R1_SHA256 0x0403
969
1035
  #define SSL_SIGN_ECDSA_SECP384R1_SHA384 0x0503
970
1036
  #define SSL_SIGN_ECDSA_SECP521R1_SHA512 0x0603
971
- #define SSL_SIGN_RSA_PSS_SHA256 0x0804
972
- #define SSL_SIGN_RSA_PSS_SHA384 0x0805
973
- #define SSL_SIGN_RSA_PSS_SHA512 0x0806
1037
+ #define SSL_SIGN_RSA_PSS_RSAE_SHA256 0x0804
1038
+ #define SSL_SIGN_RSA_PSS_RSAE_SHA384 0x0805
1039
+ #define SSL_SIGN_RSA_PSS_RSAE_SHA512 0x0806
974
1040
  #define SSL_SIGN_ED25519 0x0807
975
1041
 
976
1042
  // SSL_SIGN_RSA_PKCS1_MD5_SHA1 is an internal signature algorithm used to
@@ -1114,7 +1180,7 @@ OPENSSL_EXPORT void *SSL_CTX_get_default_passwd_cb_userdata(const SSL_CTX *ctx);
1114
1180
 
1115
1181
  // Custom private keys.
1116
1182
 
1117
- enum ssl_private_key_result_t {
1183
+ enum ssl_private_key_result_t BORINGSSL_ENUM_INT {
1118
1184
  ssl_private_key_success,
1119
1185
  ssl_private_key_retry,
1120
1186
  ssl_private_key_failure,
@@ -1196,10 +1262,14 @@ DEFINE_CONST_STACK_OF(SSL_CIPHER)
1196
1262
  // https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4.
1197
1263
  OPENSSL_EXPORT const SSL_CIPHER *SSL_get_cipher_by_value(uint16_t value);
1198
1264
 
1199
- // SSL_CIPHER_get_id returns |cipher|'s id. It may be cast to a |uint16_t| to
1200
- // get the cipher suite value.
1265
+ // SSL_CIPHER_get_id returns |cipher|'s non-IANA id. This is not its
1266
+ // IANA-assigned number, which is called the "value" here, although it may be
1267
+ // cast to a |uint16_t| to get it.
1201
1268
  OPENSSL_EXPORT uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *cipher);
1202
1269
 
1270
+ // SSL_CIPHER_get_value returns |cipher|'s IANA-assigned number.
1271
+ OPENSSL_EXPORT uint16_t SSL_CIPHER_get_value(const SSL_CIPHER *cipher);
1272
+
1203
1273
  // SSL_CIPHER_is_aead returns one if |cipher| uses an AEAD cipher.
1204
1274
  OPENSSL_EXPORT int SSL_CIPHER_is_aead(const SSL_CIPHER *cipher);
1205
1275
 
@@ -1250,7 +1320,8 @@ OPENSSL_EXPORT uint16_t SSL_CIPHER_get_max_version(const SSL_CIPHER *cipher);
1250
1320
  OPENSSL_EXPORT const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher);
1251
1321
 
1252
1322
  // SSL_CIPHER_get_name returns the OpenSSL name of |cipher|. For example,
1253
- // "ECDHE-RSA-AES128-GCM-SHA256".
1323
+ // "ECDHE-RSA-AES128-GCM-SHA256". Callers are recommended to use
1324
+ // |SSL_CIPHER_standard_name| instead.
1254
1325
  OPENSSL_EXPORT const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher);
1255
1326
 
1256
1327
  // SSL_CIPHER_get_kx_name returns a string that describes the key-exchange
@@ -1317,11 +1388,7 @@ OPENSSL_EXPORT int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher,
1317
1388
  // whose bulk cipher use the corresponding encryption scheme. Note that
1318
1389
  // |AES|, |AES128|, and |AES256| match both CBC and GCM ciphers.
1319
1390
  //
1320
- // |SHA1|, |SHA256|, and |SHA384| match legacy cipher suites using the
1321
- // corresponding hash function in their MAC. AEADs are matched by none of
1322
- // these.
1323
- //
1324
- // |SHA| is an alias for |SHA1|.
1391
+ // |SHA1|, and its alias |SHA|, match legacy cipher suites using HMAC-SHA1.
1325
1392
  //
1326
1393
  // Although implemented, authentication-only ciphers match no rules and must be
1327
1394
  // explicitly selected by name.
@@ -1357,7 +1424,7 @@ OPENSSL_EXPORT int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher,
1357
1424
  // based on client preferences. An equal-preference is specified with square
1358
1425
  // brackets, combining multiple selectors separated by |. For example:
1359
1426
  //
1360
- // [ECDHE-ECDSA-CHACHA20-POLY1305|ECDHE-ECDSA-AES128-GCM-SHA256]
1427
+ // [TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256]
1361
1428
  //
1362
1429
  // Once an equal-preference group is used, future directives must be
1363
1430
  // opcode-less. Inside an equal-preference group, spaces are not allowed.
@@ -1460,7 +1527,7 @@ OPENSSL_EXPORT STACK_OF(X509) *SSL_get_peer_full_cert_chain(const SSL *ssl);
1460
1527
  // verification. The caller does not take ownership of the result.
1461
1528
  //
1462
1529
  // This is the |CRYPTO_BUFFER| variant of |SSL_get_peer_full_cert_chain|.
1463
- OPENSSL_EXPORT STACK_OF(CRYPTO_BUFFER) *
1530
+ OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) *
1464
1531
  SSL_get0_peer_certificates(const SSL *ssl);
1465
1532
 
1466
1533
  // SSL_get0_signed_cert_timestamp_list sets |*out| and |*out_len| to point to
@@ -1507,8 +1574,8 @@ OPENSSL_EXPORT int SSL_get_tls_unique(const SSL *ssl, uint8_t *out,
1507
1574
  // TLS 1.3 was negotiated. Otherwise, it returns zero.
1508
1575
  OPENSSL_EXPORT int SSL_get_extms_support(const SSL *ssl);
1509
1576
 
1510
- // SSL_get_current_cipher returns the cipher used in the current outgoing
1511
- // connection state, or NULL if the null cipher is active.
1577
+ // SSL_get_current_cipher returns cipher suite used by |ssl|, or NULL if it has
1578
+ // not been negotiated yet.
1512
1579
  OPENSSL_EXPORT const SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl);
1513
1580
 
1514
1581
  // SSL_session_reused returns one if |ssl| performed an abbreviated handshake
@@ -1533,92 +1600,6 @@ OPENSSL_EXPORT int SSL_export_keying_material(
1533
1600
  const uint8_t *context, size_t context_len, int use_context);
1534
1601
 
1535
1602
 
1536
- // Custom extensions.
1537
- //
1538
- // The custom extension functions allow TLS extensions to be added to
1539
- // ClientHello and ServerHello messages.
1540
-
1541
- // SSL_custom_ext_add_cb is a callback function that is called when the
1542
- // ClientHello (for clients) or ServerHello (for servers) is constructed. In
1543
- // the case of a server, this callback will only be called for a given
1544
- // extension if the ClientHello contained that extension – it's not possible to
1545
- // inject extensions into a ServerHello that the client didn't request.
1546
- //
1547
- // When called, |extension_value| will contain the extension number that is
1548
- // being considered for addition (so that a single callback can handle multiple
1549
- // extensions). If the callback wishes to include the extension, it must set
1550
- // |*out| to point to |*out_len| bytes of extension contents and return one. In
1551
- // this case, the corresponding |SSL_custom_ext_free_cb| callback will later be
1552
- // called with the value of |*out| once that data has been copied.
1553
- //
1554
- // If the callback does not wish to add an extension it must return zero.
1555
- //
1556
- // Alternatively, the callback can abort the connection by setting
1557
- // |*out_alert_value| to a TLS alert number and returning -1.
1558
- typedef int (*SSL_custom_ext_add_cb)(SSL *ssl, unsigned extension_value,
1559
- const uint8_t **out, size_t *out_len,
1560
- int *out_alert_value, void *add_arg);
1561
-
1562
- // SSL_custom_ext_free_cb is a callback function that is called by OpenSSL iff
1563
- // an |SSL_custom_ext_add_cb| callback previously returned one. In that case,
1564
- // this callback is called and passed the |out| pointer that was returned by
1565
- // the add callback. This is to free any dynamically allocated data created by
1566
- // the add callback.
1567
- typedef void (*SSL_custom_ext_free_cb)(SSL *ssl, unsigned extension_value,
1568
- const uint8_t *out, void *add_arg);
1569
-
1570
- // SSL_custom_ext_parse_cb is a callback function that is called by OpenSSL to
1571
- // parse an extension from the peer: that is from the ServerHello for a client
1572
- // and from the ClientHello for a server.
1573
- //
1574
- // When called, |extension_value| will contain the extension number and the
1575
- // contents of the extension are |contents_len| bytes at |contents|.
1576
- //
1577
- // The callback must return one to continue the handshake. Otherwise, if it
1578
- // returns zero, a fatal alert with value |*out_alert_value| is sent and the
1579
- // handshake is aborted.
1580
- typedef int (*SSL_custom_ext_parse_cb)(SSL *ssl, unsigned extension_value,
1581
- const uint8_t *contents,
1582
- size_t contents_len,
1583
- int *out_alert_value, void *parse_arg);
1584
-
1585
- // SSL_extension_supported returns one iff OpenSSL internally handles
1586
- // extensions of type |extension_value|. This can be used to avoid registering
1587
- // custom extension handlers for extensions that a future version of OpenSSL
1588
- // may handle internally.
1589
- OPENSSL_EXPORT int SSL_extension_supported(unsigned extension_value);
1590
-
1591
- // SSL_CTX_add_client_custom_ext registers callback functions for handling
1592
- // custom TLS extensions for client connections.
1593
- //
1594
- // If |add_cb| is NULL then an empty extension will be added in each
1595
- // ClientHello. Otherwise, see the comment for |SSL_custom_ext_add_cb| about
1596
- // this callback.
1597
- //
1598
- // The |free_cb| may be NULL if |add_cb| doesn't dynamically allocate data that
1599
- // needs to be freed.
1600
- //
1601
- // It returns one on success or zero on error. It's always an error to register
1602
- // callbacks for the same extension twice, or to register callbacks for an
1603
- // extension that OpenSSL handles internally. See |SSL_extension_supported| to
1604
- // discover, at runtime, which extensions OpenSSL handles internally.
1605
- OPENSSL_EXPORT int SSL_CTX_add_client_custom_ext(
1606
- SSL_CTX *ctx, unsigned extension_value, SSL_custom_ext_add_cb add_cb,
1607
- SSL_custom_ext_free_cb free_cb, void *add_arg,
1608
- SSL_custom_ext_parse_cb parse_cb, void *parse_arg);
1609
-
1610
- // SSL_CTX_add_server_custom_ext is the same as
1611
- // |SSL_CTX_add_client_custom_ext|, but for server connections.
1612
- //
1613
- // Unlike on the client side, if |add_cb| is NULL no extension will be added.
1614
- // The |add_cb|, if any, will only be called if the ClientHello contained a
1615
- // matching extension.
1616
- OPENSSL_EXPORT int SSL_CTX_add_server_custom_ext(
1617
- SSL_CTX *ctx, unsigned extension_value, SSL_custom_ext_add_cb add_cb,
1618
- SSL_custom_ext_free_cb free_cb, void *add_arg,
1619
- SSL_custom_ext_parse_cb parse_cb, void *parse_arg);
1620
-
1621
-
1622
1603
  // Sessions.
1623
1604
  //
1624
1605
  // An |SSL_SESSION| represents an SSL session that may be resumed in an
@@ -1660,7 +1641,7 @@ OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_from_bytes(
1660
1641
  const uint8_t *in, size_t in_len, const SSL_CTX *ctx);
1661
1642
 
1662
1643
  // SSL_SESSION_get_version returns a string describing the TLS or DTLS version
1663
- // |session| was established at. For example, "TLSv1.2" or "SSLv3".
1644
+ // |session| was established at. For example, "TLSv1.2" or "DTLSv1".
1664
1645
  OPENSSL_EXPORT const char *SSL_SESSION_get_version(const SSL_SESSION *session);
1665
1646
 
1666
1647
  // SSL_SESSION_get_protocol_version returns the TLS or DTLS version |session|
@@ -1674,11 +1655,20 @@ SSL_SESSION_get_protocol_version(const SSL_SESSION *session);
1674
1655
  OPENSSL_EXPORT int SSL_SESSION_set_protocol_version(SSL_SESSION *session,
1675
1656
  uint16_t version);
1676
1657
 
1658
+ // SSL_MAX_SSL_SESSION_ID_LENGTH is the maximum length of an SSL session ID.
1659
+ #define SSL_MAX_SSL_SESSION_ID_LENGTH 32
1660
+
1677
1661
  // SSL_SESSION_get_id returns a pointer to a buffer containing |session|'s
1678
1662
  // session ID and sets |*out_len| to its length.
1679
1663
  OPENSSL_EXPORT const uint8_t *SSL_SESSION_get_id(const SSL_SESSION *session,
1680
1664
  unsigned *out_len);
1681
1665
 
1666
+ // SSL_SESSION_set1_id sets |session|'s session ID to |sid|, It returns one on
1667
+ // success and zero on error. This function may be useful in writing tests but
1668
+ // otherwise should not be used.
1669
+ OPENSSL_EXPORT int SSL_SESSION_set1_id(SSL_SESSION *session, const uint8_t *sid,
1670
+ size_t sid_len);
1671
+
1682
1672
  // SSL_SESSION_get_time returns the time at which |session| was established in
1683
1673
  // seconds since the UNIX epoch.
1684
1674
  OPENSSL_EXPORT uint64_t SSL_SESSION_get_time(const SSL_SESSION *session);
@@ -1692,6 +1682,36 @@ OPENSSL_EXPORT uint32_t SSL_SESSION_get_timeout(const SSL_SESSION *session);
1692
1682
  // TODO(davidben): This should return a const X509 *.
1693
1683
  OPENSSL_EXPORT X509 *SSL_SESSION_get0_peer(const SSL_SESSION *session);
1694
1684
 
1685
+ // SSL_SESSION_get0_peer_certificates returns the peer certificate chain stored
1686
+ // in |session|, or NULL if the peer did not use certificates. This is the
1687
+ // unverified list of certificates as sent by the peer, not the final chain
1688
+ // built during verification. The caller does not take ownership of the result.
1689
+ OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) *
1690
+ SSL_SESSION_get0_peer_certificates(const SSL_SESSION *session);
1691
+
1692
+ // SSL_SESSION_get0_signed_cert_timestamp_list sets |*out| and |*out_len| to
1693
+ // point to |*out_len| bytes of SCT information stored in |session|. This is
1694
+ // only valid for client sessions. The SCT information is a
1695
+ // SignedCertificateTimestampList (including the two leading length bytes). See
1696
+ // https://tools.ietf.org/html/rfc6962#section-3.3 If no SCT was received then
1697
+ // |*out_len| will be zero on return.
1698
+ //
1699
+ // WARNING: the returned data is not guaranteed to be well formed.
1700
+ OPENSSL_EXPORT void SSL_SESSION_get0_signed_cert_timestamp_list(
1701
+ const SSL_SESSION *session, const uint8_t **out, size_t *out_len);
1702
+
1703
+ // SSL_SESSION_get0_ocsp_response sets |*out| and |*out_len| to point to
1704
+ // |*out_len| bytes of an OCSP response from the server. This is the DER
1705
+ // encoding of an OCSPResponse type as defined in RFC 2560.
1706
+ //
1707
+ // WARNING: the returned data is not guaranteed to be well formed.
1708
+ OPENSSL_EXPORT void SSL_SESSION_get0_ocsp_response(const SSL_SESSION *session,
1709
+ const uint8_t **out,
1710
+ size_t *out_len);
1711
+
1712
+ // SSL_MAX_MASTER_KEY_LENGTH is the maximum length of a master secret.
1713
+ #define SSL_MAX_MASTER_KEY_LENGTH 48
1714
+
1695
1715
  // SSL_SESSION_get_master_key writes up to |max_out| bytes of |session|'s master
1696
1716
  // secret to |out| and returns the number of bytes written. If |max_out| is
1697
1717
  // zero, it returns the size of the master secret.
@@ -1710,6 +1730,12 @@ OPENSSL_EXPORT uint64_t SSL_SESSION_set_time(SSL_SESSION *session,
1710
1730
  OPENSSL_EXPORT uint32_t SSL_SESSION_set_timeout(SSL_SESSION *session,
1711
1731
  uint32_t timeout);
1712
1732
 
1733
+ // SSL_SESSION_get0_id_context returns a pointer to a buffer containing
1734
+ // |session|'s session ID context (see |SSL_CTX_set_session_id_context|) and
1735
+ // sets |*out_len| to its length.
1736
+ OPENSSL_EXPORT const uint8_t *SSL_SESSION_get0_id_context(
1737
+ const SSL_SESSION *session, unsigned *out_len);
1738
+
1713
1739
  // SSL_SESSION_set1_id_context sets |session|'s session ID context (see
1714
1740
  // |SSL_CTX_set_session_id_context|) to |sid_ctx|. It returns one on success and
1715
1741
  // zero on error. This function may be useful in writing tests but otherwise
@@ -1723,8 +1749,8 @@ OPENSSL_EXPORT int SSL_SESSION_set1_id_context(SSL_SESSION *session,
1723
1749
  //
1724
1750
  // If this function returns one, clients retain multiple sessions and use each
1725
1751
  // only once. This prevents passive observers from correlating connections with
1726
- // tickets. See draft-ietf-tls-tls13-18, appendix B.5. If it returns zero,
1727
- // |session| cannot be used without leaking a correlator.
1752
+ // tickets. See RFC 8446, appendix C.4. If it returns zero, |session| cannot be
1753
+ // used without leaking a correlator.
1728
1754
  OPENSSL_EXPORT int SSL_SESSION_should_be_single_use(const SSL_SESSION *session);
1729
1755
 
1730
1756
  // SSL_SESSION_is_resumable returns one if |session| is resumable and zero
@@ -1742,11 +1768,40 @@ OPENSSL_EXPORT void SSL_SESSION_get0_ticket(const SSL_SESSION *session,
1742
1768
  const uint8_t **out_ticket,
1743
1769
  size_t *out_len);
1744
1770
 
1771
+ // SSL_SESSION_set_ticket sets |session|'s ticket to |ticket|. It returns one on
1772
+ // success and zero on error. This function may be useful in writing tests but
1773
+ // otherwise should not be used.
1774
+ OPENSSL_EXPORT int SSL_SESSION_set_ticket(SSL_SESSION *session,
1775
+ const uint8_t *ticket,
1776
+ size_t ticket_len);
1777
+
1745
1778
  // SSL_SESSION_get_ticket_lifetime_hint returns ticket lifetime hint of
1746
1779
  // |session| in seconds or zero if none was set.
1747
1780
  OPENSSL_EXPORT uint32_t
1748
1781
  SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *session);
1749
1782
 
1783
+ // SSL_SESSION_get0_cipher returns the cipher negotiated by the connection which
1784
+ // established |session|.
1785
+ //
1786
+ // Note that, in TLS 1.3, there is no guarantee that resumptions with |session|
1787
+ // will use that cipher. Prefer calling |SSL_get_current_cipher| on the |SSL|
1788
+ // instead.
1789
+ OPENSSL_EXPORT const SSL_CIPHER *SSL_SESSION_get0_cipher(
1790
+ const SSL_SESSION *session);
1791
+
1792
+ // SSL_SESSION_has_peer_sha256 returns one if |session| has a SHA-256 hash of
1793
+ // the peer's certificate retained and zero if the peer did not present a
1794
+ // certificate or if this was not enabled when |session| was created. See also
1795
+ // |SSL_CTX_set_retain_only_sha256_of_client_certs|.
1796
+ OPENSSL_EXPORT int SSL_SESSION_has_peer_sha256(const SSL_SESSION *session);
1797
+
1798
+ // SSL_SESSION_get0_peer_sha256 sets |*out_ptr| and |*out_len| to the SHA-256
1799
+ // hash of the peer certificate retained in |session|, or NULL and zero if it
1800
+ // does not have one. See also |SSL_CTX_set_retain_only_sha256_of_client_certs|.
1801
+ OPENSSL_EXPORT void SSL_SESSION_get0_peer_sha256(const SSL_SESSION *session,
1802
+ const uint8_t **out_ptr,
1803
+ size_t *out_len);
1804
+
1750
1805
 
1751
1806
  // Session caching.
1752
1807
  //
@@ -1830,7 +1885,11 @@ OPENSSL_EXPORT int SSL_CTX_get_session_cache_mode(const SSL_CTX *ctx);
1830
1885
 
1831
1886
  // SSL_set_session, for a client, configures |ssl| to offer to resume |session|
1832
1887
  // in the initial handshake and returns one. The caller retains ownership of
1833
- // |session|.
1888
+ // |session|. Note that configuring a session assumes the authentication in the
1889
+ // session is valid. For callers that wish to revalidate the session before
1890
+ // offering, see |SSL_SESSION_get0_peer_certificates|,
1891
+ // |SSL_SESSION_get0_signed_cert_timestamp_list|, and
1892
+ // |SSL_SESSION_get0_ocsp_response|.
1834
1893
  //
1835
1894
  // It is an error to call this function after the handshake has begun.
1836
1895
  OPENSSL_EXPORT int SSL_set_session(SSL *ssl, SSL_SESSION *session);
@@ -1863,6 +1922,9 @@ OPENSSL_EXPORT void SSL_CTX_set_session_psk_dhe_timeout(SSL_CTX *ctx,
1863
1922
  // sessions created in |ctx|.
1864
1923
  OPENSSL_EXPORT uint32_t SSL_CTX_get_timeout(const SSL_CTX *ctx);
1865
1924
 
1925
+ // SSL_MAX_SID_CTX_LENGTH is the maximum length of a session ID context.
1926
+ #define SSL_MAX_SID_CTX_LENGTH 32
1927
+
1866
1928
  // SSL_CTX_set_session_id_context sets |ctx|'s session ID context to |sid_ctx|.
1867
1929
  // It returns one on success and zero on error. The session ID context is an
1868
1930
  // application-defined opaque byte string. A session will not be used in a
@@ -1881,7 +1943,7 @@ OPENSSL_EXPORT int SSL_set_session_id_context(SSL *ssl, const uint8_t *sid_ctx,
1881
1943
  size_t sid_ctx_len);
1882
1944
 
1883
1945
  // SSL_get0_session_id_context returns a pointer to |ssl|'s session ID context
1884
- // and sets |*out_len| to its length.
1946
+ // and sets |*out_len| to its length. It returns NULL on error.
1885
1947
  OPENSSL_EXPORT const uint8_t *SSL_get0_session_id_context(const SSL *ssl,
1886
1948
  size_t *out_len);
1887
1949
 
@@ -2002,13 +2064,13 @@ OPENSSL_EXPORT SSL_SESSION *SSL_magic_pending_session_ptr(void);
2002
2064
  // On the client, ticket-based sessions use the same APIs as ID-based tickets.
2003
2065
  // Callers do not need to handle them differently.
2004
2066
  //
2005
- // On the server, tickets are encrypted and authenticated with a secret key. By
2006
- // default, an |SSL_CTX| generates a key on creation and uses it for the
2007
- // lifetime of the |SSL_CTX|. Tickets are minted and processed
2008
- // transparently. The following functions may be used to configure a persistent
2009
- // key or implement more custom behavior, including key rotation and sharing
2010
- // keys between multiple servers in a large deployment. There are three levels
2011
- // of customisation possible:
2067
+ // On the server, tickets are encrypted and authenticated with a secret key.
2068
+ // By default, an |SSL_CTX| will manage session ticket encryption keys by
2069
+ // generating them internally and rotating every 48 hours. Tickets are minted
2070
+ // and processed transparently. The following functions may be used to configure
2071
+ // a persistent key or implement more custom behavior, including key rotation
2072
+ // and sharing keys between multiple servers in a large deployment. There are
2073
+ // three levels of customisation possible:
2012
2074
  //
2013
2075
  // 1) One can simply set the keys with |SSL_CTX_set_tlsext_ticket_keys|.
2014
2076
  // 2) One can configure an |EVP_CIPHER_CTX| and |HMAC_CTX| directly for
@@ -2074,7 +2136,7 @@ OPENSSL_EXPORT int SSL_CTX_set_tlsext_ticket_key_cb(
2074
2136
 
2075
2137
  // ssl_ticket_aead_result_t enumerates the possible results from decrypting a
2076
2138
  // ticket with an |SSL_TICKET_AEAD_METHOD|.
2077
- enum ssl_ticket_aead_result_t {
2139
+ enum ssl_ticket_aead_result_t BORINGSSL_ENUM_INT {
2078
2140
  // ssl_ticket_aead_success indicates that the ticket was successfully
2079
2141
  // decrypted.
2080
2142
  ssl_ticket_aead_success,
@@ -2168,6 +2230,7 @@ OPENSSL_EXPORT int SSL_set1_curves_list(SSL *ssl, const char *curves);
2168
2230
  #define SSL_CURVE_SECP384R1 24
2169
2231
  #define SSL_CURVE_SECP521R1 25
2170
2232
  #define SSL_CURVE_X25519 29
2233
+ #define SSL_CURVE_CECPQ2 16696
2171
2234
 
2172
2235
  // SSL_get_curve_id returns the ID of the curve used by |ssl|'s most recently
2173
2236
  // completed handshake or 0 if not applicable.
@@ -2247,7 +2310,7 @@ OPENSSL_EXPORT void SSL_set_verify(SSL *ssl, int mode,
2247
2310
  int (*callback)(int ok,
2248
2311
  X509_STORE_CTX *store_ctx));
2249
2312
 
2250
- enum ssl_verify_result_t {
2313
+ enum ssl_verify_result_t BORINGSSL_ENUM_INT {
2251
2314
  ssl_verify_ok,
2252
2315
  ssl_verify_invalid,
2253
2316
  ssl_verify_retry,
@@ -2285,7 +2348,7 @@ OPENSSL_EXPORT void SSL_set_custom_verify(
2285
2348
  OPENSSL_EXPORT int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);
2286
2349
 
2287
2350
  // SSL_get_verify_mode returns |ssl|'s verify mode, set by |SSL_CTX_set_verify|
2288
- // or |SSL_set_verify|.
2351
+ // or |SSL_set_verify|. It returns -1 on error.
2289
2352
  OPENSSL_EXPORT int SSL_get_verify_mode(const SSL *ssl);
2290
2353
 
2291
2354
  // SSL_CTX_get_verify_callback returns the callback set by
@@ -2456,10 +2519,19 @@ OPENSSL_EXPORT int SSL_set0_verify_cert_store(SSL *ssl, X509_STORE *store);
2456
2519
  OPENSSL_EXPORT int SSL_set1_verify_cert_store(SSL *ssl, X509_STORE *store);
2457
2520
 
2458
2521
  // SSL_CTX_set_ed25519_enabled configures whether |ctx| advertises support for
2459
- // the Ed25519 signature algorithm when using the default preference list.
2522
+ // the Ed25519 signature algorithm when using the default preference list. It is
2523
+ // disabled by default and may be enabled if the certificate verifier supports
2524
+ // Ed25519.
2460
2525
  OPENSSL_EXPORT void SSL_CTX_set_ed25519_enabled(SSL_CTX *ctx, int enabled);
2461
2526
 
2462
- // SSL_CTX_set_verify_algorithm_prefs confingures |ctx| to use |prefs| as the
2527
+ // SSL_CTX_set_rsa_pss_rsae_certs_enabled configures whether |ctx| advertises
2528
+ // support for rsa_pss_rsae_* signatures within the certificate chain. It is
2529
+ // enabled by default but should be disabled if using a custom certificate
2530
+ // verifier which does not support RSA-PSS signatures.
2531
+ OPENSSL_EXPORT void SSL_CTX_set_rsa_pss_rsae_certs_enabled(SSL_CTX *ctx,
2532
+ int enabled);
2533
+
2534
+ // SSL_CTX_set_verify_algorithm_prefs configures |ctx| to use |prefs| as the
2463
2535
  // preference list when verifying signature's from the peer's long-term key. It
2464
2536
  // returns one on zero on error. |prefs| should not include the internal-only
2465
2537
  // value |SSL_SIGN_RSA_PKCS1_MD5_SHA1|.
@@ -2513,8 +2585,8 @@ OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *ssl);
2513
2585
  //
2514
2586
  // The returned stack is owned by |ssl|, as are its contents. It should not be
2515
2587
  // used past the point where the handshake is restarted after the callback.
2516
- OPENSSL_EXPORT STACK_OF(CRYPTO_BUFFER) *SSL_get0_server_requested_CAs(
2517
- const SSL *ssl);
2588
+ OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) *
2589
+ SSL_get0_server_requested_CAs(const SSL *ssl);
2518
2590
 
2519
2591
  // SSL_CTX_get_client_CA_list returns |ctx|'s client certificate CA list.
2520
2592
  OPENSSL_EXPORT STACK_OF(X509_NAME) *
@@ -2669,6 +2741,54 @@ OPENSSL_EXPORT void SSL_CTX_set_allow_unknown_alpn_protos(SSL_CTX *ctx,
2669
2741
  int enabled);
2670
2742
 
2671
2743
 
2744
+ // Certificate compression.
2745
+ //
2746
+ // Certificates in TLS 1.3 can be compressed[1]. BoringSSL supports this as both
2747
+ // a client and a server, but does not link against any specific compression
2748
+ // libraries in order to keep dependencies to a minimum. Instead, hooks for
2749
+ // compression and decompression can be installed in an |SSL_CTX| to enable
2750
+ // support.
2751
+ //
2752
+ // [1] https://tools.ietf.org/html/draft-ietf-tls-certificate-compression-03.
2753
+
2754
+ // ssl_cert_compression_func_t is a pointer to a function that performs
2755
+ // compression. It must write the compressed representation of |in| to |out|,
2756
+ // returning one on success and zero on error. The results of compressing
2757
+ // certificates are not cached internally. Implementations may wish to implement
2758
+ // their own cache if they expect it to be useful given the certificates that
2759
+ // they serve.
2760
+ typedef int (*ssl_cert_compression_func_t)(SSL *ssl, CBB *out,
2761
+ const uint8_t *in, size_t in_len);
2762
+
2763
+ // ssl_cert_decompression_func_t is a pointer to a function that performs
2764
+ // decompression. The compressed data from the peer is passed as |in| and the
2765
+ // decompressed result must be exactly |uncompressed_len| bytes long. It returns
2766
+ // one on success, in which case |*out| must be set to the result of
2767
+ // decompressing |in|, or zero on error. Setting |*out| transfers ownership,
2768
+ // i.e. |CRYPTO_BUFFER_free| will be called on |*out| at some point in the
2769
+ // future. The results of decompressions are not cached internally.
2770
+ // Implementations may wish to implement their own cache if they expect it to be
2771
+ // useful.
2772
+ typedef int (*ssl_cert_decompression_func_t)(SSL *ssl, CRYPTO_BUFFER **out,
2773
+ size_t uncompressed_len,
2774
+ const uint8_t *in, size_t in_len);
2775
+
2776
+ // SSL_CTX_add_cert_compression_alg registers a certificate compression
2777
+ // algorithm on |ctx| with ID |alg_id|. (The value of |alg_id| should be an IANA
2778
+ // assigned value and each can only be registered once.)
2779
+ //
2780
+ // One of the function pointers may be NULL to avoid having to implement both
2781
+ // sides of a compression algorithm if you're only going to use it in one
2782
+ // direction. In this case, the unimplemented direction acts like it was never
2783
+ // configured.
2784
+ //
2785
+ // For a server, algorithms are registered in preference order with the most
2786
+ // preferable first. It returns one on success or zero on error.
2787
+ OPENSSL_EXPORT int SSL_CTX_add_cert_compression_alg(
2788
+ SSL_CTX *ctx, uint16_t alg_id, ssl_cert_compression_func_t compress,
2789
+ ssl_cert_decompression_func_t decompress);
2790
+
2791
+
2672
2792
  // Next protocol negotiation.
2673
2793
  //
2674
2794
  // The NPN extension (draft-agl-tls-nextprotoneg-03) is the predecessor to ALPN
@@ -2938,27 +3058,20 @@ OPENSSL_EXPORT const char *SSL_get_psk_identity_hint(const SSL *ssl);
2938
3058
  OPENSSL_EXPORT const char *SSL_get_psk_identity(const SSL *ssl);
2939
3059
 
2940
3060
 
2941
- // Dummy post-quantum padding.
3061
+ // Post-quantum experiment signaling extension.
2942
3062
  //
2943
- // Dummy post-quantum padding invovles the client (and later server) sending
2944
- // useless, random-looking bytes in an extension in their ClientHello or
2945
- // ServerHello. These extensions are sized to simulate a post-quantum
2946
- // key-exchange and so enable measurement of the latency impact of the
2947
- // additional bandwidth.
2948
-
2949
- // SSL_set_dummy_pq_padding_size enables the sending of a dummy PQ padding
2950
- // extension and configures its size. This is only effective for a client: a
2951
- // server will echo an extension with one of equal length when we get to that
2952
- // phase of the experiment. It returns one for success and zero otherwise.
2953
- OPENSSL_EXPORT int SSL_set_dummy_pq_padding_size(SSL *ssl, size_t num_bytes);
3063
+ // *** EXPERIMENTAL ***
3064
+ //
3065
+ // In order to define a control group in an experiment of post-quantum key
3066
+ // agreements, clients and servers may send a non-IANA defined extension as a
3067
+ // signaling bit. These functions should not be used without explicit permission
3068
+ // from BoringSSL-team.
2954
3069
 
2955
- // SSL_dummy_pq_padding_used returns one if the server echoed a dummy PQ padding
2956
- // extension and zero otherwise. It may only be called on a client connection
2957
- // once the ServerHello has been processed, otherwise it'll return zero.
2958
- OPENSSL_EXPORT int SSL_dummy_pq_padding_used(SSL *ssl);
3070
+ OPENSSL_EXPORT void SSL_CTX_enable_pq_experiment_signal(SSL_CTX *ctx);
3071
+ OPENSSL_EXPORT int SSL_pq_experiment_signal_seen(const SSL *ssl);
2959
3072
 
2960
3073
 
2961
- // QUIC Transport Parameters.
3074
+ // QUIC transport parameters.
2962
3075
  //
2963
3076
  // draft-ietf-quic-tls defines a new TLS extension quic_transport_parameters
2964
3077
  // used by QUIC for each endpoint to unilaterally declare its supported
@@ -2990,6 +3103,176 @@ OPENSSL_EXPORT void SSL_get_peer_quic_transport_params(const SSL *ssl,
2990
3103
  size_t *out_params_len);
2991
3104
 
2992
3105
 
3106
+ // Delegated credentials.
3107
+ //
3108
+ // *** EXPERIMENTAL — PRONE TO CHANGE ***
3109
+ //
3110
+ // draft-ietf-tls-subcerts is a proposed extension for TLS 1.3 and above that
3111
+ // allows an end point to use its certificate to delegate credentials for
3112
+ // authentication. If the peer indicates support for this extension, then this
3113
+ // host may use a delegated credential to sign the handshake. Once issued,
3114
+ // credentials can't be revoked. In order to mitigate the damage in case the
3115
+ // credential secret key is compromised, the credential is only valid for a
3116
+ // short time (days, hours, or even minutes). This library implements draft-03
3117
+ // of the protocol spec.
3118
+ //
3119
+ // The extension ID has not been assigned; we're using 0xff02 for the time
3120
+ // being. Currently only the server side is implemented.
3121
+ //
3122
+ // Servers configure a DC for use in the handshake via
3123
+ // |SSL_set1_delegated_credential|. It must be signed by the host's end-entity
3124
+ // certificate as defined in draft-ietf-tls-subcerts-03.
3125
+
3126
+ // SSL_set1_delegated_credential configures the delegated credential (DC) that
3127
+ // will be sent to the peer for the current connection. |dc| is the DC in wire
3128
+ // format, and |pkey| or |key_method| is the corresponding private key.
3129
+ // Currently (as of draft-03), only servers may configure a DC to use in the
3130
+ // handshake.
3131
+ //
3132
+ // The DC will only be used if the protocol version is correct and the signature
3133
+ // scheme is supported by the peer. If not, the DC will not be negotiated and
3134
+ // the handshake will use the private key (or private key method) associated
3135
+ // with the certificate.
3136
+ OPENSSL_EXPORT int SSL_set1_delegated_credential(
3137
+ SSL *ssl, CRYPTO_BUFFER *dc, EVP_PKEY *pkey,
3138
+ const SSL_PRIVATE_KEY_METHOD *key_method);
3139
+
3140
+ // SSL_delegated_credential_used returns one if a delegated credential was used
3141
+ // and zero otherwise.
3142
+ OPENSSL_EXPORT int SSL_delegated_credential_used(const SSL *ssl);
3143
+
3144
+
3145
+ // QUIC integration.
3146
+ //
3147
+ // QUIC acts as an underlying transport for the TLS 1.3 handshake. The following
3148
+ // functions allow a QUIC implementation to serve as the underlying transport as
3149
+ // described in draft-ietf-quic-tls.
3150
+ //
3151
+ // When configured for QUIC, |SSL_do_handshake| will drive the handshake as
3152
+ // before, but it will not use the configured |BIO|. It will call functions on
3153
+ // |SSL_QUIC_METHOD| to configure secrets and send data. If data is needed from
3154
+ // the peer, it will return |SSL_ERROR_WANT_READ|. When received, the caller
3155
+ // should call |SSL_provide_quic_data| and then |SSL_do_handshake| to continue
3156
+ // the handshake. After the handshake is complete, the caller should call
3157
+ // |SSL_provide_quic_data| for any post-handshake data, followed by
3158
+ // |SSL_process_quic_post_handshake| to process it. It is an error to call
3159
+ // |SSL_read| and |SSL_write| in QUIC.
3160
+ //
3161
+ // 0-RTT behaves similarly to |TLS_method|'s usual behavior. |SSL_do_handshake|
3162
+ // returns early as soon as the client (respectively, server) is allowed to send
3163
+ // 0-RTT (respectively, half-RTT) data. The caller should then call
3164
+ // |SSL_do_handshake| again to consume the remaining handshake messages and
3165
+ // confirm the handshake. As a client, |SSL_ERROR_EARLY_DATA_REJECTED| and
3166
+ // |SSL_reset_early_data_reject| behave as usual.
3167
+ //
3168
+ // Note that secrets for an encryption level may be available to QUIC before the
3169
+ // level is active in TLS. Callers should use |SSL_quic_read_level| to determine
3170
+ // the active read level for |SSL_provide_quic_data|. |SSL_do_handshake| will
3171
+ // pass the active write level to |SSL_QUIC_METHOD| when writing data. Callers
3172
+ // can use |SSL_quic_write_level| to query the active write level when
3173
+ // generating their own errors.
3174
+ //
3175
+ // See https://tools.ietf.org/html/draft-ietf-quic-tls-15#section-4.1 for more
3176
+ // details.
3177
+ //
3178
+ // To avoid DoS attacks, the QUIC implementation must limit the amount of data
3179
+ // being queued up. The implementation can call
3180
+ // |SSL_quic_max_handshake_flight_len| to get the maximum buffer length at each
3181
+ // encryption level.
3182
+ //
3183
+ // Note: 0-RTT support is incomplete and does not currently handle QUIC
3184
+ // transport parameters and server SETTINGS frame.
3185
+
3186
+ // ssl_encryption_level_t represents a specific QUIC encryption level used to
3187
+ // transmit handshake messages.
3188
+ enum ssl_encryption_level_t BORINGSSL_ENUM_INT {
3189
+ ssl_encryption_initial = 0,
3190
+ ssl_encryption_early_data,
3191
+ ssl_encryption_handshake,
3192
+ ssl_encryption_application,
3193
+ };
3194
+
3195
+ // ssl_quic_method_st (aka |SSL_QUIC_METHOD|) describes custom QUIC hooks.
3196
+ struct ssl_quic_method_st {
3197
+ // set_encryption_secrets configures the read and write secrets for the given
3198
+ // encryption level. This function will always be called before an encryption
3199
+ // level other than |ssl_encryption_initial| is used. Note, however, that
3200
+ // secrets for a level may be configured before TLS is ready to send or accept
3201
+ // data at that level.
3202
+ //
3203
+ // When reading packets at a given level, the QUIC implementation must send
3204
+ // ACKs at the same level, so this function provides read and write secrets
3205
+ // together. The exception is |ssl_encryption_early_data|, where secrets are
3206
+ // only available in the client to server direction. The other secret will be
3207
+ // NULL. The server acknowledges such data at |ssl_encryption_application|,
3208
+ // which will be configured in the same |SSL_do_handshake| call.
3209
+ //
3210
+ // This function should use |SSL_get_current_cipher| to determine the TLS
3211
+ // cipher suite.
3212
+ //
3213
+ // It returns one on success and zero on error.
3214
+ int (*set_encryption_secrets)(SSL *ssl, enum ssl_encryption_level_t level,
3215
+ const uint8_t *read_secret,
3216
+ const uint8_t *write_secret, size_t secret_len);
3217
+ // add_handshake_data adds handshake data to the current flight at the given
3218
+ // encryption level. It returns one on success and zero on error.
3219
+ //
3220
+ // BoringSSL will pack data from a single encryption level together, but a
3221
+ // single handshake flight may include multiple encryption levels. Callers
3222
+ // should defer writing data to the network until |flush_flight| to better
3223
+ // pack QUIC packets into transport datagrams.
3224
+ int (*add_handshake_data)(SSL *ssl, enum ssl_encryption_level_t level,
3225
+ const uint8_t *data, size_t len);
3226
+ // flush_flight is called when the current flight is complete and should be
3227
+ // written to the transport. Note a flight may contain data at several
3228
+ // encryption levels. It returns one on success and zero on error.
3229
+ int (*flush_flight)(SSL *ssl);
3230
+ // send_alert sends a fatal alert at the specified encryption level. It
3231
+ // returns one on success and zero on error.
3232
+ int (*send_alert)(SSL *ssl, enum ssl_encryption_level_t level, uint8_t alert);
3233
+ };
3234
+
3235
+ // SSL_quic_max_handshake_flight_len returns returns the maximum number of bytes
3236
+ // that may be received at the given encryption level. This function should be
3237
+ // used to limit buffering in the QUIC implementation.
3238
+ //
3239
+ // See https://tools.ietf.org/html/draft-ietf-quic-transport-16#section-4.4.
3240
+ OPENSSL_EXPORT size_t SSL_quic_max_handshake_flight_len(
3241
+ const SSL *ssl, enum ssl_encryption_level_t level);
3242
+
3243
+ // SSL_quic_read_level returns the current read encryption level.
3244
+ OPENSSL_EXPORT enum ssl_encryption_level_t SSL_quic_read_level(const SSL *ssl);
3245
+
3246
+ // SSL_quic_write_level returns the current write encryption level.
3247
+ OPENSSL_EXPORT enum ssl_encryption_level_t SSL_quic_write_level(const SSL *ssl);
3248
+
3249
+ // SSL_provide_quic_data provides data from QUIC at a particular encryption
3250
+ // level |level|. It is an error to call this function outside of the handshake
3251
+ // or with an encryption level other than the current read level. It returns one
3252
+ // on success and zero on error.
3253
+ OPENSSL_EXPORT int SSL_provide_quic_data(SSL *ssl,
3254
+ enum ssl_encryption_level_t level,
3255
+ const uint8_t *data, size_t len);
3256
+
3257
+
3258
+ // SSL_process_quic_post_handshake processes any data that QUIC has provided
3259
+ // after the handshake has completed. This includes NewSessionTicket messages
3260
+ // sent by the server. It returns one on success and zero on error.
3261
+ OPENSSL_EXPORT int SSL_process_quic_post_handshake(SSL *ssl);
3262
+
3263
+ // SSL_CTX_set_quic_method configures the QUIC hooks. This should only be
3264
+ // configured with a minimum version of TLS 1.3. |quic_method| must remain valid
3265
+ // for the lifetime of |ctx|. It returns one on success and zero on error.
3266
+ OPENSSL_EXPORT int SSL_CTX_set_quic_method(SSL_CTX *ctx,
3267
+ const SSL_QUIC_METHOD *quic_method);
3268
+
3269
+ // SSL_set_quic_method configures the QUIC hooks. This should only be
3270
+ // configured with a minimum version of TLS 1.3. |quic_method| must remain valid
3271
+ // for the lifetime of |ssl|. It returns one on success and zero on error.
3272
+ OPENSSL_EXPORT int SSL_set_quic_method(SSL *ssl,
3273
+ const SSL_QUIC_METHOD *quic_method);
3274
+
3275
+
2993
3276
  // Early data.
2994
3277
  //
2995
3278
  // WARNING: 0-RTT support in BoringSSL is currently experimental and not fully
@@ -3002,8 +3285,8 @@ OPENSSL_EXPORT void SSL_get_peer_quic_transport_params(const SSL *ssl,
3002
3285
  // WARNING: A 0-RTT handshake has different security properties from normal
3003
3286
  // handshake, so it is off by default unless opted in. In particular, early data
3004
3287
  // is replayable by a network attacker. Callers must account for this when
3005
- // sending or processing data before the handshake is confirmed. See
3006
- // draft-ietf-tls-tls13-18 for more information.
3288
+ // sending or processing data before the handshake is confirmed. See RFC 8446
3289
+ // for more information.
3007
3290
  //
3008
3291
  // As a server, if early data is accepted, |SSL_do_handshake| will complete as
3009
3292
  // soon as the ClientHello is processed and server flight sent. |SSL_write| may
@@ -3038,9 +3321,9 @@ OPENSSL_EXPORT void SSL_get_peer_quic_transport_params(const SSL *ssl,
3038
3321
  // properties. The caller must disregard any values from before the reset and
3039
3322
  // query again.
3040
3323
  //
3041
- // Finally, to implement the fallback described in draft-ietf-tls-tls13-18
3042
- // appendix C.3, retry on a fresh connection without 0-RTT if the handshake
3043
- // fails with |SSL_R_WRONG_VERSION_ON_EARLY_DATA|.
3324
+ // Finally, to implement the fallback described in RFC 8446 appendix D.3, retry
3325
+ // on a fresh connection without 0-RTT if the handshake fails with
3326
+ // |SSL_R_WRONG_VERSION_ON_EARLY_DATA|.
3044
3327
 
3045
3328
  // SSL_CTX_set_early_data_enabled sets whether early data is allowed to be used
3046
3329
  // with resumptions using |ctx|.
@@ -3058,6 +3341,10 @@ OPENSSL_EXPORT void SSL_set_early_data_enabled(SSL *ssl, int enabled);
3058
3341
  // and |SSL_write| to send half-RTT data.
3059
3342
  OPENSSL_EXPORT int SSL_in_early_data(const SSL *ssl);
3060
3343
 
3344
+ // SSL_SESSION_early_data_capable returns whether early data would have been
3345
+ // attempted with |session| if enabled.
3346
+ OPENSSL_EXPORT int SSL_SESSION_early_data_capable(const SSL_SESSION *session);
3347
+
3061
3348
  // SSL_early_data_accepted returns whether early data was accepted on the
3062
3349
  // handshake performed by |ssl|.
3063
3350
  OPENSSL_EXPORT int SSL_early_data_accepted(const SSL *ssl);
@@ -3071,21 +3358,59 @@ OPENSSL_EXPORT int SSL_early_data_accepted(const SSL *ssl);
3071
3358
  // |SSL_ERROR_EARLY_DATA_REJECTED|.
3072
3359
  OPENSSL_EXPORT void SSL_reset_early_data_reject(SSL *ssl);
3073
3360
 
3074
- // SSL_export_early_keying_material behaves like |SSL_export_keying_material|,
3075
- // but it uses the early exporter. The operation will fail if |ssl| did not
3076
- // negotiate TLS 1.3 or 0-RTT.
3077
- OPENSSL_EXPORT int SSL_export_early_keying_material(
3078
- SSL *ssl, uint8_t *out, size_t out_len, const char *label, size_t label_len,
3079
- const uint8_t *context, size_t context_len);
3361
+ // SSL_get_ticket_age_skew returns the difference, in seconds, between the
3362
+ // client-sent ticket age and the server-computed value in TLS 1.3 server
3363
+ // connections which resumed a session.
3364
+ OPENSSL_EXPORT int32_t SSL_get_ticket_age_skew(const SSL *ssl);
3365
+
3366
+ // An ssl_early_data_reason_t describes why 0-RTT was accepted or rejected.
3367
+ // These values are persisted to logs. Entries should not be renumbered and
3368
+ // numeric values should never be reused.
3369
+ enum ssl_early_data_reason_t BORINGSSL_ENUM_INT {
3370
+ // The handshake has not progressed far enough for the 0-RTT status to be
3371
+ // known.
3372
+ ssl_early_data_unknown = 0,
3373
+ // 0-RTT is disabled for this connection.
3374
+ ssl_early_data_disabled = 1,
3375
+ // 0-RTT was accepted.
3376
+ ssl_early_data_accepted = 2,
3377
+ // The negotiated protocol version does not support 0-RTT.
3378
+ ssl_early_data_protocol_version = 3,
3379
+ // The peer declined to offer or accept 0-RTT for an unknown reason.
3380
+ ssl_early_data_peer_declined = 4,
3381
+ // The client did not offer a session.
3382
+ ssl_early_data_no_session_offered = 5,
3383
+ // The server declined to resume the session.
3384
+ ssl_early_data_session_not_resumed = 6,
3385
+ // The session does not support 0-RTT.
3386
+ ssl_early_data_unsupported_for_session = 7,
3387
+ // The server sent a HelloRetryRequest.
3388
+ ssl_early_data_hello_retry_request = 8,
3389
+ // The negotiated ALPN protocol did not match the session.
3390
+ ssl_early_data_alpn_mismatch = 9,
3391
+ // The connection negotiated Channel ID, which is incompatible with 0-RTT.
3392
+ ssl_early_data_channel_id = 10,
3393
+ // The connection negotiated token binding, which is incompatible with 0-RTT.
3394
+ ssl_early_data_token_binding = 11,
3395
+ // The client and server ticket age were too far apart.
3396
+ ssl_early_data_ticket_age_skew = 12,
3397
+ // The value of the largest entry.
3398
+ ssl_early_data_reason_max_value = ssl_early_data_ticket_age_skew,
3399
+ };
3400
+
3401
+ // SSL_get_early_data_reason returns details why 0-RTT was accepted or rejected
3402
+ // on |ssl|. This is primarily useful on the server.
3403
+ OPENSSL_EXPORT enum ssl_early_data_reason_t SSL_get_early_data_reason(
3404
+ const SSL *ssl);
3080
3405
 
3081
3406
 
3082
3407
  // Alerts.
3083
3408
  //
3084
- // TLS and SSL 3.0 use alerts to signal error conditions. Alerts have a type
3085
- // (warning or fatal) and description. OpenSSL internally handles fatal alerts
3086
- // with dedicated error codes (see |SSL_AD_REASON_OFFSET|). Except for
3087
- // close_notify, warning alerts are silently ignored and may only be surfaced
3088
- // with |SSL_CTX_set_info_callback|.
3409
+ // TLS uses alerts to signal error conditions. Alerts have a type (warning or
3410
+ // fatal) and description. OpenSSL internally handles fatal alerts with
3411
+ // dedicated error codes (see |SSL_AD_REASON_OFFSET|). Except for close_notify,
3412
+ // warning alerts are silently ignored and may only be surfaced with
3413
+ // |SSL_CTX_set_info_callback|.
3089
3414
 
3090
3415
  // SSL_AD_REASON_OFFSET is the offset between error reasons and |SSL_AD_*|
3091
3416
  // values. Any error code under |ERR_LIB_SSL| with an error reason above this
@@ -3096,7 +3421,7 @@ OPENSSL_EXPORT int SSL_export_early_keying_material(
3096
3421
  // This value must be kept in sync with reservedReasonCode in make_errors.h
3097
3422
  #define SSL_AD_REASON_OFFSET 1000
3098
3423
 
3099
- // SSL_AD_* are alert descriptions for SSL 3.0 and TLS.
3424
+ // SSL_AD_* are alert descriptions.
3100
3425
  #define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY
3101
3426
  #define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE
3102
3427
  #define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC
@@ -3104,7 +3429,7 @@ OPENSSL_EXPORT int SSL_export_early_keying_material(
3104
3429
  #define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW
3105
3430
  #define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE
3106
3431
  #define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE
3107
- #define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE // Not used in TLS
3432
+ #define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE // Legacy SSL 3.0 value
3108
3433
  #define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE
3109
3434
  #define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE
3110
3435
  #define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED
@@ -3184,7 +3509,7 @@ OPENSSL_EXPORT int SSL_CTX_get_ex_new_index(long argl, void *argp,
3184
3509
  // SSL_get_ivs sets |*out_iv_len| to the length of the IVs for the ciphers
3185
3510
  // underlying |ssl| and sets |*out_read_iv| and |*out_write_iv| to point to the
3186
3511
  // current IVs for the read and write directions. This is only meaningful for
3187
- // connections with implicit IVs (i.e. CBC mode with SSLv3 or TLS 1.0).
3512
+ // connections with implicit IVs (i.e. CBC mode with TLS 1.0).
3188
3513
  //
3189
3514
  // It returns one on success or zero on error.
3190
3515
  OPENSSL_EXPORT int SSL_get_ivs(const SSL *ssl, const uint8_t **out_read_iv,
@@ -3213,13 +3538,6 @@ OPENSSL_EXPORT uint64_t SSL_get_write_sequence(const SSL *ssl);
3213
3538
 
3214
3539
  // Obscure functions.
3215
3540
 
3216
- // SSL_get_structure_sizes returns the sizes of the SSL, SSL_CTX and
3217
- // SSL_SESSION structures so that a test can ensure that outside code agrees on
3218
- // these values.
3219
- OPENSSL_EXPORT void SSL_get_structure_sizes(size_t *ssl_size,
3220
- size_t *ssl_ctx_size,
3221
- size_t *ssl_session_size);
3222
-
3223
3541
  // SSL_CTX_set_msg_callback installs |cb| as the message callback for |ctx|.
3224
3542
  // This callback will be called when sending or receiving low-level record
3225
3543
  // headers, complete handshake messages, ChangeCipherSpec, and alerts.
@@ -3276,11 +3594,32 @@ OPENSSL_EXPORT void (*SSL_CTX_get_keylog_callback(const SSL_CTX *ctx))(
3276
3594
  OPENSSL_EXPORT void SSL_CTX_set_current_time_cb(
3277
3595
  SSL_CTX *ctx, void (*cb)(const SSL *ssl, struct timeval *out_clock));
3278
3596
 
3279
- enum ssl_renegotiate_mode_t {
3597
+ // SSL_set_shed_handshake_config allows some of the configuration of |ssl| to be
3598
+ // freed after its handshake completes. Once configuration has been shed, APIs
3599
+ // that query it may fail. "Configuration" in this context means anything that
3600
+ // was set by the caller, as distinct from information derived from the
3601
+ // handshake. For example, |SSL_get_ciphers| queries how the |SSL| was
3602
+ // configured by the caller, and fails after configuration has been shed,
3603
+ // whereas |SSL_get_cipher| queries the result of the handshake, and is
3604
+ // unaffected by configuration shedding.
3605
+ //
3606
+ // If configuration shedding is enabled, it is an error to call |SSL_clear|.
3607
+ //
3608
+ // Note that configuration shedding as a client additionally depends on
3609
+ // renegotiation being disabled (see |SSL_set_renegotiate_mode|). If
3610
+ // renegotiation is possible, the configuration will be retained. If
3611
+ // configuration shedding is enabled and renegotiation later disabled after the
3612
+ // handshake, |SSL_set_renegotiate_mode| will shed configuration then. This may
3613
+ // be useful for clients which support renegotiation with some ALPN protocols,
3614
+ // such as HTTP/1.1, and not others, such as HTTP/2.
3615
+ OPENSSL_EXPORT void SSL_set_shed_handshake_config(SSL *ssl, int enable);
3616
+
3617
+ enum ssl_renegotiate_mode_t BORINGSSL_ENUM_INT {
3280
3618
  ssl_renegotiate_never = 0,
3281
3619
  ssl_renegotiate_once,
3282
3620
  ssl_renegotiate_freely,
3283
3621
  ssl_renegotiate_ignore,
3622
+ ssl_renegotiate_explicit,
3284
3623
  };
3285
3624
 
3286
3625
  // SSL_set_renegotiate_mode configures how |ssl|, a client, reacts to
@@ -3294,11 +3633,35 @@ enum ssl_renegotiate_mode_t {
3294
3633
  // Note that ignoring HelloRequest messages may cause the connection to stall
3295
3634
  // if the server waits for the renegotiation to complete.
3296
3635
  //
3636
+ // If set to |ssl_renegotiate_explicit|, |SSL_read| and |SSL_peek| calls which
3637
+ // encounter a HelloRequest will pause with |SSL_ERROR_WANT_RENEGOTIATE|.
3638
+ // |SSL_write| will continue to work while paused. The caller may call
3639
+ // |SSL_renegotiate| to begin the renegotiation at a later point. This mode may
3640
+ // be used if callers wish to eagerly call |SSL_peek| without triggering a
3641
+ // renegotiation.
3642
+ //
3643
+ // If configuration shedding is enabled (see |SSL_set_shed_handshake_config|),
3644
+ // configuration is released if, at any point after the handshake, renegotiation
3645
+ // is disabled. It is not possible to switch from disabling renegotiation to
3646
+ // enabling it on a given connection. Callers that condition renegotiation on,
3647
+ // e.g., ALPN must enable renegotiation before the handshake and conditionally
3648
+ // disable it afterwards.
3649
+ //
3297
3650
  // There is no support in BoringSSL for initiating renegotiations as a client
3298
3651
  // or server.
3299
3652
  OPENSSL_EXPORT void SSL_set_renegotiate_mode(SSL *ssl,
3300
3653
  enum ssl_renegotiate_mode_t mode);
3301
3654
 
3655
+ // SSL_renegotiate starts a deferred renegotiation on |ssl| if it was configured
3656
+ // with |ssl_renegotiate_explicit| and has a pending HelloRequest. It returns
3657
+ // one on success and zero on error.
3658
+ //
3659
+ // This function does not do perform any I/O. On success, a subsequent
3660
+ // |SSL_do_handshake| call will run the handshake. |SSL_write| and
3661
+ // |SSL_read| will also complete the handshake before sending or receiving
3662
+ // application data.
3663
+ OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl);
3664
+
3302
3665
  // SSL_renegotiate_pending returns one if |ssl| is in the middle of a
3303
3666
  // renegotiation.
3304
3667
  OPENSSL_EXPORT int SSL_renegotiate_pending(SSL *ssl);
@@ -3307,22 +3670,6 @@ OPENSSL_EXPORT int SSL_renegotiate_pending(SSL *ssl);
3307
3670
  // performed by |ssl|. This includes the pending renegotiation, if any.
3308
3671
  OPENSSL_EXPORT int SSL_total_renegotiations(const SSL *ssl);
3309
3672
 
3310
- enum tls13_variant_t {
3311
- tls13_default = 0,
3312
- };
3313
-
3314
- // SSL_CTX_set_tls13_variant sets which variant of TLS 1.3 we negotiate. On the
3315
- // server, if |variant| is not |tls13_default|, all variants are enabled. On the
3316
- // client, only the configured variant is enabled.
3317
- OPENSSL_EXPORT void SSL_CTX_set_tls13_variant(SSL_CTX *ctx,
3318
- enum tls13_variant_t variant);
3319
-
3320
- // SSL_set_tls13_variant sets which variant of TLS 1.3 we negotiate. On the
3321
- // server, if |variant| is not |tls13_default|, all variants are enabled. On the
3322
- // client, only the configured variant is enabled.
3323
- OPENSSL_EXPORT void SSL_set_tls13_variant(SSL *ssl,
3324
- enum tls13_variant_t variant);
3325
-
3326
3673
  // SSL_MAX_CERT_LIST_DEFAULT is the default maximum length, in bytes, of a peer
3327
3674
  // certificate chain.
3328
3675
  #define SSL_MAX_CERT_LIST_DEFAULT (1024 * 100)
@@ -3383,7 +3730,7 @@ typedef struct ssl_early_callback_ctx {
3383
3730
 
3384
3731
  // ssl_select_cert_result_t enumerates the possible results from selecting a
3385
3732
  // certificate with |select_certificate_cb|.
3386
- enum ssl_select_cert_result_t {
3733
+ enum ssl_select_cert_result_t BORINGSSL_ENUM_INT {
3387
3734
  // ssl_select_cert_success indicates that the certificate selection was
3388
3735
  // successful.
3389
3736
  ssl_select_cert_success = 1,
@@ -3414,6 +3761,8 @@ OPENSSL_EXPORT int SSL_early_callback_ctx_extension_get(
3414
3761
  // high-level operation on |ssl| to be retried at a later time, which will
3415
3762
  // result in another call to |cb|.
3416
3763
  //
3764
+ // |SSL_get_servername| may be used during this callback.
3765
+ //
3417
3766
  // Note: The |SSL_CLIENT_HELLO| is only valid for the duration of the callback
3418
3767
  // and is not valid while the handshake is paused.
3419
3768
  OPENSSL_EXPORT void SSL_CTX_set_select_certificate_cb(
@@ -3426,14 +3775,33 @@ OPENSSL_EXPORT void SSL_CTX_set_select_certificate_cb(
3426
3775
  OPENSSL_EXPORT void SSL_CTX_set_dos_protection_cb(
3427
3776
  SSL_CTX *ctx, int (*cb)(const SSL_CLIENT_HELLO *));
3428
3777
 
3429
- // SSL_ST_* are possible values for |SSL_state| and the bitmasks that make them
3430
- // up.
3778
+ // SSL_CTX_set_reverify_on_resume configures whether the certificate
3779
+ // verification callback will be used to reverify stored certificates
3780
+ // when resuming a session. This only works with |SSL_CTX_set_custom_verify|.
3781
+ // For now, this is incompatible with |SSL_VERIFY_NONE| mode, and is only
3782
+ // respected on clients.
3783
+ OPENSSL_EXPORT void SSL_CTX_set_reverify_on_resume(SSL_CTX *ctx, int enabled);
3784
+
3785
+ // SSL_set_enforce_rsa_key_usage configures whether the keyUsage extension of
3786
+ // RSA leaf certificates will be checked for consistency with the TLS
3787
+ // usage. This parameter may be set late; it will not be read until after the
3788
+ // certificate verification callback.
3789
+ OPENSSL_EXPORT void SSL_set_enforce_rsa_key_usage(SSL *ssl, int enabled);
3790
+
3791
+ // SSL_ST_* are possible values for |SSL_state|, the bitmasks that make them up,
3792
+ // and some historical values for compatibility. Only |SSL_ST_INIT| and
3793
+ // |SSL_ST_OK| are ever returned.
3431
3794
  #define SSL_ST_CONNECT 0x1000
3432
3795
  #define SSL_ST_ACCEPT 0x2000
3433
3796
  #define SSL_ST_MASK 0x0FFF
3434
3797
  #define SSL_ST_INIT (SSL_ST_CONNECT | SSL_ST_ACCEPT)
3435
3798
  #define SSL_ST_OK 0x03
3436
3799
  #define SSL_ST_RENEGOTIATE (0x04 | SSL_ST_INIT)
3800
+ #define SSL_ST_BEFORE (0x05 | SSL_ST_INIT)
3801
+
3802
+ // TLS_ST_* are aliases for |SSL_ST_*| for OpenSSL 1.1.0 compatibility.
3803
+ #define TLS_ST_OK SSL_ST_OK
3804
+ #define TLS_ST_BEFORE SSL_ST_BEFORE
3437
3805
 
3438
3806
  // SSL_CB_* are possible values for the |type| parameter in the info
3439
3807
  // callback and the bitmasks that make them up.
@@ -3537,7 +3905,8 @@ OPENSSL_EXPORT const SSL_CIPHER *SSL_get_pending_cipher(const SSL *ssl);
3537
3905
  // the SHA-256 hash of peer's certificate should be saved in memory and in the
3538
3906
  // session. This can save memory, ticket size and session cache space. If
3539
3907
  // enabled, |SSL_get_peer_certificate| will return NULL after the handshake
3540
- // completes. See the |peer_sha256| field of |SSL_SESSION| for the hash.
3908
+ // completes. See |SSL_SESSION_has_peer_sha256| and
3909
+ // |SSL_SESSION_get0_peer_sha256| to query the hash.
3541
3910
  OPENSSL_EXPORT void SSL_set_retain_only_sha256_of_client_certs(SSL *ssl,
3542
3911
  int enable);
3543
3912
 
@@ -3545,7 +3914,8 @@ OPENSSL_EXPORT void SSL_set_retain_only_sha256_of_client_certs(SSL *ssl,
3545
3914
  // only the SHA-256 hash of peer's certificate should be saved in memory and in
3546
3915
  // the session. This can save memory, ticket size and session cache space. If
3547
3916
  // enabled, |SSL_get_peer_certificate| will return NULL after the handshake
3548
- // completes. See the |peer_sha256| field of |SSL_SESSION| for the hash.
3917
+ // completes. See |SSL_SESSION_has_peer_sha256| and
3918
+ // |SSL_SESSION_get0_peer_sha256| to query the hash.
3549
3919
  OPENSSL_EXPORT void SSL_CTX_set_retain_only_sha256_of_client_certs(SSL_CTX *ctx,
3550
3920
  int enable);
3551
3921
 
@@ -3557,20 +3927,32 @@ OPENSSL_EXPORT void SSL_CTX_set_grease_enabled(SSL_CTX *ctx, int enabled);
3557
3927
  // record with |ssl|.
3558
3928
  OPENSSL_EXPORT size_t SSL_max_seal_overhead(const SSL *ssl);
3559
3929
 
3560
- // SSL_get_ticket_age_skew returns the difference, in seconds, between the
3561
- // client-sent ticket age and the server-computed value in TLS 1.3 server
3562
- // connections which resumed a session.
3563
- OPENSSL_EXPORT int32_t SSL_get_ticket_age_skew(const SSL *ssl);
3564
-
3565
3930
  // SSL_CTX_set_false_start_allowed_without_alpn configures whether connections
3566
3931
  // on |ctx| may use False Start (if |SSL_MODE_ENABLE_FALSE_START| is enabled)
3567
3932
  // without negotiating ALPN.
3568
3933
  OPENSSL_EXPORT void SSL_CTX_set_false_start_allowed_without_alpn(SSL_CTX *ctx,
3569
3934
  int allowed);
3570
3935
 
3571
- // SSL_is_draft_downgrade returns one if the TLS 1.3 anti-downgrade mechanism
3572
- // would have aborted |ssl|'s handshake and zero otherwise.
3573
- OPENSSL_EXPORT int SSL_is_draft_downgrade(const SSL *ssl);
3936
+ // SSL_CTX_set_ignore_tls13_downgrade configures whether connections on |ctx|
3937
+ // ignore the downgrade signal in the server's random value.
3938
+ OPENSSL_EXPORT void SSL_CTX_set_ignore_tls13_downgrade(SSL_CTX *ctx,
3939
+ int ignore);
3940
+
3941
+ // SSL_set_ignore_tls13_downgrade configures whether |ssl| ignores the downgrade
3942
+ // signal in the server's random value.
3943
+ OPENSSL_EXPORT void SSL_set_ignore_tls13_downgrade(SSL *ssl, int ignore);
3944
+
3945
+ // SSL_is_tls13_downgrade returns one if the TLS 1.3 anti-downgrade
3946
+ // mechanism would have aborted |ssl|'s handshake and zero otherwise.
3947
+ OPENSSL_EXPORT int SSL_is_tls13_downgrade(const SSL *ssl);
3948
+
3949
+ // SSL_set_jdk11_workaround configures whether to workaround various bugs in
3950
+ // JDK 11's TLS 1.3 implementation by disabling TLS 1.3 for such clients.
3951
+ //
3952
+ // https://bugs.openjdk.java.net/browse/JDK-8211806
3953
+ // https://bugs.openjdk.java.net/browse/JDK-8212885
3954
+ // https://bugs.openjdk.java.net/browse/JDK-8213202
3955
+ OPENSSL_EXPORT void SSL_set_jdk11_workaround(SSL *ssl, int enable);
3574
3956
 
3575
3957
 
3576
3958
  // Deprecated functions.
@@ -3722,17 +4104,14 @@ OPENSSL_EXPORT int SSL_set_tmp_rsa(SSL *ssl, const RSA *rsa);
3722
4104
  // SSL_CTX_get_read_ahead returns zero.
3723
4105
  OPENSSL_EXPORT int SSL_CTX_get_read_ahead(const SSL_CTX *ctx);
3724
4106
 
3725
- // SSL_CTX_set_read_ahead does nothing.
3726
- OPENSSL_EXPORT void SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes);
4107
+ // SSL_CTX_set_read_ahead returns one.
4108
+ OPENSSL_EXPORT int SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes);
3727
4109
 
3728
4110
  // SSL_get_read_ahead returns zero.
3729
4111
  OPENSSL_EXPORT int SSL_get_read_ahead(const SSL *ssl);
3730
4112
 
3731
- // SSL_set_read_ahead does nothing.
3732
- OPENSSL_EXPORT void SSL_set_read_ahead(SSL *ssl, int yes);
3733
-
3734
- // SSL_renegotiate put an error on the error queue and returns zero.
3735
- OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl);
4113
+ // SSL_set_read_ahead returns one.
4114
+ OPENSSL_EXPORT int SSL_set_read_ahead(SSL *ssl, int yes);
3736
4115
 
3737
4116
  // SSL_set_state does nothing.
3738
4117
  OPENSSL_EXPORT void SSL_set_state(SSL *ssl, int state);
@@ -3800,7 +4179,7 @@ OPENSSL_EXPORT const COMP_METHOD *SSL_get_current_compression(SSL *ssl);
3800
4179
  OPENSSL_EXPORT const COMP_METHOD *SSL_get_current_expansion(SSL *ssl);
3801
4180
 
3802
4181
  // SSL_get_server_tmp_key returns zero.
3803
- OPENSSL_EXPORT int *SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key);
4182
+ OPENSSL_EXPORT int SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key);
3804
4183
 
3805
4184
  // SSL_CTX_set_tmp_dh returns 1.
3806
4185
  OPENSSL_EXPORT int SSL_CTX_set_tmp_dh(SSL_CTX *ctx, const DH *dh);
@@ -3817,6 +4196,53 @@ OPENSSL_EXPORT void SSL_set_tmp_dh_callback(SSL *ssl,
3817
4196
  DH *(*cb)(SSL *ssl, int is_export,
3818
4197
  int keylength));
3819
4198
 
4199
+ // SSL_CTX_set1_sigalgs takes |num_values| ints and interprets them as pairs
4200
+ // where the first is the nid of a hash function and the second is an
4201
+ // |EVP_PKEY_*| value. It configures the signature algorithm preferences for
4202
+ // |ctx| based on them and returns one on success or zero on error.
4203
+ //
4204
+ // This API is compatible with OpenSSL. However, BoringSSL-specific code should
4205
+ // prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's
4206
+ // more convenient to codesearch for specific algorithm values.
4207
+ OPENSSL_EXPORT int SSL_CTX_set1_sigalgs(SSL_CTX *ctx, const int *values,
4208
+ size_t num_values);
4209
+
4210
+ // SSL_set1_sigalgs takes |num_values| ints and interprets them as pairs where
4211
+ // the first is the nid of a hash function and the second is an |EVP_PKEY_*|
4212
+ // value. It configures the signature algorithm preferences for |ssl| based on
4213
+ // them and returns one on success or zero on error.
4214
+ //
4215
+ // This API is compatible with OpenSSL. However, BoringSSL-specific code should
4216
+ // prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's
4217
+ // more convenient to codesearch for specific algorithm values.
4218
+ OPENSSL_EXPORT int SSL_set1_sigalgs(SSL *ssl, const int *values,
4219
+ size_t num_values);
4220
+
4221
+ // SSL_CTX_set1_sigalgs_list takes a textual specification of a set of signature
4222
+ // algorithms and configures them on |ctx|. It returns one on success and zero
4223
+ // on error. See
4224
+ // https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set1_sigalgs_list.html for
4225
+ // a description of the text format. Also note that TLS 1.3 names (e.g.
4226
+ // "rsa_pkcs1_md5_sha1") can also be used (as in OpenSSL, although OpenSSL
4227
+ // doesn't document that).
4228
+ //
4229
+ // This API is compatible with OpenSSL. However, BoringSSL-specific code should
4230
+ // prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's
4231
+ // more convenient to codesearch for specific algorithm values.
4232
+ OPENSSL_EXPORT int SSL_CTX_set1_sigalgs_list(SSL_CTX *ctx, const char *str);
4233
+
4234
+ // SSL_set1_sigalgs_list takes a textual specification of a set of signature
4235
+ // algorithms and configures them on |ssl|. It returns one on success and zero
4236
+ // on error. See
4237
+ // https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set1_sigalgs_list.html for
4238
+ // a description of the text format. Also note that TLS 1.3 names (e.g.
4239
+ // "rsa_pkcs1_md5_sha1") can also be used (as in OpenSSL, although OpenSSL
4240
+ // doesn't document that).
4241
+ //
4242
+ // This API is compatible with OpenSSL. However, BoringSSL-specific code should
4243
+ // prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's
4244
+ // more convenient to codesearch for specific algorithm values.
4245
+ OPENSSL_EXPORT int SSL_set1_sigalgs_list(SSL *ssl, const char *str);
3820
4246
 
3821
4247
  #define SSL_set_app_data(s, arg) (SSL_set_ex_data(s, 0, (char *)(arg)))
3822
4248
  #define SSL_get_app_data(s) (SSL_get_ex_data(s, 0))
@@ -3870,8 +4296,10 @@ DEFINE_STACK_OF(SSL_COMP)
3870
4296
  #define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0
3871
4297
  #define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0
3872
4298
  #define SSL_OP_NO_COMPRESSION 0
4299
+ #define SSL_OP_NO_RENEGOTIATION 0 // ssl_renegotiate_never is the default
3873
4300
  #define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0
3874
4301
  #define SSL_OP_NO_SSLv2 0
4302
+ #define SSL_OP_NO_SSLv3 0
3875
4303
  #define SSL_OP_PKCS1_CHECK_1 0
3876
4304
  #define SSL_OP_PKCS1_CHECK_2 0
3877
4305
  #define SSL_OP_SINGLE_DH_USE 0
@@ -3890,7 +4318,7 @@ OPENSSL_EXPORT int SSL_cache_hit(SSL *ssl);
3890
4318
  OPENSSL_EXPORT long SSL_get_default_timeout(const SSL *ssl);
3891
4319
 
3892
4320
  // SSL_get_version returns a string describing the TLS version used by |ssl|.
3893
- // For example, "TLSv1.2" or "SSLv3".
4321
+ // For example, "TLSv1.2" or "DTLSv1".
3894
4322
  OPENSSL_EXPORT const char *SSL_get_version(const SSL *ssl);
3895
4323
 
3896
4324
  // SSL_get_cipher_list returns the name of the |n|th cipher in the output of
@@ -3914,18 +4342,9 @@ OPENSSL_EXPORT const char *SSL_get_cipher_list(const SSL *ssl, int n);
3914
4342
  OPENSSL_EXPORT void SSL_CTX_set_client_cert_cb(
3915
4343
  SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **out_x509, EVP_PKEY **out_pkey));
3916
4344
 
3917
- #define SSL_NOTHING 1
3918
- #define SSL_WRITING 2
3919
- #define SSL_READING 3
3920
- #define SSL_X509_LOOKUP 4
3921
- #define SSL_CHANNEL_ID_LOOKUP 5
3922
- #define SSL_PENDING_SESSION 7
3923
- #define SSL_CERTIFICATE_SELECTION_PENDING 8
3924
- #define SSL_PRIVATE_KEY_OPERATION 9
3925
- #define SSL_PENDING_TICKET 10
3926
- #define SSL_EARLY_DATA_REJECTED 11
3927
- #define SSL_CERTIFICATE_VERIFY 12
3928
- #define SSL_HANDOFF 13
4345
+ #define SSL_NOTHING SSL_ERROR_NONE
4346
+ #define SSL_WRITING SSL_ERROR_WANT_WRITE
4347
+ #define SSL_READING SSL_ERROR_WANT_READ
3929
4348
 
3930
4349
  // SSL_want returns one of the above values to determine what the most recent
3931
4350
  // operation on |ssl| was blocked on. Use |SSL_get_error| instead.
@@ -3936,15 +4355,15 @@ OPENSSL_EXPORT int SSL_want(const SSL *ssl);
3936
4355
 
3937
4356
  // SSL_get_finished writes up to |count| bytes of the Finished message sent by
3938
4357
  // |ssl| to |buf|. It returns the total untruncated length or zero if none has
3939
- // been sent yet. At SSL 3.0 or TLS 1.3 and later, it returns zero.
4358
+ // been sent yet. At TLS 1.3 and later, it returns zero.
3940
4359
  //
3941
4360
  // Use |SSL_get_tls_unique| instead.
3942
4361
  OPENSSL_EXPORT size_t SSL_get_finished(const SSL *ssl, void *buf, size_t count);
3943
4362
 
3944
4363
  // SSL_get_peer_finished writes up to |count| bytes of the Finished message
3945
4364
  // received from |ssl|'s peer to |buf|. It returns the total untruncated length
3946
- // or zero if none has been received yet. At SSL 3.0 or TLS 1.3 and later, it
3947
- // returns zero.
4365
+ // or zero if none has been received yet. At TLS 1.3 and later, it returns
4366
+ // zero.
3948
4367
  //
3949
4368
  // Use |SSL_get_tls_unique| instead.
3950
4369
  OPENSSL_EXPORT size_t SSL_get_peer_finished(const SSL *ssl, void *buf,
@@ -4103,158 +4522,78 @@ OPENSSL_EXPORT SSL_SESSION *SSL_get1_session(SSL *ssl);
4103
4522
  OPENSSL_EXPORT int OPENSSL_init_ssl(uint64_t opts,
4104
4523
  const OPENSSL_INIT_SETTINGS *settings);
4105
4524
 
4106
- #if !defined(BORINGSSL_NO_CXX)
4107
- // SSL_CTX_sess_set_get_cb is a legacy C++ overload of |SSL_CTX_sess_set_get_cb|
4108
- // which supports the old callback signature.
4109
- //
4110
- // TODO(davidben): Remove this once Node is compatible with OpenSSL 1.1.0.
4111
- extern "C++" OPENSSL_EXPORT void SSL_CTX_sess_set_get_cb(
4112
- SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(SSL *ssl, uint8_t *id,
4113
- int id_len, int *out_copy));
4114
- #endif
4115
-
4525
+ // The following constants are legacy aliases for RSA-PSS with rsaEncryption
4526
+ // keys. Use the new names instead.
4527
+ #define SSL_SIGN_RSA_PSS_SHA256 SSL_SIGN_RSA_PSS_RSAE_SHA256
4528
+ #define SSL_SIGN_RSA_PSS_SHA384 SSL_SIGN_RSA_PSS_RSAE_SHA384
4529
+ #define SSL_SIGN_RSA_PSS_SHA512 SSL_SIGN_RSA_PSS_RSAE_SHA512
4116
4530
 
4117
- // Private structures.
4531
+ // SSL_set_tlsext_status_type configures a client to request OCSP stapling if
4532
+ // |type| is |TLSEXT_STATUSTYPE_ocsp| and disables it otherwise. It returns one
4533
+ // on success and zero if handshake configuration has already been shed.
4118
4534
  //
4119
- // This structures are exposed for historical reasons, but access to them is
4120
- // deprecated.
4535
+ // Use |SSL_enable_ocsp_stapling| instead.
4536
+ OPENSSL_EXPORT int SSL_set_tlsext_status_type(SSL *ssl, int type);
4121
4537
 
4122
- // TODO(davidben): Remove this forward declaration when |SSL_SESSION| is opaque.
4123
- typedef struct ssl_x509_method_st SSL_X509_METHOD;
4538
+ // SSL_get_tlsext_status_type returns |TLSEXT_STATUSTYPE_ocsp| if the client
4539
+ // requested OCSP stapling and |TLSEXT_STATUSTYPE_nothing| otherwise. On the
4540
+ // client, this reflects whether OCSP stapling was enabled via, e.g.,
4541
+ // |SSL_set_tlsext_status_type|. On the server, this is determined during the
4542
+ // handshake. It may be queried in callbacks set by |SSL_CTX_set_cert_cb|. The
4543
+ // result is undefined after the handshake completes.
4544
+ OPENSSL_EXPORT int SSL_get_tlsext_status_type(const SSL *ssl);
4124
4545
 
4125
- #define SSL_MAX_SSL_SESSION_ID_LENGTH 32
4126
- #define SSL_MAX_SID_CTX_LENGTH 32
4127
- #define SSL_MAX_MASTER_KEY_LENGTH 48
4128
-
4129
- struct ssl_session_st {
4130
- CRYPTO_refcount_t references;
4131
- uint16_t ssl_version; // what ssl version session info is being kept in here?
4132
-
4133
- // group_id is the ID of the ECDH group used to establish this session or zero
4134
- // if not applicable or unknown.
4135
- uint16_t group_id;
4136
-
4137
- // peer_signature_algorithm is the signature algorithm used to authenticate
4138
- // the peer, or zero if not applicable or unknown.
4139
- uint16_t peer_signature_algorithm;
4140
-
4141
- // master_key, in TLS 1.2 and below, is the master secret associated with the
4142
- // session. In TLS 1.3 and up, it is the resumption secret.
4143
- int master_key_length;
4144
- uint8_t master_key[SSL_MAX_MASTER_KEY_LENGTH];
4145
-
4146
- // session_id - valid?
4147
- unsigned int session_id_length;
4148
- uint8_t session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
4149
- // this is used to determine whether the session is being reused in
4150
- // the appropriate context. It is up to the application to set this,
4151
- // via SSL_new
4152
- uint8_t sid_ctx_length;
4153
- uint8_t sid_ctx[SSL_MAX_SID_CTX_LENGTH];
4154
-
4155
- char *psk_identity;
4156
-
4157
- // certs contains the certificate chain from the peer, starting with the leaf
4158
- // certificate.
4159
- STACK_OF(CRYPTO_BUFFER) *certs;
4160
-
4161
- const SSL_X509_METHOD *x509_method;
4162
-
4163
- // x509_peer is the peer's certificate.
4164
- X509 *x509_peer;
4165
-
4166
- // x509_chain is the certificate chain sent by the peer. NOTE: for historical
4167
- // reasons, when a client (so the peer is a server), the chain includes
4168
- // |peer|, but when a server it does not.
4169
- STACK_OF(X509) *x509_chain;
4170
-
4171
- // x509_chain_without_leaf is a lazily constructed copy of |x509_chain| that
4172
- // omits the leaf certificate. This exists because OpenSSL, historically,
4173
- // didn't include the leaf certificate in the chain for a server, but did for
4174
- // a client. The |x509_chain| always includes it and, if an API call requires
4175
- // a chain without, it is stored here.
4176
- STACK_OF(X509) *x509_chain_without_leaf;
4177
-
4178
- // verify_result is the result of certificate verification in the case of
4179
- // non-fatal certificate errors.
4180
- long verify_result;
4181
-
4182
- // timeout is the lifetime of the session in seconds, measured from |time|.
4183
- // This is renewable up to |auth_timeout|.
4184
- uint32_t timeout;
4185
-
4186
- // auth_timeout is the non-renewable lifetime of the session in seconds,
4187
- // measured from |time|.
4188
- uint32_t auth_timeout;
4189
-
4190
- // time is the time the session was issued, measured in seconds from the UNIX
4191
- // epoch.
4192
- uint64_t time;
4193
-
4194
- const SSL_CIPHER *cipher;
4195
-
4196
- CRYPTO_EX_DATA ex_data; // application specific data
4197
-
4198
- // These are used to make removal of session-ids more efficient and to
4199
- // implement a maximum cache size.
4200
- SSL_SESSION *prev, *next;
4201
-
4202
- // RFC4507 info
4203
- uint8_t *tlsext_tick; // Session ticket
4204
- size_t tlsext_ticklen; // Session ticket length
4205
-
4206
- CRYPTO_BUFFER *signed_cert_timestamp_list;
4207
-
4208
- // The OCSP response that came with the session.
4209
- CRYPTO_BUFFER *ocsp_response;
4210
-
4211
- // peer_sha256 contains the SHA-256 hash of the peer's certificate if
4212
- // |peer_sha256_valid| is true.
4213
- uint8_t peer_sha256[SHA256_DIGEST_LENGTH];
4214
-
4215
- // original_handshake_hash contains the handshake hash (either SHA-1+MD5 or
4216
- // SHA-2, depending on TLS version) for the original, full handshake that
4217
- // created a session. This is used by Channel IDs during resumption.
4218
- uint8_t original_handshake_hash[EVP_MAX_MD_SIZE];
4219
- uint8_t original_handshake_hash_len;
4220
-
4221
- uint32_t tlsext_tick_lifetime_hint; // Session lifetime hint in seconds
4222
-
4223
- uint32_t ticket_age_add;
4224
-
4225
- // ticket_max_early_data is the maximum amount of data allowed to be sent as
4226
- // early data. If zero, 0-RTT is disallowed.
4227
- uint32_t ticket_max_early_data;
4228
-
4229
- // early_alpn is the ALPN protocol from the initial handshake. This is only
4230
- // stored for TLS 1.3 and above in order to enforce ALPN matching for 0-RTT
4231
- // resumptions.
4232
- uint8_t *early_alpn;
4233
- size_t early_alpn_len;
4234
-
4235
- // extended_master_secret is true if the master secret in this session was
4236
- // generated using EMS and thus isn't vulnerable to the Triple Handshake
4237
- // attack.
4238
- unsigned extended_master_secret:1;
4239
-
4240
- // peer_sha256_valid is non-zero if |peer_sha256| is valid.
4241
- unsigned peer_sha256_valid:1; // Non-zero if peer_sha256 is valid
4242
-
4243
- // not_resumable is used to indicate that session resumption is disallowed.
4244
- unsigned not_resumable:1;
4245
-
4246
- // ticket_age_add_valid is non-zero if |ticket_age_add| is valid.
4247
- unsigned ticket_age_add_valid:1;
4546
+ // SSL_set_tlsext_status_ocsp_resp sets the OCSP response. It returns one on
4547
+ // success and zero on error. On success, |ssl| takes ownership of |resp|, which
4548
+ // must have been allocated by |OPENSSL_malloc|.
4549
+ //
4550
+ // Use |SSL_set_ocsp_response| instead.
4551
+ OPENSSL_EXPORT int SSL_set_tlsext_status_ocsp_resp(SSL *ssl, uint8_t *resp,
4552
+ size_t resp_len);
4248
4553
 
4249
- // is_server is true if this session was created by a server.
4250
- unsigned is_server:1;
4251
- };
4554
+ // SSL_get_tlsext_status_ocsp_resp sets |*out| to point to the OCSP response
4555
+ // from the server. It returns the length of the response. If there was no
4556
+ // response, it sets |*out| to NULL and returns zero.
4557
+ //
4558
+ // Use |SSL_get0_ocsp_response| instead.
4559
+ //
4560
+ // WARNING: the returned data is not guaranteed to be well formed.
4561
+ OPENSSL_EXPORT size_t SSL_get_tlsext_status_ocsp_resp(const SSL *ssl,
4562
+ const uint8_t **out);
4563
+
4564
+ // SSL_CTX_set_tlsext_status_cb configures the legacy OpenSSL OCSP callback and
4565
+ // returns one. Though the type signature is the same, this callback has
4566
+ // different behavior for client and server connections:
4567
+ //
4568
+ // For clients, the callback is called after certificate verification. It should
4569
+ // return one for success, zero for a bad OCSP response, and a negative number
4570
+ // for internal error. Instead, handle this as part of certificate verification.
4571
+ // (Historically, OpenSSL verified certificates just before parsing stapled OCSP
4572
+ // responses, but BoringSSL fixes this ordering. All server credentials are
4573
+ // available during verification.)
4574
+ //
4575
+ // Do not use this callback as a server. It is provided for compatibility
4576
+ // purposes only. For servers, it is called to configure server credentials. It
4577
+ // should return |SSL_TLSEXT_ERR_OK| on success, |SSL_TLSEXT_ERR_NOACK| to
4578
+ // ignore OCSP requests, or |SSL_TLSEXT_ERR_ALERT_FATAL| on error. It is usually
4579
+ // used to fetch OCSP responses on demand, which is not ideal. Instead, treat
4580
+ // OCSP responses like other server credentials, such as certificates or SCT
4581
+ // lists. Configure, store, and refresh them eagerly. This avoids downtime if
4582
+ // the CA's OCSP responder is briefly offline.
4583
+ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_cb(SSL_CTX *ctx,
4584
+ int (*callback)(SSL *ssl,
4585
+ void *arg));
4586
+
4587
+ // SSL_CTX_set_tlsext_status_arg sets additional data for
4588
+ // |SSL_CTX_set_tlsext_status_cb|'s callback and returns one.
4589
+ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
4252
4590
 
4253
4591
 
4254
4592
  // Nodejs compatibility section (hidden).
4255
4593
  //
4256
4594
  // These defines exist for node.js, with the hope that we can eliminate the
4257
4595
  // need for them over time.
4596
+
4258
4597
  #define SSLerr(function, reason) \
4259
4598
  ERR_put_error(ERR_LIB_SSL, 0, reason, __FILE__, __LINE__)
4260
4599
 
@@ -4290,6 +4629,7 @@ struct ssl_session_st {
4290
4629
  #define SSL_CTRL_GET_NUM_RENEGOTIATIONS doesnt_exist
4291
4630
  #define SSL_CTRL_GET_READ_AHEAD doesnt_exist
4292
4631
  #define SSL_CTRL_GET_RI_SUPPORT doesnt_exist
4632
+ #define SSL_CTRL_GET_SERVER_TMP_KEY doesnt_exist
4293
4633
  #define SSL_CTRL_GET_SESSION_REUSED doesnt_exist
4294
4634
  #define SSL_CTRL_GET_SESS_CACHE_MODE doesnt_exist
4295
4635
  #define SSL_CTRL_GET_SESS_CACHE_SIZE doesnt_exist
@@ -4322,6 +4662,10 @@ struct ssl_session_st {
4322
4662
  #define SSL_CTRL_SET_TMP_RSA doesnt_exist
4323
4663
  #define SSL_CTRL_SET_TMP_RSA_CB doesnt_exist
4324
4664
 
4665
+ // |BORINGSSL_PREFIX| already makes each of these symbols into macros, so there
4666
+ // is no need to define conflicting macros.
4667
+ #if !defined(BORINGSSL_PREFIX)
4668
+
4325
4669
  #define DTLSv1_get_timeout DTLSv1_get_timeout
4326
4670
  #define DTLSv1_handle_timeout DTLSv1_handle_timeout
4327
4671
  #define SSL_CTX_add0_chain_cert SSL_CTX_add0_chain_cert
@@ -4391,6 +4735,8 @@ struct ssl_session_st {
4391
4735
  #define SSL_set_tmp_rsa SSL_set_tmp_rsa
4392
4736
  #define SSL_total_renegotiations SSL_total_renegotiations
4393
4737
 
4738
+ #endif // !defined(BORINGSSL_PREFIX)
4739
+
4394
4740
 
4395
4741
  #if defined(__cplusplus)
4396
4742
  } // extern C
@@ -4399,11 +4745,13 @@ struct ssl_session_st {
4399
4745
 
4400
4746
  extern "C++" {
4401
4747
 
4402
- namespace bssl {
4748
+ BSSL_NAMESPACE_BEGIN
4403
4749
 
4404
4750
  BORINGSSL_MAKE_DELETER(SSL, SSL_free)
4405
4751
  BORINGSSL_MAKE_DELETER(SSL_CTX, SSL_CTX_free)
4752
+ BORINGSSL_MAKE_UP_REF(SSL_CTX, SSL_CTX_up_ref)
4406
4753
  BORINGSSL_MAKE_DELETER(SSL_SESSION, SSL_SESSION_free)
4754
+ BORINGSSL_MAKE_UP_REF(SSL_SESSION, SSL_SESSION_up_ref)
4407
4755
 
4408
4756
  enum class OpenRecordResult {
4409
4757
  kOK,
@@ -4478,10 +4826,10 @@ OPENSSL_EXPORT bool SealRecord(SSL *ssl, Span<uint8_t> out_prefix,
4478
4826
  // state of the connection.
4479
4827
  //
4480
4828
  // Elsewhere, a fresh |SSL| can be used with |SSL_apply_handoff| to continue
4481
- // the connection. The connection from the client is fed into this |SSL| until
4482
- // the handshake completes normally. At this point (and only at this point),
4483
- // |SSL_serialize_handback| can be called to serialize the result of the
4484
- // handshake.
4829
+ // the connection. The connection from the client is fed into this |SSL|, and
4830
+ // the handshake resumed. When the handshake stops again and |SSL_get_error|
4831
+ // indicates |SSL_ERROR_HANDBACK|, |SSL_serialize_handback| should be called to
4832
+ // serialize the state of the handshake again.
4485
4833
  //
4486
4834
  // Back at the first location, a fresh |SSL| can be used with
4487
4835
  // |SSL_apply_handback|. Then the client's connection can be processed mostly
@@ -4489,7 +4837,7 @@ OPENSSL_EXPORT bool SealRecord(SSL *ssl, Span<uint8_t> out_prefix,
4489
4837
  //
4490
4838
  // Lastly, when a connection is in the handoff state, whether or not
4491
4839
  // |SSL_serialize_handoff| is called, |SSL_decline_handoff| will move it back
4492
- // into a normal state where the connection can procede without impact.
4840
+ // into a normal state where the connection can proceed without impact.
4493
4841
  //
4494
4842
  // WARNING: Currently only works with TLS 1.0–1.2.
4495
4843
  // WARNING: The serialisation formats are not yet stable: version skew may be
@@ -4502,13 +4850,23 @@ OPENSSL_EXPORT bool SealRecord(SSL *ssl, Span<uint8_t> out_prefix,
4502
4850
  // WARNING: |SSL_apply_handoff| may trigger “msg” callback calls.
4503
4851
 
4504
4852
  OPENSSL_EXPORT void SSL_CTX_set_handoff_mode(SSL_CTX *ctx, bool on);
4505
- OPENSSL_EXPORT bool SSL_serialize_handoff(const SSL *ssl, CBB *out);
4853
+ OPENSSL_EXPORT void SSL_set_handoff_mode(SSL *SSL, bool on);
4854
+ OPENSSL_EXPORT bool SSL_serialize_handoff(const SSL *ssl, CBB *out,
4855
+ SSL_CLIENT_HELLO *out_hello);
4506
4856
  OPENSSL_EXPORT bool SSL_decline_handoff(SSL *ssl);
4507
4857
  OPENSSL_EXPORT bool SSL_apply_handoff(SSL *ssl, Span<const uint8_t> handoff);
4508
4858
  OPENSSL_EXPORT bool SSL_serialize_handback(const SSL *ssl, CBB *out);
4509
4859
  OPENSSL_EXPORT bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback);
4510
4860
 
4511
- } // namespace bssl
4861
+ // SSL_get_traffic_secrets sets |*out_read_traffic_secret| and
4862
+ // |*out_write_traffic_secret| to reference the TLS 1.3 traffic secrets for
4863
+ // |ssl|. This function is only valid on TLS 1.3 connections that have
4864
+ // completed the handshake. It returns true on success and false on error.
4865
+ OPENSSL_EXPORT bool SSL_get_traffic_secrets(
4866
+ const SSL *ssl, Span<const uint8_t> *out_read_traffic_secret,
4867
+ Span<const uint8_t> *out_write_traffic_secret);
4868
+
4869
+ BSSL_NAMESPACE_END
4512
4870
 
4513
4871
  } // extern C++
4514
4872
 
@@ -4703,6 +5061,22 @@ OPENSSL_EXPORT bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback);
4703
5061
  #define SSL_R_NEGOTIATED_TB_WITHOUT_EMS_OR_RI 285
4704
5062
  #define SSL_R_SERVER_ECHOED_INVALID_SESSION_ID 286
4705
5063
  #define SSL_R_PRIVATE_KEY_OPERATION_FAILED 287
5064
+ #define SSL_R_SECOND_SERVERHELLO_VERSION_MISMATCH 288
5065
+ #define SSL_R_OCSP_CB_ERROR 289
5066
+ #define SSL_R_SSL_SESSION_ID_TOO_LONG 290
5067
+ #define SSL_R_APPLICATION_DATA_ON_SHUTDOWN 291
5068
+ #define SSL_R_CERT_DECOMPRESSION_FAILED 292
5069
+ #define SSL_R_UNCOMPRESSED_CERT_TOO_LARGE 293
5070
+ #define SSL_R_UNKNOWN_CERT_COMPRESSION_ALG 294
5071
+ #define SSL_R_INVALID_SIGNATURE_ALGORITHM 295
5072
+ #define SSL_R_DUPLICATE_SIGNATURE_ALGORITHM 296
5073
+ #define SSL_R_TLS13_DOWNGRADE 297
5074
+ #define SSL_R_QUIC_INTERNAL_ERROR 298
5075
+ #define SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED 299
5076
+ #define SSL_R_TOO_MUCH_READ_EARLY_DATA 300
5077
+ #define SSL_R_INVALID_DELEGATED_CREDENTIAL 301
5078
+ #define SSL_R_KEY_USAGE_BIT_INCORRECT 302
5079
+ #define SSL_R_INCONSISTENT_CLIENT_HELLO 303
4706
5080
  #define SSL_R_SSLV3_ALERT_CLOSE_NOTIFY 1000
4707
5081
  #define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
4708
5082
  #define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
@@ -4735,6 +5109,5 @@ OPENSSL_EXPORT bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback);
4735
5109
  #define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114
4736
5110
  #define SSL_R_TLSV1_UNKNOWN_PSK_IDENTITY 1115
4737
5111
  #define SSL_R_TLSV1_CERTIFICATE_REQUIRED 1116
4738
- #define SSL_R_TOO_MUCH_READ_EARLY_DATA 1117
4739
5112
 
4740
5113
  #endif // OPENSSL_HEADER_SSL_H