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.
- checksums.yaml +4 -4
- data/Makefile +29 -22
- data/include/grpc/event_engine/event_engine.h +22 -32
- data/include/grpc/impl/grpc_types.h +3 -0
- data/include/grpc/support/port_platform.h +29 -23
- data/src/core/ext/filters/client_channel/client_channel.cc +44 -8
- data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +5 -0
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +21 -52
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +19 -7
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +25 -35
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +78 -132
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +38 -15
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +3 -5
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +22 -6
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric_internal.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +97 -71
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +2 -16
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +56 -11
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.h +25 -0
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -32
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +4 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +20 -79
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +31 -19
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +7 -41
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +3 -67
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +8 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +31 -74
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +7 -51
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +16 -87
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +16 -50
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -74
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -4
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +69 -59
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +7 -2
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +1 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +25 -13
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +366 -311
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +17 -1
- data/src/core/ext/filters/client_channel/retry_filter.cc +39 -2498
- data/src/core/ext/filters/client_channel/retry_filter.h +91 -1
- data/src/core/ext/filters/client_channel/retry_filter_legacy_call_data.cc +2052 -0
- data/src/core/ext/filters/client_channel/retry_filter_legacy_call_data.h +442 -0
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +38 -58
- data/src/core/ext/filters/client_channel/subchannel.h +3 -3
- data/src/core/ext/filters/client_channel/subchannel_interface_internal.h +3 -0
- data/src/core/ext/filters/rbac/rbac_filter.cc +40 -111
- data/src/core/ext/filters/rbac/rbac_filter.h +12 -30
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +162 -86
- data/src/core/ext/filters/stateful_session/stateful_session_filter.h +0 -6
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +7 -4
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +131 -186
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +6569 -174
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +2278 -441
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +9 -8
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +8 -4
- data/src/core/ext/transport/chttp2/transport/parsing.cc +15 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +2 -3
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +27 -6
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +143 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +2 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +0 -39
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +13 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +35 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +17 -13
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +85 -20
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +26 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +45 -3
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c +4 -3
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.h +21 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +30 -6
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +180 -0
- data/src/core/ext/upb-generated/envoy/data/accesslog/v3/accesslog.upb.c +558 -0
- data/src/core/ext/upb-generated/envoy/data/accesslog/v3/accesslog.upb.h +2710 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +30 -11
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +53 -24
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +30 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +110 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +41 -15
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +150 -27
- 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
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.c +47 -0
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.h +93 -0
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +88 -76
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +11 -12
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +0 -5
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +162 -160
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +129 -118
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +141 -135
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/metrics_service.upbdefs.c +19 -12
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +38 -30
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/data/accesslog/v3/accesslog.upbdefs.c +402 -0
- data/src/core/ext/upbdefs-generated/envoy/data/accesslog/v3/accesslog.upbdefs.h +111 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +80 -74
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +63 -47
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +315 -293
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +29 -29
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +33 -30
- data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -13
- data/src/core/ext/xds/xds_client_grpc.cc +11 -6
- data/src/core/ext/xds/xds_client_grpc.h +16 -2
- data/src/core/ext/xds/xds_client_stats.h +10 -0
- data/src/core/ext/xds/xds_cluster.cc +26 -16
- data/src/core/ext/xds/xds_endpoint.cc +4 -7
- data/src/core/ext/xds/xds_health_status.cc +0 -17
- data/src/core/ext/xds/xds_health_status.h +5 -25
- data/src/core/ext/xds/xds_lb_policy_registry.cc +39 -0
- data/src/core/ext/xds/xds_route_config.cc +4 -0
- data/src/core/ext/xds/xds_transport_grpc.cc +1 -3
- data/src/core/lib/address_utils/parse_address.cc +63 -1
- data/src/core/lib/address_utils/parse_address.h +8 -0
- data/src/core/lib/address_utils/sockaddr_utils.cc +46 -1
- data/src/core/lib/address_utils/sockaddr_utils.h +2 -2
- data/src/core/lib/channel/channel_args.cc +21 -10
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/connected_channel.cc +4 -1
- data/src/core/lib/channel/promise_based_filter.h +1 -0
- data/src/core/lib/debug/trace.cc +1 -4
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +2 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +1 -1
- data/src/core/lib/event_engine/event_engine.cc +0 -12
- data/src/core/lib/event_engine/forkable.cc +47 -42
- data/src/core/lib/event_engine/handle_containers.h +0 -4
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +4 -6
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -6
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +25 -11
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +3 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +2 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +8 -12
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +37 -27
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +2 -0
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +4 -2
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +42 -2
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +6 -0
- data/src/core/lib/event_engine/posix_engine/timer.h +10 -37
- data/src/core/lib/event_engine/tcp_socket_utils.cc +67 -7
- data/src/core/lib/event_engine/tcp_socket_utils.h +3 -0
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +90 -37
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +32 -12
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +12 -21
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +8 -12
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +55 -54
- data/src/core/lib/event_engine/windows/windows_endpoint.h +15 -12
- data/src/core/lib/event_engine/windows/windows_engine.cc +2 -1
- data/src/core/lib/event_engine/windows/windows_engine.h +8 -12
- data/src/core/lib/experiments/config.cc +60 -22
- data/src/core/lib/experiments/config.h +20 -8
- data/src/core/lib/experiments/experiments.cc +278 -0
- data/src/core/lib/experiments/experiments.h +59 -1
- data/src/core/lib/gprpp/dual_ref_counted.h +9 -9
- data/src/core/lib/gprpp/fork.cc +8 -9
- data/src/core/lib/gprpp/fork.h +6 -5
- data/src/core/lib/gprpp/if_list.h +4530 -0
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +6 -6
- data/src/core/lib/gprpp/sorted_pack.h +3 -12
- data/src/core/lib/gprpp/status_helper.h +16 -15
- data/src/core/lib/gprpp/time.h +12 -0
- data/src/core/lib/gprpp/type_list.h +32 -0
- data/src/core/lib/http/httpcli.h +6 -9
- data/src/core/lib/iomgr/error.cc +32 -2
- data/src/core/lib/iomgr/error.h +9 -10
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +5 -7
- data/src/core/lib/iomgr/ev_poll_posix.cc +6 -5
- data/src/core/lib/iomgr/exec_ctx.h +11 -0
- data/src/core/lib/iomgr/pollset.h +4 -5
- data/src/core/lib/iomgr/port.h +10 -0
- data/src/core/lib/iomgr/resolve_address.cc +13 -1
- data/src/core/lib/iomgr/resolve_address.h +17 -3
- data/src/core/lib/iomgr/sockaddr_posix.h +7 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +29 -0
- data/src/core/lib/iomgr/socket_utils_posix.cc +2 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +6 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +4 -1
- data/src/core/lib/iomgr/tcp_posix.cc +21 -4
- data/src/core/lib/iomgr/tcp_server_posix.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +5 -2
- data/src/core/lib/iomgr/tcp_windows.cc +1 -3
- data/src/core/lib/iomgr/vsock.cc +59 -0
- data/src/core/lib/iomgr/vsock.h +38 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.h +3 -6
- data/src/core/lib/load_balancing/delegating_helper.h +115 -0
- data/src/core/lib/load_balancing/lb_policy.h +20 -0
- data/src/core/lib/load_balancing/subchannel_interface.h +6 -0
- data/src/core/lib/promise/party.h +1 -1
- data/src/core/lib/resolver/resolver_factory.h +3 -2
- data/src/core/lib/resolver/server_address.cc +9 -94
- data/src/core/lib/resolver/server_address.h +10 -64
- data/src/core/lib/resource_quota/memory_quota.h +1 -1
- data/src/core/lib/security/credentials/channel_creds_registry.h +51 -27
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +169 -9
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +1 -1
- data/src/core/lib/security/credentials/composite/composite_credentials.h +3 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +40 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.h +6 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +30 -38
- data/src/core/lib/security/credentials/fake/fake_credentials.h +28 -0
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -1
- data/src/core/lib/security/credentials/tls/tls_credentials.h +3 -1
- data/src/core/lib/service_config/service_config_call_data.h +5 -0
- data/src/core/lib/slice/slice.h +16 -0
- data/src/core/lib/surface/call.cc +31 -29
- data/src/core/lib/surface/server.h +2 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/metadata_batch.cc +7 -7
- data/src/core/lib/transport/metadata_batch.h +86 -48
- data/src/core/lib/transport/parsed_metadata.h +34 -20
- data/src/core/lib/transport/simple_slice_based_metadata.h +9 -2
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +4 -6
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -2
- data/src/core/tsi/ssl_transport_security.cc +28 -7
- data/src/ruby/bin/math_pb.rb +24 -18
- data/src/ruby/ext/grpc/extconf.rb +19 -18
- data/src/ruby/ext/grpc/rb_call.c +62 -39
- data/src/ruby/ext/grpc/rb_call_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_channel.c +126 -49
- data/src/ruby/ext/grpc/rb_channel.h +1 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +16 -2
- data/src/ruby/ext/grpc/rb_channel_args.h +4 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_compression_options.c +0 -1
- data/src/ruby/ext/grpc/rb_event_thread.c +22 -6
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -0
- data/src/ruby/ext/grpc/rb_grpc.c +192 -30
- data/src/ruby/ext/grpc/rb_grpc.h +8 -2
- data/src/ruby/ext/grpc/rb_server.c +62 -45
- data/src/ruby/ext/grpc/rb_server_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +0 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +2 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +24 -13
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +24 -3
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +25 -111
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +25 -2
- data/third_party/boringssl-with-bazel/err_data.c +552 -552
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +34 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +4 -1
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +7 -8
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +19 -1
- data/third_party/boringssl-with-bazel/src/crypto/chacha/internal.h +8 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +28 -185
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +3 -7
- data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +49 -46
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_64_adx.c +18 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +2809 -7417
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +27 -5
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +20 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +110 -72
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_derive.c +4 -3
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +15 -14
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +13 -10
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +35 -12
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +3 -7
- data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +7 -6
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +34 -72
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +12 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +5 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +12 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +17 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +51 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +5 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/builtin_curves.h +277 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +180 -404
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +24 -57
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +17 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +33 -71
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +18 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +5 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +15 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +9 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +24 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +11 -27
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +9 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hkdf/hkdf.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +40 -26
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +21 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +38 -19
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +2 -29
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +55 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +33 -52
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +3 -8
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +198 -79
- data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +5 -4
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +7 -8
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +19 -23
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +8 -5
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +7 -6
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c +6 -12
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +48 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/{fuchsia.c → ios.c} +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/{refcount_no_threads.c → rand_extra/trusty.c} +15 -19
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +41 -19
- data/third_party/boringssl-with-bazel/src/crypto/{refcount_c11.c → refcount.c} +11 -17
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +147 -72
- data/third_party/boringssl-with-bazel/src/crypto/thread_none.c +0 -8
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +6 -35
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +5 -26
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +14 -18
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +54 -143
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +7 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +8 -12
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +19 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +4 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +4 -119
- data/third_party/boringssl-with-bazel/src/include/openssl/asm_base.h +207 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +5 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +2 -116
- data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +0 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +5 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +0 -21
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +21 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +19 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +11 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +13 -14
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +0 -61
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +127 -81
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +224 -209
- data/third_party/boringssl-with-bazel/src/include/openssl/target.h +154 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +1 -29
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +4 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +3 -2
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +9 -65
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +20 -20
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +4 -11
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +24 -18
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +37 -30
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +125 -26
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +2 -3
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_adx.h +691 -0
- data/third_party/upb/upb/collections/map.c +3 -3
- metadata +27 -12
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.cc +0 -42
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.h +0 -64
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +0 -177
- data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -68
- 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 (
|
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
|
-
|
602
|
-
|
603
|
-
//
|
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 (
|
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
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
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,
|
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->
|
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->
|
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->
|
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->
|
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->
|
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
|
-
|
118
|
-
|
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
|
-
|
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 =
|
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
|
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 =
|
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 (
|
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,
|
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
|
-
|
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 =
|
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
|
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 =
|
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) {
|
@@ -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(
|
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
|
-
|
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
|
-
//
|
87
|
-
// process is
|
88
|
-
//
|
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
|
-
|
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
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
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
|
-
#
|
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
|
159
|
+
#endif
|