grpc 1.70.1 → 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 +43 -79
- 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/json.h +16 -16
- data/src/core/call/request_buffer.cc +22 -22
- data/src/core/call/request_buffer.h +4 -4
- 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 +16 -26
- data/src/core/client_channel/client_channel.h +2 -2
- data/src/core/client_channel/client_channel_filter.cc +54 -131
- data/src/core/client_channel/client_channel_filter.h +10 -6
- 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 +16 -14
- data/src/core/client_channel/retry_interceptor.h +2 -2
- data/src/core/client_channel/retry_service_config.cc +1 -1
- data/src/core/client_channel/retry_service_config.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 +30 -20
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +5 -5
- 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 +84 -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_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 -39
- 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/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/core/v3/protocol.upb.h +30 -0
- data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.c +5 -3
- data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb.h +118 -0
- data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.c +31 -6
- data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.h +2 -0
- 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/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/server_info.upbdefs.c +6 -4
- data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.c +50 -47
- data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.c +210 -199
- data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.h +5 -0
- 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/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c +19 -17
- 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 +2 -2
- data/src/core/handshaker/handshaker.cc +0 -3
- data/src/core/handshaker/http_connect/http_connect_handshaker.cc +3 -5
- 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 +79 -80
- 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 +3 -2
- data/src/core/lib/debug/trace_flags.h +1 -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 +6 -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 +2 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +2 -4
- 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 +2 -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 +102 -213
- data/src/core/lib/experiments/experiments.h +53 -89
- 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 +0 -2
- 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.h +4 -4
- 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 +103 -49
- data/src/core/lib/promise/party.cc +48 -14
- data/src/core/lib/promise/party.h +216 -27
- 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 +14 -1
- data/src/core/lib/promise/status_flag.h +9 -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 +79 -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 +8 -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 +13 -6
- data/src/core/lib/surface/client_call.h +2 -2
- data/src/core/lib/surface/completion_queue.cc +10 -49
- 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/legacy_channel.cc +10 -8
- data/src/core/lib/surface/legacy_channel.h +2 -2
- data/src/core/lib/surface/server_call.cc +23 -6
- 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.h +100 -59
- data/src/core/lib/transport/call_spine.cc +32 -34
- data/src/core/lib/transport/call_spine.h +66 -23
- data/src/core/lib/transport/call_state.h +8 -8
- 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.h +27 -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 +1 -1
- data/src/core/load_balancing/endpoint_list.h +7 -7
- 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 -4
- 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 +21 -21
- data/src/core/load_balancing/priority/priority.cc +8 -13
- data/src/core/load_balancing/ring_hash/ring_hash.cc +54 -90
- 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 +5 -5
- 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 +8 -14
- 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 +7 -7
- 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 +80 -77
- data/src/core/resolver/xds/xds_dependency_manager.h +4 -0
- data/src/core/resolver/xds/xds_resolver.cc +53 -75
- data/src/core/server/server.cc +71 -79
- data/src/core/server/server.h +16 -5
- 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 +16 -18
- 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 +2 -2
- 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/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 +4 -5
- data/src/core/util/http_client/httpcli.h +4 -4
- 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 +2 -2
- 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/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 +4 -4
- 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 +14 -14
- 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_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 -5
- 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 +552 -359
- data/src/core/xds/xds_client/xds_client.h +39 -14
- data/src/core/xds/xds_client/xds_resource_type.h +2 -3
- data/src/core/xds/xds_client/xds_resource_type_impl.h +3 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.cc +17 -59
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.cc +41 -76
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.cc +17 -91
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +13 -57
- data/third_party/boringssl-with-bazel/src/crypto/asn1/posix_time.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/base64/base64.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bcm_support.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.cc +16 -57
- data/third_party/boringssl-with-bazel/src/crypto/bio/errno.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.cc +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.cc +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/bio/hexdump.cc +18 -58
- data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bio/pair.cc +15 -51
- data/third_party/boringssl-with-bazel/src/crypto/bio/printf.cc +17 -60
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{bn_extra → bn}/bn_asn1.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{bn_extra → bn}/convert.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/buf/buf.cc +14 -57
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.cc +23 -15
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/unicode.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/chacha/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 → cipher}/e_aesctrhmac.cc +18 -23
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → cipher}/e_aesgcmsiv.cc +20 -13
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → cipher}/e_chacha20poly1305.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → cipher}/e_des.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/cipher/e_null.cc +51 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → cipher}/e_rc2.cc +27 -69
- data/third_party/boringssl-with-bazel/src/crypto/cipher/e_rc4.cc +54 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → cipher}/e_tls.cc +13 -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 → cipher}/tls_cbc.cc +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.cc +14 -58
- data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_fuchsia.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_linux.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_sysreg.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_win.cc +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_freebsd.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_linux.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_linux.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/cpu_intel.cc +13 -67
- data/third_party/boringssl-with-bazel/src/crypto/crypto.cc +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_64_adx.cc +13 -13
- 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.cc +15 -13
- data/third_party/boringssl-with-bazel/src/crypto/des/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 → dh}/params.cc +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/{digest_extra → digest}/digest_extra.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.cc +13 -58
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.cc +13 -53
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra → ec}/ec_asn1.cc +24 -61
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra → ec}/ec_derive.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{ec_extra → ec}/hash_to_curve.cc +14 -14
- 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}/ecdsa_asn1.cc +17 -61
- data/third_party/boringssl-with-bazel/src/crypto/engine/engine.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/err/err.cc +17 -107
- data/third_party/boringssl-with-bazel/src/crypto/err/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.cc +29 -79
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.cc +122 -198
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_ctx.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/evp/internal.h +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dh.cc +15 -8
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dh_asn1.cc +13 -8
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.cc +56 -110
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.cc +20 -66
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519_asn1.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_hkdf.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.cc +19 -57
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa_asn1.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519_asn1.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.cc +29 -77
- data/third_party/boringssl-with-bazel/src/crypto/evp/print.cc +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.cc +13 -8
- data/third_party/boringssl-with-bazel/src/crypto/evp/sign.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.cc +13 -107
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.cc.inc +112 -48
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes → aes}/cbc.cc.inc +13 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes → 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 → aes}/gcm.cc.inc +127 -314
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/{modes → aes}/gcm_nohw.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +419 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/key_wrap.cc.inc +13 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.cc.inc +13 -53
- 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 → aes}/polyval.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.cc +28 -20
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm_interface.h +501 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/add.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +15 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bytes.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/cmp.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/ctx.cc.inc +16 -57
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div_extra.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.cc.inc +16 -109
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.cc.inc +13 -107
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/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 +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.cc.inc +14 -109
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.cc.inc +13 -107
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/random.cc.inc +13 -107
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/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.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.cc.inc +13 -53
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/aead.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.cc.inc +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.cc.inc +69 -283
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/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.cc.inc +13 -47
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/check.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.cc.inc +13 -55
- 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.cc.inc +13 -54
- 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.cc.inc +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.cc.inc +14 -72
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.cc.inc +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/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.cc.inc +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/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.cc.inc +22 -17
- 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.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.cc.inc +21 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.cc.inc +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.cc.inc +14 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.cc.inc +14 -65
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +13 -51
- 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 +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hkdf/hkdf.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/hmac.cc.inc +13 -55
- 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.cc → 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.cc.inc +18 -25
- 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.cc.inc +15 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.cc.inc +14 -109
- 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.cc.inc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.cc.inc +18 -77
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.cc.inc +38 -90
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.cc.inc +13 -13
- 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.cc.inc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/internal.h +44 -56
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.cc.inc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/{slhdsa → fipsmodule/slhdsa}/address.h +28 -32
- data/third_party/boringssl-with-bazel/src/crypto/{slhdsa/fors.cc → fipsmodule/slhdsa/fors.cc.inc} +44 -44
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/fors.h +58 -0
- data/third_party/boringssl-with-bazel/src/crypto/{slhdsa/merkle.cc → fipsmodule/slhdsa/merkle.cc.inc} +46 -46
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/slhdsa/merkle.h +70 -0
- data/third_party/boringssl-with-bazel/src/crypto/{slhdsa → fipsmodule/slhdsa}/params.h +20 -25
- 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/{slhdsa/wots.cc → fipsmodule/slhdsa/wots.cc.inc} +46 -46
- 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.cc.inc +13 -51
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.cc +21 -13
- data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +62 -205
- data/third_party/boringssl-with-bazel/src/crypto/kyber/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/kyber/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.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/md4/md4.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/md5/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/md5/md5.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/mem.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/mldsa/mldsa.cc +47 -1747
- data/third_party/boringssl-with-bazel/src/crypto/mlkem/mlkem.cc +97 -1042
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.cc +13 -55
- 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 +13 -55
- 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 +13 -107
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.cc +18 -58
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.cc +56 -103
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.cc +15 -13
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/pool/pool.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra → rand}/deterministic.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra → rand}/fork_detect.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/rand/forkunsafe.cc +44 -0
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra → 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 → rand}/passive.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra/rand_extra.cc → 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 → rand}/urandom.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/{rand_extra → rand}/windows.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/rc4/rc4.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/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}/rsa_asn1.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/{rsa_extra → rsa}/rsa_crypt.cc +13 -55
- 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 +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/sha/sha256.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/sha/sha512.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/slhdsa.cc +62 -256
- 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.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/thread.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/thread_none.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.cc +13 -13
- 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.cc +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.cc +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.cc +14 -14
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.cc +14 -56
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.cc +25 -71
- data/third_party/boringssl-with-bazel/src/crypto/x509/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 +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +13 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/policy.cc +13 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_akey.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_akeya.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_alt.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_bcons.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_bitst.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_conf.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_cpols.cc +13 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_crld.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_enum.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_extku.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_genn.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_ia5.cc +13 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_info.cc +17 -66
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_int.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_lib.cc +14 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_ncons.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_ocsp.cc +13 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_pcons.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_pmaps.cc +13 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_prn.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_purp.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_skey.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/v3_utl.cc +17 -70
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.cc +14 -60
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.cc +13 -58
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.cc +13 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.cc +13 -55
- data/third_party/boringssl-with-bazel/src/gen/crypto/err_data.cc +465 -451
- 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 +14 -56
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +15 -53
- 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 +13 -13
- 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 +13 -13
- 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 +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +13 -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 +14 -71
- 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 +13 -55
- 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 +13 -19
- 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 +13 -58
- 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 +13 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/siphash.h +13 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/slhdsa.h +54 -13
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +19 -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 +198 -174
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl3.h +14 -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 +13 -55
- 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 +13 -8
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +15 -114
- data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +13 -55
- data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +13 -110
- data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +17 -115
- data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +13 -55
- data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +16 -115
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +32 -34
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +314 -132
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +19 -16
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +23 -123
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +55 -174
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +26 -157
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +104 -240
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +22 -120
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +16 -148
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +16 -110
- data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +16 -16
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +14 -81
- data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +15 -20
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +14 -113
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +19 -145
- data/third_party/boringssl-with-bazel/src/ssl/ssl_credential.cc +164 -37
- 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 +15 -17
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +51 -184
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +23 -67
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +25 -144
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +14 -82
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +20 -143
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +15 -15
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +15 -139
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +28 -156
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +16 -16
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +91 -43
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +68 -80
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +154 -52
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +13 -55
- data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +15 -109
- metadata +75 -66
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.cc +0 -127
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.cc +0 -152
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.cc +0 -93
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.cc +0 -96
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.cc +0 -165
- data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.cc +0 -124
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.cc.inc +0 -196
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +0 -448
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.cc.inc +0 -87
- data/third_party/boringssl-with-bazel/src/crypto/mldsa/internal.h +0 -76
- data/third_party/boringssl-with-bazel/src/crypto/mlkem/internal.h +0 -90
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.cc +0 -44
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/ios.cc +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.cc +0 -46
- 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_extra.cc +0 -17
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_print.cc +0 -22
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/fors.h +0 -58
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/internal.h +0 -63
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/merkle.h +0 -70
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/thash.cc +0 -173
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/thash.h +0 -85
- data/third_party/boringssl-with-bazel/src/crypto/slhdsa/wots.h +0 -50
@@ -1,1746 +1,58 @@
|
|
1
|
-
|
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 <memory>
|
18
|
-
|
19
|
-
#include <assert.h>
|
20
|
-
#include <stdlib.h>
|
21
|
-
|
22
|
-
#include <openssl/bytestring.h>
|
23
|
-
#include <openssl/mem.h>
|
24
|
-
#include <openssl/rand.h>
|
25
|
-
|
26
|
-
#include "../internal.h"
|
27
|
-
#include "../keccak/internal.h"
|
28
|
-
#include "./internal.h"
|
29
|
-
|
30
|
-
namespace {
|
31
|
-
|
32
|
-
constexpr int kDegree = 256;
|
33
|
-
constexpr int kRhoBytes = 32;
|
34
|
-
constexpr int kSigmaBytes = 64;
|
35
|
-
constexpr int kKBytes = 32;
|
36
|
-
constexpr int kTrBytes = 64;
|
37
|
-
constexpr int kMuBytes = 64;
|
38
|
-
constexpr int kRhoPrimeBytes = 64;
|
39
|
-
|
40
|
-
// 2^23 - 2^13 + 1
|
41
|
-
constexpr uint32_t kPrime = 8380417;
|
42
|
-
// Inverse of -kPrime modulo 2^32
|
43
|
-
constexpr uint32_t kPrimeNegInverse = 4236238847;
|
44
|
-
constexpr int kDroppedBits = 13;
|
45
|
-
constexpr uint32_t kHalfPrime = (kPrime - 1) / 2;
|
46
|
-
constexpr uint32_t kGamma2 = (kPrime - 1) / 32;
|
47
|
-
// 256^-1 mod kPrime, in Montgomery form.
|
48
|
-
constexpr uint32_t kInverseDegreeMontgomery = 41978;
|
49
|
-
|
50
|
-
// Constants that vary depending on ML-DSA size.
|
51
|
-
//
|
52
|
-
// These are implemented as templates which take the K parameter to distinguish
|
53
|
-
// the ML-DSA sizes. (At the time of writing, `if constexpr` was not available.)
|
54
|
-
//
|
55
|
-
// TODO(crbug.com/42290600): Switch this to `if constexpr` when C++17 is
|
56
|
-
// available.
|
57
|
-
|
58
|
-
template <int K>
|
59
|
-
constexpr size_t public_key_bytes();
|
60
|
-
|
61
|
-
template <>
|
62
|
-
constexpr size_t public_key_bytes<6>() {
|
63
|
-
return MLDSA65_PUBLIC_KEY_BYTES;
|
64
|
-
}
|
65
|
-
|
66
|
-
template <int K>
|
67
|
-
constexpr size_t signature_bytes();
|
68
|
-
|
69
|
-
template <>
|
70
|
-
constexpr size_t signature_bytes<6>() {
|
71
|
-
return MLDSA65_SIGNATURE_BYTES;
|
72
|
-
}
|
73
|
-
|
74
|
-
template <int K>
|
75
|
-
constexpr int tau();
|
76
|
-
|
77
|
-
template <>
|
78
|
-
constexpr int tau<6>() {
|
79
|
-
return 49;
|
80
|
-
}
|
81
|
-
|
82
|
-
template <int K>
|
83
|
-
constexpr int lambda_bytes();
|
84
|
-
|
85
|
-
template <>
|
86
|
-
constexpr int lambda_bytes<6>() {
|
87
|
-
return 192 / 8;
|
88
|
-
}
|
89
|
-
|
90
|
-
template <int K>
|
91
|
-
constexpr int gamma1();
|
92
|
-
|
93
|
-
template <>
|
94
|
-
constexpr int gamma1<6>() {
|
95
|
-
return 1 << 19;
|
96
|
-
}
|
97
|
-
|
98
|
-
template <int K>
|
99
|
-
constexpr int beta();
|
100
|
-
|
101
|
-
template <>
|
102
|
-
constexpr int beta<6>() {
|
103
|
-
return 196;
|
104
|
-
}
|
105
|
-
|
106
|
-
template <int K>
|
107
|
-
constexpr int omega();
|
108
|
-
|
109
|
-
template <>
|
110
|
-
constexpr int omega<6>() {
|
111
|
-
return 55;
|
112
|
-
}
|
113
|
-
|
114
|
-
template <int K>
|
115
|
-
constexpr int eta();
|
116
|
-
|
117
|
-
template <>
|
118
|
-
constexpr int eta<6>() {
|
119
|
-
return 4;
|
120
|
-
}
|
121
|
-
|
122
|
-
template <int K>
|
123
|
-
constexpr int plus_minus_eta_bitlen();
|
124
|
-
|
125
|
-
template <>
|
126
|
-
constexpr int plus_minus_eta_bitlen<6>() {
|
127
|
-
return 4;
|
128
|
-
}
|
129
|
-
|
130
|
-
// Fundamental types.
|
131
|
-
|
132
|
-
typedef struct scalar {
|
133
|
-
uint32_t c[kDegree];
|
134
|
-
} scalar;
|
135
|
-
|
136
|
-
template <int K>
|
137
|
-
struct vector {
|
138
|
-
scalar v[K];
|
139
|
-
};
|
140
|
-
|
141
|
-
template <int K, int L>
|
142
|
-
struct matrix {
|
143
|
-
scalar v[K][L];
|
144
|
-
};
|
145
|
-
|
146
|
-
/* Arithmetic */
|
147
|
-
|
148
|
-
// This bit of Python will be referenced in some of the following comments:
|
149
|
-
//
|
150
|
-
// q = 8380417
|
151
|
-
// # Inverse of -q modulo 2^32
|
152
|
-
// q_neg_inverse = 4236238847
|
153
|
-
// # 2^64 modulo q
|
154
|
-
// montgomery_square = 2365951
|
155
|
-
//
|
156
|
-
// def bitreverse(i):
|
157
|
-
// ret = 0
|
158
|
-
// for n in range(8):
|
159
|
-
// bit = i & 1
|
160
|
-
// ret <<= 1
|
161
|
-
// ret |= bit
|
162
|
-
// i >>= 1
|
163
|
-
// return ret
|
164
|
-
//
|
165
|
-
// def montgomery_reduce(x):
|
166
|
-
// a = (x * q_neg_inverse) % 2**32
|
167
|
-
// b = x + a * q
|
168
|
-
// assert b & 0xFFFF_FFFF == 0
|
169
|
-
// c = b >> 32
|
170
|
-
// assert c < q
|
171
|
-
// return c
|
172
|
-
//
|
173
|
-
// def montgomery_transform(x):
|
174
|
-
// return montgomery_reduce(x * montgomery_square)
|
175
|
-
|
176
|
-
// kNTTRootsMontgomery = [
|
177
|
-
// montgomery_transform(pow(1753, bitreverse(i), q)) for i in range(256)
|
178
|
-
// ]
|
179
|
-
static const uint32_t kNTTRootsMontgomery[256] = {
|
180
|
-
4193792, 25847, 5771523, 7861508, 237124, 7602457, 7504169, 466468,
|
181
|
-
1826347, 2353451, 8021166, 6288512, 3119733, 5495562, 3111497, 2680103,
|
182
|
-
2725464, 1024112, 7300517, 3585928, 7830929, 7260833, 2619752, 6271868,
|
183
|
-
6262231, 4520680, 6980856, 5102745, 1757237, 8360995, 4010497, 280005,
|
184
|
-
2706023, 95776, 3077325, 3530437, 6718724, 4788269, 5842901, 3915439,
|
185
|
-
4519302, 5336701, 3574422, 5512770, 3539968, 8079950, 2348700, 7841118,
|
186
|
-
6681150, 6736599, 3505694, 4558682, 3507263, 6239768, 6779997, 3699596,
|
187
|
-
811944, 531354, 954230, 3881043, 3900724, 5823537, 2071892, 5582638,
|
188
|
-
4450022, 6851714, 4702672, 5339162, 6927966, 3475950, 2176455, 6795196,
|
189
|
-
7122806, 1939314, 4296819, 7380215, 5190273, 5223087, 4747489, 126922,
|
190
|
-
3412210, 7396998, 2147896, 2715295, 5412772, 4686924, 7969390, 5903370,
|
191
|
-
7709315, 7151892, 8357436, 7072248, 7998430, 1349076, 1852771, 6949987,
|
192
|
-
5037034, 264944, 508951, 3097992, 44288, 7280319, 904516, 3958618,
|
193
|
-
4656075, 8371839, 1653064, 5130689, 2389356, 8169440, 759969, 7063561,
|
194
|
-
189548, 4827145, 3159746, 6529015, 5971092, 8202977, 1315589, 1341330,
|
195
|
-
1285669, 6795489, 7567685, 6940675, 5361315, 4499357, 4751448, 3839961,
|
196
|
-
2091667, 3407706, 2316500, 3817976, 5037939, 2244091, 5933984, 4817955,
|
197
|
-
266997, 2434439, 7144689, 3513181, 4860065, 4621053, 7183191, 5187039,
|
198
|
-
900702, 1859098, 909542, 819034, 495491, 6767243, 8337157, 7857917,
|
199
|
-
7725090, 5257975, 2031748, 3207046, 4823422, 7855319, 7611795, 4784579,
|
200
|
-
342297, 286988, 5942594, 4108315, 3437287, 5038140, 1735879, 203044,
|
201
|
-
2842341, 2691481, 5790267, 1265009, 4055324, 1247620, 2486353, 1595974,
|
202
|
-
4613401, 1250494, 2635921, 4832145, 5386378, 1869119, 1903435, 7329447,
|
203
|
-
7047359, 1237275, 5062207, 6950192, 7929317, 1312455, 3306115, 6417775,
|
204
|
-
7100756, 1917081, 5834105, 7005614, 1500165, 777191, 2235880, 3406031,
|
205
|
-
7838005, 5548557, 6709241, 6533464, 5796124, 4656147, 594136, 4603424,
|
206
|
-
6366809, 2432395, 2454455, 8215696, 1957272, 3369112, 185531, 7173032,
|
207
|
-
5196991, 162844, 1616392, 3014001, 810149, 1652634, 4686184, 6581310,
|
208
|
-
5341501, 3523897, 3866901, 269760, 2213111, 7404533, 1717735, 472078,
|
209
|
-
7953734, 1723600, 6577327, 1910376, 6712985, 7276084, 8119771, 4546524,
|
210
|
-
5441381, 6144432, 7959518, 6094090, 183443, 7403526, 1612842, 4834730,
|
211
|
-
7826001, 3919660, 8332111, 7018208, 3937738, 1400424, 7534263, 1976782};
|
212
|
-
|
213
|
-
// Reduces x mod kPrime in constant time, where 0 <= x < 2*kPrime.
|
214
|
-
static uint32_t reduce_once(uint32_t x) {
|
215
|
-
declassify_assert(x < 2 * kPrime);
|
216
|
-
// return x < kPrime ? x : x - kPrime;
|
217
|
-
return constant_time_select_int(constant_time_lt_w(x, kPrime), x, x - kPrime);
|
218
|
-
}
|
219
|
-
|
220
|
-
// Returns the absolute value in constant time.
|
221
|
-
static uint32_t abs_signed(uint32_t x) {
|
222
|
-
// return is_positive(x) ? x : -x;
|
223
|
-
// Note: MSVC doesn't like applying the unary minus operator to unsigned types
|
224
|
-
// (warning C4146), so we write the negation as a bitwise not plus one
|
225
|
-
// (assuming two's complement representation).
|
226
|
-
return constant_time_select_int(constant_time_lt_w(x, 0x80000000), x, 0u - x);
|
227
|
-
}
|
228
|
-
|
229
|
-
// Returns the absolute value modulo kPrime.
|
230
|
-
static uint32_t abs_mod_prime(uint32_t x) {
|
231
|
-
declassify_assert(x < kPrime);
|
232
|
-
// return x > kHalfPrime ? kPrime - x : x;
|
233
|
-
return constant_time_select_int(constant_time_lt_w(kHalfPrime, x), kPrime - x,
|
234
|
-
x);
|
235
|
-
}
|
236
|
-
|
237
|
-
// Returns the maximum of two values in constant time.
|
238
|
-
static uint32_t maximum(uint32_t x, uint32_t y) {
|
239
|
-
// return x < y ? y : x;
|
240
|
-
return constant_time_select_int(constant_time_lt_w(x, y), y, x);
|
241
|
-
}
|
242
|
-
|
243
|
-
static uint32_t mod_sub(uint32_t a, uint32_t b) {
|
244
|
-
declassify_assert(a < kPrime);
|
245
|
-
declassify_assert(b < kPrime);
|
246
|
-
return reduce_once(kPrime + a - b);
|
247
|
-
}
|
248
|
-
|
249
|
-
static void scalar_add(scalar *out, const scalar *lhs, const scalar *rhs) {
|
250
|
-
for (int i = 0; i < kDegree; i++) {
|
251
|
-
out->c[i] = reduce_once(lhs->c[i] + rhs->c[i]);
|
252
|
-
}
|
253
|
-
}
|
254
|
-
|
255
|
-
static void scalar_sub(scalar *out, const scalar *lhs, const scalar *rhs) {
|
256
|
-
for (int i = 0; i < kDegree; i++) {
|
257
|
-
out->c[i] = mod_sub(lhs->c[i], rhs->c[i]);
|
258
|
-
}
|
259
|
-
}
|
260
|
-
|
261
|
-
static uint32_t reduce_montgomery(uint64_t x) {
|
262
|
-
declassify_assert(x <= ((uint64_t)kPrime << 32));
|
263
|
-
uint64_t a = (uint32_t)x * kPrimeNegInverse;
|
264
|
-
uint64_t b = x + a * kPrime;
|
265
|
-
declassify_assert((b & 0xffffffff) == 0);
|
266
|
-
uint32_t c = b >> 32;
|
267
|
-
return reduce_once(c);
|
268
|
-
}
|
269
|
-
|
270
|
-
// Multiply two scalars in the number theoretically transformed state.
|
271
|
-
static void scalar_mult(scalar *out, const scalar *lhs, const scalar *rhs) {
|
272
|
-
for (int i = 0; i < kDegree; i++) {
|
273
|
-
out->c[i] = reduce_montgomery((uint64_t)lhs->c[i] * (uint64_t)rhs->c[i]);
|
274
|
-
}
|
275
|
-
}
|
276
|
-
|
277
|
-
// In place number theoretic transform of a given scalar.
|
1
|
+
// Copyright 2024 The BoringSSL Authors
|
278
2
|
//
|
279
|
-
//
|
280
|
-
|
281
|
-
|
282
|
-
// Offset: 128, 64, 32, 16, ..., 1
|
283
|
-
int offset = kDegree;
|
284
|
-
for (int step = 1; step < kDegree; step <<= 1) {
|
285
|
-
offset >>= 1;
|
286
|
-
int k = 0;
|
287
|
-
for (int i = 0; i < step; i++) {
|
288
|
-
assert(k == 2 * offset * i);
|
289
|
-
const uint32_t step_root = kNTTRootsMontgomery[step + i];
|
290
|
-
for (int j = k; j < k + offset; j++) {
|
291
|
-
uint32_t even = s->c[j];
|
292
|
-
// |reduce_montgomery| works on values up to kPrime*R and R > 2*kPrime.
|
293
|
-
// |step_root| < kPrime because it's static data. |s->c[...]| is <
|
294
|
-
// kPrime by the invariants of that struct.
|
295
|
-
uint32_t odd =
|
296
|
-
reduce_montgomery((uint64_t)step_root * (uint64_t)s->c[j + offset]);
|
297
|
-
s->c[j] = reduce_once(odd + even);
|
298
|
-
s->c[j + offset] = mod_sub(even, odd);
|
299
|
-
}
|
300
|
-
k += 2 * offset;
|
301
|
-
}
|
302
|
-
}
|
303
|
-
}
|
304
|
-
|
305
|
-
// In place inverse number theoretic transform of a given scalar.
|
306
|
-
//
|
307
|
-
// FIPS 204, Algorithm 42 (`NTT^-1`).
|
308
|
-
static void scalar_inverse_ntt(scalar *s) {
|
309
|
-
// Step: 128, 64, 32, 16, ..., 1
|
310
|
-
// Offset: 1, 2, 4, 8, ..., 128
|
311
|
-
int step = kDegree;
|
312
|
-
for (int offset = 1; offset < kDegree; offset <<= 1) {
|
313
|
-
step >>= 1;
|
314
|
-
int k = 0;
|
315
|
-
for (int i = 0; i < step; i++) {
|
316
|
-
assert(k == 2 * offset * i);
|
317
|
-
const uint32_t step_root =
|
318
|
-
kPrime - kNTTRootsMontgomery[step + (step - 1 - i)];
|
319
|
-
for (int j = k; j < k + offset; j++) {
|
320
|
-
uint32_t even = s->c[j];
|
321
|
-
uint32_t odd = s->c[j + offset];
|
322
|
-
s->c[j] = reduce_once(odd + even);
|
323
|
-
|
324
|
-
// |reduce_montgomery| works on values up to kPrime*R and R > 2*kPrime.
|
325
|
-
// kPrime + even < 2*kPrime because |even| < kPrime, by the invariants
|
326
|
-
// of that structure. Thus kPrime + even - odd < 2*kPrime because odd >=
|
327
|
-
// 0, because it's unsigned and less than kPrime. Lastly step_root <
|
328
|
-
// kPrime, because |kNTTRootsMontgomery| is static data.
|
329
|
-
s->c[j + offset] = reduce_montgomery((uint64_t)step_root *
|
330
|
-
(uint64_t)(kPrime + even - odd));
|
331
|
-
}
|
332
|
-
k += 2 * offset;
|
333
|
-
}
|
334
|
-
}
|
335
|
-
for (int i = 0; i < kDegree; i++) {
|
336
|
-
s->c[i] = reduce_montgomery((uint64_t)s->c[i] *
|
337
|
-
(uint64_t)kInverseDegreeMontgomery);
|
338
|
-
}
|
339
|
-
}
|
340
|
-
|
341
|
-
template <int X>
|
342
|
-
static void vector_zero(vector<X> *out) {
|
343
|
-
OPENSSL_memset(out, 0, sizeof(*out));
|
344
|
-
}
|
345
|
-
|
346
|
-
template <int X>
|
347
|
-
static void vector_add(vector<X> *out, const vector<X> *lhs,
|
348
|
-
const vector<X> *rhs) {
|
349
|
-
for (int i = 0; i < X; i++) {
|
350
|
-
scalar_add(&out->v[i], &lhs->v[i], &rhs->v[i]);
|
351
|
-
}
|
352
|
-
}
|
353
|
-
|
354
|
-
template <int X>
|
355
|
-
static void vector_sub(vector<X> *out, const vector<X> *lhs,
|
356
|
-
const vector<X> *rhs) {
|
357
|
-
for (int i = 0; i < X; i++) {
|
358
|
-
scalar_sub(&out->v[i], &lhs->v[i], &rhs->v[i]);
|
359
|
-
}
|
360
|
-
}
|
361
|
-
|
362
|
-
template <int X>
|
363
|
-
static void vector_mult_scalar(vector<X> *out, const vector<X> *lhs,
|
364
|
-
const scalar *rhs) {
|
365
|
-
for (int i = 0; i < X; i++) {
|
366
|
-
scalar_mult(&out->v[i], &lhs->v[i], rhs);
|
367
|
-
}
|
368
|
-
}
|
369
|
-
|
370
|
-
template <int X>
|
371
|
-
static void vector_ntt(vector<X> *a) {
|
372
|
-
for (int i = 0; i < X; i++) {
|
373
|
-
scalar_ntt(&a->v[i]);
|
374
|
-
}
|
375
|
-
}
|
376
|
-
|
377
|
-
template <int X>
|
378
|
-
static void vector_inverse_ntt(vector<X> *a) {
|
379
|
-
for (int i = 0; i < X; i++) {
|
380
|
-
scalar_inverse_ntt(&a->v[i]);
|
381
|
-
}
|
382
|
-
}
|
383
|
-
|
384
|
-
template <int K, int L>
|
385
|
-
static void matrix_mult(vector<K> *out, const matrix<K, L> *m,
|
386
|
-
const vector<L> *a) {
|
387
|
-
vector_zero(out);
|
388
|
-
for (int i = 0; i < K; i++) {
|
389
|
-
for (int j = 0; j < L; j++) {
|
390
|
-
scalar product;
|
391
|
-
scalar_mult(&product, &m->v[i][j], &a->v[j]);
|
392
|
-
scalar_add(&out->v[i], &out->v[i], &product);
|
393
|
-
}
|
394
|
-
}
|
395
|
-
}
|
396
|
-
|
397
|
-
/* Rounding & hints */
|
398
|
-
|
399
|
-
// FIPS 204, Algorithm 35 (`Power2Round`).
|
400
|
-
static void power2_round(uint32_t *r1, uint32_t *r0, uint32_t r) {
|
401
|
-
*r1 = r >> kDroppedBits;
|
402
|
-
*r0 = r - (*r1 << kDroppedBits);
|
403
|
-
|
404
|
-
uint32_t r0_adjusted = mod_sub(*r0, 1 << kDroppedBits);
|
405
|
-
uint32_t r1_adjusted = *r1 + 1;
|
406
|
-
|
407
|
-
// Mask is set iff r0 > 2^(dropped_bits - 1).
|
408
|
-
crypto_word_t mask =
|
409
|
-
constant_time_lt_w((uint32_t)(1 << (kDroppedBits - 1)), *r0);
|
410
|
-
// r0 = mask ? r0_adjusted : r0
|
411
|
-
*r0 = constant_time_select_int(mask, r0_adjusted, *r0);
|
412
|
-
// r1 = mask ? r1_adjusted : r1
|
413
|
-
*r1 = constant_time_select_int(mask, r1_adjusted, *r1);
|
414
|
-
}
|
415
|
-
|
416
|
-
// Scale back previously rounded value.
|
417
|
-
static void scale_power2_round(uint32_t *out, uint32_t r1) {
|
418
|
-
// Pre-condition: 0 <= r1 <= 2^10 - 1
|
419
|
-
assert(r1 < (1u << 10));
|
420
|
-
|
421
|
-
*out = r1 << kDroppedBits;
|
422
|
-
|
423
|
-
// Post-condition: 0 <= out <= 2^23 - 2^13 = kPrime - 1
|
424
|
-
assert(*out < kPrime);
|
425
|
-
}
|
426
|
-
|
427
|
-
// FIPS 204, Algorithm 37 (`HighBits`).
|
428
|
-
static uint32_t high_bits(uint32_t x) {
|
429
|
-
// Reference description (given 0 <= x < q):
|
430
|
-
//
|
431
|
-
// ```
|
432
|
-
// int32_t r0 = x mod+- (2 * kGamma2);
|
433
|
-
// if (x - r0 == q - 1) {
|
434
|
-
// return 0;
|
435
|
-
// } else {
|
436
|
-
// return (x - r0) / (2 * kGamma2);
|
437
|
-
// }
|
438
|
-
// ```
|
439
|
-
//
|
440
|
-
// Below is the formula taken from the reference implementation.
|
441
|
-
//
|
442
|
-
// Here, kGamma2 == 2^18 - 2^8
|
443
|
-
// This returns ((ceil(x / 2^7) * (2^10 + 1) + 2^21) / 2^22) mod 2^4
|
444
|
-
uint32_t r1 = (x + 127) >> 7;
|
445
|
-
r1 = (r1 * 1025 + (1 << 21)) >> 22;
|
446
|
-
r1 &= 15;
|
447
|
-
return r1;
|
448
|
-
}
|
449
|
-
|
450
|
-
// FIPS 204, Algorithm 36 (`Decompose`).
|
451
|
-
static void decompose(uint32_t *r1, int32_t *r0, uint32_t r) {
|
452
|
-
*r1 = high_bits(r);
|
453
|
-
|
454
|
-
*r0 = r;
|
455
|
-
*r0 -= *r1 * 2 * (int32_t)kGamma2;
|
456
|
-
*r0 -= (((int32_t)kHalfPrime - *r0) >> 31) & (int32_t)kPrime;
|
457
|
-
}
|
458
|
-
|
459
|
-
// FIPS 204, Algorithm 38 (`LowBits`).
|
460
|
-
static int32_t low_bits(uint32_t x) {
|
461
|
-
uint32_t r1;
|
462
|
-
int32_t r0;
|
463
|
-
decompose(&r1, &r0, x);
|
464
|
-
return r0;
|
465
|
-
}
|
466
|
-
|
467
|
-
// FIPS 204, Algorithm 39 (`MakeHint`).
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
468
6
|
//
|
469
|
-
//
|
470
|
-
// z = -ct0
|
471
|
-
// r = w - cs2 + ct0
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
472
8
|
//
|
473
|
-
//
|
474
|
-
//
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
return high_bits(r) != high_bits(r_plus_z);
|
479
|
-
}
|
480
|
-
|
481
|
-
// FIPS 204, Algorithm 40 (`UseHint`).
|
482
|
-
static uint32_t use_hint_vartime(uint32_t h, uint32_t r) {
|
483
|
-
uint32_t r1;
|
484
|
-
int32_t r0;
|
485
|
-
decompose(&r1, &r0, r);
|
486
|
-
|
487
|
-
if (h) {
|
488
|
-
if (r0 > 0) {
|
489
|
-
// m = 16, thus |mod m| in the spec turns into |& 15|.
|
490
|
-
return (r1 + 1) & 15;
|
491
|
-
} else {
|
492
|
-
return (r1 - 1) & 15;
|
493
|
-
}
|
494
|
-
}
|
495
|
-
return r1;
|
496
|
-
}
|
497
|
-
|
498
|
-
static void scalar_power2_round(scalar *s1, scalar *s0, const scalar *s) {
|
499
|
-
for (int i = 0; i < kDegree; i++) {
|
500
|
-
power2_round(&s1->c[i], &s0->c[i], s->c[i]);
|
501
|
-
}
|
502
|
-
}
|
503
|
-
|
504
|
-
static void scalar_scale_power2_round(scalar *out, const scalar *in) {
|
505
|
-
for (int i = 0; i < kDegree; i++) {
|
506
|
-
scale_power2_round(&out->c[i], in->c[i]);
|
507
|
-
}
|
508
|
-
}
|
509
|
-
|
510
|
-
static void scalar_high_bits(scalar *out, const scalar *in) {
|
511
|
-
for (int i = 0; i < kDegree; i++) {
|
512
|
-
out->c[i] = high_bits(in->c[i]);
|
513
|
-
}
|
514
|
-
}
|
515
|
-
|
516
|
-
static void scalar_low_bits(scalar *out, const scalar *in) {
|
517
|
-
for (int i = 0; i < kDegree; i++) {
|
518
|
-
out->c[i] = low_bits(in->c[i]);
|
519
|
-
}
|
520
|
-
}
|
521
|
-
|
522
|
-
static void scalar_max(uint32_t *max, const scalar *s) {
|
523
|
-
for (int i = 0; i < kDegree; i++) {
|
524
|
-
uint32_t abs = abs_mod_prime(s->c[i]);
|
525
|
-
*max = maximum(*max, abs);
|
526
|
-
}
|
527
|
-
}
|
528
|
-
|
529
|
-
static void scalar_max_signed(uint32_t *max, const scalar *s) {
|
530
|
-
for (int i = 0; i < kDegree; i++) {
|
531
|
-
uint32_t abs = abs_signed(s->c[i]);
|
532
|
-
*max = maximum(*max, abs);
|
533
|
-
}
|
534
|
-
}
|
535
|
-
|
536
|
-
static void scalar_make_hint(scalar *out, const scalar *ct0, const scalar *cs2,
|
537
|
-
const scalar *w) {
|
538
|
-
for (int i = 0; i < kDegree; i++) {
|
539
|
-
out->c[i] = make_hint(ct0->c[i], cs2->c[i], w->c[i]);
|
540
|
-
}
|
541
|
-
}
|
542
|
-
|
543
|
-
static void scalar_use_hint_vartime(scalar *out, const scalar *h,
|
544
|
-
const scalar *r) {
|
545
|
-
for (int i = 0; i < kDegree; i++) {
|
546
|
-
out->c[i] = use_hint_vartime(h->c[i], r->c[i]);
|
547
|
-
}
|
548
|
-
}
|
549
|
-
|
550
|
-
template <int X>
|
551
|
-
static void vector_power2_round(vector<X> *t1, vector<X> *t0,
|
552
|
-
const vector<X> *t) {
|
553
|
-
for (int i = 0; i < X; i++) {
|
554
|
-
scalar_power2_round(&t1->v[i], &t0->v[i], &t->v[i]);
|
555
|
-
}
|
556
|
-
}
|
557
|
-
|
558
|
-
template <int X>
|
559
|
-
static void vector_scale_power2_round(vector<X> *out, const vector<X> *in) {
|
560
|
-
for (int i = 0; i < X; i++) {
|
561
|
-
scalar_scale_power2_round(&out->v[i], &in->v[i]);
|
562
|
-
}
|
563
|
-
}
|
564
|
-
|
565
|
-
template <int X>
|
566
|
-
static void vector_high_bits(vector<X> *out, const vector<X> *in) {
|
567
|
-
for (int i = 0; i < X; i++) {
|
568
|
-
scalar_high_bits(&out->v[i], &in->v[i]);
|
569
|
-
}
|
570
|
-
}
|
571
|
-
|
572
|
-
template <int X>
|
573
|
-
static void vector_low_bits(vector<X> *out, const vector<X> *in) {
|
574
|
-
for (int i = 0; i < X; i++) {
|
575
|
-
scalar_low_bits(&out->v[i], &in->v[i]);
|
576
|
-
}
|
577
|
-
}
|
578
|
-
|
579
|
-
template <int X>
|
580
|
-
static uint32_t vector_max(const vector<X> *a) {
|
581
|
-
uint32_t max = 0;
|
582
|
-
for (int i = 0; i < X; i++) {
|
583
|
-
scalar_max(&max, &a->v[i]);
|
584
|
-
}
|
585
|
-
return max;
|
586
|
-
}
|
587
|
-
|
588
|
-
template <int X>
|
589
|
-
static uint32_t vector_max_signed(const vector<X> *a) {
|
590
|
-
uint32_t max = 0;
|
591
|
-
for (int i = 0; i < X; i++) {
|
592
|
-
scalar_max_signed(&max, &a->v[i]);
|
593
|
-
}
|
594
|
-
return max;
|
595
|
-
}
|
596
|
-
|
597
|
-
// The input vector contains only zeroes and ones.
|
598
|
-
template <int X>
|
599
|
-
static size_t vector_count_ones(const vector<X> *a) {
|
600
|
-
size_t count = 0;
|
601
|
-
for (int i = 0; i < X; i++) {
|
602
|
-
for (int j = 0; j < kDegree; j++) {
|
603
|
-
count += a->v[i].c[j];
|
604
|
-
}
|
605
|
-
}
|
606
|
-
return count;
|
607
|
-
}
|
608
|
-
|
609
|
-
template <int X>
|
610
|
-
static void vector_make_hint(vector<X> *out, const vector<X> *ct0,
|
611
|
-
const vector<X> *cs2, const vector<X> *w) {
|
612
|
-
for (int i = 0; i < X; i++) {
|
613
|
-
scalar_make_hint(&out->v[i], &ct0->v[i], &cs2->v[i], &w->v[i]);
|
614
|
-
}
|
615
|
-
}
|
616
|
-
|
617
|
-
template <int X>
|
618
|
-
static void vector_use_hint_vartime(vector<X> *out, const vector<X> *h,
|
619
|
-
const vector<X> *r) {
|
620
|
-
for (int i = 0; i < X; i++) {
|
621
|
-
scalar_use_hint_vartime(&out->v[i], &h->v[i], &r->v[i]);
|
622
|
-
}
|
623
|
-
}
|
624
|
-
|
625
|
-
/* Bit packing */
|
626
|
-
|
627
|
-
// FIPS 204, Algorithm 16 (`SimpleBitPack`). Specialized to bitlen(b) = 4.
|
628
|
-
static void scalar_encode_4(uint8_t out[128], const scalar *s) {
|
629
|
-
// Every two elements lands on a byte boundary.
|
630
|
-
static_assert(kDegree % 2 == 0, "kDegree must be a multiple of 2");
|
631
|
-
for (int i = 0; i < kDegree / 2; i++) {
|
632
|
-
uint32_t a = s->c[2 * i];
|
633
|
-
uint32_t b = s->c[2 * i + 1];
|
634
|
-
declassify_assert(a < 16);
|
635
|
-
declassify_assert(b < 16);
|
636
|
-
out[i] = a | (b << 4);
|
637
|
-
}
|
638
|
-
}
|
639
|
-
|
640
|
-
// FIPS 204, Algorithm 16 (`SimpleBitPack`). Specialized to bitlen(b) = 10.
|
641
|
-
static void scalar_encode_10(uint8_t out[320], const scalar *s) {
|
642
|
-
// Every four elements lands on a byte boundary.
|
643
|
-
static_assert(kDegree % 4 == 0, "kDegree must be a multiple of 4");
|
644
|
-
for (int i = 0; i < kDegree / 4; i++) {
|
645
|
-
uint32_t a = s->c[4 * i];
|
646
|
-
uint32_t b = s->c[4 * i + 1];
|
647
|
-
uint32_t c = s->c[4 * i + 2];
|
648
|
-
uint32_t d = s->c[4 * i + 3];
|
649
|
-
declassify_assert(a < 1024);
|
650
|
-
declassify_assert(b < 1024);
|
651
|
-
declassify_assert(c < 1024);
|
652
|
-
declassify_assert(d < 1024);
|
653
|
-
out[5 * i] = (uint8_t)a;
|
654
|
-
out[5 * i + 1] = (uint8_t)((a >> 8) | (b << 2));
|
655
|
-
out[5 * i + 2] = (uint8_t)((b >> 6) | (c << 4));
|
656
|
-
out[5 * i + 3] = (uint8_t)((c >> 4) | (d << 6));
|
657
|
-
out[5 * i + 4] = (uint8_t)(d >> 2);
|
658
|
-
}
|
659
|
-
}
|
660
|
-
|
661
|
-
// FIPS 204, Algorithm 17 (`BitPack`). Specialized to bitlen(b) = 4 and b = 4.
|
662
|
-
static void scalar_encode_signed_4_4(uint8_t out[128], const scalar *s) {
|
663
|
-
// Every two elements lands on a byte boundary.
|
664
|
-
static_assert(kDegree % 2 == 0, "kDegree must be a multiple of 2");
|
665
|
-
for (int i = 0; i < kDegree / 2; i++) {
|
666
|
-
uint32_t a = mod_sub(4, s->c[2 * i]);
|
667
|
-
uint32_t b = mod_sub(4, s->c[2 * i + 1]);
|
668
|
-
declassify_assert(a < 16);
|
669
|
-
declassify_assert(b < 16);
|
670
|
-
out[i] = a | (b << 4);
|
671
|
-
}
|
672
|
-
}
|
673
|
-
|
674
|
-
// FIPS 204, Algorithm 17 (`BitPack`). Specialized to bitlen(b) = 13 and b =
|
675
|
-
// 2^12.
|
676
|
-
static void scalar_encode_signed_13_12(uint8_t out[416], const scalar *s) {
|
677
|
-
static const uint32_t kMax = 1u << 12;
|
678
|
-
// Every two elements lands on a byte boundary.
|
679
|
-
static_assert(kDegree % 8 == 0, "kDegree must be a multiple of 8");
|
680
|
-
for (int i = 0; i < kDegree / 8; i++) {
|
681
|
-
uint32_t a = mod_sub(kMax, s->c[8 * i]);
|
682
|
-
uint32_t b = mod_sub(kMax, s->c[8 * i + 1]);
|
683
|
-
uint32_t c = mod_sub(kMax, s->c[8 * i + 2]);
|
684
|
-
uint32_t d = mod_sub(kMax, s->c[8 * i + 3]);
|
685
|
-
uint32_t e = mod_sub(kMax, s->c[8 * i + 4]);
|
686
|
-
uint32_t f = mod_sub(kMax, s->c[8 * i + 5]);
|
687
|
-
uint32_t g = mod_sub(kMax, s->c[8 * i + 6]);
|
688
|
-
uint32_t h = mod_sub(kMax, s->c[8 * i + 7]);
|
689
|
-
declassify_assert(a < (1u << 13));
|
690
|
-
declassify_assert(b < (1u << 13));
|
691
|
-
declassify_assert(c < (1u << 13));
|
692
|
-
declassify_assert(d < (1u << 13));
|
693
|
-
declassify_assert(e < (1u << 13));
|
694
|
-
declassify_assert(f < (1u << 13));
|
695
|
-
declassify_assert(g < (1u << 13));
|
696
|
-
declassify_assert(h < (1u << 13));
|
697
|
-
a |= b << 13;
|
698
|
-
a |= c << 26;
|
699
|
-
c >>= 6;
|
700
|
-
c |= d << 7;
|
701
|
-
c |= e << 20;
|
702
|
-
e >>= 12;
|
703
|
-
e |= f << 1;
|
704
|
-
e |= g << 14;
|
705
|
-
e |= h << 27;
|
706
|
-
h >>= 5;
|
707
|
-
OPENSSL_memcpy(&out[13 * i], &a, sizeof(a));
|
708
|
-
OPENSSL_memcpy(&out[13 * i + 4], &c, sizeof(c));
|
709
|
-
OPENSSL_memcpy(&out[13 * i + 8], &e, sizeof(e));
|
710
|
-
OPENSSL_memcpy(&out[13 * i + 12], &h, 1);
|
711
|
-
}
|
712
|
-
}
|
713
|
-
|
714
|
-
// FIPS 204, Algorithm 17 (`BitPack`). Specialized to bitlen(b) = 20 and b =
|
715
|
-
// 2^19.
|
716
|
-
static void scalar_encode_signed_20_19(uint8_t out[640], const scalar *s) {
|
717
|
-
static const uint32_t kMax = 1u << 19;
|
718
|
-
// Every two elements lands on a byte boundary.
|
719
|
-
static_assert(kDegree % 4 == 0, "kDegree must be a multiple of 4");
|
720
|
-
for (int i = 0; i < kDegree / 4; i++) {
|
721
|
-
uint32_t a = mod_sub(kMax, s->c[4 * i]);
|
722
|
-
uint32_t b = mod_sub(kMax, s->c[4 * i + 1]);
|
723
|
-
uint32_t c = mod_sub(kMax, s->c[4 * i + 2]);
|
724
|
-
uint32_t d = mod_sub(kMax, s->c[4 * i + 3]);
|
725
|
-
declassify_assert(a < (1u << 20));
|
726
|
-
declassify_assert(b < (1u << 20));
|
727
|
-
declassify_assert(c < (1u << 20));
|
728
|
-
declassify_assert(d < (1u << 20));
|
729
|
-
a |= b << 20;
|
730
|
-
b >>= 12;
|
731
|
-
b |= c << 8;
|
732
|
-
b |= d << 28;
|
733
|
-
d >>= 4;
|
734
|
-
OPENSSL_memcpy(&out[10 * i], &a, sizeof(a));
|
735
|
-
OPENSSL_memcpy(&out[10 * i + 4], &b, sizeof(b));
|
736
|
-
OPENSSL_memcpy(&out[10 * i + 8], &d, 2);
|
737
|
-
}
|
738
|
-
}
|
739
|
-
|
740
|
-
// FIPS 204, Algorithm 17 (`BitPack`).
|
741
|
-
static void scalar_encode_signed(uint8_t *out, const scalar *s, int bits,
|
742
|
-
uint32_t max) {
|
743
|
-
if (bits == 4) {
|
744
|
-
assert(max == 4);
|
745
|
-
scalar_encode_signed_4_4(out, s);
|
746
|
-
} else if (bits == 20) {
|
747
|
-
assert(max == 1u << 19);
|
748
|
-
scalar_encode_signed_20_19(out, s);
|
749
|
-
} else {
|
750
|
-
assert(bits == 13);
|
751
|
-
assert(max == 1u << 12);
|
752
|
-
scalar_encode_signed_13_12(out, s);
|
753
|
-
}
|
754
|
-
}
|
755
|
-
|
756
|
-
// FIPS 204, Algorithm 18 (`SimpleBitUnpack`). Specialized for bitlen(b) == 10.
|
757
|
-
static void scalar_decode_10(scalar *out, const uint8_t in[320]) {
|
758
|
-
uint32_t v;
|
759
|
-
static_assert(kDegree % 4 == 0, "kDegree must be a multiple of 4");
|
760
|
-
for (int i = 0; i < kDegree / 4; i++) {
|
761
|
-
OPENSSL_memcpy(&v, &in[5 * i], sizeof(v));
|
762
|
-
out->c[4 * i] = v & 0x3ff;
|
763
|
-
out->c[4 * i + 1] = (v >> 10) & 0x3ff;
|
764
|
-
out->c[4 * i + 2] = (v >> 20) & 0x3ff;
|
765
|
-
out->c[4 * i + 3] = (v >> 30) | (((uint32_t)in[5 * i + 4]) << 2);
|
766
|
-
}
|
767
|
-
}
|
768
|
-
|
769
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`). Specialized to bitlen(a+b) = 4 and b =
|
770
|
-
// 4.
|
771
|
-
static int scalar_decode_signed_4_4(scalar *out, const uint8_t in[128]) {
|
772
|
-
uint32_t v;
|
773
|
-
static_assert(kDegree % 8 == 0, "kDegree must be a multiple of 8");
|
774
|
-
for (int i = 0; i < kDegree / 8; i++) {
|
775
|
-
OPENSSL_memcpy(&v, &in[4 * i], sizeof(v));
|
776
|
-
// None of the nibbles may be >= 9. So if the MSB of any nibble is set, none
|
777
|
-
// of the other bits may be set. First, select all the MSBs.
|
778
|
-
const uint32_t msbs = v & 0x88888888u;
|
779
|
-
// For each nibble where the MSB is set, form a mask of all the other bits.
|
780
|
-
const uint32_t mask = (msbs >> 1) | (msbs >> 2) | (msbs >> 3);
|
781
|
-
// A nibble is only out of range in the case of invalid input, in which case
|
782
|
-
// it is okay to leak the value.
|
783
|
-
if (constant_time_declassify_int((mask & v) != 0)) {
|
784
|
-
return 0;
|
785
|
-
}
|
786
|
-
|
787
|
-
out->c[i * 8] = mod_sub(4, v & 15);
|
788
|
-
out->c[i * 8 + 1] = mod_sub(4, (v >> 4) & 15);
|
789
|
-
out->c[i * 8 + 2] = mod_sub(4, (v >> 8) & 15);
|
790
|
-
out->c[i * 8 + 3] = mod_sub(4, (v >> 12) & 15);
|
791
|
-
out->c[i * 8 + 4] = mod_sub(4, (v >> 16) & 15);
|
792
|
-
out->c[i * 8 + 5] = mod_sub(4, (v >> 20) & 15);
|
793
|
-
out->c[i * 8 + 6] = mod_sub(4, (v >> 24) & 15);
|
794
|
-
out->c[i * 8 + 7] = mod_sub(4, v >> 28);
|
795
|
-
}
|
796
|
-
return 1;
|
797
|
-
}
|
798
|
-
|
799
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`). Specialized to bitlen(a+b) = 13 and b =
|
800
|
-
// 2^12.
|
801
|
-
static void scalar_decode_signed_13_12(scalar *out, const uint8_t in[416]) {
|
802
|
-
static const uint32_t kMax = 1u << 12;
|
803
|
-
static const uint32_t k13Bits = (1u << 13) - 1;
|
804
|
-
static const uint32_t k7Bits = (1u << 7) - 1;
|
805
|
-
|
806
|
-
uint32_t a, b, c;
|
807
|
-
uint8_t d;
|
808
|
-
static_assert(kDegree % 8 == 0, "kDegree must be a multiple of 8");
|
809
|
-
for (int i = 0; i < kDegree / 8; i++) {
|
810
|
-
OPENSSL_memcpy(&a, &in[13 * i], sizeof(a));
|
811
|
-
OPENSSL_memcpy(&b, &in[13 * i + 4], sizeof(b));
|
812
|
-
OPENSSL_memcpy(&c, &in[13 * i + 8], sizeof(c));
|
813
|
-
d = in[13 * i + 12];
|
814
|
-
|
815
|
-
// It's not possible for a 13-bit number to be out of range when the max is
|
816
|
-
// 2^12.
|
817
|
-
out->c[i * 8] = mod_sub(kMax, a & k13Bits);
|
818
|
-
out->c[i * 8 + 1] = mod_sub(kMax, (a >> 13) & k13Bits);
|
819
|
-
out->c[i * 8 + 2] = mod_sub(kMax, (a >> 26) | ((b & k7Bits) << 6));
|
820
|
-
out->c[i * 8 + 3] = mod_sub(kMax, (b >> 7) & k13Bits);
|
821
|
-
out->c[i * 8 + 4] = mod_sub(kMax, (b >> 20) | ((c & 1) << 12));
|
822
|
-
out->c[i * 8 + 5] = mod_sub(kMax, (c >> 1) & k13Bits);
|
823
|
-
out->c[i * 8 + 6] = mod_sub(kMax, (c >> 14) & k13Bits);
|
824
|
-
out->c[i * 8 + 7] = mod_sub(kMax, (c >> 27) | ((uint32_t)d) << 5);
|
825
|
-
}
|
826
|
-
}
|
827
|
-
|
828
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`). Specialized to bitlen(a+b) = 20 and b =
|
829
|
-
// 2^19.
|
830
|
-
static void scalar_decode_signed_20_19(scalar *out, const uint8_t in[640]) {
|
831
|
-
static const uint32_t kMax = 1u << 19;
|
832
|
-
static const uint32_t k20Bits = (1u << 20) - 1;
|
833
|
-
|
834
|
-
uint32_t a, b;
|
835
|
-
uint16_t c;
|
836
|
-
static_assert(kDegree % 4 == 0, "kDegree must be a multiple of 4");
|
837
|
-
for (int i = 0; i < kDegree / 4; i++) {
|
838
|
-
OPENSSL_memcpy(&a, &in[10 * i], sizeof(a));
|
839
|
-
OPENSSL_memcpy(&b, &in[10 * i + 4], sizeof(b));
|
840
|
-
OPENSSL_memcpy(&c, &in[10 * i + 8], sizeof(c));
|
841
|
-
|
842
|
-
// It's not possible for a 20-bit number to be out of range when the max is
|
843
|
-
// 2^19.
|
844
|
-
out->c[i * 4] = mod_sub(kMax, a & k20Bits);
|
845
|
-
out->c[i * 4 + 1] = mod_sub(kMax, (a >> 20) | ((b & 0xff) << 12));
|
846
|
-
out->c[i * 4 + 2] = mod_sub(kMax, (b >> 8) & k20Bits);
|
847
|
-
out->c[i * 4 + 3] = mod_sub(kMax, (b >> 28) | ((uint32_t)c) << 4);
|
848
|
-
}
|
849
|
-
}
|
850
|
-
|
851
|
-
// FIPS 204, Algorithm 19 (`BitUnpack`).
|
852
|
-
static int scalar_decode_signed(scalar *out, const uint8_t *in, int bits,
|
853
|
-
uint32_t max) {
|
854
|
-
if (bits == 4) {
|
855
|
-
assert(max == 4);
|
856
|
-
return scalar_decode_signed_4_4(out, in);
|
857
|
-
} else if (bits == 13) {
|
858
|
-
assert(max == (1u << 12));
|
859
|
-
scalar_decode_signed_13_12(out, in);
|
860
|
-
return 1;
|
861
|
-
} else if (bits == 20) {
|
862
|
-
assert(max == (1u << 19));
|
863
|
-
scalar_decode_signed_20_19(out, in);
|
864
|
-
return 1;
|
865
|
-
} else {
|
866
|
-
abort();
|
867
|
-
}
|
868
|
-
}
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
869
14
|
|
870
|
-
|
871
|
-
|
872
|
-
// FIPS 204, Algorithm 30 (`RejNTTPoly`).
|
873
|
-
//
|
874
|
-
// Rejection samples a Keccak stream to get uniformly distributed elements. This
|
875
|
-
// is used for matrix expansion and only operates on public inputs.
|
876
|
-
static void scalar_from_keccak_vartime(
|
877
|
-
scalar *out, const uint8_t derived_seed[kRhoBytes + 2]) {
|
878
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
879
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake128);
|
880
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, derived_seed, kRhoBytes + 2);
|
881
|
-
assert(keccak_ctx.squeeze_offset == 0);
|
882
|
-
assert(keccak_ctx.rate_bytes == 168);
|
883
|
-
static_assert(168 % 3 == 0, "block and coefficient boundaries do not align");
|
884
|
-
|
885
|
-
int done = 0;
|
886
|
-
while (done < kDegree) {
|
887
|
-
uint8_t block[168];
|
888
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
889
|
-
for (size_t i = 0; i < sizeof(block) && done < kDegree; i += 3) {
|
890
|
-
// FIPS 204, Algorithm 14 (`CoeffFromThreeBytes`).
|
891
|
-
uint32_t value = (uint32_t)block[i] | ((uint32_t)block[i + 1] << 8) |
|
892
|
-
(((uint32_t)block[i + 2] & 0x7f) << 16);
|
893
|
-
if (value < kPrime) {
|
894
|
-
out->c[done++] = value;
|
895
|
-
}
|
896
|
-
}
|
897
|
-
}
|
898
|
-
}
|
899
|
-
|
900
|
-
template <int ETA>
|
901
|
-
static bool coefficient_from_nibble(uint32_t nibble, uint32_t *result);
|
902
|
-
|
903
|
-
template <>
|
904
|
-
bool coefficient_from_nibble<4>(uint32_t nibble, uint32_t *result) {
|
905
|
-
if (constant_time_declassify_int(nibble < 9)) {
|
906
|
-
*result = mod_sub(4, nibble);
|
907
|
-
return true;
|
908
|
-
}
|
909
|
-
return false;
|
910
|
-
}
|
911
|
-
|
912
|
-
// FIPS 204, Algorithm 31 (`RejBoundedPoly`).
|
913
|
-
template <int ETA>
|
914
|
-
static void scalar_uniform(scalar *out,
|
915
|
-
const uint8_t derived_seed[kSigmaBytes + 2]) {
|
916
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
917
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
918
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, derived_seed, kSigmaBytes + 2);
|
919
|
-
assert(keccak_ctx.squeeze_offset == 0);
|
920
|
-
assert(keccak_ctx.rate_bytes == 136);
|
921
|
-
|
922
|
-
int done = 0;
|
923
|
-
while (done < kDegree) {
|
924
|
-
uint8_t block[136];
|
925
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
926
|
-
for (size_t i = 0; i < sizeof(block) && done < kDegree; ++i) {
|
927
|
-
uint32_t t0 = block[i] & 0x0F;
|
928
|
-
uint32_t t1 = block[i] >> 4;
|
929
|
-
// FIPS 204, Algorithm 15 (`CoefFromHalfByte`). Although both the input
|
930
|
-
// and output here are secret, it is OK to leak when we rejected a byte.
|
931
|
-
// Individual bytes of the SHAKE-256 stream are (indistiguishable from)
|
932
|
-
// independent of each other and the original seed, so leaking information
|
933
|
-
// about the rejected bytes does not reveal the input or output.
|
934
|
-
uint32_t v;
|
935
|
-
if (coefficient_from_nibble<ETA>(t0, &v)) {
|
936
|
-
out->c[done++] = v;
|
937
|
-
}
|
938
|
-
if (done < kDegree && coefficient_from_nibble<ETA>(t1, &v)) {
|
939
|
-
out->c[done++] = v;
|
940
|
-
}
|
941
|
-
}
|
942
|
-
}
|
943
|
-
}
|
944
|
-
|
945
|
-
// FIPS 204, Algorithm 34 (`ExpandMask`), but just a single step.
|
946
|
-
static void scalar_sample_mask(scalar *out,
|
947
|
-
const uint8_t derived_seed[kRhoPrimeBytes + 2]) {
|
948
|
-
uint8_t buf[640];
|
949
|
-
BORINGSSL_keccak(buf, sizeof(buf), derived_seed, kRhoPrimeBytes + 2,
|
950
|
-
boringssl_shake256);
|
951
|
-
|
952
|
-
scalar_decode_signed_20_19(out, buf);
|
953
|
-
}
|
954
|
-
|
955
|
-
// FIPS 204, Algorithm 29 (`SampleInBall`).
|
956
|
-
static void scalar_sample_in_ball_vartime(scalar *out, const uint8_t *seed,
|
957
|
-
int len, int tau) {
|
958
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
959
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
960
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, seed, len);
|
961
|
-
assert(keccak_ctx.squeeze_offset == 0);
|
962
|
-
assert(keccak_ctx.rate_bytes == 136);
|
963
|
-
|
964
|
-
uint8_t block[136];
|
965
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
966
|
-
|
967
|
-
uint64_t signs = CRYPTO_load_u64_le(block);
|
968
|
-
int offset = 8;
|
969
|
-
// SampleInBall implements a Fisher–Yates shuffle, which unavoidably leaks
|
970
|
-
// where the zeros are by memory access pattern. Although this leak happens
|
971
|
-
// before bad signatures are rejected, this is safe. See
|
972
|
-
// https://boringssl-review.googlesource.com/c/boringssl/+/67747/comment/8d8f01ac_70af3f21/
|
973
|
-
CONSTTIME_DECLASSIFY(block + offset, sizeof(block) - offset);
|
974
|
-
|
975
|
-
OPENSSL_memset(out, 0, sizeof(*out));
|
976
|
-
for (size_t i = kDegree - tau; i < kDegree; i++) {
|
977
|
-
size_t byte;
|
978
|
-
for (;;) {
|
979
|
-
if (offset == 136) {
|
980
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, block, sizeof(block));
|
981
|
-
// See above.
|
982
|
-
CONSTTIME_DECLASSIFY(block, sizeof(block));
|
983
|
-
offset = 0;
|
984
|
-
}
|
985
|
-
|
986
|
-
byte = block[offset++];
|
987
|
-
if (byte <= i) {
|
988
|
-
break;
|
989
|
-
}
|
990
|
-
}
|
991
|
-
|
992
|
-
out->c[i] = out->c[byte];
|
993
|
-
out->c[byte] = mod_sub(1, 2 * (signs & 1));
|
994
|
-
signs >>= 1;
|
995
|
-
}
|
996
|
-
}
|
997
|
-
|
998
|
-
// FIPS 204, Algorithm 32 (`ExpandA`).
|
999
|
-
template <int K, int L>
|
1000
|
-
static void matrix_expand(matrix<K, L> *out, const uint8_t rho[kRhoBytes]) {
|
1001
|
-
static_assert(K <= 0x100, "K must fit in 8 bits");
|
1002
|
-
static_assert(L <= 0x100, "L must fit in 8 bits");
|
1003
|
-
|
1004
|
-
uint8_t derived_seed[kRhoBytes + 2];
|
1005
|
-
OPENSSL_memcpy(derived_seed, rho, kRhoBytes);
|
1006
|
-
for (int i = 0; i < K; i++) {
|
1007
|
-
for (int j = 0; j < L; j++) {
|
1008
|
-
derived_seed[kRhoBytes + 1] = (uint8_t)i;
|
1009
|
-
derived_seed[kRhoBytes] = (uint8_t)j;
|
1010
|
-
scalar_from_keccak_vartime(&out->v[i][j], derived_seed);
|
1011
|
-
}
|
1012
|
-
}
|
1013
|
-
}
|
1014
|
-
|
1015
|
-
// FIPS 204, Algorithm 33 (`ExpandS`).
|
1016
|
-
template <int K, int L>
|
1017
|
-
static void vector_expand_short(vector<L> *s1, vector<K> *s2,
|
1018
|
-
const uint8_t sigma[kSigmaBytes]) {
|
1019
|
-
static_assert(K <= 0x100, "K must fit in 8 bits");
|
1020
|
-
static_assert(L <= 0x100, "L must fit in 8 bits");
|
1021
|
-
static_assert(K + L <= 0x100, "K+L must fit in 8 bits");
|
1022
|
-
|
1023
|
-
uint8_t derived_seed[kSigmaBytes + 2];
|
1024
|
-
OPENSSL_memcpy(derived_seed, sigma, kSigmaBytes);
|
1025
|
-
derived_seed[kSigmaBytes] = 0;
|
1026
|
-
derived_seed[kSigmaBytes + 1] = 0;
|
1027
|
-
for (int i = 0; i < L; i++) {
|
1028
|
-
scalar_uniform<eta<K>()>(&s1->v[i], derived_seed);
|
1029
|
-
++derived_seed[kSigmaBytes];
|
1030
|
-
}
|
1031
|
-
for (int i = 0; i < K; i++) {
|
1032
|
-
scalar_uniform<eta<K>()>(&s2->v[i], derived_seed);
|
1033
|
-
++derived_seed[kSigmaBytes];
|
1034
|
-
}
|
1035
|
-
}
|
1036
|
-
|
1037
|
-
// FIPS 204, Algorithm 34 (`ExpandMask`).
|
1038
|
-
template <int L>
|
1039
|
-
static void vector_expand_mask(vector<L> *out,
|
1040
|
-
const uint8_t seed[kRhoPrimeBytes],
|
1041
|
-
size_t kappa) {
|
1042
|
-
assert(kappa + L <= 0x10000);
|
1043
|
-
|
1044
|
-
uint8_t derived_seed[kRhoPrimeBytes + 2];
|
1045
|
-
OPENSSL_memcpy(derived_seed, seed, kRhoPrimeBytes);
|
1046
|
-
for (int i = 0; i < L; i++) {
|
1047
|
-
size_t index = kappa + i;
|
1048
|
-
derived_seed[kRhoPrimeBytes] = index & 0xFF;
|
1049
|
-
derived_seed[kRhoPrimeBytes + 1] = (index >> 8) & 0xFF;
|
1050
|
-
scalar_sample_mask(&out->v[i], derived_seed);
|
1051
|
-
}
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
/* Encoding */
|
1055
|
-
|
1056
|
-
// FIPS 204, Algorithm 16 (`SimpleBitPack`).
|
1057
|
-
//
|
1058
|
-
// Encodes an entire vector into 32*K*|bits| bytes. Note that since 256
|
1059
|
-
// (kDegree) is divisible by 8, the individual vector entries will always fill a
|
1060
|
-
// whole number of bytes, so we do not need to worry about bit packing here.
|
1061
|
-
template <int K>
|
1062
|
-
static void vector_encode(uint8_t *out, const vector<K> *a, int bits) {
|
1063
|
-
if (bits == 4) {
|
1064
|
-
for (int i = 0; i < K; i++) {
|
1065
|
-
scalar_encode_4(out + i * bits * kDegree / 8, &a->v[i]);
|
1066
|
-
}
|
1067
|
-
} else {
|
1068
|
-
assert(bits == 10);
|
1069
|
-
for (int i = 0; i < K; i++) {
|
1070
|
-
scalar_encode_10(out + i * bits * kDegree / 8, &a->v[i]);
|
1071
|
-
}
|
1072
|
-
}
|
1073
|
-
}
|
1074
|
-
|
1075
|
-
// FIPS 204, Algorithm 18 (`SimpleBitUnpack`).
|
1076
|
-
template <int K>
|
1077
|
-
static void vector_decode_10(vector<K> *out, const uint8_t *in) {
|
1078
|
-
for (int i = 0; i < K; i++) {
|
1079
|
-
scalar_decode_10(&out->v[i], in + i * 10 * kDegree / 8);
|
1080
|
-
}
|
1081
|
-
}
|
1082
|
-
|
1083
|
-
// FIPS 204, Algorithm 17 (`BitPack`).
|
1084
|
-
//
|
1085
|
-
// Encodes an entire vector into 32*L*|bits| bytes. Note that since 256
|
1086
|
-
// (kDegree) is divisible by 8, the individual vector entries will always fill a
|
1087
|
-
// whole number of bytes, so we do not need to worry about bit packing here.
|
1088
|
-
template <int X>
|
1089
|
-
static void vector_encode_signed(uint8_t *out, const vector<X> *a, int bits,
|
1090
|
-
uint32_t max) {
|
1091
|
-
for (int i = 0; i < X; i++) {
|
1092
|
-
scalar_encode_signed(out + i * bits * kDegree / 8, &a->v[i], bits, max);
|
1093
|
-
}
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
template <int X>
|
1097
|
-
static int vector_decode_signed(vector<X> *out, const uint8_t *in, int bits,
|
1098
|
-
uint32_t max) {
|
1099
|
-
for (int i = 0; i < X; i++) {
|
1100
|
-
if (!scalar_decode_signed(&out->v[i], in + i * bits * kDegree / 8, bits,
|
1101
|
-
max)) {
|
1102
|
-
return 0;
|
1103
|
-
}
|
1104
|
-
}
|
1105
|
-
return 1;
|
1106
|
-
}
|
1107
|
-
|
1108
|
-
// FIPS 204, Algorithm 28 (`w1Encode`).
|
1109
|
-
template <int K>
|
1110
|
-
static void w1_encode(uint8_t out[128 * K], const vector<K> *w1) {
|
1111
|
-
vector_encode(out, w1, 4);
|
1112
|
-
}
|
1113
|
-
|
1114
|
-
// FIPS 204, Algorithm 20 (`HintBitPack`).
|
1115
|
-
template <int K>
|
1116
|
-
static void hint_bit_pack(uint8_t out[omega<K>() + K], const vector<K> *h) {
|
1117
|
-
OPENSSL_memset(out, 0, omega<K>() + K);
|
1118
|
-
int index = 0;
|
1119
|
-
for (int i = 0; i < K; i++) {
|
1120
|
-
for (int j = 0; j < kDegree; j++) {
|
1121
|
-
if (h->v[i].c[j]) {
|
1122
|
-
// h must have at most omega<K>() non-zero coefficients.
|
1123
|
-
BSSL_CHECK(index < omega<K>());
|
1124
|
-
out[index++] = j;
|
1125
|
-
}
|
1126
|
-
}
|
1127
|
-
out[omega<K>() + i] = index;
|
1128
|
-
}
|
1129
|
-
}
|
1130
|
-
|
1131
|
-
// FIPS 204, Algorithm 21 (`HintBitUnpack`).
|
1132
|
-
template <int K>
|
1133
|
-
static int hint_bit_unpack(vector<K> *h, const uint8_t in[omega<K>() + K]) {
|
1134
|
-
vector_zero(h);
|
1135
|
-
int index = 0;
|
1136
|
-
for (int i = 0; i < K; i++) {
|
1137
|
-
const int limit = in[omega<K>() + i];
|
1138
|
-
if (limit < index || limit > omega<K>()) {
|
1139
|
-
return 0;
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
int last = -1;
|
1143
|
-
while (index < limit) {
|
1144
|
-
int byte = in[index++];
|
1145
|
-
if (last >= 0 && byte <= last) {
|
1146
|
-
return 0;
|
1147
|
-
}
|
1148
|
-
last = byte;
|
1149
|
-
static_assert(kDegree == 256,
|
1150
|
-
"kDegree must be 256 for this write to be in bounds");
|
1151
|
-
h->v[i].c[byte] = 1;
|
1152
|
-
}
|
1153
|
-
}
|
1154
|
-
for (; index < omega<K>(); index++) {
|
1155
|
-
if (in[index] != 0) {
|
1156
|
-
return 0;
|
1157
|
-
}
|
1158
|
-
}
|
1159
|
-
return 1;
|
1160
|
-
}
|
1161
|
-
|
1162
|
-
template <int K>
|
1163
|
-
struct public_key {
|
1164
|
-
uint8_t rho[kRhoBytes];
|
1165
|
-
vector<K> t1;
|
1166
|
-
// Pre-cached value(s).
|
1167
|
-
uint8_t public_key_hash[kTrBytes];
|
1168
|
-
};
|
1169
|
-
|
1170
|
-
template <int K, int L>
|
1171
|
-
struct private_key {
|
1172
|
-
uint8_t rho[kRhoBytes];
|
1173
|
-
uint8_t k[kKBytes];
|
1174
|
-
uint8_t public_key_hash[kTrBytes];
|
1175
|
-
vector<L> s1;
|
1176
|
-
vector<K> s2;
|
1177
|
-
vector<K> t0;
|
1178
|
-
};
|
1179
|
-
|
1180
|
-
template <int K, int L>
|
1181
|
-
struct signature {
|
1182
|
-
uint8_t c_tilde[2 * lambda_bytes<K>()];
|
1183
|
-
vector<L> z;
|
1184
|
-
vector<K> h;
|
1185
|
-
};
|
1186
|
-
|
1187
|
-
// FIPS 204, Algorithm 22 (`pkEncode`).
|
1188
|
-
template <int K>
|
1189
|
-
static int mldsa_marshal_public_key(CBB *out, const struct public_key<K> *pub) {
|
1190
|
-
if (!CBB_add_bytes(out, pub->rho, sizeof(pub->rho))) {
|
1191
|
-
return 0;
|
1192
|
-
}
|
1193
|
-
|
1194
|
-
uint8_t *vectork_output;
|
1195
|
-
if (!CBB_add_space(out, &vectork_output, 320 * K)) {
|
1196
|
-
return 0;
|
1197
|
-
}
|
1198
|
-
vector_encode(vectork_output, &pub->t1, 10);
|
1199
|
-
|
1200
|
-
return 1;
|
1201
|
-
}
|
1202
|
-
|
1203
|
-
// FIPS 204, Algorithm 23 (`pkDecode`).
|
1204
|
-
template <int K>
|
1205
|
-
static int mldsa_parse_public_key(struct public_key<K> *pub, CBS *in) {
|
1206
|
-
const CBS orig_in = *in;
|
1207
|
-
|
1208
|
-
if (!CBS_copy_bytes(in, pub->rho, sizeof(pub->rho))) {
|
1209
|
-
return 0;
|
1210
|
-
}
|
1211
|
-
|
1212
|
-
CBS t1_bytes;
|
1213
|
-
if (!CBS_get_bytes(in, &t1_bytes, 320 * K) || CBS_len(in) != 0) {
|
1214
|
-
return 0;
|
1215
|
-
}
|
1216
|
-
vector_decode_10(&pub->t1, CBS_data(&t1_bytes));
|
1217
|
-
|
1218
|
-
// Compute pre-cached values.
|
1219
|
-
BORINGSSL_keccak(pub->public_key_hash, sizeof(pub->public_key_hash),
|
1220
|
-
CBS_data(&orig_in), CBS_len(&orig_in), boringssl_shake256);
|
1221
|
-
|
1222
|
-
return 1;
|
1223
|
-
}
|
1224
|
-
|
1225
|
-
// FIPS 204, Algorithm 24 (`skEncode`).
|
1226
|
-
template <int K, int L>
|
1227
|
-
static int mldsa_marshal_private_key(CBB *out,
|
1228
|
-
const struct private_key<K, L> *priv) {
|
1229
|
-
if (!CBB_add_bytes(out, priv->rho, sizeof(priv->rho)) ||
|
1230
|
-
!CBB_add_bytes(out, priv->k, sizeof(priv->k)) ||
|
1231
|
-
!CBB_add_bytes(out, priv->public_key_hash,
|
1232
|
-
sizeof(priv->public_key_hash))) {
|
1233
|
-
return 0;
|
1234
|
-
}
|
1235
|
-
|
1236
|
-
constexpr size_t scalar_bytes =
|
1237
|
-
(kDegree * plus_minus_eta_bitlen<K>() + 7) / 8;
|
1238
|
-
uint8_t *vectorl_output;
|
1239
|
-
if (!CBB_add_space(out, &vectorl_output, scalar_bytes * L)) {
|
1240
|
-
return 0;
|
1241
|
-
}
|
1242
|
-
vector_encode_signed(vectorl_output, &priv->s1, plus_minus_eta_bitlen<K>(),
|
1243
|
-
eta<K>());
|
1244
|
-
|
1245
|
-
uint8_t *s2_output;
|
1246
|
-
if (!CBB_add_space(out, &s2_output, scalar_bytes * K)) {
|
1247
|
-
return 0;
|
1248
|
-
}
|
1249
|
-
vector_encode_signed(s2_output, &priv->s2, plus_minus_eta_bitlen<K>(),
|
1250
|
-
eta<K>());
|
1251
|
-
|
1252
|
-
uint8_t *t0_output;
|
1253
|
-
if (!CBB_add_space(out, &t0_output, 416 * K)) {
|
1254
|
-
return 0;
|
1255
|
-
}
|
1256
|
-
vector_encode_signed(t0_output, &priv->t0, 13, 1 << 12);
|
1257
|
-
|
1258
|
-
return 1;
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
// FIPS 204, Algorithm 25 (`skDecode`).
|
1262
|
-
template <int K, int L>
|
1263
|
-
static int mldsa_parse_private_key(struct private_key<K, L> *priv, CBS *in) {
|
1264
|
-
CBS s1_bytes;
|
1265
|
-
CBS s2_bytes;
|
1266
|
-
CBS t0_bytes;
|
1267
|
-
constexpr size_t scalar_bytes =
|
1268
|
-
(kDegree * plus_minus_eta_bitlen<K>() + 7) / 8;
|
1269
|
-
if (!CBS_copy_bytes(in, priv->rho, sizeof(priv->rho)) ||
|
1270
|
-
!CBS_copy_bytes(in, priv->k, sizeof(priv->k)) ||
|
1271
|
-
!CBS_copy_bytes(in, priv->public_key_hash,
|
1272
|
-
sizeof(priv->public_key_hash)) ||
|
1273
|
-
!CBS_get_bytes(in, &s1_bytes, scalar_bytes * L) ||
|
1274
|
-
!vector_decode_signed(&priv->s1, CBS_data(&s1_bytes),
|
1275
|
-
plus_minus_eta_bitlen<K>(), eta<K>()) ||
|
1276
|
-
!CBS_get_bytes(in, &s2_bytes, scalar_bytes * K) ||
|
1277
|
-
!vector_decode_signed(&priv->s2, CBS_data(&s2_bytes),
|
1278
|
-
plus_minus_eta_bitlen<K>(), eta<K>()) ||
|
1279
|
-
!CBS_get_bytes(in, &t0_bytes, 416 * K) ||
|
1280
|
-
// Note: Decoding 13 bits into (-2^12, 2^12] cannot fail.
|
1281
|
-
!vector_decode_signed(&priv->t0, CBS_data(&t0_bytes), 13, 1 << 12)) {
|
1282
|
-
return 0;
|
1283
|
-
}
|
1284
|
-
|
1285
|
-
return 1;
|
1286
|
-
}
|
1287
|
-
|
1288
|
-
// FIPS 204, Algorithm 26 (`sigEncode`).
|
1289
|
-
template <int K, int L>
|
1290
|
-
static int mldsa_marshal_signature(CBB *out,
|
1291
|
-
const struct signature<K, L> *sign) {
|
1292
|
-
if (!CBB_add_bytes(out, sign->c_tilde, sizeof(sign->c_tilde))) {
|
1293
|
-
return 0;
|
1294
|
-
}
|
1295
|
-
|
1296
|
-
uint8_t *vectorl_output;
|
1297
|
-
if (!CBB_add_space(out, &vectorl_output, 640 * L)) {
|
1298
|
-
return 0;
|
1299
|
-
}
|
1300
|
-
vector_encode_signed(vectorl_output, &sign->z, 20, 1 << 19);
|
1301
|
-
|
1302
|
-
uint8_t *hint_output;
|
1303
|
-
if (!CBB_add_space(out, &hint_output, omega<K>() + K)) {
|
1304
|
-
return 0;
|
1305
|
-
}
|
1306
|
-
hint_bit_pack(hint_output, &sign->h);
|
1307
|
-
|
1308
|
-
return 1;
|
1309
|
-
}
|
1310
|
-
|
1311
|
-
// FIPS 204, Algorithm 27 (`sigDecode`).
|
1312
|
-
template <int K, int L>
|
1313
|
-
static int mldsa_parse_signature(struct signature<K, L> *sign, CBS *in) {
|
1314
|
-
CBS z_bytes;
|
1315
|
-
CBS hint_bytes;
|
1316
|
-
if (!CBS_copy_bytes(in, sign->c_tilde, sizeof(sign->c_tilde)) ||
|
1317
|
-
!CBS_get_bytes(in, &z_bytes, 640 * L) ||
|
1318
|
-
// Note: Decoding 20 bits into (-2^19, 2^19] cannot fail.
|
1319
|
-
!vector_decode_signed(&sign->z, CBS_data(&z_bytes), 20, 1 << 19) ||
|
1320
|
-
!CBS_get_bytes(in, &hint_bytes, omega<K>() + K) ||
|
1321
|
-
!hint_bit_unpack(&sign->h, CBS_data(&hint_bytes))) {
|
1322
|
-
return 0;
|
1323
|
-
};
|
1324
|
-
|
1325
|
-
return 1;
|
1326
|
-
}
|
1327
|
-
|
1328
|
-
template <typename T>
|
1329
|
-
struct DeleterFree {
|
1330
|
-
void operator()(T *ptr) { OPENSSL_free(ptr); }
|
1331
|
-
};
|
1332
|
-
|
1333
|
-
// FIPS 204, Algorithm 6 (`ML-DSA.KeyGen_internal`). Returns 1 on success and 0
|
1334
|
-
// on failure.
|
1335
|
-
template <int K, int L>
|
1336
|
-
static int mldsa_generate_key_external_entropy(
|
1337
|
-
uint8_t out_encoded_public_key[public_key_bytes<K>()],
|
1338
|
-
struct private_key<K, L> *priv, const uint8_t entropy[MLDSA_SEED_BYTES]) {
|
1339
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1340
|
-
// limited amount of stack.
|
1341
|
-
struct values_st {
|
1342
|
-
struct public_key<K> pub;
|
1343
|
-
matrix<K, L> a_ntt;
|
1344
|
-
vector<L> s1_ntt;
|
1345
|
-
vector<K> t;
|
1346
|
-
};
|
1347
|
-
std::unique_ptr<values_st, DeleterFree<values_st>> values(
|
1348
|
-
reinterpret_cast<struct values_st *>(OPENSSL_malloc(sizeof(values_st))));
|
1349
|
-
if (values == NULL) {
|
1350
|
-
return 0;
|
1351
|
-
}
|
1352
|
-
|
1353
|
-
uint8_t augmented_entropy[MLDSA_SEED_BYTES + 2];
|
1354
|
-
OPENSSL_memcpy(augmented_entropy, entropy, MLDSA_SEED_BYTES);
|
1355
|
-
// The k and l parameters are appended to the seed.
|
1356
|
-
augmented_entropy[MLDSA_SEED_BYTES] = K;
|
1357
|
-
augmented_entropy[MLDSA_SEED_BYTES + 1] = L;
|
1358
|
-
uint8_t expanded_seed[kRhoBytes + kSigmaBytes + kKBytes];
|
1359
|
-
BORINGSSL_keccak(expanded_seed, sizeof(expanded_seed), augmented_entropy,
|
1360
|
-
sizeof(augmented_entropy), boringssl_shake256);
|
1361
|
-
const uint8_t *const rho = expanded_seed;
|
1362
|
-
const uint8_t *const sigma = expanded_seed + kRhoBytes;
|
1363
|
-
const uint8_t *const k = expanded_seed + kRhoBytes + kSigmaBytes;
|
1364
|
-
// rho is public.
|
1365
|
-
CONSTTIME_DECLASSIFY(rho, kRhoBytes);
|
1366
|
-
OPENSSL_memcpy(values->pub.rho, rho, sizeof(values->pub.rho));
|
1367
|
-
OPENSSL_memcpy(priv->rho, rho, sizeof(priv->rho));
|
1368
|
-
OPENSSL_memcpy(priv->k, k, sizeof(priv->k));
|
1369
|
-
|
1370
|
-
matrix_expand(&values->a_ntt, rho);
|
1371
|
-
vector_expand_short(&priv->s1, &priv->s2, sigma);
|
1372
|
-
|
1373
|
-
OPENSSL_memcpy(&values->s1_ntt, &priv->s1, sizeof(values->s1_ntt));
|
1374
|
-
vector_ntt(&values->s1_ntt);
|
1375
|
-
|
1376
|
-
matrix_mult(&values->t, &values->a_ntt, &values->s1_ntt);
|
1377
|
-
vector_inverse_ntt(&values->t);
|
1378
|
-
vector_add(&values->t, &values->t, &priv->s2);
|
1379
|
-
|
1380
|
-
vector_power2_round(&values->pub.t1, &priv->t0, &values->t);
|
1381
|
-
// t1 is public.
|
1382
|
-
CONSTTIME_DECLASSIFY(&values->pub.t1, sizeof(values->pub.t1));
|
1383
|
-
|
1384
|
-
CBB cbb;
|
1385
|
-
CBB_init_fixed(&cbb, out_encoded_public_key, public_key_bytes<K>());
|
1386
|
-
if (!mldsa_marshal_public_key(&cbb, &values->pub)) {
|
1387
|
-
return 0;
|
1388
|
-
}
|
1389
|
-
assert(CBB_len(&cbb) == public_key_bytes<K>());
|
1390
|
-
|
1391
|
-
BORINGSSL_keccak(priv->public_key_hash, sizeof(priv->public_key_hash),
|
1392
|
-
out_encoded_public_key, public_key_bytes<K>(),
|
1393
|
-
boringssl_shake256);
|
1394
|
-
|
1395
|
-
return 1;
|
1396
|
-
}
|
1397
|
-
|
1398
|
-
template <int K, int L>
|
1399
|
-
static int mldsa_public_from_private(struct public_key<K> *pub,
|
1400
|
-
const struct private_key<K, L> *priv) {
|
1401
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1402
|
-
// limited amount of stack.
|
1403
|
-
struct values_st {
|
1404
|
-
matrix<K, L> a_ntt;
|
1405
|
-
vector<L> s1_ntt;
|
1406
|
-
vector<K> t;
|
1407
|
-
vector<K> t0;
|
1408
|
-
};
|
1409
|
-
std::unique_ptr<values_st, DeleterFree<values_st>> values(
|
1410
|
-
reinterpret_cast<struct values_st *>(OPENSSL_malloc(sizeof(values_st))));
|
1411
|
-
if (values == NULL) {
|
1412
|
-
return 0;
|
1413
|
-
}
|
1414
|
-
|
1415
|
-
|
1416
|
-
OPENSSL_memcpy(pub->rho, priv->rho, sizeof(pub->rho));
|
1417
|
-
OPENSSL_memcpy(pub->public_key_hash, priv->public_key_hash,
|
1418
|
-
sizeof(pub->public_key_hash));
|
1419
|
-
|
1420
|
-
matrix_expand(&values->a_ntt, priv->rho);
|
1421
|
-
|
1422
|
-
OPENSSL_memcpy(&values->s1_ntt, &priv->s1, sizeof(values->s1_ntt));
|
1423
|
-
vector_ntt(&values->s1_ntt);
|
1424
|
-
|
1425
|
-
matrix_mult(&values->t, &values->a_ntt, &values->s1_ntt);
|
1426
|
-
vector_inverse_ntt(&values->t);
|
1427
|
-
vector_add(&values->t, &values->t, &priv->s2);
|
1428
|
-
|
1429
|
-
vector_power2_round(&pub->t1, &values->t0, &values->t);
|
1430
|
-
return 1;
|
1431
|
-
}
|
1432
|
-
|
1433
|
-
// FIPS 204, Algorithm 7 (`ML-DSA.Sign_internal`). Returns 1 on success and 0
|
1434
|
-
// on failure.
|
1435
|
-
template <int K, int L>
|
1436
|
-
static int mldsa_sign_internal(
|
1437
|
-
uint8_t out_encoded_signature[signature_bytes<K>()],
|
1438
|
-
const struct private_key<K, L> *priv, const uint8_t *msg, size_t msg_len,
|
1439
|
-
const uint8_t *context_prefix, size_t context_prefix_len,
|
1440
|
-
const uint8_t *context, size_t context_len,
|
1441
|
-
const uint8_t randomizer[MLDSA_SIGNATURE_RANDOMIZER_BYTES]) {
|
1442
|
-
uint8_t mu[kMuBytes];
|
1443
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
1444
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1445
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, priv->public_key_hash,
|
1446
|
-
sizeof(priv->public_key_hash));
|
1447
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context_prefix, context_prefix_len);
|
1448
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context, context_len);
|
1449
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, msg, msg_len);
|
1450
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, mu, kMuBytes);
|
1451
|
-
|
1452
|
-
uint8_t rho_prime[kRhoPrimeBytes];
|
1453
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1454
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, priv->k, sizeof(priv->k));
|
1455
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, randomizer,
|
1456
|
-
MLDSA_SIGNATURE_RANDOMIZER_BYTES);
|
1457
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, mu, kMuBytes);
|
1458
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, rho_prime, kRhoPrimeBytes);
|
1459
|
-
|
1460
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1461
|
-
// limited amount of stack.
|
1462
|
-
struct values_st {
|
1463
|
-
struct signature<K, L> sign;
|
1464
|
-
vector<L> s1_ntt;
|
1465
|
-
vector<K> s2_ntt;
|
1466
|
-
vector<K> t0_ntt;
|
1467
|
-
matrix<K, L> a_ntt;
|
1468
|
-
vector<L> y;
|
1469
|
-
vector<K> w;
|
1470
|
-
vector<K> w1;
|
1471
|
-
vector<L> cs1;
|
1472
|
-
vector<K> cs2;
|
1473
|
-
};
|
1474
|
-
std::unique_ptr<values_st, DeleterFree<values_st>> values(
|
1475
|
-
reinterpret_cast<struct values_st *>(OPENSSL_malloc(sizeof(values_st))));
|
1476
|
-
if (values == NULL) {
|
1477
|
-
return 0;
|
1478
|
-
}
|
1479
|
-
OPENSSL_memcpy(&values->s1_ntt, &priv->s1, sizeof(values->s1_ntt));
|
1480
|
-
vector_ntt(&values->s1_ntt);
|
1481
|
-
|
1482
|
-
OPENSSL_memcpy(&values->s2_ntt, &priv->s2, sizeof(values->s2_ntt));
|
1483
|
-
vector_ntt(&values->s2_ntt);
|
1484
|
-
|
1485
|
-
OPENSSL_memcpy(&values->t0_ntt, &priv->t0, sizeof(values->t0_ntt));
|
1486
|
-
vector_ntt(&values->t0_ntt);
|
1487
|
-
|
1488
|
-
matrix_expand(&values->a_ntt, priv->rho);
|
1489
|
-
|
1490
|
-
// kappa must not exceed 2**16/L = 13107. But the probability of it
|
1491
|
-
// exceeding even 1000 iterations is vanishingly small.
|
1492
|
-
for (size_t kappa = 0;; kappa += L) {
|
1493
|
-
vector_expand_mask(&values->y, rho_prime, kappa);
|
1494
|
-
|
1495
|
-
vector<L> *y_ntt = &values->cs1;
|
1496
|
-
OPENSSL_memcpy(y_ntt, &values->y, sizeof(*y_ntt));
|
1497
|
-
vector_ntt(y_ntt);
|
1498
|
-
|
1499
|
-
matrix_mult(&values->w, &values->a_ntt, y_ntt);
|
1500
|
-
vector_inverse_ntt(&values->w);
|
1501
|
-
|
1502
|
-
vector_high_bits(&values->w1, &values->w);
|
1503
|
-
uint8_t w1_encoded[128 * K];
|
1504
|
-
w1_encode(w1_encoded, &values->w1);
|
1505
|
-
|
1506
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1507
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, mu, kMuBytes);
|
1508
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, w1_encoded, 128 * K);
|
1509
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, values->sign.c_tilde,
|
1510
|
-
2 * lambda_bytes<K>());
|
1511
|
-
|
1512
|
-
scalar c_ntt;
|
1513
|
-
scalar_sample_in_ball_vartime(&c_ntt, values->sign.c_tilde,
|
1514
|
-
sizeof(values->sign.c_tilde), tau<K>());
|
1515
|
-
scalar_ntt(&c_ntt);
|
1516
|
-
|
1517
|
-
vector_mult_scalar(&values->cs1, &values->s1_ntt, &c_ntt);
|
1518
|
-
vector_inverse_ntt(&values->cs1);
|
1519
|
-
vector_mult_scalar(&values->cs2, &values->s2_ntt, &c_ntt);
|
1520
|
-
vector_inverse_ntt(&values->cs2);
|
1521
|
-
|
1522
|
-
vector_add(&values->sign.z, &values->y, &values->cs1);
|
1523
|
-
|
1524
|
-
vector<K> *r0 = &values->w1;
|
1525
|
-
vector_sub(r0, &values->w, &values->cs2);
|
1526
|
-
vector_low_bits(r0, r0);
|
1527
|
-
|
1528
|
-
// Leaking the fact that a signature was rejected is fine as the next
|
1529
|
-
// attempt at a signature will be (indistinguishable from) independent of
|
1530
|
-
// this one. Note, however, that we additionally leak which of the two
|
1531
|
-
// branches rejected the signature. Section 5.5 of
|
1532
|
-
// https://pq-crystals.org/dilithium/data/dilithium-specification-round3.pdf
|
1533
|
-
// describes this leak as OK. Note we leak less than what is described by
|
1534
|
-
// the paper; we do not reveal which coefficient violated the bound, and
|
1535
|
-
// we hide which of the |z_max| or |r0_max| bound failed. See also
|
1536
|
-
// https://boringssl-review.googlesource.com/c/boringssl/+/67747/comment/2bbab0fa_d241d35a/
|
1537
|
-
uint32_t z_max = vector_max(&values->sign.z);
|
1538
|
-
uint32_t r0_max = vector_max_signed(r0);
|
1539
|
-
if (constant_time_declassify_w(
|
1540
|
-
constant_time_ge_w(z_max, gamma1<K>() - beta<K>()) |
|
1541
|
-
constant_time_ge_w(r0_max, kGamma2 - beta<K>()))) {
|
1542
|
-
continue;
|
1543
|
-
}
|
1544
|
-
|
1545
|
-
vector<K> *ct0 = &values->w1;
|
1546
|
-
vector_mult_scalar(ct0, &values->t0_ntt, &c_ntt);
|
1547
|
-
vector_inverse_ntt(ct0);
|
1548
|
-
vector_make_hint(&values->sign.h, ct0, &values->cs2, &values->w);
|
1549
|
-
|
1550
|
-
// See above.
|
1551
|
-
uint32_t ct0_max = vector_max(ct0);
|
1552
|
-
size_t h_ones = vector_count_ones(&values->sign.h);
|
1553
|
-
if (constant_time_declassify_w(constant_time_ge_w(ct0_max, kGamma2) |
|
1554
|
-
constant_time_lt_w(omega<K>(), h_ones))) {
|
1555
|
-
continue;
|
1556
|
-
}
|
1557
|
-
|
1558
|
-
// Although computed with the private key, the signature is public.
|
1559
|
-
CONSTTIME_DECLASSIFY(values->sign.c_tilde, sizeof(values->sign.c_tilde));
|
1560
|
-
CONSTTIME_DECLASSIFY(&values->sign.z, sizeof(values->sign.z));
|
1561
|
-
CONSTTIME_DECLASSIFY(&values->sign.h, sizeof(values->sign.h));
|
1562
|
-
|
1563
|
-
CBB cbb;
|
1564
|
-
CBB_init_fixed(&cbb, out_encoded_signature, signature_bytes<K>());
|
1565
|
-
if (!mldsa_marshal_signature(&cbb, &values->sign)) {
|
1566
|
-
return 0;
|
1567
|
-
}
|
1568
|
-
|
1569
|
-
BSSL_CHECK(CBB_len(&cbb) == signature_bytes<K>());
|
1570
|
-
return 1;
|
1571
|
-
}
|
1572
|
-
}
|
1573
|
-
|
1574
|
-
// FIPS 204, Algorithm 8 (`ML-DSA.Verify_internal`).
|
1575
|
-
template <int K, int L>
|
1576
|
-
static int mldsa_verify_internal(
|
1577
|
-
const struct public_key<K> *pub,
|
1578
|
-
const uint8_t encoded_signature[signature_bytes<K>()], const uint8_t *msg,
|
1579
|
-
size_t msg_len, const uint8_t *context_prefix, size_t context_prefix_len,
|
1580
|
-
const uint8_t *context, size_t context_len) {
|
1581
|
-
// Intermediate values, allocated on the heap to allow use when there is a
|
1582
|
-
// limited amount of stack.
|
1583
|
-
struct values_st {
|
1584
|
-
struct signature<K, L> sign;
|
1585
|
-
matrix<K, L> a_ntt;
|
1586
|
-
vector<L> z_ntt;
|
1587
|
-
vector<K> az_ntt;
|
1588
|
-
vector<K> ct1_ntt;
|
1589
|
-
};
|
1590
|
-
std::unique_ptr<values_st, DeleterFree<values_st>> values(
|
1591
|
-
reinterpret_cast<struct values_st *>(OPENSSL_malloc(sizeof(values_st))));
|
1592
|
-
if (values == NULL) {
|
1593
|
-
return 0;
|
1594
|
-
}
|
1595
|
-
|
1596
|
-
CBS cbs;
|
1597
|
-
CBS_init(&cbs, encoded_signature, signature_bytes<K>());
|
1598
|
-
if (!mldsa_parse_signature(&values->sign, &cbs)) {
|
1599
|
-
return 0;
|
1600
|
-
}
|
1601
|
-
|
1602
|
-
matrix_expand(&values->a_ntt, pub->rho);
|
1603
|
-
|
1604
|
-
uint8_t mu[kMuBytes];
|
1605
|
-
struct BORINGSSL_keccak_st keccak_ctx;
|
1606
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1607
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, pub->public_key_hash,
|
1608
|
-
sizeof(pub->public_key_hash));
|
1609
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context_prefix, context_prefix_len);
|
1610
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, context, context_len);
|
1611
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, msg, msg_len);
|
1612
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, mu, kMuBytes);
|
1613
|
-
|
1614
|
-
scalar c_ntt;
|
1615
|
-
scalar_sample_in_ball_vartime(&c_ntt, values->sign.c_tilde,
|
1616
|
-
sizeof(values->sign.c_tilde), tau<K>());
|
1617
|
-
scalar_ntt(&c_ntt);
|
1618
|
-
|
1619
|
-
OPENSSL_memcpy(&values->z_ntt, &values->sign.z, sizeof(values->z_ntt));
|
1620
|
-
vector_ntt(&values->z_ntt);
|
1621
|
-
|
1622
|
-
matrix_mult(&values->az_ntt, &values->a_ntt, &values->z_ntt);
|
1623
|
-
|
1624
|
-
vector_scale_power2_round(&values->ct1_ntt, &pub->t1);
|
1625
|
-
vector_ntt(&values->ct1_ntt);
|
1626
|
-
|
1627
|
-
vector_mult_scalar(&values->ct1_ntt, &values->ct1_ntt, &c_ntt);
|
1628
|
-
|
1629
|
-
vector<K> *const w1 = &values->az_ntt;
|
1630
|
-
vector_sub(w1, &values->az_ntt, &values->ct1_ntt);
|
1631
|
-
vector_inverse_ntt(w1);
|
1632
|
-
|
1633
|
-
vector_use_hint_vartime(w1, &values->sign.h, w1);
|
1634
|
-
uint8_t w1_encoded[128 * K];
|
1635
|
-
w1_encode(w1_encoded, w1);
|
1636
|
-
|
1637
|
-
uint8_t c_tilde[2 * lambda_bytes<K>()];
|
1638
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake256);
|
1639
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, mu, kMuBytes);
|
1640
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, w1_encoded, 128 * K);
|
1641
|
-
BORINGSSL_keccak_squeeze(&keccak_ctx, c_tilde, 2 * lambda_bytes<K>());
|
1642
|
-
|
1643
|
-
uint32_t z_max = vector_max(&values->sign.z);
|
1644
|
-
return z_max < static_cast<uint32_t>(gamma1<K>() - beta<K>()) &&
|
1645
|
-
OPENSSL_memcmp(c_tilde, values->sign.c_tilde, 2 * lambda_bytes<K>()) ==
|
1646
|
-
0;
|
1647
|
-
}
|
1648
|
-
|
1649
|
-
} // namespace
|
1650
|
-
|
1651
|
-
// ML-DSA-65 specific wrappers.
|
1652
|
-
|
1653
|
-
static struct private_key<6, 5> *mldsa65_private_key_from_external(
|
1654
|
-
const struct MLDSA65_private_key *external) {
|
1655
|
-
static_assert(sizeof(struct MLDSA65_private_key) ==
|
1656
|
-
sizeof(struct private_key<6, 5>),
|
1657
|
-
"MLDSA65 private key size incorrect");
|
1658
|
-
static_assert(alignof(struct MLDSA65_private_key) ==
|
1659
|
-
alignof(struct private_key<6, 5>),
|
1660
|
-
"MLDSA65 private key align incorrect");
|
1661
|
-
return (struct private_key<6, 5> *)external;
|
1662
|
-
}
|
1663
|
-
|
1664
|
-
static struct public_key<6> *
|
1665
|
-
mldsa65_public_key_from_external(const struct MLDSA65_public_key *external) {
|
1666
|
-
static_assert(sizeof(struct MLDSA65_public_key) ==
|
1667
|
-
sizeof(struct public_key<6>),
|
1668
|
-
"MLDSA65 public key size incorrect");
|
1669
|
-
static_assert(alignof(struct MLDSA65_public_key) ==
|
1670
|
-
alignof(struct public_key<6>),
|
1671
|
-
"MLDSA65 public key align incorrect");
|
1672
|
-
return (struct public_key<6> *)external;
|
1673
|
-
}
|
1674
|
-
|
1675
|
-
int MLDSA65_parse_public_key(struct MLDSA65_public_key *public_key, CBS *in) {
|
1676
|
-
return mldsa_parse_public_key(mldsa65_public_key_from_external(public_key),
|
1677
|
-
in);
|
1678
|
-
}
|
15
|
+
#include <openssl/mldsa.h>
|
1679
16
|
|
1680
|
-
|
1681
|
-
const struct MLDSA65_private_key *private_key) {
|
1682
|
-
return mldsa_marshal_private_key(
|
1683
|
-
out, mldsa65_private_key_from_external(private_key));
|
1684
|
-
}
|
17
|
+
#include "../fipsmodule/bcm_interface.h"
|
1685
18
|
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
19
|
+
static_assert(sizeof(BCM_mldsa65_private_key) == sizeof(MLDSA65_private_key),
|
20
|
+
"");
|
21
|
+
static_assert(alignof(BCM_mldsa65_private_key) == alignof(MLDSA65_private_key),
|
22
|
+
"");
|
23
|
+
static_assert(sizeof(BCM_mldsa65_public_key) == sizeof(MLDSA65_public_key), "");
|
24
|
+
static_assert(alignof(BCM_mldsa65_public_key) == alignof(MLDSA65_public_key),
|
25
|
+
"");
|
26
|
+
static_assert(MLDSA_SEED_BYTES == BCM_MLDSA_SEED_BYTES, "");
|
27
|
+
static_assert(MLDSA65_PRIVATE_KEY_BYTES == BCM_MLDSA65_PRIVATE_KEY_BYTES, "");
|
28
|
+
static_assert(MLDSA65_PUBLIC_KEY_BYTES == BCM_MLDSA65_PUBLIC_KEY_BYTES, "");
|
29
|
+
static_assert(MLDSA65_SIGNATURE_BYTES == BCM_MLDSA65_SIGNATURE_BYTES, "");
|
1692
30
|
|
1693
|
-
// Calls |MLDSA_generate_key_external_entropy| with random bytes from
|
1694
|
-
// |RAND_bytes|. Returns 1 on success and 0 on failure.
|
1695
31
|
int MLDSA65_generate_key(
|
1696
32
|
uint8_t out_encoded_public_key[MLDSA65_PUBLIC_KEY_BYTES],
|
1697
33
|
uint8_t out_seed[MLDSA_SEED_BYTES],
|
1698
34
|
struct MLDSA65_private_key *out_private_key) {
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
35
|
+
return bcm_success(BCM_mldsa65_generate_key(
|
36
|
+
out_encoded_public_key, out_seed,
|
37
|
+
reinterpret_cast<BCM_mldsa65_private_key *>(out_private_key)));
|
1702
38
|
}
|
1703
39
|
|
1704
40
|
int MLDSA65_private_key_from_seed(struct MLDSA65_private_key *out_private_key,
|
1705
41
|
const uint8_t *seed, size_t seed_len) {
|
1706
|
-
if (seed_len !=
|
42
|
+
if (seed_len != BCM_MLDSA_SEED_BYTES) {
|
1707
43
|
return 0;
|
1708
44
|
}
|
1709
|
-
|
1710
|
-
|
1711
|
-
seed);
|
1712
|
-
}
|
1713
|
-
|
1714
|
-
int MLDSA65_generate_key_external_entropy(
|
1715
|
-
uint8_t out_encoded_public_key[MLDSA65_PUBLIC_KEY_BYTES],
|
1716
|
-
struct MLDSA65_private_key *out_private_key,
|
1717
|
-
const uint8_t entropy[MLDSA_SEED_BYTES]) {
|
1718
|
-
return mldsa_generate_key_external_entropy(
|
1719
|
-
out_encoded_public_key,
|
1720
|
-
mldsa65_private_key_from_external(out_private_key), entropy);
|
45
|
+
return bcm_success(BCM_mldsa65_private_key_from_seed(
|
46
|
+
reinterpret_cast<BCM_mldsa65_private_key *>(out_private_key), seed));
|
1721
47
|
}
|
1722
48
|
|
1723
49
|
int MLDSA65_public_from_private(struct MLDSA65_public_key *out_public_key,
|
1724
50
|
const struct MLDSA65_private_key *private_key) {
|
1725
|
-
return
|
1726
|
-
|
1727
|
-
|
51
|
+
return bcm_success(BCM_mldsa65_public_from_private(
|
52
|
+
reinterpret_cast<BCM_mldsa65_public_key *>(out_public_key),
|
53
|
+
reinterpret_cast<const BCM_mldsa65_private_key *>(private_key)));
|
1728
54
|
}
|
1729
55
|
|
1730
|
-
int MLDSA65_sign_internal(
|
1731
|
-
uint8_t out_encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
1732
|
-
const struct MLDSA65_private_key *private_key, const uint8_t *msg,
|
1733
|
-
size_t msg_len, const uint8_t *context_prefix, size_t context_prefix_len,
|
1734
|
-
const uint8_t *context, size_t context_len,
|
1735
|
-
const uint8_t randomizer[MLDSA_SIGNATURE_RANDOMIZER_BYTES]) {
|
1736
|
-
return mldsa_sign_internal(out_encoded_signature,
|
1737
|
-
mldsa65_private_key_from_external(private_key),
|
1738
|
-
msg, msg_len, context_prefix, context_prefix_len,
|
1739
|
-
context, context_len, randomizer);
|
1740
|
-
}
|
1741
|
-
|
1742
|
-
// ML-DSA signature in randomized mode, filling the random bytes with
|
1743
|
-
// |RAND_bytes|. Returns 1 on success and 0 on failure.
|
1744
56
|
int MLDSA65_sign(uint8_t out_encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
1745
57
|
const struct MLDSA65_private_key *private_key,
|
1746
58
|
const uint8_t *msg, size_t msg_len, const uint8_t *context,
|
@@ -1748,43 +60,31 @@ int MLDSA65_sign(uint8_t out_encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
|
1748
60
|
if (context_len > 255) {
|
1749
61
|
return 0;
|
1750
62
|
}
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
const uint8_t context_prefix[2] = {0, static_cast<uint8_t>(context_len)};
|
1756
|
-
return MLDSA65_sign_internal(out_encoded_signature, private_key, msg, msg_len,
|
1757
|
-
context_prefix, sizeof(context_prefix), context,
|
1758
|
-
context_len, randomizer);
|
63
|
+
return bcm_success(BCM_mldsa65_sign(
|
64
|
+
out_encoded_signature,
|
65
|
+
reinterpret_cast<const BCM_mldsa65_private_key *>(private_key), msg,
|
66
|
+
msg_len, context, context_len));
|
1759
67
|
}
|
1760
68
|
|
1761
|
-
// FIPS 204, Algorithm 3 (`ML-DSA.Verify`).
|
1762
69
|
int MLDSA65_verify(const struct MLDSA65_public_key *public_key,
|
1763
70
|
const uint8_t *signature, size_t signature_len,
|
1764
71
|
const uint8_t *msg, size_t msg_len, const uint8_t *context,
|
1765
72
|
size_t context_len) {
|
1766
|
-
if (context_len > 255 || signature_len !=
|
73
|
+
if (context_len > 255 || signature_len != BCM_MLDSA65_SIGNATURE_BYTES) {
|
1767
74
|
return 0;
|
1768
75
|
}
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
context_prefix, sizeof(context_prefix),
|
1773
|
-
context, context_len);
|
1774
|
-
}
|
1775
|
-
|
1776
|
-
int MLDSA65_verify_internal(
|
1777
|
-
const struct MLDSA65_public_key *public_key,
|
1778
|
-
const uint8_t encoded_signature[MLDSA65_SIGNATURE_BYTES],
|
1779
|
-
const uint8_t *msg, size_t msg_len, const uint8_t *context_prefix,
|
1780
|
-
size_t context_prefix_len, const uint8_t *context, size_t context_len) {
|
1781
|
-
return mldsa_verify_internal<6, 5>(
|
1782
|
-
mldsa65_public_key_from_external(public_key), encoded_signature, msg,
|
1783
|
-
msg_len, context_prefix, context_prefix_len, context, context_len);
|
76
|
+
return bcm_success(BCM_mldsa65_verify(
|
77
|
+
reinterpret_cast<const BCM_mldsa65_public_key *>(public_key), signature,
|
78
|
+
msg, msg_len, context, context_len));
|
1784
79
|
}
|
1785
80
|
|
1786
81
|
int MLDSA65_marshal_public_key(CBB *out,
|
1787
82
|
const struct MLDSA65_public_key *public_key) {
|
1788
|
-
return
|
1789
|
-
|
83
|
+
return bcm_success(BCM_mldsa65_marshal_public_key(
|
84
|
+
out, reinterpret_cast<const BCM_mldsa65_public_key *>(public_key)));
|
85
|
+
}
|
86
|
+
|
87
|
+
int MLDSA65_parse_public_key(struct MLDSA65_public_key *public_key, CBS *in) {
|
88
|
+
return bcm_success(BCM_mldsa65_parse_public_key(
|
89
|
+
reinterpret_cast<BCM_mldsa65_public_key *>(public_key), in));
|
1790
90
|
}
|