grpc 1.56.2 → 1.57.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (383) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +29 -22
  3. data/include/grpc/event_engine/event_engine.h +22 -32
  4. data/include/grpc/impl/grpc_types.h +3 -0
  5. data/include/grpc/support/port_platform.h +29 -23
  6. data/src/core/ext/filters/client_channel/client_channel.cc +44 -8
  7. data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
  8. data/src/core/ext/filters/client_channel/http_proxy.cc +5 -0
  9. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +21 -52
  10. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +19 -7
  11. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +25 -35
  12. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +78 -132
  13. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +2 -1
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +4 -3
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +38 -15
  17. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +3 -5
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +22 -6
  19. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric_internal.h +2 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +97 -71
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +2 -16
  22. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +56 -11
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.h +25 -0
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -32
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +4 -6
  26. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +20 -79
  27. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
  28. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +31 -19
  29. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +1 -1
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +7 -41
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +3 -67
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +8 -0
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +31 -74
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +7 -51
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +16 -87
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +16 -50
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -74
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -4
  39. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +69 -59
  40. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +7 -2
  41. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +1 -0
  42. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +25 -13
  43. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +366 -311
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +17 -1
  45. data/src/core/ext/filters/client_channel/retry_filter.cc +39 -2498
  46. data/src/core/ext/filters/client_channel/retry_filter.h +91 -1
  47. data/src/core/ext/filters/client_channel/retry_filter_legacy_call_data.cc +2052 -0
  48. data/src/core/ext/filters/client_channel/retry_filter_legacy_call_data.h +442 -0
  49. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +38 -58
  50. data/src/core/ext/filters/client_channel/subchannel.h +3 -3
  51. data/src/core/ext/filters/client_channel/subchannel_interface_internal.h +3 -0
  52. data/src/core/ext/filters/rbac/rbac_filter.cc +40 -111
  53. data/src/core/ext/filters/rbac/rbac_filter.h +12 -30
  54. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +162 -86
  55. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +0 -6
  56. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +7 -4
  57. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +131 -186
  58. data/src/core/ext/transport/chttp2/transport/decode_huff.cc +6569 -174
  59. data/src/core/ext/transport/chttp2/transport/decode_huff.h +2278 -441
  60. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -3
  61. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +4 -3
  62. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +9 -8
  63. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +4 -4
  64. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +3 -2
  65. data/src/core/ext/transport/chttp2/transport/internal.h +8 -4
  66. data/src/core/ext/transport/chttp2/transport/parsing.cc +15 -3
  67. data/src/core/ext/transport/chttp2/transport/writing.cc +2 -3
  68. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +27 -6
  69. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +143 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +2 -9
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +0 -39
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +13 -8
  73. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +35 -6
  74. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +17 -13
  75. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +85 -20
  76. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +26 -7
  77. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +45 -3
  78. data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c +4 -3
  79. data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.h +21 -0
  80. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +30 -6
  81. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +180 -0
  82. data/src/core/ext/upb-generated/envoy/data/accesslog/v3/accesslog.upb.c +558 -0
  83. data/src/core/ext/upb-generated/envoy/data/accesslog/v3/accesslog.upb.h +2710 -0
  84. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +30 -11
  85. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +53 -24
  86. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +30 -5
  87. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +110 -0
  88. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +41 -15
  89. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +150 -27
  90. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.c +1 -0
  91. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.c +47 -0
  92. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.h +93 -0
  93. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +88 -76
  94. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +5 -0
  95. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +11 -12
  96. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +0 -5
  97. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +162 -160
  98. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +129 -118
  99. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +141 -135
  100. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/metrics_service.upbdefs.c +19 -12
  101. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +38 -30
  102. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +5 -0
  103. data/src/core/ext/upbdefs-generated/envoy/data/accesslog/v3/accesslog.upbdefs.c +402 -0
  104. data/src/core/ext/upbdefs-generated/envoy/data/accesslog/v3/accesslog.upbdefs.h +111 -0
  105. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +80 -74
  106. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +63 -47
  107. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +5 -0
  108. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +315 -293
  109. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
  110. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +29 -29
  111. data/src/core/ext/xds/xds_bootstrap_grpc.cc +33 -30
  112. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -13
  113. data/src/core/ext/xds/xds_client_grpc.cc +11 -6
  114. data/src/core/ext/xds/xds_client_grpc.h +16 -2
  115. data/src/core/ext/xds/xds_client_stats.h +10 -0
  116. data/src/core/ext/xds/xds_cluster.cc +26 -16
  117. data/src/core/ext/xds/xds_endpoint.cc +4 -7
  118. data/src/core/ext/xds/xds_health_status.cc +0 -17
  119. data/src/core/ext/xds/xds_health_status.h +5 -25
  120. data/src/core/ext/xds/xds_lb_policy_registry.cc +39 -0
  121. data/src/core/ext/xds/xds_route_config.cc +4 -0
  122. data/src/core/ext/xds/xds_transport_grpc.cc +1 -3
  123. data/src/core/lib/address_utils/parse_address.cc +63 -1
  124. data/src/core/lib/address_utils/parse_address.h +8 -0
  125. data/src/core/lib/address_utils/sockaddr_utils.cc +46 -1
  126. data/src/core/lib/address_utils/sockaddr_utils.h +2 -2
  127. data/src/core/lib/channel/channel_args.cc +21 -10
  128. data/src/core/lib/channel/channel_args.h +3 -0
  129. data/src/core/lib/channel/connected_channel.cc +4 -1
  130. data/src/core/lib/channel/promise_based_filter.h +1 -0
  131. data/src/core/lib/debug/trace.cc +1 -4
  132. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +2 -1
  133. data/src/core/lib/event_engine/cf_engine/cf_engine.h +1 -1
  134. data/src/core/lib/event_engine/event_engine.cc +0 -12
  135. data/src/core/lib/event_engine/forkable.cc +47 -42
  136. data/src/core/lib/event_engine/handle_containers.h +0 -4
  137. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +4 -6
  138. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -6
  139. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +25 -11
  140. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +3 -1
  141. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +2 -1
  142. data/src/core/lib/event_engine/posix_engine/posix_engine.h +8 -12
  143. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +37 -27
  144. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +2 -0
  145. data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +4 -2
  146. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +42 -2
  147. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +6 -0
  148. data/src/core/lib/event_engine/posix_engine/timer.h +10 -37
  149. data/src/core/lib/event_engine/tcp_socket_utils.cc +67 -7
  150. data/src/core/lib/event_engine/tcp_socket_utils.h +3 -0
  151. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +90 -37
  152. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +32 -12
  153. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +12 -21
  154. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +8 -12
  155. data/src/core/lib/event_engine/windows/windows_endpoint.cc +55 -54
  156. data/src/core/lib/event_engine/windows/windows_endpoint.h +15 -12
  157. data/src/core/lib/event_engine/windows/windows_engine.cc +2 -1
  158. data/src/core/lib/event_engine/windows/windows_engine.h +8 -12
  159. data/src/core/lib/experiments/config.cc +60 -22
  160. data/src/core/lib/experiments/config.h +20 -8
  161. data/src/core/lib/experiments/experiments.cc +278 -0
  162. data/src/core/lib/experiments/experiments.h +59 -1
  163. data/src/core/lib/gprpp/dual_ref_counted.h +9 -9
  164. data/src/core/lib/gprpp/fork.cc +8 -9
  165. data/src/core/lib/gprpp/fork.h +6 -5
  166. data/src/core/lib/gprpp/if_list.h +4530 -0
  167. data/src/core/lib/gprpp/orphanable.h +3 -3
  168. data/src/core/lib/gprpp/ref_counted.h +6 -6
  169. data/src/core/lib/gprpp/sorted_pack.h +3 -12
  170. data/src/core/lib/gprpp/status_helper.h +16 -15
  171. data/src/core/lib/gprpp/time.h +12 -0
  172. data/src/core/lib/gprpp/type_list.h +32 -0
  173. data/src/core/lib/http/httpcli.h +6 -9
  174. data/src/core/lib/iomgr/error.cc +32 -2
  175. data/src/core/lib/iomgr/error.h +9 -10
  176. data/src/core/lib/iomgr/ev_epoll1_linux.cc +5 -7
  177. data/src/core/lib/iomgr/ev_poll_posix.cc +6 -5
  178. data/src/core/lib/iomgr/exec_ctx.h +11 -0
  179. data/src/core/lib/iomgr/pollset.h +4 -5
  180. data/src/core/lib/iomgr/port.h +10 -0
  181. data/src/core/lib/iomgr/resolve_address.cc +13 -1
  182. data/src/core/lib/iomgr/resolve_address.h +17 -3
  183. data/src/core/lib/iomgr/sockaddr_posix.h +7 -0
  184. data/src/core/lib/iomgr/socket_utils_common_posix.cc +29 -0
  185. data/src/core/lib/iomgr/socket_utils_posix.cc +2 -0
  186. data/src/core/lib/iomgr/socket_utils_posix.h +6 -0
  187. data/src/core/lib/iomgr/tcp_client_posix.cc +4 -1
  188. data/src/core/lib/iomgr/tcp_posix.cc +21 -4
  189. data/src/core/lib/iomgr/tcp_server_posix.cc +3 -2
  190. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +5 -2
  191. data/src/core/lib/iomgr/tcp_windows.cc +1 -3
  192. data/src/core/lib/iomgr/vsock.cc +59 -0
  193. data/src/core/lib/iomgr/vsock.h +38 -0
  194. data/src/core/lib/iomgr/wakeup_fd_posix.h +3 -6
  195. data/src/core/lib/load_balancing/delegating_helper.h +115 -0
  196. data/src/core/lib/load_balancing/lb_policy.h +20 -0
  197. data/src/core/lib/load_balancing/subchannel_interface.h +6 -0
  198. data/src/core/lib/promise/party.h +1 -1
  199. data/src/core/lib/resolver/resolver_factory.h +3 -2
  200. data/src/core/lib/resolver/server_address.cc +9 -94
  201. data/src/core/lib/resolver/server_address.h +10 -64
  202. data/src/core/lib/resource_quota/memory_quota.h +1 -1
  203. data/src/core/lib/security/credentials/channel_creds_registry.h +51 -27
  204. data/src/core/lib/security/credentials/channel_creds_registry_init.cc +169 -9
  205. data/src/core/lib/security/credentials/composite/composite_credentials.cc +1 -1
  206. data/src/core/lib/security/credentials/composite/composite_credentials.h +3 -1
  207. data/src/core/lib/security/credentials/external/external_account_credentials.cc +40 -1
  208. data/src/core/lib/security/credentials/external/external_account_credentials.h +6 -0
  209. data/src/core/lib/security/credentials/fake/fake_credentials.cc +30 -38
  210. data/src/core/lib/security/credentials/fake/fake_credentials.h +28 -0
  211. data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -1
  212. data/src/core/lib/security/credentials/tls/tls_credentials.h +3 -1
  213. data/src/core/lib/service_config/service_config_call_data.h +5 -0
  214. data/src/core/lib/slice/slice.h +16 -0
  215. data/src/core/lib/surface/call.cc +31 -29
  216. data/src/core/lib/surface/server.h +2 -2
  217. data/src/core/lib/surface/version.cc +2 -2
  218. data/src/core/lib/transport/metadata_batch.cc +7 -7
  219. data/src/core/lib/transport/metadata_batch.h +86 -48
  220. data/src/core/lib/transport/parsed_metadata.h +34 -20
  221. data/src/core/lib/transport/simple_slice_based_metadata.h +9 -2
  222. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +4 -6
  223. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -2
  224. data/src/core/tsi/ssl_transport_security.cc +28 -7
  225. data/src/ruby/bin/math_pb.rb +24 -18
  226. data/src/ruby/ext/grpc/extconf.rb +19 -18
  227. data/src/ruby/ext/grpc/rb_call.c +62 -39
  228. data/src/ruby/ext/grpc/rb_call_credentials.c +0 -1
  229. data/src/ruby/ext/grpc/rb_channel.c +126 -49
  230. data/src/ruby/ext/grpc/rb_channel.h +1 -0
  231. data/src/ruby/ext/grpc/rb_channel_args.c +16 -2
  232. data/src/ruby/ext/grpc/rb_channel_args.h +4 -0
  233. data/src/ruby/ext/grpc/rb_channel_credentials.c +0 -1
  234. data/src/ruby/ext/grpc/rb_compression_options.c +0 -1
  235. data/src/ruby/ext/grpc/rb_event_thread.c +22 -6
  236. data/src/ruby/ext/grpc/rb_event_thread.h +1 -0
  237. data/src/ruby/ext/grpc/rb_grpc.c +192 -30
  238. data/src/ruby/ext/grpc/rb_grpc.h +8 -2
  239. data/src/ruby/ext/grpc/rb_server.c +62 -45
  240. data/src/ruby/ext/grpc/rb_server_credentials.c +0 -1
  241. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +0 -1
  242. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +0 -1
  243. data/src/ruby/lib/grpc/generic/bidi_call.rb +2 -0
  244. data/src/ruby/lib/grpc/version.rb +1 -1
  245. data/src/ruby/pb/grpc/health/v1/health_pb.rb +24 -13
  246. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +24 -3
  247. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +25 -111
  248. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +25 -2
  249. data/third_party/boringssl-with-bazel/err_data.c +552 -552
  250. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +5 -5
  251. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +34 -1
  252. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +4 -1
  253. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +3 -3
  254. data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +7 -8
  255. data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +2 -2
  256. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -2
  257. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +8 -8
  258. data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +2 -2
  259. data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +2 -2
  260. data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +19 -1
  261. data/third_party/boringssl-with-bazel/src/crypto/chacha/internal.h +8 -1
  262. data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +28 -185
  263. data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +3 -7
  264. data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +8 -0
  265. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +3 -0
  266. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +49 -46
  267. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_64_adx.c +18 -0
  268. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +2809 -7417
  269. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +27 -5
  270. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +20 -0
  271. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +110 -72
  272. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_derive.c +4 -3
  273. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +15 -14
  274. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +13 -10
  275. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +35 -12
  276. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +2 -4
  277. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +3 -7
  278. data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c +3 -3
  279. data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +7 -6
  280. data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +34 -72
  281. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -1
  282. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +12 -5
  283. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +5 -6
  284. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +12 -6
  285. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +17 -18
  286. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +51 -15
  287. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +7 -7
  288. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +5 -6
  289. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +2 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/builtin_curves.h +277 -0
  291. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +180 -404
  292. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +3 -3
  293. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +24 -57
  294. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +17 -13
  295. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +33 -71
  296. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +18 -17
  297. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +5 -7
  298. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +15 -18
  299. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +9 -11
  300. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +24 -24
  301. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +11 -27
  302. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +8 -8
  303. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +4 -4
  304. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +9 -3
  305. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hkdf/hkdf.c +1 -1
  306. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +40 -26
  307. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +21 -7
  308. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +38 -19
  309. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +2 -29
  310. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +55 -0
  311. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +33 -52
  312. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +3 -8
  313. data/third_party/boringssl-with-bazel/src/crypto/internal.h +198 -79
  314. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +5 -4
  315. data/third_party/boringssl-with-bazel/src/crypto/mem.c +7 -8
  316. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +19 -23
  317. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +3 -3
  318. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.c +3 -3
  319. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +7 -7
  320. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +8 -5
  321. data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +1 -0
  322. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +7 -6
  323. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c +6 -12
  324. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +48 -0
  325. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/{fuchsia.c → ios.c} +8 -8
  326. data/third_party/boringssl-with-bazel/src/crypto/{refcount_no_threads.c → rand_extra/trusty.c} +15 -19
  327. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +41 -19
  328. data/third_party/boringssl-with-bazel/src/crypto/{refcount_c11.c → refcount.c} +11 -17
  329. data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +147 -72
  330. data/third_party/boringssl-with-bazel/src/crypto/thread_none.c +0 -8
  331. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +6 -35
  332. data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +5 -26
  333. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +14 -18
  334. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +54 -143
  335. data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +7 -13
  336. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +1 -1
  337. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +1 -1
  338. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +2 -4
  339. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +2 -2
  340. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +1 -1
  341. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +8 -12
  342. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +19 -20
  343. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -15
  344. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -5
  345. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +1 -1
  346. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +7 -7
  347. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +2 -3
  348. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +4 -6
  349. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +4 -119
  350. data/third_party/boringssl-with-bazel/src/include/openssl/asm_base.h +207 -0
  351. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +5 -0
  352. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +2 -116
  353. data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +0 -2
  354. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +6 -0
  355. data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +5 -1
  356. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +0 -21
  357. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +21 -2
  358. data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +19 -6
  359. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +11 -7
  360. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +13 -14
  361. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +0 -61
  362. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +127 -81
  363. data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +224 -209
  364. data/third_party/boringssl-with-bazel/src/include/openssl/target.h +154 -0
  365. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +1 -29
  366. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +4 -4
  367. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +3 -2
  368. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +9 -65
  369. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +20 -20
  370. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
  371. data/third_party/boringssl-with-bazel/src/ssl/internal.h +4 -11
  372. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +24 -18
  373. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +37 -30
  374. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +125 -26
  375. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +2 -3
  376. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_adx.h +691 -0
  377. data/third_party/upb/upb/collections/map.c +3 -3
  378. metadata +27 -12
  379. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.cc +0 -42
  380. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.h +0 -64
  381. data/src/core/ext/transport/chttp2/transport/stream_map.cc +0 -177
  382. data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -68
  383. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +0 -89
