grpc 1.55.0 → 1.56.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +102 -68
- data/include/grpc/event_engine/event_engine.h +4 -3
- data/include/grpc/grpc_audit_logging.h +96 -0
- data/include/grpc/grpc_security.h +19 -0
- data/include/grpc/module.modulemap +2 -0
- data/include/grpc/support/json.h +218 -0
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
- data/src/core/ext/filters/client_channel/client_channel.cc +86 -104
- data/src/core/ext/filters/client_channel/client_channel.h +6 -0
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
- data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
- data/src/core/ext/filters/client_channel/config_selector.h +9 -24
- data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +53 -21
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +42 -40
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
- data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
- data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
- data/src/core/ext/filters/client_channel/subchannel.h +3 -43
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
- data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
- data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +176 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +325 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +567 -543
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +150 -9
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +46 -32
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +18 -5
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
- data/src/core/ext/transport/chttp2/transport/parsing.cc +12 -12
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
- data/src/core/ext/xds/certificate_provider_store.cc +4 -9
- data/src/core/ext/xds/certificate_provider_store.h +1 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
- data/src/core/ext/xds/xds_api.cc +9 -6
- data/src/core/ext/xds/xds_api.h +3 -2
- data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
- data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
- data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
- data/src/core/ext/xds/xds_client.cc +5 -4
- data/src/core/ext/xds/xds_client_stats.h +1 -1
- data/src/core/ext/xds/xds_cluster.cc +20 -19
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
- data/src/core/ext/xds/xds_common_types.cc +3 -1
- data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
- data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
- data/src/core/ext/xds/xds_http_filters.h +4 -2
- data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
- data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
- data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
- data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
- data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
- data/src/core/ext/xds/xds_listener.cc +1 -0
- data/src/core/ext/xds/xds_route_config.cc +40 -3
- data/src/core/ext/xds/xds_routing.cc +2 -2
- data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
- data/src/core/lib/avl/avl.h +5 -0
- data/src/core/lib/backoff/random_early_detection.h +5 -0
- data/src/core/lib/channel/channel_args.cc +80 -22
- data/src/core/lib/channel/channel_args.h +34 -1
- data/src/core/lib/channel/channel_trace.cc +16 -12
- data/src/core/lib/channel/channelz.cc +159 -132
- data/src/core/lib/channel/channelz.h +42 -35
- data/src/core/lib/channel/channelz_registry.cc +23 -20
- data/src/core/lib/channel/connected_channel.cc +17 -6
- data/src/core/lib/channel/promise_based_filter.cc +0 -4
- data/src/core/lib/channel/promise_based_filter.h +2 -0
- data/src/core/lib/compression/compression_internal.cc +2 -5
- data/src/core/lib/config/config_vars.cc +20 -18
- data/src/core/lib/config/config_vars.h +4 -4
- data/src/core/lib/config/load_config.cc +13 -0
- data/src/core/lib/config/load_config.h +6 -0
- data/src/core/lib/debug/event_log.h +1 -1
- data/src/core/lib/debug/stats_data.h +1 -1
- data/src/core/lib/debug/trace.cc +24 -55
- data/src/core/lib/debug/trace.h +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
- data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
- data/src/core/lib/event_engine/default_event_engine.cc +13 -1
- data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
- data/src/core/lib/event_engine/poller.h +2 -2
- data/src/core/lib/event_engine/posix.h +4 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +33 -19
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +2 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +33 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +10 -8
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
- data/src/core/lib/event_engine/shim.cc +7 -1
- data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
- data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
- data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
- data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
- data/src/core/lib/event_engine/windows/iocp.cc +4 -3
- data/src/core/lib/event_engine/windows/iocp.h +3 -3
- data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
- data/src/core/lib/event_engine/windows/win_socket.h +4 -4
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
- data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
- data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
- data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
- data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
- data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
- data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
- data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
- data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
- data/src/core/lib/experiments/config.cc +38 -7
- data/src/core/lib/experiments/config.h +16 -0
- data/src/core/lib/experiments/experiments.cc +67 -20
- data/src/core/lib/experiments/experiments.h +27 -21
- data/src/core/lib/gpr/log_internal.h +55 -0
- data/src/core/lib/gprpp/crash.cc +10 -0
- data/src/core/lib/gprpp/crash.h +3 -0
- data/src/core/lib/gprpp/per_cpu.cc +33 -0
- data/src/core/lib/gprpp/per_cpu.h +29 -6
- data/src/core/lib/gprpp/time.cc +1 -0
- data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
- data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
- data/src/core/lib/iomgr/ev_apple.cc +12 -12
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
- data/src/core/lib/iomgr/iocp_windows.cc +24 -3
- data/src/core/lib/iomgr/iocp_windows.h +11 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
- data/src/core/lib/iomgr/socket_windows.cc +61 -7
- data/src/core/lib/iomgr/socket_windows.h +9 -2
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
- data/src/core/lib/iomgr/tcp_server_posix.cc +182 -119
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -1
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +21 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
- data/src/core/lib/json/json.h +2 -166
- data/src/core/lib/json/json_object_loader.cc +8 -9
- data/src/core/lib/json/json_object_loader.h +25 -18
- data/src/core/lib/json/json_reader.cc +13 -6
- data/src/core/lib/json/json_util.cc +6 -11
- data/src/core/lib/json/json_writer.cc +7 -8
- data/src/core/lib/load_balancing/lb_policy.h +13 -0
- data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
- data/src/core/lib/matchers/matchers.cc +3 -4
- data/src/core/lib/matchers/matchers.h +2 -1
- data/src/core/lib/promise/activity.cc +5 -0
- data/src/core/lib/promise/activity.h +10 -0
- data/src/core/lib/promise/detail/promise_factory.h +1 -1
- data/src/core/lib/promise/party.cc +31 -13
- data/src/core/lib/promise/party.h +11 -2
- data/src/core/lib/promise/pipe.h +9 -2
- data/src/core/lib/promise/prioritized_race.h +95 -0
- data/src/core/lib/promise/sleep.cc +2 -1
- data/src/core/lib/resolver/server_address.cc +0 -8
- data/src/core/lib/resolver/server_address.h +0 -6
- data/src/core/lib/resource_quota/memory_quota.cc +7 -7
- data/src/core/lib/resource_quota/memory_quota.h +1 -2
- data/src/core/lib/security/authorization/audit_logging.cc +98 -0
- data/src/core/lib/security/authorization/audit_logging.h +73 -0
- data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
- data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
- data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
- data/src/core/lib/security/authorization/rbac_policy.h +19 -2
- data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
- data/src/core/lib/security/authorization/stdout_logger.h +61 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +8 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +5 -1
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
- data/src/core/lib/security/security_connector/ssl_utils.cc +2 -1
- data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +1 -1
- data/src/core/lib/security/util/json_util.cc +1 -0
- data/src/core/lib/service_config/service_config_call_data.h +49 -20
- data/src/core/lib/service_config/service_config_impl.cc +2 -1
- data/src/core/lib/surface/call.cc +38 -23
- data/src/core/lib/surface/completion_queue.cc +6 -2
- data/src/core/lib/surface/validate_metadata.cc +37 -22
- data/src/core/lib/surface/validate_metadata.h +13 -3
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/batch_builder.cc +15 -12
- data/src/core/lib/transport/batch_builder.h +39 -35
- data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
- data/src/core/tsi/ssl_transport_security.cc +5 -2
- data/src/core/tsi/ssl_transport_security.h +13 -1
- data/src/ruby/ext/grpc/extconf.rb +8 -9
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
- data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
- data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
- data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
- data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
- data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
- data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
- data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
- data/third_party/cares/cares/include/ares.h +23 -1
- data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
- data/third_party/cares/cares/include/ares_rules.h +2 -2
- data/third_party/cares/cares/include/ares_version.h +3 -3
- data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
- data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
- data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
- data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
- data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
- data/third_party/cares/cares/src/lib/ares_data.c +16 -0
- data/third_party/cares/cares/src/lib/ares_data.h +7 -0
- data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
- data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
- data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
- data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
- data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
- data/third_party/cares/cares/src/lib/ares_init.c +97 -485
- data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
- data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
- data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
- data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
- data/third_party/cares/cares/src/lib/ares_private.h +30 -16
- data/third_party/cares/cares/src/lib/ares_process.c +55 -16
- data/third_party/cares/cares/src/lib/ares_query.c +1 -35
- data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
- data/third_party/cares/cares/src/lib/ares_send.c +5 -7
- data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
- data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
- data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
- data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
- data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
- metadata +50 -12
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
- data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
- data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -74,53 +74,72 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
int rsa_check_public_key(const RSA *rsa) {
|
77
|
-
if (rsa->n == NULL
|
77
|
+
if (rsa->n == NULL) {
|
78
78
|
OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING);
|
79
79
|
return 0;
|
80
80
|
}
|
81
81
|
|
82
|
+
// TODO(davidben): 16384-bit RSA is huge. Can we bring this down to a limit of
|
83
|
+
// 8192-bit?
|
82
84
|
unsigned n_bits = BN_num_bits(rsa->n);
|
83
85
|
if (n_bits > 16 * 1024) {
|
84
86
|
OPENSSL_PUT_ERROR(RSA, RSA_R_MODULUS_TOO_LARGE);
|
85
87
|
return 0;
|
86
88
|
}
|
87
89
|
|
88
|
-
//
|
89
|
-
//
|
90
|
-
if (
|
91
|
-
OPENSSL_PUT_ERROR(RSA,
|
90
|
+
// TODO(crbug.com/boringssl/607): Raise this limit. 512-bit RSA was factored
|
91
|
+
// in 1999.
|
92
|
+
if (n_bits < 512) {
|
93
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL);
|
92
94
|
return 0;
|
93
95
|
}
|
94
96
|
|
95
|
-
//
|
96
|
-
//
|
97
|
-
|
98
|
-
|
99
|
-
// does.
|
100
|
-
//
|
101
|
-
// [1] https://www.imperialviolet.org/2012/03/16/rsae.html
|
102
|
-
// [2] https://www.imperialviolet.org/2012/03/17/rsados.html
|
103
|
-
// [3] https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx
|
104
|
-
static const unsigned kMaxExponentBits = 33;
|
105
|
-
unsigned e_bits = BN_num_bits(rsa->e);
|
106
|
-
if (e_bits > kMaxExponentBits ||
|
107
|
-
// Additionally reject e = 1 or even e. e must be odd to be relatively
|
108
|
-
// prime with phi(n).
|
109
|
-
e_bits < 2 ||
|
110
|
-
!BN_is_odd(rsa->e)) {
|
111
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE);
|
97
|
+
// RSA moduli must be positive and odd. In addition to being necessary for RSA
|
98
|
+
// in general, we cannot setup Montgomery reduction with even moduli.
|
99
|
+
if (!BN_is_odd(rsa->n) || BN_is_negative(rsa->n)) {
|
100
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_RSA_PARAMETERS);
|
112
101
|
return 0;
|
113
102
|
}
|
114
103
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
104
|
+
static const unsigned kMaxExponentBits = 33;
|
105
|
+
if (rsa->e != NULL) {
|
106
|
+
// Reject e = 1, negative e, and even e. e must be odd to be relatively
|
107
|
+
// prime with phi(n).
|
108
|
+
unsigned e_bits = BN_num_bits(rsa->e);
|
109
|
+
if (e_bits < 2 || BN_is_negative(rsa->e) || !BN_is_odd(rsa->e)) {
|
110
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE);
|
111
|
+
return 0;
|
112
|
+
}
|
113
|
+
if (rsa->flags & RSA_FLAG_LARGE_PUBLIC_EXPONENT) {
|
114
|
+
// The caller has requested disabling DoS protections. Still, e must be
|
115
|
+
// less than n.
|
116
|
+
if (BN_ucmp(rsa->n, rsa->e) <= 0) {
|
117
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE);
|
118
|
+
return 0;
|
119
|
+
}
|
120
|
+
} else {
|
121
|
+
// Mitigate DoS attacks by limiting the exponent size. 33 bits was chosen
|
122
|
+
// as the limit based on the recommendations in [1] and [2]. Windows
|
123
|
+
// CryptoAPI doesn't support values larger than 32 bits [3], so it is
|
124
|
+
// unlikely that exponents larger than 32 bits are being used for anything
|
125
|
+
// Windows commonly does.
|
126
|
+
//
|
127
|
+
// [1] https://www.imperialviolet.org/2012/03/16/rsae.html
|
128
|
+
// [2] https://www.imperialviolet.org/2012/03/17/rsados.html
|
129
|
+
// [3] https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx
|
130
|
+
if (e_bits > kMaxExponentBits) {
|
131
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE);
|
132
|
+
return 0;
|
133
|
+
}
|
134
|
+
|
135
|
+
// The upper bound on |e_bits| and lower bound on |n_bits| imply e is
|
136
|
+
// bounded by n.
|
137
|
+
assert(BN_ucmp(rsa->n, rsa->e) > 0);
|
138
|
+
}
|
139
|
+
} else if (!(rsa->flags & RSA_FLAG_NO_PUBLIC_EXPONENT)) {
|
140
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING);
|
121
141
|
return 0;
|
122
142
|
}
|
123
|
-
assert(BN_ucmp(rsa->n, rsa->e) > 0);
|
124
143
|
|
125
144
|
return 1;
|
126
145
|
}
|
@@ -160,6 +179,11 @@ static int freeze_private_key(RSA *rsa, BN_CTX *ctx) {
|
|
160
179
|
goto err;
|
161
180
|
}
|
162
181
|
|
182
|
+
// Check the public components are within DoS bounds.
|
183
|
+
if (!rsa_check_public_key(rsa)) {
|
184
|
+
goto err;
|
185
|
+
}
|
186
|
+
|
163
187
|
// Pre-compute various intermediate values, as well as copies of private
|
164
188
|
// exponents with correct widths. Note that other threads may concurrently
|
165
189
|
// read from |rsa->n|, |rsa->e|, etc., so any fixes must be in separate
|
@@ -183,7 +207,7 @@ static int freeze_private_key(RSA *rsa, BN_CTX *ctx) {
|
|
183
207
|
goto err;
|
184
208
|
}
|
185
209
|
|
186
|
-
if (rsa->p != NULL && rsa->q != NULL) {
|
210
|
+
if (rsa->e != NULL && rsa->p != NULL && rsa->q != NULL) {
|
187
211
|
// TODO: p and q are also CONSTTIME_SECRET but not yet marked as such
|
188
212
|
// because the Montgomery code does things like test whether or not values
|
189
213
|
// are zero. So the secret marking probably needs to happen inside that
|
@@ -262,96 +286,38 @@ err:
|
|
262
286
|
return ret;
|
263
287
|
}
|
264
288
|
|
265
|
-
|
266
|
-
|
267
|
-
}
|
268
|
-
|
269
|
-
int RSA_encrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out,
|
270
|
-
const uint8_t *in, size_t in_len, int padding) {
|
271
|
-
boringssl_ensure_rsa_self_test();
|
289
|
+
void rsa_invalidate_key(RSA *rsa) {
|
290
|
+
rsa->private_key_frozen = 0;
|
272
291
|
|
273
|
-
|
274
|
-
|
275
|
-
|
292
|
+
BN_MONT_CTX_free(rsa->mont_n);
|
293
|
+
rsa->mont_n = NULL;
|
294
|
+
BN_MONT_CTX_free(rsa->mont_p);
|
295
|
+
rsa->mont_p = NULL;
|
296
|
+
BN_MONT_CTX_free(rsa->mont_q);
|
297
|
+
rsa->mont_q = NULL;
|
276
298
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
299
|
+
BN_free(rsa->d_fixed);
|
300
|
+
rsa->d_fixed = NULL;
|
301
|
+
BN_free(rsa->dmp1_fixed);
|
302
|
+
rsa->dmp1_fixed = NULL;
|
303
|
+
BN_free(rsa->dmq1_fixed);
|
304
|
+
rsa->dmq1_fixed = NULL;
|
305
|
+
BN_free(rsa->inv_small_mod_large_mont);
|
306
|
+
rsa->inv_small_mod_large_mont = NULL;
|
282
307
|
|
283
|
-
|
284
|
-
|
285
|
-
return 0;
|
308
|
+
for (size_t i = 0; i < rsa->num_blindings; i++) {
|
309
|
+
BN_BLINDING_free(rsa->blindings[i]);
|
286
310
|
}
|
311
|
+
OPENSSL_free(rsa->blindings);
|
312
|
+
rsa->blindings = NULL;
|
313
|
+
rsa->num_blindings = 0;
|
314
|
+
OPENSSL_free(rsa->blindings_inuse);
|
315
|
+
rsa->blindings_inuse = NULL;
|
316
|
+
rsa->blinding_fork_generation = 0;
|
317
|
+
}
|
287
318
|
|
288
|
-
|
289
|
-
|
290
|
-
goto err;
|
291
|
-
}
|
292
|
-
|
293
|
-
BN_CTX_start(ctx);
|
294
|
-
f = BN_CTX_get(ctx);
|
295
|
-
result = BN_CTX_get(ctx);
|
296
|
-
buf = OPENSSL_malloc(rsa_size);
|
297
|
-
if (!f || !result || !buf) {
|
298
|
-
goto err;
|
299
|
-
}
|
300
|
-
|
301
|
-
switch (padding) {
|
302
|
-
case RSA_PKCS1_PADDING:
|
303
|
-
i = RSA_padding_add_PKCS1_type_2(buf, rsa_size, in, in_len);
|
304
|
-
break;
|
305
|
-
case RSA_PKCS1_OAEP_PADDING:
|
306
|
-
// Use the default parameters: SHA-1 for both hashes and no label.
|
307
|
-
i = RSA_padding_add_PKCS1_OAEP_mgf1(buf, rsa_size, in, in_len,
|
308
|
-
NULL, 0, NULL, NULL);
|
309
|
-
break;
|
310
|
-
case RSA_NO_PADDING:
|
311
|
-
i = RSA_padding_add_none(buf, rsa_size, in, in_len);
|
312
|
-
break;
|
313
|
-
default:
|
314
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_UNKNOWN_PADDING_TYPE);
|
315
|
-
goto err;
|
316
|
-
}
|
317
|
-
|
318
|
-
if (i <= 0) {
|
319
|
-
goto err;
|
320
|
-
}
|
321
|
-
|
322
|
-
if (BN_bin2bn(buf, rsa_size, f) == NULL) {
|
323
|
-
goto err;
|
324
|
-
}
|
325
|
-
|
326
|
-
if (BN_ucmp(f, rsa->n) >= 0) {
|
327
|
-
// usually the padding functions would catch this
|
328
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
|
329
|
-
goto err;
|
330
|
-
}
|
331
|
-
|
332
|
-
if (!BN_MONT_CTX_set_locked(&rsa->mont_n, &rsa->lock, rsa->n, ctx) ||
|
333
|
-
!BN_mod_exp_mont(result, f, rsa->e, &rsa->mont_n->N, ctx, rsa->mont_n)) {
|
334
|
-
goto err;
|
335
|
-
}
|
336
|
-
|
337
|
-
// put in leading 0 bytes if the number is less than the length of the
|
338
|
-
// modulus
|
339
|
-
if (!BN_bn2bin_padded(out, rsa_size, result)) {
|
340
|
-
OPENSSL_PUT_ERROR(RSA, ERR_R_INTERNAL_ERROR);
|
341
|
-
goto err;
|
342
|
-
}
|
343
|
-
|
344
|
-
*out_len = rsa_size;
|
345
|
-
ret = 1;
|
346
|
-
|
347
|
-
err:
|
348
|
-
if (ctx != NULL) {
|
349
|
-
BN_CTX_end(ctx);
|
350
|
-
BN_CTX_free(ctx);
|
351
|
-
}
|
352
|
-
OPENSSL_free(buf);
|
353
|
-
|
354
|
-
return ret;
|
319
|
+
size_t rsa_default_size(const RSA *rsa) {
|
320
|
+
return BN_num_bytes(rsa->n);
|
355
321
|
}
|
356
322
|
|
357
323
|
// MAX_BLINDINGS_PER_RSA defines the maximum number of cached BN_BLINDINGs per
|
@@ -516,7 +482,7 @@ int rsa_default_sign_raw(RSA *rsa, size_t *out_len, uint8_t *out,
|
|
516
482
|
goto err;
|
517
483
|
}
|
518
484
|
|
519
|
-
if (!
|
485
|
+
if (!rsa_private_transform_no_self_test(rsa, out, buf, rsa_size)) {
|
520
486
|
goto err;
|
521
487
|
}
|
522
488
|
|
@@ -530,77 +496,17 @@ err:
|
|
530
496
|
return ret;
|
531
497
|
}
|
532
498
|
|
533
|
-
int rsa_default_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out,
|
534
|
-
const uint8_t *in, size_t in_len, int padding) {
|
535
|
-
boringssl_ensure_rsa_self_test();
|
536
|
-
|
537
|
-
const unsigned rsa_size = RSA_size(rsa);
|
538
|
-
uint8_t *buf = NULL;
|
539
|
-
int ret = 0;
|
540
|
-
|
541
|
-
if (max_out < rsa_size) {
|
542
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_OUTPUT_BUFFER_TOO_SMALL);
|
543
|
-
return 0;
|
544
|
-
}
|
545
|
-
|
546
|
-
if (padding == RSA_NO_PADDING) {
|
547
|
-
buf = out;
|
548
|
-
} else {
|
549
|
-
// Allocate a temporary buffer to hold the padded plaintext.
|
550
|
-
buf = OPENSSL_malloc(rsa_size);
|
551
|
-
if (buf == NULL) {
|
552
|
-
goto err;
|
553
|
-
}
|
554
|
-
}
|
555
|
-
|
556
|
-
if (in_len != rsa_size) {
|
557
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_LEN_NOT_EQUAL_TO_MOD_LEN);
|
558
|
-
goto err;
|
559
|
-
}
|
560
|
-
|
561
|
-
if (!RSA_private_transform(rsa, buf, in, rsa_size)) {
|
562
|
-
goto err;
|
563
|
-
}
|
564
|
-
|
565
|
-
switch (padding) {
|
566
|
-
case RSA_PKCS1_PADDING:
|
567
|
-
ret =
|
568
|
-
RSA_padding_check_PKCS1_type_2(out, out_len, rsa_size, buf, rsa_size);
|
569
|
-
break;
|
570
|
-
case RSA_PKCS1_OAEP_PADDING:
|
571
|
-
// Use the default parameters: SHA-1 for both hashes and no label.
|
572
|
-
ret = RSA_padding_check_PKCS1_OAEP_mgf1(out, out_len, rsa_size, buf,
|
573
|
-
rsa_size, NULL, 0, NULL, NULL);
|
574
|
-
break;
|
575
|
-
case RSA_NO_PADDING:
|
576
|
-
*out_len = rsa_size;
|
577
|
-
ret = 1;
|
578
|
-
break;
|
579
|
-
default:
|
580
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_UNKNOWN_PADDING_TYPE);
|
581
|
-
goto err;
|
582
|
-
}
|
583
|
-
|
584
|
-
CONSTTIME_DECLASSIFY(&ret, sizeof(ret));
|
585
|
-
if (!ret) {
|
586
|
-
OPENSSL_PUT_ERROR(RSA, RSA_R_PADDING_CHECK_FAILED);
|
587
|
-
} else {
|
588
|
-
CONSTTIME_DECLASSIFY(out, *out_len);
|
589
|
-
}
|
590
|
-
|
591
|
-
err:
|
592
|
-
if (padding != RSA_NO_PADDING) {
|
593
|
-
OPENSSL_free(buf);
|
594
|
-
}
|
595
|
-
|
596
|
-
return ret;
|
597
|
-
}
|
598
499
|
|
599
500
|
static int mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
|
600
501
|
|
601
502
|
int rsa_verify_raw_no_self_test(RSA *rsa, size_t *out_len, uint8_t *out,
|
602
503
|
size_t max_out, const uint8_t *in,
|
603
504
|
size_t in_len, int padding) {
|
505
|
+
if (rsa->n == NULL || rsa->e == NULL) {
|
506
|
+
OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING);
|
507
|
+
return 0;
|
508
|
+
}
|
509
|
+
|
604
510
|
if (!rsa_check_public_key(rsa)) {
|
605
511
|
return 0;
|
606
512
|
}
|
@@ -740,13 +646,18 @@ int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in,
|
|
740
646
|
goto err;
|
741
647
|
}
|
742
648
|
|
743
|
-
const int do_blinding =
|
649
|
+
const int do_blinding =
|
650
|
+
(rsa->flags & (RSA_FLAG_NO_BLINDING | RSA_FLAG_NO_PUBLIC_EXPONENT)) == 0;
|
744
651
|
|
745
652
|
if (rsa->e == NULL && do_blinding) {
|
746
653
|
// We cannot do blinding or verification without |e|, and continuing without
|
747
654
|
// those countermeasures is dangerous. However, the Java/Android RSA API
|
748
655
|
// requires support for keys where only |d| and |n| (and not |e|) are known.
|
749
|
-
// The callers that require that bad behavior set
|
656
|
+
// The callers that require that bad behavior must set
|
657
|
+
// |RSA_FLAG_NO_BLINDING| or use |RSA_new_private_key_no_e|.
|
658
|
+
//
|
659
|
+
// TODO(davidben): Update this comment when Conscrypt is updated to use
|
660
|
+
// |RSA_new_private_key_no_e|.
|
750
661
|
OPENSSL_PUT_ERROR(RSA, RSA_R_NO_PUBLIC_EXPONENT);
|
751
662
|
goto err;
|
752
663
|
}
|
@@ -1382,6 +1293,7 @@ static int RSA_generate_key_ex_maybe_fips(RSA *rsa, int bits,
|
|
1382
1293
|
goto out;
|
1383
1294
|
}
|
1384
1295
|
|
1296
|
+
rsa_invalidate_key(rsa);
|
1385
1297
|
replace_bignum(&rsa->n, &tmp->n);
|
1386
1298
|
replace_bignum(&rsa->e, &tmp->e);
|
1387
1299
|
replace_bignum(&rsa->d, &tmp->d);
|
@@ -26,6 +26,7 @@
|
|
26
26
|
#include <openssl/ec.h>
|
27
27
|
#include <openssl/ecdsa.h>
|
28
28
|
#include <openssl/ec_key.h>
|
29
|
+
#include <openssl/hkdf.h>
|
29
30
|
#include <openssl/hmac.h>
|
30
31
|
#include <openssl/nid.h>
|
31
32
|
#include <openssl/rsa.h>
|
@@ -946,6 +947,76 @@ static int boringssl_self_test_fast(void) {
|
|
946
947
|
goto err;
|
947
948
|
}
|
948
949
|
|
950
|
+
// TLS v1.3: derives a dummy client-early-traffic secret.
|
951
|
+
static const uint8_t kTLS13Secret[32] = {
|
952
|
+
0x02, 0x4a, 0x0d, 0x80, 0xf3, 0x57, 0xf2, 0x49, 0x9a, 0x12, 0x44,
|
953
|
+
0xda, 0xc2, 0x6d, 0xab, 0x66, 0xfc, 0x13, 0xed, 0x85, 0xfc, 0xa7,
|
954
|
+
0x1d, 0xac, 0xe1, 0x46, 0x21, 0x11, 0x19, 0x52, 0x58, 0x74,
|
955
|
+
};
|
956
|
+
static const uint8_t kTLS13Salt[16] = {
|
957
|
+
0x54, 0x61, 0x11, 0x36, 0x75, 0x91, 0xf0, 0xf8,
|
958
|
+
0x92, 0xec, 0x70, 0xbd, 0x78, 0x2a, 0xef, 0x61,
|
959
|
+
};
|
960
|
+
static const uint8_t kTLS13Label[] = "c e traffic";
|
961
|
+
static const uint8_t kTLS13ClientHelloHash[32] = {
|
962
|
+
0x1d, 0xe8, 0x67, 0xed, 0x93, 0x6a, 0x73, 0x65, 0x9b, 0x05, 0xcf,
|
963
|
+
0x8a, 0x22, 0x77, 0xb7, 0x37, 0x29, 0xf2, 0x44, 0x94, 0x81, 0x6a,
|
964
|
+
0x83, 0x33, 0x7f, 0x09, 0xbb, 0x6c, 0xc2, 0x6f, 0x48, 0x9c,
|
965
|
+
};
|
966
|
+
static const uint8_t kTLS13ExpandLabelOutput[32] = {
|
967
|
+
0x62, 0x91, 0x52, 0x90, 0x2e, 0xc9, 0xcf, 0x9c, 0x5f, 0x1e, 0x0a,
|
968
|
+
0xb7, 0x00, 0x33, 0x42, 0x24, 0xc4, 0xe3, 0xba, 0x01, 0x40, 0x32,
|
969
|
+
0x06, 0xab, 0x09, 0x23, 0x8a, 0xdd, 0x01, 0xa4, 0x05, 0xcd,
|
970
|
+
};
|
971
|
+
uint8_t tls13_extract_output[32];
|
972
|
+
size_t tls13_extract_output_len;
|
973
|
+
uint8_t tls13_expand_label_output[32];
|
974
|
+
if (!HKDF_extract(tls13_extract_output, &tls13_extract_output_len,
|
975
|
+
EVP_sha256(), kTLS13Secret, sizeof(kTLS13Secret),
|
976
|
+
kTLS13Salt, sizeof(kTLS13Salt)) ||
|
977
|
+
tls13_extract_output_len != sizeof(tls13_extract_output) ||
|
978
|
+
!CRYPTO_tls13_hkdf_expand_label(
|
979
|
+
tls13_expand_label_output, sizeof(tls13_expand_label_output),
|
980
|
+
EVP_sha256(), tls13_extract_output, sizeof(tls13_extract_output),
|
981
|
+
kTLS13Label, sizeof(kTLS13Label) - 1, kTLS13ClientHelloHash,
|
982
|
+
sizeof(kTLS13ClientHelloHash)) ||
|
983
|
+
!check_test(kTLS13ExpandLabelOutput, tls13_expand_label_output,
|
984
|
+
sizeof(kTLS13ExpandLabelOutput),
|
985
|
+
"CRYPTO_tls13_hkdf_expand_label")) {
|
986
|
+
fprintf(stderr, "TLSv1.3 KDF failed.\n");
|
987
|
+
goto err;
|
988
|
+
}
|
989
|
+
|
990
|
+
// HKDF
|
991
|
+
static const uint8_t kHKDFSecret[32] = {
|
992
|
+
0x68, 0x67, 0x85, 0x04, 0xb9, 0xb3, 0xad, 0xd1, 0x7d, 0x59, 0x67,
|
993
|
+
0xa1, 0xa7, 0xbd, 0x37, 0x99, 0x3f, 0xd8, 0xa3, 0x3c, 0xe7, 0x30,
|
994
|
+
0x30, 0x71, 0xf3, 0x9c, 0x09, 0x6d, 0x16, 0x35, 0xb3, 0xc9,
|
995
|
+
};
|
996
|
+
static const uint8_t kHKDFSalt[32] = {
|
997
|
+
0x8a, 0xab, 0x18, 0xb4, 0x9b, 0x0a, 0x17, 0xf9, 0xe8, 0xe6, 0x97,
|
998
|
+
0x1a, 0x3d, 0xff, 0xda, 0x9b, 0x26, 0x8b, 0x3d, 0x17, 0x78, 0x0a,
|
999
|
+
0xb3, 0xea, 0x65, 0xdb, 0x2a, 0xc0, 0x29, 0x9c, 0xfa, 0x72,
|
1000
|
+
};
|
1001
|
+
static const uint8_t kHKDFInfo[32] = {
|
1002
|
+
0xe5, 0x6f, 0xf9, 0xe1, 0x18, 0x5e, 0x64, 0x8c, 0x6c, 0x8f, 0xee,
|
1003
|
+
0xc6, 0x93, 0x5a, 0xc5, 0x14, 0x8c, 0xf3, 0xd9, 0x78, 0xd2, 0x3a,
|
1004
|
+
0x86, 0xdd, 0x01, 0xdf, 0xb9, 0xe9, 0x5e, 0xe5, 0x1a, 0x56,
|
1005
|
+
};
|
1006
|
+
static const uint8_t kHKDFOutput[32] = {
|
1007
|
+
0xa6, 0x29, 0xb4, 0xd7, 0xf4, 0xc1, 0x16, 0x64, 0x71, 0x5e, 0xa4,
|
1008
|
+
0xa8, 0xe6, 0x60, 0x8c, 0xf3, 0xc1, 0xa5, 0x03, 0xe2, 0x22, 0xf9,
|
1009
|
+
0x89, 0xe2, 0x12, 0x18, 0xbe, 0xef, 0x16, 0x86, 0xe0, 0xec,
|
1010
|
+
};
|
1011
|
+
uint8_t hkdf_output[sizeof(kHKDFOutput)];
|
1012
|
+
if (!HKDF(hkdf_output, sizeof(hkdf_output), EVP_sha256(), kHKDFSecret,
|
1013
|
+
sizeof(kHKDFSecret), kHKDFSalt, sizeof(kHKDFSalt), kHKDFInfo,
|
1014
|
+
sizeof(kHKDFInfo)) ||
|
1015
|
+
!check_test(kHKDFOutput, hkdf_output, sizeof(kHKDFOutput), "HKDF")) {
|
1016
|
+
fprintf(stderr, "HKDF failed.\n");
|
1017
|
+
goto err;
|
1018
|
+
}
|
1019
|
+
|
949
1020
|
ret = 1;
|
950
1021
|
|
951
1022
|
err:
|
@@ -31,6 +31,14 @@ OPENSSL_EXPORT int CRYPTO_tls1_prf(const EVP_MD *digest,
|
|
31
31
|
const uint8_t *seed1, size_t seed1_len,
|
32
32
|
const uint8_t *seed2, size_t seed2_len);
|
33
33
|
|
34
|
+
// CRYPTO_tls13_hkdf_expand_label computes the TLS 1.3 KDF function of the same
|
35
|
+
// name. See https://www.rfc-editor.org/rfc/rfc8446#section-7.1.
|
36
|
+
OPENSSL_EXPORT int CRYPTO_tls13_hkdf_expand_label(
|
37
|
+
uint8_t *out, size_t out_len, const EVP_MD *digest, //
|
38
|
+
const uint8_t *secret, size_t secret_len, //
|
39
|
+
const uint8_t *label, size_t label_len, //
|
40
|
+
const uint8_t *hash, size_t hash_len);
|
41
|
+
|
34
42
|
|
35
43
|
#if defined(__cplusplus)
|
36
44
|
}
|
@@ -52,7 +52,9 @@
|
|
52
52
|
|
53
53
|
#include <assert.h>
|
54
54
|
|
55
|
+
#include <openssl/bytestring.h>
|
55
56
|
#include <openssl/digest.h>
|
57
|
+
#include <openssl/hkdf.h>
|
56
58
|
#include <openssl/hmac.h>
|
57
59
|
#include <openssl/mem.h>
|
58
60
|
|
@@ -176,3 +178,34 @@ end:
|
|
176
178
|
}
|
177
179
|
return ret;
|
178
180
|
}
|
181
|
+
|
182
|
+
int CRYPTO_tls13_hkdf_expand_label(uint8_t *out, size_t out_len,
|
183
|
+
const EVP_MD *digest, //
|
184
|
+
const uint8_t *secret, size_t secret_len,
|
185
|
+
const uint8_t *label, size_t label_len,
|
186
|
+
const uint8_t *hash, size_t hash_len) {
|
187
|
+
static const uint8_t kProtocolLabel[] = "tls13 ";
|
188
|
+
CBB cbb, child;
|
189
|
+
uint8_t *hkdf_label = NULL;
|
190
|
+
size_t hkdf_label_len;
|
191
|
+
|
192
|
+
CBB_zero(&cbb);
|
193
|
+
if (!CBB_init(&cbb, 2 + 1 + sizeof(kProtocolLabel) - 1 + label_len + 1 +
|
194
|
+
hash_len) ||
|
195
|
+
!CBB_add_u16(&cbb, out_len) ||
|
196
|
+
!CBB_add_u8_length_prefixed(&cbb, &child) ||
|
197
|
+
!CBB_add_bytes(&child, kProtocolLabel, sizeof(kProtocolLabel) - 1) ||
|
198
|
+
!CBB_add_bytes(&child, label, label_len) ||
|
199
|
+
!CBB_add_u8_length_prefixed(&cbb, &child) ||
|
200
|
+
!CBB_add_bytes(&child, hash, hash_len) ||
|
201
|
+
!CBB_finish(&cbb, &hkdf_label, &hkdf_label_len)) {
|
202
|
+
CBB_cleanup(&cbb);
|
203
|
+
return 0;
|
204
|
+
}
|
205
|
+
|
206
|
+
const int ret = HKDF_expand(out, out_len, digest, secret, secret_len,
|
207
|
+
hkdf_label, hkdf_label_len);
|
208
|
+
OPENSSL_free(hkdf_label);
|
209
|
+
return ret;
|
210
|
+
}
|
211
|
+
|