grpc 1.38.0 → 1.40.0

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 (340) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +68 -21
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +23 -29
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +21 -36
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +33 -19
  11. data/include/grpc/impl/codegen/port_platform.h +41 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +415 -249
  13. data/src/core/ext/filters/client_channel/client_channel.h +42 -18
  14. data/src/core/ext/filters/client_channel/config_selector.h +19 -6
  15. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  16. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  17. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +7 -8
  19. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
  20. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -5
  21. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
  24. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -6
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -36
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -22
  27. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +68 -103
  29. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
  30. data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  34. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  35. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  36. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +116 -76
  37. data/src/core/ext/filters/client_channel/retry_filter.cc +967 -544
  38. data/src/core/ext/filters/client_channel/retry_service_config.cc +57 -28
  39. data/src/core/ext/filters/client_channel/retry_service_config.h +9 -3
  40. data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
  41. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  42. data/src/core/ext/filters/http/client/http_client_filter.cc +5 -2
  43. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -1
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  46. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
  47. data/src/core/{lib/event_engine/slice_allocator.cc → ext/transport/chttp2/transport/chttp2_slice_allocator.cc} +23 -16
  48. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +12 -10
  50. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
  51. data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
  52. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
  53. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
  54. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +639 -752
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +190 -69
  56. data/src/core/ext/transport/chttp2/transport/internal.h +2 -1
  57. data/src/core/ext/transport/chttp2/transport/parsing.cc +72 -56
  58. data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
  59. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  60. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
  61. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
  62. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
  63. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
  64. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
  65. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
  66. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
  67. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
  68. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
  69. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
  73. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
  74. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
  75. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
  76. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
  77. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
  78. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
  79. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
  80. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
  81. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
  82. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
  83. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
  84. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
  85. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
  86. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
  87. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
  88. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
  89. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
  90. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
  91. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
  92. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
  93. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
  94. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
  95. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
  96. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
  97. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
  98. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
  99. data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
  100. data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
  101. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
  102. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
  103. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
  104. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
  105. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
  106. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
  107. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
  108. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
  109. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
  110. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
  111. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
  112. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
  113. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
  114. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
  115. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
  116. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
  117. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
  118. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
  119. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
  120. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
  121. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
  122. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
  123. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
  124. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
  125. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  126. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
  127. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
  128. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
  129. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
  130. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
  131. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
  132. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
  133. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
  134. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
  135. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
  136. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
  137. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
  138. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
  139. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  140. data/src/core/ext/xds/xds_api.cc +582 -257
  141. data/src/core/ext/xds/xds_api.h +46 -8
  142. data/src/core/ext/xds/xds_bootstrap.cc +4 -1
  143. data/src/core/ext/xds/xds_client.cc +66 -43
  144. data/src/core/ext/xds/xds_client.h +0 -4
  145. data/src/core/ext/xds/xds_http_filters.cc +3 -2
  146. data/src/core/ext/xds/xds_http_filters.h +3 -0
  147. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  148. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  149. data/src/core/lib/channel/call_tracer.h +85 -0
  150. data/src/core/lib/channel/channel_stack.h +1 -1
  151. data/src/core/lib/channel/channelz.h +3 -0
  152. data/src/core/lib/channel/context.h +3 -0
  153. data/src/core/lib/channel/status_util.h +4 -0
  154. data/src/core/lib/compression/stream_compression.h +1 -1
  155. data/src/core/lib/compression/stream_compression_gzip.h +1 -1
  156. data/src/core/lib/compression/stream_compression_identity.h +1 -1
  157. data/src/core/lib/debug/stats.h +1 -1
  158. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  159. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  160. data/src/core/lib/event_engine/event_engine.cc +50 -0
  161. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  162. data/src/core/lib/event_engine/sockaddr.h +44 -0
  163. data/src/core/lib/gpr/murmur_hash.cc +4 -2
  164. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  165. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  166. data/src/core/lib/gprpp/orphanable.h +3 -3
  167. data/src/core/lib/gprpp/status_helper.h +3 -0
  168. data/src/core/lib/gprpp/sync.h +2 -30
  169. data/src/core/lib/iomgr/buffer_list.cc +1 -1
  170. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  171. data/src/core/lib/iomgr/error.cc +5 -4
  172. data/src/core/lib/iomgr/error.h +1 -1
  173. data/src/core/lib/iomgr/ev_apple.h +1 -1
  174. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  175. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  176. data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
  177. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  178. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  179. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  180. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  181. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  182. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  183. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  184. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  185. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  186. data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
  187. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  188. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  189. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  190. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  191. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  192. data/src/core/lib/iomgr/iomgr.cc +1 -1
  193. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  194. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  195. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  196. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  197. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  198. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  199. data/src/core/lib/iomgr/port.h +7 -5
  200. data/src/core/lib/iomgr/python_util.h +1 -1
  201. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  202. data/src/core/lib/iomgr/resolve_address.h +6 -0
  203. data/src/core/lib/iomgr/resource_quota.cc +2 -0
  204. data/src/core/lib/iomgr/sockaddr.h +1 -0
  205. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  206. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  207. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  208. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  209. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  210. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -0
  211. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  212. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  213. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  214. data/src/core/lib/iomgr/tcp_server_posix.cc +7 -0
  215. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  216. data/src/core/lib/iomgr/timer.h +6 -1
  217. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  218. data/src/core/lib/json/json_reader.cc +1 -2
  219. data/src/core/lib/matchers/matchers.cc +8 -20
  220. data/src/core/lib/matchers/matchers.h +2 -1
  221. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  222. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  223. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  224. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  225. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  226. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  227. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +49 -0
  228. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
  229. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  230. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  231. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  232. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  233. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -18
  234. data/src/core/lib/security/transport/security_handshaker.cc +12 -4
  235. data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
  236. data/src/core/lib/slice/slice.cc +12 -2
  237. data/src/core/lib/slice/slice_internal.h +1 -0
  238. data/src/core/lib/surface/call.cc +26 -7
  239. data/src/core/lib/surface/call.h +11 -0
  240. data/src/core/lib/surface/completion_queue.cc +22 -22
  241. data/src/core/lib/surface/completion_queue.h +1 -1
  242. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  243. data/src/core/lib/surface/init.cc +1 -3
  244. data/src/core/lib/surface/init.h +10 -1
  245. data/src/core/lib/surface/server.cc +3 -1
  246. data/src/core/lib/surface/server.h +3 -3
  247. data/src/core/lib/surface/version.cc +2 -4
  248. data/src/core/lib/transport/error_utils.cc +2 -2
  249. data/src/core/lib/transport/metadata_batch.cc +13 -2
  250. data/src/core/lib/transport/metadata_batch.h +7 -0
  251. data/src/core/lib/transport/transport.h +2 -0
  252. data/src/core/lib/transport/transport_op_string.cc +1 -1
  253. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  254. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  255. data/src/ruby/ext/grpc/extconf.rb +2 -0
  256. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  257. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  258. data/src/ruby/lib/grpc/version.rb +1 -1
  259. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  260. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  261. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  262. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  264. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  277. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  278. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  279. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  280. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  281. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  282. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  283. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  284. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  286. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  288. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  289. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  295. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  296. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  297. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  298. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  299. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  300. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  301. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  302. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  303. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  304. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  305. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  306. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  307. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  308. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  309. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  310. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  311. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  312. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  313. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  314. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  315. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  316. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  317. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  318. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  319. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  320. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  321. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  322. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  323. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  324. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  325. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  326. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  327. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  328. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  329. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  331. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  332. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  333. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  334. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  336. data/third_party/xxhash/xxhash.h +77 -195
  337. metadata +81 -39
  338. data/src/core/lib/gpr/arena.h +0 -47
  339. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  340. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -250,3 +250,34 @@ int i2d_X509_CRL_tbs(X509_CRL *crl, unsigned char **outp)