@@ -155,6 +155,32 @@
155
155
  #if defined(OPENSSL_THREADS) && !defined(OPENSSL_PTHREADS) && \
156
156
  defined(OPENSSL_WINDOWS)
157
157
  #define OPENSSL_WINDOWS_THREADS
158
+ #endif
159
+
160
+ // Determine the atomics implementation to use with C.
161
+ #if !defined(__cplusplus)
162
+ #if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \
163
+ !defined(__STDC_NO_ATOMICS__) && defined(__STDC_VERSION__) && \
164
+ __STDC_VERSION__ >= 201112L
165
+ #define OPENSSL_C11_ATOMIC
166
+ #endif
167
+
168
+ #if defined(OPENSSL_C11_ATOMIC)
169
+ #include <stdatomic.h>
170
+ #endif
171
+
172
+ // Older MSVC does not support C11 atomics, so we fallback to the Windows APIs.
173
+ // When both are available (e.g. clang-cl), we prefer the C11 ones. The Windows
174
+ // APIs don't allow some operations to be implemented as efficiently. This can
175
+ // be removed once we can rely on
176
+ // https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/
177
+ #if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \
178
+ defined(OPENSSL_WINDOWS)
179
+ #define OPENSSL_WINDOWS_ATOMIC
180
+ #endif
181
+ #endif // !__cplusplus
182
+
183
+ #if defined(OPENSSL_WINDOWS_THREADS) || defined(OPENSSL_WINDOWS_ATOMIC)
158
184
  OPENSSL_MSVC_PRAGMA(warning(push, 3))
