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
@@ -191,7 +191,7 @@ static void ecp_nistz256_windowed_mul(const EC_GROUP *group, P256_POINT *r,
191
191
  const EC_SCALAR *p_scalar) {
192
192
  assert(p != NULL);
193
193
  assert(p_scalar != NULL);
194
- assert(group->field.width == P256_LIMBS);
194
+ assert(group->field.N.width == P256_LIMBS);
195
195
 
196
196
  static const size_t kWindowSize = 5;
197
197
  static const crypto_word_t kMask = (1 << (5 /* kWindowSize */ + 1)) - 1;
@@ -208,7 +208,7 @@ static void ecp_nistz256_windowed_mul(const EC_GROUP *group, P256_POINT *r,
208
208
  // not stored. All other values are actually stored with an offset of -1 in
209
209
  // table.
210
210
  P256_POINT *row = table;
211
- assert(group->field.width == P256_LIMBS);
211
+ assert(group->field.N.width == P256_LIMBS);
212
212
  OPENSSL_memcpy(row[1 - 1].X, p->X.words, P256_LIMBS * sizeof(BN_ULONG));
213
213
  OPENSSL_memcpy(row[1 - 1].Y, p->Y.words, P256_LIMBS * sizeof(BN_ULONG));
214
214
  OPENSSL_memcpy(row[1 - 1].Z, p->Z.words, P256_LIMBS * sizeof(BN_ULONG));
@@ -305,7 +305,7 @@ static void ecp_nistz256_point_mul(const EC_GROUP *group, EC_JACOBIAN *r,
305
305
  alignas(32) P256_POINT out;
306
306
  ecp_nistz256_windowed_mul(group, &out, p, scalar);
307
307
 
308
- assert(group->field.width == P256_LIMBS);
308
+ assert(group->field.N.width == P256_LIMBS);
309
309
  OPENSSL_memcpy(r->X.words, out.X, P256_LIMBS * sizeof(BN_ULONG));
310
310
  OPENSSL_memcpy(r->Y.words, out.Y, P256_LIMBS * sizeof(BN_ULONG));
311
311
  OPENSSL_memcpy(r->Z.words, out.Z, P256_LIMBS * sizeof(BN_ULONG));
@@ -349,7 +349,7 @@ static void ecp_nistz256_point_mul_base(const EC_GROUP *group, EC_JACOBIAN *r,
349
349
  ecp_nistz256_point_add_affine(&p, &p, &t);
350
350
  }
351
351
 
352
- assert(group->field.width == P256_LIMBS);
352
+ assert(group->field.N.width == P256_LIMBS);
353
353
  OPENSSL_memcpy(r->X.words, p.X, P256_LIMBS * sizeof(BN_ULONG));
354
354
  OPENSSL_memcpy(r->Y.words, p.Y, P256_LIMBS * sizeof(BN_ULONG));
355
355
  OPENSSL_memcpy(r->Z.words, p.Z, P256_LIMBS * sizeof(BN_ULONG));
@@ -413,7 +413,7 @@ static void ecp_nistz256_points_mul_public(const EC_GROUP *group,
413
413
  ecp_nistz256_windowed_mul(group, &tmp, p_, p_scalar);
414
414
  ecp_nistz256_point_add(&p, &p, &tmp);
415
415
 
416
- assert(group->field.width == P256_LIMBS);
416
+ assert(group->field.N.width == P256_LIMBS);
417
417
  OPENSSL_memcpy(r->X.words, p.X, P256_LIMBS * sizeof(BN_ULONG));
418
418
  OPENSSL_memcpy(r->Y.words, p.Y, P256_LIMBS * sizeof(BN_ULONG));
419
419
  OPENSSL_memcpy(r->Z.words, p.Z, P256_LIMBS * sizeof(BN_ULONG));
@@ -422,13 +422,14 @@ static void ecp_nistz256_points_mul_public(const EC_GROUP *group,
422
422
  static int ecp_nistz256_get_affine(const EC_GROUP *group,
423
423
  const EC_JACOBIAN *point, EC_FELEM *x,
424
424
  EC_FELEM *y) {
425
- if (ec_GFp_simple_is_at_infinity(group, point)) {
425
+ if (constant_time_declassify_int(
426
+ ec_GFp_simple_is_at_infinity(group, point))) {
426
427
  OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY);
427
428
  return 0;
428
429
  }
429
430
 
430
431
  BN_ULONG z_inv2[P256_LIMBS];
431
- assert(group->field.width == P256_LIMBS);
432
+ assert(group->field.N.width == P256_LIMBS);
432
433
  ecp_nistz256_mod_inverse_sqr_mont(z_inv2, point->Z.words);
433
434
 
434
435
  if (x != NULL) {
@@ -562,8 +563,8 @@ static int ecp_nistz256_scalar_to_montgomery_inv_vartime(const EC_GROUP *group,
562
563
  }
563
564
  #endif
564
565
 
565
- assert(group->order.width == P256_LIMBS);
566
- if (!beeu_mod_inverse_vartime(out->words, in->words, group->order.d)) {
566
+ assert(group->order.N.width == P256_LIMBS);
567
+ if (!beeu_mod_inverse_vartime(out->words, in->words, group->order.N.d)) {
567
568
  return 0;
568
569
  }
569
570
 
@@ -579,8 +580,8 @@ static int ecp_nistz256_cmp_x_coordinate(const EC_GROUP *group,
579
580
  return 0;
580
581
  }
581
582
 
582
- assert(group->order.width == P256_LIMBS);
583
- assert(group->field.width == P256_LIMBS);
583
+ assert(group->order.N.width == P256_LIMBS);
584
+ assert(group->field.N.width == P256_LIMBS);
584
585
 
585
586
  // We wish to compare X/Z^2 with r. This is equivalent to comparing X with
586
587
  // r*Z^2. Note that X and Z are represented in Montgomery form, while r is
@@ -598,10 +599,9 @@ static int ecp_nistz256_cmp_x_coordinate(const EC_GROUP *group,
598
599
  // Therefore there is a small possibility, less than 1/2^128, that group_order
599
600
  // < p.x < P. in that case we need not only to compare against |r| but also to
600
601
  // compare against r+group_order.
601
- if (bn_less_than_words(r->words, group->field_minus_order.words,
602
- P256_LIMBS)) {
603
- // We can ignore the carry because: r + group_order < p < 2^256.
604
- bn_add_words(r_Z2, r->words, group->order.d, P256_LIMBS);
602
+ BN_ULONG carry = bn_add_words(r_Z2, r->words, group->order.N.d, P256_LIMBS);
603
+ if (carry == 0 && bn_less_than_words(r_Z2, group->field.N.d, P256_LIMBS)) {
604
+ // r + group_order < p, so compare (r + group_order) * Z^2 against X.
605
605
  ecp_nistz256_mul_mont(r_Z2, r_Z2, Z2_mont);
606
606
  if (OPENSSL_memcmp(r_Z2, X, sizeof(r_Z2)) == 0) {
607
607
  return 1;
@@ -612,9 +612,6 @@ static int ecp_nistz256_cmp_x_coordinate(const EC_GROUP *group,
612
612
  }
613
613
 
614
614
  DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistz256_method) {
615
- out->group_init = ec_GFp_mont_group_init;
616
- out->group_finish = ec_GFp_mont_group_finish;
617
- out->group_set_curve = ec_GFp_mont_group_set_curve;
618
615
  out->point_get_affine_coordinates = ecp_nistz256_get_affine;
619
616
  out->add = ecp_nistz256_add;
620
617
  out->dbl = ecp_nistz256_dbl;
@@ -324,7 +324,7 @@ static void fiat_p256_point_add(fiat_p256_felem x3, fiat_p256_felem y3,
324
324
  fiat_p256_limb_t is_nontrivial_double = constant_time_is_zero_w(xneq | yneq) &
325
325
  ~constant_time_is_zero_w(z1nz) &
326
326
  ~constant_time_is_zero_w(z2nz);
327
- if (is_nontrivial_double) {
327
+ if (constant_time_declassify_w(is_nontrivial_double)) {
328
328
  fiat_p256_point_double(x3, y3, z3, x1, y1, z1);
329
329
  return;
330
330
  }
@@ -416,7 +416,8 @@ static crypto_word_t fiat_p256_get_bit(const EC_SCALAR *in, int i) {
416
416
  static int ec_GFp_nistp256_point_get_affine_coordinates(
417
417
  const EC_GROUP *group, const EC_JACOBIAN *point, EC_FELEM *x_out,
418
418
  EC_FELEM *y_out) {
419
- if (ec_GFp_simple_is_at_infinity(group, point)) {
419
+ if (constant_time_declassify_int(
420
+ ec_GFp_simple_is_at_infinity(group, point))) {
420
421
  OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY);
421
422
  return 0;
422
423
  }
@@ -709,12 +710,12 @@ static int ec_GFp_nistp256_cmp_x_coordinate(const EC_GROUP *group,
709
710
  // Therefore there is a small possibility, less than 1/2^128, that group_order
710
711
  // < p.x < P. in that case we need not only to compare against |r| but also to
711
712
  // compare against r+group_order.
712
- assert(group->field.width == group->order.width);
713
- if (bn_less_than_words(r->words, group->field_minus_order.words,
714
- group->field.width)) {
715
- // We can ignore the carry because: r + group_order < p < 2^256.
716
- EC_FELEM tmp;
717
- bn_add_words(tmp.words, r->words, group->order.d, group->order.width);
713
+ assert(group->field.N.width == group->order.N.width);
714
+ EC_FELEM tmp;
715
+ BN_ULONG carry =
716
+ bn_add_words(tmp.words, r->words, group->order.N.d, group->field.N.width);
717
+ if (carry == 0 &&
718
+ bn_less_than_words(tmp.words, group->field.N.d, group->field.N.width)) {
718
719
  fiat_p256_from_generic(r_Z2, &tmp);
719
720
  fiat_p256_mul(r_Z2, r_Z2, Z2_mont);
720
721
  if (OPENSSL_memcmp(&r_Z2, &X, sizeof(r_Z2)) == 0) {
@@ -726,9 +727,6 @@ static int ec_GFp_nistp256_cmp_x_coordinate(const EC_GROUP *group,
726
727
  }
727
728
 
728
729
  DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp256_method) {
729
- out->group_init = ec_GFp_mont_group_init;
730
- out->group_finish = ec_GFp_mont_group_finish;
731
- out->group_set_curve = ec_GFp_mont_group_set_curve;
732
730
  out->point_get_affine_coordinates =
733
731
  ec_GFp_nistp256_point_get_affine_coordinates;
734
732
  out->add = ec_GFp_nistp256_add;
@@ -23,8 +23,8 @@
23
23
 
24
24
  int ec_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
25
25
  const BIGNUM *in) {
26
- if (!bn_copy_words(out->words, group->order.width, in) ||
27
- !bn_less_than_words(out->words, group->order.d, group->order.width)) {
26
+ if (!bn_copy_words(out->words, group->order.N.width, in) ||
27
+ !bn_less_than_words(out->words, group->order.N.d, group->order.N.width)) {
28
28
  OPENSSL_PUT_ERROR(EC, EC_R_INVALID_SCALAR);
29
29
  return 0;
30
30
  }
@@ -34,12 +34,12 @@ int ec_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
34
34
  int ec_scalar_equal_vartime(const EC_GROUP *group, const EC_SCALAR *a,
35
35
  const EC_SCALAR *b) {
36
36
  return OPENSSL_memcmp(a->words, b->words,
37
- group->order.width * sizeof(BN_ULONG)) == 0;
37
+ group->order.N.width * sizeof(BN_ULONG)) == 0;
38
38
  }
39
39
 
40
40
  int ec_scalar_is_zero(const EC_GROUP *group, const EC_SCALAR *a) {
41
41
  BN_ULONG mask = 0;
42
- for (int i = 0; i < group->order.width; i++) {
42
+ for (int i = 0; i < group->order.N.width; i++) {
43
43
  mask |= a->words[i];
44
44
  }
45
45
  return mask == 0;
@@ -47,27 +47,27 @@ int ec_scalar_is_zero(const EC_GROUP *group, const EC_SCALAR *a) {
47
47
 
48
48
  int ec_random_nonzero_scalar(const EC_GROUP *group, EC_SCALAR *out,
49
49
  const uint8_t additional_data[32]) {
50
- return bn_rand_range_words(out->words, 1, group->order.d, group->order.width,
51
- additional_data);
50
+ return bn_rand_range_words(out->words, 1, group->order.N.d,
51
+ group->order.N.width, additional_data);
52
52
  }
53
53
 
54
54
  void ec_scalar_to_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len,
55
55
  const EC_SCALAR *in) {
56
- size_t len = BN_num_bytes(&group->order);
57
- bn_words_to_big_endian(out, len, in->words, group->order.width);
56
+ size_t len = BN_num_bytes(&group->order.N);
57
+ bn_words_to_big_endian(out, len, in->words, group->order.N.width);
58
58
  *out_len = len;
59
59
  }
60
60
 
61
61
  int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out,
62
62
  const uint8_t *in, size_t len) {
63
- if (len != BN_num_bytes(&group->order)) {
63
+ if (len != BN_num_bytes(&group->order.N)) {
64
64
  OPENSSL_PUT_ERROR(EC, EC_R_INVALID_SCALAR);
65
65
  return 0;
66
66
  }
67
67
 
68
- bn_big_endian_to_words(out->words, group->order.width, in, len);
68
+ bn_big_endian_to_words(out->words, group->order.N.width, in, len);
69
69
 
70
- if (!bn_less_than_words(out->words, group->order.d, group->order.width)) {
70
+ if (!bn_less_than_words(out->words, group->order.N.d, group->order.N.width)) {
71
71
  OPENSSL_PUT_ERROR(EC, EC_R_INVALID_SCALAR);
72
72
  return 0;
73
73
  }
@@ -78,15 +78,15 @@ int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out,
78
78
  void ec_scalar_reduce(const EC_GROUP *group, EC_SCALAR *out,
79
79
  const BN_ULONG *words, size_t num) {
80
80
  // Convert "from" Montgomery form so the value is reduced modulo the order.
81
- bn_from_montgomery_small(out->words, group->order.width, words, num,
82
- group->order_mont);
81
+ bn_from_montgomery_small(out->words, group->order.N.width, words, num,
82
+ &group->order);
83
83
  // Convert "to" Montgomery form to remove the R^-1 factor added.
84
84
  ec_scalar_to_montgomery(group, out, out);
85
85
  }
86
86
 
87
87
  void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
88
88
  const EC_SCALAR *b) {
89
- const BIGNUM *order = &group->order;
89
+ const BIGNUM *order = &group->order.N;
90
90
  BN_ULONG tmp[EC_MAX_WORDS];
91
91
  bn_mod_add_words(r->words, a->words, b->words, order->d, tmp, order->width);
92
92
  OPENSSL_cleanse(tmp, sizeof(tmp));
@@ -94,7 +94,7 @@ void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
94
94
 
95
95
  void ec_scalar_sub(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
96
96
  const EC_SCALAR *b) {
97
- const BIGNUM *order = &group->order;
97
+ const BIGNUM *order = &group->order.N;
98
98
  BN_ULONG tmp[EC_MAX_WORDS];
99
99
  bn_mod_sub_words(r->words, a->words, b->words, order->d, tmp, order->width);
100
100
  OPENSSL_cleanse(tmp, sizeof(tmp));
@@ -108,35 +108,35 @@ void ec_scalar_neg(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a) {
108
108
 
109
109
  void ec_scalar_select(const EC_GROUP *group, EC_SCALAR *out, BN_ULONG mask,
110
110
  const EC_SCALAR *a, const EC_SCALAR *b) {
111
- const BIGNUM *order = &group->order;
111
+ const BIGNUM *order = &group->order.N;
112
112
  bn_select_words(out->words, mask, a->words, b->words, order->width);
113
113
  }
114
114
 
115
115
  void ec_scalar_to_montgomery(const EC_GROUP *group, EC_SCALAR *r,
116
116
  const EC_SCALAR *a) {
117
- const BIGNUM *order = &group->order;
118
- bn_to_montgomery_small(r->words, a->words, order->width, group->order_mont);
117
+ const BIGNUM *order = &group->order.N;
118
+ bn_to_montgomery_small(r->words, a->words, order->width, &group->order);
119
119
  }
120
120
 
121
121
  void ec_scalar_from_montgomery(const EC_GROUP *group, EC_SCALAR *r,
122
122
  const EC_SCALAR *a) {
123
- const BIGNUM *order = &group->order;
123
+ const BIGNUM *order = &group->order.N;
124
124
  bn_from_montgomery_small(r->words, order->width, a->words, order->width,
125
- group->order_mont);
125
+ &group->order);
126
126
  }
127
127
 
128
128
  void ec_scalar_mul_montgomery(const EC_GROUP *group, EC_SCALAR *r,
129
129
  const EC_SCALAR *a, const EC_SCALAR *b) {
130
- const BIGNUM *order = &group->order;
130
+ const BIGNUM *order = &group->order.N;
131
131
  bn_mod_mul_montgomery_small(r->words, a->words, b->words, order->width,
132
- group->order_mont);
132
+ &group->order);
133
133
  }
134
134
 
135
135
  void ec_simple_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r,
136
136
  const EC_SCALAR *a) {
137
- const BIGNUM *order = &group->order;
137
+ const BIGNUM *order = &group->order.N;
138
138
  bn_mod_inverse0_prime_mont_small(r->words, a->words, order->width,
139
- group->order_mont);
139
+ &group->order);
140
140
  }
141
141
 
142
142
  int ec_simple_scalar_to_montgomery_inv_vartime(const EC_GROUP *group,
@@ -88,16 +88,6 @@
88
88
  // used, it is a Montgomery representation (i.e. 'encoding' means multiplying
89
89
  // by some factor R).
90
90
 
91
- int ec_GFp_simple_group_init(EC_GROUP *group) {
92
- BN_init(&group->field);
93
- group->a_is_minus3 = 0;
94
- return 1;
95
- }
96
-
97
- void ec_GFp_simple_group_finish(EC_GROUP *group) {
98
- BN_free(&group->field);
99
- }
100
-
101
91
  int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p,
102
92
  const BIGNUM *a, const BIGNUM *b,
103
93
  BN_CTX *ctx) {
@@ -114,17 +104,11 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p,
114
104
  goto err;
115
105
  }
116
106
 
117
- // group->field
118
- if (!BN_copy(&group->field, p)) {
119
- goto err;
120
- }
121
- BN_set_negative(&group->field, 0);
122
- // Store the field in minimal form, so it can be used with |BN_ULONG| arrays.
123
- bn_set_minimal_width(&group->field);
124
-
125
- if (!ec_bignum_to_felem(group, &group->a, a) ||
107
+ if (!BN_MONT_CTX_set(&group->field, p, ctx) ||
108
+ !ec_bignum_to_felem(group, &group->a, a) ||
126
109
  !ec_bignum_to_felem(group, &group->b, b) ||
127
- !ec_bignum_to_felem(group, &group->one, BN_value_one())) {
110
+ // Reuse Z from the generator to cache the value one.
111
+ !ec_bignum_to_felem(group, &group->generator.raw.Z, BN_value_one())) {
128
112
  goto err;
129
113
  }
130
114
 
@@ -133,7 +117,7 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p,
133
117
  !BN_add_word(tmp, 3)) {
134
118
  goto err;
135
119
  }
136
- group->a_is_minus3 = (0 == BN_cmp(tmp, &group->field));
120
+ group->a_is_minus3 = (0 == BN_cmp(tmp, &group->field.N));
137
121
 
138
122
  ret = 1;
139
123
 
@@ -144,7 +128,7 @@ err:
144
128
 
145
129
  int ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
146
130
  BIGNUM *b) {
147
- if ((p != NULL && !BN_copy(p, &group->field)) ||
131
+ if ((p != NULL && !BN_copy(p, &group->field.N)) ||
148
132
  (a != NULL && !ec_felem_to_bignum(group, a, &group->a)) ||
149
133
  (b != NULL && !ec_felem_to_bignum(group, b, &group->b))) {
150
134
  return 0;
@@ -329,21 +313,21 @@ int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_JACOBIAN *p,
329
313
 
330
314
  void ec_GFp_simple_felem_to_bytes(const EC_GROUP *group, uint8_t *out,
331
315
  size_t *out_len, const EC_FELEM *in) {
332
- size_t len = BN_num_bytes(&group->field);
333
- bn_words_to_big_endian(out, len, in->words, group->field.width);
316
+ size_t len = BN_num_bytes(&group->field.N);
317
+ bn_words_to_big_endian(out, len, in->words, group->field.N.width);
334
318
  *out_len = len;
335
319
  }
336
320
 
337
321
  int ec_GFp_simple_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out,
338
322
  const uint8_t *in, size_t len) {
339
- if (len != BN_num_bytes(&group->field)) {
323
+ if (len != BN_num_bytes(&group->field.N)) {
340
324
  OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR);
341
325
  return 0;
342
326
  }
343
327
 
344
- bn_big_endian_to_words(out->words, group->field.width, in, len);
328
+ bn_big_endian_to_words(out->words, group->field.N.width, in, len);
345
329
 
346
- if (!bn_less_than_words(out->words, group->field.d, group->field.width)) {
330
+ if (!bn_less_than_words(out->words, group->field.N.d, group->field.N.width)) {
347
331
  OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR);
348
332
  return 0;
349
333
  }
@@ -40,7 +40,7 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_JACOBIAN *r,
40
40
  }
41
41
 
42
42
  // Divide bits in |scalar| into windows.
43
- unsigned bits = BN_num_bits(&group->order);
43
+ unsigned bits = EC_GROUP_order_bits(group);
44
44
  int r_is_at_infinity = 1;
45
45
  for (unsigned i = bits - 1; i < bits; i--) {
46
46
  if (!r_is_at_infinity) {
@@ -48,7 +48,7 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_JACOBIAN *r,
48
48
  }
49
49
  if (i % 5 == 0) {
50
50
  // Compute the next window value.
51
- const size_t width = group->order.width;
51
+ const size_t width = group->order.N.width;
52
52
  uint8_t window = bn_is_bit_set_words(scalar->words, width, i + 4) << 4;
53
53
  window |= bn_is_bit_set_words(scalar->words, width, i + 3) << 3;
54
54
  window |= bn_is_bit_set_words(scalar->words, width, i + 2) << 2;
@@ -78,7 +78,7 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_JACOBIAN *r,
78
78
 
79
79
  void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_JACOBIAN *r,
80
80
  const EC_SCALAR *scalar) {
81
- ec_GFp_mont_mul(group, r, &group->generator->raw, scalar);
81
+ ec_GFp_mont_mul(group, r, &group->generator.raw, scalar);
82
82
  }
83
83
 
84
84
  static void ec_GFp_mont_batch_precomp(const EC_GROUP *group, EC_JACOBIAN *out,
@@ -99,7 +99,7 @@ static void ec_GFp_mont_batch_get_window(const EC_GROUP *group,
99
99
  EC_JACOBIAN *out,
100
100
  const EC_JACOBIAN precomp[17],
101
101
  const EC_SCALAR *scalar, unsigned i) {
102
- const size_t width = group->order.width;
102
+ const size_t width = group->order.N.width;
103
103
  uint8_t window = bn_is_bit_set_words(scalar->words, width, i + 4) << 5;
104
104
  window |= bn_is_bit_set_words(scalar->words, width, i + 3) << 4;
105
105
  window |= bn_is_bit_set_words(scalar->words, width, i + 2) << 3;
@@ -138,7 +138,7 @@ void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_JACOBIAN *r,
138
138
  }
139
139
 
140
140
  // Divide bits in |scalar| into windows.
141
- unsigned bits = BN_num_bits(&group->order);
141
+ unsigned bits = EC_GROUP_order_bits(group);
142
142
  int r_is_at_infinity = 1;
143
143
  for (unsigned i = bits; i <= bits; i--) {
144
144
  if (!r_is_at_infinity) {
@@ -169,7 +169,7 @@ void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_JACOBIAN *r,
169
169
  }
170
170
 
171
171
  static unsigned ec_GFp_mont_comb_stride(const EC_GROUP *group) {
172
- return (BN_num_bits(&group->field) + EC_MONT_PRECOMP_COMB_SIZE - 1) /
172
+ return (EC_GROUP_get_degree(group) + EC_MONT_PRECOMP_COMB_SIZE - 1) /
173
173
  EC_MONT_PRECOMP_COMB_SIZE;
174
174
  }
175
175
 
@@ -212,7 +212,7 @@ static void ec_GFp_mont_get_comb_window(const EC_GROUP *group,
212
212
  EC_JACOBIAN *out,
213
213
  const EC_PRECOMP *precomp,
214
214
  const EC_SCALAR *scalar, unsigned i) {
215
- const size_t width = group->order.width;
215
+ const size_t width = group->order.N.width;
216
216
  unsigned stride = ec_GFp_mont_comb_stride(group);
217
217
  // Select the bits corresponding to the comb shifted up by |i|.
218
218
  unsigned window = 0;
@@ -230,7 +230,7 @@ static void ec_GFp_mont_get_comb_window(const EC_GROUP *group,
230
230
  ec_felem_select(group, &out->Y, match, &precomp->comb[j].Y, &out->Y);
231
231
  }
232
232
  BN_ULONG is_infinity = constant_time_is_zero_w(window);
233
- ec_felem_select(group, &out->Z, is_infinity, &out->Z, &group->one);
233
+ ec_felem_select(group, &out->Z, is_infinity, &out->Z, ec_felem_one(group));
234
234
  }
235
235
 
236
236
  void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_JACOBIAN *r,
@@ -138,8 +138,8 @@ void ec_compute_wNAF(const EC_GROUP *group, int8_t *out,
138
138
  // we shift and add at most one copy of |bit|, this will continue to hold
139
139
  // afterwards.
140
140
  window_val >>= 1;
141
- window_val +=
142
- bit * bn_is_bit_set_words(scalar->words, group->order.width, j + w + 1);
141
+ window_val += bit * bn_is_bit_set_words(scalar->words, group->order.N.width,
142
+ j + w + 1);
143
143
  assert(window_val <= next_bit);
144
144
  }
145
145
 
@@ -183,7 +183,7 @@ int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_JACOBIAN *r,
183
183
  const EC_SCALAR *g_scalar,
184
184
  const EC_JACOBIAN *points,
185
185
  const EC_SCALAR *scalars, size_t num) {
186
- size_t bits = BN_num_bits(&group->order);
186
+ size_t bits = EC_GROUP_order_bits(group);
187
187
  size_t wNAF_len = bits + 1;
188
188
 
189
189
  int ret = 0;
@@ -214,7 +214,7 @@ int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_JACOBIAN *r,
214
214
  int8_t g_wNAF[EC_MAX_BYTES * 8 + 1];
215
215
  EC_JACOBIAN g_precomp[EC_WNAF_TABLE_SIZE];
216
216
  assert(wNAF_len <= OPENSSL_ARRAY_SIZE(g_wNAF));
217
- const EC_JACOBIAN *g = &group->generator->raw;
217
+ const EC_JACOBIAN *g = &group->generator.raw;
218
218
  if (g_scalar != NULL) {
219
219
  ec_compute_wNAF(group, g_wNAF, g_scalar, bits, EC_WNAF_WINDOW_BITS);
220
220
  compute_precomp(group, g_precomp, g, EC_WNAF_TABLE_SIZE);
@@ -71,7 +71,7 @@
71
71
  // ECDSA.
72
72
  static void digest_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
73
73
  const uint8_t *digest, size_t digest_len) {
74
- const BIGNUM *order = &group->order;
74
+ const BIGNUM *order = EC_GROUP_get0_order(group);
75
75
  size_t num_bits = BN_num_bits(order);
76
76
  // Need to truncate digest if it is too long: first truncate whole bytes.
77
77
  size_t num_bytes = (num_bits + 7) / 8;
@@ -223,7 +223,7 @@ static ECDSA_SIG *ecdsa_sign_impl(const EC_GROUP *group, int *out_retry,
223
223
  return NULL;
224
224
  }
225
225
 
226
- if (ec_scalar_is_zero(group, &r)) {
226
+ if (constant_time_declassify_int(ec_scalar_is_zero(group, &r))) {
227
227
  *out_retry = 1;
228
228
  return NULL;
229
229
  }
@@ -250,11 +250,13 @@ static ECDSA_SIG *ecdsa_sign_impl(const EC_GROUP *group, int *out_retry,
250
250
  ec_scalar_inv0_montgomery(group, &tmp, k); // tmp = k^-1 R^2
251
251
  ec_scalar_from_montgomery(group, &tmp, &tmp); // tmp = k^-1 R
252
252
  ec_scalar_mul_montgomery(group, &s, &s, &tmp);
253
- if (ec_scalar_is_zero(group, &s)) {
253
+ if (constant_time_declassify_int(ec_scalar_is_zero(group, &s))) {
254
254
  *out_retry = 1;
255
255
  return NULL;
256
256
  }
257
257
 
258
+ CONSTTIME_DECLASSIFY(r.words, sizeof(r.words));
259
+ CONSTTIME_DECLASSIFY(s.words, sizeof(r.words));
258
260
  ECDSA_SIG *ret = ECDSA_SIG_new();
259
261
  if (ret == NULL || //
260
262
  !bn_set_words(ret->r, r.words, order->width) ||
@@ -347,6 +349,10 @@ ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len,
347
349
  goto out;
348
350
  }
349
351
 
352
+ // TODO(davidben): Move this inside |ec_random_nonzero_scalar| or lower, so
353
+ // that all scalars we generate are, by default, secret.
354
+ CONSTTIME_SECRET(k.words, sizeof(k.words));
355
+
350
356
  int retry;
351
357
  ret = ecdsa_sign_impl(group, &retry, priv_key, &k, digest, digest_len);
352
358
  if (ret != NULL || !retry) {
@@ -94,7 +94,7 @@ int HKDF_expand(uint8_t *out_key, size_t out_len, const EVP_MD *digest,
94
94
  }
95
95
 
96
96
  todo = digest_len;
97
- if (done + todo > out_len) {
97
+ if (todo > out_len - done) {
98
98
  todo = out_len - done;
99
99
  }
100
100
  OPENSSL_memcpy(out_key + done, previous, todo);
@@ -38,7 +38,7 @@ static_assert(MADV_WIPEONFORK == 18, "MADV_WIPEONFORK is not 18");
38
38
 
39
39
  DEFINE_STATIC_ONCE(g_fork_detect_once);
40
40
  DEFINE_STATIC_MUTEX(g_fork_detect_lock);
41
- DEFINE_BSS_GET(volatile char *, g_fork_detect_addr);
41
+ DEFINE_BSS_GET(CRYPTO_atomic_u32 *, g_fork_detect_addr);
42
42
  DEFINE_BSS_GET(uint64_t, g_fork_generation);
43
43
  DEFINE_BSS_GET(int, g_force_madv_wipeonfork);
44
44
  DEFINE_BSS_GET(int, g_force_madv_wipeonfork_enabled);
@@ -70,7 +70,7 @@ static void init_fork_detect(void) {
70
70
  return;
71
71
  }
72
72
 
73
- *((volatile char *) addr) = 1;
73
+ CRYPTO_atomic_store_u32(addr, 1);
74
74
  *g_fork_detect_addr_bss_get() = addr;
75
75
  *g_fork_generation_bss_get() = 1;
76
76
  }
@@ -83,16 +83,12 @@ uint64_t CRYPTO_get_fork_generation(void) {
83
83
  // is initialised atomically, even if multiple threads enter this function
84
84
  // concurrently.
85
85
  //
86
- // In the limit, the kernel may clear WIPEONFORK pages while a multi-threaded
87
- // process is running. (For example, because a VM was cloned.) Therefore a
88
- // lock is used below to synchronise the potentially multiple threads that may
89
- // concurrently observe the cleared flag.
86
+ // Additionally, while the kernel will only clear WIPEONFORK at a point when a
87
+ // child process is single-threaded, the child may become multi-threaded
88
+ // before it observes this. Therefore, we must synchronize the logic below.
90
89
 
91
90
  CRYPTO_once(g_fork_detect_once_bss_get(), init_fork_detect);
92
- // This pointer is |volatile| because the value pointed to may be changed by
93
- // external forces (i.e. the kernel wiping the page) thus the compiler must
94
- // not assume that it has exclusive access to it.
95
- volatile char *const flag_ptr = *g_fork_detect_addr_bss_get();
91
+ CRYPTO_atomic_u32 *const flag_ptr = *g_fork_detect_addr_bss_get();
96
92
  if (flag_ptr == NULL) {
97
93
  // Our kernel is too old to support |MADV_WIPEONFORK| or
98
94
  // |g_force_madv_wipeonfork| is set.
@@ -105,30 +101,36 @@ uint64_t CRYPTO_get_fork_generation(void) {
105
101
  return 0;
106
102
  }
107
103
 
108
- struct CRYPTO_STATIC_MUTEX *const lock = g_fork_detect_lock_bss_get();
104
+ // In the common case, try to observe the flag without taking a lock. This
105
+ // avoids cacheline contention in the PRNG.
109
106
  uint64_t *const generation_ptr = g_fork_generation_bss_get();
110
-
111
- CRYPTO_STATIC_MUTEX_lock_read(lock);
112
- uint64_t current_generation = *generation_ptr;
113
- if (*flag_ptr) {
114
- CRYPTO_STATIC_MUTEX_unlock_read(lock);
115
- return current_generation;
107
+ if (CRYPTO_atomic_load_u32(flag_ptr) != 0) {
108
+ // If we observe a non-zero flag, it is safe to read |generation_ptr|
109
+ // without a lock. The flag and generation number are fixed for this copy of
110
+ // the address space.
111
+ return *generation_ptr;
116
112
  }
117
113
 
118
- CRYPTO_STATIC_MUTEX_unlock_read(lock);
119
- CRYPTO_STATIC_MUTEX_lock_write(lock);
120
- current_generation = *generation_ptr;
121
- if (*flag_ptr == 0) {
114
+ // The flag was zero. The generation number must be incremented, but other
115
+ // threads may have concurrently observed the zero, so take a lock before
116
+ // incrementing.
117
+ CRYPTO_MUTEX *const lock = g_fork_detect_lock_bss_get();
118
+ CRYPTO_MUTEX_lock_write(lock);
119
+ uint64_t current_generation = *generation_ptr;
120
+ if (CRYPTO_atomic_load_u32(flag_ptr) == 0) {
122
121
  // A fork has occurred.
123
- *flag_ptr = 1;
124
-
125
122
  current_generation++;
126
123
  if (current_generation == 0) {
124
+ // Zero means fork detection isn't supported, so skip that value.
127
125
  current_generation = 1;
128
126
  }
127
+
128
+ // We must update |generation_ptr| before |flag_ptr|. Other threads may
129
+ // observe |flag_ptr| without taking a lock.
129
130
  *generation_ptr = current_generation;
131
+ CRYPTO_atomic_store_u32(flag_ptr, 1);
130
132
  }
131
- CRYPTO_STATIC_MUTEX_unlock_write(lock);
133
+ CRYPTO_MUTEX_unlock_write(lock);
132
134
 
133
135
  return current_generation;
134
136
  }
@@ -138,8 +140,20 @@ void CRYPTO_fork_detect_force_madv_wipeonfork_for_testing(int on) {
138
140
  *g_force_madv_wipeonfork_enabled_bss_get() = on;
139
141
  }
140
142
 
141
- #else // !OPENSSL_LINUX
143
+ #elif defined(OPENSSL_WINDOWS) || defined(OPENSSL_TRUSTY)
142
144
 
145
+ // These platforms are guaranteed not to fork, and therefore do not require
146
+ // fork detection support. Returning a constant non zero value makes BoringSSL
147
+ // assume address space duplication is not a concern and adding entropy to
148
+ // every RAND_bytes call is not needed.
149
+ uint64_t CRYPTO_get_fork_generation(void) { return 0xc0ffee; }
150
+
151
+ #else
152
+
153
+ // These platforms may fork, but we do not have a mitigation mechanism in
154
+ // place. Returning a constant zero value makes BoringSSL assume that address
155
+ // space duplication could have occured on any call entropy must be added to
156
+ // every RAND_bytes call.
143
157
  uint64_t CRYPTO_get_fork_generation(void) { return 0; }
144
158
 
145
- #endif // OPENSSL_LINUX
159
+ #endif