250
250
  {
251
251
  return i2d_X509_CRL_INFO(crl->crl, outp);
252
252
  }
253
+
254
+ int X509_CRL_set1_signature_algo(X509_CRL *crl, const X509_ALGOR *algo)
255
+ {
256
+ /* TODO(davidben): Const-correct generated ASN.1 dup functions.
257
+ * Alternatively, when the types are hidden and we can embed required fields
258
+ * directly in structs, import |X509_ALGOR_copy| from upstream. */
259
+ X509_ALGOR *copy1 = X509_ALGOR_dup((X509_ALGOR *)algo);
260
+ X509_ALGOR *copy2 = X509_ALGOR_dup((X509_ALGOR *)algo);
261
+ if (copy1 == NULL || copy2 == NULL) {
262
+ X509_ALGOR_free(copy1);
263
+ X509_ALGOR_free(copy2);
264
+ return 0;
265
+ }
266
+
267
+ X509_ALGOR_free(crl->sig_alg);
268
+ crl->sig_alg = copy1;
269
+ X509_ALGOR_free(crl->crl->sig_alg);
270
+ crl->crl->sig_alg = copy2;
271
+ return 1;
272
+ }
273
+
274
+ int X509_CRL_set1_signature_value(X509_CRL *crl, const uint8_t *sig,
275
+ size_t sig_len)
276
+ {
277
+ if (!ASN1_STRING_set(crl->signature, sig, sig_len)) {
278
+ return 0;
279
+ }
280
+ crl->signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
281
+ crl->signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;
282
+ return 1;
283
+ }
@@ -59,6 +59,9 @@
59
59
  #include <openssl/obj.h>