159
185
  #include <windows.h>
160
186
  OPENSSL_MSVC_PRAGMA(warning(pop))
@@ -180,14 +206,17 @@ OPENSSL_EXPORT uint32_t *OPENSSL_get_armcap_pointer_for_test(void);
180
206
  #endif
181
207
 
182
208
 
209
+ // On non-MSVC 64-bit targets, we expect __uint128_t support. This includes
210
+ // clang-cl, which defines both __clang__ and _MSC_VER.
183
211
  #if (!defined(_MSC_VER) || defined(__clang__)) && defined(OPENSSL_64_BIT)
184
212
  #define BORINGSSL_HAS_UINT128
185
213
  typedef __int128_t int128_t;
186
214
  typedef __uint128_t uint128_t;
187
215
 
188
- // clang-cl supports __uint128_t but modulus and division don't work.
189
- // https://crbug.com/787617.
190
- #if !defined(_MSC_VER) || !defined(__clang__)
216
+ // __uint128_t division depends on intrinsics in the compiler runtime. Those
217
+ // intrinsics are missing in clang-cl (https://crbug.com/787617) and nanolibc.
218
+ // These may be bugs in the toolchain definition, but just disable it for now.
219
+ #if !defined(_MSC_VER) && !defined(OPENSSL_NANOLIBC)
191
220
  #define BORINGSSL_CAN_DIVIDE_UINT128
