grpc 1.38.0 → 1.40.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 +68 -21
- data/include/grpc/event_engine/endpoint_config.h +48 -0
- data/include/grpc/event_engine/event_engine.h +23 -29
- data/include/grpc/event_engine/port.h +2 -0
- data/include/grpc/event_engine/slice_allocator.h +21 -36
- data/include/grpc/grpc.h +9 -2
- data/include/grpc/grpc_security.h +32 -0
- data/include/grpc/grpc_security_constants.h +1 -0
- data/include/grpc/impl/codegen/grpc_types.h +33 -19
- data/include/grpc/impl/codegen/port_platform.h +41 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +415 -249
- data/src/core/ext/filters/client_channel/client_channel.h +42 -18
- data/src/core/ext/filters/client_channel/config_selector.h +19 -6
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +7 -8
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -5
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -6
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -36
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -22
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +68 -103
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
- data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +116 -76
- data/src/core/ext/filters/client_channel/retry_filter.cc +967 -544
- data/src/core/ext/filters/client_channel/retry_service_config.cc +57 -28
- data/src/core/ext/filters/client_channel/retry_service_config.h +9 -3
- data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +5 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
- data/src/core/{lib/event_engine/slice_allocator.cc → ext/transport/chttp2/transport/chttp2_slice_allocator.cc} +23 -16
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +12 -10
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +639 -752
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +190 -69
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -1
- data/src/core/ext/transport/chttp2/transport/parsing.cc +72 -56
- data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
- data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
- data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
- data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
- data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
- data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
- data/src/core/ext/xds/certificate_provider_store.h +1 -1
- data/src/core/ext/xds/xds_api.cc +582 -257
- data/src/core/ext/xds/xds_api.h +46 -8
- data/src/core/ext/xds/xds_bootstrap.cc +4 -1
- data/src/core/ext/xds/xds_client.cc +66 -43
- data/src/core/ext/xds/xds_client.h +0 -4
- data/src/core/ext/xds/xds_http_filters.cc +3 -2
- data/src/core/ext/xds/xds_http_filters.h +3 -0
- data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
- data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
- data/src/core/lib/channel/call_tracer.h +85 -0
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channelz.h +3 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/status_util.h +4 -0
- data/src/core/lib/compression/stream_compression.h +1 -1
- data/src/core/lib/compression/stream_compression_gzip.h +1 -1
- data/src/core/lib/compression/stream_compression_identity.h +1 -1
- data/src/core/lib/debug/stats.h +1 -1
- data/src/core/lib/event_engine/endpoint_config.cc +46 -0
- data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
- data/src/core/lib/event_engine/event_engine.cc +50 -0
- data/src/core/lib/event_engine/sockaddr.cc +14 -12
- data/src/core/lib/event_engine/sockaddr.h +44 -0
- data/src/core/lib/gpr/murmur_hash.cc +4 -2
- data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
- data/src/core/lib/gprpp/manual_constructor.h +1 -1
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/status_helper.h +3 -0
- data/src/core/lib/gprpp/sync.h +2 -30
- data/src/core/lib/iomgr/buffer_list.cc +1 -1
- data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
- data/src/core/lib/iomgr/error.cc +5 -4
- data/src/core/lib/iomgr/error.h +1 -1
- data/src/core/lib/iomgr/ev_apple.h +1 -1
- data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
- data/src/core/lib/iomgr/event_engine/closure.h +33 -0
- data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
- data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
- data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
- data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
- data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
- data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
- data/src/core/lib/iomgr/event_engine/promise.h +51 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
- data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
- data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
- data/src/core/lib/iomgr/exec_ctx.cc +8 -0
- data/src/core/lib/iomgr/exec_ctx.h +3 -4
- data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
- data/src/core/lib/iomgr/executor/threadpool.h +2 -2
- data/src/core/lib/iomgr/iomgr.cc +1 -1
- data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
- data/src/core/lib/iomgr/pollset_custom.cc +2 -2
- data/src/core/lib/iomgr/pollset_custom.h +3 -1
- data/src/core/lib/iomgr/pollset_uv.cc +3 -1
- data/src/core/lib/iomgr/pollset_uv.h +5 -1
- data/src/core/lib/iomgr/port.h +7 -5
- data/src/core/lib/iomgr/python_util.h +1 -1
- data/src/core/lib/iomgr/resolve_address.cc +5 -1
- data/src/core/lib/iomgr/resolve_address.h +6 -0
- data/src/core/lib/iomgr/resource_quota.cc +2 -0
- data/src/core/lib/iomgr/sockaddr.h +1 -0
- data/src/core/lib/iomgr/socket_mutator.cc +15 -2
- data/src/core/lib/iomgr/socket_mutator.h +26 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
- data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -0
- data/src/core/lib/iomgr/tcp_posix.cc +42 -39
- data/src/core/lib/iomgr/tcp_posix.h +8 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
- data/src/core/lib/iomgr/tcp_server_posix.cc +7 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
- data/src/core/lib/iomgr/timer.h +6 -1
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/json/json_reader.cc +1 -2
- data/src/core/lib/matchers/matchers.cc +8 -20
- data/src/core/lib/matchers/matchers.h +2 -1
- data/src/core/lib/security/authorization/authorization_engine.h +44 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
- data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
- data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
- data/src/core/lib/security/authorization/evaluate_args.h +91 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +49 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
- data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
- data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
- data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -18
- data/src/core/lib/security/transport/security_handshaker.cc +12 -4
- data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
- data/src/core/lib/slice/slice.cc +12 -2
- data/src/core/lib/slice/slice_internal.h +1 -0
- data/src/core/lib/surface/call.cc +26 -7
- data/src/core/lib/surface/call.h +11 -0
- data/src/core/lib/surface/completion_queue.cc +22 -22
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +1 -2
- data/src/core/lib/surface/init.cc +1 -3
- data/src/core/lib/surface/init.h +10 -1
- data/src/core/lib/surface/server.cc +3 -1
- data/src/core/lib/surface/server.h +3 -3
- data/src/core/lib/surface/version.cc +2 -4
- data/src/core/lib/transport/error_utils.cc +2 -2
- data/src/core/lib/transport/metadata_batch.cc +13 -2
- data/src/core/lib/transport/metadata_batch.h +7 -0
- data/src/core/lib/transport/transport.h +2 -0
- data/src/core/lib/transport/transport_op_string.cc +1 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/crypt/gsec.h +2 -0
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/err_data.c +269 -263
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
- data/third_party/xxhash/xxhash.h +77 -195
- metadata +81 -39
- data/src/core/lib/gpr/arena.h +0 -47
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
- data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -23,12 +23,12 @@
|
|
23
23
|
#include <openssl/bytestring.h>
|
24
24
|
#include <openssl/digest.h>
|
25
25
|
#include <openssl/err.h>
|
26
|
+
#include <openssl/hpke.h>
|
26
27
|
#include <openssl/mem.h>
|
27
28
|
#include <openssl/rand.h>
|
28
29
|
#include <openssl/stack.h>
|
29
30
|
|
30
31
|
#include "../crypto/internal.h"
|
31
|
-
#include "../crypto/hpke/internal.h"
|
32
32
|
#include "internal.h"
|
33
33
|
|
34
34
|
|
@@ -155,7 +155,7 @@ static bool add_new_session_tickets(SSL_HANDSHAKE *hs, bool *out_sent_tickets) {
|
|
155
155
|
(!ssl->quic_method || !ssl->config->quic_early_data_context.empty());
|
156
156
|
if (enable_early_data) {
|
157
157
|
// QUIC does not use the max_early_data_size parameter and always sets it
|
158
|
-
// to a fixed value. See
|
158
|
+
// to a fixed value. See RFC 9001, section 4.6.1.
|
159
159
|
session->ticket_max_early_data =
|
160
160
|
ssl->quic_method != nullptr ? 0xffffffff : kMaxEarlyDataAccepted;
|
161
161
|
}
|
@@ -188,7 +188,7 @@ static bool add_new_session_tickets(SSL_HANDSHAKE *hs, bool *out_sent_tickets) {
|
|
188
188
|
}
|
189
189
|
}
|
190
190
|
|
191
|
-
// Add a fake extension. See
|
191
|
+
// Add a fake extension. See RFC 8701.
|
192
192
|
if (!CBB_add_u16(&extensions,
|
193
193
|
ssl_get_grease_value(hs, ssl_grease_ticket_extension)) ||
|
194
194
|
!CBB_add_u16(&extensions, 0 /* empty */)) {
|
@@ -377,7 +377,7 @@ static enum ssl_hs_wait_t do_select_session(SSL_HANDSHAKE *hs) {
|
|
377
377
|
&offered_ticket, msg, &client_hello)) {
|
378
378
|
case ssl_ticket_aead_ignore_ticket:
|
379
379
|
assert(!session);
|
380
|
-
if (!ssl_get_new_session(hs
|
380
|
+
if (!ssl_get_new_session(hs)) {
|
381
381
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
382
382
|
return ssl_hs_error;
|
383
383
|
}
|
@@ -394,6 +394,7 @@ static enum ssl_hs_wait_t do_select_session(SSL_HANDSHAKE *hs) {
|
|
394
394
|
}
|
395
395
|
|
396
396
|
ssl->s3->session_reused = true;
|
397
|
+
hs->can_release_private_key = true;
|
397
398
|
|
398
399
|
// Resumption incorporates fresh key material, so refresh the timeout.
|
399
400
|
ssl_session_renew_timeout(ssl, hs->new_session.get(),
|
@@ -444,12 +445,9 @@ static enum ssl_hs_wait_t do_select_session(SSL_HANDSHAKE *hs) {
|
|
444
445
|
ssl->s3->early_data_reason = ssl_early_data_unsupported_for_session;
|
445
446
|
} else if (!hs->early_data_offered) {
|
446
447
|
ssl->s3->early_data_reason = ssl_early_data_peer_declined;
|
447
|
-
} else if (
|
448
|
+
} else if (hs->channel_id_negotiated) {
|
448
449
|
// Channel ID is incompatible with 0-RTT.
|
449
450
|
ssl->s3->early_data_reason = ssl_early_data_channel_id;
|
450
|
-
} else if (ssl->s3->token_binding_negotiated) {
|
451
|
-
// Token Binding is incompatible with 0-RTT.
|
452
|
-
ssl->s3->early_data_reason = ssl_early_data_token_binding;
|
453
451
|
} else if (MakeConstSpan(ssl->s3->alpn_selected) != session->early_alpn) {
|
454
452
|
// The negotiated ALPN must match the one in the ticket.
|
455
453
|
ssl->s3->early_data_reason = ssl_early_data_alpn_mismatch;
|
@@ -514,17 +512,12 @@ static enum ssl_hs_wait_t do_select_session(SSL_HANDSHAKE *hs) {
|
|
514
512
|
ssl_get_handshake_digest(ssl_protocol_version(ssl), hs->new_cipher));
|
515
513
|
|
516
514
|
// Set up the key schedule and incorporate the PSK into the running secret.
|
517
|
-
if (
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
} else if (!tls13_init_key_schedule(hs, MakeConstSpan(kZeroes, hash_len))) {
|
524
|
-
return ssl_hs_error;
|
525
|
-
}
|
526
|
-
|
527
|
-
if (!ssl_hash_message(hs, msg)) {
|
515
|
+
if (!tls13_init_key_schedule(
|
516
|
+
hs, ssl->s3->session_reused
|
517
|
+
? MakeConstSpan(hs->new_session->secret,
|
518
|
+
hs->new_session->secret_length)
|
519
|
+
: MakeConstSpan(kZeroes, hash_len)) ||
|
520
|
+
!ssl_hash_message(hs, msg)) {
|
528
521
|
return ssl_hs_error;
|
529
522
|
}
|
530
523
|
|
@@ -608,7 +601,7 @@ static enum ssl_hs_wait_t do_read_second_client_hello(SSL_HANDSHAKE *hs) {
|
|
608
601
|
return ssl_hs_error;
|
609
602
|
}
|
610
603
|
|
611
|
-
if (
|
604
|
+
if (ssl->s3->ech_accept) {
|
612
605
|
// If we previously accepted the ClientHelloInner, check that the second
|
613
606
|
// ClientHello contains an encrypted_client_hello extension.
|
614
607
|
CBS ech_body;
|
@@ -621,10 +614,11 @@ static enum ssl_hs_wait_t do_read_second_client_hello(SSL_HANDSHAKE *hs) {
|
|
621
614
|
|
622
615
|
// Parse a ClientECH out of the extension body.
|
623
616
|
uint16_t kdf_id, aead_id;
|
624
|
-
|
617
|
+
uint8_t config_id;
|
618
|
+
CBS enc, payload;
|
625
619
|
if (!CBS_get_u16(&ech_body, &kdf_id) || //
|
626
620
|
!CBS_get_u16(&ech_body, &aead_id) ||
|
627
|
-
!
|
621
|
+
!CBS_get_u8(&ech_body, &config_id) ||
|
628
622
|
!CBS_get_u16_length_prefixed(&ech_body, &enc) ||
|
629
623
|
!CBS_get_u16_length_prefixed(&ech_body, &payload) ||
|
630
624
|
CBS_len(&ech_body) != 0) {
|
@@ -634,10 +628,11 @@ static enum ssl_hs_wait_t do_read_second_client_hello(SSL_HANDSHAKE *hs) {
|
|
634
628
|
}
|
635
629
|
|
636
630
|
// Check that ClientECH.cipher_suite is unchanged and that
|
637
|
-
// ClientECH.
|
638
|
-
if (kdf_id !=
|
639
|
-
aead_id !=
|
640
|
-
|
631
|
+
// ClientECH.enc is empty.
|
632
|
+
if (kdf_id != EVP_HPKE_KDF_id(EVP_HPKE_CTX_kdf(hs->ech_hpke_ctx.get())) ||
|
633
|
+
aead_id !=
|
634
|
+
EVP_HPKE_AEAD_id(EVP_HPKE_CTX_aead(hs->ech_hpke_ctx.get())) ||
|
635
|
+
config_id != hs->ech_config_id || CBS_len(&enc) > 0) {
|
641
636
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
642
637
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
643
638
|
return ssl_hs_error;
|
@@ -730,28 +725,6 @@ static enum ssl_hs_wait_t do_read_second_client_hello(SSL_HANDSHAKE *hs) {
|
|
730
725
|
return ssl_hs_ok;
|
731
726
|
}
|
732
727
|
|
733
|
-
static bool make_server_hello(SSL_HANDSHAKE *hs, Array<uint8_t> *out) {
|
734
|
-
SSL *const ssl = hs->ssl;
|
735
|
-
ScopedCBB cbb;
|
736
|
-
CBB body, extensions, session_id;
|
737
|
-
if (!ssl->method->init_message(ssl, cbb.get(), &body, SSL3_MT_SERVER_HELLO) ||
|
738
|
-
!CBB_add_u16(&body, TLS1_2_VERSION) ||
|
739
|
-
!CBB_add_bytes(&body, ssl->s3->server_random,
|
740
|
-
sizeof(ssl->s3->server_random)) ||
|
741
|
-
!CBB_add_u8_length_prefixed(&body, &session_id) ||
|
742
|
-
!CBB_add_bytes(&session_id, hs->session_id, hs->session_id_len) ||
|
743
|
-
!CBB_add_u16(&body, SSL_CIPHER_get_protocol_id(hs->new_cipher)) ||
|
744
|
-
!CBB_add_u8(&body, 0) ||
|
745
|
-
!CBB_add_u16_length_prefixed(&body, &extensions) ||
|
746
|
-
!ssl_ext_pre_shared_key_add_serverhello(hs, &extensions) ||
|
747
|
-
!ssl_ext_key_share_add_serverhello(hs, &extensions) ||
|
748
|
-
!ssl_ext_supported_versions_add_serverhello(hs, &extensions) ||
|
749
|
-
!ssl->method->finish_message(ssl, cbb.get(), out)) {
|
750
|
-
return false;
|
751
|
-
}
|
752
|
-
return true;
|
753
|
-
}
|
754
|
-
|
755
728
|
static enum ssl_hs_wait_t do_send_server_hello(SSL_HANDSHAKE *hs) {
|
756
729
|
SSL *const ssl = hs->ssl;
|
757
730
|
|
@@ -769,25 +742,44 @@ static enum ssl_hs_wait_t do_send_server_hello(SSL_HANDSHAKE *hs) {
|
|
769
742
|
}
|
770
743
|
}
|
771
744
|
|
772
|
-
|
745
|
+
Array<uint8_t> server_hello;
|
746
|
+
ScopedCBB cbb;
|
747
|
+
CBB body, extensions, session_id;
|
748
|
+
if (!ssl->method->init_message(ssl, cbb.get(), &body, SSL3_MT_SERVER_HELLO) ||
|
749
|
+
!CBB_add_u16(&body, TLS1_2_VERSION) ||
|
750
|
+
!CBB_add_bytes(&body, ssl->s3->server_random,
|
751
|
+
sizeof(ssl->s3->server_random)) ||
|
752
|
+
!CBB_add_u8_length_prefixed(&body, &session_id) ||
|
753
|
+
!CBB_add_bytes(&session_id, hs->session_id, hs->session_id_len) ||
|
754
|
+
!CBB_add_u16(&body, SSL_CIPHER_get_protocol_id(hs->new_cipher)) ||
|
755
|
+
!CBB_add_u8(&body, 0) ||
|
756
|
+
!CBB_add_u16_length_prefixed(&body, &extensions) ||
|
757
|
+
!ssl_ext_pre_shared_key_add_serverhello(hs, &extensions) ||
|
758
|
+
!ssl_ext_key_share_add_serverhello(hs, &extensions) ||
|
759
|
+
!ssl_ext_supported_versions_add_serverhello(hs, &extensions) ||
|
760
|
+
!ssl->method->finish_message(ssl, cbb.get(), &server_hello)) {
|
761
|
+
return ssl_hs_error;
|
762
|
+
}
|
773
763
|
|
764
|
+
assert(!ssl->s3->ech_accept || hs->ech_is_inner_present);
|
774
765
|
if (hs->ech_is_inner_present) {
|
775
|
-
//
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
Array<uint8_t> server_hello_ech_conf;
|
781
|
-
if (!make_server_hello(hs, &server_hello_ech_conf) ||
|
782
|
-
!tls13_ech_accept_confirmation(hs, random_suffix,
|
783
|
-
server_hello_ech_conf)) {
|
766
|
+
// Fill in the ECH confirmation signal.
|
767
|
+
Span<uint8_t> random_suffix =
|
768
|
+
random.subspan(SSL3_RANDOM_SIZE - ECH_CONFIRMATION_SIGNAL_LEN);
|
769
|
+
if (!ssl_ech_accept_confirmation(hs, random_suffix, hs->transcript,
|
770
|
+
server_hello)) {
|
784
771
|
return ssl_hs_error;
|
785
772
|
}
|
773
|
+
|
774
|
+
// Update |server_hello|.
|
775
|
+
const size_t offset = ssl_ech_confirmation_signal_hello_offset(ssl);
|
776
|
+
Span<uint8_t> server_hello_out =
|
777
|
+
MakeSpan(server_hello).subspan(offset, ECH_CONFIRMATION_SIGNAL_LEN);
|
778
|
+
OPENSSL_memcpy(server_hello_out.data(), random_suffix.data(),
|
779
|
+
ECH_CONFIRMATION_SIGNAL_LEN);
|
786
780
|
}
|
787
781
|
|
788
|
-
|
789
|
-
if (!make_server_hello(hs, &server_hello) ||
|
790
|
-
!ssl->method->add_message(ssl, std::move(server_hello))) {
|
782
|
+
if (!ssl->method->add_message(ssl, std::move(server_hello))) {
|
791
783
|
return ssl_hs_error;
|
792
784
|
}
|
793
785
|
|
@@ -806,8 +798,6 @@ static enum ssl_hs_wait_t do_send_server_hello(SSL_HANDSHAKE *hs) {
|
|
806
798
|
}
|
807
799
|
|
808
800
|
// Send EncryptedExtensions.
|
809
|
-
ScopedCBB cbb;
|
810
|
-
CBB body;
|
811
801
|
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
812
802
|
SSL3_MT_ENCRYPTED_EXTENSIONS) ||
|
813
803
|
!ssl_add_serverhello_tlsext(hs, &body) ||
|
@@ -820,7 +810,7 @@ static enum ssl_hs_wait_t do_send_server_hello(SSL_HANDSHAKE *hs) {
|
|
820
810
|
hs->cert_request = !!(hs->config->verify_mode & SSL_VERIFY_PEER);
|
821
811
|
// Only request a certificate if Channel ID isn't negotiated.
|
822
812
|
if ((hs->config->verify_mode & SSL_VERIFY_PEER_IF_NO_OBC) &&
|
823
|
-
|
813
|
+
hs->channel_id_negotiated) {
|
824
814
|
hs->cert_request = false;
|
825
815
|
}
|
826
816
|
}
|
@@ -901,6 +891,7 @@ static enum ssl_hs_wait_t do_send_server_finished(SSL_HANDSHAKE *hs) {
|
|
901
891
|
return ssl_hs_hints_ready;
|
902
892
|
}
|
903
893
|
|
894
|
+
hs->can_release_private_key = true;
|
904
895
|
if (!tls13_add_finished(hs) ||
|
905
896
|
// Update the secret to the master secret and derive traffic keys.
|
906
897
|
!tls13_advance_key_schedule(
|
@@ -978,9 +969,8 @@ static enum ssl_hs_wait_t do_read_second_client_flight(SSL_HANDSHAKE *hs) {
|
|
978
969
|
hs->in_early_data = true;
|
979
970
|
}
|
980
971
|
|
981
|
-
// QUIC doesn't use an EndOfEarlyData message (
|
982
|
-
//
|
983
|
-
// return.
|
972
|
+
// QUIC doesn't use an EndOfEarlyData message (RFC 9001, section 8.3), so we
|
973
|
+
// switch to client_handshake_secret before the early return.
|
984
974
|
if (ssl->quic_method != nullptr) {
|
985
975
|
if (!tls13_set_traffic_key(ssl, ssl_encryption_handshake, evp_aead_open,
|
986
976
|
hs->new_session.get(),
|
@@ -1156,7 +1146,7 @@ static enum ssl_hs_wait_t do_read_client_certificate_verify(SSL_HANDSHAKE *hs) {
|
|
1156
1146
|
|
1157
1147
|
static enum ssl_hs_wait_t do_read_channel_id(SSL_HANDSHAKE *hs) {
|
1158
1148
|
SSL *const ssl = hs->ssl;
|
1159
|
-
if (!
|
1149
|
+
if (!hs->channel_id_negotiated) {
|
1160
1150
|
hs->tls13_state = state13_read_client_finished;
|
1161
1151
|
return ssl_hs_ok;
|
1162
1152
|
}
|
data/third_party/xxhash/xxhash.h
CHANGED
@@ -266,7 +266,7 @@ extern "C" {
|
|
266
266
|
***************************************/
|
267
267
|
#define XXH_VERSION_MAJOR 0
|
268
268
|
#define XXH_VERSION_MINOR 8
|
269
|
-
#define XXH_VERSION_RELEASE
|
269
|
+
#define XXH_VERSION_RELEASE 1
|
270
270
|
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
|
271
271
|
|
272
272
|
/*!
|
@@ -275,7 +275,7 @@ extern "C" {
|
|
275
275
|
* This is only useful when xxHash is compiled as a shared library, as it is
|
276
276
|
* independent of the version defined in the header.
|
277
277
|
*
|
278
|
-
* @return `XXH_VERSION_NUMBER` as of when the
|
278
|
+
* @return `XXH_VERSION_NUMBER` as of when the libray was compiled.
|
279
279
|
*/
|
280
280
|
XXH_PUBLIC_API unsigned XXH_versionNumber (void);
|
281
281
|
|
@@ -1394,6 +1394,27 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
|
|
1394
1394
|
/* note: use after variable declarations */
|
1395
1395
|
#define XXH_STATIC_ASSERT(c) do { enum { XXH_sa = 1/(int)(!!(c)) }; } while (0)
|
1396
1396
|
|
1397
|
+
/*!
|
1398
|
+
* @internal
|
1399
|
+
* @def XXH_COMPILER_GUARD(var)
|
1400
|
+
* @brief Used to prevent unwanted optimizations for @p var.
|
1401
|
+
*
|
1402
|
+
* It uses an empty GCC inline assembly statement with a register constraint
|
1403
|
+
* which forces @p var into a general purpose register (eg eax, ebx, ecx
|
1404
|
+
* on x86) and marks it as modified.
|
1405
|
+
*
|
1406
|
+
* This is used in a few places to avoid unwanted autovectorization (e.g.
|
1407
|
+
* XXH32_round()). All vectorization we want is explicit via intrinsics,
|
1408
|
+
* and _usually_ isn't wanted elsewhere.
|
1409
|
+
*
|
1410
|
+
* We also use it to prevent unwanted constant folding for AArch64 in
|
1411
|
+
* XXH3_initCustomSecret_scalar().
|
1412
|
+
*/
|
1413
|
+
#ifdef __GNUC__
|
1414
|
+
# define XXH_COMPILER_GUARD(var) __asm__ __volatile__("" : "+r" (var))
|
1415
|
+
#else
|
1416
|
+
# define XXH_COMPILER_GUARD(var) ((void)0)
|
1417
|
+
#endif
|
1397
1418
|
|
1398
1419
|
/* *************************************
|
1399
1420
|
* Basic Types
|
@@ -1703,11 +1724,12 @@ XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
|
|
1703
1724
|
* @ingroup impl
|
1704
1725
|
* @{
|
1705
1726
|
*/
|
1706
|
-
static const
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1727
|
+
/* #define instead of static const, to be used as initializers */
|
1728
|
+
#define XXH_PRIME32_1 0x9E3779B1U /*!< 0b10011110001101110111100110110001 */
|
1729
|
+
#define XXH_PRIME32_2 0x85EBCA77U /*!< 0b10000101111010111100101001110111 */
|
1730
|
+
#define XXH_PRIME32_3 0xC2B2AE3DU /*!< 0b11000010101100101010111000111101 */
|
1731
|
+
#define XXH_PRIME32_4 0x27D4EB2FU /*!< 0b00100111110101001110101100101111 */
|
1732
|
+
#define XXH_PRIME32_5 0x165667B1U /*!< 0b00010110010101100110011110110001 */
|
1711
1733
|
|
1712
1734
|
#ifdef XXH_OLD_NAMES
|
1713
1735
|
# define PRIME32_1 XXH_PRIME32_1
|
@@ -1733,13 +1755,12 @@ static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input)
|
|
1733
1755
|
acc += input * XXH_PRIME32_2;
|
1734
1756
|
acc = XXH_rotl32(acc, 13);
|
1735
1757
|
acc *= XXH_PRIME32_1;
|
1736
|
-
#if defined(
|
1758
|
+
#if (defined(__SSE4_1__) || defined(__aarch64__)) && !defined(XXH_ENABLE_AUTOVECTORIZE)
|
1737
1759
|
/*
|
1738
1760
|
* UGLY HACK:
|
1739
|
-
*
|
1740
|
-
*
|
1741
|
-
*
|
1742
|
-
* disabling SSE4.1.
|
1761
|
+
* A compiler fence is the only thing that prevents GCC and Clang from
|
1762
|
+
* autovectorizing the XXH32 loop (pragmas and attributes don't work for some
|
1763
|
+
* reason) without globally disabling SSE4.1.
|
1743
1764
|
*
|
1744
1765
|
* The reason we want to avoid vectorization is because despite working on
|
1745
1766
|
* 4 integers at a time, there are multiple factors slowing XXH32 down on
|
@@ -1764,22 +1785,11 @@ static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input)
|
|
1764
1785
|
* can load data, while v3 can multiply. SSE forces them to operate
|
1765
1786
|
* together.
|
1766
1787
|
*
|
1767
|
-
*
|
1768
|
-
*
|
1769
|
-
*
|
1770
|
-
* "+r" // constrain a read/write operand (+) as a general purpose register (r).
|
1771
|
-
* (acc) // and set acc as the operand
|
1772
|
-
* );
|
1773
|
-
*
|
1774
|
-
* Because of the 'r', the compiler has promised that seed will be in a
|
1775
|
-
* general purpose register and the '+' says that it will be 'read/write',
|
1776
|
-
* so it has to assume it has changed. It is like volatile without all the
|
1777
|
-
* loads and stores.
|
1778
|
-
*
|
1779
|
-
* Since the argument has to be in a normal register (not an SSE register),
|
1780
|
-
* each time XXH32_round is called, it is impossible to vectorize.
|
1788
|
+
* This is also enabled on AArch64, as Clang autovectorizes it incorrectly
|
1789
|
+
* and it is pointless writing a NEON implementation that is basically the
|
1790
|
+
* same speed as scalar for XXH32.
|
1781
1791
|
*/
|
1782
|
-
|
1792
|
+
XXH_COMPILER_GUARD(acc);
|
1783
1793
|
#endif
|
1784
1794
|
return acc;
|
1785
1795
|
}
|
@@ -1910,7 +1920,7 @@ XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align)
|
|
1910
1920
|
XXH_FORCE_INLINE xxh_u32
|
1911
1921
|
XXH32_endian_align(const xxh_u8* input, size_t len, xxh_u32 seed, XXH_alignment align)
|
1912
1922
|
{
|
1913
|
-
const xxh_u8* bEnd = input + len;
|
1923
|
+
const xxh_u8* bEnd = input ? input + len : NULL;
|
1914
1924
|
xxh_u32 h32;
|
1915
1925
|
|
1916
1926
|
#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
|
@@ -2134,35 +2144,6 @@ typedef XXH64_hash_t xxh_u64;
|
|
2134
2144
|
# define U64 xxh_u64
|
2135
2145
|
#endif
|
2136
2146
|
|
2137
|
-
/*!
|
2138
|
-
* XXH_REROLL_XXH64:
|
2139
|
-
* Whether to reroll the XXH64_finalize() loop.
|
2140
|
-
*
|
2141
|
-
* Just like XXH32, we can unroll the XXH64_finalize() loop. This can be a
|
2142
|
-
* performance gain on 64-bit hosts, as only one jump is required.
|
2143
|
-
*
|
2144
|
-
* However, on 32-bit hosts, because arithmetic needs to be done with two 32-bit
|
2145
|
-
* registers, and 64-bit arithmetic needs to be simulated, it isn't beneficial
|
2146
|
-
* to unroll. The code becomes ridiculously large (the largest function in the
|
2147
|
-
* binary on i386!), and rerolling it saves anywhere from 3kB to 20kB. It is
|
2148
|
-
* also slightly faster because it fits into cache better and is more likely
|
2149
|
-
* to be inlined by the compiler.
|
2150
|
-
*
|
2151
|
-
* If XXH_REROLL is defined, this is ignored and the loop is always rerolled.
|
2152
|
-
*/
|
2153
|
-
#ifndef XXH_REROLL_XXH64
|
2154
|
-
# if (defined(__ILP32__) || defined(_ILP32)) /* ILP32 is often defined on 32-bit GCC family */ \
|
2155
|
-
|| !(defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) /* x86-64 */ \
|
2156
|
-
|| defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) /* aarch64 */ \
|
2157
|
-
|| defined(__PPC64__) || defined(__PPC64LE__) || defined(__ppc64__) || defined(__powerpc64__) /* ppc64 */ \
|
2158
|
-
|| defined(__mips64__) || defined(__mips64)) /* mips64 */ \
|
2159
|
-
|| (!defined(SIZE_MAX) || SIZE_MAX < ULLONG_MAX) /* check limits */
|
2160
|
-
# define XXH_REROLL_XXH64 1
|
2161
|
-
# else
|
2162
|
-
# define XXH_REROLL_XXH64 0
|
2163
|
-
# endif
|
2164
|
-
#endif /* !defined(XXH_REROLL_XXH64) */
|
2165
|
-
|
2166
2147
|
#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==3))
|
2167
2148
|
/*
|
2168
2149
|
* Manual byteshift. Best for old compilers which don't inline memcpy.
|
@@ -2285,11 +2266,12 @@ XXH_readLE64_align(const void* ptr, XXH_alignment align)
|
|
2285
2266
|
* @ingroup impl
|
2286
2267
|
* @{
|
2287
2268
|
*/
|
2288
|
-
static const
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2269
|
+
/* #define rather that static const, to be used as initializers */
|
2270
|
+
#define XXH_PRIME64_1 0x9E3779B185EBCA87ULL /*!< 0b1001111000110111011110011011000110000101111010111100101010000111 */
|
2271
|
+
#define XXH_PRIME64_2 0xC2B2AE3D27D4EB4FULL /*!< 0b1100001010110010101011100011110100100111110101001110101101001111 */
|
2272
|
+
#define XXH_PRIME64_3 0x165667B19E3779F9ULL /*!< 0b0001011001010110011001111011000110011110001101110111100111111001 */
|
2273
|
+
#define XXH_PRIME64_4 0x85EBCA77C2B2AE63ULL /*!< 0b1000010111101011110010100111011111000010101100101010111001100011 */
|
2274
|
+
#define XXH_PRIME64_5 0x27D4EB2F165667C5ULL /*!< 0b0010011111010100111010110010111100010110010101100110011111000101 */
|
2293
2275
|
|
2294
2276
|
#ifdef XXH_OLD_NAMES
|
2295
2277
|
# define PRIME64_1 XXH_PRIME64_1
|
@@ -2331,126 +2313,26 @@ static xxh_u64 XXH64_avalanche(xxh_u64 h64)
|
|
2331
2313
|
static xxh_u64
|
2332
2314
|
XXH64_finalize(xxh_u64 h64, const xxh_u8* ptr, size_t len, XXH_alignment align)
|
2333
2315
|
{
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
/* Rerolled version for 32-bit targets is faster and much smaller. */
|
2353
|
-
if (XXH_REROLL || XXH_REROLL_XXH64) {
|
2354
|
-
len &= 31;
|
2355
|
-
while (len >= 8) {
|
2356
|
-
XXH_PROCESS8_64;
|
2357
|
-
len -= 8;
|
2358
|
-
}
|
2359
|
-
if (len >= 4) {
|
2360
|
-
XXH_PROCESS4_64;
|
2361
|
-
len -= 4;
|
2362
|
-
}
|
2363
|
-
while (len > 0) {
|
2364
|
-
XXH_PROCESS1_64;
|
2365
|
-
--len;
|
2366
|
-
}
|
2367
|
-
return XXH64_avalanche(h64);
|
2368
|
-
} else {
|
2369
|
-
switch(len & 31) {
|
2370
|
-
case 24: XXH_PROCESS8_64;
|
2371
|
-
/* fallthrough */
|
2372
|
-
case 16: XXH_PROCESS8_64;
|
2373
|
-
/* fallthrough */
|
2374
|
-
case 8: XXH_PROCESS8_64;
|
2375
|
-
return XXH64_avalanche(h64);
|
2376
|
-
|
2377
|
-
case 28: XXH_PROCESS8_64;
|
2378
|
-
/* fallthrough */
|
2379
|
-
case 20: XXH_PROCESS8_64;
|
2380
|
-
/* fallthrough */
|
2381
|
-
case 12: XXH_PROCESS8_64;
|
2382
|
-
/* fallthrough */
|
2383
|
-
case 4: XXH_PROCESS4_64;
|
2384
|
-
return XXH64_avalanche(h64);
|
2385
|
-
|
2386
|
-
case 25: XXH_PROCESS8_64;
|
2387
|
-
/* fallthrough */
|
2388
|
-
case 17: XXH_PROCESS8_64;
|
2389
|
-
/* fallthrough */
|
2390
|
-
case 9: XXH_PROCESS8_64;
|
2391
|
-
XXH_PROCESS1_64;
|
2392
|
-
return XXH64_avalanche(h64);
|
2393
|
-
|
2394
|
-
case 29: XXH_PROCESS8_64;
|
2395
|
-
/* fallthrough */
|
2396
|
-
case 21: XXH_PROCESS8_64;
|
2397
|
-
/* fallthrough */
|
2398
|
-
case 13: XXH_PROCESS8_64;
|
2399
|
-
/* fallthrough */
|
2400
|
-
case 5: XXH_PROCESS4_64;
|
2401
|
-
XXH_PROCESS1_64;
|
2402
|
-
return XXH64_avalanche(h64);
|
2403
|
-
|
2404
|
-
case 26: XXH_PROCESS8_64;
|
2405
|
-
/* fallthrough */
|
2406
|
-
case 18: XXH_PROCESS8_64;
|
2407
|
-
/* fallthrough */
|
2408
|
-
case 10: XXH_PROCESS8_64;
|
2409
|
-
XXH_PROCESS1_64;
|
2410
|
-
XXH_PROCESS1_64;
|
2411
|
-
return XXH64_avalanche(h64);
|
2412
|
-
|
2413
|
-
case 30: XXH_PROCESS8_64;
|
2414
|
-
/* fallthrough */
|
2415
|
-
case 22: XXH_PROCESS8_64;
|
2416
|
-
/* fallthrough */
|
2417
|
-
case 14: XXH_PROCESS8_64;
|
2418
|
-
/* fallthrough */
|
2419
|
-
case 6: XXH_PROCESS4_64;
|
2420
|
-
XXH_PROCESS1_64;
|
2421
|
-
XXH_PROCESS1_64;
|
2422
|
-
return XXH64_avalanche(h64);
|
2423
|
-
|
2424
|
-
case 27: XXH_PROCESS8_64;
|
2425
|
-
/* fallthrough */
|
2426
|
-
case 19: XXH_PROCESS8_64;
|
2427
|
-
/* fallthrough */
|
2428
|
-
case 11: XXH_PROCESS8_64;
|
2429
|
-
XXH_PROCESS1_64;
|
2430
|
-
XXH_PROCESS1_64;
|
2431
|
-
XXH_PROCESS1_64;
|
2432
|
-
return XXH64_avalanche(h64);
|
2433
|
-
|
2434
|
-
case 31: XXH_PROCESS8_64;
|
2435
|
-
/* fallthrough */
|
2436
|
-
case 23: XXH_PROCESS8_64;
|
2437
|
-
/* fallthrough */
|
2438
|
-
case 15: XXH_PROCESS8_64;
|
2439
|
-
/* fallthrough */
|
2440
|
-
case 7: XXH_PROCESS4_64;
|
2441
|
-
/* fallthrough */
|
2442
|
-
case 3: XXH_PROCESS1_64;
|
2443
|
-
/* fallthrough */
|
2444
|
-
case 2: XXH_PROCESS1_64;
|
2445
|
-
/* fallthrough */
|
2446
|
-
case 1: XXH_PROCESS1_64;
|
2447
|
-
/* fallthrough */
|
2448
|
-
case 0: return XXH64_avalanche(h64);
|
2449
|
-
}
|
2316
|
+
len &= 31;
|
2317
|
+
while (len >= 8) {
|
2318
|
+
xxh_u64 const k1 = XXH64_round(0, XXH_get64bits(ptr));
|
2319
|
+
ptr += 8;
|
2320
|
+
h64 ^= k1;
|
2321
|
+
h64 = XXH_rotl64(h64,27) * XXH_PRIME64_1 + XXH_PRIME64_4;
|
2322
|
+
len -= 8;
|
2323
|
+
}
|
2324
|
+
if (len >= 4) {
|
2325
|
+
h64 ^= (xxh_u64)(XXH_get32bits(ptr)) * XXH_PRIME64_1;
|
2326
|
+
ptr += 4;
|
2327
|
+
h64 = XXH_rotl64(h64, 23) * XXH_PRIME64_2 + XXH_PRIME64_3;
|
2328
|
+
len -= 4;
|
2329
|
+
}
|
2330
|
+
while (len > 0) {
|
2331
|
+
h64 ^= (*ptr++) * XXH_PRIME64_5;
|
2332
|
+
h64 = XXH_rotl64(h64, 11) * XXH_PRIME64_1;
|
2333
|
+
--len;
|
2450
2334
|
}
|
2451
|
-
|
2452
|
-
XXH_ASSERT(0);
|
2453
|
-
return 0; /* unreachable, but some compilers complain without it */
|
2335
|
+
return XXH64_avalanche(h64);
|
2454
2336
|
}
|
2455
2337
|
|
2456
2338
|
#ifdef XXH_OLD_NAMES
|
@@ -2466,7 +2348,7 @@ XXH64_finalize(xxh_u64 h64, const xxh_u8* ptr, size_t len, XXH_alignment align)
|
|
2466
2348
|
XXH_FORCE_INLINE xxh_u64
|
2467
2349
|
XXH64_endian_align(const xxh_u8* input, size_t len, xxh_u64 seed, XXH_alignment align)
|
2468
2350
|
{
|
2469
|
-
const xxh_u8* bEnd = input + len;
|
2351
|
+
const xxh_u8* bEnd = input ? input + len : NULL;
|
2470
2352
|
xxh_u64 h64;
|
2471
2353
|
|
2472
2354
|
#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
|
@@ -2664,7 +2546,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
|
|
2664
2546
|
return XXH_readBE64(src);
|
2665
2547
|
}
|
2666
2548
|
|
2667
|
-
|
2549
|
+
#ifndef XXH_NO_XXH3
|
2668
2550
|
|
2669
2551
|
/* *********************************************************************
|
2670
2552
|
* XXH3
|
@@ -2679,7 +2561,9 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
|
|
2679
2561
|
|
2680
2562
|
/* === Compiler specifics === */
|
2681
2563
|
|
2682
|
-
#if defined (
|
2564
|
+
#if ((defined(sun) || defined(__sun)) && __cplusplus) /* Solaris includes __STDC_VERSION__ with C++. Tested with GCC 5.5 */
|
2565
|
+
# define XXH_RESTRICT /* disable */
|
2566
|
+
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* >= C99 */
|
2683
2567
|
# define XXH_RESTRICT restrict
|
2684
2568
|
#else
|
2685
2569
|
/* Note: it might be useful to define __restrict or __restrict__ for some C++ compilers */
|
@@ -3441,7 +3325,7 @@ XXH3_len_4to8_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h
|
|
3441
3325
|
{
|
3442
3326
|
XXH_ASSERT(input != NULL);
|
3443
3327
|
XXH_ASSERT(secret != NULL);
|
3444
|
-
XXH_ASSERT(4 <= len && len
|
3328
|
+
XXH_ASSERT(4 <= len && len <= 8);
|
3445
3329
|
seed ^= (xxh_u64)XXH_swap32((xxh_u32)seed) << 32;
|
3446
3330
|
{ xxh_u32 const input1 = XXH_readLE32(input);
|
3447
3331
|
xxh_u32 const input2 = XXH_readLE32(input + len - 4);
|
@@ -3457,7 +3341,7 @@ XXH3_len_9to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_
|
|
3457
3341
|
{
|
3458
3342
|
XXH_ASSERT(input != NULL);
|
3459
3343
|
XXH_ASSERT(secret != NULL);
|
3460
|
-
XXH_ASSERT(
|
3344
|
+
XXH_ASSERT(9 <= len && len <= 16);
|
3461
3345
|
{ xxh_u64 const bitflip1 = (XXH_readLE64(secret+24) ^ XXH_readLE64(secret+32)) + seed;
|
3462
3346
|
xxh_u64 const bitflip2 = (XXH_readLE64(secret+40) ^ XXH_readLE64(secret+48)) - seed;
|
3463
3347
|
xxh_u64 const input_lo = XXH_readLE64(input) ^ bitflip1;
|
@@ -3527,7 +3411,7 @@ XXH_FORCE_INLINE xxh_u64 XXH3_mix16B(const xxh_u8* XXH_RESTRICT input,
|
|
3527
3411
|
* GCC generates much better scalar code than Clang for the rest of XXH3,
|
3528
3412
|
* which is why finding a more optimal codepath is an interest.
|
3529
3413
|
*/
|
3530
|
-
|
3414
|
+
XXH_COMPILER_GUARD(seed64);
|
3531
3415
|
#endif
|
3532
3416
|
{ xxh_u64 const input_lo = XXH_readLE64(input);
|
3533
3417
|
xxh_u64 const input_hi = XXH_readLE64(input+8);
|
@@ -3871,12 +3755,8 @@ XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_initCustomSecret_avx2(void* XXH_RESTR
|
|
3871
3755
|
* On GCC & Clang, marking 'dest' as modified will cause the compiler:
|
3872
3756
|
* - do not extract the secret from sse registers in the internal loop
|
3873
3757
|
* - use less common registers, and avoid pushing these reg into stack
|
3874
|
-
* The asm hack causes Clang to assume that XXH3_kSecretPtr aliases with
|
3875
|
-
* customSecret, and on aarch64, this prevented LDP from merging two
|
3876
|
-
* loads together for free. Putting the loads together before the stores
|
3877
|
-
* properly generates LDP.
|
3878
3758
|
*/
|
3879
|
-
|
3759
|
+
XXH_COMPILER_GUARD(dest);
|
3880
3760
|
# endif
|
3881
3761
|
|
3882
3762
|
/* GCC -O2 need unroll loop manually */
|
@@ -3985,7 +3865,7 @@ XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_initCustomSecret_sse2(void* XXH_RESTR
|
|
3985
3865
|
* - do not extract the secret from sse registers in the internal loop
|
3986
3866
|
* - use less common registers, and avoid pushing these reg into stack
|
3987
3867
|
*/
|
3988
|
-
|
3868
|
+
XXH_COMPILER_GUARD(dest);
|
3989
3869
|
# endif
|
3990
3870
|
|
3991
3871
|
for (i=0; i < nbRounds; ++i) {
|
@@ -4231,7 +4111,7 @@ XXH3_initCustomSecret_scalar(void* XXH_RESTRICT customSecret, xxh_u64 seed64)
|
|
4231
4111
|
* without hack: 2654.4 MB/s
|
4232
4112
|
* with hack: 3202.9 MB/s
|
4233
4113
|
*/
|
4234
|
-
|
4114
|
+
XXH_COMPILER_GUARD(kSecretPtr);
|
4235
4115
|
#endif
|
4236
4116
|
/*
|
4237
4117
|
* Note: in debug mode, this overrides the asm optimization
|
@@ -4396,7 +4276,7 @@ XXH3_mergeAccs(const xxh_u64* XXH_RESTRICT acc, const xxh_u8* XXH_RESTRICT secre
|
|
4396
4276
|
* without hack: 2063.7 MB/s
|
4397
4277
|
* with hack: 2560.7 MB/s
|
4398
4278
|
*/
|
4399
|
-
|
4279
|
+
XXH_COMPILER_GUARD(result64);
|
4400
4280
|
#endif
|
4401
4281
|
}
|
4402
4282
|
|
@@ -5432,6 +5312,8 @@ XXH128_hashFromCanonical(const XXH128_canonical_t* src)
|
|
5432
5312
|
|
5433
5313
|
#endif /* XXH_NO_LONG_LONG */
|
5434
5314
|
|
5315
|
+
#endif /* XXH_NO_XXH3 */
|
5316
|
+
|
5435
5317
|
/*!
|
5436
5318
|
* @}
|
5437
5319
|
*/
|