60
60
  #include <openssl/x509.h>
61
61
 
62
+ #include "internal.h"
63
+
64
+
62
65
  int X509_REQ_set_version(X509_REQ *x, long version)
63
66
  {
64
67
  if (x == NULL)
@@ -66,6 +66,9 @@
66
66
  #include <openssl/rsa.h>
67
67
  #include <openssl/stack.h>
68
68
 
69
+ #include "internal.h"
70
+
71
+
69
72
  int X509_verify(X509 *x509, EVP_PKEY *pkey)
70
73
  {
71
74
  if (X509_ALGOR_cmp(x509->sig_alg, x509->cert_info->signature)) {
@@ -60,17 +60,16 @@
60
60
  #include <openssl/thread.h>
61
61
  #include <openssl/x509.h>
62
62
 
63
+ #include "internal.h"
64
+
65
+
63
66
  /*
64
67
  * X509_REQ_INFO is handled in an unusual way to get round invalid encodings.
65
68
  * Some broken certificate requests don't encode the attributes field if it
66
69
  * is empty. This is in violation of PKCS#10 but we need to tolerate it. We
67
70
  * do this by making the attributes field OPTIONAL then using the callback to
68
71
  * initialise it to an empty STACK. This means that the field will be
69
- * correctly encoded unless we NULL out the field. As a result we no longer
70
- * need the req_kludge field because the information is now contained in the
71
- * attributes field: 1. If it is NULL then it's the invalid omission. 2. If
72
- * it is empty it is the correct encoding. 3. If it is not empty then some
73
- * attributes are present.
72
+ * correctly encoded unless we NULL out the field.
74
73
  */
75
74
 
76
75
  static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
@@ -90,9 +89,7 @@ ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = {
90
89
  ASN1_SIMPLE(X509_REQ_INFO, version, ASN1_INTEGER),
91
90
  ASN1_SIMPLE(X509_REQ_INFO, subject, X509_NAME),
92
91
  ASN1_SIMPLE(X509_REQ_INFO, pubkey, X509_PUBKEY),
93
- /* This isn't really OPTIONAL but it gets round invalid
94
- * encodings
95
- */
92
+ /* This isn't really OPTIONAL but it gets around invalid encodings. */
96
93
  ASN1_IMP_SET_OF_OPT(X509_REQ_INFO, attributes, X509_ATTRIBUTE, 0)
97
94
  } ASN1_SEQUENCE_END_enc(X509_REQ_INFO, X509_REQ_INFO)
98
95
 
@@ -61,6 +61,11 @@
61
61
  #include <openssl/x509.h>
62
62
 
63
63
 
64
+ struct X509_sig_st {
65
+ X509_ALGOR *algor;
66
+ ASN1_OCTET_STRING *digest;
67
+ } /* X509_SIG */;
68
+
64
69
  ASN1_SEQUENCE(X509_SIG) = {
65
70
  ASN1_SIMPLE(X509_SIG, algor, X509_ALGOR),
66
71
  ASN1_SIMPLE(X509_SIG, digest, ASN1_OCTET_STRING)
@@ -61,6 +61,9 @@
61
61
  #include <openssl/obj.h>
62
62
  #include <openssl/x509.h>
63
63
 
64
+ #include "internal.h"
65
+
66
+
64
67
  /*
65
68
  * X509_CERT_AUX routines. These are used to encode additional user
66
69
  * modifiable data about a certificate. This data is appended to the X509
@@ -53,6 +53,13 @@ OPENSSL_EXPORT int x509v3_looks_like_dns_name(const unsigned char *in,
53
53
  // invalid.
54
54
  int x509v3_cache_extensions(X509 *x);
55
55
 
56
+ // x509v3_a2i_ipadd decodes |ipasc| as an IPv4 or IPv6 address. IPv6 addresses
57
+ // use colon-separated syntax while IPv4 addresses use dotted decimal syntax. If
58
+ // it decodes an IPv4 address, it writes the result to the first four bytes of
59
+ // |ipout| and returns four. If it decodes an IPv6 address, it writes the result
60
+ // to all 16 bytes of |ipout| and returns 16. Otherwise, it returns zero.
61
+ int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc);
62
+
56
63
 
57
64
  #if defined(__cplusplus)
58
65
  } /* extern C */
@@ -440,7 +440,7 @@ int x509v3_cache_extensions(X509 *x)
440
440
  if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL))
441
441
  x->ex_flags |= EXFLAG_INVALID;
442
442
  /* V1 should mean no extensions ... */
443
- if (X509_get_version(x) == X509V1_VERSION)
443
+ if (X509_get_version(x) == X509_VERSION_1)
444
444
  x->ex_flags |= EXFLAG_V1;
445
445
  /* Handle basic constraints */
446
446
  if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &j, NULL))) {
@@ -1112,7 +1112,7 @@ int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags)
1112
1112
 