192
221
  #endif
193
222
  #endif
@@ -239,15 +268,15 @@ OPENSSL_INLINE void OPENSSL_reset_malloc_counter_for_testing(void) {}
239
268
  // Pointer utility functions.
240
269
 
241
270
  // buffers_alias returns one if |a| and |b| alias and zero otherwise.
242
- static inline int buffers_alias(const uint8_t *a, size_t a_len,
243
- const uint8_t *b, size_t b_len) {
271
+ static inline int buffers_alias(const void *a, size_t a_bytes,
272
+ const void *b, size_t b_bytes) {
244
273
  // Cast |a| and |b| to integers. In C, pointer comparisons between unrelated
245
274
  // objects are undefined whereas pointer to integer conversions are merely
246
275
  // implementation-defined. We assume the implementation defined it in a sane
247
276
  // way.
248
277
  uintptr_t a_u = (uintptr_t)a;
249
278
  uintptr_t b_u = (uintptr_t)b;
250
- return a_u + a_len > b_u && b_u + b_len > a_u;
279
+ return a_u + a_bytes > b_u && b_u + b_bytes > a_u;
251
280
  }
252
281
 
253
282
  // align_pointer returns |ptr|, advanced to |alignment|. |alignment| must be a
@@ -334,6 +363,9 @@ static inline uint64_t value_barrier_u64(uint64_t a) {
334
363
  return a;
335
364
  }
336
365
 
366
+ // |value_barrier_u8| could be defined as above, but compilers other than
367
+ // clang seem to still materialize 0x00..00MM instead of reusing 0x??..??MM.
368
+
337
369
  // constant_time_msb_w returns the given value with the MSB copied to all the
338
370
  // other bits.
339
371
  static inline crypto_word_t constant_time_msb_w(crypto_word_t a) {
@@ -450,16 +482,23 @@ static inline crypto_word_t constant_time_select_w(crypto_word_t mask,
450
482
  // to a cmov, it sometimes further transforms it into a branch, which we do
451
483
  // not want.
452
484
  //
453
- // Adding barriers to both |mask| and |~mask| breaks the relationship between
454
- // the two, which makes the compiler stick with bitmasks.
455
- return (value_barrier_w(mask) & a) | (value_barrier_w(~mask) & b);
485
+ // Hiding the value of the mask from the compiler evades this transformation.
486
+ mask = value_barrier_w(mask);
487
+ return (mask & a) | (~mask & b);
456
488
  }
457
489
 
458
490
  // constant_time_select_8 acts like |constant_time_select| but operates on
459
491
  // 8-bit values.
460
- static inline uint8_t constant_time_select_8(uint8_t mask, uint8_t a,
492
+ static inline uint8_t constant_time_select_8(crypto_word_t mask, uint8_t a,
461
493
  uint8_t b) {
462
- return (uint8_t)(constant_time_select_w(mask, a, b));
494
+ // |mask| is a word instead of |uint8_t| to avoid materializing 0x000..0MM
495
+ // Making both |mask| and its value barrier |uint8_t| would allow the compiler
496
+ // to materialize 0x????..?MM instead, but only clang is that clever.
497
+ // However, vectorization of bitwise operations seems to work better on
498
+ // |uint8_t| than a mix of |uint64_t| and |uint8_t|, so |m| is cast to
499
+ // |uint8_t| after the value barrier but before the bitwise operations.
500
+ uint8_t m = value_barrier_w(mask);
501
+ return (m & a) | (~m & b);
463
502
  }
464
503
 
465
504
  // constant_time_select_int acts like |constant_time_select| but operates on
@@ -469,6 +508,34 @@ static inline int constant_time_select_int(crypto_word_t mask, int a, int b) {
469
508
  (crypto_word_t)(b)));
470
509
  }
471
510
 
511
+ // constant_time_conditional_memcpy copies |n| bytes from |src| to |dst| if
512
+ // |mask| is 0xff..ff and does nothing if |mask| is 0. The |n|-byte memory
513
+ // ranges at |dst| and |src| must not overlap, as when calling |memcpy|.
514
+ static inline void constant_time_conditional_memcpy(void *dst, const void *src,
515
+ const size_t n,
516
+ const crypto_word_t mask) {
517
+ assert(!buffers_alias(dst, n, src, n));
518
+ uint8_t *out = (uint8_t *)dst;
519
+ const uint8_t *in = (const uint8_t *)src;
520
+ for (size_t i = 0; i < n; i++) {
521
+ out[i] = constant_time_select_8(mask, in[i], out[i]);
522
+ }
523
+ }
524
+
525
+ // constant_time_conditional_memxor xors |n| bytes from |src| to |dst| if
526
+ // |mask| is 0xff..ff and does nothing if |mask| is 0. The |n|-byte memory
527
+ // ranges at |dst| and |src| must not overlap, as when calling |memcpy|.
528
+ static inline void constant_time_conditional_memxor(void *dst, const void *src,
529
+ const size_t n,
530
+ const crypto_word_t mask) {
531
+ assert(!buffers_alias(dst, n, src, n));
532
+ uint8_t *out = (uint8_t *)dst;
533
+ const uint8_t *in = (const uint8_t *)src;
534
+ for (size_t i = 0; i < n; i++) {
535
+ out[i] ^= value_barrier_w(mask) & in[i];
536
+ }
537
+ }
538
+
472
539
  #if defined(BORINGSSL_CONSTANT_TIME_VALIDATION)
473
540
 
474
541
  // CONSTTIME_SECRET takes a pointer and a number of bytes and marks that region
@@ -539,33 +606,117 @@ typedef pthread_once_t CRYPTO_once_t;
539
606
  OPENSSL_EXPORT void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void));
540
607
 
541
608
 
542
- // Reference counting.
609
+ // Atomics.
610
+ //
611
+ // The following functions provide an API analogous to <stdatomic.h> from C11
612
+ // and abstract between a few variations on atomics we need to support.
543
613
 
