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
@@ -106,7 +106,7 @@ err:
|
|
106
106
|
}
|
107
107
|
|
108
108
|
int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt,
|
109
|
-
size_t salt_len, uint8_t id,
|
109
|
+
size_t salt_len, uint8_t id, uint32_t iterations,
|
110
110
|
size_t out_len, uint8_t *out, const EVP_MD *md) {
|
111
111
|
// See https://tools.ietf.org/html/rfc7292#appendix-B. Quoted parts of the
|
112
112
|
// specification have errata applied and other typos fixed.
|
@@ -182,7 +182,7 @@ int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt,
|
|
182
182
|
!EVP_DigestFinal_ex(&ctx, A, &A_len)) {
|
183
183
|
goto err;
|
184
184
|
}
|
185
|
-
for (
|
185
|
+
for (uint32_t iter = 1; iter < iterations; iter++) {
|
186
186
|
if (!EVP_DigestInit_ex(&ctx, md, NULL) ||
|
187
187
|
!EVP_DigestUpdate(&ctx, A, A_len) ||
|
188
188
|
!EVP_DigestFinal_ex(&ctx, A, &A_len)) {
|
@@ -229,7 +229,7 @@ err:
|
|
229
229
|
}
|
230
230
|
|
231
231
|
static int pkcs12_pbe_cipher_init(const struct pbe_suite *suite,
|
232
|
-
EVP_CIPHER_CTX *ctx,
|
232
|
+
EVP_CIPHER_CTX *ctx, uint32_t iterations,
|
233
233
|
const char *pass, size_t pass_len,
|
234
234
|
const uint8_t *salt, size_t salt_len,
|
235
235
|
int is_encrypt) {
|
@@ -271,7 +271,7 @@ static int pkcs12_pbe_decrypt_init(const struct pbe_suite *suite,
|
|
271
271
|
return 0;
|
272
272
|
}
|
273
273
|
|
274
|
-
return pkcs12_pbe_cipher_init(suite, ctx, (
|
274
|
+
return pkcs12_pbe_cipher_init(suite, ctx, (uint32_t)iterations, pass,
|
275
275
|
pass_len, CBS_data(&salt), CBS_len(&salt),
|
276
276
|
0 /* decrypt */);
|
277
277
|
}
|
@@ -329,7 +329,7 @@ static const struct pbe_suite *get_pkcs12_pbe_suite(int pbe_nid) {
|
|
329
329
|
}
|
330
330
|
|
331
331
|
int pkcs12_pbe_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, int alg,
|
332
|
-
|
332
|
+
uint32_t iterations, const char *pass,
|
333
333
|
size_t pass_len, const uint8_t *salt,
|
334
334
|
size_t salt_len) {
|
335
335
|
const struct pbe_suite *suite = get_pkcs12_pbe_suite(alg);
|
@@ -489,10 +489,10 @@ int PKCS8_marshal_encrypted_private_key(CBB *out, int pbe_nid,
|
|
489
489
|
// it. See 5693a30813a031d3921a016a870420e7eb93ec90 in OpenSSL.
|
490
490
|
int alg_ok;
|
491
491
|
if (pbe_nid == -1) {
|
492
|
-
alg_ok = PKCS5_pbe2_encrypt_init(&epki, &ctx, cipher, (
|
492
|
+
alg_ok = PKCS5_pbe2_encrypt_init(&epki, &ctx, cipher, (uint32_t)iterations,
|
493
493
|
pass, pass_len, salt, salt_len);
|
494
494
|
} else {
|
495
|
-
alg_ok = pkcs12_pbe_encrypt_init(&epki, &ctx, pbe_nid, (
|
495
|
+
alg_ok = pkcs12_pbe_encrypt_init(&epki, &ctx, pbe_nid, (uint32_t)iterations,
|
496
496
|
pass, pass_len, salt, salt_len);
|
497
497
|
}
|
498
498
|
if (!alg_ok) {
|
@@ -87,6 +87,7 @@ int pkcs12_iterations_acceptable(uint64_t iterations) {
|
|
87
87
|
static const uint64_t kIterationsLimit = 100 * 1000000;
|
88
88
|
#endif
|
89
89
|
|
90
|
+
assert(kIterationsLimit <= UINT32_MAX);
|
90
91
|
return 0 < iterations && iterations <= kIterationsLimit;
|
91
92
|
}
|
92
93
|
|
@@ -554,7 +555,7 @@ err:
|
|
554
555
|
|
555
556
|
static int pkcs12_check_mac(int *out_mac_ok, const char *password,
|
556
557
|
size_t password_len, const CBS *salt,
|
557
|
-
|
558
|
+
uint32_t iterations, const EVP_MD *md,
|
558
559
|
const CBS *authsafes, const CBS *expected_mac) {
|
559
560
|
int ret = 0;
|
560
561
|
uint8_t hmac_key[EVP_MAX_MD_SIZE];
|
@@ -676,13 +677,15 @@ int PKCS12_get_key_and_certs(EVP_PKEY **out_key, STACK_OF(X509) *out_certs,
|
|
676
677
|
}
|
677
678
|
|
678
679
|
// The iteration count is optional and the default is one.
|
679
|
-
|
680
|
+
uint32_t iterations = 1;
|
680
681
|
if (CBS_len(&mac_data) > 0) {
|
681
|
-
|
682
|
-
|
682
|
+
uint64_t iterations_u64;
|
683
|
+
if (!CBS_get_asn1_uint64(&mac_data, &iterations_u64) ||
|
684
|
+
!pkcs12_iterations_acceptable(iterations_u64)) {
|
683
685
|
OPENSSL_PUT_ERROR(PKCS8, PKCS8_R_BAD_PKCS12_DATA);
|
684
686
|
goto err;
|
685
687
|
}
|
688
|
+
iterations = (uint32_t)iterations_u64;
|
686
689
|
}
|
687
690
|
|
688
691
|
int mac_ok;
|
@@ -1056,7 +1059,7 @@ static int add_cert_safe_contents(CBB *cbb, X509 *cert,
|
|
1056
1059
|
}
|
1057
1060
|
|
1058
1061
|
static int add_encrypted_data(CBB *out, int pbe_nid, const char *password,
|
1059
|
-
size_t password_len,
|
1062
|
+
size_t password_len, uint32_t iterations,
|
1060
1063
|
const uint8_t *in, size_t in_len) {
|
1061
1064
|
uint8_t salt[PKCS5_SALT_LEN];
|
1062
1065
|
if (!RAND_bytes(salt, sizeof(salt))) {
|
@@ -14,14 +14,15 @@
|
|
14
14
|
|
15
15
|
#include <openssl/rand.h>
|
16
16
|
|
17
|
-
#
|
17
|
+
#include "../fipsmodule/rand/internal.h"
|
18
|
+
|
19
|
+
#if defined(OPENSSL_RAND_DETERMINISTIC)
|
18
20
|
|
19
21
|
#include <string.h>
|
20
22
|
|
21
23
|
#include <openssl/chacha.h>
|
22
24
|
|
23
25
|
#include "../internal.h"
|
24
|
-
#include "../fipsmodule/rand/internal.h"
|
25
26
|
|
26
27
|
|
27
28
|
// g_num_calls is the number of calls to |CRYPTO_sysrand| that have occurred.
|
@@ -30,16 +31,16 @@
|
|
30
31
|
// multi-threaded program, replace this with a thread-local. (A mutex would not
|
31
32
|
// be deterministic.)
|
32
33
|
static uint64_t g_num_calls = 0;
|
33
|
-
static
|
34
|
+
static CRYPTO_MUTEX g_num_calls_lock = CRYPTO_MUTEX_INIT;
|
34
35
|
|
35
36
|
void RAND_reset_for_fuzzing(void) { g_num_calls = 0; }
|
36
37
|
|
37
38
|
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
38
39
|
static const uint8_t kZeroKey[32];
|
39
40
|
|
40
|
-
|
41
|
+
CRYPTO_MUTEX_lock_write(&g_num_calls_lock);
|
41
42
|
uint64_t num_calls = g_num_calls++;
|
42
|
-
|
43
|
+
CRYPTO_MUTEX_unlock_write(&g_num_calls_lock);
|
43
44
|
|
44
45
|
uint8_t nonce[12];
|
45
46
|
OPENSSL_memset(nonce, 0, sizeof(nonce));
|
@@ -53,4 +54,4 @@ void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
|
53
54
|
CRYPTO_sysrand(out, requested);
|
54
55
|
}
|
55
56
|
|
56
|
-
#endif //
|
57
|
+
#endif // OPENSSL_RAND_DETERMINISTIC
|
@@ -17,13 +17,12 @@
|
|
17
17
|
#include <stdlib.h>
|
18
18
|
|
19
19
|
#include "../fipsmodule/rand/internal.h"
|
20
|
+
#include "../internal.h"
|
20
21
|
|
21
22
|
|
22
|
-
// g_buffering_enabled is
|
23
|
-
|
24
|
-
|
25
|
-
// g_lock protects |g_buffering_enabled|.
|
26
|
-
static struct CRYPTO_STATIC_MUTEX g_lock = CRYPTO_STATIC_MUTEX_INIT;
|
23
|
+
// g_buffering_enabled is one if fork-unsafe buffering has been enabled and zero
|
24
|
+
// otherwise.
|
25
|
+
static CRYPTO_atomic_u32 g_buffering_enabled = 0;
|
27
26
|
|
28
27
|
#if !defined(OPENSSL_WINDOWS)
|
29
28
|
void RAND_enable_fork_unsafe_buffering(int fd) {
|
@@ -32,15 +31,10 @@ void RAND_enable_fork_unsafe_buffering(int fd) {
|
|
32
31
|
abort();
|
33
32
|
}
|
34
33
|
|
35
|
-
|
36
|
-
g_buffering_enabled = 1;
|
37
|
-
CRYPTO_STATIC_MUTEX_unlock_write(&g_lock);
|
34
|
+
CRYPTO_atomic_store_u32(&g_buffering_enabled, 1);
|
38
35
|
}
|
39
36
|
#endif
|
40
37
|
|
41
38
|
int rand_fork_unsafe_buffering_enabled(void) {
|
42
|
-
|
43
|
-
const int ret = g_buffering_enabled;
|
44
|
-
CRYPTO_STATIC_MUTEX_unlock_read(&g_lock);
|
45
|
-
return ret;
|
39
|
+
return CRYPTO_atomic_load_u32(&g_buffering_enabled) != 0;
|
46
40
|
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/* Copyright (c) 2023, Google Inc.
|
2
|
+
*
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
6
|
+
*
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
+
|
15
|
+
#include <openssl/rand.h>
|
16
|
+
|
17
|
+
#include "../fipsmodule/rand/internal.h"
|
18
|
+
|
19
|
+
#if defined(OPENSSL_RAND_GETENTROPY)
|
20
|
+
|
21
|
+
#include <stdio.h>
|
22
|
+
#include <stdlib.h>
|
23
|
+
#include <unistd.h>
|
24
|
+
|
25
|
+
#if defined(OPENSSL_MACOS) || defined(OPENSSL_FUCHSIA)
|
26
|
+
#include <sys/random.h>
|
27
|
+
#endif
|
28
|
+
|
29
|
+
// CRYPTO_sysrand puts |requested| random bytes into |out|.
|
30
|
+
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
31
|
+
while (requested > 0) {
|
32
|
+
// |getentropy| can only request 256 bytes at a time.
|
33
|
+
size_t todo = requested <= 256 ? requested : 256;
|
34
|
+
if (getentropy(out, todo) != 0) {
|
35
|
+
perror("getentropy() failed");
|
36
|
+
abort();
|
37
|
+
}
|
38
|
+
|
39
|
+
out += todo;
|
40
|
+
requested -= todo;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
45
|
+
CRYPTO_sysrand(out, requested);
|
46
|
+
}
|
47
|
+
|
48
|
+
#endif // OPENSSL_RAND_GETENTROPY
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* Copyright (c)
|
1
|
+
/* Copyright (c) 2023, Google Inc.
|
2
2
|
*
|
3
3
|
* Permission to use, copy, modify, and/or distribute this software for any
|
4
4
|
* purpose with or without fee is hereby granted, provided that the above
|
@@ -14,21 +14,21 @@
|
|
14
14
|
|
15
15
|
#include <openssl/rand.h>
|
16
16
|
|
17
|
-
#
|
17
|
+
#include "../fipsmodule/rand/internal.h"
|
18
18
|
|
19
|
-
#
|
19
|
+
#if defined(OPENSSL_RAND_IOS)
|
20
20
|
#include <stdlib.h>
|
21
21
|
|
22
|
-
#include <
|
23
|
-
|
24
|
-
#include "../fipsmodule/rand/internal.h"
|
22
|
+
#include <CommonCrypto/CommonRandom.h>
|
25
23
|
|
26
24
|
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
27
|
-
|
25
|
+
if (CCRandomGenerateBytes(out, requested) != kCCSuccess) {
|
26
|
+
abort();
|
27
|
+
}
|
28
28
|
}
|
29
29
|
|
30
30
|
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
31
31
|
CRYPTO_sysrand(out, requested);
|
32
32
|
}
|
33
33
|
|
34
|
-
#endif //
|
34
|
+
#endif // OPENSSL_RAND_IOS
|
data/third_party/boringssl-with-bazel/src/crypto/{refcount_no_threads.c → rand_extra/trusty.c}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* Copyright (c)
|
1
|
+
/* Copyright (c) 2023, Google Inc.
|
2
2
|
*
|
3
3
|
* Permission to use, copy, modify, and/or distribute this software for any
|
4
4
|
* purpose with or without fee is hereby granted, provided that the above
|
@@ -12,31 +12,27 @@
|
|
12
12
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
13
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
14
|
|
15
|
-
#include
|
15
|
+
#include <openssl/rand.h>
|
16
16
|
|
17
|
-
#include
|
18
|
-
#include <stdlib.h>
|
17
|
+
#include "../fipsmodule/rand/internal.h"
|
19
18
|
|
19
|
+
#if defined(OPENSSL_RAND_TRUSTY)
|
20
|
+
#include <stdint.h>
|
21
|
+
#include <stdlib.h>
|
20
22
|
|
21
|
-
#
|
23
|
+
#include <sys/types.h>
|
24
|
+
#include <uapi/err.h>
|
22
25
|
|
23
|
-
|
24
|
-
"CRYPTO_REFCOUNT_MAX is incorrect");
|
26
|
+
#include <lib/rng/trusty_rng.h>
|
25
27
|
|
26
|
-
void
|
27
|
-
if (
|
28
|
-
(
|
28
|
+
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
29
|
+
if (trusty_rng_hw_rand(out, requested) != NO_ERROR) {
|
30
|
+
abort();
|
29
31
|
}
|
30
32
|
}
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
abort();
|
35
|
-
}
|
36
|
-
if (*count < CRYPTO_REFCOUNT_MAX) {
|
37
|
-
(*count)--;
|
38
|
-
}
|
39
|
-
return *count == 0;
|
34
|
+
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
35
|
+
CRYPTO_sysrand(out, requested);
|
40
36
|
}
|
41
37
|
|
42
|
-
#endif //
|
38
|
+
#endif // OPENSSL_RAND_TRUSTY
|
@@ -14,7 +14,9 @@
|
|
14
14
|
|
15
15
|
#include <openssl/rand.h>
|
16
16
|
|
17
|
-
#
|
17
|
+
#include "../fipsmodule/rand/internal.h"
|
18
|
+
|
19
|
+
#if defined(OPENSSL_RAND_WINDOWS)
|
18
20
|
|
19
21
|
#include <limits.h>
|
20
22
|
#include <stdlib.h>
|
@@ -27,19 +29,14 @@ OPENSSL_MSVC_PRAGMA(warning(push, 3))
|
|
27
29
|
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
28
30
|
#include <bcrypt.h>
|
29
31
|
OPENSSL_MSVC_PRAGMA(comment(lib, "bcrypt.lib"))
|
30
|
-
#else
|
31
|
-
// #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See the
|
32
|
-
// "Community Additions" comment on MSDN here:
|
33
|
-
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx
|
34
|
-
#define SystemFunction036 NTAPI SystemFunction036
|
35
|
-
#include <ntsecapi.h>
|
36
|
-
#undef SystemFunction036
|
37
32
|
#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP
|
38
33
|
|
39
34
|
OPENSSL_MSVC_PRAGMA(warning(pop))
|
40
35
|
|
41
|
-
#
|
36
|
+
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
37
|
+
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
42
38
|
|
39
|
+
void CRYPTO_init_sysrand(void) {}
|
43
40
|
|
44
41
|
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
45
42
|
while (requested > 0) {
|
@@ -47,27 +44,52 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
|
47
44
|
if (requested < output_bytes_this_pass) {
|
48
45
|
output_bytes_this_pass = (ULONG)requested;
|
49
46
|
}
|
50
|
-
// On non-UWP configurations, use RtlGenRandom instead of BCryptGenRandom
|
51
|
-
// to avoid accessing resources that may be unavailable inside the
|
52
|
-
// Chromium sandbox. See https://crbug.com/boringssl/307
|
53
|
-
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
54
|
-
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
55
47
|
if (!BCRYPT_SUCCESS(BCryptGenRandom(
|
56
48
|
/*hAlgorithm=*/NULL, out, output_bytes_this_pass,
|
57
49
|
BCRYPT_USE_SYSTEM_PREFERRED_RNG))) {
|
58
|
-
#else
|
59
|
-
if (RtlGenRandom(out, output_bytes_this_pass) == FALSE) {
|
60
|
-
#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP
|
61
50
|
abort();
|
62
51
|
}
|
63
52
|
requested -= output_bytes_this_pass;
|
64
53
|
out += output_bytes_this_pass;
|
65
54
|
}
|
66
|
-
return;
|
67
55
|
}
|
68
56
|
|
57
|
+
#else
|
58
|
+
|
59
|
+
// See: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
|
60
|
+
typedef BOOL (WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData);
|
61
|
+
static ProcessPrngFunction g_processprng_fn = NULL;
|
62
|
+
|
63
|
+
static void init_processprng(void) {
|
64
|
+
HMODULE hmod = LoadLibraryW(L"bcryptprimitives");
|
65
|
+
if (hmod == NULL) {
|
66
|
+
abort();
|
67
|
+
}
|
68
|
+
g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
|
69
|
+
if (g_processprng_fn == NULL) {
|
70
|
+
abort();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
void CRYPTO_init_sysrand(void) {
|
75
|
+
static CRYPTO_once_t once = CRYPTO_ONCE_INIT;
|
76
|
+
CRYPTO_once(&once, init_processprng);
|
77
|
+
}
|
78
|
+
|
79
|
+
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
80
|
+
CRYPTO_init_sysrand();
|
81
|
+
// On non-UWP configurations, use ProcessPrng instead of BCryptGenRandom
|
82
|
+
// to avoid accessing resources that may be unavailable inside the
|
83
|
+
// Chromium sandbox. See https://crbug.com/74242
|
84
|
+
if (!g_processprng_fn(out, requested)) {
|
85
|
+
abort();
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP
|
90
|
+
|
69
91
|
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
70
92
|
CRYPTO_sysrand(out, requested);
|
71
93
|
}
|
72
94
|
|
73
|
-
#endif //
|
95
|
+
#endif // OPENSSL_RAND_WINDOWS
|
@@ -14,39 +14,34 @@
|
|
14
14
|
|
15
15
|
#include "internal.h"
|
16
16
|
|
17
|
-
|
18
|
-
#if defined(OPENSSL_C11_ATOMIC)
|
19
|
-
|
20
17
|
#include <assert.h>
|
21
|
-
#include <stdalign.h>
|
22
|
-
#include <stdatomic.h>
|
23
18
|
#include <stdlib.h>
|
24
19
|
|
25
20
|
|
26
21
|
// See comment above the typedef of CRYPTO_refcount_t about these tests.
|
27
|
-
static_assert(alignof(CRYPTO_refcount_t) == alignof(
|
28
|
-
"
|
29
|
-
static_assert(sizeof(CRYPTO_refcount_t) == sizeof(
|
30
|
-
"
|
22
|
+
static_assert(alignof(CRYPTO_refcount_t) == alignof(CRYPTO_atomic_u32),
|
23
|
+
"CRYPTO_refcount_t does not match CRYPTO_atomic_u32 alignment");
|
24
|
+
static_assert(sizeof(CRYPTO_refcount_t) == sizeof(CRYPTO_atomic_u32),
|
25
|
+
"CRYPTO_refcount_t does not match CRYPTO_atomic_u32 size");
|
31
26
|
|
32
27
|
static_assert((CRYPTO_refcount_t)-1 == CRYPTO_REFCOUNT_MAX,
|
33
28
|
"CRYPTO_REFCOUNT_MAX is incorrect");
|
34
29
|
|
35
30
|
void CRYPTO_refcount_inc(CRYPTO_refcount_t *in_count) {
|
36
|
-
|
37
|
-
uint32_t expected =
|
31
|
+
CRYPTO_atomic_u32 *count = (CRYPTO_atomic_u32 *)in_count;
|
32
|
+
uint32_t expected = CRYPTO_atomic_load_u32(count);
|
38
33
|
|
39
34
|
while (expected != CRYPTO_REFCOUNT_MAX) {
|
40
35
|
uint32_t new_value = expected + 1;
|
41
|
-
if (
|
36
|
+
if (CRYPTO_atomic_compare_exchange_weak_u32(count, &expected, new_value)) {
|
42
37
|
break;
|
43
38
|
}
|
44
39
|
}
|
45
40
|
}
|
46
41
|
|
47
42
|
int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *in_count) {
|
48
|
-
|
49
|
-
uint32_t expected =
|
43
|
+
CRYPTO_atomic_u32 *count = (CRYPTO_atomic_u32 *)in_count;
|
44
|
+
uint32_t expected = CRYPTO_atomic_load_u32(count);
|
50
45
|
|
51
46
|
for (;;) {
|
52
47
|
if (expected == 0) {
|
@@ -55,11 +50,10 @@ int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *in_count) {
|
|
55
50
|
return 0;
|
56
51
|
} else {
|
57
52
|
const uint32_t new_value = expected - 1;
|
58
|
-
if (
|
53
|
+
if (CRYPTO_atomic_compare_exchange_weak_u32(count, &expected,
|
54
|
+
new_value)) {
|
59
55
|
return new_value == 0;
|
60
56
|
}
|
61
57
|
}
|
62
58
|
}
|
63
59
|
}
|
64
|
-
|
65
|
-
#endif // OPENSSL_C11_ATOMIC
|