1113
1113
  if (ipasc == NULL)
1114
1114
  return -2;
1115
- iplen = (size_t)a2i_ipadd(ipout, ipasc);
1115
+ iplen = (size_t)x509v3_a2i_ipadd(ipout, ipasc);
1116
1116
  if (iplen == 0)
1117
1117
  return -2;
1118
1118
  return do_x509_check(x, (char *)ipout, iplen, flags, GEN_IPADD, NULL);
@@ -1129,10 +1129,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc)
1129
1129
  ASN1_OCTET_STRING *ret;
1130
1130
  int iplen;
1131
1131
 
1132
- /* If string contains a ':' assume IPv6 */
1133
-
1134
- iplen = a2i_ipadd(ipout, ipasc);
1135
-
1132
+ iplen = x509v3_a2i_ipadd(ipout, ipasc);
1136
1133
  if (!iplen)
1137
1134
  return NULL;
1138
1135
 
@@ -1161,12 +1158,12 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
1161
1158
  p = iptmp + (p - ipasc);
1162
1159
  *p++ = 0;
1163
1160
 
1164
- iplen1 = a2i_ipadd(ipout, iptmp);
1161
+ iplen1 = x509v3_a2i_ipadd(ipout, iptmp);
1165
1162
 
1166
1163
  if (!iplen1)
1167
1164
  goto err;
1168
1165
 
1169
- iplen2 = a2i_ipadd(ipout + iplen1, p);
1166
+ iplen2 = x509v3_a2i_ipadd(ipout + iplen1, p);
1170
1167
 
1171
1168
  OPENSSL_free(iptmp);
1172
1169
  iptmp = NULL;
@@ -1190,7 +1187,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
1190
1187
  return NULL;
1191
1188
  }
1192
1189
 