544
- // Automatically enable C11 atomics if implemented.
545
- #if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \
546
- !defined(__STDC_NO_ATOMICS__) && defined(__STDC_VERSION__) && \
547
- __STDC_VERSION__ >= 201112L
548
- #define OPENSSL_C11_ATOMIC
549
- #endif
614
+ #if defined(__cplusplus)
550
615
 
551
- // Older MSVC does not support C11 atomics, so we fallback to the Windows APIs.
552
- // This can be removed once we can rely on
553
- // https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/
554
- #if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \
555
- defined(OPENSSL_WINDOWS)
556
- #define OPENSSL_WINDOWS_ATOMIC
557
- #endif
616
+ // In C++, we can't easily detect whether C will use |OPENSSL_C11_ATOMIC| or
617
+ // |OPENSSL_WINDOWS_ATOMIC|. Instead, we define a layout-compatible type without
618
+ // the corresponding functions. When we can rely on C11 atomics in MSVC, that
619
+ // will no longer be a concern.
620
+ typedef uint32_t CRYPTO_atomic_u32;
621
+
622
+ #elif defined(OPENSSL_C11_ATOMIC)
623
+
624
+ typedef _Atomic uint32_t CRYPTO_atomic_u32;
625
+
626
+ // This should be const, but the |OPENSSL_WINDOWS_ATOMIC| implementation is not
627
+ // const due to Windows limitations. When we can rely on C11 atomics, make this
628
+ // const-correct.
629
+ OPENSSL_INLINE uint32_t CRYPTO_atomic_load_u32(CRYPTO_atomic_u32 *val) {
630
+ return atomic_load(val);
631
+ }
632
+
633
+ OPENSSL_INLINE int CRYPTO_atomic_compare_exchange_weak_u32(
634
+ CRYPTO_atomic_u32 *val, uint32_t *expected, uint32_t desired) {
635
+ return atomic_compare_exchange_weak(val, expected, desired);
636
+ }
637
+
638
+ OPENSSL_INLINE void CRYPTO_atomic_store_u32(CRYPTO_atomic_u32 *val,
639
+ uint32_t desired) {
640
+ atomic_store(val, desired);
641
+ }
642
+
643
+ #elif defined(OPENSSL_WINDOWS_ATOMIC)
644
+
645
+ typedef LONG CRYPTO_atomic_u32;
646
+
647
+ OPENSSL_INLINE uint32_t CRYPTO_atomic_load_u32(volatile CRYPTO_atomic_u32 *val) {
648
+ // This is not ideal because it still writes to a cacheline. MSVC is not able
649
+ // to optimize this to a true atomic read, and Windows does not provide an
650
+ // InterlockedLoad function.
651
+ //
652
+ // The Windows documentation [1] does say "Simple reads and writes to
653
+ // properly-aligned 32-bit variables are atomic operations", but this is not
654
+ // phrased in terms of the C11 and C++11 memory models, and indeed a read or
655
+ // write seems to produce slightly different code on MSVC than a sequentially
656
+ // consistent std::atomic::load in C++. Moreover, it is unclear if non-MSVC
657
+ // compilers on Windows provide the same guarantees. Thus we avoid relying on
658
+ // this and instead still use an interlocked function. This is still
659
+ // preferable a global mutex, and eventually this code will be replaced by
660
+ // [2]. Additionally, on clang-cl, we'll use the |OPENSSL_C11_ATOMIC| path.
661
+ //
662
+ // [1] https://learn.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access
663
+ // [2] https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/
664
+ return (uint32_t)InterlockedCompareExchange(val, 0, 0);
665
+ }
666
+
667
+ OPENSSL_INLINE int CRYPTO_atomic_compare_exchange_weak_u32(
668
+ volatile CRYPTO_atomic_u32 *val, uint32_t *expected32, uint32_t desired) {
669
+ LONG expected = (LONG)*expected32;
670
+ LONG actual = InterlockedCompareExchange(val, (LONG)desired, expected);
671
+ *expected32 = (uint32_t)actual;
672
+ return actual == expected;
673
+ }
674
+
675
+ OPENSSL_INLINE void CRYPTO_atomic_store_u32(volatile CRYPTO_atomic_u32 *val,
676
+ uint32_t desired) {
677
+ InterlockedExchange(val, (LONG)desired);
678
+ }
679
+
680
+ #elif !defined(OPENSSL_THREADS)
681
+
682
+ typedef uint32_t CRYPTO_atomic_u32;
683
+
684
+ OPENSSL_INLINE uint32_t CRYPTO_atomic_load_u32(CRYPTO_atomic_u32 *val) {
685
+ return *val;
686
+ }
687
+
688
+ OPENSSL_INLINE int CRYPTO_atomic_compare_exchange_weak_u32(
689
+ CRYPTO_atomic_u32 *val, uint32_t *expected, uint32_t desired) {
690
+ if (*val != *expected) {
691
+ *expected = *val;
692
+ return 0;
693
+ }
694
+ *val = desired;
695
+ return 1;
696
+ }
697
+
698
+ OPENSSL_INLINE void CRYPTO_atomic_store_u32(CRYPTO_atomic_u32 *val,
699
+ uint32_t desired) {
700
+ *val = desired;
701
+ }
702
+
703
+ #else
558
704
 
559
705
  // Require some atomics implementation. Contact BoringSSL maintainers if you
560
706
  // have a platform with fails this check.
561
- //
562
- // Note this check can only be done in C. From C++, we don't know whether the
563
- // corresponding C mode would support C11 atomics.
564
- #if !defined(__cplusplus) && defined(OPENSSL_THREADS) && \
565
- !defined(OPENSSL_C11_ATOMIC) && !defined(OPENSSL_WINDOWS_ATOMIC)
566
707
  #error "Thread-compatible configurations require atomics"
708
+
567
709
  #endif
568
710
 
711
+ // See the comment in the |__cplusplus| section above.
712
+ static_assert(sizeof(CRYPTO_atomic_u32) == sizeof(uint32_t),
713
+ "CRYPTO_atomic_u32 does not match uint32_t size");
714
+ static_assert(alignof(CRYPTO_atomic_u32) == alignof(uint32_t),
715
+ "CRYPTO_atomic_u32 does not match uint32_t alignment");
716
+
717
+
718
+ // Reference counting.
719
+
569
720
  // CRYPTO_REFCOUNT_MAX is the value at which the reference count saturates.
570
721
  #define CRYPTO_REFCOUNT_MAX 0xffffffff
571
722
 
@@ -587,37 +738,24 @@ OPENSSL_EXPORT int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *count);
587
738
 
588
739
 
589
740
  // Locks.
