grpc 1.69.0 → 1.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +249 -283
- data/include/grpc/event_engine/endpoint_config.h +5 -5
- data/include/grpc/event_engine/event_engine.h +44 -5
- data/include/grpc/status.h +1 -1
- data/include/grpc/support/atm.h +0 -13
- data/include/grpc/support/json.h +16 -16
- data/src/core/call/request_buffer.cc +224 -0
- data/src/core/call/request_buffer.h +192 -0
- data/src/core/channelz/channelz.cc +2 -2
- data/src/core/channelz/channelz.h +3 -22
- data/src/core/channelz/channelz_registry.cc +0 -7
- data/src/core/client_channel/client_channel.cc +18 -29
- data/src/core/client_channel/client_channel.h +2 -2
- data/src/core/client_channel/client_channel_args.h +21 -0
- data/src/core/client_channel/client_channel_filter.cc +54 -131
- data/src/core/client_channel/client_channel_filter.h +11 -9
- data/src/core/client_channel/client_channel_plugin.cc +2 -1
- data/src/core/client_channel/client_channel_service_config.cc +1 -1
- data/src/core/client_channel/client_channel_service_config.h +5 -5
- data/src/core/client_channel/direct_channel.cc +1 -1
- data/src/core/client_channel/direct_channel.h +1 -1
- data/src/core/client_channel/lb_metadata.cc +7 -8
- data/src/core/client_channel/lb_metadata.h +3 -3
- data/src/core/client_channel/load_balanced_call_destination.cc +4 -4
- data/src/core/client_channel/retry_filter.cc +1 -1
- data/src/core/client_channel/retry_filter.h +1 -1
- data/src/core/client_channel/retry_filter_legacy_call_data.cc +10 -12
- data/src/core/client_channel/retry_filter_legacy_call_data.h +7 -7
- data/src/core/client_channel/retry_interceptor.cc +408 -0
- data/src/core/client_channel/retry_interceptor.h +157 -0
- data/src/core/client_channel/retry_service_config.cc +1 -1
- data/src/core/client_channel/retry_service_config.h +16 -3
- data/src/core/client_channel/retry_throttle.cc +33 -18
- data/src/core/client_channel/retry_throttle.h +3 -3
- data/src/core/client_channel/subchannel.cc +43 -76
- data/src/core/client_channel/subchannel.h +4 -4
- data/src/core/client_channel/subchannel_stream_client.cc +0 -1
- data/src/core/client_channel/subchannel_stream_client.h +3 -3
- data/src/core/config/config_vars.cc +1 -0
- data/src/core/config/config_vars.h +1 -0
- data/src/core/config/load_config.cc +3 -2
- data/src/core/config/load_config.h +1 -1
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +4 -11
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.h +7 -7
- data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +1 -1
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +8 -15
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +6 -6
- data/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.cc +1 -1
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +0 -7
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +6 -6
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.cc +1 -1
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -6
- data/src/core/ext/filters/http/client/http_client_filter.h +4 -4
- data/src/core/ext/filters/http/client_authority_filter.cc +6 -11
- data/src/core/ext/filters/http/client_authority_filter.h +6 -6
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +18 -22
- data/src/core/ext/filters/http/message_compress/compression_filter.h +18 -13
- data/src/core/ext/filters/http/server/http_server_filter.cc +3 -8
- data/src/core/ext/filters/http/server/http_server_filter.h +4 -4
- data/src/core/ext/filters/message_size/message_size_filter.cc +13 -25
- data/src/core/ext/filters/message_size/message_size_filter.h +20 -21
- data/src/core/ext/filters/rbac/rbac_filter.cc +0 -7
- data/src/core/ext/filters/rbac/rbac_filter.h +6 -6
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +3 -3
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +1 -6
- data/src/core/ext/filters/stateful_session/stateful_session_filter.h +4 -4
- data/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc +1 -1
- data/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h +2 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +4 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +612 -100
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +189 -13
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/call_tracer_wrapper.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/call_tracer_wrapper.h +4 -4
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +85 -59
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +7 -7
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/flow_control.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/frame.h +5 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
- data/src/core/ext/transport/chttp2/transport/frame_security.cc +1 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +32 -31
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +6 -7
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +19 -8
- data/src/core/ext/transport/chttp2/transport/parsing.cc +14 -14
- data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/ping_callbacks.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/ping_callbacks.h +2 -2
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +2 -2
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/varint.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +16 -22
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +15 -10
- data/src/core/ext/upb-gen/envoy/admin/v3/config_dump_shared.upb.h +3 -1
- data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb.h +16 -0
- data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb_minitable.c +3 -2
- data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb.h +66 -36
- data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.c +19 -17
- data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb.h +116 -0
- data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.c +31 -5
- data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.h +2 -0
- data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb.h +97 -6
- data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.c +17 -11
- data/src/core/ext/upb-gen/envoy/config/core/v3/socket_cmsg_headers.upb.h +151 -0
- data/src/core/ext/upb-gen/envoy/config/core/v3/socket_cmsg_headers.upb_minitable.c +60 -0
- data/src/core/ext/upb-gen/envoy/config/core/v3/socket_cmsg_headers.upb_minitable.h +32 -0
- data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb.h +228 -21
- data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb_minitable.c +65 -17
- data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb_minitable.h +6 -0
- data/src/core/ext/upb-gen/envoy/config/listener/v3/listener_components.upb.h +7 -106
- data/src/core/ext/upb-gen/envoy/config/listener/v3/listener_components.upb_minitable.c +7 -28
- data/src/core/ext/upb-gen/envoy/config/listener/v3/listener_components.upb_minitable.h +0 -2
- data/src/core/ext/upb-gen/envoy/config/listener/v3/quic_config.upb.h +85 -0
- data/src/core/ext/upb-gen/envoy/config/listener/v3/quic_config.upb_minitable.c +25 -3
- data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb.h +2 -1
- data/src/core/ext/upb-gen/envoy/config/rbac/v3/rbac.upb.h +152 -0
- data/src/core/ext/upb-gen/envoy/config/rbac/v3/rbac.upb_minitable.c +40 -10
- data/src/core/ext/upb-gen/envoy/config/rbac/v3/rbac.upb_minitable.h +2 -0
- data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb.h +253 -4
- data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.c +70 -13
- data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.h +4 -0
- data/src/core/ext/upb-gen/envoy/config/trace/v3/trace.upb.h +0 -2
- data/src/core/ext/upb-gen/envoy/config/trace/v3/trace.upb_minitable.c +0 -1
- data/src/core/ext/upb-gen/envoy/config/trace/v3/trace.upb_minitable.h +0 -1
- data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +16 -0
- data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.c +3 -2
- data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +60 -0
- data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb_minitable.c +13 -2
- data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb.h +0 -1
- data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb_minitable.c +0 -1
- data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +102 -24
- data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls.upb_minitable.c +28 -19
- data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +37 -7
- data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb_minitable.c +7 -5
- data/src/core/ext/upb-gen/envoy/service/discovery/v3/discovery.upb.h +251 -18
- data/src/core/ext/upb-gen/envoy/service/discovery/v3/discovery.upb_minitable.c +41 -16
- data/src/core/ext/upb-gen/envoy/service/discovery/v3/discovery.upb_minitable.h +2 -0
- data/src/core/ext/upb-gen/envoy/service/status/v3/csds.upb.h +2 -1
- data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb.h +142 -0
- data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb_minitable.c +55 -0
- data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb_minitable.h +32 -0
- data/src/core/ext/upb-gen/envoy/type/matcher/v3/filter_state.upb.h +33 -0
- data/src/core/ext/upb-gen/envoy/type/matcher/v3/filter_state.upb_minitable.c +7 -4
- data/src/core/ext/upbdefs-gen/envoy/admin/v3/config_dump_shared.upbdefs.c +11 -10
- data/src/core/ext/upbdefs-gen/envoy/admin/v3/server_info.upbdefs.c +6 -4
- data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.c +418 -413
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.c +161 -153
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.c +270 -261
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_cmsg_headers.upbdefs.c +46 -0
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_cmsg_headers.upbdefs.h +33 -0
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_option.upbdefs.c +29 -19
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_option.upbdefs.h +15 -0
- data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener_components.upbdefs.c +58 -65
- data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener_components.upbdefs.h +0 -5
- data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/quic_config.upbdefs.c +73 -63
- data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.c +49 -48
- data/src/core/ext/upbdefs-gen/envoy/config/rbac/v3/rbac.upbdefs.c +117 -100
- data/src/core/ext/upbdefs-gen/envoy/config/rbac/v3/rbac.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.c +917 -898
- data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/trace.upbdefs.c +15 -18
- data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +33 -33
- data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +460 -457
- data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upbdefs.c +16 -19
- data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +95 -95
- data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +202 -191
- data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c +19 -17
- data/src/core/ext/upbdefs-gen/envoy/service/discovery/v3/discovery.upbdefs.c +148 -135
- data/src/core/ext/upbdefs-gen/envoy/service/discovery/v3/discovery.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-gen/envoy/service/status/v3/csds.upbdefs.c +23 -22
- data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/address.upbdefs.c +41 -0
- data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/address.upbdefs.h +33 -0
- data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/filter_state.upbdefs.c +26 -19
- data/src/core/filter/blackboard.cc +2 -2
- data/src/core/filter/filter_args.h +112 -0
- data/src/core/handshaker/handshaker.cc +0 -3
- data/src/core/handshaker/http_connect/http_connect_handshaker.cc +4 -6
- data/src/core/handshaker/http_connect/http_proxy_mapper.cc +31 -32
- data/src/core/handshaker/http_connect/http_proxy_mapper.h +4 -4
- data/src/core/handshaker/http_connect/xds_http_proxy_mapper.cc +5 -5
- data/src/core/handshaker/http_connect/xds_http_proxy_mapper.h +5 -5
- data/src/core/handshaker/proxy_mapper.h +4 -4
- data/src/core/handshaker/proxy_mapper_registry.cc +5 -6
- data/src/core/handshaker/proxy_mapper_registry.h +4 -4
- data/src/core/handshaker/security/secure_endpoint.cc +2 -2
- data/src/core/handshaker/security/security_handshaker.cc +3 -5
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +6 -4
- data/src/core/lib/channel/channel_args.cc +13 -13
- data/src/core/lib/channel/channel_args.h +8 -8
- data/src/core/lib/channel/connected_channel.cc +1 -1
- data/src/core/lib/channel/promise_based_filter.cc +9 -9
- data/src/core/lib/channel/promise_based_filter.h +84 -159
- data/src/core/lib/compression/compression.cc +3 -2
- data/src/core/lib/compression/compression_internal.cc +9 -9
- data/src/core/lib/compression/compression_internal.h +3 -3
- data/src/core/lib/debug/trace_flags.cc +5 -2
- data/src/core/lib/debug/trace_flags.h +2 -1
- data/src/core/lib/event_engine/ares_resolver.cc +9 -11
- data/src/core/lib/event_engine/ares_resolver.h +6 -10
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +2 -4
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -4
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +6 -7
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +2 -4
- data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +2 -4
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +3 -7
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.h +2 -4
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +5 -7
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +6 -7
- data/src/core/lib/event_engine/common_closures.h +2 -4
- data/src/core/lib/event_engine/default_event_engine.cc +62 -33
- data/src/core/lib/event_engine/default_event_engine.h +24 -33
- data/src/core/lib/event_engine/default_event_engine_factory.cc +6 -12
- data/src/core/lib/event_engine/default_event_engine_factory.h +2 -4
- data/src/core/lib/event_engine/event_engine.cc +2 -4
- data/src/core/lib/event_engine/extensions/can_track_errors.h +2 -4
- data/src/core/lib/event_engine/extensions/chaotic_good_extension.h +2 -4
- data/src/core/lib/event_engine/extensions/supports_fd.h +2 -4
- data/src/core/lib/event_engine/extensions/tcp_trace.h +2 -4
- data/src/core/lib/event_engine/forkable.cc +2 -4
- data/src/core/lib/event_engine/forkable.h +2 -4
- data/src/core/lib/event_engine/grpc_polled_fd.h +2 -4
- data/src/core/lib/event_engine/handle_containers.h +2 -4
- data/src/core/lib/event_engine/memory_allocator_factory.h +2 -4
- data/src/core/lib/event_engine/poller.h +2 -4
- data/src/core/lib/event_engine/posix.h +2 -4
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +4 -50
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +2 -4
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -51
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +2 -4
- data/src/core/lib/event_engine/posix_engine/event_poller.h +2 -4
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +2 -4
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +2 -4
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +2 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.h +2 -4
- data/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h +2 -4
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +20 -10
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +2 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +9 -6
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +2 -6
- data/src/core/lib/event_engine/posix_engine/posix_engine_closure.h +2 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +3 -5
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +2 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +2 -4
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +5 -6
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +2 -4
- data/src/core/lib/event_engine/posix_engine/timer.cc +4 -6
- data/src/core/lib/event_engine/posix_engine/timer.h +4 -6
- data/src/core/lib/event_engine/posix_engine/timer_heap.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/timer_heap.h +2 -4
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +5 -7
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +4 -6
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +4 -8
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +24 -25
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +2 -4
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +2 -4
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +2 -4
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +2 -4
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +2 -4
- data/src/core/lib/event_engine/query_extensions.h +2 -4
- data/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h +2 -4
- data/src/core/lib/event_engine/resolved_address.cc +2 -4
- data/src/core/lib/event_engine/resolved_address_internal.h +2 -4
- data/src/core/lib/event_engine/shim.cc +2 -4
- data/src/core/lib/event_engine/shim.h +2 -4
- data/src/core/lib/event_engine/slice.cc +2 -4
- data/src/core/lib/event_engine/slice_buffer.cc +2 -4
- data/src/core/lib/event_engine/tcp_socket_utils.cc +6 -8
- data/src/core/lib/event_engine/tcp_socket_utils.h +5 -7
- data/src/core/lib/event_engine/thread_local.cc +2 -4
- data/src/core/lib/event_engine/thread_local.h +2 -4
- data/src/core/lib/event_engine/thread_pool/thread_count.cc +2 -4
- data/src/core/lib/event_engine/thread_pool/thread_count.h +4 -18
- data/src/core/lib/event_engine/thread_pool/thread_pool.h +2 -4
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +2 -4
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +3 -5
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +2 -4
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +2 -4
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +2 -4
- data/src/core/lib/event_engine/time_util.cc +2 -4
- data/src/core/lib/event_engine/time_util.h +2 -4
- data/src/core/lib/event_engine/utils.cc +2 -4
- data/src/core/lib/event_engine/utils.h +2 -4
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -4
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h +2 -4
- data/src/core/lib/event_engine/windows/iocp.cc +2 -4
- data/src/core/lib/event_engine/windows/iocp.h +2 -4
- data/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc +2 -4
- data/src/core/lib/event_engine/windows/native_windows_dns_resolver.h +2 -4
- data/src/core/lib/event_engine/windows/win_socket.cc +2 -4
- data/src/core/lib/event_engine/windows/win_socket.h +2 -4
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +2 -4
- data/src/core/lib/event_engine/windows/windows_endpoint.h +4 -6
- data/src/core/lib/event_engine/windows/windows_engine.cc +3 -4
- data/src/core/lib/event_engine/windows/windows_engine.h +2 -4
- data/src/core/lib/event_engine/windows/windows_listener.cc +2 -4
- data/src/core/lib/event_engine/windows/windows_listener.h +2 -4
- data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +2 -4
- data/src/core/lib/event_engine/work_queue/basic_work_queue.h +2 -4
- data/src/core/lib/event_engine/work_queue/work_queue.h +2 -4
- data/src/core/lib/experiments/experiments.cc +147 -207
- data/src/core/lib/experiments/experiments.h +79 -96
- data/src/core/lib/iomgr/buffer_list.h +22 -21
- data/src/core/lib/iomgr/cfstream_handle.cc +0 -2
- data/src/core/lib/iomgr/closure.h +1 -4
- data/src/core/lib/iomgr/combiner.cc +0 -1
- data/src/core/lib/iomgr/error.cc +2 -2
- data/src/core/lib/iomgr/event_engine_shims/closure.cc +0 -1
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +1 -3
- data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +0 -1
- data/src/core/lib/iomgr/exec_ctx.cc +1 -7
- data/src/core/lib/iomgr/exec_ctx.h +1 -132
- data/src/core/lib/iomgr/executor.cc +0 -11
- data/src/core/lib/iomgr/resolve_address_posix.cc +0 -2
- data/src/core/lib/iomgr/resolve_address_windows.cc +0 -2
- data/src/core/lib/iomgr/socket_utils_posix.cc +3 -2
- data/src/core/lib/iomgr/tcp_posix.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_posix.cc +1 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +0 -1
- data/src/core/lib/iomgr/timer_manager.cc +1 -9
- data/src/core/lib/promise/activity.cc +2 -0
- data/src/core/lib/promise/activity.h +33 -12
- data/src/core/lib/promise/detail/join_state.h +16 -68
- data/src/core/lib/promise/detail/promise_factory.h +85 -25
- data/src/core/lib/promise/detail/promise_like.h +16 -19
- data/src/core/lib/promise/detail/seq_state.h +102 -315
- data/src/core/lib/promise/for_each.h +14 -5
- data/src/core/lib/promise/if.h +48 -20
- data/src/core/lib/promise/interceptor_list.h +9 -9
- data/src/core/lib/promise/latch.h +14 -6
- data/src/core/lib/promise/loop.h +58 -18
- data/src/core/lib/promise/map.h +145 -49
- data/src/core/lib/promise/party.cc +84 -15
- data/src/core/lib/promise/party.h +229 -32
- data/src/core/lib/promise/pipe.h +12 -12
- data/src/core/lib/promise/poll.h +8 -5
- data/src/core/lib/promise/prioritized_race.h +16 -22
- data/src/core/lib/promise/promise.h +2 -3
- data/src/core/lib/promise/race.h +4 -12
- data/src/core/lib/promise/seq.h +41 -6
- data/src/core/lib/promise/sleep.cc +3 -3
- data/src/core/lib/promise/sleep.h +15 -1
- data/src/core/lib/promise/status_flag.h +19 -3
- data/src/core/lib/promise/try_join.h +119 -5
- data/src/core/lib/promise/try_seq.h +39 -12
- data/src/core/lib/resource_quota/arena.h +87 -0
- data/src/core/lib/resource_quota/connection_quota.h +4 -0
- data/src/core/lib/resource_quota/memory_quota.cc +53 -49
- data/src/core/lib/resource_quota/memory_quota.h +4 -4
- data/src/core/lib/security/authorization/evaluate_args.cc +3 -3
- data/src/core/lib/security/authorization/evaluate_args.h +3 -3
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +0 -7
- data/src/core/lib/security/authorization/grpc_server_authz_filter.h +6 -6
- data/src/core/lib/security/authorization/matchers.h +3 -3
- data/src/core/lib/security/authorization/rbac_policy.cc +1 -1
- data/src/core/lib/security/authorization/rbac_policy.h +3 -3
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +1 -2
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +1 -3
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +0 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +1 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -2
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +1 -1
- data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +0 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +4 -4
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +3 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +0 -1
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +12 -13
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +14 -14
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +23 -15
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +3 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc +0 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h +1 -2
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +2 -2
- data/src/core/lib/security/credentials/token_fetcher/token_fetcher_credentials.cc +4 -5
- data/src/core/lib/security/credentials/token_fetcher/token_fetcher_credentials.h +4 -4
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +2 -1
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +3 -3
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +9 -9
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +13 -13
- data/src/core/lib/security/transport/auth_filters.h +95 -7
- data/src/core/lib/security/transport/client_auth_filter.cc +96 -6
- data/src/core/lib/security/transport/server_auth_filter.cc +0 -8
- data/src/core/lib/slice/slice_buffer.cc +2 -2
- data/src/core/lib/slice/slice_buffer.h +2 -2
- data/src/core/lib/surface/call.cc +0 -4
- data/src/core/lib/surface/call.h +4 -3
- data/src/core/lib/surface/call_utils.cc +2 -2
- data/src/core/lib/surface/call_utils.h +10 -4
- data/src/core/lib/surface/channel.cc +6 -14
- data/src/core/lib/surface/channel.h +3 -3
- data/src/core/lib/surface/channel_init.cc +1 -1
- data/src/core/lib/surface/client_call.cc +56 -41
- data/src/core/lib/surface/client_call.h +7 -2
- data/src/core/lib/surface/completion_queue.cc +10 -49
- data/src/core/lib/surface/event_string.cc +7 -1
- data/src/core/lib/surface/filter_stack_call.cc +2 -4
- data/src/core/lib/surface/filter_stack_call.h +1 -1
- data/src/core/lib/surface/init.cc +17 -12
- data/src/core/lib/surface/init_internally.h +13 -2
- data/src/core/lib/surface/legacy_channel.cc +10 -8
- data/src/core/lib/surface/legacy_channel.h +2 -2
- data/src/core/lib/surface/server_call.cc +116 -84
- data/src/core/lib/surface/server_call.h +2 -0
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/call_filters.cc +10 -4
- data/src/core/lib/transport/call_filters.h +108 -59
- data/src/core/lib/transport/call_spine.cc +12 -49
- data/src/core/lib/transport/call_spine.h +174 -7
- data/src/core/lib/transport/call_state.h +140 -47
- data/src/core/lib/transport/connectivity_state.cc +8 -9
- data/src/core/lib/transport/connectivity_state.h +2 -4
- data/src/core/lib/transport/http2_errors.h +5 -3
- data/src/core/lib/transport/interception_chain.cc +8 -0
- data/src/core/lib/transport/interception_chain.h +36 -7
- data/src/core/lib/transport/metadata.h +88 -0
- data/src/core/lib/transport/metadata_batch.cc +2 -2
- data/src/core/lib/transport/metadata_batch.h +79 -18
- data/src/core/lib/transport/timeout_encoding.cc +15 -15
- data/src/core/lib/transport/timeout_encoding.h +3 -2
- data/src/core/lib/transport/transport.cc +0 -1
- data/src/core/lib/transport/transport.h +12 -7
- data/src/core/load_balancing/backend_metric_parser.cc +21 -28
- data/src/core/load_balancing/endpoint_list.cc +11 -1
- data/src/core/load_balancing/endpoint_list.h +20 -13
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +1 -6
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +4 -4
- data/src/core/load_balancing/grpclb/grpclb.cc +21 -38
- data/src/core/load_balancing/health_check_client.cc +16 -48
- data/src/core/load_balancing/health_check_client_internal.h +7 -7
- data/src/core/load_balancing/lb_policy.cc +4 -6
- data/src/core/load_balancing/lb_policy.h +4 -12
- data/src/core/load_balancing/lb_policy_registry.cc +10 -8
- data/src/core/load_balancing/outlier_detection/outlier_detection.cc +57 -68
- data/src/core/load_balancing/outlier_detection/outlier_detection.h +4 -3
- data/src/core/load_balancing/pick_first/pick_first.cc +110 -77
- data/src/core/load_balancing/priority/priority.cc +8 -13
- data/src/core/load_balancing/ring_hash/ring_hash.cc +210 -158
- data/src/core/load_balancing/ring_hash/ring_hash.h +4 -11
- data/src/core/load_balancing/rls/rls.cc +105 -194
- data/src/core/load_balancing/rls/rls.h +97 -1
- data/src/core/load_balancing/round_robin/round_robin.cc +14 -19
- data/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc +4 -4
- data/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h +2 -2
- data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +20 -29
- data/src/core/load_balancing/weighted_target/weighted_target.cc +7 -15
- data/src/core/load_balancing/xds/cds.cc +11 -15
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +15 -18
- data/src/core/load_balancing/xds/xds_cluster_manager.cc +10 -18
- data/src/core/load_balancing/xds/xds_override_host.cc +45 -92
- data/src/core/load_balancing/xds/xds_wrr_locality.cc +10 -12
- data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +11 -11
- data/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +10 -15
- data/src/core/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/resolver/fake/fake_resolver.cc +10 -11
- data/src/core/resolver/fake/fake_resolver.h +2 -2
- data/src/core/resolver/google_c2p/google_c2p_resolver.cc +9 -12
- data/src/core/resolver/polling_resolver.cc +2 -5
- data/src/core/resolver/polling_resolver.h +3 -3
- data/src/core/resolver/resolver_registry.cc +4 -3
- data/src/core/resolver/xds/xds_config.cc +6 -6
- data/src/core/resolver/xds/xds_config.h +2 -2
- data/src/core/resolver/xds/xds_dependency_manager.cc +190 -183
- data/src/core/resolver/xds/xds_dependency_manager.h +28 -18
- data/src/core/resolver/xds/xds_resolver.cc +81 -122
- data/src/core/server/server.cc +353 -95
- data/src/core/server/server.h +214 -65
- data/src/core/server/server_call_tracer_filter.cc +3 -7
- data/src/core/server/server_config_selector_filter.cc +8 -15
- data/src/core/server/xds_server_config_fetcher.cc +93 -159
- data/src/core/service_config/service_config_channel_arg_filter.cc +7 -19
- data/src/core/service_config/service_config_impl.cc +3 -3
- data/src/core/telemetry/call_tracer.cc +8 -8
- data/src/core/telemetry/call_tracer.h +6 -5
- data/src/core/telemetry/metrics.cc +3 -3
- data/src/core/telemetry/metrics.h +2 -8
- data/src/core/telemetry/tcp_tracer.h +32 -32
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +14 -14
- data/src/core/tsi/fake_transport_security.cc +5 -0
- data/src/core/util/backoff.cc +15 -4
- data/src/core/util/dump_args.h +1 -9
- data/src/core/util/env.h +3 -4
- data/src/core/util/examine_stack.cc +2 -2
- data/src/core/util/examine_stack.h +3 -4
- data/src/core/util/gpr_time.cc +0 -2
- data/src/core/util/http_client/httpcli.cc +69 -22
- data/src/core/util/http_client/httpcli.h +18 -8
- data/src/core/util/http_client/httpcli_security_connector.cc +2 -2
- data/src/core/util/json/json_channel_args.h +2 -1
- data/src/core/util/json/json_object_loader.cc +4 -4
- data/src/core/util/json/json_object_loader.h +12 -12
- data/src/core/util/json/json_reader.cc +4 -4
- data/src/core/util/json/json_writer.cc +3 -3
- data/src/core/util/latent_see.cc +3 -3
- data/src/core/util/latent_see.h +2 -2
- data/src/core/util/linux/env.cc +3 -4
- data/src/core/util/lru_cache.h +4 -4
- data/src/core/util/match.h +7 -7
- data/src/core/util/matchers.cc +1 -2
- data/src/core/util/matchers.h +7 -12
- data/src/core/util/posix/env.cc +2 -2
- data/src/core/util/posix/sync.cc +0 -1
- data/src/core/util/posix/time.cc +0 -1
- data/src/core/util/ref_counted.h +1 -0
- data/src/core/util/ref_counted_ptr.h +1 -1
- data/src/core/util/ring_buffer.h +4 -5
- data/src/core/util/status_helper.cc +16 -20
- data/src/core/util/status_helper.h +5 -5
- data/src/core/util/sync_abseil.cc +0 -1
- data/src/core/util/table.h +6 -21
- data/src/core/util/time.cc +1 -1
- data/src/core/util/time.h +3 -3
- data/src/core/util/time_precise.cc +0 -1
- data/src/core/util/type_list.h +56 -0
- data/src/core/util/uri.cc +6 -4
- data/src/core/util/uri.h +7 -0
- data/src/core/util/useful.h +13 -15
- data/src/core/util/validation_errors.cc +5 -5
- data/src/core/util/wait_for_single_owner.h +62 -0
- data/src/core/util/windows/env.cc +3 -3
- data/src/core/util/windows/sync.cc +0 -1
- data/src/core/util/windows/time.cc +0 -1
- data/src/core/util/work_serializer.cc +27 -267
- data/src/core/util/work_serializer.h +3 -27
- data/src/core/xds/grpc/certificate_provider_store.cc +12 -17
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +2 -2
- data/src/core/xds/grpc/xds_audit_logger_registry.cc +1 -1
- data/src/core/xds/grpc/xds_bootstrap_grpc.cc +11 -14
- data/src/core/xds/grpc/xds_bootstrap_grpc.h +2 -2
- data/src/core/xds/grpc/xds_certificate_provider.cc +15 -15
- data/src/core/xds/grpc/xds_client_grpc.cc +7 -8
- data/src/core/xds/grpc/xds_cluster.h +4 -4
- data/src/core/xds/grpc/xds_cluster_parser.cc +26 -26
- data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +4 -4
- data/src/core/xds/grpc/xds_common_types.cc +2 -2
- data/src/core/xds/grpc/xds_common_types.h +4 -4
- data/src/core/xds/grpc/xds_common_types_parser.cc +29 -31
- data/src/core/xds/grpc/xds_common_types_parser.h +8 -7
- data/src/core/xds/grpc/xds_endpoint.cc +3 -4
- data/src/core/xds/grpc/xds_endpoint_parser.cc +68 -37
- data/src/core/xds/grpc/xds_health_status.cc +4 -4
- data/src/core/xds/grpc/xds_health_status.h +4 -3
- data/src/core/xds/grpc/xds_http_fault_filter.cc +18 -20
- data/src/core/xds/grpc/xds_http_fault_filter.h +4 -3
- data/src/core/xds/grpc/xds_http_filter.h +3 -3
- data/src/core/xds/grpc/xds_http_filter_registry.cc +7 -7
- data/src/core/xds/grpc/xds_http_filter_registry.h +3 -3
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +7 -7
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +4 -3
- data/src/core/xds/grpc/xds_http_rbac_filter.cc +30 -23
- data/src/core/xds/grpc/xds_http_rbac_filter.h +4 -3
- data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +10 -10
- data/src/core/xds/grpc/xds_http_stateful_session_filter.h +4 -3
- data/src/core/xds/grpc/xds_lb_policy_registry.cc +4 -4
- data/src/core/xds/grpc/xds_listener.cc +4 -6
- data/src/core/xds/grpc/xds_listener.h +10 -10
- data/src/core/xds/grpc/xds_listener_parser.cc +58 -51
- data/src/core/xds/grpc/xds_listener_parser.h +2 -1
- data/src/core/xds/grpc/xds_metadata.cc +5 -5
- data/src/core/xds/grpc/xds_metadata.h +8 -0
- data/src/core/xds/grpc/xds_metadata_parser.cc +65 -52
- data/src/core/xds/grpc/xds_route_config.cc +9 -15
- data/src/core/xds/grpc/xds_route_config.h +9 -9
- data/src/core/xds/grpc/xds_route_config_parser.cc +114 -116
- data/src/core/xds/grpc/xds_route_config_parser.h +4 -4
- data/src/core/xds/grpc/xds_routing.cc +6 -6
- data/src/core/xds/grpc/xds_routing.h +5 -5
- data/src/core/xds/grpc/xds_server_grpc.cc +22 -1
- data/src/core/xds/grpc/xds_server_grpc.h +5 -2
- data/src/core/xds/grpc/xds_server_grpc_interface.h +33 -0
- data/src/core/xds/grpc/xds_transport_grpc.cc +5 -6
- data/src/core/xds/xds_client/lrs_client.cc +71 -83
- data/src/core/xds/xds_client/lrs_client.h +8 -8
- data/src/core/xds/xds_client/xds_api.cc +5 -228
- data/src/core/xds/xds_client/xds_api.h +1 -133
- data/src/core/xds/xds_client/xds_bootstrap.cc +11 -1
- data/src/core/xds/xds_client/xds_bootstrap.h +7 -0
- data/src/core/xds/xds_client/xds_client.cc +1030 -704
- data/src/core/xds/xds_client/xds_client.h +135 -29
- data/src/core/xds/xds_client/xds_resource_type.h +2 -3
- data/src/core/xds/xds_client/xds_resource_type_impl.h +13 -8
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_bitstr.c → a_bitstr.cc} +16 -57
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.cc +53 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.cc +47 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.cc +42 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.cc +109 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.cc +43 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_int.c → a_int.cc} +15 -56
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_mbstr.c → a_mbstr.cc} +22 -62
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_object.c → a_object.cc} +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.cc +32 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_strex.c → a_strex.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_strnid.c → a_strnid.cc} +20 -59
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_time.c → a_time.cc} +41 -76
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{a_type.c → a_type.cc} +17 -59
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.cc +109 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{asn1_lib.c → asn1_lib.cc} +17 -59
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.cc +61 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.cc +56 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.cc +63 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.cc +52 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +13 -57
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{posix_time.c → posix_time.cc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{tasn_dec.c → tasn_dec.cc} +17 -58
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{tasn_enc.c → tasn_enc.cc} +22 -61
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.cc +164 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{tasn_new.c → tasn_new.cc} +20 -61
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.cc +84 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{tasn_utl.c → tasn_utl.cc} +26 -65
- data/third_party/boringssl-with-bazel/src/crypto/base64/{base64.c → base64.cc} +22 -67
- data/third_party/boringssl-with-bazel/src/crypto/bcm_support.h +19 -13
- data/third_party/boringssl-with-bazel/src/crypto/bio/{bio.c → bio.cc} +45 -113
- data/third_party/boringssl-with-bazel/src/crypto/bio/{bio_mem.c → bio_mem.cc} +21 -62
- data/third_party/boringssl-with-bazel/src/crypto/bio/{connect.c → connect.cc} +40 -73
- data/third_party/boringssl-with-bazel/src/crypto/bio/errno.cc +50 -0
- data/third_party/boringssl-with-bazel/src/crypto/bio/{fd.c → fd.cc} +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/bio/{file.c → file.cc} +17 -59
- data/third_party/boringssl-with-bazel/src/crypto/bio/hexdump.cc +152 -0
- data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bio/{pair.c → pair.cc} +37 -71
- data/third_party/boringssl-with-bazel/src/crypto/bio/printf.cc +59 -0
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.cc +147 -0
- data/third_party/boringssl-with-bazel/src/crypto/bio/{socket_helper.c → socket_helper.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/blake2/{blake2.c → blake2.cc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/{bn_extra/bn_asn1.c → bn/bn_asn1.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{bn_extra/convert.c → bn/convert.cc} +34 -76
- data/third_party/boringssl-with-bazel/src/crypto/buf/buf.cc +118 -0
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.cc +53 -0
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/{ber.c → ber.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/{cbb.c → cbb.cc} +45 -61
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/{cbs.c → cbs.cc} +42 -41
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/{unicode.c → unicode.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/chacha/{chacha.c → chacha.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/chacha/internal.h +18 -18
- data/third_party/boringssl-with-bazel/src/crypto/cipher/derive_key.cc +110 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra/e_aesctrhmac.c → cipher/e_aesctrhmac.cc} +18 -23
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra/e_aesgcmsiv.c → cipher/e_aesgcmsiv.cc} +42 -38
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra/e_chacha20poly1305.c → cipher/e_chacha20poly1305.cc} +13 -20
- data/third_party/boringssl-with-bazel/src/crypto/cipher/e_des.cc +198 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher/e_null.cc +51 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra/e_rc2.c → cipher/e_rc2.cc} +50 -88
- data/third_party/boringssl-with-bazel/src/crypto/cipher/e_rc4.cc +54 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra/e_tls.c → cipher/e_tls.cc} +14 -13
- data/third_party/boringssl-with-bazel/src/crypto/cipher/get_cipher.cc +85 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → cipher}/internal.h +29 -69
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra/tls_cbc.c → cipher/tls_cbc.cc} +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/conf/{conf.c → conf.cc} +31 -72
- data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_aarch64_apple.c → cpu_aarch64_apple.cc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_aarch64_fuchsia.c → cpu_aarch64_fuchsia.cc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_aarch64_linux.c → cpu_aarch64_linux.cc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_aarch64_openbsd.c → cpu_aarch64_openbsd.cc} +17 -17
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_aarch64_sysreg.c → cpu_aarch64_sysreg.cc} +15 -14
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_win.cc +41 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_arm_freebsd.c → cpu_arm_freebsd.cc} +15 -15
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_arm_linux.c → cpu_arm_linux.cc} +17 -17
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_linux.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{cpu_intel.c → cpu_intel.cc} +60 -99
- data/third_party/boringssl-with-bazel/src/crypto/{crypto.c → crypto.cc} +18 -23
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/{curve25519.c → curve25519.cc} +40 -43
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_64_adx.cc +18 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/{spake25519.c → spake25519.cc} +34 -28
- data/third_party/boringssl-with-bazel/src/crypto/des/{des.c → des.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/des/internal.h +27 -69
- data/third_party/boringssl-with-bazel/src/crypto/dh/dh_asn1.cc +124 -0
- data/third_party/boringssl-with-bazel/src/crypto/{dh_extra/params.c → dh/params.cc} +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/{digest_extra/digest_extra.c → digest/digest_extra.cc} +126 -86
- data/third_party/boringssl-with-bazel/src/crypto/dsa/{dsa.c → dsa.cc} +166 -212
- data/third_party/boringssl-with-bazel/src/crypto/dsa/{dsa_asn1.c → dsa_asn1.cc} +13 -53
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +13 -15
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra/ec_asn1.c → ec/ec_asn1.cc} +59 -61
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra/ec_derive.c → ec/ec_derive.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra/hash_to_curve.c → ec/hash_to_curve.cc} +79 -77
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra → ec}/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/ecdh/ecdh.cc +73 -0
- data/third_party/boringssl-with-bazel/src/crypto/{ecdsa_extra/ecdsa_asn1.c → ecdsa/ecdsa_asn1.cc} +32 -86
- data/third_party/boringssl-with-bazel/src/crypto/engine/{engine.c → engine.cc} +24 -20
- data/third_party/boringssl-with-bazel/src/crypto/err/{err.c → err.cc} +41 -134
- data/third_party/boringssl-with-bazel/src/crypto/err/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/{evp.c → evp.cc} +37 -88
- data/third_party/boringssl-with-bazel/src/crypto/evp/{evp_asn1.c → evp_asn1.cc} +122 -198
- data/third_party/boringssl-with-bazel/src/crypto/evp/{evp_ctx.c → evp_ctx.cc} +20 -63
- data/third_party/boringssl-with-bazel/src/crypto/evp/internal.h +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_dh.c → p_dh.cc} +38 -22
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_dh_asn1.c → p_dh_asn1.cc} +51 -29
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_dsa_asn1.c → p_dsa_asn1.cc} +75 -134
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_ec.c → p_ec.cc} +31 -75
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_ec_asn1.c → p_ec_asn1.cc} +36 -82
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_ed25519.c → p_ed25519.cc} +34 -31
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_ed25519_asn1.c → p_ed25519_asn1.cc} +26 -25
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_hkdf.c → p_hkdf.cc} +30 -26
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_rsa.c → p_rsa.cc} +54 -91
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_rsa_asn1.c → p_rsa_asn1.cc} +26 -69
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_x25519.c → p_x25519.cc} +34 -31
- data/third_party/boringssl-with-bazel/src/crypto/evp/{p_x25519_asn1.c → p_x25519_asn1.cc} +30 -29
- data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.cc +98 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/{print.c → print.cc} +17 -56
- data/third_party/boringssl-with-bazel/src/crypto/evp/{scrypt.c → scrypt.cc} +20 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/sign.cc +114 -0
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.cc +141 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.cc.inc +191 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/{aes_nohw.c.inc → aes_nohw.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes/cbc.c.inc → aes/cbc.cc.inc} +13 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes/cfb.c.inc → aes/cfb.cc.inc} +13 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/ctr.cc.inc +100 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes/gcm.c.inc → aes/gcm.cc.inc} +175 -314
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes/gcm_nohw.c.inc → aes/gcm_nohw.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +419 -70
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/{key_wrap.c.inc → key_wrap.cc.inc} +14 -48
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.cc.inc +84 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/ofb.cc.inc +53 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes/polyval.c.inc → aes/polyval.cc.inc} +14 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{bcm.c → bcm.cc} +116 -113
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm_interface.h +665 -25
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{add.c.inc → add.cc.inc} +14 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/asm/{x86_64-gcc.c.inc → x86_64-gcc.cc.inc} +19 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{bn.c.inc → bn.cc.inc} +25 -79
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{bytes.c.inc → bytes.cc.inc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{cmp.c.inc → cmp.cc.inc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{ctx.c.inc → ctx.cc.inc} +20 -63
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{div.c.inc → div.cc.inc} +42 -93
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{div_extra.c.inc → div_extra.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{exponentiation.c.inc → exponentiation.cc.inc} +38 -131
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{gcd.c.inc → gcd.cc.inc} +16 -113
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{gcd_extra.c.inc → gcd_extra.cc.inc} +45 -37
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{generic.c.inc → generic.cc.inc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +25 -134
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/jacobi.cc.inc +108 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{montgomery.c.inc → montgomery.cc.inc} +24 -126
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{montgomery_inv.c.inc → montgomery_inv.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{mul.c.inc → mul.cc.inc} +24 -70
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{prime.c.inc → prime.cc.inc} +44 -141
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{random.c.inc → random.cc.inc} +13 -107
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{rsaz_exp.c.inc → rsaz_exp.cc.inc} +18 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.h +20 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{shift.c.inc → shift.cc.inc} +16 -59
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{sqrt.c.inc → sqrt.cc.inc} +13 -53
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{aead.c.inc → aead.cc.inc} +30 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{cipher.c.inc → cipher.cc.inc} +20 -65
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{e_aes.c.inc → e_aes.cc.inc} +113 -335
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{e_aesccm.c.inc → e_aesccm.cc.inc} +21 -58
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h +14 -65
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cmac/{cmac.c.inc → cmac.cc.inc} +19 -53
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +26 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/{check.c.inc → check.cc.inc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/{dh.c.inc → dh.cc.inc} +28 -74
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +13 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/{digest.c.inc → digest.cc.inc} +30 -68
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.cc.inc +178 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/internal.h +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +13 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digestsign/{digestsign.c.inc → digestsign.cc.inc} +14 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/builtin_curves.h +91 -91
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{ec.c.inc → ec.cc.inc} +24 -81
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{ec_key.c.inc → ec_key.cc.inc} +26 -86
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{ec_montgomery.c.inc → ec_montgomery.cc.inc} +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{felem.c.inc → felem.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +19 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{oct.c.inc → oct.cc.inc} +19 -72
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p224-64.c.inc → p224-64.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz-table.h +15 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-nistz.c.inc → p256-nistz.cc.inc} +37 -30
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.h +22 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256.c.inc → p256.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{scalar.c.inc → scalar.cc.inc} +21 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{simple.c.inc → simple.cc.inc} +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{simple_mul.c.inc → simple_mul.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{util.c.inc → util.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{wnaf.c.inc → wnaf.cc.inc} +38 -81
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.cc.inc +88 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/{ecdsa.c.inc → ecdsa.cc.inc} +19 -58
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/fips_shared_support.cc +28 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hkdf/{hkdf.c.inc → hkdf.cc.inc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/{hmac.c.inc → hmac.cc.inc} +16 -57
- data/third_party/boringssl-with-bazel/src/crypto/{keccak → fipsmodule/keccak}/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{keccak/keccak.c → fipsmodule/keccak/keccak.cc.inc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/mldsa/mldsa.cc.inc +1993 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/mlkem/mlkem.cc.inc +1165 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/{ctrdrbg.c.inc → ctrdrbg.cc.inc} +22 -28
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +18 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/{rand.c.inc → rand.cc.inc} +34 -30
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.cc.inc +147 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +13 -56
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{padding.c.inc → padding.cc.inc} +32 -73
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{rsa.c.inc → rsa.cc.inc} +93 -148
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{rsa_impl.c.inc → rsa_impl.cc.inc} +82 -137
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/{fips.c.inc → fips.cc.inc} +26 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/{self_check.c.inc → self_check.cc.inc} +68 -64
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/internal.h +34 -34
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/{service_indicator.c.inc → service_indicator.cc.inc} +23 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/internal.h +43 -57
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/{sha1.c.inc → sha1.cc.inc} +39 -88
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/{sha256.c.inc → sha256.cc.inc} +50 -110
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/{sha512.c.inc → sha512.cc.inc} +61 -131
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/address.h +119 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/fors.cc.inc +169 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/fors.h +58 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/merkle.cc.inc +161 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/merkle.h +70 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/params.h +78 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/slhdsa.cc.inc +329 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/thash.cc.inc +173 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/thash.h +85 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/wots.cc.inc +171 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/wots.h +50 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/{kdf.c.inc → kdf.cc.inc} +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/hpke/{hpke.c → hpke.cc} +19 -16
- data/third_party/boringssl-with-bazel/src/crypto/hrss/{hrss.c → hrss.cc} +73 -122
- data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +242 -442
- data/third_party/boringssl-with-bazel/src/crypto/kyber/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/kyber/{kyber.c → kyber.cc} +52 -28
- data/third_party/boringssl-with-bazel/src/crypto/lhash/internal.h +31 -75
- data/third_party/boringssl-with-bazel/src/crypto/lhash/{lhash.c → lhash.cc} +21 -62
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/md4/md4.c.inc → md4/md4.cc} +21 -67
- data/third_party/boringssl-with-bazel/src/crypto/md5/internal.h +37 -0
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/md5/md5.c.inc → md5/md5.cc} +17 -58
- data/third_party/boringssl-with-bazel/src/crypto/{mem.c → mem.cc} +47 -77
- data/third_party/boringssl-with-bazel/src/crypto/mldsa/mldsa.cc +90 -0
- data/third_party/boringssl-with-bazel/src/crypto/mlkem/mlkem.cc +97 -1042
- data/third_party/boringssl-with-bazel/src/crypto/obj/{obj.c → obj.cc} +40 -85
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_xref.cc +80 -0
- data/third_party/boringssl-with-bazel/src/crypto/pem/internal.h +44 -0
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.cc +149 -0
- data/third_party/boringssl-with-bazel/src/crypto/pem/{pem_info.c → pem_info.cc} +20 -60
- data/third_party/boringssl-with-bazel/src/crypto/pem/{pem_lib.c → pem_lib.cc} +59 -107
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.cc +45 -0
- data/third_party/boringssl-with-bazel/src/crypto/pem/{pem_pk8.c → pem_pk8.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pem/{pem_pkey.c → pem_pkey.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.cc +22 -0
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.cc +22 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/{pkcs7.c → pkcs7.cc} +17 -17
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/{pkcs7_x509.c → pkcs7_x509.cc} +40 -37
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/{p5_pbev2.c → p5_pbev2.cc} +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/{pkcs8.c → pkcs8.cc} +170 -210
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/{pkcs8_x509.c → pkcs8_x509.cc} +101 -149
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/{poly1305.c → poly1305.cc} +15 -15
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/{poly1305_arm.c → poly1305_arm.cc} +16 -14
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/{poly1305_vec.c → poly1305_vec.cc} +26 -23
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/pool/{pool.c → pool.cc} +24 -23
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/deterministic.c → rand/deterministic.cc} +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/fork_detect.c → rand/fork_detect.cc} +23 -24
- data/third_party/boringssl-with-bazel/src/crypto/rand/forkunsafe.cc +44 -0
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/getentropy.c → rand/getentropy.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra → rand}/getrandom_fillin.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/rand/ios.cc +42 -0
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/passive.c → rand/passive.cc} +34 -30
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/rand_extra.c → rand/rand.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/rand/sysrand_internal.h +37 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand/trusty.cc +46 -0
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/urandom.c → rand/urandom.cc} +19 -19
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/windows.c → rand/windows.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/rc4/rc4.cc +56 -0
- data/third_party/boringssl-with-bazel/src/crypto/{refcount.c → refcount.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/rsa/internal.h +36 -0
- data/third_party/boringssl-with-bazel/src/crypto/{rsa_extra/rsa_asn1.c → rsa/rsa_asn1.cc} +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/{rsa_extra/rsa_crypt.c → rsa/rsa_crypt.cc} +94 -133
- data/third_party/boringssl-with-bazel/src/crypto/rsa/rsa_extra.cc +19 -0
- data/third_party/boringssl-with-bazel/src/crypto/rsa/rsa_print.cc +27 -0
- data/third_party/boringssl-with-bazel/src/crypto/sha/sha1.cc +52 -0
- data/third_party/boringssl-with-bazel/src/crypto/sha/sha256.cc +87 -0
- data/third_party/boringssl-with-bazel/src/crypto/sha/sha512.cc +104 -0
- data/third_party/boringssl-with-bazel/src/crypto/siphash/{siphash.c → siphash.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/slhdsa.cc +113 -0
- data/third_party/boringssl-with-bazel/src/crypto/spake2plus/internal.h +204 -0
- data/third_party/boringssl-with-bazel/src/crypto/spake2plus/spake2plus.cc +501 -0
- data/third_party/boringssl-with-bazel/src/crypto/stack/{stack.c → stack.cc} +23 -61
- data/third_party/boringssl-with-bazel/src/crypto/thread.cc +68 -0
- data/third_party/boringssl-with-bazel/src/crypto/{thread_none.c → thread_none.cc} +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{thread_pthread.c → thread_pthread.cc} +21 -20
- data/third_party/boringssl-with-bazel/src/crypto/{thread_win.c → thread_win.cc} +33 -29
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/{pmbtoken.c → pmbtoken.cc} +159 -171
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/{trust_token.c → trust_token.cc} +32 -34
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/{voprf.c → voprf.cc} +178 -182
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.cc +52 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.cc +97 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.cc +74 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{algorithm.c → algorithm.cc} +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/x509/{asn1_gen.c → asn1_gen.cc} +19 -62
- data/third_party/boringssl-with-bazel/src/crypto/x509/{by_dir.c → by_dir.cc} +32 -77
- data/third_party/boringssl-with-bazel/src/crypto/x509/{by_file.c → by_file.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/ext_dat.h +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.cc +37 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +13 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/{name_print.c → name_print.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{policy.c → policy.cc} +200 -190
- data/third_party/boringssl-with-bazel/src/crypto/x509/{rsa_pss.c → rsa_pss.cc} +59 -96
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.cc +103 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{t_req.c → t_req.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{t_x509.c → t_x509.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.cc +79 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_akey.c → v3_akey.cc} +17 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_akeya.cc +31 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_alt.c → v3_alt.cc} +17 -58
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_bcons.cc +95 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_bitst.cc +102 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_conf.c → v3_conf.cc} +18 -60
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_cpols.c → v3_cpols.cc} +60 -98
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_crld.c → v3_crld.cc} +16 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_enum.cc +73 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_extku.cc +114 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_genn.c → v3_genn.cc} +20 -62
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_ia5.cc +79 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_info.c → v3_info.cc} +20 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_int.cc +81 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_lib.c → v3_lib.cc} +23 -63
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_ncons.c → v3_ncons.cc} +15 -56
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_ocsp.c → v3_ocsp.cc} +17 -9
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_pcons.cc +101 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_pmaps.c → v3_pmaps.cc} +15 -56
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_prn.c → v3_prn.cc} +15 -56
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_purp.c → v3_purp.cc} +29 -63
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_skey.cc +131 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{v3_utl.c → v3_utl.cc} +30 -78
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.cc +47 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_att.c → x509_att.cc} +16 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_cmp.c → x509_cmp.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.cc +66 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.cc +44 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_ext.c → x509_ext.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_lu.c → x509_lu.cc} +20 -65
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_obj.c → x509_obj.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_req.c → x509_req.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_set.c → x509_set.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_trs.c → x509_trs.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_txt.c → x509_txt.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_v3.c → x509_v3.cc} +15 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_vfy.c → x509_vfy.cc} +229 -267
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509_vpm.c → x509_vpm.cc} +68 -68
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509cset.c → x509cset.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x509name.c → x509name.cc} +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.cc +67 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.cc +91 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.cc +107 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x_all.c → x_all.cc} +23 -61
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.cc +55 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x_crl.c → x_crl.cc} +19 -61
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.cc +36 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x_name.c → x_name.cc} +52 -87
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x_pubkey.c → x_pubkey.cc} +17 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.cc +74 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.cc +51 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.cc +34 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.cc +28 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x_x509.c → x_x509.cc} +61 -99
- data/third_party/boringssl-with-bazel/src/crypto/x509/{x_x509a.c → x_x509a.cc} +17 -57
- data/third_party/boringssl-with-bazel/src/gen/crypto/{err_data.c → err_data.cc} +468 -453
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +13 -47
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +13 -51
- data/third_party/boringssl-with-bazel/src/include/openssl/asm_base.h +14 -14
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +23 -62
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1_mac.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +248 -328
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +24 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/bcm_public.h +82 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/blowfish.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +14 -121
- data/third_party/boringssl-with-bazel/src/include/openssl/buf.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/buffer.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +31 -16
- data/third_party/boringssl-with-bazel/src/include/openssl/cast.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +31 -59
- data/third_party/boringssl-with-bazel/src/include/openssl/cmac.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +25 -14
- data/third_party/boringssl-with-bazel/src/include/openssl/ctrdrbg.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/curve25519.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/des.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +17 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +19 -56
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +17 -58
- data/third_party/boringssl-with-bazel/src/include/openssl/dtls1.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/e_os2.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +14 -66
- data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +31 -72
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdh.h +14 -65
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +13 -51
- data/third_party/boringssl-with-bazel/src/include/openssl/engine.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +13 -107
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +14 -56
- data/third_party/boringssl-with-bazel/src/include/openssl/evp_errors.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/ex_data.h +13 -107
- data/third_party/boringssl-with-bazel/src/include/openssl/experimental/kyber.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/hkdf.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/hmac.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/hrss.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/is_boringssl.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/kdf.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/lhash.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/md4.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/md5.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/mldsa.h +20 -26
- data/third_party/boringssl-with-bazel/src/include/openssl/mlkem.h +13 -37
- data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +27 -69
- data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/obj_mac.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/objects.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/opensslv.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/ossl_typ.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +22 -60
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs12.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/poly1305.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/pool.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/posix_time.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/rc4.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/ripemd.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +23 -63
- data/third_party/boringssl-with-bazel/src/include/openssl/safestack.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/service_indicator.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +15 -95
- data/third_party/boringssl-with-bazel/src/include/openssl/siphash.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/slhdsa.h +174 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +24 -32
- data/third_party/boringssl-with-bazel/src/include/openssl/srtp.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +358 -290
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl3.h +15 -114
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/target.h +23 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +15 -57
- data/third_party/boringssl-with-bazel/src/include/openssl/time.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +27 -156
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +15 -15
- data/third_party/boringssl-with-bazel/src/include/openssl/type_check.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +14 -61
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3_errors.h +13 -53
- data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +15 -14
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +680 -434
- data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +129 -174
- data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +176 -131
- data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +21 -127
- data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +107 -104
- data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +311 -312
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +54 -47
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +677 -475
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +66 -73
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +61 -153
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +198 -331
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +88 -212
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +949 -531
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +47 -157
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +29 -159
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +18 -112
- data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +103 -196
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +52 -145
- data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +15 -20
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +117 -157
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +229 -365
- data/third_party/boringssl-with-bazel/src/ssl/ssl_credential.cc +216 -31
- data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +13 -109
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +34 -33
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +194 -350
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +38 -83
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +101 -236
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +17 -91
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +109 -157
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +44 -30
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +66 -195
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +45 -176
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +58 -42
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +146 -94
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +251 -180
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +236 -107
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +64 -117
- data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +52 -134
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +6 -0
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +6 -0
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_adx.h +4 -1
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +1 -1
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +3 -0
- metadata +357 -348
- data/src/core/ext/upb-gen/envoy/config/trace/v3/opencensus.upb.h +0 -426
- data/src/core/ext/upb-gen/envoy/config/trace/v3/opencensus.upb_minitable.c +0 -87
- data/src/core/ext/upb-gen/envoy/config/trace/v3/opencensus.upb_minitable.h +0 -32
- data/src/core/ext/upb-gen/opencensus/proto/trace/v1/trace_config.upb.h +0 -408
- data/src/core/ext/upb-gen/opencensus/proto/trace/v1/trace_config.upb_minitable.c +0 -124
- data/src/core/ext/upb-gen/opencensus/proto/trace/v1/trace_config.upb_minitable.h +0 -38
- data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/opencensus.upbdefs.c +0 -108
- data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/opencensus.upbdefs.h +0 -33
- data/src/core/ext/upbdefs-gen/opencensus/proto/trace/v1/trace_config.upbdefs.c +0 -67
- data/src/core/ext/upbdefs-gen/opencensus/proto/trace/v1/trace_config.upbdefs.h +0 -48
- data/src/core/util/atm.cc +0 -34
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +0 -95
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +0 -89
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.c +0 -84
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +0 -151
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.c +0 -85
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +0 -74
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +0 -183
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +0 -103
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +0 -98
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +0 -105
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +0 -94
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +0 -212
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +0 -126
- data/third_party/boringssl-with-bazel/src/crypto/bio/errno.c +0 -92
- data/third_party/boringssl-with-bazel/src/crypto/bio/hexdump.c +0 -192
- data/third_party/boringssl-with-bazel/src/crypto/bio/printf.c +0 -102
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +0 -189
- data/third_party/boringssl-with-bazel/src/crypto/buf/buf.c +0 -158
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.c +0 -53
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +0 -127
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +0 -152
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_des.c +0 -228
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.c +0 -90
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.c +0 -94
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_win.c +0 -41
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_64_adx.c +0 -18
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c +0 -165
- data/third_party/boringssl-with-bazel/src/crypto/dilithium/dilithium.c +0 -1539
- data/third_party/boringssl-with-bazel/src/crypto/dilithium/internal.h +0 -58
- data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +0 -124
- data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c +0 -146
- data/third_party/boringssl-with-bazel/src/crypto/evp/sign.c +0 -156
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +0 -236
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.c.inc +0 -127
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c.inc +0 -124
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/jacobi.c.inc +0 -146
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c.inc +0 -304
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c.inc +0 -130
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/fips_shared_support.c +0 -29
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/internal.h +0 -37
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c.inc +0 -196
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +0 -428
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c.inc +0 -87
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c.inc +0 -241
- data/third_party/boringssl-with-bazel/src/crypto/mldsa/internal.h +0 -73
- data/third_party/boringssl-with-bazel/src/crypto/mldsa/mldsa.c +0 -1687
- data/third_party/boringssl-with-bazel/src/crypto/mlkem/internal.h +0 -90
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_xref.c +0 -122
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +0 -243
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.c +0 -87
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.c +0 -64
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.c +0 -64
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c +0 -44
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/ios.c +0 -42
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/sysrand_internal.h +0 -37
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/trusty.c +0 -46
- data/third_party/boringssl-with-bazel/src/crypto/rc4/rc4.c +0 -98
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +0 -79
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_print.c +0 -22
- data/third_party/boringssl-with-bazel/src/crypto/spx/address.c +0 -101
- data/third_party/boringssl-with-bazel/src/crypto/spx/address.h +0 -50
- data/third_party/boringssl-with-bazel/src/crypto/spx/fors.c +0 -133
- data/third_party/boringssl-with-bazel/src/crypto/spx/fors.h +0 -54
- data/third_party/boringssl-with-bazel/src/crypto/spx/merkle.c +0 -150
- data/third_party/boringssl-with-bazel/src/crypto/spx/merkle.h +0 -61
- data/third_party/boringssl-with-bazel/src/crypto/spx/params.h +0 -71
- data/third_party/boringssl-with-bazel/src/crypto/spx/spx.c +0 -140
- data/third_party/boringssl-with-bazel/src/crypto/spx/spx_util.c +0 -53
- data/third_party/boringssl-with-bazel/src/crypto/spx/spx_util.h +0 -44
- data/third_party/boringssl-with-bazel/src/crypto/spx/thash.c +0 -136
- data/third_party/boringssl-with-bazel/src/crypto/spx/thash.h +0 -70
- data/third_party/boringssl-with-bazel/src/crypto/spx/wots.c +0 -135
- data/third_party/boringssl-with-bazel/src/crypto/spx/wots.h +0 -45
- data/third_party/boringssl-with-bazel/src/crypto/thread.c +0 -110
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.c +0 -94
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +0 -136
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +0 -116
- data/third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.c +0 -79
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +0 -145
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +0 -121
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_akeya.c +0 -73
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_bcons.c +0 -135
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_bitst.c +0 -141
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_enum.c +0 -112
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_extku.c +0 -154
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_ia5.c +0 -122
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_int.c +0 -121
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_pcons.c +0 -142
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_skey.c +0 -170
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +0 -89
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +0 -108
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.c +0 -86
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +0 -109
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +0 -133
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +0 -149
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +0 -97
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +0 -78
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +0 -116
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +0 -93
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.c +0 -79
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +0 -70
- data/third_party/boringssl-with-bazel/src/include/openssl/experimental/dilithium.h +0 -129
- data/third_party/boringssl-with-bazel/src/include/openssl/experimental/spx.h +0 -90
@@ -1,1687 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2024, Google LLC
|
2
|
-
*
|
3
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
* purpose with or without fee is hereby granted, provided that the above
|
5
|
-
* copyright notice and this permission notice appear in all copies.
|
6
|
-
*
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
-
|
15
|
-
#include <openssl/mldsa.h>
|
16
|
-
|
17
|
-
#include <assert.h>
|
18
|
-
#include <stdlib.h>
|
19
|
-
|
20
|
-
#include <openssl/bytestring.h>
|
21
|
-
#include <openssl/mem.h>
|
22
|
-
#include <openssl/rand.h>
|
23
|
-
|
24
|
-
#include "../internal.h"
|
25
|
-
#include "../keccak/internal.h"
|
26
|
-
#include "./internal.h"
|
27
|
-
|
28
|
-
#define DEGREE 256
|
29
|
-
#define K 6
|
30
|
-
#define L 5
|
31
|
-
#define ETA 4
|
32
|
-
#define TAU 49
|
33
|
-
#define BETA 196
|
34
|
-
#define OMEGA 55
|
35
|
-
|
36
|
-
#define RHO_BYTES 32
|
37
|
-
#define SIGMA_BYTES 64
|
38
|
-
#define K_BYTES 32
|
39
|
-
#define TR_BYTES 64
|
40
|
-
#define MU_BYTES 64
|
41
|
-
#define RHO_PRIME_BYTES 64
|
42
|
-
#define LAMBDA_BITS 192
|
43
|
-
#define LAMBDA_BYTES (LAMBDA_BITS / 8)
|
44
|
-
|
45
|
-
// 2^23 - 2^13 + 1
|
46
|
-
static const uint32_t kPrime = 8380417;
|
47
|
-
// Inverse of -kPrime modulo 2^32
|
48
|
-
static const uint32_t kPrimeNegInverse = 4236238847;
|
49
|
-
static const int kDroppedBits = 13;
|
50
|
-
static const uint32_t kHalfPrime = (8380417 - 1) / 2;
|
51
|
-
static const uint32_t kGamma1 = 1 << 19;
|
52
|
-
static const uint32_t kGamma2 = (8380417 - 1) / 32;
|
53
|
-
// 256^-1 mod kPrime, in Montgomery form.
|
54
|
-
static const uint32_t kInverseDegreeMontgomery = 41978;
|
55
|
-
|
56
|
-
typedef struct scalar {
|
57
|
-
uint32_t c[DEGREE];
|
58
|
-
} scalar;
|
59
|
-
|
60
|
-
typedef struct vectork {
|
61
|
-
scalar v[K];
|
62
|
-
} vectork;
|
63
|
-
|
64
|
-
typedef struct vectorl {
|
65
|
-
scalar v[L];
|
66
|
-
} vectorl;
|
67
|
-
|
68
|
-
typedef struct matrix {
|
69
|
-
scalar v[K][L];
|
70
|
-
} matrix;
|
71
|
-
|
72
|
-
/* Arithmetic */
|
73
|
-
|
74
|
-
// This bit of Python will be referenced in some of the following comments:
|
75
|
-
//
|
76
|
-
// q = 8380417
|
77
|
-
// # Inverse of -q modulo 2^32
|
78
|
-
// q_neg_inverse = 4236238847
|
79
|
-
// # 2^64 modulo q
|
80
|
-
// montgomery_square = 2365951
|
81
|
-
//
|
82
|
-
// def bitreverse(i):
|
83
|
-
// ret = 0
|
84
|
-
// for n in range(8):
|
85
|
-
// bit = i & 1
|
86
|
-
// ret <<= 1
|
87
|
-
// ret |= bit
|
88
|
-
// i >>= 1
|
89
|
-
// return ret
|
90
|
-
//
|
91
|
-
// def montgomery_reduce(x):
|
92
|
-
// a = (x * q_neg_inverse) % 2**32
|
93
|
-
// b = x + a * q
|
94
|
-
// assert b & 0xFFFF_FFFF == 0
|
95
|
-
// c = b >> 32
|
96
|
-
// assert c < q
|
97
|
-
// return c
|
98
|
-
//
|
99
|
-
// def montgomery_transform(x):
|
100
|
-
// return montgomery_reduce(x * montgomery_square)
|
101
|
-
|
102
|
-
// kNTTRootsMontgomery = [
|
103
|
-
// montgomery_transform(pow(1753, bitreverse(i), q)) for i in range(256)
|
104
|
-
// ]
|
105
|
-
static const uint32_t kNTTRootsMontgomery[256] = {
|
106
|
-
4193792, 25847, 5771523, 7861508, 237124, 7602457, 7504169, 466468,
|
107
|
-
1826347, 2353451, 8021166, 6288512, 3119733, 5495562, 3111497, 2680103,
|
108
|
-
2725464, 1024112, 7300517, 3585928, 7830929, 7260833, 2619752, 6271868,
|
109
|
-
6262231, 4520680, 6980856, 5102745, 1757237, 8360995, 4010497, 280005,
|
110
|
-
2706023, 95776, 3077325, 3530437, 6718724, 4788269, 5842901, 3915439,
|
111
|
-
4519302, 5336701, 3574422, 5512770, 3539968, 8079950, 2348700, 7841118,
|
112
|
-
6681150, 6736599, 3505694, 4558682, 3507263, 6239768, 6779997, 3699596,
|
113
|
-
811944, 531354, 954230, 3881043, 3900724, 5823537, 2071892, 5582638,
|
114
|
-
4450022, 6851714, 4702672, 5339162, 6927966, 3475950, 2176455, 6795196,
|
115
|
-
7122806, 1939314, 4296819, 7380215, 5190273, 5223087, 4747489, 126922,
|
116
|
-
3412210, 7396998, 2147896, 2715295, 5412772, 4686924, 7969390, 5903370,
|
117
|
-
7709315, 7151892, 8357436, 7072248, 7998430, 1349076, 1852771, 6949987,
|
118
|
-
5037034, 264944, 508951, 3097992, 44288, 7280319, 904516, 3958618,
|
119
|
-
4656075, 8371839, 1653064, 5130689, 2389356, 8169440, 759969, 7063561,
|
120
|
-
189548, 4827145, 3159746, 6529015, 5971092, 8202977, 1315589, 1341330,
|
121
|
-
1285669, 6795489, 7567685, 6940675, 5361315, 4499357, 4751448, 3839961,
|
122
|
-
2091667, 3407706, 2316500, 3817976, 5037939, 2244091, 5933984, 4817955,
|
123
|
-
266997, 2434439, 7144689, 3513181, 4860065, 4621053, 7183191, 5187039,
|
124
|
-
900702, 1859098, 909542, 819034, 495491, 6767243, 8337157, 7857917,
|
125
|
-
7725090, 5257975, 2031748, 3207046, 4823422, 7855319, 7611795, 4784579,
|
126
|
-
342297, 286988, 5942594, 4108315, 3437287, 5038140, 1735879, 203044,
|
127
|
-
2842341, 2691481, 5790267, 1265009, 4055324, 1247620, 2486353, 1595974,
|
128
|
-
4613401, 1250494, 2635921, 4832145, 5386378, 1869119, 1903435, 7329447,
|
129
|
-
7047359, 1237275, 5062207, 6950192, 7929317, 1312455, 3306115, 6417775,
|
130
|
-
7100756, 1917081, 5834105, 7005614, 1500165, 777191, 2235880, 3406031,
|
131
|
-
7838005, 5548557, 6709241, 6533464, 5796124, 4656147, 594136, 4603424,
|
132
|
-
6366809, 2432395, 2454455, 8215696, 1957272, 3369112, 185531, 7173032,
|
133
|
-
5196991, 162844, 1616392, 3014001, 810149, 1652634, 4686184, 6581310,
|
134
|
-
5341501, 3523897, 3866901, 269760, 2213111, 7404533, 1717735, 472078,
|
135
|
-
7953734, 1723600, 6577327, 1910376, 6712985, 7276084, 8119771, 4546524,
|
136
|
-
5441381, 6144432, 7959518, 6094090, 183443, 7403526, 1612842, 4834730,
|
137
|
-
7826001, 3919660, 8332111, 7018208, 3937738, 1400424, 7534263, 1976782};
|
138
|
-
|
139
|
-
// Reduces x mod kPrime in constant time, where 0 <= x < 2*kPrime.
|
140
|
-
static uint32_t reduce_once(uint32_t x) {
|
141
|
-
declassify_assert(x < 2 * kPrime);
|
142
|
-
// return x < kPrime ? x : x - kPrime;
|
143
|
-
return constant_time_select_int(constant_time_lt_w(x, kPrime), x, x - kPrime);
|
144
|
-
}
|
145
|
-
|
146
|
-
// Returns the absolute value in constant time.
|
147
|
-
static uint32_t abs_signed(uint32_t x) {
|
148
|
-
// return is_positive(x) ? x : -x;
|
149
|
-
// Note: MSVC doesn't like applying the unary minus operator to unsigned types
|
150
|
-
// (warning C4146), so we write the negation as a bitwise not plus one
|
151
|
-
// (assuming two's complement representation).
|
152
|
-
return constant_time_select_int(constant_time_lt_w(x, 0x80000000), x, 0u - x);
|
153
|
-
}
|
154
|
-
|
155
|
-
// Returns the absolute value modulo kPrime.
|
156
|
-
static uint32_t abs_mod_prime(uint32_t x) {
|
157
|
-
declassify_assert(x < kPrime);
|
158
|
-
// return x > kHalfPrime ? kPrime - x : x;
|
159
|
-
return constant_time_select_int(constant_time_lt_w(kHalfPrime, x), kPrime - x,
|
160
|
-
x);
|
161
|
-
}
|
162
|
-
|
163
|
-
// Returns the maximum of two values in constant time.
|
164
|
-
static uint32_t maximum(uint32_t x, uint32_t y) {
|
165
|
-
// return x < y ? y : x;
|
166
|
-
return constant_time_select_int(constant_time_lt_w(x, y), y, x);
|
167
|
-
}
|
168
|
-
|
169
|
-
static uint32_t mod_sub(uint32_t a, uint32_t b) {
|
170
|
-
declassify_assert(a < kPrime);
|
171
|
-
declassify_assert(b < kPrime);
|
172
|
-
return reduce_once(kPrime + a - b);
|
173
|
-
}
|
174
|
-
|
175
|
-
static void scalar_add(scalar *out, const scalar *lhs, const scalar *rhs) {
|
176
|
-
for (int i = 0; i < DEGREE; i++) {
|
177
|
-
out->c[i] = reduce_once(lhs->c[i] + rhs->c[i]);
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
static void scalar_sub(scalar *out, const scalar *lhs, const scalar *rhs) {
|
182
|
-
for (int i = 0; i < DEGREE; i++) {
|
183
|
-
out->c[i] = mod_sub(lhs->c[i], rhs->c[i]);
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
static uint32_t reduce_montgomery(uint64_t x) {
|
188
|
-
declassify_assert(x <= ((uint64_t)kPrime << 32));
|
189
|
-
uint64_t a = (uint32_t)x * kPrimeNegInverse;
|
190
|
-
uint64_t b = x + a * kPrime;
|
191
|
-
declassify_assert((b & 0xffffffff) == 0);
|
192
|
-
uint32_t c = b >> 32;
|
193
|
-
return reduce_once(c);
|
194
|
-
}
|
195
|
-
|
196
|
-
// Multiply two scalars in the number theoretically transformed state.
|
197
|
-
static void scalar_mult(scalar *out, const scalar *lhs, const scalar *rhs) {
|
198
|
-
for (int i = 0; i < DEGREE; i++) {
|
199
|
-
out->c[i] = reduce_montgomery((uint64_t)lhs->c[i] * (uint64_t)rhs->c[i]);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
// In place number theoretic transform of a given scalar.
|
204
|
-
//
|
205
|
-
// FIPS 204, Algorithm 41 (`NTT`).
|
206
|
-
static void scalar_ntt(scalar *s) {
|
207
|
-
// Step: 1, 2, 4, 8, ..., 128
|
208
|
-
// Offset: 128, 64, 32, 16, ..., 1
|
209
|
-
int offset = DEGREE;
|
210
|
-
for (int step = 1; step < DEGREE; step <<= 1) {
|
211
|
-
offset >>= 1;
|
212
|
-
int k = 0;
|
213
|
-
for (int i = 0; i < step; i++) {
|
214
|
-
assert(k == 2 * offset * i);
|
215
|
-
const uint32_t step_root = kNTTRootsMontgomery[step + i];
|
216
|
-
for (int j = k; j < k + offset; j++) {
|
217
|
-
uint32_t even = s->c[j];
|
218
|
-
// |reduce_montgomery| works on values up to kPrime*R and R > 2*kPrime.
|
219
|
-
// |step_root| < kPrime because it's static data. |s->c[...]| is <
|
220
|
-
// kPrime by the invariants of that struct.
|
221
|
-
uint32_t odd =
|
222
|
-
reduce_montgomery((uint64_t)step_root * (uint64_t)s->c[j + offset]);
|
223
|
-
s->c[j] = reduce_once(odd + even);
|
224
|
-
s->c[j + offset] = mod_sub(even, odd);
|
225
|
-
}
|
226
|
-
k += 2 * offset;
|
227
|
-
}
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
// In place inverse number theoretic transform of a given scalar.
|
232
|
-
//
|
233
|
-
// FIPS 204, Algorithm 42 (`NTT^-1`).
|
234
|
-
static void scalar_inverse_ntt(scalar *s) {
|
235
|
-
// Step: 128, 64, 32, 16, ..., 1
|
236
|
-
// Offset: 1, 2, 4, 8, ..., 128
|
237
|
-
int step = DEGREE;
|
238
|
-
for (int offset = 1; offset < DEGREE; offset <<= 1) {
|
239
|
-
step >>= 1;
|
240
|
-
int k = 0;
|
241
|
-
for (int i = 0; i < step; i++) {
|
242
|
-
assert(k == 2 * offset * i);
|
243
|
-
const uint32_t step_root =
|
244
|
-
kPrime - kNTTRootsMontgomery[step + (step - 1 - i)];
|
245
|
-
for (int j = k; j < k + offset; j++) {
|
246
|
-
uint32_t even = s->c[j];
|
247
|
-
uint32_t odd = s->c[j + offset];
|
248
|
-
s->c[j] = reduce_once(odd + even);
|
249
|
-
|
250
|
-
// |reduce_montgomery| works on values up to kPrime*R and R > 2*kPrime.
|
251
|
-
// kPrime + even < 2*kPrime because |even| < kPrime, by the invariants
|
252
|
-
// of that structure. Thus kPrime + even - odd < 2*kPrime because odd >=
|
253
|
-
// 0, because it's unsigned and less than kPrime. Lastly step_root <
|
254
|
-
// kPrime, because |kNTTRootsMontgomery| is static data.
|
255
|
-
s->c[j + offset] = reduce_montgomery((uint64_t)step_root *
|
256
|
-
(uint64_t)(kPrime + even - odd));
|
257
|
-
}
|
258
|
-
k += 2 * offset;
|
259
|
-
}
|
260
|
-
}
|
261
|
-
for (int i = 0; i < DEGREE; i++) {
|
262
|
-
s->c[i] = reduce_montgomery((uint64_t)s->c[i] *
|
263
|
-
(uint64_t)kInverseDegreeMontgomery);
|
264
|
-
}
|
265
|
-
}
|
266
|
-
|
267
|
-
static void vectork_zero(vectork *out) { OPENSSL_memset(out, 0, sizeof(*out)); }
|
268
|
-
|
269
|
-
static void vectork_add(vectork *out, const vectork *lhs, const vectork *rhs) {
|
270
|
-
for (int i = 0; i < K; i++) {
|
271
|
-
scalar_add(&out->v[i], &lhs->v[i], &rhs->v[i]);
|
272
|
-
}
|
273
|
-
}
|
274
|
-
|
275
|
-
static void vectork_sub(vectork *out, const vectork *lhs, const vectork *rhs) {
|
276
|
-
for (int i = 0; i < K; i++) {
|
277
|
-
scalar_sub(&out->v[i], &lhs->v[i], &rhs->v[i]);
|
278
|
-
}
|
279
|
-
}
|
280
|
-
|
281
|
-
static void vectork_mult_scalar(vectork *out, const vectork *lhs,
|
282
|
-
const scalar *rhs) {
|
283
|
-
for (int i = 0; i < K; i++) {
|
284
|
-
scalar_mult(&out->v[i], &lhs->v[i], rhs);
|
285
|
-
}
|
286
|
-
}
|
287
|
-
|
288
|
-
static void vectork_ntt(vectork *a) {
|
289
|
-
for (int i = 0; i < K; i++) {
|
290
|
-
scalar_ntt(&a->v[i]);
|
291
|
-
}
|
292
|
-
}
|
293
|
-
|
294
|
-
static void vectork_inverse_ntt(vectork *a) {
|
295
|
-
for (int i = 0; i < K; i++) {
|
296
|
-
scalar_inverse_ntt(&a->v[i]);
|
297
|
-
}
|
298
|
-
}
|
299
|
-
|
300
|
-
static void vectorl_add(vectorl *out, const vectorl *lhs, const vectorl *rhs) {
|
301
|
-
for (int i = 0; i < L; i++) {
|
302
|
-
scalar_add(&out->v[i], &lhs->v[i], &rhs->v[i]);
|
303
|
-
}
|
304
|
-
}
|
305
|
-
|
306
|
-
static void vectorl_mult_scalar(vectorl *out, const vectorl *lhs,
|
307
|
-
const scalar *rhs) {
|
308
|
-
for (int i = 0; i < L; i++) {
|
309
|
-
scalar_mult(&out->v[i], &lhs->v[i], rhs);
|
310
|
-
}
|
311
|
-
}
|
312
|
-
|
313
|
-
static void vectorl_ntt(vectorl *a) {
|
314
|
-
for (int i = 0; i < L; i++) {
|
315
|
-
scalar_ntt(&a->v[i]);
|
316
|
-
}
|
317
|
-
}
|
318
|
-
|
319
|
-
static void vectorl_inverse_ntt(vectorl *a) {
|
320
|
-
for (int i = 0; i < L; i++) {
|
321
|
-
scalar_inverse_ntt(&a->v[i]);
|
322
|
-
}
|
323
|
-
}
|
324
|
-
|
325
|
-
static void matrix_mult(vectork *out, const matrix *m, const vectorl *a) {
|
326
|
-
vectork_zero(out);
|
327
|
-
for (int i = 0; i < K; i++) {
|
328
|
-
for (int j = 0; j < L; j++) {
|
329
|
-
scalar product;
|
330
|
-
scalar_mult(&product, &m->v[i][j], &a->v[j]);
|
331
|
-
scalar_add(&out->v[i], &out->v[i], &product);
|
332
|
-
}
|
333
|
-
}
|
334
|
-
}
|
335
|
-
|
336
|
-
/* Rounding & hints */
|
337
|
-
|
338
|
-
// FIPS 204, Algorithm 35 (`Power2Round`).
|
339
|
-
static void power2_round(uint32_t *r1, uint32_t *r0, uint32_t r) {
|
340
|
-
*r1 = r >> kDroppedBits;
|
341
|
-
*r0 = r - (*r1 << kDroppedBits);
|
342
|
-
|
343
|
-
uint32_t r0_adjusted = mod_sub(*r0, 1 << kDroppedBits);
|
344
|
-
uint32_t r1_adjusted = *r1 + 1;
|
345
|
-
|
346
|
-
// Mask is set iff r0 > 2^(dropped_bits - 1).
|
347
|
-
crypto_word_t mask =
|
348
|
-
constant_time_lt_w((uint32_t)(1 << (kDroppedBits - 1)), *r0);
|
349
|
-
// r0 = mask ? r0_adjusted : r0
|
350
|
-
*r0 = constant_time_select_int(mask, r0_adjusted, *r0);
|
351
|
-
// r1 = mask ? r1_adjusted : r1
|
352
|
-
*r1 = constant_time_select_int(mask, r1_adjusted, *r1);
|
353
|
-
}
|
354
|
-
|
355
|
-
// Scale back previously rounded value.
|
356
|
-
static void scale_power2_round(uint32_t *out, uint32_t r1) {
|
357
|
-
// Pre-condition: 0 <= r1 <= 2^10 - 1
|
358
|
-
assert(r1 < (1u << 10));
|
359
|
-
|
360
|
-
*out = r1 << kDroppedBits;
|
361
|
-
|
362
|
-
// Post-condition: 0 <= out <= 2^23 - 2^13 = kPrime - 1
|
363
|
-
assert(*out < kPrime);
|
364
|
-
}
|
365
|
-
|
366
|
-
// FIPS 204, Algorithm 37 (`HighBits`).
|
367
|
-
static uint32_t high_bits(uint32_t x) {
|
368
|
-
// Reference description (given 0 <= x < q):
|
369
|
-
//
|
370
|
-
// ```
|
371
|
-
// int32_t r0 = x mod+- (2 * kGamma2);
|
372
|
-
// if (x - r0 == q - 1) {
|
373
|
-
// return 0;
|
374
|
-
// } else {
|
375
|
-
// return (x - r0) / (2 * kGamma2);
|
376
|
-
// }
|
377
|
-
// ```
|
378
|
-
//
|
379
|
-
// Below is the formula taken from the reference implementation.
|
380
|
-
//
|
381
|
-
// Here, kGamma2 == 2^18 - 2^8
|
382
|
-
// This returns ((ceil(x / 2^7) * (2^10 + 1) + 2^21) / 2^22) mod 2^4
|
383
|
-
uint32_t r1 = (x + 127) >> 7;
|
384
|
-
r1 = (r1 * 1025 + (1 << 21)) >> 22;
|
385
|
-
r1 &= 15;
|
386
|
-
return r1;
|
387
|
-
}
|
388
|
-
|
389
|
-
// FIPS 204, Algorithm 36 (`Decompose`).
|
390
|
-
static void decompose(uint32_t *r1, int32_t *r0, uint32_t r) {
|
391
|
-
*r1 = high_bits(r);
|
392
|
-
|
393
|
-
*r0 = r;
|
394
|
-
*r0 -= *r1 * 2 * (int32_t)kGamma2;
|
395
|
-
*r0 -= (((int32_t)kHalfPrime - *r0) >> 31) & (int32_t)kPrime;
|
396
|
-
}
|
397
|
-
|
398
|
-
// FIPS 204, Algorithm 38 (`LowBits`).
|
399
|
-
static int32_t low_bits(uint32_t x) {
|
400
|
-
uint32_t r1;
|
401
|
-
int32_t r0;
|
402
|
-
decompose(&r1, &r0, x);
|
403
|
-
return r0;
|
404
|
-
}
|
405
|
-
|
406
|
-
// FIPS 204, Algorithm 39 (`MakeHint`).
|
407
|
-
//
|
408
|
-
// In the spec this takes two arguments, z and r, and is called with
|
409
|
-
// z = -ct0
|
410
|
-
// r = w - cs2 + ct0
|
411
|
-
//
|
412
|
-
// It then computes HighBits (algorithm 37) of z and z+r. But z+r is just w -
|
413
|
-
// cs2, so this takes three arguments and saves an addition.
|
414
|
-
static int32_t make_hint(uint32_t ct0, uint32_t cs2, uint32_t w) {
|
415
|
-
uint32_t r_plus_z = mod_sub(w, cs2);
|
416
|
-
uint32_t r = reduce_once(r_plus_z + ct0);
|
417
|
-
return high_bits(r) != high_bits(r_plus_z);
|
418
|
-
}
|
419
|
-
|
420
|
-
// FIPS 204, Algorithm 40 (`UseHint`).
|
421
|
-
static uint32_t use_hint_vartime(uint32_t h, uint32_t r) {
|
422
|
-
uint32_t r1;
|
423
|
-
int32_t r0;
|
424
|
-
decompose(&r1, &r0, r);
|
425
|
-
|
426
|
-
if (h) {
|
427
|
-
if (r0 > 0) {
|
428
|
-
// m = 16, thus |mod m| in the spec turns into |& 15|.
|
429
|
-
return (r1 + 1) & 15;
|
430
|
-
} else {
|
431
|
-
return (r1 - 1) & 15;
|
432
|
-
}
|
433
|
-
}
|
434
|
-
return r1;
|
435
|
-
}
|
436
|
-
|
437
|
-
static void scalar_power2_round(scalar *s1, scalar *s0, const scalar *s) {
|
438
|
-
for (int i = 0; i < DEGREE; i++) {
|
439
|
-
power2_round(&s1->c[i], &s0->c[i], s->c[i]);
|
440
|
-
}
|
441
|
-
}
|
442
|
-
|
443
|
-
static void scalar_scale_power2_round(scalar *out, const scalar *in) {
|
444
|
-
for (int i = 0; i < DEGREE; i++) {
|
445
|
-
scale_power2_round(&out->c[i], in->c[i]);
|
446
|
-
}
|
447
|
-
}
|
448
|
-
|
449
|
-
static void scalar_high_bits(scalar *out, const scalar *in) {
|
450
|
-
for (int i = 0; i < DEGREE; i++) {
|
451
|
-
out->c[i] = high_bits(in->c[i]);
|
452
|
-
}
|
453
|
-
}
|
454
|
-
|
455
|
-
static void scalar_low_bits(scalar *out, const scalar *in) {
|
456
|
-
for (int i = 0; i < DEGREE; i++) {
|
457
|
-
out->c[i] = low_bits(in->c[i]);
|
458
|
-
}
|
459
|
-
}
|
460
|
-
|
461
|
-
static void scalar_max(uint32_t *max, const scalar *s) {
|
462
|
-
for (int i = 0; i < DEGREE; i++) {
|
463
|
-
uint32_t abs = abs_mod_prime(s->c[i]);
|
464
|
-
*max = maximum(*max, abs);
|
465
|
-
}
|
466
|
-
}
|
467
|
-
|
468
|
-
static void scalar_max_signed(uint32_t *max, const scalar *s) {
|
469
|
-
for (int i = 0; i < DEGREE; i++) {
|
470
|
-
uint32_t abs = abs_signed(s->c[i]);
|
471
|
-
*max = maximum(*max, abs);
|
472
|
-
}
|
473
|
-
}
|
474
|
-
|
475
|
-
static void scalar_make_hint(scalar *out, const scalar *ct0, const scalar *cs2,
|
476
|
-
const scalar *w) {
|
477
|
-
for (int i = 0; i < DEGREE; i++) {
|
478
|
-
out->c[i] = make_hint(ct0->c[i], cs2->c[i], w->c[i]);
|
479
|
-
}
|
480
|
-
}
|
481
|
-
|
482
|
-
static void scalar_use_hint_vartime(scalar *out, const scalar *h,
|
483
|
-
const scalar *r) {
|
484
|
-
for (int i = 0; i < DEGREE; i++) {
|
485
|
-
out->c[i] = use_hint_vartime(h->c[i], r->c[i]);
|
486
|
-
}
|
487
|
-
}
|
488
|
-
|
489
|
-
static void vectork_power2_round(vectork *t1, vectork *t0, const vectork *t) {
|
490
|
-
for (int i = 0; i < K; i++) {
|
491
|
-
scalar_power2_round(&t1->v[i], &t0->v[i], &t->v[i]);
|
492
|
-
}
|
493
|
-
}
|
494
|
-
|
495
|
-
static void vectork_scale_power2_round(vectork *out, const vectork *in) {
|
496
|
-
for (int i = 0; i < K; i++) {
|
497
|
-
scalar_scale_power2_round(&out->v[i], &in->v[i]);
|
498
|
-
}
|
499
|
-
}
|
500
|
-
|
501
|
-
static void vectork_high_bits(vectork *out, const vectork *in) {
|
502
|
-
for (int i = 0; i < K; i++) {
|
503
|
-
scalar_high_bits(&out->v[i], &in->v[i]);
|
504
|
-
}
|
505
|
-
}
|
506
|
-
|
507
|
-
static void vectork_low_bits(vectork *out, const vectork *in) {
|
508
|
-
for (int i = 0; i < K; i++) {
|
509
|
-
scalar_low_bits(&out->v[i], &in->v[i]);
|
510
|
-
}
|
511
|
-
}
|
512
|
-
|
513
|
-
static uint32_t vectork_max(const vectork *a) {
|
514
|
-
uint32_t max = 0;
|
515
|
-
for (int i = 0; i < K; i++) {
|
516
|
-
scalar_max(&max, &a->v[i]);
|
517
|
-
}
|
518
|
-
return max;
|
519
|
-
}
|
520
|
-
|
521
|
-
static uint32_t vectork_max_signed(const vectork *a) {
|
522
|
-
uint32_t max = 0;
|
523
|
-
for (int i = 0; i < K; i++) {
|
524
|
-
scalar_max_signed(&max, &a->v[i]);
|
525
|
-
}
|
526
|
-
return max;
|
527
|
-
}
|
528
|
-
|
529
|
-
// The input vector contains only zeroes and ones.
|
530
|
-
static size_t vectork_count_ones(const vectork *a) {
|
531
|
-
size_t count = 0;
|
532
|
-
for (int i = 0; i < K; i++) {
|
533
|
-
for (int j = 0; j < DEGREE; j++) {
|
534
|
-
count += a->v[i].c[j];
|
535
|
-
}
|
536
|
-
}
|
537
|
-
return count;
|
538
|
-
}
|
539
|
-
|
540
|
-
static void vectork_make_hint(vectork *out, const vectork *ct0,
|
541
|
-
const vectork *cs2, const vectork *w) {
|
542
|
-
for (int i = 0; i < K; i++) {
|
543
|
-
scalar_make_hint(&out->v[i], &ct0->v[i], &cs2->v[i], &w->v[i]);
|
544
|
-
}
|
545
|
-
}
|
546
|
-
|
547
|
-
static void vectork_use_hint_vartime(vectork *out, const vectork *h,
|
548
|
-
const vectork *r) {
|
549
|
-
for (int i = 0; i < K; i++) {
|
550
|
-
scalar_use_hint_vartime(&out->v[i], &h->v[i], &r->v[i]);
|
551
|
-
}
|
552
|
-
}
|
553
|
-
|
554
|
-
static uint32_t vectorl_max(const vectorl *a) {
|
555
|
-
uint32_t max = 0;
|
556
|
-
for (int i = 0; i < L; i++) {
|
557
|
-
scalar_max(&max, &a->v[i]);
|
558
|
-
}
|
559
|
-
return max;
|
560
|
-
}
|
561
|
-
|
562
|
-
/* Bit packing */
|
563
|
-
|
564
|
-
// FIPS 204, Algorithm 16 (`SimpleBitPack`). Specialized to bitlen(b) = 4.
|
565
|
-
static void scalar_encode_4(uint8_t out[128], const scalar *s) {
|
566
|
-
// Every two elements lands on a byte boundary.
|
567
|
-
static_assert(DEGREE % 2 == 0, "DEGREE must be a multiple of 2");
|
568
|
-
for (int i = 0; i < DEGREE / 2; i++) {
|
569
|
-
uint32_t a = s->c[2 * i];
|
570
|
-
uint32_t b = s->c[2 * i + 1];
|
571
|
-
declassify_assert(a < 16);
|
572
|
-
declassify_assert(b < 16);
|
573
|
-
out[i] = a | (b << 4);
|
574
|
-
}
|
575
|
-
}
|
576
|
-
|
577
|
-
// FIPS 204, Algorithm 16 (`SimpleBitPack`). Specialized to bitlen(b) = 10.
|
578
|
-
static void scalar_encode_10(uint8_t out[320], const scalar *s) {
|
579
|
-
// Every four elements lands on a byte boundary.
|
580
|
-
static_assert(DEGREE % 4 == 0, "DEGREE must be a multiple of 4");
|
581
|
-
for (int i = 0; i < DEGREE / 4; i++) {
|
582
|
-
uint32_t a = s->c[4 * i];
|
583
|
-
uint32_t b = s->c[4 * i + 1];
|
584
|
-
uint32_t c = s->c[4 * i + 2];
|
585
|
-
uint32_t d = s->c[4 * i + 3];
|
586
|
-
declassify_assert(a < 1024);
|
587
|
-
declassify_assert(b < 1024);
|
588
|
-
declassify_assert(c < 1024);
|
589
|
-
declassify_assert(d < 1024);
|
590
|
-
out[5 * i] = (uint8_t)a;
|
591
|
-
out[5 * i + 1] = (uint8_t)((a >> 8) | (b << 2));
|
592
|
-
out[5 * i + 2] = (uint8_t)((b >> 6) | (c << 4));
|
593
|
-
out[5 * i + 3] = (uint8_t)((c >> 4) | (d << 6));
|
594
|
-
out[5 * i + 4] = (uint8_t)(d >> 2);
|
595
|
-
}
|
596
|
-
}
|
597
|
-
|
598
|
-
// FIPS 204, Algorithm 17 (`BitPack`). Specialized to bitlen(b) = 4 and b =
|
599
|
-
// 2^19.
|
600
|
-
static void scalar_encode_signed_4_eta(uint8_t out[128], const scalar *s) {
|
601
|
-
// Every two elements lands on a byte boundary.
|
602
|
-
static_assert(DEGREE % 2 == 0, "DEGREE must be a multiple of 2");
|
603
|
-
for (int i = 0; i < DEGREE / 2; i++) {
|
604
|
-
uint32_t a = mod_sub(ETA, s->c[2 * i]);
|
605
|
-
uint32_t b = mod_sub(ETA, s->c[2 * i + 1]);
|
606
|
-
declassify_assert(a < 16);
|
607
|
-
declassify_assert(b < 16);
|
608
|
-
out[i] = a | (b << 4);
|
609
|
-
}
|
610
|
-
}
|
611
|
-
|
612
|
-
// FIPS 204, Algorithm 17 (`BitPack`). Specialized to bitlen(b) = 13 and b =
|
613
|
-
// 2^12.
|
614
|
-
static void scalar_encode_signed_13_12(uint8_t out[416], const scalar *s) {
|
615
|
-
static const uint32_t kMax = 1u << 12;
|
616
|
-
// Every two elements lands on a byte boundary.
|
617
|
-
static_assert(DEGREE % 8 == 0, "DEGREE must be a multiple of 8");
|
618
|
-
for (int i = 0; i < DEGREE / 8; i++) {
|
619
|
-
uint32_t a = mod_sub(kMax, s->c[8 * i]);
|
620
|
-
uint32_t b = mod_sub(kMax, s->c[8 * i + 1]);
|
621
|
-
uint32_t c = mod_sub(kMax, s->c[8 * i + 2]);
|
622
|
-
uint32_t d = mod_sub(kMax, s->c[8 * i + 3]);
|
623
|
-
uint32_t e = mod_sub(kMax, s->c[8 * i + 4]);
|
624
|
-
uint32_t f = mod_sub(kMax, s->c[8 * i + 5]);
|
625
|
-
uint32_t g = mod_sub(kMax, s->c[8 * i + 6]);
|
626
|
-
uint32_t h = mod_sub(kMax, s->c[8 * i + 7]);
|
627
|
-
declassify_assert(a < (1u << 13));
|
628
|
-
declassify_assert(b < (1u << 13));
|
629
|
-
declassify_assert(c < (1u << 13));
|
630
|
-
declassify_assert(d < (1u << 13));
|
631
|
-
declassify_assert(e < (1u << 13));
|
632
|
-
declassify_assert(f < (1u << 13));
|
633
|
-
declassify_assert(g < (1u << 13));
|
634
|
-
declassify_assert(h < (1u << 13));
|
635
|
-
a |= b << 13;
|
636
|
-
a |= c << 26;
|
637
|
-
c >>= 6;
|
638
|
-
c |= d << 7;
|
639
|
-
c |= e << 20;
|
640
|
-
e >>= 12;
|
641
|
-
e |= f << 1;
|
642
|
-
e |= g << 14;
|
643
|
-
e |= h << 27;
|
644
|
-
h >>= 5;
|
645
|
-
OPENSSL_memcpy(&out[13 * i], &a, sizeof(a));
|
646
|
-
OPENSSL_memcpy(&out[13 * i + 4], &c, sizeof(c));
|
647
|
-
OPENSSL_memcpy(&out[13 * i + 8], &e, sizeof(e));
|
648
|
-
OPENSSL_memcpy(&out[13 * i + 12], &h, 1);
|
649
|
-
}
|
650
|
-
}
|
651
|
-
|
652
|
-
// FIPS 204, Algorithm 17 (`BitPack`). Specialized to bitlen(b) = 20 and b =
|
653
|
-
// 2^19.
|
654
|
-
static void scalar_encode_signed_20_19(uint8_t out[640], const scalar *s) {
|
655
|
-
static const uint32_t kMax = 1u << 19;
|
656
|
-
// Every two elements lands on a byte boundary.
|
657
|
-
static_assert(DEGREE % 4 == 0, "DEGREE must be a multiple of 4");
|
658
|
-
for (int i = 0; i < DEGREE / 4; i++) {
|
659
|
-
uint32_t a = mod_sub(kMax, s->c[4 * i]);
|
660
|
-
uint32_t b = mod_sub(kMax, s->c[4 * i + 1]);
|
661
|
-
uint32_t c = mod_sub(kMax, s->c[4 * i + 2]);
|
662
|
-
uint32_t d = mod_sub(kMax, s->c[4 * i + 3]);
|
663
|
-
declassify_assert(a < (1u << 20));
|
664
|
-
declassify_assert(b < (1u << 20));
|
665
|
-
declassify_assert(c < (1u << 20));
|
666
|
-
declassify_assert(d < (1u << 20));
|
667
|
-
a |= b << 20;
|
668
|
-
b >>= 12;
|
669
|
-
b |= c << 8;
|
670
|
-
b |= d << 28;
|
671
|
-
d >>= 4;
|
672
|
-
OPENSSL_memcpy(&out[10 * i], &a, sizeof(a));
|
673
|
-
OPENSSL_memcpy(&out[10 * i + 4], &b, sizeof(b));
|
674
|
-
OPENSSL_memcpy(&out[10 * i + 8], &d, 2);
|
675
|
-
}
|
676
|
-
}
|
677
|
-
|
678
|
-
// FIPS 204, Algorithm 17 (`BitPack`).
|
679
|
-
static void scalar_encode_signed(uint8_t *out, const scalar *s, int bits,
|
680
|
-
uint32_t max) {
|
681
|
-
if (bits == 4) {
|
682
|
-
assert(max == ETA);
|
683
|
-
scalar_encode_signed_4_eta(out, s);
|
684
|
-
} else if (bits == 20) {
|
685
|
-
assert(max == 1u << 19);
|
686
|
-
scalar_encode_signed_20_19(out, s);
|
687
|
-
} else {
|
688
|
-
assert(bits == 13);
|
689
|
-
assert(max == 1u << 12);
|
690
|
-
scalar_encode_signed_13_12(out, s);
|
691
|
-
}
|
692
|
-
}
|
693
|
-
|
694
|
-
// FIPS 204, Algorithm 18 (`SimpleBitUnpack`). Specialized for bitlen(b) == 10.
|
695
|
-
static void scalar_decode_10(scalar *out, const uint8_t in[320]) {
|
696
|
-
uint32_t v;
|
697
|
-
static_assert(DEGREE % 4 == 0, "DEGREE must be a multiple of 4");
|
698
|
-
for (int i = 0; i < DEGREE / 4; i++) {
|
699
|
-
OPENSSL_memcpy(&v, &in[5 * i], sizeof(v));
|
700
|
-
out->c[4 * i] = v & 0x3ff;
|
701
|
-
out->c[4 * i + 1] = (v >> 10) & 0x3ff;
|
702
|
-
out->c[4 * i + 2] = (v >> 20) & 0x3ff;
|
703
|
-
out->c[4 * i + 3] = (v >> 30) | (((uint32_t)in[5 * i + 4]) << 2);
|
704
|
-
}
|
705
|
-
}
|
706
|
-
|
707
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`). Specialized to bitlen(a+b) = 4 and b =
|
708
|
-
// eta.
|
709
|
-
static int scalar_decode_signed_4_eta(scalar *out, const uint8_t in[128]) {
|
710
|
-
uint32_t v;
|
711
|
-
static_assert(DEGREE % 8 == 0, "DEGREE must be a multiple of 8");
|
712
|
-
for (int i = 0; i < DEGREE / 8; i++) {
|
713
|
-
OPENSSL_memcpy(&v, &in[4 * i], sizeof(v));
|
714
|
-
static_assert(ETA == 4, "ETA must be 4");
|
715
|
-
// None of the nibbles may be >= 9. So if the MSB of any nibble is set, none
|
716
|
-
// of the other bits may be set. First, select all the MSBs.
|
717
|
-
const uint32_t msbs = v & 0x88888888u;
|
718
|
-
// For each nibble where the MSB is set, form a mask of all the other bits.
|
719
|
-
const uint32_t mask = (msbs >> 1) | (msbs >> 2) | (msbs >> 3);
|
720
|
-
// A nibble is only out of range in the case of invalid input, in which case
|
721
|
-
// it is okay to leak the value.
|
722
|
-
if (constant_time_declassify_int((mask & v) != 0)) {
|
723
|
-
return 0;
|
724
|
-
}
|
725
|
-
|
726
|
-
out->c[i * 8] = mod_sub(ETA, v & 15);
|
727
|
-
out->c[i * 8 + 1] = mod_sub(ETA, (v >> 4) & 15);
|
728
|
-
out->c[i * 8 + 2] = mod_sub(ETA, (v >> 8) & 15);
|
729
|
-
out->c[i * 8 + 3] = mod_sub(ETA, (v >> 12) & 15);
|
730
|
-
out->c[i * 8 + 4] = mod_sub(ETA, (v >> 16) & 15);
|
731
|
-
out->c[i * 8 + 5] = mod_sub(ETA, (v >> 20) & 15);
|
732
|
-
out->c[i * 8 + 6] = mod_sub(ETA, (v >> 24) & 15);
|
733
|
-
out->c[i * 8 + 7] = mod_sub(ETA, v >> 28);
|
734
|
-
}
|
735
|
-
return 1;
|
736
|
-
}
|
737
|
-
|
738
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`). Specialized to bitlen(a+b) = 13 and b =
|
739
|
-
// 2^12.
|
740
|
-
static void scalar_decode_signed_13_12(scalar *out, const uint8_t in[416]) {
|
741
|
-
static const uint32_t kMax = 1u << 12;
|
742
|
-
static const uint32_t k13Bits = (1u << 13) - 1;
|
743
|
-
static const uint32_t k7Bits = (1u << 7) - 1;
|
744
|
-
|
745
|
-
uint32_t a, b, c;
|
746
|
-
uint8_t d;
|
747
|
-
static_assert(DEGREE % 8 == 0, "DEGREE must be a multiple of 8");
|
748
|
-
for (int i = 0; i < DEGREE / 8; i++) {
|
749
|
-
OPENSSL_memcpy(&a, &in[13 * i], sizeof(a));
|
750
|
-
OPENSSL_memcpy(&b, &in[13 * i + 4], sizeof(b));
|
751
|
-
OPENSSL_memcpy(&c, &in[13 * i + 8], sizeof(c));
|
752
|
-
d = in[13 * i + 12];
|
753
|
-
|
754
|
-
// It's not possible for a 13-bit number to be out of range when the max is
|
755
|
-
// 2^12.
|
756
|
-
out->c[i * 8] = mod_sub(kMax, a & k13Bits);
|
757
|
-
out->c[i * 8 + 1] = mod_sub(kMax, (a >> 13) & k13Bits);
|
758
|
-
out->c[i * 8 + 2] = mod_sub(kMax, (a >> 26) | ((b & k7Bits) << 6));
|
759
|
-
out->c[i * 8 + 3] = mod_sub(kMax, (b >> 7) & k13Bits);
|
760
|
-
out->c[i * 8 + 4] = mod_sub(kMax, (b >> 20) | ((c & 1) << 12));
|
761
|
-
out->c[i * 8 + 5] = mod_sub(kMax, (c >> 1) & k13Bits);
|
762
|
-
out->c[i * 8 + 6] = mod_sub(kMax, (c >> 14) & k13Bits);
|
763
|
-
out->c[i * 8 + 7] = mod_sub(kMax, (c >> 27) | ((uint32_t)d) << 5);
|
764
|
-
}
|
765
|
-
}
|
766
|
-
|
767
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`). Specialized to bitlen(a+b) = 20 and b =
|
768
|
-
// 2^19.
|
769
|
-
static void scalar_decode_signed_20_19(scalar *out, const uint8_t in[640]) {
|
770
|
-
static const uint32_t kMax = 1u << 19;
|
771
|
-
static const uint32_t k20Bits = (1u << 20) - 1;
|
772
|
-
|
773
|
-
uint32_t a, b;
|
774
|
-
uint16_t c;
|
775
|
-
static_assert(DEGREE % 4 == 0, "DEGREE must be a multiple of 4");
|
776
|
-
for (int i = 0; i < DEGREE / 4; i++) {
|
777
|
-
OPENSSL_memcpy(&a, &in[10 * i], sizeof(a));
|
778
|
-
OPENSSL_memcpy(&b, &in[10 * i + 4], sizeof(b));
|
779
|
-
OPENSSL_memcpy(&c, &in[10 * i + 8], sizeof(c));
|
780
|
-
|
781
|
-
// It's not possible for a 20-bit number to be out of range when the max is
|
782
|
-
// 2^19.
|
783
|
-
out->c[i * 4] = mod_sub(kMax, a & k20Bits);
|
784
|
-
out->c[i * 4 + 1] = mod_sub(kMax, (a >> 20) | ((b & 0xff) << 12));
|
785
|
-
out->c[i * 4 + 2] = mod_sub(kMax, (b >> 8) & k20Bits);
|
786
|
-
out->c[i * 4 + 3] = mod_sub(kMax, (b >> 28) | ((uint32_t)c) << 4);
|
787
|
-
}
|
788
|
-
}
|
789
|
-
|
790
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`).
|
791
|
-
static int scalar_decode_signed(scalar *out, const uint8_t *in, int bits,
|
792
|
-
uint32_t max) {
|
793
|
-
if (bits == 4) {
|
794
|
-
assert(max == ETA);
|
795
|
-
return scalar_decode_signed_4_eta(out, in);
|
796
|
-
} else if (bits == 13) {
|
797
|
-
assert(max == (1u << 12));
|
798
|
-
scalar_decode_signed_13_12(out, in);
|
799
|
-
return 1;
|
800
|
-
} else if (bits == 20) {
|
801
|
-
assert(max == (1u << 19));
|
802
|
-
scalar_decode_signed_20_19(out, in);
|
803
|
-
return 1;
|
804
|
-
} else {
|
805
|
-
abort();
|
806
|
-
}
|
807
|
-
}
|
808
|
-
|
809
|
-
/* Expansion functions */
|
810
|
-
|
811
|
-
// FIPS 204, Algorithm 30 (`RejNTTPoly`).
|
812
|
-
//
|
813
|
-
// Rejection samples a Keccak stream to get uniformly distributed elements. This
|
814
|
-
// is used for matrix expansion and only operates on public inputs.
|
815
|
-
static void scalar_from_keccak_vartime(
|
816
|
-
scalar *out, const uint8_t derived_seed[RHO_BYTES + 2]) {
|
817
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
818
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake128);
|
819
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, derived_seed, RHO_BYTES + 2);
|
820
|
-
assert(keccak_ctx.squeeze_offset == 0);
|
821
|
-
assert(keccak_ctx.rate_bytes == 168);
|
822
|
-
static_assert(168 % 3 == 0, "block and coefficient boundaries do not align");
|
823
|
-
|
824
|
-
int done = 0;
|
825
|
-
while (done < DEGREE) {
|
826
|
-
uint8_t block[168];
|
827
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
828
|
-
for (size_t i = 0; i < sizeof(block) && done < DEGREE; i += 3) {
|
829
|
-
// FIPS 204, Algorithm 14 (`CoeffFromThreeBytes`).
|
830
|
-
uint32_t value = (uint32_t)block[i] | ((uint32_t)block[i + 1] << 8) |
|
831
|
-
(((uint32_t)block[i + 2] & 0x7f) << 16);
|
832
|
-
if (value < kPrime) {
|
833
|
-
out->c[done++] = value;
|
834
|
-
}
|
835
|
-
}
|
836
|
-
}
|
837
|
-
}
|
838
|
-
|
839
|
-
// FIPS 204, Algorithm 31 (`RejBoundedPoly`).
|
840
|
-
static void scalar_uniform_eta_4(scalar *out,
|
841
|
-
const uint8_t derived_seed[SIGMA_BYTES + 2]) {
|
842
|
-
static_assert(ETA == 4, "This implementation is specialized for ETA == 4");
|
843
|
-
|
844
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
845
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
846
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, derived_seed, SIGMA_BYTES + 2);
|
847
|
-
assert(keccak_ctx.squeeze_offset == 0);
|
848
|
-
assert(keccak_ctx.rate_bytes == 136);
|
849
|
-
|
850
|
-
int done = 0;
|
851
|
-
while (done < DEGREE) {
|
852
|
-
uint8_t block[136];
|
853
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
854
|
-
for (size_t i = 0; i < sizeof(block) && done < DEGREE; ++i) {
|
855
|
-
uint32_t t0 = block[i] & 0x0F;
|
856
|
-
uint32_t t1 = block[i] >> 4;
|
857
|
-
// FIPS 204, Algorithm 15 (`CoefFromHalfByte`). Although both the input
|
858
|
-
// and output here are secret, it is OK to leak when we rejected a byte.
|
859
|
-
// Individual bytes of the SHAKE-256 stream are (indistiguishable from)
|
860
|
-
// independent of each other and the original seed, so leaking information
|
861
|
-
// about the rejected bytes does not reveal the input or output.
|
862
|
-
if (constant_time_declassify_int(t0 < 9)) {
|
863
|
-
out->c[done++] = mod_sub(ETA, t0);
|
864
|
-
}
|
865
|
-
if (done < DEGREE && constant_time_declassify_int(t1 < 9)) {
|
866
|
-
out->c[done++] = mod_sub(ETA, t1);
|
867
|
-
}
|
868
|
-
}
|
869
|
-
}
|
870
|
-
}
|
871
|
-
|
872
|
-
// FIPS 204, Algorithm 34 (`ExpandMask`), but just a single step.
|
873
|
-
static void scalar_sample_mask(
|
874
|
-
scalar *out, const uint8_t derived_seed[RHO_PRIME_BYTES + 2]) {
|
875
|
-
uint8_t buf[640];
|
876
|
-
BORINGSSL_keccak(buf, sizeof(buf), derived_seed, RHO_PRIME_BYTES + 2,
|
877
|
-
boringssl_shake256);
|
878
|
-
|
879
|
-
scalar_decode_signed_20_19(out, buf);
|
880
|
-
}
|
881
|
-
|
882
|
-
// FIPS 204, Algorithm 29 (`SampleInBall`).
|
883
|
-
static void scalar_sample_in_ball_vartime(scalar *out, const uint8_t *seed,
|
884
|
-
int len) {
|
885
|
-
assert(len == 2 * LAMBDA_BYTES);
|
886
|
-
|
887
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
888
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
889
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, seed, len);
|
890
|
-
assert(keccak_ctx.squeeze_offset == 0);
|
891
|
-
assert(keccak_ctx.rate_bytes == 136);
|
892
|
-
|
893
|
-
uint8_t block[136];
|
894
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
895
|
-
|
896
|
-
uint64_t signs = CRYPTO_load_u64_le(block);
|
897
|
-
int offset = 8;
|
898
|
-
// SampleInBall implements a Fisher–Yates shuffle, which unavoidably leaks
|
899
|
-
// where the zeros are by memory access pattern. Although this leak happens
|
900
|
-
// before bad signatures are rejected, this is safe. See
|
901
|
-
// https://boringssl-review.googlesource.com/c/boringssl/+/67747/comment/8d8f01ac_70af3f21/
|
902
|
-
CONSTTIME_DECLASSIFY(block + offset, sizeof(block) - offset);
|
903
|
-
|
904
|
-
OPENSSL_memset(out, 0, sizeof(*out));
|
905
|
-
for (size_t i = DEGREE - TAU; i < DEGREE; i++) {
|
906
|
-
size_t byte;
|
907
|
-
for (;;) {
|
908
|
-
if (offset == 136) {
|
909
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
910
|
-
// See above.
|
911
|
-
CONSTTIME_DECLASSIFY(block, sizeof(block));
|
912
|
-
offset = 0;
|
913
|
-
}
|
914
|
-
|
915
|
-
byte = block[offset++];
|
916
|
-
if (byte <= i) {
|
917
|
-
break;
|
918
|
-
}
|
919
|
-
}
|
920
|
-
|
921
|
-
out->c[i] = out->c[byte];
|
922
|
-
out->c[byte] = mod_sub(1, 2 * (signs & 1));
|
923
|
-
signs >>= 1;
|
924
|
-
}
|
925
|
-
}
|
926
|
-
|
927
|
-
// FIPS 204, Algorithm 32 (`ExpandA`).
|
928
|
-
static void matrix_expand(matrix *out, const uint8_t rho[RHO_BYTES]) {
|
929
|
-
static_assert(K <= 0x100, "K must fit in 8 bits");
|
930
|
-
static_assert(L <= 0x100, "L must fit in 8 bits");
|
931
|
-
|
932
|
-
uint8_t derived_seed[RHO_BYTES + 2];
|
933
|
-
OPENSSL_memcpy(derived_seed, rho, RHO_BYTES);
|
934
|
-
for (int i = 0; i < K; i++) {
|
935
|
-
for (int j = 0; j < L; j++) {
|
936
|
-
derived_seed[RHO_BYTES + 1] = (uint8_t)i;
|
937
|
-
derived_seed[RHO_BYTES] = (uint8_t)j;
|
938
|
-
scalar_from_keccak_vartime(&out->v[i][j], derived_seed);
|
939
|
-
}
|
940
|
-
}
|
941
|
-
}
|
942
|
-
|
943
|
-
// FIPS 204, Algorithm 33 (`ExpandS`).
|
944
|
-
static void vector_expand_short(vectorl *s1, vectork *s2,
|
945
|
-
const uint8_t sigma[SIGMA_BYTES]) {
|
946
|
-
static_assert(K <= 0x100, "K must fit in 8 bits");
|
947
|
-
static_assert(L <= 0x100, "L must fit in 8 bits");
|
948
|
-
static_assert(K + L <= 0x100, "K+L must fit in 8 bits");
|
949
|
-
|
950
|
-
uint8_t derived_seed[SIGMA_BYTES + 2];
|
951
|
-
OPENSSL_memcpy(derived_seed, sigma, SIGMA_BYTES);
|
952
|
-
derived_seed[SIGMA_BYTES] = 0;
|
953
|
-
derived_seed[SIGMA_BYTES + 1] = 0;
|
954
|
-
for (int i = 0; i < L; i++) {
|
955
|
-
scalar_uniform_eta_4(&s1->v[i], derived_seed);
|
956
|
-
++derived_seed[SIGMA_BYTES];
|
957
|
-
}
|
958
|
-
for (int i = 0; i < K; i++) {
|
959
|
-
scalar_uniform_eta_4(&s2->v[i], derived_seed);
|
960
|
-
++derived_seed[SIGMA_BYTES];
|
961
|
-
}
|
962
|
-
}
|
963
|
-
|
964
|
-
// FIPS 204, Algorithm 34 (`ExpandMask`).
|
965
|
-
static void vectorl_expand_mask(vectorl *out,
|
966
|
-
const uint8_t seed[RHO_PRIME_BYTES],
|
967
|
-
size_t kappa) {
|
968
|
-
assert(kappa + L <= 0x10000);
|
969
|
-
|
970
|
-
uint8_t derived_seed[RHO_PRIME_BYTES + 2];
|
971
|
-
OPENSSL_memcpy(derived_seed, seed, RHO_PRIME_BYTES);
|
972
|
-
for (int i = 0; i < L; i++) {
|
973
|
-
size_t index = kappa + i;
|
974
|
-
derived_seed[RHO_PRIME_BYTES] = index & 0xFF;
|
975
|
-
derived_seed[RHO_PRIME_BYTES + 1] = (index >> 8) & 0xFF;
|
976
|
-
scalar_sample_mask(&out->v[i], derived_seed);
|
977
|
-
}
|
978
|
-
}
|
979
|
-
|
980
|
-
/* Encoding */
|
981
|
-
|
982
|
-
// FIPS 204, Algorithm 16 (`SimpleBitPack`).
|
983
|
-
//
|
984
|
-
// Encodes an entire vector into 32*K*|bits| bytes. Note that since 256 (DEGREE)
|
985
|
-
// is divisible by 8, the individual vector entries will always fill a whole
|
986
|
-
// number of bytes, so we do not need to worry about bit packing here.
|
987
|
-
static void vectork_encode(uint8_t *out, const vectork *a, int bits) {
|
988
|
-
if (bits == 4) {
|
989
|
-
for (int i = 0; i < K; i++) {
|
990
|
-
scalar_encode_4(out + i * bits * DEGREE / 8, &a->v[i]);
|
991
|
-
}
|
992
|
-
} else {
|
993
|
-
assert(bits == 10);
|
994
|
-
for (int i = 0; i < K; i++) {
|
995
|
-
scalar_encode_10(out + i * bits * DEGREE / 8, &a->v[i]);
|
996
|
-
}
|
997
|
-
}
|
998
|
-
}
|
999
|
-
|
1000
|
-
// FIPS 204, Algorithm 18 (`SimpleBitUnpack`).
|
1001
|
-
static void vectork_decode_10(vectork *out, const uint8_t *in) {
|
1002
|
-
for (int i = 0; i < K; i++) {
|
1003
|
-
scalar_decode_10(&out->v[i], in + i * 10 * DEGREE / 8);
|
1004
|
-
}
|
1005
|
-
}
|
1006
|
-
|
1007
|
-
static void vectork_encode_signed(uint8_t *out, const vectork *a, int bits,
|
1008
|
-
uint32_t max) {
|
1009
|
-
for (int i = 0; i < K; i++) {
|
1010
|
-
scalar_encode_signed(out + i * bits * DEGREE / 8, &a->v[i], bits, max);
|
1011
|
-
}
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
static int vectork_decode_signed(vectork *out, const uint8_t *in, int bits,
|
1015
|
-
uint32_t max) {
|
1016
|
-
for (int i = 0; i < K; i++) {
|
1017
|
-
if (!scalar_decode_signed(&out->v[i], in + i * bits * DEGREE / 8, bits,
|
1018
|
-
max)) {
|
1019
|
-
return 0;
|
1020
|
-
}
|
1021
|
-
}
|
1022
|
-
return 1;
|
1023
|
-
}
|
1024
|
-
|
1025
|
-
// FIPS 204, Algorithm 17 (`BitPack`).
|
1026
|
-
//
|
1027
|
-
// Encodes an entire vector into 32*L*|bits| bytes. Note that since 256 (DEGREE)
|
1028
|
-
// is divisible by 8, the individual vector entries will always fill a whole
|
1029
|
-
// number of bytes, so we do not need to worry about bit packing here.
|
1030
|
-
static void vectorl_encode_signed(uint8_t *out, const vectorl *a, int bits,
|
1031
|
-
uint32_t max) {
|
1032
|
-
for (int i = 0; i < L; i++) {
|
1033
|
-
scalar_encode_signed(out + i * bits * DEGREE / 8, &a->v[i], bits, max);
|
1034
|
-
}
|
1035
|
-
}
|
1036
|
-
|
1037
|
-
static int vectorl_decode_signed(vectorl *out, const uint8_t *in, int bits,
|
1038
|
-
uint32_t max) {
|
1039
|
-
for (int i = 0; i < L; i++) {
|
1040
|
-
if (!scalar_decode_signed(&out->v[i], in + i * bits * DEGREE / 8, bits,
|
1041
|
-
max)) {
|
1042
|
-
return 0;
|
1043
|
-
}
|
1044
|
-
}
|
1045
|
-
return 1;
|
1046
|
-
}
|
1047
|
-
|
1048
|
-
// FIPS 204, Algorithm 28 (`w1Encode`).
|
1049
|
-
static void w1_encode(uint8_t out[128 * K], const vectork *w1) {
|
1050
|
-
vectork_encode(out, w1, 4);
|
1051
|
-
}
|
1052
|
-
|
1053
|
-
// FIPS 204, Algorithm 20 (`HintBitPack`).
|
1054
|
-
static void hint_bit_pack(uint8_t out[OMEGA + K], const vectork *h) {
|
1055
|
-
OPENSSL_memset(out, 0, OMEGA + K);
|
1056
|
-
int index = 0;
|
1057
|
-
for (int i = 0; i < K; i++) {
|
1058
|
-
for (int j = 0; j < DEGREE; j++) {
|
1059
|
-
if (h->v[i].c[j]) {
|
1060
|
-
// h must have at most OMEGA non-zero coefficients.
|
1061
|
-
BSSL_CHECK(index < OMEGA);
|
1062
|
-
out[index++] = j;
|
1063
|
-
}
|
1064
|
-
}
|
1065
|
-
out[OMEGA + i] = index;
|
1066
|
-
}
|
1067
|
-
}
|
1068
|
-
|
1069
|
-
// FIPS 204, Algorithm 21 (`HintBitUnpack`).
|
1070
|
-
static int hint_bit_unpack(vectork *h, const uint8_t in[OMEGA + K]) {
|
1071
|
-
vectork_zero(h);
|
1072
|
-
int index = 0;
|
1073
|
-
for (int i = 0; i < K; i++) {
|
1074
|
-
const int limit = in[OMEGA + i];
|
1075
|
-
if (limit < index || limit > OMEGA) {
|
1076
|
-
return 0;
|
1077
|
-
}
|
1078
|
-
|
1079
|
-
int last = -1;
|
1080
|
-
while (index < limit) {
|
1081
|
-
int byte = in[index++];
|
1082
|
-
if (last >= 0 && byte <= last) {
|
1083
|
-
return 0;
|
1084
|
-
}
|
1085
|
-
last = byte;
|
1086
|
-
static_assert(DEGREE == 256,
|
1087
|
-
"DEGREE must be 256 for this write to be in bounds");
|
1088
|
-
h->v[i].c[byte] = 1;
|
1089
|
-
}
|
1090
|
-
}
|
1091
|
-
for (; index < OMEGA; index++) {
|
1092
|
-
if (in[index] != 0) {
|
1093
|
-
return 0;
|
1094
|
-
}
|
1095
|
-
}
|
1096
|
-
return 1;
|
1097
|
-
}
|
1098
|
-
|
1099
|
-
struct public_key {
|
1100
|
-
uint8_t rho[RHO_BYTES];
|
1101
|
-
vectork t1;
|
1102
|
-
// Pre-cached value(s).
|
1103
|
-
uint8_t public_key_hash[TR_BYTES];
|
1104
|
-
};
|
1105
|
-
|
1106
|
-
struct private_key {
|
1107
|
-
uint8_t rho[RHO_BYTES];
|
1108
|
-
uint8_t k[K_BYTES];
|
1109
|
-
uint8_t public_key_hash[TR_BYTES];
|
1110
|
-
vectorl s1;
|
1111
|
-
vectork s2;
|
1112
|
-
vectork t0;
|
1113
|
-
};
|
1114
|
-
|
1115
|
-
struct signature {
|
1116
|
-
uint8_t c_tilde[2 * LAMBDA_BYTES];
|
1117
|
-
vectorl z;
|
1118
|
-
vectork h;
|
1119
|
-
};
|
1120
|
-
|
1121
|
-
// FIPS 204, Algorithm 22 (`pkEncode`).
|
1122
|
-
static int mldsa_marshal_public_key(CBB *out, const struct public_key *pub) {
|
1123
|
-
if (!CBB_add_bytes(out, pub->rho, sizeof(pub->rho))) {
|
1124
|
-
return 0;
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
uint8_t *vectork_output;
|
1128
|
-
if (!CBB_add_space(out, &vectork_output, 320 * K)) {
|
1129
|
-
return 0;
|
1130
|
-
}
|
1131
|
-
vectork_encode(vectork_output, &pub->t1, 10);
|
1132
|
-
|
1133
|
-
return 1;
|
1134
|
-
}
|
1135
|
-
|
1136
|
-
// FIPS 204, Algorithm 23 (`pkDecode`).
|
1137
|
-
static int mldsa_parse_public_key(struct public_key *pub, CBS *in) {
|
1138
|
-
if (!CBS_copy_bytes(in, pub->rho, sizeof(pub->rho))) {
|
1139
|
-
return 0;
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
CBS t1_bytes;
|
1143
|
-
if (!CBS_get_bytes(in, &t1_bytes, 320 * K)) {
|
1144
|
-
return 0;
|
1145
|
-
}
|
1146
|
-
vectork_decode_10(&pub->t1, CBS_data(&t1_bytes));
|
1147
|
-
|
1148
|
-
return 1;
|
1149
|
-
}
|
1150
|
-
|
1151
|
-
// FIPS 204, Algorithm 24 (`skEncode`).
|
1152
|
-
static int mldsa_marshal_private_key(CBB *out, const struct private_key *priv) {
|
1153
|
-
if (!CBB_add_bytes(out, priv->rho, sizeof(priv->rho)) ||
|
1154
|
-
!CBB_add_bytes(out, priv->k, sizeof(priv->k)) ||
|
1155
|
-
!CBB_add_bytes(out, priv->public_key_hash,
|
1156
|
-
sizeof(priv->public_key_hash))) {
|
1157
|
-
return 0;
|
1158
|
-
}
|
1159
|
-
|
1160
|
-
uint8_t *vectorl_output;
|
1161
|
-
if (!CBB_add_space(out, &vectorl_output, 128 * L)) {
|
1162
|
-
return 0;
|
1163
|
-
}
|
1164
|
-
vectorl_encode_signed(vectorl_output, &priv->s1, 4, ETA);
|
1165
|
-
|
1166
|
-
uint8_t *vectork_output;
|
1167
|
-
if (!CBB_add_space(out, &vectork_output, 128 * K)) {
|
1168
|
-
return 0;
|
1169
|
-
}
|
1170
|
-
vectork_encode_signed(vectork_output, &priv->s2, 4, ETA);
|
1171
|
-
|
1172
|
-
if (!CBB_add_space(out, &vectork_output, 416 * K)) {
|
1173
|
-
return 0;
|
1174
|
-
}
|
1175
|
-
vectork_encode_signed(vectork_output, &priv->t0, 13, 1 << 12);
|
1176
|
-
|
1177
|
-
return 1;
|
1178
|
-
}
|
1179
|
-
|
1180
|
-
// FIPS 204, Algorithm 25 (`skDecode`).
|
1181
|
-
static int mldsa_parse_private_key(struct private_key *priv, CBS *in) {
|
1182
|
-
CBS s1_bytes;
|
1183
|
-
CBS s2_bytes;
|
1184
|
-
CBS t0_bytes;
|
1185
|
-
if (!CBS_copy_bytes(in, priv->rho, sizeof(priv->rho)) ||
|
1186
|
-
!CBS_copy_bytes(in, priv->k, sizeof(priv->k)) ||
|
1187
|
-
!CBS_copy_bytes(in, priv->public_key_hash,
|
1188
|
-
sizeof(priv->public_key_hash)) ||
|
1189
|
-
!CBS_get_bytes(in, &s1_bytes, 128 * L) ||
|
1190
|
-
!vectorl_decode_signed(&priv->s1, CBS_data(&s1_bytes), 4, ETA) ||
|
1191
|
-
!CBS_get_bytes(in, &s2_bytes, 128 * K) ||
|
1192
|
-
!vectork_decode_signed(&priv->s2, CBS_data(&s2_bytes), 4, ETA) ||
|
1193
|
-
!CBS_get_bytes(in, &t0_bytes, 416 * K) ||
|
1194
|
-
// Note: Decoding 13 bits into (-2^12, 2^12] cannot fail.
|
1195
|
-
!vectork_decode_signed(&priv->t0, CBS_data(&t0_bytes), 13, 1 << 12)) {
|
1196
|
-
return 0;
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
return 1;
|
1200
|
-
}
|
1201
|
-
|
1202
|
-
// FIPS 204, Algorithm 26 (`sigEncode`).
|
1203
|
-
static int mldsa_marshal_signature(CBB *out, const struct signature *sign) {
|
1204
|
-
if (!CBB_add_bytes(out, sign->c_tilde, sizeof(sign->c_tilde))) {
|
1205
|
-
return 0;
|
1206
|
-
}
|
1207
|
-
|
1208
|
-
uint8_t *vectorl_output;
|
1209
|
-
if (!CBB_add_space(out, &vectorl_output, 640 * L)) {
|
1210
|
-
return 0;
|
1211
|
-
}
|
1212
|
-
vectorl_encode_signed(vectorl_output, &sign->z, 20, 1 << 19);
|
1213
|
-
|
1214
|
-
uint8_t *hint_output;
|
1215
|
-
if (!CBB_add_space(out, &hint_output, OMEGA + K)) {
|
1216
|
-
return 0;
|
1217
|
-
}
|
1218
|
-
hint_bit_pack(hint_output, &sign->h);
|
1219
|
-
|
1220
|
-
return 1;
|
1221
|
-
}
|
1222
|
-
|
1223
|
-
// FIPS 204, Algorithm 27 (`sigDecode`).
|
1224
|
-
static int mldsa_parse_signature(struct signature *sign, CBS *in) {
|
1225
|
-
CBS z_bytes;
|
1226
|
-
CBS hint_bytes;
|
1227
|
-
if (!CBS_copy_bytes(in, sign->c_tilde, sizeof(sign->c_tilde)) ||
|
1228
|
-
!CBS_get_bytes(in, &z_bytes, 640 * L) ||
|
1229
|
-
// Note: Decoding 20 bits into (-2^19, 2^19] cannot fail.
|
1230
|
-
!vectorl_decode_signed(&sign->z, CBS_data(&z_bytes), 20, 1 << 19) ||
|
1231
|
-
!CBS_get_bytes(in, &hint_bytes, OMEGA + K) ||
|
1232
|
-
!hint_bit_unpack(&sign->h, CBS_data(&hint_bytes))) {
|
1233
|
-
return 0;
|
1234
|
-
};
|
1235
|
-
|
1236
|
-
return 1;
|
1237
|
-
}
|
1238
|
-
|
1239
|
-
static struct private_key *private_key_from_external(
|
1240
|
-
const struct MLDSA65_private_key *external) {
|
1241
|
-
static_assert(
|
1242
|
-
sizeof(struct MLDSA65_private_key) == sizeof(struct private_key),
|
1243
|
-
"Kyber private key size incorrect");
|
1244
|
-
static_assert(
|
1245
|
-
alignof(struct MLDSA65_private_key) == alignof(struct private_key),
|
1246
|
-
"Kyber private key align incorrect");
|
1247
|
-
return (struct private_key *)external;
|
1248
|
-
}
|
1249
|
-
|
1250
|
-
static struct public_key *public_key_from_external(
|
1251
|
-
const struct MLDSA65_public_key *external) {
|
1252
|
-
static_assert(sizeof(struct MLDSA65_public_key) == sizeof(struct public_key),
|
1253
|
-
"mldsa public key size incorrect");
|
1254
|
-
static_assert(
|
1255
|
-
alignof(struct MLDSA65_public_key) == alignof(struct public_key),
|
1256
|
-
"mldsa public key align incorrect");
|
1257
|
-
return (struct public_key *)external;
|
1258
|
-
}
|
1259
|
-
|
1260
|
-
/* API */
|
1261
|
-
|
1262
|
-
// Calls |MLDSA_generate_key_external_entropy| with random bytes from
|
1263
|
-
// |RAND_bytes|. Returns 1 on success and 0 on failure.
|
1264
|
-
int MLDSA65_generate_key(
|
1265
|
-
uint8_t out_encoded_public_key[MLDSA65_PUBLIC_KEY_BYTES],
|
1266
|
-
uint8_t out_seed[MLDSA_SEED_BYTES],
|
1267
|
-
struct MLDSA65_private_key *out_private_key) {
|
1268
|
-
RAND_bytes(out_seed, MLDSA_SEED_BYTES);
|
1269
|
-
return MLDSA65_generate_key_external_entropy(out_encoded_public_key,
|
1270
|
-
out_private_key, out_seed);
|
1271
|
-
}
|
1272
|
-
|
1273
|
-
int MLDSA65_private_key_from_seed(struct MLDSA65_private_key *out_private_key,
|
1274
|
-
const uint8_t *seed, size_t seed_len) {
|
1275
|
-
if (seed_len != MLDSA_SEED_BYTES) {
|
1276
|
-
return 0;
|
1277
|
-
}
|
1278
|
-
uint8_t public_key[MLDSA65_PUBLIC_KEY_BYTES];
|
1279
|
-
return MLDSA65_generate_key_external_entropy(public_key, out_private_key,
|
1280
|
-
seed);
|
1281
|
-
}
|
1282
|
-
|
1283
|
-
// FIPS 204, Algorithm 6 (`ML-DSA.KeyGen_internal`). Returns 1 on success and 0
|
1284
|
-
// on failure.
|
1285
|
-
int MLDSA65_generate_key_external_entropy(
|
1286
|
-
uint8_t out_encoded_public_key[MLDSA65_PUBLIC_KEY_BYTES],
|
1287
|
-
struct MLDSA65_private_key *out_private_key,
|
1288
|
-
const uint8_t entropy[MLDSA_SEED_BYTES]) {
|
1289
|
-
int ret = 0;
|
1290
|
-
|
1291
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1292
|
-
// limited amount of stack.
|
1293
|
-
struct values_st {
|
1294
|
-
struct public_key pub;
|
1295
|
-
matrix a_ntt;
|
1296
|
-
vectorl s1_ntt;
|
1297
|
-
vectork t;
|
1298
|
-
};
|
1299
|
-
struct values_st *values = OPENSSL_malloc(sizeof(*values));
|
1300
|
-
if (values == NULL) {
|
1301
|
-
goto err;
|
1302
|
-
}
|
1303
|
-
|
1304
|
-
struct private_key *priv = private_key_from_external(out_private_key);
|
1305
|
-
|
1306
|
-
uint8_t augmented_entropy[MLDSA_SEED_BYTES + 2];
|
1307
|
-
OPENSSL_memcpy(augmented_entropy, entropy, MLDSA_SEED_BYTES);
|
1308
|
-
// The k and l parameters are appended to the seed.
|
1309
|
-
augmented_entropy[MLDSA_SEED_BYTES] = K;
|
1310
|
-
augmented_entropy[MLDSA_SEED_BYTES + 1] = L;
|
1311
|
-
uint8_t expanded_seed[RHO_BYTES + SIGMA_BYTES + K_BYTES];
|
1312
|
-
BORINGSSL_keccak(expanded_seed, sizeof(expanded_seed), augmented_entropy,
|
1313
|
-
sizeof(augmented_entropy), boringssl_shake256);
|
1314
|
-
const uint8_t *const rho = expanded_seed;
|
1315
|
-
const uint8_t *const sigma = expanded_seed + RHO_BYTES;
|
1316
|
-
const uint8_t *const k = expanded_seed + RHO_BYTES + SIGMA_BYTES;
|
1317
|
-
// rho is public.
|
1318
|
-
CONSTTIME_DECLASSIFY(rho, RHO_BYTES);
|
1319
|
-
OPENSSL_memcpy(values->pub.rho, rho, sizeof(values->pub.rho));
|
1320
|
-
OPENSSL_memcpy(priv->rho, rho, sizeof(priv->rho));
|
1321
|
-
OPENSSL_memcpy(priv->k, k, sizeof(priv->k));
|
1322
|
-
|
1323
|
-
matrix_expand(&values->a_ntt, rho);
|
1324
|
-
vector_expand_short(&priv->s1, &priv->s2, sigma);
|
1325
|
-
|
1326
|
-
OPENSSL_memcpy(&values->s1_ntt, &priv->s1, sizeof(values->s1_ntt));
|
1327
|
-
vectorl_ntt(&values->s1_ntt);
|
1328
|
-
|
1329
|
-
matrix_mult(&values->t, &values->a_ntt, &values->s1_ntt);
|
1330
|
-
vectork_inverse_ntt(&values->t);
|
1331
|
-
vectork_add(&values->t, &values->t, &priv->s2);
|
1332
|
-
|
1333
|
-
vectork_power2_round(&values->pub.t1, &priv->t0, &values->t);
|
1334
|
-
// t1 is public.
|
1335
|
-
CONSTTIME_DECLASSIFY(&values->pub.t1, sizeof(values->pub.t1));
|
1336
|
-
|
1337
|
-
CBB cbb;
|
1338
|
-
CBB_init_fixed(&cbb, out_encoded_public_key, MLDSA65_PUBLIC_KEY_BYTES);
|
1339
|
-
if (!mldsa_marshal_public_key(&cbb, &values->pub)) {
|
1340
|
-
goto err;
|
1341
|
-
}
|
1342
|
-
assert(CBB_len(&cbb) == MLDSA65_PUBLIC_KEY_BYTES);
|
1343
|
-
|
1344
|
-
BORINGSSL_keccak(priv->public_key_hash, sizeof(priv->public_key_hash),
|
1345
|
-
out_encoded_public_key, MLDSA65_PUBLIC_KEY_BYTES,
|
1346
|
-
boringssl_shake256);
|
1347
|
-
|
1348
|
-
ret = 1;
|
1349
|
-
err:
|
1350
|
-
OPENSSL_free(values);
|
1351
|
-
return ret;
|
1352
|
-
}
|
1353
|
-
|
1354
|
-
int MLDSA65_public_from_private(struct MLDSA65_public_key *out_public_key,
|
1355
|
-
const struct MLDSA65_private_key *private_key) {
|
1356
|
-
int ret = 0;
|
1357
|
-
|
1358
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1359
|
-
// limited amount of stack.
|
1360
|
-
struct values_st {
|
1361
|
-
matrix a_ntt;
|
1362
|
-
vectorl s1_ntt;
|
1363
|
-
vectork t;
|
1364
|
-
vectork t0;
|
1365
|
-
};
|
1366
|
-
struct values_st *values = OPENSSL_malloc(sizeof(*values));
|
1367
|
-
if (values == NULL) {
|
1368
|
-
goto err;
|
1369
|
-
}
|
1370
|
-
|
1371
|
-
const struct private_key *priv = private_key_from_external(private_key);
|
1372
|
-
struct public_key *pub = public_key_from_external(out_public_key);
|
1373
|
-
|
1374
|
-
OPENSSL_memcpy(pub->rho, priv->rho, sizeof(pub->rho));
|
1375
|
-
OPENSSL_memcpy(pub->public_key_hash, priv->public_key_hash,
|
1376
|
-
sizeof(pub->public_key_hash));
|
1377
|
-
|
1378
|
-
matrix_expand(&values->a_ntt, priv->rho);
|
1379
|
-
|
1380
|
-
OPENSSL_memcpy(&values->s1_ntt, &priv->s1, sizeof(values->s1_ntt));
|
1381
|
-
vectorl_ntt(&values->s1_ntt);
|
1382
|
-
|
1383
|
-
matrix_mult(&values->t, &values->a_ntt, &values->s1_ntt);
|
1384
|
-
vectork_inverse_ntt(&values->t);
|
1385
|
-
vectork_add(&values->t, &values->t, &priv->s2);
|
1386
|
-
|
1387
|
-
vectork_power2_round(&pub->t1, &values->t0, &values->t);
|
1388
|
-
|
1389
|
-
ret = 1;
|
1390
|
-
err:
|
1391
|
-
OPENSSL_free(values);
|
1392
|
-
return ret;
|
1393
|
-
}
|
1394
|
-
|
1395
|
-
// FIPS 204, Algorithm 7 (`ML-DSA.Sign_internal`). Returns 1 on success and 0 on
|
1396
|
-
// failure.
|
1397
|
-
int MLDSA65_sign_internal(
|
1398
|
-
uint8_t out_encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
1399
|
-
const struct MLDSA65_private_key *private_key, const uint8_t *msg,
|
1400
|
-
size_t msg_len, const uint8_t *context_prefix, size_t context_prefix_len,
|
1401
|
-
const uint8_t *context, size_t context_len,
|
1402
|
-
const uint8_t randomizer[MLDSA_SIGNATURE_RANDOMIZER_BYTES]) {
|
1403
|
-
int ret = 0;
|
1404
|
-
const struct private_key *priv = private_key_from_external(private_key);
|
1405
|
-
|
1406
|
-
uint8_t mu[MU_BYTES];
|
1407
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
1408
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1409
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, priv->public_key_hash,
|
1410
|
-
sizeof(priv->public_key_hash));
|
1411
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context_prefix, context_prefix_len);
|
1412
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context, context_len);
|
1413
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, msg, msg_len);
|
1414
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, mu, MU_BYTES);
|
1415
|
-
|
1416
|
-
uint8_t rho_prime[RHO_PRIME_BYTES];
|
1417
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1418
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, priv->k, sizeof(priv->k));
|
1419
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, randomizer,
|
1420
|
-
MLDSA_SIGNATURE_RANDOMIZER_BYTES);
|
1421
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, mu, MU_BYTES);
|
1422
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, rho_prime, RHO_PRIME_BYTES);
|
1423
|
-
|
1424
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1425
|
-
// limited amount of stack.
|
1426
|
-
struct values_st {
|
1427
|
-
struct signature sign;
|
1428
|
-
vectorl s1_ntt;
|
1429
|
-
vectork s2_ntt;
|
1430
|
-
vectork t0_ntt;
|
1431
|
-
matrix a_ntt;
|
1432
|
-
vectorl y;
|
1433
|
-
vectork w;
|
1434
|
-
vectork w1;
|
1435
|
-
vectorl cs1;
|
1436
|
-
vectork cs2;
|
1437
|
-
};
|
1438
|
-
struct values_st *values = OPENSSL_malloc(sizeof(*values));
|
1439
|
-
if (values == NULL) {
|
1440
|
-
goto err;
|
1441
|
-
}
|
1442
|
-
OPENSSL_memcpy(&values->s1_ntt, &priv->s1, sizeof(values->s1_ntt));
|
1443
|
-
vectorl_ntt(&values->s1_ntt);
|
1444
|
-
|
1445
|
-
OPENSSL_memcpy(&values->s2_ntt, &priv->s2, sizeof(values->s2_ntt));
|
1446
|
-
vectork_ntt(&values->s2_ntt);
|
1447
|
-
|
1448
|
-
OPENSSL_memcpy(&values->t0_ntt, &priv->t0, sizeof(values->t0_ntt));
|
1449
|
-
vectork_ntt(&values->t0_ntt);
|
1450
|
-
|
1451
|
-
matrix_expand(&values->a_ntt, priv->rho);
|
1452
|
-
|
1453
|
-
// kappa must not exceed 2**16/L = 13107. But the probability of it exceeding
|
1454
|
-
// even 1000 iterations is vanishingly small.
|
1455
|
-
for (size_t kappa = 0;; kappa += L) {
|
1456
|
-
vectorl_expand_mask(&values->y, rho_prime, kappa);
|
1457
|
-
|
1458
|
-
vectorl *y_ntt = &values->cs1;
|
1459
|
-
OPENSSL_memcpy(y_ntt, &values->y, sizeof(*y_ntt));
|
1460
|
-
vectorl_ntt(y_ntt);
|
1461
|
-
|
1462
|
-
matrix_mult(&values->w, &values->a_ntt, y_ntt);
|
1463
|
-
vectork_inverse_ntt(&values->w);
|
1464
|
-
|
1465
|
-
vectork_high_bits(&values->w1, &values->w);
|
1466
|
-
uint8_t w1_encoded[128 * K];
|
1467
|
-
w1_encode(w1_encoded, &values->w1);
|
1468
|
-
|
1469
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1470
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, mu, MU_BYTES);
|
1471
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, w1_encoded, 128 * K);
|
1472
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, values->sign.c_tilde,
|
1473
|
-
2 * LAMBDA_BYTES);
|
1474
|
-
|
1475
|
-
scalar c_ntt;
|
1476
|
-
scalar_sample_in_ball_vartime(&c_ntt, values->sign.c_tilde,
|
1477
|
-
sizeof(values->sign.c_tilde));
|
1478
|
-
scalar_ntt(&c_ntt);
|
1479
|
-
|
1480
|
-
vectorl_mult_scalar(&values->cs1, &values->s1_ntt, &c_ntt);
|
1481
|
-
vectorl_inverse_ntt(&values->cs1);
|
1482
|
-
vectork_mult_scalar(&values->cs2, &values->s2_ntt, &c_ntt);
|
1483
|
-
vectork_inverse_ntt(&values->cs2);
|
1484
|
-
|
1485
|
-
vectorl_add(&values->sign.z, &values->y, &values->cs1);
|
1486
|
-
|
1487
|
-
vectork *r0 = &values->w1;
|
1488
|
-
vectork_sub(r0, &values->w, &values->cs2);
|
1489
|
-
vectork_low_bits(r0, r0);
|
1490
|
-
|
1491
|
-
// Leaking the fact that a signature was rejected is fine as the next
|
1492
|
-
// attempt at a signature will be (indistinguishable from) independent of
|
1493
|
-
// this one. Note, however, that we additionally leak which of the two
|
1494
|
-
// branches rejected the signature. Section 5.5 of
|
1495
|
-
// https://pq-crystals.org/dilithium/data/dilithium-specification-round3.pdf
|
1496
|
-
// describes this leak as OK. Note we leak less than what is described by
|
1497
|
-
// the paper; we do not reveal which coefficient violated the bound, and we
|
1498
|
-
// hide which of the |z_max| or |r0_max| bound failed. See also
|
1499
|
-
// https://boringssl-review.googlesource.com/c/boringssl/+/67747/comment/2bbab0fa_d241d35a/
|
1500
|
-
uint32_t z_max = vectorl_max(&values->sign.z);
|
1501
|
-
uint32_t r0_max = vectork_max_signed(r0);
|
1502
|
-
if (constant_time_declassify_w(
|
1503
|
-
constant_time_ge_w(z_max, kGamma1 - BETA) |
|
1504
|
-
constant_time_ge_w(r0_max, kGamma2 - BETA))) {
|
1505
|
-
continue;
|
1506
|
-
}
|
1507
|
-
|
1508
|
-
vectork *ct0 = &values->w1;
|
1509
|
-
vectork_mult_scalar(ct0, &values->t0_ntt, &c_ntt);
|
1510
|
-
vectork_inverse_ntt(ct0);
|
1511
|
-
vectork_make_hint(&values->sign.h, ct0, &values->cs2, &values->w);
|
1512
|
-
|
1513
|
-
// See above.
|
1514
|
-
uint32_t ct0_max = vectork_max(ct0);
|
1515
|
-
size_t h_ones = vectork_count_ones(&values->sign.h);
|
1516
|
-
if (constant_time_declassify_w(constant_time_ge_w(ct0_max, kGamma2) |
|
1517
|
-
constant_time_lt_w(OMEGA, h_ones))) {
|
1518
|
-
continue;
|
1519
|
-
}
|
1520
|
-
|
1521
|
-
// Although computed with the private key, the signature is public.
|
1522
|
-
CONSTTIME_DECLASSIFY(values->sign.c_tilde, sizeof(values->sign.c_tilde));
|
1523
|
-
CONSTTIME_DECLASSIFY(&values->sign.z, sizeof(values->sign.z));
|
1524
|
-
CONSTTIME_DECLASSIFY(&values->sign.h, sizeof(values->sign.h));
|
1525
|
-
|
1526
|
-
CBB cbb;
|
1527
|
-
CBB_init_fixed(&cbb, out_encoded_signature, MLDSA65_SIGNATURE_BYTES);
|
1528
|
-
if (!mldsa_marshal_signature(&cbb, &values->sign)) {
|
1529
|
-
goto err;
|
1530
|
-
}
|
1531
|
-
|
1532
|
-
BSSL_CHECK(CBB_len(&cbb) == MLDSA65_SIGNATURE_BYTES);
|
1533
|
-
ret = 1;
|
1534
|
-
break;
|
1535
|
-
}
|
1536
|
-
|
1537
|
-
err:
|
1538
|
-
OPENSSL_free(values);
|
1539
|
-
return ret;
|
1540
|
-
}
|
1541
|
-
|
1542
|
-
// mldsa signature in randomized mode, filling the random bytes with
|
1543
|
-
// |RAND_bytes|. Returns 1 on success and 0 on failure.
|
1544
|
-
int MLDSA65_sign(uint8_t out_encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
1545
|
-
const struct MLDSA65_private_key *private_key,
|
1546
|
-
const uint8_t *msg, size_t msg_len, const uint8_t *context,
|
1547
|
-
size_t context_len) {
|
1548
|
-
if (context_len > 255) {
|
1549
|
-
return 0;
|
1550
|
-
}
|
1551
|
-
|
1552
|
-
uint8_t randomizer[MLDSA_SIGNATURE_RANDOMIZER_BYTES];
|
1553
|
-
RAND_bytes(randomizer, sizeof(randomizer));
|
1554
|
-
|
1555
|
-
const uint8_t context_prefix[2] = {0, context_len};
|
1556
|
-
return MLDSA65_sign_internal(out_encoded_signature, private_key, msg, msg_len,
|
1557
|
-
context_prefix, sizeof(context_prefix), context,
|
1558
|
-
context_len, randomizer);
|
1559
|
-
}
|
1560
|
-
|
1561
|
-
// FIPS 204, Algorithm 3 (`ML-DSA.Verify`).
|
1562
|
-
int MLDSA65_verify(const struct MLDSA65_public_key *public_key,
|
1563
|
-
const uint8_t *signature, size_t signature_len,
|
1564
|
-
const uint8_t *msg, size_t msg_len, const uint8_t *context,
|
1565
|
-
size_t context_len) {
|
1566
|
-
if (context_len > 255 || signature_len != MLDSA65_SIGNATURE_BYTES) {
|
1567
|
-
return 0;
|
1568
|
-
}
|
1569
|
-
|
1570
|
-
const uint8_t context_prefix[2] = {0, context_len};
|
1571
|
-
return MLDSA65_verify_internal(public_key, signature, msg, msg_len,
|
1572
|
-
context_prefix, sizeof(context_prefix),
|
1573
|
-
context, context_len);
|
1574
|
-
}
|
1575
|
-
|
1576
|
-
// FIPS 204, Algorithm 8 (`ML-DSA.Verify_internal`).
|
1577
|
-
int MLDSA65_verify_internal(
|
1578
|
-
const struct MLDSA65_public_key *public_key,
|
1579
|
-
const uint8_t encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
1580
|
-
const uint8_t *msg, size_t msg_len, const uint8_t *context_prefix,
|
1581
|
-
size_t context_prefix_len, const uint8_t *context, size_t context_len) {
|
1582
|
-
int ret = 0;
|
1583
|
-
|
1584
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1585
|
-
// limited amount of stack.
|
1586
|
-
struct values_st {
|
1587
|
-
struct signature sign;
|
1588
|
-
matrix a_ntt;
|
1589
|
-
vectorl z_ntt;
|
1590
|
-
vectork az_ntt;
|
1591
|
-
vectork ct1_ntt;
|
1592
|
-
};
|
1593
|
-
struct values_st *values = OPENSSL_malloc(sizeof(*values));
|
1594
|
-
if (values == NULL) {
|
1595
|
-
goto err;
|
1596
|
-
}
|
1597
|
-
|
1598
|
-
const struct public_key *pub = public_key_from_external(public_key);
|
1599
|
-
|
1600
|
-
CBS cbs;
|
1601
|
-
CBS_init(&cbs, encoded_signature, MLDSA65_SIGNATURE_BYTES);
|
1602
|
-
if (!mldsa_parse_signature(&values->sign, &cbs)) {
|
1603
|
-
goto err;
|
1604
|
-
}
|
1605
|
-
|
1606
|
-
matrix_expand(&values->a_ntt, pub->rho);
|
1607
|
-
|
1608
|
-
uint8_t mu[MU_BYTES];
|
1609
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
1610
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1611
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, pub->public_key_hash,
|
1612
|
-
sizeof(pub->public_key_hash));
|
1613
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context_prefix, context_prefix_len);
|
1614
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context, context_len);
|
1615
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, msg, msg_len);
|
1616
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, mu, MU_BYTES);
|
1617
|
-
|
1618
|
-
scalar c_ntt;
|
1619
|
-
scalar_sample_in_ball_vartime(&c_ntt, values->sign.c_tilde,
|
1620
|
-
sizeof(values->sign.c_tilde));
|
1621
|
-
scalar_ntt(&c_ntt);
|
1622
|
-
|
1623
|
-
OPENSSL_memcpy(&values->z_ntt, &values->sign.z, sizeof(values->z_ntt));
|
1624
|
-
vectorl_ntt(&values->z_ntt);
|
1625
|
-
|
1626
|
-
matrix_mult(&values->az_ntt, &values->a_ntt, &values->z_ntt);
|
1627
|
-
|
1628
|
-
vectork_scale_power2_round(&values->ct1_ntt, &pub->t1);
|
1629
|
-
vectork_ntt(&values->ct1_ntt);
|
1630
|
-
|
1631
|
-
vectork_mult_scalar(&values->ct1_ntt, &values->ct1_ntt, &c_ntt);
|
1632
|
-
|
1633
|
-
vectork *const w1 = &values->az_ntt;
|
1634
|
-
vectork_sub(w1, &values->az_ntt, &values->ct1_ntt);
|
1635
|
-
vectork_inverse_ntt(w1);
|
1636
|
-
|
1637
|
-
vectork_use_hint_vartime(w1, &values->sign.h, w1);
|
1638
|
-
uint8_t w1_encoded[128 * K];
|
1639
|
-
w1_encode(w1_encoded, w1);
|
1640
|
-
|
1641
|
-
uint8_t c_tilde[2 * LAMBDA_BYTES];
|
1642
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1643
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, mu, MU_BYTES);
|
1644
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, w1_encoded, 128 * K);
|
1645
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, c_tilde, 2 * LAMBDA_BYTES);
|
1646
|
-
|
1647
|
-
uint32_t z_max = vectorl_max(&values->sign.z);
|
1648
|
-
if (z_max < kGamma1 - BETA &&
|
1649
|
-
OPENSSL_memcmp(c_tilde, values->sign.c_tilde, 2 * LAMBDA_BYTES) == 0) {
|
1650
|
-
ret = 1;
|
1651
|
-
}
|
1652
|
-
|
1653
|
-
err:
|
1654
|
-
OPENSSL_free(values);
|
1655
|
-
return ret;
|
1656
|
-
}
|
1657
|
-
|
1658
|
-
/* Serialization of keys. */
|
1659
|
-
|
1660
|
-
int MLDSA65_marshal_public_key(CBB *out,
|
1661
|
-
const struct MLDSA65_public_key *public_key) {
|
1662
|
-
return mldsa_marshal_public_key(out, public_key_from_external(public_key));
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
int MLDSA65_parse_public_key(struct MLDSA65_public_key *public_key, CBS *in) {
|
1666
|
-
struct public_key *pub = public_key_from_external(public_key);
|
1667
|
-
CBS orig_in = *in;
|
1668
|
-
if (!mldsa_parse_public_key(pub, in) || CBS_len(in) != 0) {
|
1669
|
-
return 0;
|
1670
|
-
}
|
1671
|
-
|
1672
|
-
// Compute pre-cached values.
|
1673
|
-
BORINGSSL_keccak(pub->public_key_hash, sizeof(pub->public_key_hash),
|
1674
|
-
CBS_data(&orig_in), CBS_len(&orig_in), boringssl_shake256);
|
1675
|
-
return 1;
|
1676
|
-
}
|
1677
|
-
|
1678
|
-
int MLDSA65_marshal_private_key(CBB *out,
|
1679
|
-
const struct MLDSA65_private_key *private_key) {
|
1680
|
-
return mldsa_marshal_private_key(out, private_key_from_external(private_key));
|
1681
|
-
}
|
1682
|
-
|
1683
|
-
int MLDSA65_parse_private_key(struct MLDSA65_private_key *private_key,
|
1684
|
-
CBS *in) {
|
1685
|
-
struct private_key *priv = private_key_from_external(private_key);
|
1686
|
-
return mldsa_parse_private_key(priv, in) && CBS_len(in) == 0;
|
1687
|
-
}
|