grpc 1.53.2 → 1.54.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +78 -66
- data/include/grpc/event_engine/event_engine.h +30 -14
- data/include/grpc/grpc_security.h +4 -0
- data/include/grpc/support/port_platform.h +4 -4
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +11 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +6 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +2 -11
- data/src/core/ext/filters/client_channel/backup_poller.h +0 -3
- data/src/core/ext/filters/client_channel/client_channel.cc +848 -813
- data/src/core/ext/filters/client_channel/client_channel.h +131 -173
- data/src/core/ext/filters/client_channel/client_channel_internal.h +114 -0
- data/src/core/ext/filters/client_channel/config_selector.h +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +6 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +17 -18
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +134 -151
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +2 -16
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +14 -10
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +68 -30
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -3
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +8 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -5
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +30 -38
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +20 -26
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +31 -179
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +1 -2
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +1 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +4 -2
- data/src/core/ext/filters/client_channel/retry_filter.cc +95 -102
- data/src/core/ext/filters/client_channel/subchannel.cc +2 -4
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +26 -27
- data/src/core/ext/filters/client_channel/subchannel_stream_client.h +8 -5
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -3
- data/src/core/ext/filters/http/http_filters_plugin.cc +1 -12
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +27 -11
- data/src/core/ext/filters/message_size/message_size_filter.cc +141 -224
- data/src/core/ext/filters/message_size/message_size_filter.h +48 -3
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +7 -6
- data/src/core/ext/gcp/metadata_query.cc +142 -0
- data/src/core/ext/gcp/metadata_query.h +82 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +70 -55
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +8 -12
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +116 -58
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +5 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +222 -118
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +113 -295
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +0 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +0 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +277 -451
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +1 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +12 -14
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +1 -9
- data/src/core/ext/transport/chttp2/transport/internal.h +16 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/writing.cc +10 -5
- data/src/core/ext/transport/inproc/inproc_transport.cc +20 -14
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +22 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +22 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +23 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +94 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +23 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +6 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +22 -0
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +24 -6
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +111 -12
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +9 -7
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +27 -9
- data/src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +11 -7
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +56 -12
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +24 -0
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.h +24 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.c +13 -2
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.h +49 -0
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +24 -9
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +66 -12
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +191 -187
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +139 -136
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +31 -15
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +12 -9
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +15 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +54 -45
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +135 -119
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +100 -97
- data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/opentelemetry.upbdefs.c +15 -18
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +272 -264
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +117 -117
- data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +5 -5
- data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +5 -5
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +5 -5
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/http_inputs.upbdefs.c +12 -9
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/http_inputs.upbdefs.h +5 -0
- data/src/core/ext/xds/xds_channel_stack_modifier.cc +1 -2
- data/src/core/ext/xds/xds_client_stats.cc +29 -15
- data/src/core/ext/xds/xds_client_stats.h +24 -20
- data/src/core/ext/xds/xds_endpoint.cc +5 -2
- data/src/core/ext/xds/xds_endpoint.h +9 -1
- data/src/core/ext/xds/xds_http_rbac_filter.cc +1 -1
- data/src/core/ext/xds/xds_lb_policy_registry.cc +13 -0
- data/src/core/ext/xds/xds_transport_grpc.cc +1 -1
- data/src/core/lib/channel/call_finalization.h +1 -1
- data/src/core/lib/channel/call_tracer.cc +51 -0
- data/src/core/lib/channel/call_tracer.h +101 -38
- data/src/core/lib/channel/connected_channel.cc +483 -1050
- data/src/core/lib/channel/context.h +8 -1
- data/src/core/lib/channel/promise_based_filter.cc +106 -42
- data/src/core/lib/channel/promise_based_filter.h +27 -13
- data/src/core/lib/channel/server_call_tracer_filter.cc +110 -0
- data/src/core/lib/config/config_vars.cc +151 -0
- data/src/core/lib/config/config_vars.h +127 -0
- data/src/core/lib/config/config_vars_non_generated.cc +51 -0
- data/src/core/lib/config/load_config.cc +66 -0
- data/src/core/lib/config/load_config.h +49 -0
- data/src/core/lib/debug/trace.cc +5 -6
- data/src/core/lib/debug/trace.h +0 -5
- data/src/core/lib/event_engine/event_engine.cc +37 -2
- data/src/core/lib/event_engine/handle_containers.h +7 -22
- data/src/core/lib/event_engine/memory_allocator_factory.h +47 -0
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +0 -4
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +3 -9
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +48 -15
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +8 -8
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -5
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +0 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +6 -32
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +0 -3
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +27 -18
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +0 -3
- data/src/core/lib/event_engine/resolved_address.cc +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +0 -1
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +129 -82
- data/src/core/lib/event_engine/windows/windows_endpoint.h +21 -5
- data/src/core/lib/event_engine/windows/windows_engine.cc +39 -18
- data/src/core/lib/event_engine/windows/windows_engine.h +2 -1
- data/src/core/lib/event_engine/windows/windows_listener.cc +370 -0
- data/src/core/lib/event_engine/windows/windows_listener.h +155 -0
- data/src/core/lib/experiments/config.cc +3 -10
- data/src/core/lib/experiments/experiments.cc +7 -0
- data/src/core/lib/experiments/experiments.h +9 -1
- data/src/core/lib/gpr/log.cc +15 -28
- data/src/core/lib/gprpp/fork.cc +8 -14
- data/src/core/lib/gprpp/orphanable.h +4 -3
- data/src/core/lib/gprpp/per_cpu.h +9 -3
- data/src/core/lib/gprpp/{thd_posix.cc → posix/thd.cc} +49 -37
- data/src/core/lib/gprpp/ref_counted.h +33 -34
- data/src/core/lib/gprpp/thd.h +16 -0
- data/src/core/lib/gprpp/time.cc +1 -0
- data/src/core/lib/gprpp/time.h +4 -4
- data/src/core/lib/gprpp/{thd_windows.cc → windows/thd.cc} +2 -2
- data/src/core/lib/iomgr/call_combiner.h +2 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +4 -2
- data/src/core/lib/iomgr/ev_posix.cc +13 -53
- data/src/core/lib/iomgr/ev_posix.h +0 -3
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +103 -76
- data/src/core/lib/iomgr/iomgr.cc +4 -8
- data/src/core/lib/iomgr/iomgr_windows.cc +8 -2
- data/src/core/lib/iomgr/pollset_set_windows.cc +9 -9
- data/src/core/lib/iomgr/pollset_windows.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +16 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_posix.cc +0 -1
- data/src/core/lib/iomgr/tcp_server_posix.cc +19 -55
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +0 -21
- data/src/core/lib/iomgr/tcp_server_windows.cc +176 -9
- data/src/core/lib/iomgr/tcp_windows.cc +12 -8
- data/src/core/lib/load_balancing/lb_policy.cc +9 -13
- data/src/core/lib/load_balancing/lb_policy.h +4 -2
- data/src/core/lib/promise/activity.cc +22 -6
- data/src/core/lib/promise/activity.h +61 -24
- data/src/core/lib/promise/cancel_callback.h +77 -0
- data/src/core/lib/promise/detail/basic_seq.h +1 -1
- data/src/core/lib/promise/detail/promise_factory.h +4 -0
- data/src/core/lib/promise/for_each.h +176 -0
- data/src/core/lib/promise/if.h +9 -0
- data/src/core/lib/promise/interceptor_list.h +23 -2
- data/src/core/lib/promise/latch.h +89 -3
- data/src/core/lib/promise/loop.h +13 -9
- data/src/core/lib/promise/map.h +7 -0
- data/src/core/lib/promise/party.cc +286 -0
- data/src/core/lib/promise/party.h +499 -0
- data/src/core/lib/promise/pipe.h +197 -57
- data/src/core/lib/promise/poll.h +48 -0
- data/src/core/lib/promise/promise.h +2 -2
- data/src/core/lib/resource_quota/arena.cc +19 -3
- data/src/core/lib/resource_quota/arena.h +119 -5
- data/src/core/lib/resource_quota/memory_quota.cc +1 -1
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +12 -35
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +0 -59
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +10 -5
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +13 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +2 -0
- data/src/core/lib/security/security_connector/load_system_roots_supported.cc +5 -9
- data/src/core/lib/security/security_connector/ssl_utils.cc +11 -25
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +12 -0
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +20 -2
- data/src/core/lib/slice/slice.cc +1 -1
- data/src/core/lib/surface/builtins.cc +2 -0
- data/src/core/lib/surface/call.cc +926 -1024
- data/src/core/lib/surface/call.h +10 -0
- data/src/core/lib/surface/lame_client.cc +1 -0
- data/src/core/lib/surface/validate_metadata.cc +42 -43
- data/src/core/lib/surface/validate_metadata.h +0 -9
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/batch_builder.cc +179 -0
- data/src/core/lib/transport/batch_builder.h +468 -0
- data/src/core/lib/transport/bdp_estimator.cc +7 -7
- data/src/core/lib/transport/bdp_estimator.h +10 -6
- data/src/core/lib/transport/custom_metadata.h +30 -0
- data/src/core/lib/transport/metadata_batch.cc +5 -2
- data/src/core/lib/transport/metadata_batch.h +17 -113
- data/src/core/lib/transport/parsed_metadata.h +6 -16
- data/src/core/lib/transport/timeout_encoding.cc +6 -1
- data/src/core/lib/transport/transport.cc +30 -2
- data/src/core/lib/transport/transport.h +70 -14
- data/src/core/lib/transport/transport_impl.h +7 -0
- data/src/core/lib/transport/transport_op_string.cc +52 -42
- data/src/core/plugin_registry/grpc_plugin_registry.cc +2 -2
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +1 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +21 -4
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +5 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +4 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/abseil-cpp/absl/base/config.h +1 -1
- data/third_party/abseil-cpp/absl/flags/commandlineflag.cc +34 -0
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +200 -0
- data/third_party/abseil-cpp/absl/flags/config.h +68 -0
- data/third_party/abseil-cpp/absl/flags/declare.h +73 -0
- data/third_party/abseil-cpp/absl/flags/flag.cc +38 -0
- data/third_party/abseil-cpp/absl/flags/flag.h +310 -0
- data/{src/core/lib/gprpp/global_config_custom.h → third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc} +11 -14
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +68 -0
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +615 -0
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +800 -0
- data/third_party/abseil-cpp/absl/flags/internal/flag_msvc.inc +116 -0
- data/third_party/abseil-cpp/absl/flags/internal/path_util.h +62 -0
- data/third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc +65 -0
- data/third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.h +61 -0
- data/third_party/abseil-cpp/absl/flags/internal/program_name.cc +60 -0
- data/third_party/abseil-cpp/absl/flags/internal/program_name.h +50 -0
- data/third_party/abseil-cpp/absl/flags/internal/registry.h +97 -0
- data/third_party/abseil-cpp/absl/flags/internal/sequence_lock.h +187 -0
- data/third_party/abseil-cpp/absl/flags/marshalling.cc +241 -0
- data/third_party/abseil-cpp/absl/flags/marshalling.h +356 -0
- data/third_party/abseil-cpp/absl/flags/reflection.cc +354 -0
- data/third_party/abseil-cpp/absl/flags/reflection.h +90 -0
- data/third_party/abseil-cpp/absl/flags/usage_config.cc +165 -0
- data/third_party/abseil-cpp/absl/flags/usage_config.h +135 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +12 -8
- data/third_party/boringssl-with-bazel/err_data.c +728 -712
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +177 -177
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +28 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +21 -23
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.c +20 -23
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +66 -185
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.c +18 -21
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +356 -311
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +174 -194
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +146 -210
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +6 -9
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.c +346 -526
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +110 -131
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +130 -116
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +93 -60
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +93 -181
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +242 -305
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +41 -18
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +30 -33
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +36 -33
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +29 -26
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +133 -88
- data/third_party/boringssl-with-bazel/src/crypto/asn1/posix_time.c +230 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +791 -791
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +526 -526
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +114 -135
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +201 -207
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +21 -26
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +55 -68
- data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +11 -7
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +15 -9
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +17 -10
- data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/bio/printf.c +0 -13
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +3 -6
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +9 -5
- data/third_party/boringssl-with-bazel/src/crypto/bn_extra/convert.c +10 -23
- data/third_party/boringssl-with-bazel/src/crypto/buf/buf.c +2 -6
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +29 -28
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c +161 -201
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +254 -39
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/internal.h +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesctrhmac.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesgcmsiv.c +37 -75
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +8 -10
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/cipher → cipher_extra}/e_des.c +100 -78
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc2.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +6 -12
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -11
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +6 -10
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +12 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +74 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_freebsd.c +62 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-aarch64-fuchsia.c → cpu_aarch64_fuchsia.c} +8 -7
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-aarch64-linux.c → cpu_aarch64_linux.c} +6 -4
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-aarch64-win.c → cpu_aarch64_win.c} +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-arm.c → cpu_arm.c} +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_freebsd.c +55 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-arm-linux.c → cpu_arm_linux.c} +11 -90
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-arm-linux.h → cpu_arm_linux.h} +0 -38
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-intel.c → cpu_intel.c} +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/crypto.c +25 -20
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +16 -27
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +17 -32
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/des → des}/des.c +232 -232
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/des → des}/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/params.c +232 -29
- data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +0 -3
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +39 -16
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +37 -7
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +11 -36
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +214 -99
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +21 -5
- data/third_party/boringssl-with-bazel/src/crypto/ecdsa_extra/ecdsa_asn1.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +83 -60
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +46 -12
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_ctx.c +25 -23
- data/third_party/boringssl-with-bazel/src/crypto/evp/internal.h +43 -9
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +75 -44
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +19 -25
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +96 -45
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519.c +7 -8
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519_asn1.c +26 -23
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_hkdf.c +233 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa_asn1.c +42 -25
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519_asn1.c +35 -47
- data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +135 -244
- data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/evp/sign.c +15 -10
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +29 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +13 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +3 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/key_wrap.c +13 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +9 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +35 -27
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +16 -26
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bytes.c +88 -60
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/cmp.c +4 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/ctx.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div_extra.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +99 -113
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/generic.c +112 -168
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +86 -31
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +11 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +13 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/random.c +13 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +19 -108
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.h +19 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/shift.c +15 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +22 -21
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/aead.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +79 -19
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +102 -99
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → fipsmodule/cipher}/e_aesccm.c +52 -46
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cmac → fipsmodule/cmac}/cmac.c +55 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/check.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +21 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +56 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/{evp → fipsmodule/digestsign}/digestsign.c +51 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +25 -25
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +91 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +34 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +54 -23
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +44 -60
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-x86_64-table.h → p256-nistz-table.h} +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-x86_64.c → p256-nistz.c} +60 -53
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-x86_64.h → p256-nistz.h} +5 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +48 -36
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +2 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +2 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +42 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +6 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/hmac.c +52 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +9 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +71 -43
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +14 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/ctrdrbg.c +31 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +16 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +3 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +9 -38
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +73 -59
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -45
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +22 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +63 -52
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +107 -62
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +58 -31
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +41 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +523 -422
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/internal.h +89 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/service_indicator.c +334 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/internal.h +3 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +12 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +14 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +19 -6
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +32 -14
- data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +65 -29
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +373 -18
- data/third_party/boringssl-with-bazel/src/crypto/kyber/internal.h +61 -0
- data/third_party/boringssl-with-bazel/src/crypto/kyber/keccak.c +205 -0
- data/third_party/boringssl-with-bazel/src/crypto/lhash/internal.h +13 -1
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +220 -13
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +19 -7
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +13 -1
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +81 -90
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c +150 -245
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +629 -613
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.c +17 -17
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +142 -149
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +99 -131
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +0 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -66
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +31 -38
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +18 -31
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +8 -1
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +129 -5
- data/third_party/boringssl-with-bazel/src/crypto/refcount_c11.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/refcount_lock.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +8 -11
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +61 -27
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +10 -13
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +10 -13
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +66 -34
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +190 -77
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +81 -284
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +109 -42
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.c +22 -24
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +54 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +32 -34
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +32 -16
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +465 -704
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +284 -331
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +183 -178
- data/third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.c +11 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +67 -50
- data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +153 -150
- data/third_party/boringssl-with-bazel/src/crypto/x509/policy.c +786 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +95 -102
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +72 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +12 -10
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +227 -252
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +52 -47
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +230 -224
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +161 -327
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +37 -33
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.c +14 -31
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +55 -85
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +534 -618
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +129 -122
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +116 -182
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +132 -132
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +181 -202
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +64 -79
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +175 -160
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +1865 -2050
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +433 -462
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +156 -163
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +267 -263
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +40 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +59 -63
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +63 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +114 -144
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +25 -26
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +326 -415
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +8 -7
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_info.c +30 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +354 -370
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +37 -32
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +116 -119
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +36 -26
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.c +10 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +419 -261
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +113 -105
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +11 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +78 -170
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +126 -131
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akeya.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +465 -469
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bcons.c +56 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +46 -49
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +309 -346
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +341 -365
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +429 -393
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +29 -24
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_extku.c +65 -59
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +125 -121
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +43 -42
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +122 -125
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_int.c +50 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +247 -253
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c +386 -389
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ocsp.c +45 -32
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcons.c +57 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pmaps.c +63 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +143 -136
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +664 -707
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +83 -75
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1062 -1146
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +8 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +28 -48
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +211 -187
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +26 -78
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +19 -14
- data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +21 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +49 -17
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +99 -29
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +49 -60
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +2 -15
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +16 -200
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +34 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ctrdrbg.h +82 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +32 -30
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +7 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +48 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +37 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +33 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +22 -30
- data/third_party/boringssl-with-bazel/src/include/openssl/ex_data.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/hmac.h +7 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +41 -16
- data/third_party/boringssl-with-bazel/src/include/openssl/kdf.h +91 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +74 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +13 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +11 -15
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +8 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +12 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +7 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/service_indicator.h +96 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +13 -21
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -75
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl3.h +1 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +384 -286
- data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +5 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/time.h +41 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +18 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +49 -23
- data/third_party/boringssl-with-bazel/src/include/openssl/type_check.h +0 -11
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +1592 -1074
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +202 -205
- data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +6 -13
- data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +17 -18
- data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +4 -5
- data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +25 -33
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +34 -20
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +65 -34
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +198 -54
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +5 -5
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +32 -28
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +76 -44
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +130 -98
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +27 -11
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +91 -75
- data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +8 -10
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +39 -65
- data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +1 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +5 -9
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +30 -33
- data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +77 -100
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +120 -107
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +164 -30
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +150 -60
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +22 -11
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +22 -6
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +15 -13
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +5 -43
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +7 -4
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +22 -34
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +16 -98
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +1241 -657
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +751 -398
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +3551 -1938
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +1272 -487
- metadata +103 -70
- data/src/core/ext/filters/client_channel/lb_call_state_internal.h +0 -39
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +0 -30
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +0 -29
- data/src/core/lib/gprpp/global_config.h +0 -93
- data/src/core/lib/gprpp/global_config_env.cc +0 -140
- data/src/core/lib/gprpp/global_config_env.h +0 -133
- data/src/core/lib/gprpp/global_config_generic.h +0 -40
- data/src/core/lib/promise/intra_activity_waiter.h +0 -55
- data/src/core/lib/security/security_connector/ssl_utils_config.cc +0 -32
- data/src/core/lib/security/security_connector/ssl_utils_config.h +0 -29
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +0 -195
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c +0 -83
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +0 -236
- data/third_party/boringssl-with-bazel/src/crypto/asn1/charmap.h +0 -15
- data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +0 -206
- data/third_party/boringssl-with-bazel/src/crypto/cpu-ppc64le.c +0 -38
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1-altivec.c +0 -361
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +0 -287
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +0 -132
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_lib.c +0 -155
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +0 -131
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_node.c +0 -189
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +0 -843
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c +0 -289
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcia.c +0 -57
- /data/src/core/lib/gpr/{log_android.cc → android/log.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_iphone.cc → iphone/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_linux.cc → linux/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{log_linux.cc → linux/log.cc} +0 -0
- /data/src/core/lib/gpr/{tmpfile_msys.cc → msys/tmpfile.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_posix.cc → posix/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{log_posix.cc → posix/log.cc} +0 -0
- /data/src/core/lib/gpr/{string_posix.cc → posix/string.cc} +0 -0
- /data/src/core/lib/gpr/{sync_posix.cc → posix/sync.cc} +0 -0
- /data/src/core/lib/gpr/{time_posix.cc → posix/time.cc} +0 -0
- /data/src/core/lib/gpr/{tmpfile_posix.cc → posix/tmpfile.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_windows.cc → windows/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{log_windows.cc → windows/log.cc} +0 -0
- /data/src/core/lib/gpr/{string_windows.cc → windows/string.cc} +0 -0
- /data/src/core/lib/gpr/{string_util_windows.cc → windows/string_util.cc} +0 -0
- /data/src/core/lib/gpr/{sync_windows.cc → windows/sync.cc} +0 -0
- /data/src/core/lib/gpr/{time_windows.cc → windows/time.cc} +0 -0
- /data/src/core/lib/gpr/{tmpfile_windows.cc → windows/tmpfile.cc} +0 -0
- /data/src/core/lib/gprpp/{env_linux.cc → linux/env.cc} +0 -0
- /data/src/core/lib/gprpp/{env_posix.cc → posix/env.cc} +0 -0
- /data/src/core/lib/gprpp/{stat_posix.cc → posix/stat.cc} +0 -0
- /data/src/core/lib/gprpp/{env_windows.cc → windows/env.cc} +0 -0
- /data/src/core/lib/gprpp/{stat_windows.cc → windows/stat.cc} +0 -0
@@ -0,0 +1,786 @@
|
|
1
|
+
/* Copyright (c) 2022, 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/x509.h>
|
16
|
+
|
17
|
+
#include <assert.h>
|
18
|
+
|
19
|
+
#include <openssl/mem.h>
|
20
|
+
#include <openssl/obj.h>
|
21
|
+
#include <openssl/stack.h>
|
22
|
+
#include <openssl/x509v3.h>
|
23
|
+
|
24
|
+
#include "../internal.h"
|
25
|
+
#include "../x509v3/internal.h"
|
26
|
+
#include "internal.h"
|
27
|
+
|
28
|
+
|
29
|
+
// This file computes the X.509 policy tree, as described in RFC 5280, section
|
30
|
+
// 6.1. It differs in that:
|
31
|
+
//
|
32
|
+
// (1) It does not track "qualifier_set". This is not needed as it is not
|
33
|
+
// output by this implementation.
|
34
|
+
//
|
35
|
+
// (2) It builds a directed acyclic graph, rather than a tree. When a given
|
36
|
+
// policy matches multiple parents, RFC 5280 makes a separate node for
|
37
|
+
// each parent. This representation condenses them into one node with
|
38
|
+
// multiple parents. Thus we refer to this structure as a "policy graph",
|
39
|
+
// rather than a "policy tree".
|
40
|
+
//
|
41
|
+
// (3) "expected_policy_set" is not tracked explicitly and built temporarily
|
42
|
+
// as part of building the graph.
|
43
|
+
//
|
44
|
+
// (4) anyPolicy nodes are not tracked explicitly.
|
45
|
+
//
|
46
|
+
// (5) Some pruning steps are deferred to when policies are evaluated, as a
|
47
|
+
// reachability pass.
|
48
|
+
|
49
|
+
// An X509_POLICY_NODE is a node in the policy graph. It corresponds to a node
|
50
|
+
// from RFC 5280, section 6.1.2, step (a), but we store some fields differently.
|
51
|
+
typedef struct x509_policy_node_st {
|
52
|
+
// policy is the "valid_policy" field from RFC 5280.
|
53
|
+
ASN1_OBJECT *policy;
|
54
|
+
|
55
|
+
// parent_policies, if non-empty, is the list of "valid_policy" values for all
|
56
|
+
// nodes which are a parent of this node. In this case, no entry in this list
|
57
|
+
// will be anyPolicy. This list is in no particular order and may contain
|
58
|
+
// duplicates if the corresponding certificate had duplicate mappings.
|
59
|
+
//
|
60
|
+
// If empty, this node has a single parent, anyPolicy. The node is then a root
|
61
|
+
// policies, and is in authorities-constrained-policy-set if it has a path to
|
62
|
+
// a leaf node.
|
63
|
+
//
|
64
|
+
// Note it is not possible for a policy to have both anyPolicy and a
|
65
|
+
// concrete policy as a parent. Section 6.1.3, step (d.1.ii) only runs if
|
66
|
+
// there was no match in step (d.1.i). We do not need to represent a parent
|
67
|
+
// list of, say, {anyPolicy, OID1, OID2}.
|
68
|
+
STACK_OF(ASN1_OBJECT) *parent_policies;
|
69
|
+
|
70
|
+
// mapped is one if this node matches a policy mapping in the certificate and
|
71
|
+
// zero otherwise.
|
72
|
+
int mapped;
|
73
|
+
|
74
|
+
// reachable is one if this node is reachable from some valid policy in the
|
75
|
+
// end-entity certificate. It is computed during |has_explicit_policy|.
|
76
|
+
int reachable;
|
77
|
+
} X509_POLICY_NODE;
|
78
|
+
|
79
|
+
DEFINE_STACK_OF(X509_POLICY_NODE)
|
80
|
+
|
81
|
+
// An X509_POLICY_LEVEL is the collection of nodes at the same depth in the
|
82
|
+
// policy graph. This structure can also be used to represent a level's
|
83
|
+
// "expected_policy_set" values. See |process_policy_mappings|.
|
84
|
+
typedef struct x509_policy_level_st {
|
85
|
+
// nodes is the list of nodes at this depth, except for the anyPolicy node, if
|
86
|
+
// any. This list is sorted by policy OID for efficient lookup.
|
87
|
+
STACK_OF(X509_POLICY_NODE) *nodes;
|
88
|
+
|
89
|
+
// has_any_policy is one if there is an anyPolicy node at this depth, and zero
|
90
|
+
// otherwise.
|
91
|
+
int has_any_policy;
|
92
|
+
} X509_POLICY_LEVEL;
|
93
|
+
|
94
|
+
DEFINE_STACK_OF(X509_POLICY_LEVEL)
|
95
|
+
|
96
|
+
static int is_any_policy(const ASN1_OBJECT *obj) {
|
97
|
+
return OBJ_obj2nid(obj) == NID_any_policy;
|
98
|
+
}
|
99
|
+
|
100
|
+
static void x509_policy_node_free(X509_POLICY_NODE *node) {
|
101
|
+
if (node != NULL) {
|
102
|
+
ASN1_OBJECT_free(node->policy);
|
103
|
+
sk_ASN1_OBJECT_pop_free(node->parent_policies, ASN1_OBJECT_free);
|
104
|
+
OPENSSL_free(node);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
static X509_POLICY_NODE *x509_policy_node_new(const ASN1_OBJECT *policy) {
|
109
|
+
assert(!is_any_policy(policy));
|
110
|
+
X509_POLICY_NODE *node = OPENSSL_malloc(sizeof(X509_POLICY_NODE));
|
111
|
+
if (node == NULL) {
|
112
|
+
return NULL;
|
113
|
+
}
|
114
|
+
OPENSSL_memset(node, 0, sizeof(X509_POLICY_NODE));
|
115
|
+
node->policy = OBJ_dup(policy);
|
116
|
+
node->parent_policies = sk_ASN1_OBJECT_new_null();
|
117
|
+
if (node->policy == NULL || node->parent_policies == NULL) {
|
118
|
+
x509_policy_node_free(node);
|
119
|
+
return NULL;
|
120
|
+
}
|
121
|
+
return node;
|
122
|
+
}
|
123
|
+
|
124
|
+
static int x509_policy_node_cmp(const X509_POLICY_NODE **a,
|
125
|
+
const X509_POLICY_NODE **b) {
|
126
|
+
return OBJ_cmp((*a)->policy, (*b)->policy);
|
127
|
+
}
|
128
|
+
|
129
|
+
static void x509_policy_level_free(X509_POLICY_LEVEL *level) {
|
130
|
+
if (level != NULL) {
|
131
|
+
sk_X509_POLICY_NODE_pop_free(level->nodes, x509_policy_node_free);
|
132
|
+
OPENSSL_free(level);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
static X509_POLICY_LEVEL *x509_policy_level_new(void) {
|
137
|
+
X509_POLICY_LEVEL *level = OPENSSL_malloc(sizeof(X509_POLICY_LEVEL));
|
138
|
+
if (level == NULL) {
|
139
|
+
return NULL;
|
140
|
+
}
|
141
|
+
OPENSSL_memset(level, 0, sizeof(X509_POLICY_LEVEL));
|
142
|
+
level->nodes = sk_X509_POLICY_NODE_new(x509_policy_node_cmp);
|
143
|
+
if (level->nodes == NULL) {
|
144
|
+
x509_policy_level_free(level);
|
145
|
+
return NULL;
|
146
|
+
}
|
147
|
+
return level;
|
148
|
+
}
|
149
|
+
|
150
|
+
static int x509_policy_level_is_empty(const X509_POLICY_LEVEL *level) {
|
151
|
+
return !level->has_any_policy && sk_X509_POLICY_NODE_num(level->nodes) == 0;
|
152
|
+
}
|
153
|
+
|
154
|
+
static void x509_policy_level_clear(X509_POLICY_LEVEL *level) {
|
155
|
+
level->has_any_policy = 0;
|
156
|
+
for (size_t i = 0; i < sk_X509_POLICY_NODE_num(level->nodes); i++) {
|
157
|
+
x509_policy_node_free(sk_X509_POLICY_NODE_value(level->nodes, i));
|
158
|
+
}
|
159
|
+
sk_X509_POLICY_NODE_zero(level->nodes);
|
160
|
+
}
|
161
|
+
|
162
|
+
// x509_policy_level_find returns the node in |level| corresponding to |policy|,
|
163
|
+
// or NULL if none exists.
|
164
|
+
static X509_POLICY_NODE *x509_policy_level_find(X509_POLICY_LEVEL *level,
|
165
|
+
const ASN1_OBJECT *policy) {
|
166
|
+
assert(sk_X509_POLICY_NODE_is_sorted(level->nodes));
|
167
|
+
X509_POLICY_NODE node;
|
168
|
+
node.policy = (ASN1_OBJECT *)policy;
|
169
|
+
size_t idx;
|
170
|
+
if (!sk_X509_POLICY_NODE_find(level->nodes, &idx, &node)) {
|
171
|
+
return NULL;
|
172
|
+
}
|
173
|
+
return sk_X509_POLICY_NODE_value(level->nodes, idx);
|
174
|
+
}
|
175
|
+
|
176
|
+
// x509_policy_level_add_nodes adds the nodes in |nodes| to |level|. It returns
|
177
|
+
// one on success and zero on error. No policy in |nodes| may already be present
|
178
|
+
// in |level|. This function modifies |nodes| to avoid making a copy, but the
|
179
|
+
// caller is still responsible for releasing |nodes| itself.
|
180
|
+
//
|
181
|
+
// This function is used to add nodes to |level| in bulk, and avoid resorting
|
182
|
+
// |level| after each addition.
|
183
|
+
static int x509_policy_level_add_nodes(X509_POLICY_LEVEL *level,
|
184
|
+
STACK_OF(X509_POLICY_NODE) *nodes) {
|
185
|
+
for (size_t i = 0; i < sk_X509_POLICY_NODE_num(nodes); i++) {
|
186
|
+
X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(nodes, i);
|
187
|
+
if (!sk_X509_POLICY_NODE_push(level->nodes, node)) {
|
188
|
+
return 0;
|
189
|
+
}
|
190
|
+
sk_X509_POLICY_NODE_set(nodes, i, NULL);
|
191
|
+
}
|
192
|
+
sk_X509_POLICY_NODE_sort(level->nodes);
|
193
|
+
|
194
|
+
#if !defined(NDEBUG)
|
195
|
+
// There should be no duplicate nodes.
|
196
|
+
for (size_t i = 1; i < sk_X509_POLICY_NODE_num(level->nodes); i++) {
|
197
|
+
assert(OBJ_cmp(sk_X509_POLICY_NODE_value(level->nodes, i - 1)->policy,
|
198
|
+
sk_X509_POLICY_NODE_value(level->nodes, i)->policy) != 0);
|
199
|
+
}
|
200
|
+
#endif
|
201
|
+
return 1;
|
202
|
+
}
|
203
|
+
|
204
|
+
static int policyinfo_cmp(const POLICYINFO **a, const POLICYINFO **b) {
|
205
|
+
return OBJ_cmp((*a)->policyid, (*b)->policyid);
|
206
|
+
}
|
207
|
+
|
208
|
+
static int delete_if_not_in_policies(X509_POLICY_NODE *node, void *data) {
|
209
|
+
const CERTIFICATEPOLICIES *policies = data;
|
210
|
+
assert(sk_POLICYINFO_is_sorted(policies));
|
211
|
+
POLICYINFO info;
|
212
|
+
info.policyid = node->policy;
|
213
|
+
if (sk_POLICYINFO_find(policies, NULL, &info)) {
|
214
|
+
return 0;
|
215
|
+
}
|
216
|
+
x509_policy_node_free(node);
|
217
|
+
return 1;
|
218
|
+
}
|
219
|
+
|
220
|
+
// process_certificate_policies updates |level| to incorporate |x509|'s
|
221
|
+
// certificate policies extension. This implements steps (d) and (e) of RFC
|
222
|
+
// 5280, section 6.1.3. |level| must contain the previous level's
|
223
|
+
// "expected_policy_set" information. For all but the top-most level, this is
|
224
|
+
// the output of |process_policy_mappings|. |any_policy_allowed| specifies
|
225
|
+
// whether anyPolicy is allowed or inhibited, taking into account the exception
|
226
|
+
// for self-issued certificates.
|
227
|
+
static int process_certificate_policies(const X509 *x509,
|
228
|
+
X509_POLICY_LEVEL *level,
|
229
|
+
int any_policy_allowed) {
|
230
|
+
int ret = 0;
|
231
|
+
int critical;
|
232
|
+
STACK_OF(X509_POLICY_NODE) *new_nodes = NULL;
|
233
|
+
CERTIFICATEPOLICIES *policies =
|
234
|
+
X509_get_ext_d2i(x509, NID_certificate_policies, &critical, NULL);
|
235
|
+
if (policies == NULL) {
|
236
|
+
if (critical != -1) {
|
237
|
+
return 0; // Syntax error in the extension.
|
238
|
+
}
|
239
|
+
|
240
|
+
// RFC 5280, section 6.1.3, step (e).
|
241
|
+
x509_policy_level_clear(level);
|
242
|
+
return 1;
|
243
|
+
}
|
244
|
+
|
245
|
+
// certificatePolicies may not be empty. See RFC 5280, section 4.2.1.4.
|
246
|
+
// TODO(https://crbug.com/boringssl/443): Move this check into the parser.
|
247
|
+
if (sk_POLICYINFO_num(policies) == 0) {
|
248
|
+
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_POLICY_EXTENSION);
|
249
|
+
goto err;
|
250
|
+
}
|
251
|
+
|
252
|
+
sk_POLICYINFO_set_cmp_func(policies, policyinfo_cmp);
|
253
|
+
sk_POLICYINFO_sort(policies);
|
254
|
+
int cert_has_any_policy = 0;
|
255
|
+
for (size_t i = 0; i < sk_POLICYINFO_num(policies); i++) {
|
256
|
+
const POLICYINFO *policy = sk_POLICYINFO_value(policies, i);
|
257
|
+
if (is_any_policy(policy->policyid)) {
|
258
|
+
cert_has_any_policy = 1;
|
259
|
+
}
|
260
|
+
if (i > 0 && OBJ_cmp(sk_POLICYINFO_value(policies, i - 1)->policyid,
|
261
|
+
policy->policyid) == 0) {
|
262
|
+
// Per RFC 5280, section 4.2.1.4, |policies| may not have duplicates.
|
263
|
+
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_POLICY_EXTENSION);
|
264
|
+
goto err;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
// This does the same thing as RFC 5280, section 6.1.3, step (d), though in
|
269
|
+
// a slighty different order. |level| currently contains "expected_policy_set"
|
270
|
+
// values of the previous level. See |process_policy_mappings| for details.
|
271
|
+
const int previous_level_has_any_policy = level->has_any_policy;
|
272
|
+
|
273
|
+
// First, we handle steps (d.1.i) and (d.2). The net effect of these two steps
|
274
|
+
// is to intersect |level| with |policies|, ignoring anyPolicy if it is
|
275
|
+
// inhibited.
|
276
|
+
if (!cert_has_any_policy || !any_policy_allowed) {
|
277
|
+
sk_X509_POLICY_NODE_delete_if(level->nodes, delete_if_not_in_policies,
|
278
|
+
policies);
|
279
|
+
level->has_any_policy = 0;
|
280
|
+
}
|
281
|
+
|
282
|
+
// Step (d.1.ii) may attach new nodes to the previous level's anyPolicy node.
|
283
|
+
if (previous_level_has_any_policy) {
|
284
|
+
new_nodes = sk_X509_POLICY_NODE_new_null();
|
285
|
+
if (new_nodes == NULL) {
|
286
|
+
goto err;
|
287
|
+
}
|
288
|
+
for (size_t i = 0; i < sk_POLICYINFO_num(policies); i++) {
|
289
|
+
const POLICYINFO *policy = sk_POLICYINFO_value(policies, i);
|
290
|
+
// Though we've reordered the steps slightly, |policy| is in |level| if
|
291
|
+
// and only if it would have been a match in step (d.1.ii).
|
292
|
+
if (!is_any_policy(policy->policyid) &&
|
293
|
+
x509_policy_level_find(level, policy->policyid) == NULL) {
|
294
|
+
X509_POLICY_NODE *node = x509_policy_node_new(policy->policyid);
|
295
|
+
if (node == NULL || //
|
296
|
+
!sk_X509_POLICY_NODE_push(new_nodes, node)) {
|
297
|
+
x509_policy_node_free(node);
|
298
|
+
goto err;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
if (!x509_policy_level_add_nodes(level, new_nodes)) {
|
303
|
+
goto err;
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
ret = 1;
|
308
|
+
|
309
|
+
err:
|
310
|
+
sk_X509_POLICY_NODE_pop_free(new_nodes, x509_policy_node_free);
|
311
|
+
CERTIFICATEPOLICIES_free(policies);
|
312
|
+
return ret;
|
313
|
+
}
|
314
|
+
|
315
|
+
static int compare_issuer_policy(const POLICY_MAPPING **a,
|
316
|
+
const POLICY_MAPPING **b) {
|
317
|
+
return OBJ_cmp((*a)->issuerDomainPolicy, (*b)->issuerDomainPolicy);
|
318
|
+
}
|
319
|
+
|
320
|
+
static int compare_subject_policy(const POLICY_MAPPING **a,
|
321
|
+
const POLICY_MAPPING **b) {
|
322
|
+
return OBJ_cmp((*a)->subjectDomainPolicy, (*b)->subjectDomainPolicy);
|
323
|
+
}
|
324
|
+
|
325
|
+
static int delete_if_mapped(X509_POLICY_NODE *node, void *data) {
|
326
|
+
const POLICY_MAPPINGS *mappings = data;
|
327
|
+
// |mappings| must have been sorted by |compare_issuer_policy|.
|
328
|
+
assert(sk_POLICY_MAPPING_is_sorted(mappings));
|
329
|
+
POLICY_MAPPING mapping;
|
330
|
+
mapping.issuerDomainPolicy = node->policy;
|
331
|
+
if (!sk_POLICY_MAPPING_find(mappings, /*out_index=*/NULL, &mapping)) {
|
332
|
+
return 0;
|
333
|
+
}
|
334
|
+
x509_policy_node_free(node);
|
335
|
+
return 1;
|
336
|
+
}
|
337
|
+
|
338
|
+
// process_policy_mappings processes the policy mappings extension of |cert|,
|
339
|
+
// whose corresponding graph level is |level|. |mapping_allowed| specifies
|
340
|
+
// whether policy mapping is inhibited at this point. On success, it returns an
|
341
|
+
// |X509_POLICY_LEVEL| containing the "expected_policy_set" for |level|. On
|
342
|
+
// error, it returns NULL. This implements steps (a) and (b) of RFC 5280,
|
343
|
+
// section 6.1.4.
|
344
|
+
//
|
345
|
+
// We represent the "expected_policy_set" as an |X509_POLICY_LEVEL|.
|
346
|
+
// |has_any_policy| indicates whether there is an anyPolicy node with
|
347
|
+
// "expected_policy_set" of {anyPolicy}. If a node with policy oid P1 contains
|
348
|
+
// P2 in its "expected_policy_set", the level will contain a node of policy P2
|
349
|
+
// with P1 in |parent_policies|.
|
350
|
+
//
|
351
|
+
// This is equivalent to the |X509_POLICY_LEVEL| that would result if the next
|
352
|
+
// certificats contained anyPolicy. |process_certificate_policies| will filter
|
353
|
+
// this result down to compute the actual level.
|
354
|
+
static X509_POLICY_LEVEL *process_policy_mappings(const X509 *cert,
|
355
|
+
X509_POLICY_LEVEL *level,
|
356
|
+
int mapping_allowed) {
|
357
|
+
int ok = 0;
|
358
|
+
STACK_OF(X509_POLICY_NODE) *new_nodes = NULL;
|
359
|
+
X509_POLICY_LEVEL *next = NULL;
|
360
|
+
int critical;
|
361
|
+
POLICY_MAPPINGS *mappings =
|
362
|
+
X509_get_ext_d2i(cert, NID_policy_mappings, &critical, NULL);
|
363
|
+
if (mappings == NULL && critical != -1) {
|
364
|
+
// Syntax error in the policy mappings extension.
|
365
|
+
goto err;
|
366
|
+
}
|
367
|
+
|
368
|
+
if (mappings != NULL) {
|
369
|
+
// PolicyMappings may not be empty. See RFC 5280, section 4.2.1.5.
|
370
|
+
// TODO(https://crbug.com/boringssl/443): Move this check into the parser.
|
371
|
+
if (sk_POLICY_MAPPING_num(mappings) == 0) {
|
372
|
+
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_POLICY_EXTENSION);
|
373
|
+
goto err;
|
374
|
+
}
|
375
|
+
|
376
|
+
// RFC 5280, section 6.1.4, step (a).
|
377
|
+
for (size_t i = 0; i < sk_POLICY_MAPPING_num(mappings); i++) {
|
378
|
+
POLICY_MAPPING *mapping = sk_POLICY_MAPPING_value(mappings, i);
|
379
|
+
if (is_any_policy(mapping->issuerDomainPolicy) ||
|
380
|
+
is_any_policy(mapping->subjectDomainPolicy)) {
|
381
|
+
goto err;
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
// Sort to group by issuerDomainPolicy.
|
386
|
+
sk_POLICY_MAPPING_set_cmp_func(mappings, compare_issuer_policy);
|
387
|
+
sk_POLICY_MAPPING_sort(mappings);
|
388
|
+
|
389
|
+
if (mapping_allowed) {
|
390
|
+
// Mark nodes as mapped, and add any nodes to |level| which may be needed
|
391
|
+
// as part of RFC 5280, section 6.1.4, step (b.1).
|
392
|
+
new_nodes = sk_X509_POLICY_NODE_new_null();
|
393
|
+
if (new_nodes == NULL) {
|
394
|
+
goto err;
|
395
|
+
}
|
396
|
+
const ASN1_OBJECT *last_policy = NULL;
|
397
|
+
for (size_t i = 0; i < sk_POLICY_MAPPING_num(mappings); i++) {
|
398
|
+
const POLICY_MAPPING *mapping = sk_POLICY_MAPPING_value(mappings, i);
|
399
|
+
// There may be multiple mappings with the same |issuerDomainPolicy|.
|
400
|
+
if (last_policy != NULL &&
|
401
|
+
OBJ_cmp(mapping->issuerDomainPolicy, last_policy) == 0) {
|
402
|
+
continue;
|
403
|
+
}
|
404
|
+
last_policy = mapping->issuerDomainPolicy;
|
405
|
+
|
406
|
+
X509_POLICY_NODE *node =
|
407
|
+
x509_policy_level_find(level, mapping->issuerDomainPolicy);
|
408
|
+
if (node == NULL) {
|
409
|
+
if (!level->has_any_policy) {
|
410
|
+
continue;
|
411
|
+
}
|
412
|
+
node = x509_policy_node_new(mapping->issuerDomainPolicy);
|
413
|
+
if (node == NULL || //
|
414
|
+
!sk_X509_POLICY_NODE_push(new_nodes, node)) {
|
415
|
+
x509_policy_node_free(node);
|
416
|
+
goto err;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
node->mapped = 1;
|
420
|
+
}
|
421
|
+
if (!x509_policy_level_add_nodes(level, new_nodes)) {
|
422
|
+
goto err;
|
423
|
+
}
|
424
|
+
} else {
|
425
|
+
// RFC 5280, section 6.1.4, step (b.2). If mapping is inhibited, delete
|
426
|
+
// all mapped nodes.
|
427
|
+
sk_X509_POLICY_NODE_delete_if(level->nodes, delete_if_mapped, mappings);
|
428
|
+
sk_POLICY_MAPPING_pop_free(mappings, POLICY_MAPPING_free);
|
429
|
+
mappings = NULL;
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
// If a node was not mapped, it retains the original "explicit_policy_set"
|
434
|
+
// value, itself. Add those to |mappings|.
|
435
|
+
if (mappings == NULL) {
|
436
|
+
mappings = sk_POLICY_MAPPING_new_null();
|
437
|
+
if (mappings == NULL) {
|
438
|
+
goto err;
|
439
|
+
}
|
440
|
+
}
|
441
|
+
for (size_t i = 0; i < sk_X509_POLICY_NODE_num(level->nodes); i++) {
|
442
|
+
X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(level->nodes, i);
|
443
|
+
if (!node->mapped) {
|
444
|
+
POLICY_MAPPING *mapping = POLICY_MAPPING_new();
|
445
|
+
if (mapping == NULL) {
|
446
|
+
goto err;
|
447
|
+
}
|
448
|
+
mapping->issuerDomainPolicy = OBJ_dup(node->policy);
|
449
|
+
mapping->subjectDomainPolicy = OBJ_dup(node->policy);
|
450
|
+
if (mapping->issuerDomainPolicy == NULL ||
|
451
|
+
mapping->subjectDomainPolicy == NULL ||
|
452
|
+
!sk_POLICY_MAPPING_push(mappings, mapping)) {
|
453
|
+
POLICY_MAPPING_free(mapping);
|
454
|
+
goto err;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
// Sort to group by subjectDomainPolicy.
|
460
|
+
sk_POLICY_MAPPING_set_cmp_func(mappings, compare_subject_policy);
|
461
|
+
sk_POLICY_MAPPING_sort(mappings);
|
462
|
+
|
463
|
+
// Convert |mappings| to our "expected_policy_set" representation.
|
464
|
+
next = x509_policy_level_new();
|
465
|
+
if (next == NULL) {
|
466
|
+
goto err;
|
467
|
+
}
|
468
|
+
next->has_any_policy = level->has_any_policy;
|
469
|
+
|
470
|
+
X509_POLICY_NODE *last_node = NULL;
|
471
|
+
for (size_t i = 0; i < sk_POLICY_MAPPING_num(mappings); i++) {
|
472
|
+
POLICY_MAPPING *mapping = sk_POLICY_MAPPING_value(mappings, i);
|
473
|
+
// Skip mappings where |issuerDomainPolicy| does not appear in the graph.
|
474
|
+
if (!level->has_any_policy &&
|
475
|
+
x509_policy_level_find(level, mapping->issuerDomainPolicy) == NULL) {
|
476
|
+
continue;
|
477
|
+
}
|
478
|
+
|
479
|
+
if (last_node == NULL ||
|
480
|
+
OBJ_cmp(last_node->policy, mapping->subjectDomainPolicy) != 0) {
|
481
|
+
last_node = x509_policy_node_new(mapping->subjectDomainPolicy);
|
482
|
+
if (last_node == NULL ||
|
483
|
+
!sk_X509_POLICY_NODE_push(next->nodes, last_node)) {
|
484
|
+
x509_policy_node_free(last_node);
|
485
|
+
goto err;
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
if (!sk_ASN1_OBJECT_push(last_node->parent_policies,
|
490
|
+
mapping->issuerDomainPolicy)) {
|
491
|
+
goto err;
|
492
|
+
}
|
493
|
+
mapping->issuerDomainPolicy = NULL;
|
494
|
+
}
|
495
|
+
|
496
|
+
sk_X509_POLICY_NODE_sort(next->nodes);
|
497
|
+
ok = 1;
|
498
|
+
|
499
|
+
err:
|
500
|
+
if (!ok) {
|
501
|
+
x509_policy_level_free(next);
|
502
|
+
next = NULL;
|
503
|
+
}
|
504
|
+
|
505
|
+
sk_POLICY_MAPPING_pop_free(mappings, POLICY_MAPPING_free);
|
506
|
+
sk_X509_POLICY_NODE_pop_free(new_nodes, x509_policy_node_free);
|
507
|
+
return next;
|
508
|
+
}
|
509
|
+
|
510
|
+
// apply_skip_certs, if |skip_certs| is non-NULL, sets |*value| to the minimum
|
511
|
+
// of its current value and |skip_certs|. It returns one on success and zero if
|
512
|
+
// |skip_certs| is negative.
|
513
|
+
static int apply_skip_certs(const ASN1_INTEGER *skip_certs, size_t *value) {
|
514
|
+
if (skip_certs == NULL) {
|
515
|
+
return 1;
|
516
|
+
}
|
517
|
+
|
518
|
+
// TODO(https://crbug.com/boringssl/443): Move this check into the parser.
|
519
|
+
if (skip_certs->type & V_ASN1_NEG) {
|
520
|
+
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_POLICY_EXTENSION);
|
521
|
+
return 0;
|
522
|
+
}
|
523
|
+
|
524
|
+
// If |skip_certs| does not fit in |uint64_t|, it must exceed |*value|.
|
525
|
+
uint64_t u64;
|
526
|
+
if (ASN1_INTEGER_get_uint64(&u64, skip_certs) && u64 < *value) {
|
527
|
+
*value = (size_t)u64;
|
528
|
+
}
|
529
|
+
ERR_clear_error();
|
530
|
+
return 1;
|
531
|
+
}
|
532
|
+
|
533
|
+
// process_policy_constraints updates |*explicit_policy|, |*policy_mapping|, and
|
534
|
+
// |*inhibit_any_policy| according to |x509|'s policy constraints and inhibit
|
535
|
+
// anyPolicy extensions. It returns one on success and zero on error. This
|
536
|
+
// implements steps (i) and (j) of RFC 5280, section 6.1.4.
|
537
|
+
static int process_policy_constraints(const X509 *x509, size_t *explicit_policy,
|
538
|
+
size_t *policy_mapping,
|
539
|
+
size_t *inhibit_any_policy) {
|
540
|
+
int critical;
|
541
|
+
POLICY_CONSTRAINTS *constraints =
|
542
|
+
X509_get_ext_d2i(x509, NID_policy_constraints, &critical, NULL);
|
543
|
+
if (constraints == NULL && critical != -1) {
|
544
|
+
return 0;
|
545
|
+
}
|
546
|
+
if (constraints != NULL) {
|
547
|
+
if (constraints->requireExplicitPolicy == NULL &&
|
548
|
+
constraints->inhibitPolicyMapping == NULL) {
|
549
|
+
// Per RFC 5280, section 4.2.1.11, at least one of the fields must be
|
550
|
+
// present.
|
551
|
+
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_POLICY_EXTENSION);
|
552
|
+
POLICY_CONSTRAINTS_free(constraints);
|
553
|
+
return 0;
|
554
|
+
}
|
555
|
+
int ok =
|
556
|
+
apply_skip_certs(constraints->requireExplicitPolicy, explicit_policy) &&
|
557
|
+
apply_skip_certs(constraints->inhibitPolicyMapping, policy_mapping);
|
558
|
+
POLICY_CONSTRAINTS_free(constraints);
|
559
|
+
if (!ok) {
|
560
|
+
return 0;
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
ASN1_INTEGER *inhibit_any_policy_ext =
|
565
|
+
X509_get_ext_d2i(x509, NID_inhibit_any_policy, &critical, NULL);
|
566
|
+
if (inhibit_any_policy_ext == NULL && critical != -1) {
|
567
|
+
return 0;
|
568
|
+
}
|
569
|
+
int ok = apply_skip_certs(inhibit_any_policy_ext, inhibit_any_policy);
|
570
|
+
ASN1_INTEGER_free(inhibit_any_policy_ext);
|
571
|
+
return ok;
|
572
|
+
}
|
573
|
+
|
574
|
+
// has_explicit_policy returns one if the set of authority-space policy OIDs
|
575
|
+
// |levels| has some non-empty intersection with |user_policies|, and zero
|
576
|
+
// otherwise. This mirrors the logic in RFC 5280, section 6.1.5, step (g). This
|
577
|
+
// function modifies |levels| and should only be called at the end of policy
|
578
|
+
// evaluation.
|
579
|
+
static int has_explicit_policy(STACK_OF(X509_POLICY_LEVEL) *levels,
|
580
|
+
const STACK_OF(ASN1_OBJECT) *user_policies) {
|
581
|
+
assert(sk_ASN1_OBJECT_is_sorted(user_policies));
|
582
|
+
|
583
|
+
// Step (g.i). If the policy graph is empty, the intersection is empty.
|
584
|
+
size_t num_levels = sk_X509_POLICY_LEVEL_num(levels);
|
585
|
+
X509_POLICY_LEVEL *level = sk_X509_POLICY_LEVEL_value(levels, num_levels - 1);
|
586
|
+
if (x509_policy_level_is_empty(level)) {
|
587
|
+
return 0;
|
588
|
+
}
|
589
|
+
|
590
|
+
// If |user_policies| is empty, we interpret it as having a single anyPolicy
|
591
|
+
// value. The caller may also have supplied anyPolicy explicitly.
|
592
|
+
int user_has_any_policy = sk_ASN1_OBJECT_num(user_policies) == 0;
|
593
|
+
for (size_t i = 0; i < sk_ASN1_OBJECT_num(user_policies); i++) {
|
594
|
+
if (is_any_policy(sk_ASN1_OBJECT_value(user_policies, i))) {
|
595
|
+
user_has_any_policy = 1;
|
596
|
+
break;
|
597
|
+
}
|
598
|
+
}
|
599
|
+
|
600
|
+
// Step (g.ii). If the policy graph is not empty and the user set contains
|
601
|
+
// anyPolicy, the intersection is the entire (non-empty) graph.
|
602
|
+
if (user_has_any_policy) {
|
603
|
+
return 1;
|
604
|
+
}
|
605
|
+
|
606
|
+
// Step (g.iii) does not delete anyPolicy nodes, so if the graph has
|
607
|
+
// anyPolicy, some explicit policy will survive. The actual intersection may
|
608
|
+
// synthesize some nodes in step (g.iii.3), but we do not return the policy
|
609
|
+
// list itself, so we skip actually computing this.
|
610
|
+
if (level->has_any_policy) {
|
611
|
+
return 1;
|
612
|
+
}
|
613
|
+
|
614
|
+
// We defer pruning the tree, so as we look for nodes with parent anyPolicy,
|
615
|
+
// step (g.iii.1), we must limit to nodes reachable from the bottommost level.
|
616
|
+
// Start by marking each of those nodes as reachable.
|
617
|
+
for (size_t i = 0; i < sk_X509_POLICY_NODE_num(level->nodes); i++) {
|
618
|
+
sk_X509_POLICY_NODE_value(level->nodes, i)->reachable = 1;
|
619
|
+
}
|
620
|
+
|
621
|
+
for (size_t i = num_levels - 1; i < num_levels; i--) {
|
622
|
+
level = sk_X509_POLICY_LEVEL_value(levels, i);
|
623
|
+
for (size_t j = 0; j < sk_X509_POLICY_NODE_num(level->nodes); j++) {
|
624
|
+
X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(level->nodes, j);
|
625
|
+
if (!node->reachable) {
|
626
|
+
continue;
|
627
|
+
}
|
628
|
+
if (sk_ASN1_OBJECT_num(node->parent_policies) == 0) {
|
629
|
+
// |node|'s parent is anyPolicy and is part of "valid_policy_node_set".
|
630
|
+
// If it exists in |user_policies|, the intersection is non-empty and we
|
631
|
+
// can return immediately.
|
632
|
+
if (sk_ASN1_OBJECT_find(user_policies, /*out_index=*/NULL,
|
633
|
+
node->policy)) {
|
634
|
+
return 1;
|
635
|
+
}
|
636
|
+
} else if (i > 0) {
|
637
|
+
// |node|'s parents are concrete policies. Mark the parents reachable,
|
638
|
+
// to be inspected by the next loop iteration.
|
639
|
+
X509_POLICY_LEVEL *prev = sk_X509_POLICY_LEVEL_value(levels, i - 1);
|
640
|
+
for (size_t k = 0; k < sk_ASN1_OBJECT_num(node->parent_policies); k++) {
|
641
|
+
X509_POLICY_NODE *parent = x509_policy_level_find(
|
642
|
+
prev, sk_ASN1_OBJECT_value(node->parent_policies, k));
|
643
|
+
if (parent != NULL) {
|
644
|
+
parent->reachable = 1;
|
645
|
+
}
|
646
|
+
}
|
647
|
+
}
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
651
|
+
return 0;
|
652
|
+
}
|
653
|
+
|
654
|
+
static int asn1_object_cmp(const ASN1_OBJECT **a, const ASN1_OBJECT **b) {
|
655
|
+
return OBJ_cmp(*a, *b);
|
656
|
+
}
|
657
|
+
|
658
|
+
int X509_policy_check(const STACK_OF(X509) *certs,
|
659
|
+
const STACK_OF(ASN1_OBJECT) *user_policies,
|
660
|
+
unsigned long flags, X509 **out_current_cert) {
|
661
|
+
*out_current_cert = NULL;
|
662
|
+
int ret = X509_V_ERR_OUT_OF_MEM;
|
663
|
+
X509_POLICY_LEVEL *level = NULL;
|
664
|
+
STACK_OF(X509_POLICY_LEVEL) *levels = NULL;
|
665
|
+
STACK_OF(ASN1_OBJECT) *user_policies_sorted = NULL;
|
666
|
+
size_t num_certs = sk_X509_num(certs);
|
667
|
+
|
668
|
+
// Skip policy checking if the chain is just the trust anchor.
|
669
|
+
if (num_certs <= 1) {
|
670
|
+
return X509_V_OK;
|
671
|
+
}
|
672
|
+
|
673
|
+
// See RFC 5280, section 6.1.2, steps (d) through (f).
|
674
|
+
size_t explicit_policy =
|
675
|
+
(flags & X509_V_FLAG_EXPLICIT_POLICY) ? 0 : num_certs + 1;
|
676
|
+
size_t inhibit_any_policy =
|
677
|
+
(flags & X509_V_FLAG_INHIBIT_ANY) ? 0 : num_certs + 1;
|
678
|
+
size_t policy_mapping =
|
679
|
+
(flags & X509_V_FLAG_INHIBIT_MAP) ? 0 : num_certs + 1;
|
680
|
+
|
681
|
+
levels = sk_X509_POLICY_LEVEL_new_null();
|
682
|
+
if (levels == NULL) {
|
683
|
+
goto err;
|
684
|
+
}
|
685
|
+
|
686
|
+
for (size_t i = num_certs - 2; i < num_certs; i--) {
|
687
|
+
X509 *cert = sk_X509_value(certs, i);
|
688
|
+
if (!x509v3_cache_extensions(cert)) {
|
689
|
+
goto err;
|
690
|
+
}
|
691
|
+
const int is_self_issued = (cert->ex_flags & EXFLAG_SI) != 0;
|
692
|
+
|
693
|
+
if (level == NULL) {
|
694
|
+
assert(i == num_certs - 2);
|
695
|
+
level = x509_policy_level_new();
|
696
|
+
if (level == NULL) {
|
697
|
+
goto err;
|
698
|
+
}
|
699
|
+
level->has_any_policy = 1;
|
700
|
+
}
|
701
|
+
|
702
|
+
// RFC 5280, section 6.1.3, steps (d) and (e). |any_policy_allowed| is
|
703
|
+
// computed as in step (d.2).
|
704
|
+
const int any_policy_allowed =
|
705
|
+
inhibit_any_policy > 0 || (i > 0 && is_self_issued);
|
706
|
+
if (!process_certificate_policies(cert, level, any_policy_allowed)) {
|
707
|
+
ret = X509_V_ERR_INVALID_POLICY_EXTENSION;
|
708
|
+
*out_current_cert = cert;
|
709
|
+
goto err;
|
710
|
+
}
|
711
|
+
|
712
|
+
// RFC 5280, section 6.1.3, step (f).
|
713
|
+
if (explicit_policy == 0 && x509_policy_level_is_empty(level)) {
|
714
|
+
ret = X509_V_ERR_NO_EXPLICIT_POLICY;
|
715
|
+
goto err;
|
716
|
+
}
|
717
|
+
|
718
|
+
// Insert into the list.
|
719
|
+
if (!sk_X509_POLICY_LEVEL_push(levels, level)) {
|
720
|
+
goto err;
|
721
|
+
}
|
722
|
+
X509_POLICY_LEVEL *current_level = level;
|
723
|
+
level = NULL;
|
724
|
+
|
725
|
+
// If this is not the leaf certificate, we go to section 6.1.4. If it
|
726
|
+
// is the leaf certificate, we go to section 6.1.5 instead.
|
727
|
+
if (i != 0) {
|
728
|
+
// RFC 5280, section 6.1.4, steps (a) and (b).
|
729
|
+
level = process_policy_mappings(cert, current_level, policy_mapping > 0);
|
730
|
+
if (level == NULL) {
|
731
|
+
ret = X509_V_ERR_INVALID_POLICY_EXTENSION;
|
732
|
+
*out_current_cert = cert;
|
733
|
+
goto err;
|
734
|
+
}
|
735
|
+
}
|
736
|
+
|
737
|
+
// RFC 5280, section 6.1.4, step (h-j) for non-leaves, and section 6.1.5,
|
738
|
+
// step (a-b) for leaves. In the leaf case, RFC 5280 says only to update
|
739
|
+
// |explicit_policy|, but |policy_mapping| and |inhibit_any_policy| are no
|
740
|
+
// longer read at this point, so we use the same process.
|
741
|
+
if (i == 0 || !is_self_issued) {
|
742
|
+
if (explicit_policy > 0) {
|
743
|
+
explicit_policy--;
|
744
|
+
}
|
745
|
+
if (policy_mapping > 0) {
|
746
|
+
policy_mapping--;
|
747
|
+
}
|
748
|
+
if (inhibit_any_policy > 0) {
|
749
|
+
inhibit_any_policy--;
|
750
|
+
}
|
751
|
+
}
|
752
|
+
if (!process_policy_constraints(cert, &explicit_policy, &policy_mapping,
|
753
|
+
&inhibit_any_policy)) {
|
754
|
+
ret = X509_V_ERR_INVALID_POLICY_EXTENSION;
|
755
|
+
*out_current_cert = cert;
|
756
|
+
goto err;
|
757
|
+
}
|
758
|
+
}
|
759
|
+
|
760
|
+
// RFC 5280, section 6.1.5, step (g). We do not output the policy set, so it
|
761
|
+
// is only necessary to check if the user-constrained-policy-set is not empty.
|
762
|
+
if (explicit_policy == 0) {
|
763
|
+
// Build a sorted copy of |user_policies| for more efficient lookup.
|
764
|
+
user_policies_sorted = sk_ASN1_OBJECT_dup(user_policies);
|
765
|
+
if (user_policies_sorted == NULL) {
|
766
|
+
goto err;
|
767
|
+
}
|
768
|
+
sk_ASN1_OBJECT_set_cmp_func(user_policies_sorted, asn1_object_cmp);
|
769
|
+
sk_ASN1_OBJECT_sort(user_policies_sorted);
|
770
|
+
|
771
|
+
if (!has_explicit_policy(levels, user_policies_sorted)) {
|
772
|
+
ret = X509_V_ERR_NO_EXPLICIT_POLICY;
|
773
|
+
goto err;
|
774
|
+
}
|
775
|
+
}
|
776
|
+
|
777
|
+
ret = X509_V_OK;
|
778
|
+
|
779
|
+
err:
|
780
|
+
x509_policy_level_free(level);
|
781
|
+
// |user_policies_sorted|'s contents are owned by |user_policies|, so we do
|
782
|
+
// not use |sk_ASN1_OBJECT_pop_free|.
|
783
|
+
sk_ASN1_OBJECT_free(user_policies_sorted);
|
784
|
+
sk_X509_POLICY_LEVEL_pop_free(levels, x509_policy_level_free);
|
785
|
+
return ret;
|
786
|
+
}
|