590
- //
591
- // Two types of locks are defined: |CRYPTO_MUTEX|, which can be used in
592
- // structures as normal, and |struct CRYPTO_STATIC_MUTEX|, which can be used as
593
- // a global lock. A global lock must be initialised to the value
594
- // |CRYPTO_STATIC_MUTEX_INIT|.
595
- //
596
- // |CRYPTO_MUTEX| can appear in public structures and so is defined in
597
- // thread.h as a structure large enough to fit the real type. The global lock is
598
- // a different type so it may be initialized with platform initializer macros.
599
741
 
600
742
  #if !defined(OPENSSL_THREADS)
601
- struct CRYPTO_STATIC_MUTEX {
743
+ typedef struct crypto_mutex_st {
602
744
  char padding; // Empty structs have different sizes in C and C++.
603
- };
604
- #define CRYPTO_STATIC_MUTEX_INIT { 0 }
745
+ } CRYPTO_MUTEX;
746
+ #define CRYPTO_MUTEX_INIT { 0 }
605
747
  #elif defined(OPENSSL_WINDOWS_THREADS)
606
- struct CRYPTO_STATIC_MUTEX {
607
- SRWLOCK lock;
608
- };
609
- #define CRYPTO_STATIC_MUTEX_INIT { SRWLOCK_INIT }
748
+ typedef SRWLOCK CRYPTO_MUTEX;
749
+ #define CRYPTO_MUTEX_INIT SRWLOCK_INIT
610
750
  #elif defined(OPENSSL_PTHREADS)
611
- struct CRYPTO_STATIC_MUTEX {
612
- pthread_rwlock_t lock;
613
- };
614
- #define CRYPTO_STATIC_MUTEX_INIT { PTHREAD_RWLOCK_INITIALIZER }
751
+ typedef pthread_rwlock_t CRYPTO_MUTEX;
752
+ #define CRYPTO_MUTEX_INIT PTHREAD_RWLOCK_INITIALIZER
615
753
  #else
616
754
  #error "Unknown threading library"
617
755
  #endif
618
756
 
619
757
  // CRYPTO_MUTEX_init initialises |lock|. If |lock| is a static variable, use a
620
- // |CRYPTO_STATIC_MUTEX|.
758
+ // |CRYPTO_MUTEX_INIT|.
621
759
  OPENSSL_EXPORT void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock);
622
760
 
623
761
  // CRYPTO_MUTEX_lock_read locks |lock| such that other threads may also have a
@@ -637,28 +775,6 @@ OPENSSL_EXPORT void CRYPTO_MUTEX_unlock_write(CRYPTO_MUTEX *lock);
637
775
  // CRYPTO_MUTEX_cleanup releases all resources held by |lock|.
638
776
  OPENSSL_EXPORT void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock);
639
777
 
640
- // CRYPTO_STATIC_MUTEX_lock_read locks |lock| such that other threads may also
641
- // have a read lock, but none may have a write lock. The |lock| variable does
642
- // not need to be initialised by any function, but must have been statically
643
- // initialised with |CRYPTO_STATIC_MUTEX_INIT|.
644
- OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_lock_read(
645
- struct CRYPTO_STATIC_MUTEX *lock);
646
-
647
- // CRYPTO_STATIC_MUTEX_lock_write locks |lock| such that no other thread has
648
- // any type of lock on it. The |lock| variable does not need to be initialised
649
- // by any function, but must have been statically initialised with
650
- // |CRYPTO_STATIC_MUTEX_INIT|.
651
- OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_lock_write(
652
- struct CRYPTO_STATIC_MUTEX *lock);
653
-
654
- // CRYPTO_STATIC_MUTEX_unlock_read unlocks |lock| for reading.
655
- OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_unlock_read(
656
- struct CRYPTO_STATIC_MUTEX *lock);
657
-
658
- // CRYPTO_STATIC_MUTEX_unlock_write unlocks |lock| for writing.
659
- OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_unlock_write(
660
- struct CRYPTO_STATIC_MUTEX *lock);
661
-
662
778
  #if defined(__cplusplus)