1193
- int a2i_ipadd(unsigned char *ipout, const char *ipasc)
1190
+ int x509v3_a2i_ipadd(unsigned char *ipout, const char *ipasc)
1194
1191
  {
1195
1192
  /* If string contains a ':' assume IPv6 */
1196
1193
 
@@ -122,7 +122,7 @@ OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_192_gcm(void);
122
122
  OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_gcm(void);
123
123
 
124
124
  // EVP_aead_chacha20_poly1305 is the AEAD built from ChaCha20 and
125
- // Poly1305 as described in RFC 7539.
125
+ // Poly1305 as described in RFC 8439.
126
126
  OPENSSL_EXPORT const EVP_AEAD *EVP_aead_chacha20_poly1305(void);
127
127
 
128
128
  // EVP_aead_xchacha20_poly1305 is ChaCha20-Poly1305 with an extended nonce that
@@ -124,7 +124,72 @@
124
124
  // - Armv8.5-A Branch Target Identification
125
125
  // features which require emitting a .note.gnu.property section with the
126
126
  // appropriate architecture-dependent feature bits set.
127
- // Read more: "ELF for the Arm® 64-bit Architecture"
127
+ //
128
+ // |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to
129
+ // PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be
130
+ // used immediately before saving the LR register (x30) to the stack.
131
+ // |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring
132
+ // it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone
133
+ // with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also
134
+ // have the same value at the two points. For example:
135
+ //
136
+ // .global f
137
+ // f:
138
+ // AARCH64_SIGN_LINK_REGISTER
139
+ // stp x29, x30, [sp, #-96]!
140
+ // mov x29, sp
141
+ // ...
142
+ // ldp x29, x30, [sp], #96
143
+ // AARCH64_VALIDATE_LINK_REGISTER
144
+ // ret
145
+ //
146
+ // |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or
147
+ // |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an
148
+ // indirect call target. In particular, all symbols exported from a file must
149
+ // begin with one of these macros. For example, a leaf function that does not
150
+ // save LR can instead use |AARCH64_VALID_CALL_TARGET|:
151
+ //
152
+ // .globl return_zero
153
+ // return_zero:
154
+ // AARCH64_VALID_CALL_TARGET
155
+ // mov x0, #0
156
+ // ret
157
+ //
158
+ // A non-leaf function which does not immediately save LR may need both macros
159
+ // because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function
160
+ // may jump to an alternate implementation before setting up the stack:
161
+ //
162
+ // .globl with_early_jump
163
+ // with_early_jump:
164
+ // AARCH64_VALID_CALL_TARGET
165
+ // cmp x0, #128
166
+ // b.lt .Lwith_early_jump_128
167
+ // AARCH64_SIGN_LINK_REGISTER
168
+ // stp x29, x30, [sp, #-96]!
169
+ // mov x29, sp
170
+ // ...
171
+ // ldp x29, x30, [sp], #96
172
+ // AARCH64_VALIDATE_LINK_REGISTER
173
+ // ret
174
+ //
175
+ // .Lwith_early_jump_128:
176
+ // ...
177
+ // ret
178
+ //
179
+ // These annotations are only required with indirect calls. Private symbols that
180
+ // are only the target of direct calls do not require annotations. Also note
181
+ // that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not
182
+ // indirect jumps (BR). Indirect jumps in assembly are currently not supported
183
+ // and would require a macro for BTI 'j'.
184
+ //
185
+ // Although not necessary, it is safe to use these macros in 32-bit ARM
186
+ // assembly. This may be used to simplify dual 32-bit and 64-bit files.
187
+ //
188
+ // References:
189
+ // - "ELF for the Arm® 64-bit Architecture"
190
+ // https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst
191
+ // - "Providing protection for complex software"
192
+ // https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
128
193
 
129
194
  #if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
130
195
  #define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has Branch Target Identification
@@ -160,10 +160,6 @@ extern "C" {
160
160
 
161
161
  #if defined(__ANDROID_API__)
162
162
  #define OPENSSL_ANDROID
163
- #if defined(BORINGSSL_FIPS)
164
- // The FIPS module on Android passively receives entropy.
165
- #define BORINGSSL_FIPS_PASSIVE_ENTROPY
166
- #endif
167
163
  #endif
168
164
 
169
165
  #if defined(__FreeBSD__)
@@ -199,7 +195,7 @@ extern "C" {
199
195
  // A consumer may use this symbol in the preprocessor to temporarily build
200
196
  // against multiple revisions of BoringSSL at the same time. It is not
201
197
  // recommended to do so for longer than is necessary.
202
- #define BORINGSSL_API_VERSION 14
198
+ #define BORINGSSL_API_VERSION 16
203
199
 
204
200
  #if defined(BORINGSSL_SHARED_LIBRARY)
205
201
 
@@ -376,7 +372,6 @@ typedef struct X509_info_st X509_INFO;
376
372
  typedef struct X509_name_entry_st X509_NAME_ENTRY;
377
373
  typedef struct X509_name_st X509_NAME;
378
374
  typedef struct X509_pubkey_st X509_PUBKEY;
379
- typedef struct X509_req_info_st X509_REQ_INFO;
380
375
  typedef struct X509_req_st X509_REQ;
381
376
  typedef struct X509_sig_st X509_SIG;
382
377
  typedef struct X509_val_st X509_VAL;
@@ -409,6 +404,11 @@ typedef struct evp_aead_st EVP_AEAD;
409
404
  typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
410
405
  typedef struct evp_cipher_st EVP_CIPHER;
411
406
  typedef struct evp_encode_ctx_st EVP_ENCODE_CTX;
407
+ typedef struct evp_hpke_aead_st EVP_HPKE_AEAD;
408
+ typedef struct evp_hpke_ctx_st EVP_HPKE_CTX;
409
+ typedef struct evp_hpke_kdf_st EVP_HPKE_KDF;
410
+ typedef struct evp_hpke_kem_st EVP_HPKE_KEM;
411
+ typedef struct evp_hpke_key_st EVP_HPKE_KEY;
412
412
  typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
413
413
  typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
414
414
  typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
@@ -431,7 +431,7 @@ typedef struct spake2_ctx_st SPAKE2_CTX;
431
431
  typedef struct srtp_protection_profile_st SRTP_PROTECTION_PROFILE;
432
432
  typedef struct ssl_cipher_st SSL_CIPHER;
433
433
  typedef struct ssl_ctx_st SSL_CTX;
434
- typedef struct ssl_ech_server_config_list_st SSL_ECH_SERVER_CONFIG_LIST;
434
+ typedef struct ssl_ech_keys_st SSL_ECH_KEYS;
435
435
  typedef struct ssl_method_st SSL_METHOD;
436
436
  typedef struct ssl_private_key_method_st SSL_PRIVATE_KEY_METHOD;
437
437
  typedef struct ssl_quic_method_st SSL_QUIC_METHOD;
@@ -537,8 +537,39 @@ class StackAllocated {
537
537
  StackAllocated() { init(&ctx_); }
538
538
  ~StackAllocated() { cleanup(&ctx_); }
539
539
 
540
- StackAllocated(const StackAllocated<T, CleanupRet, init, cleanup> &) = delete;
541
- T& operator=(const StackAllocated<T, CleanupRet, init, cleanup> &) = delete;
540
+ StackAllocated(const StackAllocated &) = delete;
541
+ StackAllocated& operator=(const StackAllocated &) = delete;
542
+
543
+ T *get() { return &ctx_; }
544
+ const T *get() const { return &ctx_; }
545
+
546
+ T *operator->() { return &ctx_; }
547
+ const T *operator->() const { return &ctx_; }
548
+
549
+ void Reset() {
550
+ cleanup(&ctx_);
551
+ init(&ctx_);
552
+ }
553
+
554
+ private:
555
+ T ctx_;
556
+ };
557
+
558
+ template <typename T, typename CleanupRet, void (*init)(T *),
559
+ CleanupRet (*cleanup)(T *), void (*move)(T *, T *)>
560
+ class StackAllocatedMovable {
561
+ public:
562
+ StackAllocatedMovable() { init(&ctx_); }
563
+ ~StackAllocatedMovable() { cleanup(&ctx_); }
564
+
565
+ StackAllocatedMovable(StackAllocatedMovable &&other) {
566
+ init(&ctx_);
567
+ move(&ctx_, &other.ctx_);
568
+ }
569
+ StackAllocatedMovable &operator=(StackAllocatedMovable &&other) {
570
+ move(&ctx_, &other.ctx_);
571
+ return *this;
572
+ }
542
573
 
543
574
  T *get() { return &ctx_; }
544
575
  const T *get() const { return &ctx_; }
@@ -51,6 +51,7 @@ struct cbs_st {
51
51
  // Defining any constructors requires we explicitly default the others.
52
52
  cbs_st() = default;
53
53
  cbs_st(const cbs_st &) = default;
54
+ cbs_st &operator=(const cbs_st &) = default;
54
55
  #endif
55
56
  };
56
57
 
@@ -23,7 +23,7 @@ extern "C" {
23
23
 
24
24
  // ChaCha20.
25
25
  //
26
- // ChaCha20 is a stream cipher. See https://tools.ietf.org/html/rfc7539.
26
+ // ChaCha20 is a stream cipher. See https://tools.ietf.org/html/rfc8439.
27
27
 
28
28
 
29
29
  // CRYPTO_chacha_20 encrypts |in_len| bytes from |in| with the given key and
@@ -124,6 +124,10 @@ OPENSSL_EXPORT void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
124
124
  // copy of |in|. It returns one on success and zero on allocation failure.
125
125
  OPENSSL_EXPORT int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
126
126
 
127
+ // EVP_MD_CTX_move sets |out|, which must already be initialised, to the hash
128
+ // state in |in|. |in| is mutated and left in an empty state.
129
+ OPENSSL_EXPORT void EVP_MD_CTX_move(EVP_MD_CTX *out, EVP_MD_CTX *in);
130
+
127
131
  // EVP_MD_CTX_reset calls |EVP_MD_CTX_cleanup| followed by |EVP_MD_CTX_init|. It
128
132
  // returns one.
129
133
  OPENSSL_EXPORT int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
@@ -324,8 +328,8 @@ BSSL_NAMESPACE_BEGIN
324
328
  BORINGSSL_MAKE_DELETER(EVP_MD_CTX, EVP_MD_CTX_free)
325
329
 
326
330
  using ScopedEVP_MD_CTX =
327
- internal::StackAllocated<EVP_MD_CTX, int, EVP_MD_CTX_init,
328
- EVP_MD_CTX_cleanup>;
331
+ internal::StackAllocatedMovable<EVP_MD_CTX, int, EVP_MD_CTX_init,
332
+ EVP_MD_CTX_cleanup, EVP_MD_CTX_move>;
329
333
 
330
334
  BSSL_NAMESPACE_END
331
335
 
@@ -73,6 +73,9 @@ extern "C" {
73
73
  // space. On successful exit, |*sig_len| is set to the actual number of bytes
74
74
  // written. The |type| argument should be zero. It returns one on success and
75
75
  // zero otherwise.
76
+ //
77
+ // WARNING: |digest| must be the output of some hash function on the data to be
78
+ // signed. Passing unhashed inputs will not result in a secure signature scheme.
76
79
  OPENSSL_EXPORT int ECDSA_sign(int type, const uint8_t *digest,
77
80
  size_t digest_len, uint8_t *sig,
78
81
  unsigned int *sig_len, const EC_KEY *key);
@@ -81,6 +84,10 @@ OPENSSL_EXPORT int ECDSA_sign(int type, const uint8_t *digest,
81
84
  // signature by |key| of |digest|. (The |type| argument should be zero.) It
82
85
  // returns one on success or zero if the signature is invalid or an error
83
86
  // occurred.
87
+ //
88
+ // WARNING: |digest| must be the output of some hash function on the data to be
89
+ // verified. Passing unhashed inputs will not result in a secure signature
90
+ // scheme.
84
91
  OPENSSL_EXPORT int ECDSA_verify(int type, const uint8_t *digest,
85
92
  size_t digest_len, const uint8_t *sig,
86
93
  size_t sig_len, const EC_KEY *key);
@@ -124,12 +131,19 @@ OPENSSL_EXPORT int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
124
131
 
125
132
  // ECDSA_do_sign signs |digest_len| bytes from |digest| with |key| and returns
126
133
  // the resulting signature structure, or NULL on error.
134
+ //
135
+ // WARNING: |digest| must be the output of some hash function on the data to be
136
+ // signed. Passing unhashed inputs will not result in a secure signature scheme.
127
137
  OPENSSL_EXPORT ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest,
128
138
  size_t digest_len, const EC_KEY *key);
129
139
 
130
140
  // ECDSA_do_verify verifies that |sig| constitutes a valid signature by |key|
131
141
  // of |digest|. It returns one on success or zero if the signature is invalid
132
142
  // or on error.
143
+ //
144
+ // WARNING: |digest| must be the output of some hash function on the data to be
145
+ // verified. Passing unhashed inputs will not result in a secure signature
146
+ // scheme.
133
147
  OPENSSL_EXPORT int ECDSA_do_verify(const uint8_t *digest, size_t digest_len,
134
148
  const ECDSA_SIG *sig, const EC_KEY *key);
135
149
 
@@ -545,14 +545,15 @@ OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
545
545
  OPENSSL_EXPORT int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
546
546
 
547
547
  // EVP_PKEY_sign signs |digest_len| bytes from |digest| using |ctx|. If |sig| is
548
- // NULL, the maximum size of the signature is written to
549
- // |out_sig_len|. Otherwise, |*sig_len| must contain the number of bytes of
550
- // space available at |sig|. If sufficient, the signature will be written to
551
- // |sig| and |*sig_len| updated with the true length.
548
+ // NULL, the maximum size of the signature is written to |out_sig_len|.
549
+ // Otherwise, |*sig_len| must contain the number of bytes of space available at
550
+ // |sig|. If sufficient, the signature will be written to |sig| and |*sig_len|
551
+ // updated with the true length. This function will fail for signature
552
+ // algorithms like Ed25519 that do not support signing pre-hashed inputs.
552
553
  //
553
- // This function expects a pre-hashed input and will fail for signature
554
- // algorithms which do not support this. Use |EVP_DigestSignInit| to sign an
555
- // unhashed input.
554
+ // WARNING: |digest| must be the output of some hash function on the data to be
555
+ // signed. Passing unhashed inputs will not result in a secure signature scheme.
556
+ // Use |EVP_DigestSignInit| to sign an unhashed input.
556
557
  //
557
558
  // WARNING: Setting |sig| to NULL only gives the maximum size of the
558
559
  // signature. The actual signature may be smaller.
@@ -570,11 +571,13 @@ OPENSSL_EXPORT int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, uint8_t *sig,
570
571
  OPENSSL_EXPORT int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
571
572
 
572
573
  // EVP_PKEY_verify verifies that |sig_len| bytes from |sig| are a valid
573
- // signature for |digest|.
574
+ // signature for |digest|. This function will fail for signature
575
+ // algorithms like Ed25519 that do not support signing pre-hashed inputs.
574
576
  //
575
- // This function expects a pre-hashed input and will fail for signature
576
- // algorithms which do not support this. Use |EVP_DigestVerifyInit| to verify a
577
- // signature given the unhashed input.
577
+ // WARNING: |digest| must be the output of some hash function on the data to be
578
+ // verified. Passing unhashed inputs will not result in a secure signature
579
+ // scheme. Use |EVP_DigestVerifyInit| to verify a signature given the unhashed
580
+ // input.
578
581
  //
579
582
  // It returns one on success or zero on error.
580
583
  OPENSSL_EXPORT int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, const uint8_t *sig,
@@ -833,6 +836,11 @@ OPENSSL_EXPORT int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx,
833
836
  // Ed448 and attempts to create keys will fail.
834
837
  #define EVP_PKEY_ED448 NID_ED448
835
838
 
839
+ // EVP_PKEY_get0 returns NULL. This function is provided for compatibility with
840
+ // OpenSSL but does not return anything. Use the typed |EVP_PKEY_get0_*|
841
+ // functions instead.
842
+ OPENSSL_EXPORT void *EVP_PKEY_get0(const EVP_PKEY *pkey);
843
+
836
844
  // OpenSSL_add_all_algorithms does nothing.
837
845
  OPENSSL_EXPORT void OpenSSL_add_all_algorithms(void);
838
846