663
779
  extern "C++" {
664
780
 
@@ -740,22 +856,25 @@ OPENSSL_EXPORT int CRYPTO_set_thread_local(
740
856
 
741
857
  typedef struct crypto_ex_data_func_st CRYPTO_EX_DATA_FUNCS;
742
858
 
743
- DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
744
-
745
859
  // CRYPTO_EX_DATA_CLASS tracks the ex_indices registered for a type which
746
860
  // supports ex_data. It should defined as a static global within the module
747
861
  // which defines that type.
748
862
  typedef struct {
749
- struct CRYPTO_STATIC_MUTEX lock;
750
- STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth;
863
+ CRYPTO_MUTEX lock;
864
+ // funcs is a linked list of |CRYPTO_EX_DATA_FUNCS| structures. It may be
865
+ // traversed without serialization only up to |num_funcs|. last points to the
866
+ // final entry of |funcs|, or NULL if empty.
867
+ CRYPTO_EX_DATA_FUNCS *funcs, *last;
868
+ // num_funcs is the number of entries in |funcs|.
869
+ CRYPTO_atomic_u32 num_funcs;
751
870
  // num_reserved is one if the ex_data index zero is reserved for legacy
752
871
  // |TYPE_get_app_data| functions.
753
872
  uint8_t num_reserved;
754
873
  } CRYPTO_EX_DATA_CLASS;
755
874
 
756
- #define CRYPTO_EX_DATA_CLASS_INIT {CRYPTO_STATIC_MUTEX_INIT, NULL, 0}
875
+ #define CRYPTO_EX_DATA_CLASS_INIT {CRYPTO_MUTEX_INIT, NULL, NULL, 0, 0}
757
876
  #define CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA \
758
- {CRYPTO_STATIC_MUTEX_INIT, NULL, 1}
877
+ {CRYPTO_MUTEX_INIT, NULL, NULL, 0, 1}
759
878
 
760
879
  // CRYPTO_get_ex_new_index allocates a new index for |ex_data_class| and writes
761
880
  // it to |*out_index|. Each class of object should provide a wrapper function
@@ -132,7 +132,7 @@ static uint16_t reduce_once(uint16_t x) {
132
132
  static uint16_t reduce(uint32_t x) {
133
133
  assert(x < kPrime + 2u * kPrime * kPrime);
134
134
  uint64_t product = (uint64_t)x * kBarrettMultiplier;
135
- uint32_t quotient = product >> kBarrettShift;
135
+ uint32_t quotient = (uint32_t)(product >> kBarrettShift);
136
136
  uint32_t remainder = x - quotient * kPrime;
137
137
  return reduce_once(remainder);
138
138
  }
@@ -491,9 +491,10 @@ static int vector_decode(vector *out, const uint8_t *in, int bits) {
491
491
  // remainder (for rounding) and the quotient (as the result), we cannot use
492
492
  // |reduce| here, but need to do the Barrett reduction directly.
493
493
  static uint16_t compress(uint16_t x, int bits) {
494
- uint32_t product = (uint32_t)x << bits;
495
- uint32_t quotient = ((uint64_t)product * kBarrettMultiplier) >> kBarrettShift;
496
- uint32_t remainder = product - quotient * kPrime;
494
+ uint32_t shifted = (uint32_t)x << bits;
495
+ uint64_t product = (uint64_t)shifted * kBarrettMultiplier;
496
+ uint32_t quotient = (uint32_t)(product >> kBarrettShift);
497
+ uint32_t remainder = shifted - quotient * kPrime;
497
498
 
498
499
  // Adjust the quotient to round correctly:
499
500
  // 0 <= remainder <= kHalfPrime round to 0
@@ -159,21 +159,20 @@ static const uint8_t kBoringSSLBinaryTag[18] = {
159
159
  };
160
160
 
161
161
  #if defined(BORINGSSL_MALLOC_FAILURE_TESTING)
162
- static struct CRYPTO_STATIC_MUTEX malloc_failure_lock =
163
- CRYPTO_STATIC_MUTEX_INIT;
162
+ static CRYPTO_MUTEX malloc_failure_lock = CRYPTO_MUTEX_INIT;
164
163
  static uint64_t current_malloc_count = 0;
165
164
  static uint64_t malloc_number_to_fail = 0;
166
165
  static int malloc_failure_enabled = 0, break_on_malloc_fail = 0,
167
166
  any_malloc_failed = 0;
168
167
 
169
168
  static void malloc_exit_handler(void) {
170
- CRYPTO_STATIC_MUTEX_lock_read(&malloc_failure_lock);
169
+ CRYPTO_MUTEX_lock_read(&malloc_failure_lock);
171
170
  if (any_malloc_failed) {
172
171
  // Signal to the test driver that some allocation failed, so it knows to
173
172
  // increment the counter and continue.
174
173
  _exit(88);
175
174
  }
176
- CRYPTO_STATIC_MUTEX_unlock_read(&malloc_failure_lock);
175
+ CRYPTO_MUTEX_unlock_read(&malloc_failure_lock);
177
176
  }
178
177
 
179
178
  static void init_malloc_failure(void) {
@@ -200,11 +199,11 @@ static int should_fail_allocation() {
200
199
 
201
200
  // We lock just so multi-threaded tests are still correct, but we won't test
202
201
  // every malloc exhaustively.
203
- CRYPTO_STATIC_MUTEX_lock_write(&malloc_failure_lock);
202
+ CRYPTO_MUTEX_lock_write(&malloc_failure_lock);
204
203
  int should_fail = current_malloc_count == malloc_number_to_fail;
205
204
  current_malloc_count++;
206
205
  any_malloc_failed = any_malloc_failed || should_fail;
207
- CRYPTO_STATIC_MUTEX_unlock_write(&malloc_failure_lock);
206
+ CRYPTO_MUTEX_unlock_write(&malloc_failure_lock);
208
207
 
209
208
  if (should_fail && break_on_malloc_fail) {
210
209
  raise(SIGTRAP);
@@ -216,9 +215,9 @@ static int should_fail_allocation() {
216
215
  }
217
216
 
218
217
  void OPENSSL_reset_malloc_counter_for_testing(void) {
219
- CRYPTO_STATIC_MUTEX_lock_write(&malloc_failure_lock);
218
+ CRYPTO_MUTEX_lock_write(&malloc_failure_lock);
220
219
  current_malloc_count = 0;
221
- CRYPTO_STATIC_MUTEX_unlock_write(&malloc_failure_lock);
220
+ CRYPTO_MUTEX_unlock_write(&malloc_failure_lock);
222
221
  }
223
222
 
224
223
  #else
@@ -77,24 +77,20 @@
77
77
 
78
78
  DEFINE_LHASH_OF(ASN1_OBJECT)
79
79
 
80
- static struct CRYPTO_STATIC_MUTEX global_added_lock = CRYPTO_STATIC_MUTEX_INIT;
80
+ static CRYPTO_MUTEX global_added_lock = CRYPTO_MUTEX_INIT;
81
81
  // These globals are protected by |global_added_lock|.
82
82
  static LHASH_OF(ASN1_OBJECT) *global_added_by_data = NULL;
83
83
  static LHASH_OF(ASN1_OBJECT) *global_added_by_nid = NULL;
84
84
  static LHASH_OF(ASN1_OBJECT) *global_added_by_short_name = NULL;
85
85
  static LHASH_OF(ASN1_OBJECT) *global_added_by_long_name = NULL;
86
86
 
87
- static struct CRYPTO_STATIC_MUTEX global_next_nid_lock =
88
- CRYPTO_STATIC_MUTEX_INIT;
87
+ static CRYPTO_MUTEX global_next_nid_lock = CRYPTO_MUTEX_INIT;
89
88
  static unsigned global_next_nid = NUM_NID;
90
89
 
91
90
  static int obj_next_nid(void) {
92
- int ret;
93
-
94
- CRYPTO_STATIC_MUTEX_lock_write(&global_next_nid_lock);
95
- ret = global_next_nid++;
96
- CRYPTO_STATIC_MUTEX_unlock_write(&global_next_nid_lock);
97
-
91
+ CRYPTO_MUTEX_lock_write(&global_next_nid_lock);
92
+ int ret = global_next_nid++;
93
+ CRYPTO_MUTEX_unlock_write(&global_next_nid_lock);
98
94
  return ret;
99
95
  }
100
96
 
@@ -213,17 +209,17 @@ int OBJ_obj2nid(const ASN1_OBJECT *obj) {
213
209
  return obj->nid;
214
210
  }
215
211
 
216
- CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock);
212
+ CRYPTO_MUTEX_lock_read(&global_added_lock);
217
213
  if (global_added_by_data != NULL) {
218
214
  ASN1_OBJECT *match;
219
215
 
220
216
  match = lh_ASN1_OBJECT_retrieve(global_added_by_data, obj);
221
217
  if (match != NULL) {
222
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
218
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
223
219
  return match->nid;
224
220
  }
225
221
  }
226
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
222
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
227
223
 
228
224
  const uint16_t *nid_ptr =
229
225
  bsearch(obj, kNIDsInOIDOrder, OPENSSL_ARRAY_SIZE(kNIDsInOIDOrder),
@@ -259,18 +255,18 @@ static int short_name_cmp(const void *key, const void *element) {
259
255
  }
260
256
 
261
257
  int OBJ_sn2nid(const char *short_name) {
262
- CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock);
258
+ CRYPTO_MUTEX_lock_read(&global_added_lock);
263
259
  if (global_added_by_short_name != NULL) {
264
260
  ASN1_OBJECT *match, template;
265
261
 
266
262
  template.sn = short_name;
267
263
  match = lh_ASN1_OBJECT_retrieve(global_added_by_short_name, &template);
268
264
  if (match != NULL) {
269
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
265
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
270
266
  return match->nid;
271
267
  }
272
268
  }
273
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
269
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
274
270
 
275
271
  const uint16_t *nid_ptr =
276
272
  bsearch(short_name, kNIDsInShortNameOrder,
@@ -294,18 +290,18 @@ static int long_name_cmp(const void *key, const void *element) {
294
290
  }
295
291
 
296
292
  int OBJ_ln2nid(const char *long_name) {
297
- CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock);
293
+ CRYPTO_MUTEX_lock_read(&global_added_lock);
298
294
  if (global_added_by_long_name != NULL) {
299
295
  ASN1_OBJECT *match, template;
300
296
 
301
297
  template.ln = long_name;
302
298
  match = lh_ASN1_OBJECT_retrieve(global_added_by_long_name, &template);
303
299
  if (match != NULL) {
304
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
300
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
305
301
  return match->nid;
306
302
  }
307
303
  }
308
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
304
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
309
305
 
310
306
  const uint16_t *nid_ptr = bsearch(
311
307
  long_name, kNIDsInLongNameOrder, OPENSSL_ARRAY_SIZE(kNIDsInLongNameOrder),
@@ -349,18 +345,18 @@ ASN1_OBJECT *OBJ_nid2obj(int nid) {
349
345
  return (ASN1_OBJECT *)&kObjects[nid];
350
346
  }
351
347
 
352
- CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock);
348
+ CRYPTO_MUTEX_lock_read(&global_added_lock);
353
349
  if (global_added_by_nid != NULL) {
354
350
  ASN1_OBJECT *match, template;
355
351
 
356
352
  template.nid = nid;
357
353
  match = lh_ASN1_OBJECT_retrieve(global_added_by_nid, &template);
358
354
  if (match != NULL) {
359
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
355
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
360
356
  return match;
361
357
  }
362
358
  }
363
- CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock);
359
+ CRYPTO_MUTEX_unlock_read(&global_added_lock);
364
360
 
365
361
  err:
366
362
  OPENSSL_PUT_ERROR(OBJ, OBJ_R_UNKNOWN_NID);
@@ -508,7 +504,7 @@ static int obj_add_object(ASN1_OBJECT *obj) {
508
504
  obj->flags &= ~(ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
509
505
  ASN1_OBJECT_FLAG_DYNAMIC_DATA);
510
506
 
511
- CRYPTO_STATIC_MUTEX_lock_write(&global_added_lock);
507
+ CRYPTO_MUTEX_lock_write(&global_added_lock);
512
508
  if (global_added_by_nid == NULL) {
513
509
  global_added_by_nid = lh_ASN1_OBJECT_new(hash_nid, cmp_nid);
514
510
  }
@@ -548,7 +544,7 @@ static int obj_add_object(ASN1_OBJECT *obj) {
548
544
  }
549
545
 
550
546
  err:
551
- CRYPTO_STATIC_MUTEX_unlock_write(&global_added_lock);
547
+ CRYPTO_MUTEX_unlock_write(&global_added_lock);
552
548
  return ok;
553
549
  }
554
550
 
@@ -87,13 +87,13 @@ int pkcs8_pbe_decrypt(uint8_t **out, size_t *out_len, CBS *algorithm,
87
87
  // key material to |out| and returns one. Otherwise, it returns zero. |id|
88
88
  // should be one of the |PKCS12_*_ID| values.
89
89
  int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt,
90
- size_t salt_len, uint8_t id, unsigned iterations,
90
+ size_t salt_len, uint8_t id, uint32_t iterations,
91
91
  size_t out_len, uint8_t *out, const EVP_MD *md);
92
92
 
93
93
  // pkcs12_pbe_encrypt_init configures |ctx| for encrypting with a PBES1 scheme
94
94
  // defined in PKCS#12. It writes the corresponding AlgorithmIdentifier to |out|.
95
95
  int pkcs12_pbe_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, int alg,
96
- unsigned iterations, const char *pass,
96
+ uint32_t iterations, const char *pass,
97
97
  size_t pass_len, const uint8_t *salt,
98
98
  size_t salt_len);
99
99
 
@@ -121,7 +121,7 @@ int PKCS5_pbe2_decrypt_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx,
121
121
  // as defined in RFC 2998, with the specified parameters. It writes the
122
122
  // corresponding AlgorithmIdentifier to |out|.
123
123
  int PKCS5_pbe2_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx,
124
- const EVP_CIPHER *cipher, unsigned iterations,
124
+ const EVP_CIPHER *cipher, uint32_t iterations,
125
125
  const char *pass, size_t pass_len,
126
126
  const uint8_t *salt, size_t salt_len);
127
127
 
@@ -144,7 +144,7 @@ static int add_cipher_oid(CBB *out, int nid) {
144
144
  }
145
145
 
146
146
  static int pkcs5_pbe2_cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
147
- const EVP_MD *pbkdf2_md, unsigned iterations,
147
+ const EVP_MD *pbkdf2_md, uint32_t iterations,
148
148
  const char *pass, size_t pass_len,
149
149
  const uint8_t *salt, size_t salt_len,
150
150
  const uint8_t *iv, size_t iv_len, int enc) {
@@ -162,7 +162,7 @@ static int pkcs5_pbe2_cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
162
162
  }
163
163
 
164
164
  int PKCS5_pbe2_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx,
165
- const EVP_CIPHER *cipher, unsigned iterations,
165
+ const EVP_CIPHER *cipher, uint32_t iterations,
166
166
  const char *pass, size_t pass_len,
167
167
  const uint8_t *salt, size_t salt_len) {
168
168
  int cipher_nid = EVP_CIPHER_nid(cipher);
@@ -310,7 +310,7 @@ int PKCS5_pbe2_decrypt_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx,
310
310
  return 0;
311
311
  }
312
312
 
313
- return pkcs5_pbe2_cipher_init(ctx, cipher, md, (unsigned)iterations, pass,
313
+ return pkcs5_pbe2_cipher_init(ctx, cipher, md, (uint32_t)iterations, pass,
314
314
  pass_len, CBS_data(&salt), CBS_len(&salt),
315
315
  CBS_data(&iv), CBS_len(&iv), 0 /* decrypt */);
316
316
  }