grpc 1.84.0 → 1.85.0.pre1
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 +40 -27
- data/include/grpc/event_engine/memory_allocator.h +1 -0
- data/include/grpc/grpc.h +3 -0
- data/include/grpc/grpc_security_constants.h +2 -0
- data/include/grpc/impl/channel_arg_names.h +4 -0
- data/src/core/call/call_filters.h +10 -10
- data/src/core/{lib/security/authorization → call}/evaluate_args.cc +22 -1
- data/src/core/{lib/security/authorization → call}/evaluate_args.h +19 -5
- data/src/core/call/filter_fusion.h +15 -15
- data/src/core/call/interception_chain.h +3 -3
- data/src/core/call/metadata_batch.cc +1 -0
- data/src/core/call/metadata_batch.h +45 -33
- data/src/core/call/parsed_metadata.h +3 -3
- data/src/core/call/request_buffer.cc +6 -6
- data/src/core/call/request_buffer.h +1 -1
- data/src/core/channelz/channel_trace.cc +5 -5
- data/src/core/channelz/channel_trace.h +1 -1
- data/src/core/channelz/channelz.cc +9 -9
- data/src/core/channelz/channelz.h +12 -12
- data/src/core/channelz/channelz_registry.cc +10 -10
- data/src/core/channelz/ztrace_collector.h +5 -5
- data/src/core/client_channel/client_channel.cc +4 -4
- data/src/core/client_channel/client_channel_filter.cc +14 -14
- data/src/core/client_channel/global_subchannel_pool.cc +4 -4
- data/src/core/client_channel/subchannel.cc +24 -23
- data/src/core/client_channel/subchannel_stream_client.cc +5 -5
- data/src/core/credentials/call/external/aws_external_account_credentials.cc +7 -7
- data/src/core/credentials/call/external/aws_request_signer.cc +16 -0
- data/src/core/credentials/call/external/external_account_credentials.cc +4 -4
- data/src/core/credentials/call/regional_access_boundary_fetcher.cc +9 -9
- data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +4 -4
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -3
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +1 -1
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +9 -9
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +1 -1
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +6 -6
- data/src/core/credentials/transport/tls/grpc_tls_certificate_verifier.cc +3 -3
- data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +4 -4
- data/src/core/credentials/transport/tls/ssl_utils.cc +10 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +10 -10
- data/src/core/credentials/transport/tls/tls_security_connector.h +6 -6
- data/src/core/credentials/transport/tls/tls_utils.h +9 -0
- 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 +1 -1
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +2 -2
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +1 -1
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +15 -0
- data/src/core/ext/filters/rbac/rbac_filter.h +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +5 -5
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +30 -21
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +5 -11
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +14 -11
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -4
- data/src/core/ext/transport/chttp2/transport/frame.h +9 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +12 -9
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -2
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +16 -18
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +2 -1
- data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +277 -189
- data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +40 -17
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +12 -24
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +3 -29
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/read_context.h +96 -3
- data/src/core/ext/transport/chttp2/transport/reclaimer.cc +32 -0
- data/src/core/ext/transport/chttp2/transport/reclaimer.h +64 -0
- data/src/core/ext/transport/chttp2/transport/security_frame.h +8 -8
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +17 -9
- data/src/core/ext/transport/chttp2/transport/write_cycle.h +23 -3
- data/src/core/ext/transport/inproc/inproc_transport.cc +5 -5
- data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb.h +137 -73
- data/src/core/ext/upb-gen/grpc/channelz/v1/channelz.upb_minitable.c +45 -25
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb.h +6 -6
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.c +4 -4
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/altscontext.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb.h +46 -26
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.c +17 -14
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/handshaker.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.c +3 -3
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/gcp/transport_security_common.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/grpc/health/v1/health.upb.h +329 -0
- data/src/core/ext/upb-gen/grpc/health/v1/health.upb_minitable.c +128 -0
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/health/v1/health.upb_minitable.h +8 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.c +3 -3
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lb/v1/load_balancer.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb.h +185 -23
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.c +20 -12
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls.upb_minitable.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb.h +58 -42
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.c +17 -12
- data/src/core/ext/upb-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upb_minitable.h +5 -5
- data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +567 -549
- data/src/core/ext/upbdefs-gen/grpc/lookup/v1/rls_config.upbdefs.c +182 -0
- data/src/core/ext/upbdefs-gen/{src/proto/grpc → grpc}/lookup/v1/rls_config.upbdefs.h +14 -14
- data/src/core/filter/ext_proc/ext_proc_filter.cc +1603 -46
- data/src/core/filter/ext_proc/ext_proc_filter.h +55 -22
- data/src/core/filter/ext_proc/ext_proc_messages.cc +106 -51
- data/src/core/filter/ext_proc/ext_proc_messages.h +36 -9
- data/src/core/handshaker/handshaker.cc +4 -4
- data/src/core/handshaker/http_connect/http_connect_client_handshaker.cc +3 -3
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +10 -10
- data/src/core/handshaker/security/secure_endpoint.cc +13 -13
- data/src/core/handshaker/security/security_handshaker.cc +6 -6
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +4 -4
- data/src/core/lib/channel/channel_args.cc +20 -0
- data/src/core/lib/channel/channel_args.h +17 -17
- data/src/core/lib/channel/promise_based_filter.cc +2 -2
- data/src/core/lib/channel/promise_based_filter.h +66 -27
- data/src/core/lib/debug/trace_flags.cc +2 -0
- data/src/core/lib/debug/trace_flags.h +1 -0
- data/src/core/lib/event_engine/ares_resolver.cc +14 -14
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +7 -7
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +4 -4
- data/src/core/lib/event_engine/default_event_engine.cc +5 -5
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +9 -9
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +16 -14
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +6 -6
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +3 -3
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +7 -7
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +17 -17
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/timer.cc +5 -5
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +5 -5
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +1 -1
- data/src/core/lib/event_engine/thread_pool/thread_count.cc +1 -1
- data/src/core/lib/event_engine/thread_pool/thread_count.h +3 -3
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +50 -21
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +3 -3
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +3 -3
- data/src/core/lib/event_engine/windows/windows_engine.cc +15 -15
- data/src/core/lib/event_engine/windows/windows_listener.cc +6 -6
- data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +6 -6
- data/src/core/lib/experiments/experiments.cc +48 -0
- data/src/core/lib/experiments/experiments.h +24 -0
- data/src/core/lib/iomgr/buffer_list.cc +3 -3
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/combiner.cc +0 -1
- data/src/core/lib/iomgr/ev_apple.cc +4 -4
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_posix.cc +7 -7
- data/src/core/lib/promise/activity.cc +1 -1
- data/src/core/lib/promise/activity.h +1 -1
- data/src/core/lib/promise/arena_promise.h +7 -7
- data/src/core/lib/promise/detail/promise_factory.h +8 -8
- data/src/core/lib/promise/detail/promise_like.h +4 -4
- data/src/core/lib/promise/inter_activity_latch.h +6 -6
- data/src/core/lib/promise/inter_activity_pipe.h +1 -1
- data/src/core/lib/promise/observable.h +3 -3
- data/src/core/lib/promise/party.cc +1 -1
- data/src/core/lib/promise/try_seq.h +2 -2
- data/src/core/lib/resource_quota/arena.h +3 -3
- data/src/core/lib/resource_quota/memory_quota.cc +16 -16
- data/src/core/lib/resource_quota/memory_quota.h +1 -1
- data/src/core/lib/resource_quota/thread_quota.cc +3 -3
- data/src/core/lib/security/authorization/audit_logging.cc +5 -5
- data/src/core/lib/security/authorization/authorization_engine.h +1 -1
- data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -1
- data/src/core/lib/security/authorization/grpc_server_authz_filter.h +1 -1
- data/src/core/lib/security/authorization/matchers.h +1 -1
- data/src/core/lib/surface/call.cc +8 -7
- data/src/core/lib/surface/call.h +3 -3
- data/src/core/lib/surface/call_utils.h +4 -0
- data/src/core/lib/surface/channel.cc +1 -1
- data/src/core/lib/surface/channel.h +1 -1
- data/src/core/lib/surface/channel_init.cc +1 -1
- data/src/core/lib/surface/init.cc +7 -7
- data/src/core/lib/surface/lame_client.cc +1 -1
- data/src/core/lib/surface/legacy_channel.cc +2 -2
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/transport_framing_endpoint_extension.h +3 -3
- data/src/core/load_balancing/autosharding/autosharding.cc +931 -0
- data/src/core/load_balancing/autosharding/autosharding.h +78 -0
- data/src/core/load_balancing/grpclb/grpclb_client_stats.cc +2 -2
- data/src/core/load_balancing/grpclb/load_balancer_api.cc +1 -1
- data/src/core/load_balancing/grpclb/load_balancer_api.h +3 -1
- data/src/core/load_balancing/health_check_client.cc +7 -7
- data/src/core/load_balancing/lb_policy.cc +1 -1
- data/src/core/load_balancing/oob_backend_metric.cc +5 -5
- data/src/core/load_balancing/outlier_detection/outlier_detection.cc +2 -2
- data/src/core/load_balancing/ring_hash/ring_hash.cc +109 -37
- data/src/core/load_balancing/rls/rls.cc +23 -17
- data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +10 -10
- data/src/core/load_balancing/xds/cds.cc +6 -5
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +2 -2
- data/src/core/load_balancing/xds/xds_override_host.cc +10 -10
- data/src/core/mitigation_engine/mitigation_engine.h +28 -4
- data/src/core/plugin_registry/grpc_plugin_registry.cc +2 -0
- data/src/core/resolver/dns/dns_resolver.cc +7 -7
- data/src/core/resolver/fake/fake_resolver.cc +5 -5
- data/src/core/resolver/google_c2p/google_c2p_resolver.cc +38 -30
- data/src/core/server/server.cc +30 -30
- data/src/core/server/server.h +4 -3
- data/src/core/server/server_config_selector_filter.cc +3 -3
- data/src/core/server/xds_server_config_fetcher_legacy.cc +15 -15
- data/src/core/telemetry/default_tcp_tracer.cc +1 -1
- data/src/core/telemetry/instrument.cc +30 -16
- data/src/core/telemetry/instrument.h +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +4 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +2 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +5 -5
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +3 -3
- data/src/core/tsi/ssl_transport_security.cc +46 -13
- data/src/core/tsi/ssl_transport_security.h +7 -0
- data/src/core/tsi/ssl_transport_security_utils.cc +16 -6
- data/src/core/util/event_log.cc +3 -3
- data/src/core/util/http_client/httpcli.cc +5 -5
- data/src/core/util/http_client/httpcli.h +1 -1
- data/src/core/util/json/json_object_loader.cc +7 -0
- data/src/core/util/json/json_object_loader.h +17 -2
- data/src/core/util/latent_see.cc +123 -36
- data/src/core/util/latent_see.h +14 -1
- data/src/core/util/mpscq.cc +1 -1
- data/src/core/util/notification.h +4 -4
- data/src/core/util/sync.h +20 -6
- data/src/core/util/table.h +20 -22
- data/src/core/util/work_serializer.cc +2 -2
- data/src/core/xds/grpc/blackboard.cc +4 -3
- data/src/core/xds/grpc/certificate_provider_store.cc +2 -2
- data/src/core/xds/grpc/streaming_call_promise_wrapper.cc +181 -0
- data/src/core/xds/grpc/streaming_call_promise_wrapper.h +213 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +2 -2
- data/src/core/xds/grpc/xds_client_grpc.cc +8 -8
- data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +2 -2
- data/src/core/xds/grpc/xds_endpoint.cc +1 -1
- data/src/core/xds/grpc/xds_endpoint_parser.cc +11 -0
- data/src/core/xds/grpc/xds_grpc_service_parser.cc +12 -10
- data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +17 -14
- data/src/core/xds/grpc/xds_matcher.h +2 -2
- data/src/core/xds/grpc/xds_transport_grpc.cc +125 -85
- data/src/core/xds/grpc/xds_transport_grpc.h +19 -4
- data/src/core/xds/xds_client/lrs_client.cc +22 -19
- data/src/core/xds/xds_client/xds_client.cc +19 -16
- data/src/core/xds/xds_client/xds_transport.h +49 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/generate_proto_ruby.sh +1 -1
- data/third_party/abseil-cpp/absl/algorithm/algorithm.h +34 -2
- data/third_party/abseil-cpp/absl/algorithm/container.h +345 -147
- data/third_party/abseil-cpp/absl/base/attributes.h +67 -44
- data/third_party/abseil-cpp/absl/base/call_once.h +1 -0
- data/third_party/abseil-cpp/absl/base/casts.cc +61 -0
- data/third_party/abseil-cpp/absl/base/casts.h +135 -2
- data/third_party/abseil-cpp/absl/base/config.h +63 -41
- data/third_party/abseil-cpp/absl/base/fast_type_id.h +30 -2
- data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +1 -1
- data/third_party/abseil-cpp/absl/base/internal/hardening.h +136 -0
- data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +6 -2
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +39 -4
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +6 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +77 -15
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +3 -4
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +26 -24
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +74 -29
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -11
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +52 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +5 -1
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +5 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +1 -1
- data/third_party/abseil-cpp/absl/base/macros.h +76 -37
- data/third_party/abseil-cpp/absl/base/nullability.h +5 -5
- data/third_party/abseil-cpp/absl/base/optimization.h +4 -5
- data/third_party/abseil-cpp/absl/base/options.h +46 -18
- data/third_party/abseil-cpp/absl/base/policy_checks.h +5 -5
- data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.cc → throw_delegate.cc} +9 -7
- data/third_party/abseil-cpp/absl/base/{internal/throw_delegate.h → throw_delegate.h} +4 -14
- data/third_party/abseil-cpp/absl/cleanup/cleanup.h +7 -2
- data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -2
- data/third_party/abseil-cpp/absl/container/btree_map.h +60 -10
- data/third_party/abseil-cpp/absl/container/btree_set.h +61 -15
- data/third_party/abseil-cpp/absl/container/fixed_array.h +19 -21
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +49 -27
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +50 -26
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +42 -36
- data/third_party/abseil-cpp/absl/container/internal/btree.h +32 -24
- data/third_party/abseil-cpp/absl/container/internal/btree_container.h +30 -22
- data/third_party/abseil-cpp/absl/container/internal/common.h +57 -5
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +40 -36
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +119 -39
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +14 -2
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +14 -22
- data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +52 -52
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +7 -7
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +7 -7
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +32 -40
- data/third_party/abseil-cpp/absl/container/internal/layout.h +13 -13
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +95 -72
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +633 -365
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1016 -749
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +0 -1
- data/third_party/abseil-cpp/absl/container/node_hash_map.h +58 -35
- data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +23 -6
- data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.h +7 -1
- data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -6
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +41 -0
- data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +0 -16
- data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_arm_combined.cc +5 -0
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +304 -188
- data/third_party/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +4 -2
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +2 -2
- data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.h +8 -0
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +4 -4
- data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +15 -1
- data/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h +7 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +12 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +6 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +13 -11
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +14 -7
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +3 -2
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +6 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +14 -8
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +48 -38
- data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +4 -0
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +63 -118
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +7 -47
- data/third_party/abseil-cpp/absl/debugging/symbolize.cc +20 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +83 -149
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +4 -17
- data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +4 -4
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +2 -4
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +8 -6
- data/third_party/abseil-cpp/absl/flags/declare.h +9 -0
- data/third_party/abseil-cpp/absl/flags/flag.h +2 -1
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +1 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +19 -18
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +33 -34
- data/third_party/abseil-cpp/absl/flags/internal/program_name.cc +2 -2
- data/third_party/abseil-cpp/absl/flags/marshalling.cc +1 -16
- data/third_party/abseil-cpp/absl/flags/marshalling.h +2 -28
- data/third_party/abseil-cpp/absl/flags/reflection.cc +11 -7
- data/third_party/abseil-cpp/absl/flags/usage_config.cc +2 -2
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +22 -19
- data/third_party/abseil-cpp/absl/functional/bind_front.h +7 -1
- data/third_party/abseil-cpp/absl/functional/function_ref.h +125 -20
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +43 -31
- data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +4 -4
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +44 -6
- data/third_party/abseil-cpp/absl/hash/hash.h +1 -1
- data/third_party/abseil-cpp/absl/hash/internal/city.cc +39 -51
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +379 -14
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +457 -353
- data/third_party/abseil-cpp/absl/log/absl_vlog_is_on.h +0 -2
- data/third_party/abseil-cpp/absl/log/internal/check_impl.h +2 -1
- data/third_party/abseil-cpp/absl/log/internal/check_op.cc +4 -0
- data/third_party/abseil-cpp/absl/log/internal/check_op.h +128 -50
- data/third_party/abseil-cpp/absl/log/internal/conditions.h +38 -35
- data/third_party/abseil-cpp/absl/log/internal/log_impl.h +108 -110
- data/third_party/abseil-cpp/absl/log/internal/log_message.cc +10 -6
- data/third_party/abseil-cpp/absl/log/internal/log_message.h +19 -1
- data/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc +4 -4
- data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -1
- data/third_party/abseil-cpp/absl/log/internal/proto.cc +13 -0
- data/third_party/abseil-cpp/absl/log/internal/strip.h +30 -31
- data/third_party/abseil-cpp/absl/log/internal/structured_proto.cc +5 -5
- data/third_party/abseil-cpp/absl/log/internal/structured_proto.h +6 -5
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.cc +30 -30
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +0 -1
- data/third_party/abseil-cpp/absl/log/log.h +2 -2
- data/third_party/abseil-cpp/absl/log/log_entry.cc +263 -0
- data/third_party/abseil-cpp/absl/log/log_entry.h +2 -0
- data/third_party/abseil-cpp/absl/log/vlog_is_on.h +0 -2
- data/third_party/abseil-cpp/absl/memory/memory.h +55 -5
- data/third_party/abseil-cpp/absl/meta/type_traits.h +161 -56
- data/third_party/abseil-cpp/absl/numeric/int128.h +41 -21
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +16 -22
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +5 -7
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +32 -4
- data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +9 -9
- data/third_party/abseil-cpp/absl/random/beta_distribution.h +2 -2
- data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +26 -53
- data/third_party/abseil-cpp/absl/random/discrete_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/distributions.h +17 -17
- data/third_party/abseil-cpp/absl/random/exponential_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +8 -21
- data/third_party/abseil-cpp/absl/random/internal/entropy_pool.cc +2 -2
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +2 -2
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +2 -2
- data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +6 -6
- data/third_party/abseil-cpp/absl/random/internal/platform.h +0 -13
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +6 -6
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +2 -2
- data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +6 -5
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +5 -31
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +2 -1
- data/third_party/abseil-cpp/absl/random/internal/traits.h +21 -0
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +23 -23
- data/third_party/abseil-cpp/absl/random/mocking_access.h +74 -0
- data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +63 -18
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +30 -4
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +225 -63
- data/third_party/abseil-cpp/absl/status/status.cc +66 -70
- data/third_party/abseil-cpp/absl/status/status.h +254 -23
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +3 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +117 -137
- data/third_party/abseil-cpp/absl/strings/ascii.h +10 -6
- data/third_party/abseil-cpp/absl/strings/cord.cc +41 -17
- data/third_party/abseil-cpp/absl/strings/cord.h +26 -17
- data/third_party/abseil-cpp/absl/strings/cord_buffer.h +4 -2
- data/third_party/abseil-cpp/absl/strings/escaping.cc +305 -125
- data/third_party/abseil-cpp/absl/strings/escaping.h +12 -2
- data/third_party/abseil-cpp/absl/strings/internal/append_and_overwrite.h +93 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +2 -2
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +6 -6
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +27 -21
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +11 -19
- data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +6 -0
- data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +1 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +0 -141
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +2 -24
- data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +31 -36
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +39 -39
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -22
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +2 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +2 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +921 -231
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +18 -16
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +16 -12
- data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.h +12 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +477 -8
- data/third_party/abseil-cpp/absl/strings/numbers.h +29 -12
- data/third_party/abseil-cpp/absl/strings/resize_and_overwrite.h +198 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +96 -91
- data/third_party/abseil-cpp/absl/strings/str_cat.h +53 -13
- data/third_party/abseil-cpp/absl/strings/str_split.h +14 -9
- data/third_party/abseil-cpp/absl/strings/string_view.h +10 -716
- data/third_party/abseil-cpp/absl/strings/substitute.cc +24 -24
- data/third_party/abseil-cpp/absl/strings/substitute.h +2 -2
- data/third_party/abseil-cpp/absl/synchronization/barrier.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +24 -3
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +30 -33
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +5 -0
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +41 -29
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +199 -94
- data/third_party/abseil-cpp/absl/synchronization/notification.cc +5 -5
- data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
- data/third_party/abseil-cpp/absl/time/clock.cc +29 -30
- data/third_party/abseil-cpp/absl/time/clock.h +3 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +2 -2
- data/third_party/abseil-cpp/absl/time/format.cc +3 -10
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +12 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +131 -91
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +6 -103
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +185 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.h +37 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +10 -15
- data/third_party/abseil-cpp/absl/time/time.cc +4 -4
- data/third_party/abseil-cpp/absl/time/time.h +14 -13
- data/third_party/abseil-cpp/absl/types/compare.h +64 -63
- data/third_party/abseil-cpp/absl/types/internal/span.h +6 -6
- data/third_party/abseil-cpp/absl/types/optional.h +31 -4
- data/third_party/abseil-cpp/absl/types/optional_ref.h +295 -0
- data/third_party/{boringssl-with-bazel/crypto/x509/x_val.cc → abseil-cpp/absl/types/source_location.cc} +4 -14
- data/third_party/abseil-cpp/absl/types/source_location.h +172 -0
- data/third_party/abseil-cpp/absl/types/span.h +67 -38
- data/third_party/abseil-cpp/absl/types/variant.h +75 -18
- data/third_party/abseil-cpp/absl/utility/utility.h +112 -16
- data/third_party/boringssl-with-bazel/crypto/aes/aes.cc +3 -0
- data/third_party/boringssl-with-bazel/crypto/armv8_feature_parsing.h +67 -0
- data/third_party/boringssl-with-bazel/crypto/asn1/a_bitstr.cc +143 -105
- data/third_party/boringssl-with-bazel/crypto/asn1/a_bool.cc +5 -8
- data/third_party/boringssl-with-bazel/crypto/asn1/a_d2i_fp.cc +3 -3
- data/third_party/boringssl-with-bazel/crypto/asn1/a_dup.cc +6 -6
- data/third_party/boringssl-with-bazel/crypto/asn1/a_gentm.cc +33 -12
- data/third_party/boringssl-with-bazel/crypto/asn1/a_i2d_fp.cc +7 -6
- data/third_party/boringssl-with-bazel/crypto/asn1/a_int.cc +80 -52
- data/third_party/boringssl-with-bazel/crypto/asn1/a_mbstr.cc +7 -4
- data/third_party/boringssl-with-bazel/crypto/asn1/a_object.cc +70 -72
- data/third_party/boringssl-with-bazel/crypto/asn1/a_strex.cc +38 -42
- data/third_party/boringssl-with-bazel/crypto/asn1/a_strnid.cc +41 -39
- data/third_party/boringssl-with-bazel/crypto/asn1/a_time.cc +59 -35
- data/third_party/boringssl-with-bazel/crypto/asn1/a_type.cc +275 -15
- data/third_party/boringssl-with-bazel/crypto/asn1/a_utctm.cc +32 -13
- data/third_party/boringssl-with-bazel/crypto/asn1/asn1_lib.cc +128 -30
- data/third_party/boringssl-with-bazel/crypto/asn1/asn_pack.cc +10 -10
- data/third_party/boringssl-with-bazel/crypto/asn1/f_int.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/asn1/f_string.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/asn1/internal.h +261 -115
- data/third_party/boringssl-with-bazel/crypto/asn1/posix_time.cc +8 -5
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_dec.cc +373 -725
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_enc.cc +211 -526
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_fre.cc +22 -19
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_new.cc +26 -24
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_typ.cc +19 -5
- data/third_party/boringssl-with-bazel/crypto/asn1/tasn_utl.cc +47 -51
- data/third_party/boringssl-with-bazel/crypto/base64/base64.cc +14 -15
- data/third_party/boringssl-with-bazel/crypto/bcm_support.h +7 -29
- data/third_party/boringssl-with-bazel/crypto/bio/bio.cc +234 -176
- data/third_party/boringssl-with-bazel/crypto/bio/bio_mem.cc +72 -86
- data/third_party/boringssl-with-bazel/crypto/bio/connect.cc +153 -199
- data/third_party/boringssl-with-bazel/crypto/bio/errno.cc +3 -1
- data/third_party/boringssl-with-bazel/crypto/bio/fd.cc +56 -55
- data/third_party/boringssl-with-bazel/crypto/bio/file.cc +70 -78
- data/third_party/boringssl-with-bazel/crypto/bio/hexdump.cc +6 -4
- data/third_party/boringssl-with-bazel/crypto/bio/internal.h +69 -17
- data/third_party/boringssl-with-bazel/crypto/bio/pair.cc +117 -136
- data/third_party/boringssl-with-bazel/crypto/bio/printf.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/bio/socket.cc +116 -50
- data/third_party/boringssl-with-bazel/crypto/bio/socket_helper.cc +53 -5
- data/third_party/boringssl-with-bazel/crypto/blake2/blake2.cc +9 -5
- data/third_party/boringssl-with-bazel/crypto/bn/bn_asn1.cc +2 -2
- data/third_party/boringssl-with-bazel/crypto/bn/convert.cc +56 -70
- data/third_party/boringssl-with-bazel/crypto/bn/div.cc +102 -0
- data/third_party/boringssl-with-bazel/crypto/bn/exponentiation.cc +26 -42
- data/third_party/boringssl-with-bazel/crypto/bn/sqrt.cc +93 -0
- data/third_party/boringssl-with-bazel/crypto/buf/buf.cc +6 -5
- data/third_party/boringssl-with-bazel/crypto/bytestring/asn1_compat.cc +6 -5
- data/third_party/boringssl-with-bazel/crypto/bytestring/ber.cc +22 -20
- data/third_party/boringssl-with-bazel/crypto/bytestring/cbb.cc +119 -59
- data/third_party/boringssl-with-bazel/crypto/bytestring/cbs.cc +115 -31
- data/third_party/boringssl-with-bazel/crypto/bytestring/internal.h +79 -24
- data/third_party/boringssl-with-bazel/crypto/bytestring/unicode.cc +2 -2
- data/third_party/boringssl-with-bazel/crypto/chacha/chacha.cc +5 -3
- data/third_party/boringssl-with-bazel/crypto/chacha/internal.h +23 -22
- data/third_party/boringssl-with-bazel/crypto/cipher/derive_key.cc +14 -18
- data/third_party/boringssl-with-bazel/crypto/cipher/e_aesctrhmac.cc +73 -58
- data/third_party/boringssl-with-bazel/crypto/cipher/e_aeseax.cc +132 -70
- data/third_party/boringssl-with-bazel/crypto/cipher/e_aesgcmsiv.cc +390 -249
- data/third_party/boringssl-with-bazel/crypto/cipher/e_chacha20poly1305.cc +200 -137
- data/third_party/boringssl-with-bazel/crypto/cipher/e_des.cc +45 -29
- data/third_party/boringssl-with-bazel/crypto/cipher/e_null.cc +9 -5
- data/third_party/boringssl-with-bazel/crypto/cipher/e_rc2.cc +43 -28
- data/third_party/boringssl-with-bazel/crypto/cipher/e_rc4.cc +7 -5
- data/third_party/boringssl-with-bazel/crypto/cipher/e_tls.cc +250 -237
- data/third_party/boringssl-with-bazel/crypto/cipher/get_cipher.cc +12 -12
- data/third_party/boringssl-with-bazel/crypto/cipher/internal.h +59 -59
- data/third_party/boringssl-with-bazel/crypto/cipher/tls_cbc.cc +111 -111
- data/third_party/boringssl-with-bazel/crypto/cms/cms.cc +48 -42
- data/third_party/boringssl-with-bazel/crypto/conf/conf.cc +69 -63
- data/third_party/boringssl-with-bazel/crypto/conf/internal.h +11 -12
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_apple.cc +8 -5
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_fuchsia.cc +6 -1
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_linux.cc +7 -1
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_openbsd.cc +7 -21
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_sysreg.cc +15 -41
- data/third_party/boringssl-with-bazel/crypto/cpu_aarch64_win.cc +16 -3
- data/third_party/boringssl-with-bazel/crypto/cpu_arm_freebsd.cc +4 -2
- data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.cc +54 -31
- data/third_party/boringssl-with-bazel/crypto/cpu_arm_linux.h +79 -101
- data/third_party/boringssl-with-bazel/crypto/cpu_intel.cc +51 -45
- data/third_party/boringssl-with-bazel/crypto/crypto.cc +26 -55
- data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519.cc +28 -25
- data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519_tables.h +6 -6
- data/third_party/boringssl-with-bazel/crypto/curve25519/internal.h +14 -15
- data/third_party/boringssl-with-bazel/crypto/curve25519/spake25519.cc +23 -20
- data/third_party/boringssl-with-bazel/crypto/des/des.cc +27 -19
- data/third_party/boringssl-with-bazel/crypto/des/internal.h +4 -9
- data/third_party/boringssl-with-bazel/crypto/dh/dh_asn1.cc +34 -49
- data/third_party/boringssl-with-bazel/crypto/dh/params.cc +44 -41
- data/third_party/boringssl-with-bazel/crypto/digest/digest_extra.cc +87 -40
- data/third_party/boringssl-with-bazel/crypto/dsa/dsa.cc +237 -260
- data/third_party/boringssl-with-bazel/crypto/dsa/dsa_asn1.cc +100 -173
- data/third_party/boringssl-with-bazel/crypto/dsa/internal.h +23 -21
- data/third_party/boringssl-with-bazel/crypto/ec/ec_asn1.cc +181 -209
- data/third_party/boringssl-with-bazel/crypto/ec/ec_derive.cc +26 -28
- data/third_party/boringssl-with-bazel/crypto/ec/hash_to_curve.cc +265 -174
- data/third_party/boringssl-with-bazel/crypto/ec/internal.h +54 -18
- data/third_party/boringssl-with-bazel/crypto/ecdh/ecdh.cc +7 -5
- data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_asn1.cc +50 -70
- data/third_party/boringssl-with-bazel/crypto/ecdsa/ecdsa_p1363.cc +54 -0
- data/third_party/boringssl-with-bazel/crypto/engine/engine.cc +7 -7
- data/third_party/boringssl-with-bazel/crypto/err/err.cc +116 -105
- data/third_party/boringssl-with-bazel/crypto/err/internal.h +8 -21
- data/third_party/boringssl-with-bazel/crypto/evp/evp.cc +238 -166
- data/third_party/boringssl-with-bazel/crypto/evp/evp_asn1.cc +202 -234
- data/third_party/boringssl-with-bazel/crypto/evp/evp_ctx.cc +260 -159
- data/third_party/boringssl-with-bazel/crypto/evp/evp_kem.cc +82 -0
- data/third_party/boringssl-with-bazel/crypto/evp/internal.h +292 -137
- data/third_party/boringssl-with-bazel/crypto/evp/p_dh.cc +198 -25
- data/third_party/boringssl-with-bazel/crypto/evp/p_dsa.cc +333 -0
- data/third_party/boringssl-with-bazel/crypto/evp/p_ec.cc +427 -42
- data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519.cc +270 -14
- data/third_party/boringssl-with-bazel/crypto/evp/p_hkdf.cc +70 -102
- data/third_party/boringssl-with-bazel/crypto/evp/p_mldsa.cc +549 -0
- data/third_party/boringssl-with-bazel/crypto/evp/p_mlkem.cc +485 -0
- data/third_party/boringssl-with-bazel/crypto/evp/p_rsa.cc +666 -158
- data/third_party/boringssl-with-bazel/crypto/evp/p_x25519.cc +290 -28
- data/third_party/boringssl-with-bazel/crypto/evp/p_xwing.cc +273 -0
- data/third_party/boringssl-with-bazel/crypto/evp/pbkdf.cc +14 -7
- data/third_party/boringssl-with-bazel/crypto/evp/print.cc +34 -89
- data/third_party/boringssl-with-bazel/crypto/evp/scrypt.cc +23 -21
- data/third_party/boringssl-with-bazel/crypto/evp/sign.cc +23 -42
- data/third_party/boringssl-with-bazel/crypto/ex_data.cc +40 -41
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes.cc.inc +34 -28
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes_nohw.cc.inc +119 -121
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cbc.cc.inc +16 -14
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/cfb.cc.inc +12 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ctr.cc.inc +7 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm.cc.inc +39 -29
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm_nohw.cc.inc +15 -13
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/internal.h +193 -177
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/key_wrap.cc.inc +5 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/mode_wrappers.cc.inc +7 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/ofb.cc.inc +7 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm.cc +24 -19
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm_interface.h +512 -384
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/add.cc.inc +7 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +63 -44
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bn.cc.inc +40 -37
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/bytes.cc.inc +27 -22
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/cmp.cc.inc +9 -7
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/ctx.cc.inc +62 -126
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div.cc.inc +92 -167
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/div_extra.cc.inc +15 -12
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/exponentiation.cc.inc +96 -93
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd.cc.inc +73 -92
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/gcd_extra.cc.inc +59 -71
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/generic.cc.inc +54 -57
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/internal.h +333 -255
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/jacobi.cc.inc +12 -19
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery.cc.inc +80 -95
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery_inv.cc.inc +53 -96
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/mul.cc.inc +58 -419
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/prime.cc.inc +164 -213
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/random.cc.inc +27 -26
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.cc.inc +12 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.h +47 -49
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/shift.cc.inc +14 -17
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/sqrt.cc.inc +19 -108
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/aead.cc.inc +427 -105
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/cipher.cc.inc +412 -212
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aes.cc.inc +230 -225
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/e_aesccm.cc.inc +115 -84
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/internal.h +374 -27
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/cmac/cmac.cc.inc +28 -23
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/delocate.h +36 -40
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/check.cc.inc +68 -78
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/dh.cc.inc +154 -196
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/internal.h +24 -24
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digest.cc.inc +40 -69
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/digests.cc.inc +13 -7
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/internal.h +13 -11
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digest/md32_common.h +86 -81
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/digestsign/digestsign.cc.inc +38 -34
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec.cc.inc +187 -196
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_key.cc.inc +196 -154
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_montgomery.cc.inc +65 -125
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/felem.cc.inc +85 -22
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/internal.h +281 -287
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/oct.cc.inc +23 -22
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256.cc.inc +514 -573
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256_internal.h +193 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/scalar.cc.inc +44 -39
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple.cc.inc +58 -90
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple_mul.cc.inc +39 -34
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/util.cc.inc +6 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/wnaf.cc.inc +23 -20
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdh/ecdh.cc.inc +6 -3
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +47 -37
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/internal.h +5 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/internal.h +38 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/jitter.cc.inc +463 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/sha512.cc.inc +329 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/hkdf/hkdf.cc.inc +8 -6
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/hmac/hmac.cc.inc +19 -16
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/internal.h +41 -15
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/keccak.cc.inc +172 -44
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/fips_known_values.inc +5 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/mldsa.cc.inc +1632 -766
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/fips_known_values.inc +5 -5
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/mlkem.cc.inc +740 -436
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/android_entropy_client.cc.inc +82 -0
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/ctrdrbg.cc.inc +240 -53
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/internal.h +41 -26
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rand/rand.cc.inc +221 -218
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/internal.h +64 -67
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/padding.cc.inc +49 -57
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa.cc.inc +247 -234
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa_impl.cc.inc +392 -692
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/fips.cc.inc +10 -10
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/self_check/self_check.cc.inc +479 -449
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/internal.h +34 -11
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/service_indicator/service_indicator.cc.inc +46 -43
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/internal.h +61 -70
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha1.cc.inc +27 -13
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha256.cc.inc +46 -30
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha512.cc.inc +47 -47
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/address.h +98 -73
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.cc.inc +108 -98
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.h +14 -24
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.cc.inc +94 -91
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/merkle.h +19 -31
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/params.h +156 -56
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/slhdsa.cc.inc +318 -132
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.cc.inc +234 -81
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/thash.h +20 -34
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.cc.inc +97 -96
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/wots.h +10 -20
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/internal.h +2 -16
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/tls/kdf.cc.inc +26 -26
- data/third_party/boringssl-with-bazel/crypto/fuzzer_mode.cc +5 -5
- data/third_party/boringssl-with-bazel/crypto/hpke/hpke.cc +461 -97
- data/third_party/boringssl-with-bazel/crypto/hrss/hrss.cc +153 -149
- data/third_party/boringssl-with-bazel/crypto/hrss/internal.h +9 -13
- data/third_party/boringssl-with-bazel/crypto/internal.h +531 -394
- data/third_party/boringssl-with-bazel/crypto/kyber/internal.h +117 -12
- data/third_party/boringssl-with-bazel/crypto/kyber/kyber.cc +59 -58
- data/third_party/boringssl-with-bazel/crypto/lhash/internal.h +38 -37
- data/third_party/boringssl-with-bazel/crypto/lhash/lhash.cc +68 -65
- data/third_party/boringssl-with-bazel/crypto/md4/md4.cc +19 -6
- data/third_party/boringssl-with-bazel/crypto/md5/internal.h +6 -9
- data/third_party/boringssl-with-bazel/crypto/md5/md5.cc +18 -6
- data/third_party/boringssl-with-bazel/crypto/mem.cc +61 -65
- data/third_party/boringssl-with-bazel/crypto/mem_internal.h +671 -0
- data/third_party/boringssl-with-bazel/crypto/mldsa/mldsa.cc +238 -32
- data/third_party/boringssl-with-bazel/crypto/mlkem/mlkem.cc +21 -65
- data/third_party/boringssl-with-bazel/crypto/obj/obj.cc +132 -157
- data/third_party/boringssl-with-bazel/crypto/obj/obj_dat.h +79 -1
- data/third_party/boringssl-with-bazel/crypto/obj/obj_xref.cc +14 -11
- data/third_party/boringssl-with-bazel/crypto/params_internal.h +30 -0
- data/third_party/boringssl-with-bazel/crypto/pem/internal.h +20 -15
- data/third_party/boringssl-with-bazel/crypto/pem/pem_all.cc +20 -19
- data/third_party/boringssl-with-bazel/crypto/pem/pem_info.cc +72 -76
- data/third_party/boringssl-with-bazel/crypto/pem/pem_lib.cc +215 -217
- data/third_party/boringssl-with-bazel/crypto/pem/pem_oth.cc +6 -6
- data/third_party/boringssl-with-bazel/crypto/pem/pem_pk8.cc +13 -13
- data/third_party/boringssl-with-bazel/crypto/pem/pem_pkey.cc +11 -11
- data/third_party/boringssl-with-bazel/crypto/pkcs7/internal.h +12 -17
- data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7.cc +29 -27
- data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7_x509.cc +55 -49
- data/third_party/boringssl-with-bazel/crypto/pkcs8/internal.h +21 -26
- data/third_party/boringssl-with-bazel/crypto/pkcs8/p5_pbev2.cc +33 -31
- data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8.cc +73 -81
- data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8_x509.cc +139 -138
- data/third_party/boringssl-with-bazel/crypto/poly1305/internal.h +3 -7
- data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305.cc +5 -4
- data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_arm.cc +43 -47
- data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_vec.cc +29 -26
- data/third_party/boringssl-with-bazel/crypto/pool/internal.h +64 -20
- data/third_party/boringssl-with-bazel/crypto/pool/pool.cc +177 -157
- data/third_party/boringssl-with-bazel/crypto/rand/deterministic.cc +9 -16
- data/third_party/boringssl-with-bazel/crypto/rand/fork_detect.cc +70 -42
- data/third_party/boringssl-with-bazel/crypto/rand/forkunsafe.cc +7 -7
- data/third_party/boringssl-with-bazel/crypto/rand/getentropy.cc +6 -13
- data/third_party/boringssl-with-bazel/crypto/rand/internal.h +16 -4
- data/third_party/boringssl-with-bazel/crypto/rand/ios.cc +4 -11
- data/third_party/boringssl-with-bazel/crypto/rand/rand.cc +11 -9
- data/third_party/boringssl-with-bazel/crypto/rand/trusty.cc +4 -11
- data/third_party/boringssl-with-bazel/crypto/rand/urandom.cc +16 -195
- data/third_party/boringssl-with-bazel/crypto/rand/windows.cc +12 -19
- data/third_party/boringssl-with-bazel/crypto/refcount.cc +7 -17
- data/third_party/boringssl-with-bazel/crypto/rsa/internal.h +22 -7
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_asn1.cc +199 -78
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_crypt.cc +49 -50
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_extra.cc +11 -0
- data/third_party/boringssl-with-bazel/crypto/rsa/rsa_print.cc +4 -6
- data/third_party/boringssl-with-bazel/crypto/sha/sha1.cc +3 -0
- data/third_party/boringssl-with-bazel/crypto/sha/sha256.cc +3 -1
- data/third_party/boringssl-with-bazel/crypto/sha/sha512.cc +6 -4
- data/third_party/boringssl-with-bazel/crypto/siphash/siphash.cc +2 -0
- data/third_party/boringssl-with-bazel/crypto/slhdsa/slhdsa.cc +43 -6
- data/third_party/boringssl-with-bazel/crypto/spake2plus/internal.h +31 -31
- data/third_party/boringssl-with-bazel/crypto/spake2plus/spake2plus.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/stack/stack.cc +89 -130
- data/third_party/boringssl-with-bazel/crypto/thread.cc +14 -14
- data/third_party/boringssl-with-bazel/crypto/thread_none.cc +10 -13
- data/third_party/boringssl-with-bazel/crypto/thread_pthread.cc +22 -35
- data/third_party/boringssl-with-bazel/crypto/thread_win.cc +29 -40
- data/third_party/boringssl-with-bazel/crypto/trust_token/internal.h +81 -88
- data/third_party/boringssl-with-bazel/crypto/trust_token/pmbtoken.cc +160 -144
- data/third_party/boringssl-with-bazel/crypto/trust_token/trust_token.cc +96 -80
- data/third_party/boringssl-with-bazel/crypto/trust_token/voprf.cc +90 -87
- data/third_party/boringssl-with-bazel/crypto/x509/a_digest.cc +5 -5
- data/third_party/boringssl-with-bazel/crypto/x509/a_sign.cc +51 -48
- data/third_party/boringssl-with-bazel/crypto/x509/a_verify.cc +30 -34
- data/third_party/boringssl-with-bazel/crypto/x509/algorithm.cc +47 -16
- data/third_party/boringssl-with-bazel/crypto/x509/asn1_gen.cc +41 -43
- data/third_party/boringssl-with-bazel/crypto/x509/by_dir.cc +183 -237
- data/third_party/boringssl-with-bazel/crypto/x509/by_file.cc +29 -30
- data/third_party/boringssl-with-bazel/crypto/x509/internal.h +276 -180
- data/third_party/boringssl-with-bazel/crypto/x509/name_print.cc +15 -13
- data/third_party/boringssl-with-bazel/crypto/x509/policy.cc +415 -525
- data/third_party/boringssl-with-bazel/crypto/x509/rsa_pss.cc +94 -271
- data/third_party/boringssl-with-bazel/crypto/x509/t_crl.cc +11 -8
- data/third_party/boringssl-with-bazel/crypto/x509/t_req.cc +26 -23
- data/third_party/boringssl-with-bazel/crypto/x509/t_x509.cc +26 -22
- data/third_party/boringssl-with-bazel/crypto/x509/t_x509a.cc +3 -1
- data/third_party/boringssl-with-bazel/crypto/x509/v3_akey.cc +69 -76
- data/third_party/boringssl-with-bazel/crypto/x509/v3_akeya.cc +2 -2
- data/third_party/boringssl-with-bazel/crypto/x509/v3_alt.cc +112 -69
- data/third_party/boringssl-with-bazel/crypto/x509/v3_bcons.cc +15 -14
- data/third_party/boringssl-with-bazel/crypto/x509/v3_bitst.cc +16 -18
- data/third_party/boringssl-with-bazel/crypto/x509/v3_conf.cc +62 -67
- data/third_party/boringssl-with-bazel/crypto/x509/v3_cpols.cc +143 -170
- data/third_party/boringssl-with-bazel/crypto/x509/v3_crld.cc +121 -165
- data/third_party/boringssl-with-bazel/crypto/x509/v3_enum.cc +13 -12
- data/third_party/boringssl-with-bazel/crypto/x509/v3_extku.cc +17 -34
- data/third_party/boringssl-with-bazel/crypto/x509/v3_genn.cc +20 -10
- data/third_party/boringssl-with-bazel/crypto/x509/v3_ia5.cc +22 -18
- data/third_party/boringssl-with-bazel/crypto/x509/v3_info.cc +45 -47
- data/third_party/boringssl-with-bazel/crypto/x509/v3_int.cc +35 -33
- data/third_party/boringssl-with-bazel/crypto/x509/v3_lib.cc +106 -61
- data/third_party/boringssl-with-bazel/crypto/x509/v3_ncons.cc +642 -358
- data/third_party/boringssl-with-bazel/crypto/x509/v3_ocsp.cc +25 -22
- data/third_party/boringssl-with-bazel/crypto/x509/v3_pcons.cc +15 -14
- data/third_party/boringssl-with-bazel/crypto/x509/v3_pmaps.cc +16 -15
- data/third_party/boringssl-with-bazel/crypto/x509/v3_prn.cc +6 -6
- data/third_party/boringssl-with-bazel/crypto/x509/v3_purp.cc +150 -137
- data/third_party/boringssl-with-bazel/crypto/x509/v3_skey.cc +23 -26
- data/third_party/boringssl-with-bazel/crypto/x509/v3_utl.cc +151 -178
- data/third_party/boringssl-with-bazel/crypto/x509/x509.cc +1 -1
- data/third_party/boringssl-with-bazel/crypto/x509/x509_att.cc +32 -30
- data/third_party/boringssl-with-bazel/crypto/x509/x509_cmp.cc +95 -88
- data/third_party/boringssl-with-bazel/crypto/x509/x509_d2.cc +9 -9
- data/third_party/boringssl-with-bazel/crypto/x509/x509_def.cc +6 -8
- data/third_party/boringssl-with-bazel/crypto/x509/x509_ext.cc +46 -24
- data/third_party/boringssl-with-bazel/crypto/x509/x509_lu.cc +211 -195
- data/third_party/boringssl-with-bazel/crypto/x509/x509_obj.cc +20 -16
- data/third_party/boringssl-with-bazel/crypto/x509/x509_req.cc +37 -46
- data/third_party/boringssl-with-bazel/crypto/x509/x509_set.cc +62 -90
- data/third_party/boringssl-with-bazel/crypto/x509/x509_trs.cc +18 -13
- data/third_party/boringssl-with-bazel/crypto/x509/x509_v3.cc +33 -33
- data/third_party/boringssl-with-bazel/crypto/x509/x509_vfy.cc +109 -110
- data/third_party/boringssl-with-bazel/crypto/x509/x509_vpm.cc +56 -47
- data/third_party/boringssl-with-bazel/crypto/x509/x509cset.cc +27 -40
- data/third_party/boringssl-with-bazel/crypto/x509/x509name.cc +77 -67
- data/third_party/boringssl-with-bazel/crypto/x509/x509rset.cc +5 -17
- data/third_party/boringssl-with-bazel/crypto/x509/x509spki.cc +13 -13
- data/third_party/boringssl-with-bazel/crypto/x509/x_algor.cc +131 -24
- data/third_party/boringssl-with-bazel/crypto/x509/x_all.cc +72 -39
- data/third_party/boringssl-with-bazel/crypto/x509/x_attrib.cc +10 -4
- data/third_party/boringssl-with-bazel/crypto/x509/x_crl.cc +77 -44
- data/third_party/boringssl-with-bazel/crypto/x509/x_exten.cc +6 -0
- data/third_party/boringssl-with-bazel/crypto/x509/x_name.cc +311 -383
- data/third_party/boringssl-with-bazel/crypto/x509/x_pubkey.cc +129 -82
- data/third_party/boringssl-with-bazel/crypto/x509/x_req.cc +11 -6
- data/third_party/boringssl-with-bazel/crypto/x509/x_sig.cc +4 -4
- data/third_party/boringssl-with-bazel/crypto/x509/x_spki.cc +11 -1
- data/third_party/boringssl-with-bazel/crypto/x509/x_x509.cc +285 -280
- data/third_party/boringssl-with-bazel/crypto/x509/x_x509a.cc +60 -60
- data/third_party/boringssl-with-bazel/crypto/xwing/xwing.cc +257 -0
- data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +301 -0
- data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +301 -0
- data/third_party/boringssl-with-bazel/gen/crypto/err_data.cc +526 -500
- data/third_party/boringssl-with-bazel/include/openssl/aead.h +286 -114
- data/third_party/boringssl-with-bazel/include/openssl/aes.h +43 -43
- data/third_party/boringssl-with-bazel/include/openssl/asm_base.h +29 -16
- data/third_party/boringssl-with-bazel/include/openssl/asn1.h +641 -631
- data/third_party/boringssl-with-bazel/include/openssl/asn1t.h +7 -9
- data/third_party/boringssl-with-bazel/include/openssl/base.h +34 -54
- data/third_party/boringssl-with-bazel/include/openssl/base64.h +30 -30
- data/third_party/boringssl-with-bazel/include/openssl/bio.h +373 -316
- data/third_party/boringssl-with-bazel/include/openssl/blake2.h +15 -11
- data/third_party/boringssl-with-bazel/include/openssl/blowfish.h +10 -3
- data/third_party/boringssl-with-bazel/include/openssl/bn.h +298 -306
- data/third_party/boringssl-with-bazel/include/openssl/buf.h +14 -14
- data/third_party/boringssl-with-bazel/include/openssl/bytestring.h +272 -207
- data/third_party/boringssl-with-bazel/include/openssl/cast.h +45 -8
- data/third_party/boringssl-with-bazel/include/openssl/chacha.h +3 -3
- data/third_party/boringssl-with-bazel/include/openssl/cipher.h +334 -152
- data/third_party/boringssl-with-bazel/include/openssl/cmac.h +13 -13
- data/third_party/boringssl-with-bazel/include/openssl/cms.h +35 -34
- data/third_party/boringssl-with-bazel/include/openssl/conf.h +15 -14
- data/third_party/boringssl-with-bazel/include/openssl/crypto.h +15 -13
- data/third_party/boringssl-with-bazel/include/openssl/ctrdrbg.h +49 -15
- data/third_party/boringssl-with-bazel/include/openssl/curve25519.h +24 -24
- data/third_party/boringssl-with-bazel/include/openssl/des.h +22 -16
- data/third_party/boringssl-with-bazel/include/openssl/dh.h +95 -95
- data/third_party/boringssl-with-bazel/include/openssl/digest.h +140 -71
- data/third_party/boringssl-with-bazel/include/openssl/dsa.h +101 -101
- data/third_party/boringssl-with-bazel/include/openssl/ec.h +143 -119
- data/third_party/boringssl-with-bazel/include/openssl/ec_key.h +97 -97
- data/third_party/boringssl-with-bazel/include/openssl/ecdh.h +9 -9
- data/third_party/boringssl-with-bazel/include/openssl/ecdsa.h +89 -46
- data/third_party/boringssl-with-bazel/include/openssl/engine.h +5 -5
- data/third_party/boringssl-with-bazel/include/openssl/err.h +73 -71
- data/third_party/boringssl-with-bazel/include/openssl/evp.h +824 -344
- data/third_party/boringssl-with-bazel/include/openssl/evp_errors.h +9 -2
- data/third_party/boringssl-with-bazel/include/openssl/ex_data.h +27 -32
- data/third_party/boringssl-with-bazel/include/openssl/hkdf.h +6 -6
- data/third_party/boringssl-with-bazel/include/openssl/hmac.h +31 -31
- data/third_party/boringssl-with-bazel/include/openssl/hpke.h +133 -117
- data/third_party/boringssl-with-bazel/include/openssl/hrss.h +14 -8
- data/third_party/boringssl-with-bazel/include/openssl/kdf.h +20 -19
- data/third_party/boringssl-with-bazel/include/openssl/lhash.h +4 -25
- data/third_party/boringssl-with-bazel/include/openssl/md4.h +14 -7
- data/third_party/boringssl-with-bazel/include/openssl/md5.h +7 -7
- data/third_party/boringssl-with-bazel/include/openssl/mem.h +38 -38
- data/third_party/boringssl-with-bazel/include/openssl/mldsa.h +380 -24
- data/third_party/boringssl-with-bazel/include/openssl/mlkem.h +43 -43
- data/third_party/boringssl-with-bazel/include/openssl/nid.h +1297 -2
- data/third_party/boringssl-with-bazel/include/openssl/obj.h +49 -49
- data/third_party/boringssl-with-bazel/include/openssl/opensslconf.h +30 -0
- data/third_party/boringssl-with-bazel/include/openssl/params.h +42 -0
- data/third_party/boringssl-with-bazel/include/openssl/pem.h +39 -30
- data/third_party/boringssl-with-bazel/include/openssl/pkcs7.h +40 -40
- data/third_party/boringssl-with-bazel/include/openssl/pkcs8.h +69 -63
- data/third_party/boringssl-with-bazel/include/openssl/poly1305.h +8 -5
- data/third_party/boringssl-with-bazel/include/openssl/pool.h +54 -25
- data/third_party/boringssl-with-bazel/include/openssl/posix_time.h +6 -6
- data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols.h +7866 -0
- data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_S.h +585 -0
- data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_c.h +305 -0
- data/third_party/boringssl-with-bazel/include/openssl/rand.h +18 -18
- data/third_party/boringssl-with-bazel/include/openssl/rc4.h +4 -4
- data/third_party/boringssl-with-bazel/include/openssl/ripemd.h +15 -10
- data/third_party/boringssl-with-bazel/include/openssl/rsa.h +272 -235
- data/third_party/boringssl-with-bazel/include/openssl/service_indicator.h +4 -81
- data/third_party/boringssl-with-bazel/include/openssl/sha.h +43 -166
- data/third_party/boringssl-with-bazel/include/openssl/sha2.h +201 -0
- data/third_party/boringssl-with-bazel/include/openssl/slhdsa.h +100 -48
- data/third_party/boringssl-with-bazel/include/openssl/span.h +190 -75
- data/third_party/boringssl-with-bazel/include/openssl/ssl.h +2168 -1567
- data/third_party/boringssl-with-bazel/include/openssl/ssl3.h +11 -69
- data/third_party/boringssl-with-bazel/include/openssl/stack.h +135 -80
- data/third_party/boringssl-with-bazel/include/openssl/target.h +13 -1
- data/third_party/boringssl-with-bazel/include/openssl/thread.h +0 -10
- data/third_party/boringssl-with-bazel/include/openssl/tls1.h +31 -310
- data/third_party/boringssl-with-bazel/include/openssl/tls_prf.h +47 -0
- data/third_party/boringssl-with-bazel/include/openssl/trust_token.h +97 -92
- data/third_party/boringssl-with-bazel/include/openssl/type_check.h +1 -1
- data/third_party/boringssl-with-bazel/include/openssl/x509.h +1805 -1857
- data/third_party/boringssl-with-bazel/include/openssl/x509v3.h +1 -1
- data/third_party/boringssl-with-bazel/include/openssl/xwing.h +115 -0
- data/third_party/boringssl-with-bazel/ssl/bio_ssl.cc +24 -19
- data/third_party/boringssl-with-bazel/ssl/d1_both.cc +59 -57
- data/third_party/boringssl-with-bazel/ssl/d1_lib.cc +53 -42
- data/third_party/boringssl-with-bazel/ssl/d1_pkt.cc +4 -4
- data/third_party/boringssl-with-bazel/ssl/d1_srtp.cc +2 -2
- data/third_party/boringssl-with-bazel/ssl/dtls_method.cc +10 -10
- data/third_party/boringssl-with-bazel/ssl/dtls_record.cc +6 -6
- data/third_party/boringssl-with-bazel/ssl/encrypted_client_hello.cc +61 -71
- data/third_party/boringssl-with-bazel/ssl/extensions.cc +967 -366
- data/third_party/boringssl-with-bazel/ssl/handoff.cc +77 -38
- data/third_party/boringssl-with-bazel/ssl/handshake.cc +63 -30
- data/third_party/boringssl-with-bazel/ssl/handshake_client.cc +129 -85
- data/third_party/boringssl-with-bazel/ssl/handshake_server.cc +116 -68
- data/third_party/boringssl-with-bazel/ssl/internal.h +983 -1207
- data/third_party/boringssl-with-bazel/ssl/s3_both.cc +34 -29
- data/third_party/boringssl-with-bazel/ssl/s3_lib.cc +4 -3
- data/third_party/boringssl-with-bazel/ssl/s3_pkt.cc +12 -12
- data/third_party/boringssl-with-bazel/ssl/ssl_aead_ctx.cc +5 -5
- data/third_party/boringssl-with-bazel/ssl/ssl_asn1.cc +114 -59
- data/third_party/boringssl-with-bazel/ssl/ssl_buffer.cc +17 -18
- data/third_party/boringssl-with-bazel/ssl/ssl_cert.cc +99 -61
- data/third_party/boringssl-with-bazel/ssl/ssl_cipher.cc +143 -134
- data/third_party/boringssl-with-bazel/ssl/ssl_credential.cc +188 -90
- data/third_party/boringssl-with-bazel/ssl/ssl_file.cc +132 -225
- data/third_party/boringssl-with-bazel/ssl/ssl_key_share.cc +79 -7
- data/third_party/boringssl-with-bazel/ssl/ssl_lib.cc +698 -302
- data/third_party/boringssl-with-bazel/ssl/ssl_privkey.cc +102 -45
- data/third_party/boringssl-with-bazel/ssl/ssl_session.cc +117 -102
- data/third_party/boringssl-with-bazel/ssl/ssl_transcript.cc +3 -3
- data/third_party/boringssl-with-bazel/ssl/ssl_versions.cc +24 -24
- data/third_party/boringssl-with-bazel/ssl/ssl_x509.cc +184 -170
- data/third_party/boringssl-with-bazel/ssl/t1_enc.cc +12 -10
- data/third_party/boringssl-with-bazel/ssl/tls13_both.cc +86 -54
- data/third_party/boringssl-with-bazel/ssl/tls13_client.cc +176 -90
- data/third_party/boringssl-with-bazel/ssl/tls13_enc.cc +166 -112
- data/third_party/boringssl-with-bazel/ssl/tls13_server.cc +188 -97
- data/third_party/boringssl-with-bazel/ssl/tls_method.cc +23 -23
- data/third_party/boringssl-with-bazel/ssl/tls_record.cc +17 -14
- data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_bareminimum.c.inc +47 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/bedrock_unverified_platform.c.inc +137 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/curve25519_64_adx.h +37 -33
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_64.h +4 -93
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_64_msvc.h +4 -69
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_32.br.c.inc +71 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_field_64.br.c.inc +84 -0
- data/third_party/boringssl-with-bazel/third_party/fiat/p256_point.br.c.inc +166 -0
- metadata +77 -52
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +0 -240
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +0 -56
- data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb.h +0 -157
- data/src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb_minitable.c +0 -72
- data/src/core/ext/upbdefs-gen/src/proto/grpc/lookup/v1/rls_config.upbdefs.c +0 -181
- data/third_party/abseil-cpp/absl/base/internal/identity.h +0 -39
- data/third_party/abseil-cpp/absl/base/internal/nullability_deprecated.h +0 -106
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +0 -105
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +0 -50
- data/third_party/abseil-cpp/absl/strings/string_view.cc +0 -257
- data/third_party/boringssl-with-bazel/crypto/evp/p_dh_asn1.cc +0 -142
- data/third_party/boringssl-with-bazel/crypto/evp/p_dsa_asn1.cc +0 -279
- data/third_party/boringssl-with-bazel/crypto/evp/p_ec_asn1.cc +0 -286
- data/third_party/boringssl-with-bazel/crypto/evp/p_ed25519_asn1.cc +0 -225
- data/third_party/boringssl-with-bazel/crypto/evp/p_rsa_asn1.cc +0 -198
- data/third_party/boringssl-with-bazel/crypto/evp/p_x25519_asn1.cc +0 -237
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p224-64.cc.inc +0 -1163
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.cc.inc +0 -741
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.h +0 -207
- data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/blinding.cc.inc +0 -147
- data/third_party/boringssl-with-bazel/crypto/rand/getrandom_fillin.h +0 -64
- data/third_party/boringssl-with-bazel/crypto/rand/passive.cc +0 -178
- data/third_party/boringssl-with-bazel/crypto/x509/ext_dat.h +0 -92
- data/third_party/boringssl-with-bazel/include/openssl/bcm_public.h +0 -82
- data/third_party/boringssl-with-bazel/include/openssl/experimental/kyber.h +0 -146
|
@@ -26,10 +26,19 @@
|
|
|
26
26
|
|
|
27
27
|
#include "../../internal.h"
|
|
28
28
|
#include "../bcm_interface.h"
|
|
29
|
-
#include "../delocate.h"
|
|
30
29
|
#include "../keccak/internal.h"
|
|
31
30
|
|
|
32
31
|
|
|
32
|
+
using namespace bssl;
|
|
33
|
+
|
|
34
|
+
#if defined(BORINGSSL_FIPS)
|
|
35
|
+
|
|
36
|
+
DEFINE_STATIC_ONCE(g_mlkem_keygen_self_test_once)
|
|
37
|
+
DEFINE_STATIC_ONCE(g_mlkem_encap_self_test_once)
|
|
38
|
+
DEFINE_STATIC_ONCE(g_mlkem_decap_self_test_once)
|
|
39
|
+
|
|
40
|
+
#endif
|
|
41
|
+
|
|
33
42
|
namespace mlkem {
|
|
34
43
|
namespace {
|
|
35
44
|
|
|
@@ -42,10 +51,17 @@ void ensure_decap_self_test();
|
|
|
42
51
|
// See
|
|
43
52
|
// https://csrc.nist.gov/pubs/fips/203/final
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
inline void prf(uint8_t *out, size_t out_len, const uint8_t in[33]) {
|
|
46
55
|
BORINGSSL_keccak(out, out_len, in, 33, boringssl_shake256);
|
|
47
56
|
}
|
|
48
57
|
|
|
58
|
+
#if defined(HAVE_KECCAK_X2)
|
|
59
|
+
inline void prf_x2(uint8_t *outs[2], size_t out_len,
|
|
60
|
+
const uint8_t *ins[2] /* 33 each */) {
|
|
61
|
+
BORINGSSL_keccak_short_x2(outs, out_len, ins, 33, boringssl_shake256);
|
|
62
|
+
}
|
|
63
|
+
#endif
|
|
64
|
+
|
|
49
65
|
// Section 4.1
|
|
50
66
|
void hash_h(uint8_t out[32], const uint8_t *in, size_t len) {
|
|
51
67
|
BORINGSSL_keccak(out, 32, in, len, boringssl_sha3_256);
|
|
@@ -56,21 +72,21 @@ void hash_g(uint8_t out[64], const uint8_t *in, size_t len) {
|
|
|
56
72
|
}
|
|
57
73
|
|
|
58
74
|
// This is called `J` in the spec.
|
|
59
|
-
void kdf(uint8_t out[
|
|
75
|
+
void kdf(uint8_t out[MLKEM_SHARED_SECRET_BYTES],
|
|
60
76
|
const uint8_t failure_secret[32], const uint8_t *ciphertext,
|
|
61
77
|
size_t ciphertext_len) {
|
|
62
|
-
|
|
78
|
+
BORINGSSL_keccak_st st;
|
|
63
79
|
BORINGSSL_keccak_init(&st, boringssl_shake256);
|
|
64
80
|
BORINGSSL_keccak_absorb(&st, failure_secret, 32);
|
|
65
81
|
BORINGSSL_keccak_absorb(&st, ciphertext, ciphertext_len);
|
|
66
|
-
BORINGSSL_keccak_squeeze(&st, out,
|
|
82
|
+
BORINGSSL_keccak_squeeze(&st, out, MLKEM_SHARED_SECRET_BYTES);
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
// Constants that are common across all sizes.
|
|
70
86
|
#define DEGREE 256
|
|
71
87
|
const size_t kBarrettMultiplier = 5039;
|
|
72
88
|
const unsigned kBarrettShift = 24;
|
|
73
|
-
|
|
89
|
+
const uint16_t kPrime = 3329;
|
|
74
90
|
const int kLog2Prime = 12;
|
|
75
91
|
const uint16_t kHalfPrime = (/*kPrime=*/3329 - 1) / 2;
|
|
76
92
|
// kInverseDegree is 128^-1 mod 3329; 128 because kPrime does not have a 512th
|
|
@@ -79,10 +95,10 @@ const uint16_t kInverseDegree = 3303;
|
|
|
79
95
|
|
|
80
96
|
// Rank-specific constants.
|
|
81
97
|
#define RANK768 3
|
|
82
|
-
|
|
98
|
+
const int kDU768 = 10;
|
|
83
99
|
const int kDV768 = 4;
|
|
84
100
|
#define RANK1024 4
|
|
85
|
-
|
|
101
|
+
const int kDU1024 = 11;
|
|
86
102
|
const int kDV1024 = 5;
|
|
87
103
|
|
|
88
104
|
constexpr size_t encoded_vector_size(int rank) {
|
|
@@ -93,11 +109,8 @@ constexpr size_t encoded_public_key_size(int rank) {
|
|
|
93
109
|
return encoded_vector_size(rank) + /*sizeof(rho)=*/32;
|
|
94
110
|
}
|
|
95
111
|
|
|
96
|
-
static_assert(encoded_public_key_size(RANK768) ==
|
|
97
|
-
|
|
98
|
-
static_assert(encoded_public_key_size(RANK1024) ==
|
|
99
|
-
BCM_MLKEM1024_PUBLIC_KEY_BYTES,
|
|
100
|
-
"");
|
|
112
|
+
static_assert(encoded_public_key_size(RANK768) == MLKEM768_PUBLIC_KEY_BYTES);
|
|
113
|
+
static_assert(encoded_public_key_size(RANK1024) == MLKEM1024_PUBLIC_KEY_BYTES);
|
|
101
114
|
|
|
102
115
|
constexpr size_t compressed_vector_size(int rank) {
|
|
103
116
|
// `if constexpr` isn't available in C++17.
|
|
@@ -110,13 +123,13 @@ constexpr size_t ciphertext_size(int rank) {
|
|
|
110
123
|
(rank == RANK768 ? kDV768 : kDV1024) * DEGREE / 8;
|
|
111
124
|
}
|
|
112
125
|
|
|
113
|
-
static_assert(ciphertext_size(RANK768) ==
|
|
114
|
-
static_assert(ciphertext_size(RANK1024) ==
|
|
126
|
+
static_assert(ciphertext_size(RANK768) == MLKEM768_CIPHERTEXT_BYTES);
|
|
127
|
+
static_assert(ciphertext_size(RANK1024) == MLKEM1024_CIPHERTEXT_BYTES);
|
|
115
128
|
|
|
116
|
-
|
|
129
|
+
struct scalar {
|
|
117
130
|
// On every function entry and exit, 0 <= c < kPrime.
|
|
118
131
|
uint16_t c[DEGREE];
|
|
119
|
-
}
|
|
132
|
+
};
|
|
120
133
|
|
|
121
134
|
template <int RANK>
|
|
122
135
|
struct vector {
|
|
@@ -187,7 +200,7 @@ const uint16_t kModRoots[128] = {
|
|
|
187
200
|
};
|
|
188
201
|
|
|
189
202
|
// reduce_once reduces 0 <= x < 2*kPrime, mod kPrime.
|
|
190
|
-
uint16_t reduce_once(uint16_t x) {
|
|
203
|
+
inline uint16_t reduce_once(uint16_t x) {
|
|
191
204
|
declassify_assert(x < 2 * kPrime);
|
|
192
205
|
const uint16_t subtracted = x - kPrime;
|
|
193
206
|
uint16_t mask = 0u - (subtracted >> 15);
|
|
@@ -199,13 +212,13 @@ uint16_t reduce_once(uint16_t x) {
|
|
|
199
212
|
// We usually add value barriers to selects because Clang turns consecutive
|
|
200
213
|
// selects with the same condition into a branch instead of CMOV/CSEL. This
|
|
201
214
|
// condition does not occur in ML-KEM, so omitting it seems to be safe so far,
|
|
202
|
-
// but see
|
|
215
|
+
// but see `scalar_centered_binomial_distribution_eta_2_with_prf`.
|
|
203
216
|
return (mask & x) | (~mask & subtracted);
|
|
204
217
|
}
|
|
205
218
|
|
|
206
219
|
// constant time reduce x mod kPrime using Barrett reduction. x must be less
|
|
207
220
|
// than kPrime + 2×kPrime².
|
|
208
|
-
|
|
221
|
+
inline uint16_t reduce(uint32_t x) {
|
|
209
222
|
declassify_assert(x < kPrime + 2u * kPrime * kPrime);
|
|
210
223
|
uint64_t product = (uint64_t)x * kBarrettMultiplier;
|
|
211
224
|
uint32_t quotient = (uint32_t)(product >> kBarrettShift);
|
|
@@ -213,41 +226,49 @@ static uint16_t reduce(uint32_t x) {
|
|
|
213
226
|
return reduce_once(remainder);
|
|
214
227
|
}
|
|
215
228
|
|
|
216
|
-
void scalar_zero(scalar *out) { OPENSSL_memset(out, 0, sizeof(*out)); }
|
|
229
|
+
inline void scalar_zero(scalar *out) { OPENSSL_memset(out, 0, sizeof(*out)); }
|
|
217
230
|
|
|
218
231
|
template <int RANK>
|
|
219
|
-
void vector_zero(vector<RANK> *out) {
|
|
232
|
+
inline void vector_zero(vector<RANK> *out) {
|
|
220
233
|
OPENSSL_memset(out->v, 0, sizeof(scalar) * RANK);
|
|
221
234
|
}
|
|
222
235
|
|
|
223
236
|
// In place number theoretic transform of a given scalar.
|
|
224
237
|
// Note that MLKEM's kPrime 3329 does not have a 512th root of unity, so this
|
|
225
238
|
// transform leaves off the last iteration of the usual FFT code, with the 128
|
|
226
|
-
// relevant roots of unity being stored in
|
|
239
|
+
// relevant roots of unity being stored in `kNTTRoots`. This means the output
|
|
227
240
|
// should be seen as 128 elements in GF(3329^2), with the coefficients of the
|
|
228
|
-
// elements being consecutive entries in
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
k += 2 * offset;
|
|
245
|
-
}
|
|
241
|
+
// elements being consecutive entries in `s->c`.
|
|
242
|
+
inline void scalar_ntt(scalar *s) {
|
|
243
|
+
// Manually unrolled loop to maximize vectorization.
|
|
244
|
+
#define ITER(step, offset) \
|
|
245
|
+
{ \
|
|
246
|
+
int k = 0; \
|
|
247
|
+
for (int i = 0; i < step; i++) { \
|
|
248
|
+
const uint32_t step_root = kNTTRoots[i + step]; \
|
|
249
|
+
for (int j = k; j < k + offset; j++) { \
|
|
250
|
+
uint16_t odd = reduce(step_root * s->c[j + offset]); \
|
|
251
|
+
uint16_t even = s->c[j]; \
|
|
252
|
+
s->c[j] = reduce_once(odd + even); \
|
|
253
|
+
s->c[j + offset] = reduce_once(even - odd + kPrime); \
|
|
254
|
+
} \
|
|
255
|
+
k += 2 * offset; \
|
|
256
|
+
} \
|
|
246
257
|
}
|
|
258
|
+
// for (int step = 1; step < DEGREE / 2; step <<= 1)
|
|
259
|
+
ITER(1, 128)
|
|
260
|
+
ITER(2, 64)
|
|
261
|
+
ITER(4, 32)
|
|
262
|
+
ITER(8, 16)
|
|
263
|
+
ITER(16, 8)
|
|
264
|
+
ITER(32, 4)
|
|
265
|
+
ITER(64, 2)
|
|
266
|
+
static_assert(DEGREE == 256);
|
|
267
|
+
#undef ITER
|
|
247
268
|
}
|
|
248
269
|
|
|
249
270
|
template <int RANK>
|
|
250
|
-
|
|
271
|
+
inline void vector_ntt(vector<RANK> *a) {
|
|
251
272
|
for (int i = 0; i < RANK; i++) {
|
|
252
273
|
scalar_ntt(&a->v[i]);
|
|
253
274
|
}
|
|
@@ -257,25 +278,34 @@ static void vector_ntt(vector<RANK> *a) {
|
|
|
257
278
|
// entries of s->v being interpreted as elements of GF(3329^2). Just as with the
|
|
258
279
|
// number theoretic transform, this leaves off the first step of the normal iFFT
|
|
259
280
|
// to account for the fact that 3329 does not have a 512th root of unity, using
|
|
260
|
-
// the precomputed 128 roots of unity stored in
|
|
281
|
+
// the precomputed 128 roots of unity stored in `kInverseNTTRoots`.
|
|
261
282
|
void scalar_inverse_ntt(scalar *s) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
step
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
k += 2 * offset;
|
|
277
|
-
}
|
|
283
|
+
// Manually unrolled loop to maximize vectorization.
|
|
284
|
+
#define ITER(step, offset) \
|
|
285
|
+
{ \
|
|
286
|
+
int k = 0; \
|
|
287
|
+
for (int i = 0; i < step; i++) { \
|
|
288
|
+
uint32_t step_root = kInverseNTTRoots[i + step]; \
|
|
289
|
+
for (int j = k; j < k + offset; j++) { \
|
|
290
|
+
uint16_t odd = s->c[j + offset]; \
|
|
291
|
+
uint16_t even = s->c[j]; \
|
|
292
|
+
s->c[j] = reduce_once(odd + even); \
|
|
293
|
+
s->c[j + offset] = reduce(step_root * (even - odd + kPrime)); \
|
|
294
|
+
} \
|
|
295
|
+
k += 2 * offset; \
|
|
296
|
+
} \
|
|
278
297
|
}
|
|
298
|
+
// for (int offset = 2; offset < DEGREE; offset <<= 1)
|
|
299
|
+
ITER(64, 2)
|
|
300
|
+
ITER(32, 4)
|
|
301
|
+
ITER(16, 8)
|
|
302
|
+
ITER(8, 16)
|
|
303
|
+
ITER(4, 32)
|
|
304
|
+
ITER(2, 64)
|
|
305
|
+
ITER(1, 128)
|
|
306
|
+
static_assert(DEGREE == 256);
|
|
307
|
+
#undef ITER
|
|
308
|
+
|
|
279
309
|
for (int i = 0; i < DEGREE; i++) {
|
|
280
310
|
s->c[i] = reduce(s->c[i] * kInverseDegree);
|
|
281
311
|
}
|
|
@@ -288,13 +318,13 @@ void vector_inverse_ntt(vector<RANK> *a) {
|
|
|
288
318
|
}
|
|
289
319
|
}
|
|
290
320
|
|
|
291
|
-
void scalar_add(scalar *lhs, const scalar *rhs) {
|
|
321
|
+
inline void scalar_add(scalar *lhs, const scalar *rhs) {
|
|
292
322
|
for (int i = 0; i < DEGREE; i++) {
|
|
293
323
|
lhs->c[i] = reduce_once(lhs->c[i] + rhs->c[i]);
|
|
294
324
|
}
|
|
295
325
|
}
|
|
296
326
|
|
|
297
|
-
void scalar_sub(scalar *lhs, const scalar *rhs) {
|
|
327
|
+
inline void scalar_sub(scalar *lhs, const scalar *rhs) {
|
|
298
328
|
for (int i = 0; i < DEGREE; i++) {
|
|
299
329
|
lhs->c[i] = reduce_once(lhs->c[i] - rhs->c[i] + kPrime);
|
|
300
330
|
}
|
|
@@ -304,11 +334,11 @@ void scalar_sub(scalar *lhs, const scalar *rhs) {
|
|
|
304
334
|
// 3329 does not have a 512th root of unity, this means we have to interpret
|
|
305
335
|
// the 2*ith and (2*i+1)th entries of the scalar as elements of GF(3329)[X]/(X^2
|
|
306
336
|
// - 17^(2*bitreverse(i)+1)) The value of 17^(2*bitreverse(i)+1) mod 3329 is
|
|
307
|
-
// stored in the precomputed
|
|
308
|
-
// only allows us to
|
|
337
|
+
// stored in the precomputed `kModRoots` table. Note that our Barrett transform
|
|
338
|
+
// only allows us to multiply two reduced numbers together, so we need some
|
|
309
339
|
// intermediate reduction steps, even if an uint64_t could hold 3 multiplied
|
|
310
340
|
// numbers.
|
|
311
|
-
void scalar_mult(scalar *out, const scalar *lhs, const scalar *rhs) {
|
|
341
|
+
inline void scalar_mult(scalar *out, const scalar *lhs, const scalar *rhs) {
|
|
312
342
|
for (int i = 0; i < DEGREE / 2; i++) {
|
|
313
343
|
uint32_t real_real = (uint32_t)lhs->c[2 * i] * rhs->c[2 * i];
|
|
314
344
|
uint32_t img_img = (uint32_t)lhs->c[2 * i + 1] * rhs->c[2 * i + 1];
|
|
@@ -321,14 +351,14 @@ void scalar_mult(scalar *out, const scalar *lhs, const scalar *rhs) {
|
|
|
321
351
|
}
|
|
322
352
|
|
|
323
353
|
template <int RANK>
|
|
324
|
-
void vector_add(vector<RANK> *lhs, const vector<RANK> *rhs) {
|
|
354
|
+
inline void vector_add(vector<RANK> *lhs, const vector<RANK> *rhs) {
|
|
325
355
|
for (int i = 0; i < RANK; i++) {
|
|
326
356
|
scalar_add(&lhs->v[i], &rhs->v[i]);
|
|
327
357
|
}
|
|
328
358
|
}
|
|
329
359
|
|
|
330
360
|
template <int RANK>
|
|
331
|
-
|
|
361
|
+
inline void matrix_mult(vector<RANK> *out, const matrix<RANK> *m,
|
|
332
362
|
const vector<RANK> *a) {
|
|
333
363
|
vector_zero(out);
|
|
334
364
|
for (int i = 0; i < RANK; i++) {
|
|
@@ -341,7 +371,7 @@ static void matrix_mult(vector<RANK> *out, const matrix<RANK> *m,
|
|
|
341
371
|
}
|
|
342
372
|
|
|
343
373
|
template <int RANK>
|
|
344
|
-
void matrix_mult_transpose(vector<RANK> *out, const matrix<RANK> *m,
|
|
374
|
+
inline void matrix_mult_transpose(vector<RANK> *out, const matrix<RANK> *m,
|
|
345
375
|
const vector<RANK> *a) {
|
|
346
376
|
vector_zero(out);
|
|
347
377
|
for (int i = 0; i < RANK; i++) {
|
|
@@ -354,7 +384,7 @@ void matrix_mult_transpose(vector<RANK> *out, const matrix<RANK> *m,
|
|
|
354
384
|
}
|
|
355
385
|
|
|
356
386
|
template <int RANK>
|
|
357
|
-
void scalar_inner_product(scalar *out, const vector<RANK> *lhs,
|
|
387
|
+
inline void scalar_inner_product(scalar *out, const vector<RANK> *lhs,
|
|
358
388
|
const vector<RANK> *rhs) {
|
|
359
389
|
scalar_zero(out);
|
|
360
390
|
for (int i = 0; i < RANK; i++) {
|
|
@@ -364,11 +394,25 @@ void scalar_inner_product(scalar *out, const vector<RANK> *lhs,
|
|
|
364
394
|
}
|
|
365
395
|
}
|
|
366
396
|
|
|
367
|
-
|
|
397
|
+
inline void scalar_from_keccak_block_vartime(scalar *out, int *done,
|
|
398
|
+
const uint8_t block[168]) {
|
|
399
|
+
for (size_t i = 0; i < 168 && *done < DEGREE; i += 3) {
|
|
400
|
+
uint16_t d1 = block[i] + 256 * (block[i + 1] % 16);
|
|
401
|
+
uint16_t d2 = block[i + 1] / 16 + 16 * block[i + 2];
|
|
402
|
+
if (d1 < kPrime) {
|
|
403
|
+
out->c[(*done)++] = d1;
|
|
404
|
+
}
|
|
405
|
+
if (d2 < kPrime && *done < DEGREE) {
|
|
406
|
+
out->c[(*done)++] = d2;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Algorithm 7 from the spec. Rejection samples a Keccak stream to get
|
|
368
412
|
// uniformly distributed elements. This is used for matrix expansion and only
|
|
369
413
|
// operates on public inputs.
|
|
370
|
-
|
|
371
|
-
|
|
414
|
+
inline void scalar_from_keccak_vartime(scalar *out,
|
|
415
|
+
BORINGSSL_keccak_st *keccak_ctx) {
|
|
372
416
|
assert(keccak_ctx->squeeze_offset == 0);
|
|
373
417
|
assert(keccak_ctx->rate_bytes == 168);
|
|
374
418
|
static_assert(168 % 3 == 0, "block and coefficient boundaries do not align");
|
|
@@ -377,40 +421,41 @@ static void scalar_from_keccak_vartime(scalar *out,
|
|
|
377
421
|
while (done < DEGREE) {
|
|
378
422
|
uint8_t block[168];
|
|
379
423
|
BORINGSSL_keccak_squeeze(keccak_ctx, block, sizeof(block));
|
|
380
|
-
|
|
381
|
-
uint16_t d1 = block[i] + 256 * (block[i + 1] % 16);
|
|
382
|
-
uint16_t d2 = block[i + 1] / 16 + 16 * block[i + 2];
|
|
383
|
-
if (d1 < kPrime) {
|
|
384
|
-
out->c[done++] = d1;
|
|
385
|
-
}
|
|
386
|
-
if (d2 < kPrime && done < DEGREE) {
|
|
387
|
-
out->c[done++] = d2;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
424
|
+
scalar_from_keccak_block_vartime(out, &done, block);
|
|
390
425
|
}
|
|
391
426
|
}
|
|
392
427
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
428
|
+
#if defined(HAVE_KECCAK_X2)
|
|
429
|
+
inline void scalar_from_keccak_vartime_x2(scalar *out[2],
|
|
430
|
+
BORINGSSL_keccak_st keccak_ctx[2]) {
|
|
431
|
+
assert(keccak_ctx[0].squeeze_offset == 0);
|
|
432
|
+
assert(keccak_ctx[0].rate_bytes == 168);
|
|
433
|
+
assert(keccak_ctx[1].squeeze_offset == 0);
|
|
434
|
+
assert(keccak_ctx[1].rate_bytes == 168);
|
|
435
|
+
static_assert(168 % 3 == 0, "block and coefficient boundaries do not align");
|
|
436
|
+
|
|
437
|
+
int done[2] = {0, 0};
|
|
438
|
+
while (done[0] < DEGREE || done[1] < DEGREE) {
|
|
439
|
+
uint8_t block[2][168];
|
|
440
|
+
uint8_t *blocks[] = {block[0], block[1]};
|
|
441
|
+
BORINGSSL_keccak_squeeze_x2(keccak_ctx, blocks, sizeof(block[0]));
|
|
442
|
+
scalar_from_keccak_block_vartime(out[0], &done[0], block[0]);
|
|
443
|
+
scalar_from_keccak_block_vartime(out[1], &done[1], block[1]);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
#endif
|
|
404
447
|
|
|
448
|
+
static void scalar_centered_binomial_distribution_eta_2(
|
|
449
|
+
scalar *out, const uint8_t entropy[128]) {
|
|
405
450
|
for (int i = 0; i < DEGREE; i += 2) {
|
|
406
451
|
uint8_t byte = entropy[i / 2];
|
|
407
452
|
|
|
408
453
|
uint16_t value = (byte & 1) + ((byte >> 1) & 1);
|
|
409
454
|
value -= ((byte >> 2) & 1) + ((byte >> 3) & 1);
|
|
410
|
-
// Add
|
|
455
|
+
// Add `kPrime` if `value` underflowed. See `reduce_once` for a discussion
|
|
411
456
|
// on why the value barrier is omitted. While this could have been written
|
|
412
457
|
// reduce_once(value + kPrime), this is one extra addition and small range
|
|
413
|
-
// of
|
|
458
|
+
// of `value` tempts some versions of Clang to emit a branch.
|
|
414
459
|
uint16_t mask = 0u - (value >> 15);
|
|
415
460
|
out->c[i] = ((value + kPrime) & mask) | (value & ~mask);
|
|
416
461
|
|
|
@@ -423,170 +468,388 @@ void scalar_centered_binomial_distribution_eta_2_with_prf(
|
|
|
423
468
|
}
|
|
424
469
|
}
|
|
425
470
|
|
|
471
|
+
// Algorithm 8 from the spec, with eta fixed to two and the PRF call
|
|
472
|
+
// included. Creates binominally distributed elements by sampling 2*`eta` bits,
|
|
473
|
+
// and setting the coefficient to the count of the first bits minus the count of
|
|
474
|
+
// the second bits, resulting in a centered binomial distribution. Since eta is
|
|
475
|
+
// two this gives -2/2 with a probability of 1/16, -1/1 with probability 1/4,
|
|
476
|
+
// and 0 with probability 3/8.
|
|
477
|
+
void scalar_centered_binomial_distribution_eta_2_with_prf(
|
|
478
|
+
scalar *out, const uint8_t input[33]) {
|
|
479
|
+
uint8_t entropy[128];
|
|
480
|
+
static_assert(sizeof(entropy) == 2 * /*kEta=*/2 * DEGREE / 8);
|
|
481
|
+
prf(entropy, sizeof(entropy), input);
|
|
482
|
+
scalar_centered_binomial_distribution_eta_2(out, entropy);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
#if defined(HAVE_KECCAK_X2)
|
|
486
|
+
// scalar_centered_binomial_distribution_eta_2_with_prf_x2 computes two blocks
|
|
487
|
+
// of scalar_centered_binomial_distribution_eta_2_with_prf.
|
|
488
|
+
static void scalar_centered_binomial_distribution_eta_2_with_prf_x2(
|
|
489
|
+
scalar out[2], uint8_t input[33]) {
|
|
490
|
+
uint8_t entropy[2][128];
|
|
491
|
+
static_assert(sizeof(entropy[0]) == 2 * /*kEta=*/2 * DEGREE / 8);
|
|
492
|
+
|
|
493
|
+
uint8_t input1[33];
|
|
494
|
+
OPENSSL_memcpy(input1, input, 33);
|
|
495
|
+
++input1[32]; // Counter.
|
|
496
|
+
|
|
497
|
+
uint8_t *entropies[] = {entropy[0], entropy[1]};
|
|
498
|
+
const uint8_t *inputs[2] = {input, input1};
|
|
499
|
+
prf_x2(entropies, sizeof(entropy[0]), inputs);
|
|
500
|
+
|
|
501
|
+
for (int k = 0; k < 2; k++) {
|
|
502
|
+
scalar_centered_binomial_distribution_eta_2(&out[k], entropy[k]);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
#endif
|
|
506
|
+
|
|
426
507
|
// Generates a secret vector by using
|
|
427
|
-
//
|
|
428
|
-
// appending and incrementing
|
|
508
|
+
// `scalar_centered_binomial_distribution_eta_2_with_prf`, using the given seed
|
|
509
|
+
// appending and incrementing `counter` for entry of the vector.
|
|
429
510
|
template <int RANK>
|
|
430
511
|
void vector_generate_secret_eta_2(vector<RANK> *out, uint8_t *counter,
|
|
431
512
|
const uint8_t seed[32]) {
|
|
432
513
|
uint8_t input[33];
|
|
433
514
|
OPENSSL_memcpy(input, seed, 32);
|
|
434
|
-
|
|
515
|
+
|
|
516
|
+
int i = 0;
|
|
517
|
+
#if defined(HAVE_KECCAK_X2)
|
|
518
|
+
for (; i + 2 <= RANK; i += 2) {
|
|
519
|
+
input[32] = *counter;
|
|
520
|
+
*counter += 2;
|
|
521
|
+
scalar_centered_binomial_distribution_eta_2_with_prf_x2(&out->v[i], input);
|
|
522
|
+
}
|
|
523
|
+
#endif
|
|
524
|
+
|
|
525
|
+
for (; i < RANK; i++) {
|
|
435
526
|
input[32] = (*counter)++;
|
|
436
527
|
scalar_centered_binomial_distribution_eta_2_with_prf(&out->v[i], input);
|
|
437
528
|
}
|
|
438
529
|
}
|
|
439
530
|
|
|
531
|
+
template <int RANK>
|
|
532
|
+
void matrix_expand_step(scalar *out, uint8_t input[34], int i) {
|
|
533
|
+
input[32] = i / RANK;
|
|
534
|
+
input[33] = i % RANK;
|
|
535
|
+
BORINGSSL_keccak_st keccak_ctx;
|
|
536
|
+
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake128);
|
|
537
|
+
BORINGSSL_keccak_absorb(&keccak_ctx, input, 34);
|
|
538
|
+
scalar_from_keccak_vartime(out, &keccak_ctx);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
#if defined(HAVE_KECCAK_X2)
|
|
542
|
+
template <int RANK>
|
|
543
|
+
void matrix_expand_step_x2(matrix<RANK> out[2], uint8_t input[34], int i) {
|
|
544
|
+
input[32] = i / RANK;
|
|
545
|
+
input[33] = i % RANK;
|
|
546
|
+
uint8_t input1[34];
|
|
547
|
+
OPENSSL_memcpy(input1, input, 32);
|
|
548
|
+
input1[32] = (i + 1) / RANK;
|
|
549
|
+
input1[33] = (i + 1) % RANK;
|
|
550
|
+
BORINGSSL_keccak_st keccak_ctx[2];
|
|
551
|
+
BORINGSSL_keccak_init(&keccak_ctx[0], boringssl_shake128);
|
|
552
|
+
BORINGSSL_keccak_init(&keccak_ctx[1], boringssl_shake128);
|
|
553
|
+
BORINGSSL_keccak_absorb(&keccak_ctx[0], input, 34);
|
|
554
|
+
BORINGSSL_keccak_absorb(&keccak_ctx[1], input1, 34);
|
|
555
|
+
scalar *outs[] = {&out->v[i / RANK][i % RANK],
|
|
556
|
+
&out->v[(i + 1) / RANK][(i + 1) % RANK]};
|
|
557
|
+
scalar_from_keccak_vartime_x2(outs, keccak_ctx);
|
|
558
|
+
}
|
|
559
|
+
#endif
|
|
560
|
+
|
|
440
561
|
// Expands the matrix of a seed for key generation and for encaps-CPA.
|
|
441
562
|
template <int RANK>
|
|
442
563
|
void matrix_expand(matrix<RANK> *out, const uint8_t rho[32]) {
|
|
443
564
|
uint8_t input[34];
|
|
444
565
|
OPENSSL_memcpy(input, rho, 32);
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
BORINGSSL_keccak_init(&keccak_ctx, boringssl_shake128);
|
|
451
|
-
BORINGSSL_keccak_absorb(&keccak_ctx, input, sizeof(input));
|
|
452
|
-
scalar_from_keccak_vartime(&out->v[i][j], &keccak_ctx);
|
|
453
|
-
}
|
|
566
|
+
|
|
567
|
+
int i = 0;
|
|
568
|
+
#if defined(HAVE_KECCAK_X2)
|
|
569
|
+
for (; i + 2 <= RANK * RANK; i += 2) {
|
|
570
|
+
matrix_expand_step_x2(out, input, i);
|
|
454
571
|
}
|
|
455
|
-
|
|
572
|
+
#endif
|
|
456
573
|
|
|
457
|
-
|
|
574
|
+
for (; i < RANK * RANK; i++) {
|
|
575
|
+
matrix_expand_step<RANK>(&out->v[i / RANK][i % RANK], input, i);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
458
578
|
|
|
459
|
-
|
|
460
|
-
|
|
579
|
+
// Encodes a scalar of 256 `BITS`-bit words into 32*`BITS` bytes by splitting
|
|
580
|
+
// and joining into bytes using LSB-first bit order (i.e. opposite to standard
|
|
581
|
+
// reading order). See below for examples. If an input is >= 1 << `BITS`, the
|
|
582
|
+
// result is undefined.
|
|
583
|
+
template <int BITS>
|
|
584
|
+
void scalar_encode(uint8_t *out, const scalar *s);
|
|
585
|
+
|
|
586
|
+
// Encodes a scalar of 256 10-bit words into 320 bytes as follows:
|
|
587
|
+
// 000000Aaaaaaaaaa 000000Bbbbbbbbbb 000000Cccccccccc 000000Dddddddddd ...
|
|
588
|
+
// -> aaaaaaaa bbbbbbAa ccccBbbb ddCccccc Dddddddd ...
|
|
589
|
+
template <>
|
|
590
|
+
void scalar_encode<10>(uint8_t out[320], const scalar *s) {
|
|
591
|
+
for (int i = 0; i < DEGREE; i += 4) {
|
|
592
|
+
uint16_t s0 = s->c[i];
|
|
593
|
+
uint16_t s1 = s->c[i + 1];
|
|
594
|
+
uint16_t s2 = s->c[i + 2];
|
|
595
|
+
uint16_t s3 = s->c[i + 3];
|
|
596
|
+
declassify_assert((s0 | s1 | s2 | s3) < (1 << 10));
|
|
597
|
+
out[0] = (uint8_t)s0;
|
|
598
|
+
out[1] = (uint8_t)((s0 >> 8) | (s1 << 2));
|
|
599
|
+
out[2] = (uint8_t)((s1 >> 6) | (s2 << 4));
|
|
600
|
+
out[3] = (uint8_t)((s2 >> 4) | (s3 << 6));
|
|
601
|
+
out[4] = (uint8_t)(s3 >> 2);
|
|
602
|
+
out += 5;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
461
605
|
|
|
462
|
-
|
|
463
|
-
|
|
606
|
+
// Encodes a scalar of 256 12-bit words into 384 bytes as follows:
|
|
607
|
+
// 0000Aaaaaaaaaaaa 0000Bbbbbbbbbbbb 0000Cccccccccccc 0000Dddddddddddd ...
|
|
608
|
+
// -> aaaaaaaa bbbbAaaa Bbbbbbbb cccccccc ddddCccc Dddddddd ....
|
|
609
|
+
template <>
|
|
610
|
+
void scalar_encode<12>(uint8_t out[384], const scalar *s) {
|
|
611
|
+
for (int i = 0; i < DEGREE; i += 2) {
|
|
612
|
+
uint16_t s0 = s->c[i];
|
|
613
|
+
uint16_t s1 = s->c[i + 1];
|
|
614
|
+
declassify_assert((s0 | s1) < (1 << 12));
|
|
615
|
+
out[0] = (uint8_t)s0;
|
|
616
|
+
out[1] = (uint8_t)((s0 >> 8) | (s1 << 4));
|
|
617
|
+
out[2] = (uint8_t)(s1 >> 4);
|
|
618
|
+
out += 3;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
464
621
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
out_byte = 0;
|
|
479
|
-
} else {
|
|
480
|
-
out_byte |= (element & kMasks[chunk_bits - 1]) << out_byte_bits;
|
|
481
|
-
out_byte_bits += chunk_bits;
|
|
482
|
-
}
|
|
622
|
+
// Encodes a scalar of 256 4-bit words into 128 bytes as follows:
|
|
623
|
+
// 000000000000Aaaa 00000000000Bbbb 000000000000Cccc 000000000000Dddd ...
|
|
624
|
+
// -> BbbbAaaa DdddCccc ...
|
|
625
|
+
template <>
|
|
626
|
+
void scalar_encode<4>(uint8_t out[128], const scalar *s) {
|
|
627
|
+
for (int i = 0; i < DEGREE; i += 2) {
|
|
628
|
+
uint16_t s0 = s->c[i];
|
|
629
|
+
uint16_t s1 = s->c[i + 1];
|
|
630
|
+
declassify_assert((s0 | s1) < (1 << 4));
|
|
631
|
+
out[0] = (uint8_t)(s0 | (s1 << 4));
|
|
632
|
+
out += 1;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
483
635
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
636
|
+
// Encodes a scalar of 256 11-bit words into 352 bytes as follows:
|
|
637
|
+
// 00000Aaaaaaaaaaa 00000Bbbbbbbbbbb 00000Ccccccccccc 00000Ddddddddddd ...
|
|
638
|
+
// -> aaaaaaaa bbbbbAaa ccBbbbbb cccccccc dddddddC eeeeDddd fEeeeeee ...
|
|
639
|
+
template <>
|
|
640
|
+
void scalar_encode<11>(uint8_t out[352], const scalar *s) {
|
|
641
|
+
for (int i = 0; i < DEGREE; i += 8) {
|
|
642
|
+
uint16_t s0 = s->c[i];
|
|
643
|
+
uint16_t s1 = s->c[i + 1];
|
|
644
|
+
uint16_t s2 = s->c[i + 2];
|
|
645
|
+
uint16_t s3 = s->c[i + 3];
|
|
646
|
+
uint16_t s4 = s->c[i + 4];
|
|
647
|
+
uint16_t s5 = s->c[i + 5];
|
|
648
|
+
uint16_t s6 = s->c[i + 6];
|
|
649
|
+
uint16_t s7 = s->c[i + 7];
|
|
650
|
+
declassify_assert((s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7) < (1 << 11));
|
|
651
|
+
out[0] = (uint8_t)s0;
|
|
652
|
+
out[1] = (uint8_t)((s0 >> 8) | (s1 << 3));
|
|
653
|
+
out[2] = (uint8_t)((s1 >> 5) | (s2 << 6));
|
|
654
|
+
out[3] = (uint8_t)(s2 >> 2);
|
|
655
|
+
out[4] = (uint8_t)((s2 >> 10) | (s3 << 1));
|
|
656
|
+
out[5] = (uint8_t)((s3 >> 7) | (s4 << 4));
|
|
657
|
+
out[6] = (uint8_t)((s4 >> 4) | (s5 << 7));
|
|
658
|
+
out[7] = (uint8_t)(s5 >> 1);
|
|
659
|
+
out[8] = (uint8_t)((s5 >> 9) | (s6 << 2));
|
|
660
|
+
out[9] = (uint8_t)((s6 >> 6) | (s7 << 5));
|
|
661
|
+
out[10] = (uint8_t)(s7 >> 3);
|
|
662
|
+
out += 11;
|
|
487
663
|
}
|
|
664
|
+
}
|
|
488
665
|
|
|
489
|
-
|
|
490
|
-
|
|
666
|
+
// Encodes a scalar of 256 5-bit words into 160 bytes as follows:
|
|
667
|
+
// 00000000000Aaaaa 00000000000Bbbbb 00000000000Ccccc 00000000000Ddddd ...
|
|
668
|
+
// -> bbbAaaaa dCccccBb eeeeDddd ggFffffE HhhhhGgg ...
|
|
669
|
+
template <>
|
|
670
|
+
void scalar_encode<5>(uint8_t out[160], const scalar *s) {
|
|
671
|
+
for (int i = 0; i < DEGREE; i += 8) {
|
|
672
|
+
uint16_t s0 = s->c[i];
|
|
673
|
+
uint16_t s1 = s->c[i + 1];
|
|
674
|
+
uint16_t s2 = s->c[i + 2];
|
|
675
|
+
uint16_t s3 = s->c[i + 3];
|
|
676
|
+
uint16_t s4 = s->c[i + 4];
|
|
677
|
+
uint16_t s5 = s->c[i + 5];
|
|
678
|
+
uint16_t s6 = s->c[i + 6];
|
|
679
|
+
uint16_t s7 = s->c[i + 7];
|
|
680
|
+
declassify_assert((s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7) < (1 << 5));
|
|
681
|
+
out[0] = (uint8_t)(s0 | (s1 << 5));
|
|
682
|
+
out[1] = (uint8_t)((s1 >> 3) | (s2 << 2) | (s3 << 7));
|
|
683
|
+
out[2] = (uint8_t)((s3 >> 1) | (s4 << 4));
|
|
684
|
+
out[3] = (uint8_t)((s4 >> 4) | (s5 << 1) | (s6 << 6));
|
|
685
|
+
out[4] = (uint8_t)((s6 >> 2) | (s7 << 3));
|
|
686
|
+
out += 5;
|
|
491
687
|
}
|
|
492
688
|
}
|
|
493
689
|
|
|
494
|
-
//
|
|
495
|
-
|
|
690
|
+
// Encodes a scalar of 256 1-bit "words" into 32 bytes as follows:
|
|
691
|
+
// 0000000000000A 000000000000000B 000000000000000C 000000000000000D ...
|
|
692
|
+
// -> HGFEDCBA PONMLKJI XWVUTSRQ ...
|
|
693
|
+
// This order is best understood as the natural way of joining into bytes
|
|
694
|
+
// assuming LSB-first bit order.
|
|
695
|
+
template <>
|
|
696
|
+
void scalar_encode<1>(uint8_t out[32], const scalar *s) {
|
|
496
697
|
for (int i = 0; i < DEGREE; i += 8) {
|
|
497
698
|
uint8_t out_byte = 0;
|
|
498
699
|
for (int j = 0; j < 8; j++) {
|
|
499
|
-
|
|
700
|
+
declassify_assert(s->c[i + j] <= 1);
|
|
701
|
+
out_byte |= s->c[i + j] << j;
|
|
500
702
|
}
|
|
501
|
-
|
|
502
|
-
out++;
|
|
703
|
+
out[i / 8] = out_byte;
|
|
503
704
|
}
|
|
504
705
|
}
|
|
505
706
|
|
|
506
|
-
// Encodes an entire vector into 32
|
|
707
|
+
// Encodes an entire vector into 32*`RANK`*`bits` bytes. Note that since 256
|
|
507
708
|
// (DEGREE) is divisible by 8, the individual vector entries will always fill a
|
|
508
709
|
// whole number of bytes, so we do not need to worry about bit packing here.
|
|
509
|
-
template <int RANK>
|
|
510
|
-
void vector_encode(uint8_t *out, const vector<RANK> *a
|
|
710
|
+
template <int bits, int RANK>
|
|
711
|
+
void vector_encode(uint8_t *out, const vector<RANK> *a) {
|
|
511
712
|
for (int i = 0; i < RANK; i++) {
|
|
512
|
-
scalar_encode(out + i * bits * DEGREE / 8, &a->v[i]
|
|
713
|
+
scalar_encode<bits>(out + i * bits * DEGREE / 8, &a->v[i]);
|
|
513
714
|
}
|
|
514
715
|
}
|
|
515
716
|
|
|
516
|
-
//
|
|
517
|
-
//
|
|
518
|
-
//
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
uint16_t
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
717
|
+
// The inverse of `scalar_encode`. Returns 1 iff the encoded scalar is valid,
|
|
718
|
+
// i.e. all components are < `kPrime`. Otherwise, returns 0 and the value of
|
|
719
|
+
// `out` is undefined.
|
|
720
|
+
template <int BITS>
|
|
721
|
+
int scalar_decode(scalar *out, const uint8_t *in);
|
|
722
|
+
|
|
723
|
+
template <>
|
|
724
|
+
int scalar_decode<10>(scalar *out, const uint8_t in[320]) {
|
|
725
|
+
for (int i = 0; i < DEGREE; i += 4) {
|
|
726
|
+
uint16_t s0 = (uint16_t)(in[0] | ((in[1] & 0x03) << 8));
|
|
727
|
+
uint16_t s1 = (uint16_t)((in[1] >> 2) | ((in[2] & 0x0f) << 6));
|
|
728
|
+
uint16_t s2 = (uint16_t)((in[2] >> 4) | ((in[3] & 0x3f) << 4));
|
|
729
|
+
uint16_t s3 = (uint16_t)((in[3] >> 6) | (in[4] << 2));
|
|
730
|
+
out->c[i] = s0;
|
|
731
|
+
out->c[i + 1] = s1;
|
|
732
|
+
out->c[i + 2] = s2;
|
|
733
|
+
out->c[i + 3] = s3;
|
|
734
|
+
in += 5;
|
|
735
|
+
}
|
|
736
|
+
return 1;
|
|
737
|
+
}
|
|
535
738
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
739
|
+
template <>
|
|
740
|
+
int scalar_decode<12>(scalar *out, const uint8_t in[384]) {
|
|
741
|
+
for (int i = 0; i < DEGREE; i += 2) {
|
|
742
|
+
uint16_t s0 = (uint16_t)(in[0] | ((in[1] & 0x0f) << 8));
|
|
743
|
+
uint16_t s1 = (uint16_t)((in[1] >> 4) | (in[2] << 4));
|
|
744
|
+
if (constant_time_declassify_int((s0 | s1) >= kPrime)) {
|
|
745
|
+
if (s0 >= kPrime || s1 >= kPrime) {
|
|
746
|
+
return 0;
|
|
539
747
|
}
|
|
540
|
-
|
|
541
|
-
element |= (in_byte & kMasks[chunk_bits - 1]) << element_bits_done;
|
|
542
|
-
in_byte_bits_left -= chunk_bits;
|
|
543
|
-
in_byte >>= chunk_bits;
|
|
544
|
-
|
|
545
|
-
element_bits_done += chunk_bits;
|
|
546
748
|
}
|
|
749
|
+
out->c[i] = s0;
|
|
750
|
+
out->c[i + 1] = s1;
|
|
751
|
+
in += 3;
|
|
752
|
+
}
|
|
753
|
+
return 1;
|
|
754
|
+
}
|
|
547
755
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
756
|
+
template <>
|
|
757
|
+
int scalar_decode<4>(scalar *out, const uint8_t in[128]) {
|
|
758
|
+
for (int i = 0; i < DEGREE; i += 2) {
|
|
759
|
+
uint16_t s0 = (uint16_t)(in[0] & 0x0f);
|
|
760
|
+
uint16_t s1 = (uint16_t)(in[0] >> 4);
|
|
761
|
+
// kPrime is 3329, so 4-bit values are always < kPrime.
|
|
762
|
+
out->c[i] = s0;
|
|
763
|
+
out->c[i + 1] = s1;
|
|
764
|
+
in += 1;
|
|
765
|
+
}
|
|
766
|
+
return 1;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// scalar_decode parses `DEGREE * bits` bits from `in` into `DEGREE` values in
|
|
770
|
+
// `out`. It returns one on success and zero if any parsed value is >=
|
|
771
|
+
// `kPrime`.
|
|
772
|
+
template <>
|
|
773
|
+
int scalar_decode<11>(scalar *out, const uint8_t in[352]) {
|
|
774
|
+
for (int i = 0; i < DEGREE; i += 8) {
|
|
775
|
+
uint16_t s0 = (uint16_t)(in[0] | ((in[1] & 0x07) << 8));
|
|
776
|
+
uint16_t s1 = (uint16_t)((in[1] >> 3) | ((in[2] & 0x3f) << 5));
|
|
777
|
+
uint16_t s2 =
|
|
778
|
+
(uint16_t)((in[2] >> 6) | (in[3] << 2) | ((in[4] & 0x01) << 10));
|
|
779
|
+
uint16_t s3 = (uint16_t)((in[4] >> 1) | ((in[5] & 0x0f) << 7));
|
|
780
|
+
uint16_t s4 = (uint16_t)((in[5] >> 4) | ((in[6] & 0x7f) << 4));
|
|
781
|
+
uint16_t s5 =
|
|
782
|
+
(uint16_t)((in[6] >> 7) | (in[7] << 1) | ((in[8] & 0x03) << 9));
|
|
783
|
+
uint16_t s6 = (uint16_t)((in[8] >> 2) | ((in[9] & 0x1f) << 6));
|
|
784
|
+
uint16_t s7 = (uint16_t)((in[9] >> 5) | (in[10] << 3));
|
|
785
|
+
out->c[i] = s0;
|
|
786
|
+
out->c[i + 1] = s1;
|
|
787
|
+
out->c[i + 2] = s2;
|
|
788
|
+
out->c[i + 3] = s3;
|
|
789
|
+
out->c[i + 4] = s4;
|
|
790
|
+
out->c[i + 5] = s5;
|
|
791
|
+
out->c[i + 6] = s6;
|
|
792
|
+
out->c[i + 7] = s7;
|
|
793
|
+
in += 11;
|
|
554
794
|
}
|
|
795
|
+
return 1;
|
|
796
|
+
}
|
|
555
797
|
|
|
798
|
+
template <>
|
|
799
|
+
int scalar_decode<5>(scalar *out, const uint8_t in[160]) {
|
|
800
|
+
for (int i = 0; i < DEGREE; i += 8) {
|
|
801
|
+
uint16_t s0 = (uint16_t)(in[0] & 0x1f);
|
|
802
|
+
uint16_t s1 = (uint16_t)((in[0] >> 5) | ((in[1] & 0x03) << 3));
|
|
803
|
+
uint16_t s2 = (uint16_t)((in[1] >> 2) & 0x1f);
|
|
804
|
+
uint16_t s3 = (uint16_t)((in[1] >> 7) | ((in[2] & 0x0f) << 1));
|
|
805
|
+
uint16_t s4 = (uint16_t)((in[2] >> 4) | ((in[3] & 0x01) << 4));
|
|
806
|
+
uint16_t s5 = (uint16_t)((in[3] >> 1) & 0x1f);
|
|
807
|
+
uint16_t s6 = (uint16_t)((in[3] >> 6) | ((in[4] & 0x07) << 2));
|
|
808
|
+
uint16_t s7 = (uint16_t)(in[4] >> 3);
|
|
809
|
+
// kPrime is 3329, so 5-bit values are always < kPrime.
|
|
810
|
+
out->c[i] = s0;
|
|
811
|
+
out->c[i + 1] = s1;
|
|
812
|
+
out->c[i + 2] = s2;
|
|
813
|
+
out->c[i + 3] = s3;
|
|
814
|
+
out->c[i + 4] = s4;
|
|
815
|
+
out->c[i + 5] = s5;
|
|
816
|
+
out->c[i + 6] = s6;
|
|
817
|
+
out->c[i + 7] = s7;
|
|
818
|
+
in += 5;
|
|
819
|
+
}
|
|
556
820
|
return 1;
|
|
557
821
|
}
|
|
558
822
|
|
|
559
|
-
|
|
560
|
-
|
|
823
|
+
template <>
|
|
824
|
+
int scalar_decode<1>(scalar *out, const uint8_t in[32]) {
|
|
561
825
|
for (int i = 0; i < DEGREE; i += 8) {
|
|
562
|
-
uint8_t in_byte =
|
|
563
|
-
in++;
|
|
826
|
+
uint8_t in_byte = in[i / 8];
|
|
564
827
|
for (int j = 0; j < 8; j++) {
|
|
565
|
-
out->c[i + j] = in_byte & 1;
|
|
566
|
-
in_byte >>= 1;
|
|
828
|
+
out->c[i + j] = (in_byte >> j) & 1;
|
|
567
829
|
}
|
|
568
830
|
}
|
|
831
|
+
return 1;
|
|
569
832
|
}
|
|
570
833
|
|
|
571
|
-
// Decodes 32
|
|
572
|
-
// success or zero if any parsed value is >=
|
|
573
|
-
template <int RANK>
|
|
574
|
-
|
|
834
|
+
// Decodes 32*`RANK`*`bits` bytes from `in` into `out`. It returns one on
|
|
835
|
+
// success or zero if any parsed value is >= `kPrime`.
|
|
836
|
+
template <int bits, int RANK>
|
|
837
|
+
inline int vector_decode(vector<RANK> *out, const uint8_t *in) {
|
|
575
838
|
for (int i = 0; i < RANK; i++) {
|
|
576
|
-
if (!scalar_decode(&out->v[i], in + i * bits * DEGREE / 8
|
|
839
|
+
if (!scalar_decode<bits>(&out->v[i], in + i * bits * DEGREE / 8)) {
|
|
577
840
|
return 0;
|
|
578
841
|
}
|
|
579
842
|
}
|
|
580
843
|
return 1;
|
|
581
844
|
}
|
|
582
845
|
|
|
583
|
-
// Compresses (lossily) an input
|
|
846
|
+
// Compresses (lossily) an input `x` mod 3329 into `bits` many bits by grouping
|
|
584
847
|
// numbers close to each other together. The formula used is
|
|
585
|
-
// round(2
|
|
848
|
+
// round(2^`bits`/kPrime*x) mod 2^`bits`.
|
|
586
849
|
// Uses Barrett reduction to achieve constant time. Since we need both the
|
|
587
850
|
// remainder (for rounding) and the quotient (as the result), we cannot use
|
|
588
|
-
//
|
|
589
|
-
|
|
851
|
+
// `reduce` here, but need to do the Barrett reduction directly.
|
|
852
|
+
inline uint16_t compress(uint16_t x, int bits) {
|
|
590
853
|
uint32_t shifted = (uint32_t)x << bits;
|
|
591
854
|
uint64_t product = (uint64_t)shifted * kBarrettMultiplier;
|
|
592
855
|
uint32_t quotient = (uint32_t)(product >> kBarrettShift);
|
|
@@ -602,30 +865,30 @@ static uint16_t compress(uint16_t x, int bits) {
|
|
|
602
865
|
return quotient & ((1 << bits) - 1);
|
|
603
866
|
}
|
|
604
867
|
|
|
605
|
-
// Decompresses
|
|
606
|
-
// round(kPrime/2
|
|
868
|
+
// Decompresses `x` by using an equi-distant representative. The formula is
|
|
869
|
+
// round(kPrime/2^`bits`*x). Note that 2^`bits` being the divisor allows us to
|
|
607
870
|
// implement this logic using only bit operations.
|
|
608
|
-
uint16_t decompress(uint16_t x, int bits) {
|
|
871
|
+
inline uint16_t decompress(uint16_t x, int bits) {
|
|
609
872
|
uint32_t product = (uint32_t)x * kPrime;
|
|
610
873
|
uint32_t power = 1 << bits;
|
|
611
|
-
// This is
|
|
874
|
+
// This is `product` % power, since `power` is a power of 2.
|
|
612
875
|
uint32_t remainder = product & (power - 1);
|
|
613
|
-
// This is
|
|
876
|
+
// This is `product` / power, since `power` is a power of 2.
|
|
614
877
|
uint32_t lower = product >> bits;
|
|
615
|
-
// The rounding logic works since the first half of numbers mod
|
|
616
|
-
// 0 as first bit, and the second half has a 1 as first bit, since
|
|
617
|
-
// a power of 2. As a 12 bit number,
|
|
878
|
+
// The rounding logic works since the first half of numbers mod `power` have a
|
|
879
|
+
// 0 as first bit, and the second half has a 1 as first bit, since `power` is
|
|
880
|
+
// a power of 2. As a 12 bit number, `remainder` is always positive, so we
|
|
618
881
|
// will shift in 0s for a right shift.
|
|
619
882
|
return lower + (remainder >> (bits - 1));
|
|
620
883
|
}
|
|
621
884
|
|
|
622
|
-
|
|
885
|
+
inline void scalar_compress(scalar *s, int bits) {
|
|
623
886
|
for (int i = 0; i < DEGREE; i++) {
|
|
624
887
|
s->c[i] = compress(s->c[i], bits);
|
|
625
888
|
}
|
|
626
889
|
}
|
|
627
890
|
|
|
628
|
-
|
|
891
|
+
inline void scalar_decompress(scalar *s, int bits) {
|
|
629
892
|
for (int i = 0; i < DEGREE; i++) {
|
|
630
893
|
s->c[i] = decompress(s->c[i], bits);
|
|
631
894
|
}
|
|
@@ -655,51 +918,56 @@ struct public_key {
|
|
|
655
918
|
|
|
656
919
|
template <int RANK>
|
|
657
920
|
struct private_key {
|
|
658
|
-
|
|
921
|
+
public_key<RANK> pub;
|
|
659
922
|
vector<RANK> s;
|
|
660
923
|
uint8_t fo_failure_secret[32];
|
|
661
924
|
};
|
|
662
925
|
|
|
663
926
|
template <int RANK>
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
const uint8_t ciphertext[BCM_MLKEM768_CIPHERTEXT_BYTES]) {
|
|
927
|
+
inline void decrypt_cpa(uint8_t out[32], const private_key<RANK> *priv,
|
|
928
|
+
const uint8_t ciphertext[MLKEM768_CIPHERTEXT_BYTES]) {
|
|
667
929
|
constexpr int du = RANK == RANK768 ? kDU768 : kDU1024;
|
|
668
930
|
constexpr int dv = RANK == RANK768 ? kDV768 : kDV1024;
|
|
669
931
|
|
|
670
932
|
vector<RANK> u;
|
|
671
|
-
vector_decode(&u, ciphertext
|
|
933
|
+
vector_decode<du>(&u, ciphertext);
|
|
672
934
|
vector_decompress(&u, du);
|
|
673
935
|
vector_ntt(&u);
|
|
674
936
|
scalar v;
|
|
675
|
-
scalar_decode(&v, ciphertext + compressed_vector_size(RANK)
|
|
937
|
+
scalar_decode<dv>(&v, ciphertext + compressed_vector_size(RANK));
|
|
676
938
|
scalar_decompress(&v, dv);
|
|
677
939
|
scalar mask;
|
|
678
940
|
scalar_inner_product(&mask, &priv->s, &u);
|
|
679
941
|
scalar_inverse_ntt(&mask);
|
|
680
942
|
scalar_sub(&v, &mask);
|
|
681
943
|
scalar_compress(&v, 1);
|
|
682
|
-
|
|
944
|
+
scalar_encode<1>(out, &v);
|
|
683
945
|
}
|
|
684
946
|
|
|
685
947
|
template <int RANK>
|
|
686
|
-
|
|
687
|
-
const
|
|
948
|
+
inline bcm_status mlkem_marshal_public_key(CBB *out,
|
|
949
|
+
const public_key<RANK> *pub) {
|
|
688
950
|
uint8_t *vector_output;
|
|
689
951
|
if (!CBB_add_space(out, &vector_output, encoded_vector_size(RANK))) {
|
|
690
952
|
return bcm_status::failure;
|
|
691
953
|
}
|
|
692
|
-
vector_encode(vector_output, &pub->t
|
|
954
|
+
vector_encode<kLog2Prime>(vector_output, &pub->t);
|
|
693
955
|
if (!CBB_add_bytes(out, pub->rho, sizeof(pub->rho))) {
|
|
694
956
|
return bcm_status::failure;
|
|
695
957
|
}
|
|
696
958
|
return bcm_status::approved;
|
|
697
959
|
}
|
|
698
960
|
|
|
961
|
+
template <int RANK>
|
|
962
|
+
inline bool mlkem_public_keys_equal(const public_key<RANK> *a,
|
|
963
|
+
const public_key<RANK> *b) {
|
|
964
|
+
return OPENSSL_memcmp(a->public_key_hash, b->public_key_hash, 32) == 0;
|
|
965
|
+
}
|
|
966
|
+
|
|
699
967
|
template <int RANK>
|
|
700
968
|
void mlkem_generate_key_external_seed_no_self_test(
|
|
701
969
|
uint8_t *out_encoded_public_key, private_key<RANK> *priv,
|
|
702
|
-
const uint8_t seed[
|
|
970
|
+
const uint8_t seed[MLKEM_SEED_BYTES]) {
|
|
703
971
|
uint8_t augmented_seed[33];
|
|
704
972
|
OPENSSL_memcpy(augmented_seed, seed, 32);
|
|
705
973
|
augmented_seed[32] = RANK;
|
|
@@ -735,20 +1003,20 @@ void mlkem_generate_key_external_seed_no_self_test(
|
|
|
735
1003
|
}
|
|
736
1004
|
|
|
737
1005
|
template <int RANK>
|
|
738
|
-
void mlkem_generate_key_external_seed(
|
|
739
|
-
|
|
740
|
-
|
|
1006
|
+
void mlkem_generate_key_external_seed(uint8_t *out_encoded_public_key,
|
|
1007
|
+
private_key<RANK> *priv,
|
|
1008
|
+
const uint8_t seed[MLKEM_SEED_BYTES]) {
|
|
741
1009
|
fips::ensure_keygen_self_test();
|
|
742
1010
|
mlkem_generate_key_external_seed_no_self_test(out_encoded_public_key, priv,
|
|
743
1011
|
seed);
|
|
744
1012
|
}
|
|
745
1013
|
|
|
746
1014
|
// Encrypts a message with given randomness to
|
|
747
|
-
// the ciphertext in
|
|
1015
|
+
// the ciphertext in `out`. Without applying the Fujisaki-Okamoto transform this
|
|
748
1016
|
// would not result in a CCA secure scheme, since lattice schemes are vulnerable
|
|
749
1017
|
// to decryption failure oracles.
|
|
750
1018
|
template <int RANK>
|
|
751
|
-
void encrypt_cpa(uint8_t *out, const
|
|
1019
|
+
void encrypt_cpa(uint8_t *out, const mlkem::public_key<RANK> *pub,
|
|
752
1020
|
const uint8_t message[32], const uint8_t randomness[32]) {
|
|
753
1021
|
constexpr int du = RANK == RANK768 ? mlkem::kDU768 : mlkem::kDU1024;
|
|
754
1022
|
constexpr int dv = RANK == RANK768 ? mlkem::kDV768 : mlkem::kDV1024;
|
|
@@ -773,20 +1041,20 @@ void encrypt_cpa(uint8_t *out, const struct mlkem::public_key<RANK> *pub,
|
|
|
773
1041
|
scalar_inverse_ntt(&v);
|
|
774
1042
|
scalar_add(&v, &scalar_error);
|
|
775
1043
|
mlkem::scalar expanded_message;
|
|
776
|
-
|
|
1044
|
+
scalar_decode<1>(&expanded_message, message);
|
|
777
1045
|
scalar_decompress(&expanded_message, 1);
|
|
778
1046
|
scalar_add(&v, &expanded_message);
|
|
779
1047
|
vector_compress(&u, du);
|
|
780
|
-
vector_encode(out, &u
|
|
1048
|
+
vector_encode<du>(out, &u);
|
|
781
1049
|
scalar_compress(&v, dv);
|
|
782
|
-
scalar_encode(out + mlkem::compressed_vector_size(RANK), &v
|
|
1050
|
+
scalar_encode<dv>(out + mlkem::compressed_vector_size(RANK), &v);
|
|
783
1051
|
}
|
|
784
1052
|
|
|
785
1053
|
// See section 6.3
|
|
786
1054
|
template <int RANK>
|
|
787
1055
|
void mlkem_decap_no_self_test(
|
|
788
|
-
uint8_t out_shared_secret[
|
|
789
|
-
const uint8_t *ciphertext, const
|
|
1056
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1057
|
+
const uint8_t *ciphertext, const private_key<RANK> *priv) {
|
|
790
1058
|
uint8_t decrypted[64];
|
|
791
1059
|
decrypt_cpa(decrypted, priv, ciphertext);
|
|
792
1060
|
OPENSSL_memcpy(decrypted + 32, priv->pub.public_key_hash,
|
|
@@ -794,8 +1062,8 @@ void mlkem_decap_no_self_test(
|
|
|
794
1062
|
uint8_t key_and_randomness[64];
|
|
795
1063
|
hash_g(key_and_randomness, decrypted, sizeof(decrypted));
|
|
796
1064
|
constexpr size_t ciphertext_len = ciphertext_size(RANK);
|
|
797
|
-
uint8_t expected_ciphertext[
|
|
798
|
-
static_assert(ciphertext_len <= sizeof(expected_ciphertext)
|
|
1065
|
+
uint8_t expected_ciphertext[MLKEM1024_CIPHERTEXT_BYTES];
|
|
1066
|
+
static_assert(ciphertext_len <= sizeof(expected_ciphertext));
|
|
799
1067
|
encrypt_cpa(expected_ciphertext, &priv->pub, decrypted,
|
|
800
1068
|
key_and_randomness + 32);
|
|
801
1069
|
|
|
@@ -804,53 +1072,56 @@ void mlkem_decap_no_self_test(
|
|
|
804
1072
|
|
|
805
1073
|
uint8_t mask = constant_time_eq_int_8(
|
|
806
1074
|
CRYPTO_memcmp(ciphertext, expected_ciphertext, ciphertext_len), 0);
|
|
807
|
-
for (int i = 0; i <
|
|
1075
|
+
for (int i = 0; i < MLKEM_SHARED_SECRET_BYTES; i++) {
|
|
808
1076
|
out_shared_secret[i] =
|
|
809
1077
|
constant_time_select_8(mask, key_and_randomness[i], failure_key[i]);
|
|
810
1078
|
}
|
|
811
1079
|
}
|
|
812
1080
|
|
|
813
1081
|
template <int RANK>
|
|
814
|
-
void mlkem_decap(uint8_t out_shared_secret[
|
|
815
|
-
const uint8_t *ciphertext,
|
|
816
|
-
const struct private_key<RANK> *priv) {
|
|
1082
|
+
void mlkem_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1083
|
+
const uint8_t *ciphertext, const private_key<RANK> *priv) {
|
|
817
1084
|
fips::ensure_decap_self_test();
|
|
818
1085
|
mlkem_decap_no_self_test(out_shared_secret, ciphertext, priv);
|
|
819
1086
|
}
|
|
820
1087
|
|
|
821
|
-
//
|
|
822
|
-
//
|
|
1088
|
+
// mlkem_parse_public_key_with_trailing_data parses `in` into `pub` but leaves
|
|
1089
|
+
// trailing data in `in` for the caller.
|
|
823
1090
|
template <int RANK>
|
|
824
|
-
int
|
|
1091
|
+
int mlkem_parse_public_key_with_trailing_data(public_key<RANK> *pub, CBS *in) {
|
|
1092
|
+
CBS orig_in = *in;
|
|
825
1093
|
CBS t_bytes;
|
|
826
1094
|
if (!CBS_get_bytes(in, &t_bytes, encoded_vector_size(RANK)) ||
|
|
827
|
-
!vector_decode(&pub->t, CBS_data(&t_bytes)
|
|
1095
|
+
!vector_decode<kLog2Prime>(&pub->t, CBS_data(&t_bytes)) ||
|
|
828
1096
|
!CBS_copy_bytes(in, pub->rho, sizeof(pub->rho))) {
|
|
829
1097
|
return 0;
|
|
830
1098
|
}
|
|
831
1099
|
matrix_expand(&pub->m, pub->rho);
|
|
1100
|
+
size_t pub_key_len = CBS_len(&orig_in) - CBS_len(in);
|
|
1101
|
+
assert(pub_key_len == encoded_public_key_size(RANK));
|
|
1102
|
+
hash_h(pub->public_key_hash, CBS_data(&orig_in), pub_key_len);
|
|
832
1103
|
return 1;
|
|
833
1104
|
}
|
|
834
1105
|
|
|
835
1106
|
template <int RANK>
|
|
836
|
-
int mlkem_parse_public_key(
|
|
837
|
-
|
|
838
|
-
if (!mlkem_parse_public_key_no_hash(pub, in) || //
|
|
1107
|
+
int mlkem_parse_public_key(public_key<RANK> *pub, CBS *in) {
|
|
1108
|
+
if (!mlkem_parse_public_key_with_trailing_data(pub, in) || //
|
|
839
1109
|
CBS_len(in) != 0) {
|
|
840
1110
|
return 0;
|
|
841
1111
|
}
|
|
842
|
-
hash_h(pub->public_key_hash, CBS_data(&orig_in), CBS_len(&orig_in));
|
|
843
1112
|
return 1;
|
|
844
1113
|
}
|
|
845
1114
|
|
|
846
1115
|
template <int RANK>
|
|
847
|
-
int mlkem_parse_private_key(
|
|
848
|
-
CBS s_bytes;
|
|
1116
|
+
int mlkem_parse_private_key(private_key<RANK> *priv, CBS *in) {
|
|
1117
|
+
CBS s_bytes, public_key_hash;
|
|
849
1118
|
if (!CBS_get_bytes(in, &s_bytes, encoded_vector_size(RANK)) ||
|
|
850
|
-
!vector_decode(&priv->s, CBS_data(&s_bytes)
|
|
851
|
-
!
|
|
852
|
-
|
|
853
|
-
|
|
1119
|
+
!vector_decode<kLog2Prime>(&priv->s, CBS_data(&s_bytes)) ||
|
|
1120
|
+
!mlkem_parse_public_key_with_trailing_data(&priv->pub, in) ||
|
|
1121
|
+
// We compute the public key hash ourselves, but check it matched.
|
|
1122
|
+
!CBS_get_bytes(in, &public_key_hash, sizeof(priv->pub.public_key_hash)) ||
|
|
1123
|
+
!CBS_mem_equal(&public_key_hash, priv->pub.public_key_hash,
|
|
1124
|
+
sizeof(priv->pub.public_key_hash)) ||
|
|
854
1125
|
!CBS_copy_bytes(in, priv->fo_failure_secret,
|
|
855
1126
|
sizeof(priv->fo_failure_secret)) ||
|
|
856
1127
|
CBS_len(in) != 0) {
|
|
@@ -860,12 +1131,12 @@ int mlkem_parse_private_key(struct private_key<RANK> *priv, CBS *in) {
|
|
|
860
1131
|
}
|
|
861
1132
|
|
|
862
1133
|
template <int RANK>
|
|
863
|
-
int mlkem_marshal_private_key(CBB *out, const
|
|
1134
|
+
int mlkem_marshal_private_key(CBB *out, const private_key<RANK> *priv) {
|
|
864
1135
|
uint8_t *s_output;
|
|
865
1136
|
if (!CBB_add_space(out, &s_output, encoded_vector_size(RANK))) {
|
|
866
1137
|
return 0;
|
|
867
1138
|
}
|
|
868
|
-
vector_encode(s_output, &priv->s
|
|
1139
|
+
vector_encode<kLog2Prime>(s_output, &priv->s);
|
|
869
1140
|
if (!bcm_success(mlkem_marshal_public_key(out, &priv->pub)) ||
|
|
870
1141
|
!CBB_add_bytes(out, priv->pub.public_key_hash,
|
|
871
1142
|
sizeof(priv->pub.public_key_hash)) ||
|
|
@@ -876,56 +1147,69 @@ int mlkem_marshal_private_key(CBB *out, const struct private_key<RANK> *priv) {
|
|
|
876
1147
|
return 1;
|
|
877
1148
|
}
|
|
878
1149
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
return
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1150
|
+
static_assert(sizeof(MLKEM768_public_key) == sizeof(public_key<RANK768>));
|
|
1151
|
+
static_assert(alignof(MLKEM768_public_key) == alignof(public_key<RANK768>));
|
|
1152
|
+
|
|
1153
|
+
const public_key<RANK768> *public_key_768_from_external(
|
|
1154
|
+
const MLKEM768_public_key *external) {
|
|
1155
|
+
return reinterpret_cast<const public_key<RANK768> *>(external);
|
|
1156
|
+
}
|
|
1157
|
+
public_key<RANK768> *public_key_768_from_external(
|
|
1158
|
+
MLKEM768_public_key *external) {
|
|
1159
|
+
return reinterpret_cast<public_key<RANK768> *>(external);
|
|
1160
|
+
}
|
|
1161
|
+
const MLKEM768_public_key *public_key_768_to_external(
|
|
1162
|
+
const public_key<RANK768> *public_key) {
|
|
1163
|
+
return reinterpret_cast<const MLKEM768_public_key *>(public_key);
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
static_assert(sizeof(MLKEM1024_public_key) == sizeof(public_key<RANK1024>));
|
|
1167
|
+
static_assert(alignof(MLKEM1024_public_key) == alignof(public_key<RANK1024>));
|
|
1168
|
+
|
|
1169
|
+
const public_key<RANK1024> *public_key_1024_from_external(
|
|
1170
|
+
const MLKEM1024_public_key *external) {
|
|
1171
|
+
return reinterpret_cast<const public_key<RANK1024> *>(external);
|
|
1172
|
+
}
|
|
1173
|
+
public_key<RANK1024> *public_key_1024_from_external(
|
|
1174
|
+
MLKEM1024_public_key *external) {
|
|
1175
|
+
return reinterpret_cast<public_key<RANK1024> *>(external);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
const MLKEM1024_public_key *public_key_1024_to_external(
|
|
1179
|
+
const public_key<RANK1024> *public_key) {
|
|
1180
|
+
return reinterpret_cast<const MLKEM1024_public_key *>(public_key);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
static_assert(sizeof(MLKEM768_private_key) >= sizeof(private_key<RANK768>));
|
|
1184
|
+
static_assert(alignof(MLKEM768_private_key) >= alignof(private_key<RANK768>));
|
|
1185
|
+
|
|
1186
|
+
const private_key<RANK768> *private_key_768_from_external(
|
|
1187
|
+
const MLKEM768_private_key *external) {
|
|
1188
|
+
return reinterpret_cast<const private_key<RANK768> *>(external);
|
|
1189
|
+
}
|
|
1190
|
+
private_key<RANK768> *private_key_768_from_external(
|
|
1191
|
+
MLKEM768_private_key *external) {
|
|
1192
|
+
return reinterpret_cast<private_key<RANK768> *>(external);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
static_assert(sizeof(MLKEM1024_private_key) >= sizeof(private_key<RANK1024>));
|
|
1196
|
+
static_assert(alignof(MLKEM1024_private_key) >= alignof(private_key<RANK1024>));
|
|
1197
|
+
|
|
1198
|
+
const private_key<RANK1024> *private_key_1024_from_external(
|
|
1199
|
+
const MLKEM1024_private_key *external) {
|
|
1200
|
+
return reinterpret_cast<const private_key<RANK1024> *>(external);
|
|
1201
|
+
}
|
|
1202
|
+
private_key<RANK1024> *private_key_1024_from_external(
|
|
1203
|
+
MLKEM1024_private_key *external) {
|
|
1204
|
+
return reinterpret_cast<private_key<RANK1024> *>(external);
|
|
921
1205
|
}
|
|
922
1206
|
|
|
923
1207
|
// See section 6.2.
|
|
924
1208
|
template <int RANK>
|
|
925
1209
|
void mlkem_encap_external_entropy_no_self_test(
|
|
926
1210
|
uint8_t *out_ciphertext,
|
|
927
|
-
uint8_t out_shared_secret[
|
|
928
|
-
const
|
|
1211
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1212
|
+
const mlkem::public_key<RANK> *pub,
|
|
929
1213
|
const uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY]) {
|
|
930
1214
|
uint8_t input[64];
|
|
931
1215
|
OPENSSL_memcpy(input, entropy, BCM_MLKEM_ENCAP_ENTROPY);
|
|
@@ -936,15 +1220,15 @@ void mlkem_encap_external_entropy_no_self_test(
|
|
|
936
1220
|
encrypt_cpa(out_ciphertext, pub, entropy, key_and_randomness + 32);
|
|
937
1221
|
// The ciphertext is public.
|
|
938
1222
|
CONSTTIME_DECLASSIFY(out_ciphertext, mlkem::ciphertext_size(RANK));
|
|
939
|
-
static_assert(
|
|
1223
|
+
static_assert(MLKEM_SHARED_SECRET_BYTES == 32);
|
|
940
1224
|
memcpy(out_shared_secret, key_and_randomness, 32);
|
|
941
1225
|
}
|
|
942
1226
|
|
|
943
1227
|
template <int RANK>
|
|
944
1228
|
void mlkem_encap_external_entropy(
|
|
945
1229
|
uint8_t *out_ciphertext,
|
|
946
|
-
uint8_t out_shared_secret[
|
|
947
|
-
const
|
|
1230
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1231
|
+
const mlkem::public_key<RANK> *pub,
|
|
948
1232
|
const uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY]) {
|
|
949
1233
|
fips::ensure_encap_self_test();
|
|
950
1234
|
mlkem_encap_external_entropy_no_self_test(out_ciphertext, out_shared_secret,
|
|
@@ -955,75 +1239,67 @@ namespace fips {
|
|
|
955
1239
|
|
|
956
1240
|
#include "fips_known_values.inc"
|
|
957
1241
|
|
|
958
|
-
|
|
959
|
-
uint8_t pub_key[
|
|
1242
|
+
inline int keygen_self_test() {
|
|
1243
|
+
uint8_t pub_key[MLKEM768_PUBLIC_KEY_BYTES];
|
|
960
1244
|
private_key<RANK768> priv;
|
|
961
|
-
static_assert(sizeof(kTestEntropy) >=
|
|
1245
|
+
static_assert(sizeof(kTestEntropy) >= MLKEM_SEED_BYTES);
|
|
962
1246
|
mlkem_generate_key_external_seed_no_self_test(pub_key, &priv, kTestEntropy);
|
|
963
1247
|
CBB cbb;
|
|
964
1248
|
constexpr size_t kMarshaledPrivateKeySize = 2400;
|
|
965
1249
|
uint8_t priv_bytes[kMarshaledPrivateKeySize];
|
|
966
1250
|
CBB_init_fixed(&cbb, priv_bytes, sizeof(priv_bytes));
|
|
967
|
-
static_assert(sizeof(kExpectedPrivateKeyBytes) == kMarshaledPrivateKeySize);
|
|
968
|
-
static_assert(sizeof(kExpectedPublicKeyBytes) == sizeof(pub_key));
|
|
969
1251
|
if (!mlkem_marshal_private_key(&cbb, &priv) ||
|
|
970
1252
|
!BORINGSSL_check_test(kExpectedPrivateKeyBytes, priv_bytes,
|
|
971
|
-
|
|
972
|
-
!BORINGSSL_check_test(kExpectedPublicKeyBytes, pub_key,
|
|
1253
|
+
"ML-KEM keygen private key") ||
|
|
1254
|
+
!BORINGSSL_check_test(kExpectedPublicKeyBytes, pub_key,
|
|
973
1255
|
"ML-KEM keygen public key")) {
|
|
974
1256
|
return 0;
|
|
975
1257
|
}
|
|
976
1258
|
return 1;
|
|
977
1259
|
}
|
|
978
1260
|
|
|
979
|
-
|
|
1261
|
+
inline int encap_self_test() {
|
|
980
1262
|
CBS cbs;
|
|
981
1263
|
CBS_init(&cbs, kExpectedPublicKeyBytes, sizeof(kExpectedPublicKeyBytes));
|
|
982
1264
|
public_key<RANK768> pub;
|
|
983
1265
|
if (!mlkem_parse_public_key(&pub, &cbs)) {
|
|
984
1266
|
return 0;
|
|
985
1267
|
}
|
|
986
|
-
uint8_t ciphertext[
|
|
987
|
-
uint8_t shared_secret[
|
|
1268
|
+
uint8_t ciphertext[MLKEM768_CIPHERTEXT_BYTES];
|
|
1269
|
+
uint8_t shared_secret[MLKEM_SHARED_SECRET_BYTES];
|
|
988
1270
|
static_assert(sizeof(kTestEntropy) >= BCM_MLKEM_ENCAP_ENTROPY);
|
|
989
1271
|
mlkem_encap_external_entropy_no_self_test(ciphertext, shared_secret, &pub,
|
|
990
1272
|
kTestEntropy);
|
|
991
|
-
if (!BORINGSSL_check_test(ciphertext, kExpectedCiphertext,
|
|
1273
|
+
if (!BORINGSSL_check_test(ciphertext, kExpectedCiphertext,
|
|
992
1274
|
"ML-KEM encap ciphertext") ||
|
|
993
1275
|
!BORINGSSL_check_test(kExpectedSharedSecret, shared_secret,
|
|
994
|
-
sizeof(kExpectedSharedSecret),
|
|
995
1276
|
"ML-KEM encap shared secret")) {
|
|
996
1277
|
return 0;
|
|
997
1278
|
}
|
|
998
1279
|
return 1;
|
|
999
1280
|
}
|
|
1000
1281
|
|
|
1001
|
-
|
|
1282
|
+
inline int decap_self_test() {
|
|
1002
1283
|
CBS cbs;
|
|
1003
1284
|
CBS_init(&cbs, kExpectedPrivateKeyBytes, sizeof(kExpectedPrivateKeyBytes));
|
|
1004
1285
|
private_key<RANK768> priv;
|
|
1005
1286
|
if (!mlkem_parse_private_key(&priv, &cbs)) {
|
|
1006
1287
|
return 0;
|
|
1007
1288
|
}
|
|
1008
|
-
uint8_t shared_secret[
|
|
1289
|
+
uint8_t shared_secret[MLKEM_SHARED_SECRET_BYTES];
|
|
1009
1290
|
mlkem_decap_no_self_test(shared_secret, kExpectedCiphertext, &priv);
|
|
1010
|
-
static_assert(sizeof(kExpectedSharedSecret) == sizeof(shared_secret));
|
|
1011
1291
|
if (!BORINGSSL_check_test(kExpectedSharedSecret, shared_secret,
|
|
1012
|
-
sizeof(shared_secret),
|
|
1013
1292
|
"ML-KEM decap shared secret")) {
|
|
1014
1293
|
return 0;
|
|
1015
1294
|
}
|
|
1016
1295
|
|
|
1017
|
-
uint8_t implicit_rejection_shared_secret[
|
|
1296
|
+
uint8_t implicit_rejection_shared_secret[MLKEM_SHARED_SECRET_BYTES];
|
|
1018
1297
|
static_assert(sizeof(kExpectedPrivateKeyBytes) >=
|
|
1019
1298
|
sizeof(kExpectedCiphertext));
|
|
1020
1299
|
mlkem_decap_no_self_test(implicit_rejection_shared_secret,
|
|
1021
1300
|
kExpectedPrivateKeyBytes, &priv);
|
|
1022
|
-
static_assert(sizeof(kExpectedImplicitRejectionSharedSecret) ==
|
|
1023
|
-
sizeof(implicit_rejection_shared_secret));
|
|
1024
1301
|
if (!BORINGSSL_check_test(kExpectedImplicitRejectionSharedSecret,
|
|
1025
1302
|
implicit_rejection_shared_secret,
|
|
1026
|
-
sizeof(implicit_rejection_shared_secret),
|
|
1027
1303
|
"ML-KEM decap implicit rejection shared secret")) {
|
|
1028
1304
|
return 0;
|
|
1029
1305
|
}
|
|
@@ -1032,9 +1308,7 @@ static int decap_self_test() {
|
|
|
1032
1308
|
|
|
1033
1309
|
#if defined(BORINGSSL_FIPS)
|
|
1034
1310
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
void ensure_keygen_self_test(void) {
|
|
1311
|
+
void ensure_keygen_self_test() {
|
|
1038
1312
|
CRYPTO_once(g_mlkem_keygen_self_test_once_bss_get(), []() {
|
|
1039
1313
|
if (!keygen_self_test()) {
|
|
1040
1314
|
BORINGSSL_FIPS_abort();
|
|
@@ -1042,9 +1316,7 @@ void ensure_keygen_self_test(void) {
|
|
|
1042
1316
|
});
|
|
1043
1317
|
}
|
|
1044
1318
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
void ensure_encap_self_test(void) {
|
|
1319
|
+
void ensure_encap_self_test() {
|
|
1048
1320
|
CRYPTO_once(g_mlkem_encap_self_test_once_bss_get(), []() {
|
|
1049
1321
|
if (!encap_self_test()) {
|
|
1050
1322
|
BORINGSSL_FIPS_abort();
|
|
@@ -1052,9 +1324,7 @@ void ensure_encap_self_test(void) {
|
|
|
1052
1324
|
});
|
|
1053
1325
|
}
|
|
1054
1326
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
void ensure_decap_self_test(void) {
|
|
1327
|
+
void ensure_decap_self_test() {
|
|
1058
1328
|
CRYPTO_once(g_mlkem_decap_self_test_once_bss_get(), []() {
|
|
1059
1329
|
if (!decap_self_test()) {
|
|
1060
1330
|
BORINGSSL_FIPS_abort();
|
|
@@ -1064,9 +1334,9 @@ void ensure_decap_self_test(void) {
|
|
|
1064
1334
|
|
|
1065
1335
|
#else
|
|
1066
1336
|
|
|
1067
|
-
void ensure_keygen_self_test(
|
|
1068
|
-
void ensure_encap_self_test(
|
|
1069
|
-
void ensure_decap_self_test(
|
|
1337
|
+
void ensure_keygen_self_test() {}
|
|
1338
|
+
void ensure_encap_self_test() {}
|
|
1339
|
+
void ensure_decap_self_test() {}
|
|
1070
1340
|
|
|
1071
1341
|
#endif
|
|
1072
1342
|
} // namespace fips
|
|
@@ -1074,14 +1344,14 @@ void ensure_decap_self_test(void) {}
|
|
|
1074
1344
|
} // namespace
|
|
1075
1345
|
} // namespace mlkem
|
|
1076
1346
|
|
|
1077
|
-
bcm_status BCM_mlkem768_check_fips(
|
|
1078
|
-
const
|
|
1079
|
-
mlkem::private_key<RANK768> *priv =
|
|
1347
|
+
bcm_status bssl::BCM_mlkem768_check_fips(
|
|
1348
|
+
const MLKEM768_private_key *private_key) {
|
|
1349
|
+
const mlkem::private_key<RANK768> *priv =
|
|
1080
1350
|
mlkem::private_key_768_from_external(private_key);
|
|
1081
1351
|
|
|
1082
1352
|
const uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY] = {1, 2, 3, 4};
|
|
1083
|
-
uint8_t ciphertext[
|
|
1084
|
-
uint8_t shared_secret[
|
|
1353
|
+
uint8_t ciphertext[MLKEM768_CIPHERTEXT_BYTES];
|
|
1354
|
+
uint8_t shared_secret[MLKEM_SHARED_SECRET_BYTES];
|
|
1085
1355
|
mlkem_encap_external_entropy_no_self_test(ciphertext, shared_secret,
|
|
1086
1356
|
&priv->pub, entropy);
|
|
1087
1357
|
|
|
@@ -1089,7 +1359,7 @@ bcm_status BCM_mlkem768_check_fips(
|
|
|
1089
1359
|
shared_secret[0] ^= 1;
|
|
1090
1360
|
}
|
|
1091
1361
|
|
|
1092
|
-
uint8_t shared_secret2[
|
|
1362
|
+
uint8_t shared_secret2[MLKEM_SHARED_SECRET_BYTES];
|
|
1093
1363
|
mlkem::mlkem_decap_no_self_test(shared_secret2, ciphertext, priv);
|
|
1094
1364
|
if (CRYPTO_memcmp(shared_secret, shared_secret2, sizeof(shared_secret)) !=
|
|
1095
1365
|
0) {
|
|
@@ -1098,10 +1368,10 @@ bcm_status BCM_mlkem768_check_fips(
|
|
|
1098
1368
|
return bcm_status::approved;
|
|
1099
1369
|
}
|
|
1100
1370
|
|
|
1101
|
-
bcm_status BCM_mlkem768_generate_key_fips(
|
|
1102
|
-
uint8_t out_encoded_public_key[
|
|
1103
|
-
uint8_t optional_out_seed[
|
|
1104
|
-
|
|
1371
|
+
bcm_status bssl::BCM_mlkem768_generate_key_fips(
|
|
1372
|
+
uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
|
|
1373
|
+
uint8_t optional_out_seed[MLKEM_SEED_BYTES],
|
|
1374
|
+
MLKEM768_private_key *out_private_key) {
|
|
1105
1375
|
if (out_encoded_public_key == nullptr || out_private_key == nullptr) {
|
|
1106
1376
|
return bcm_status::failure;
|
|
1107
1377
|
}
|
|
@@ -1110,11 +1380,11 @@ bcm_status BCM_mlkem768_generate_key_fips(
|
|
|
1110
1380
|
return BCM_mlkem768_check_fips(out_private_key);
|
|
1111
1381
|
}
|
|
1112
1382
|
|
|
1113
|
-
bcm_infallible BCM_mlkem768_generate_key(
|
|
1114
|
-
uint8_t out_encoded_public_key[
|
|
1115
|
-
uint8_t optional_out_seed[
|
|
1116
|
-
|
|
1117
|
-
uint8_t seed[
|
|
1383
|
+
bcm_infallible bssl::BCM_mlkem768_generate_key(
|
|
1384
|
+
uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
|
|
1385
|
+
uint8_t optional_out_seed[MLKEM_SEED_BYTES],
|
|
1386
|
+
MLKEM768_private_key *out_private_key) {
|
|
1387
|
+
uint8_t seed[MLKEM_SEED_BYTES];
|
|
1118
1388
|
BCM_rand_bytes(seed, sizeof(seed));
|
|
1119
1389
|
CONSTTIME_SECRET(seed, sizeof(seed));
|
|
1120
1390
|
if (optional_out_seed) {
|
|
@@ -1125,27 +1395,27 @@ bcm_infallible BCM_mlkem768_generate_key(
|
|
|
1125
1395
|
return bcm_infallible::not_approved;
|
|
1126
1396
|
}
|
|
1127
1397
|
|
|
1128
|
-
bcm_status BCM_mlkem768_private_key_from_seed(
|
|
1129
|
-
|
|
1398
|
+
bcm_status bssl::BCM_mlkem768_private_key_from_seed(
|
|
1399
|
+
MLKEM768_private_key *out_private_key, const uint8_t *seed,
|
|
1130
1400
|
size_t seed_len) {
|
|
1131
|
-
if (seed_len !=
|
|
1401
|
+
if (seed_len != MLKEM_SEED_BYTES) {
|
|
1132
1402
|
return bcm_status::failure;
|
|
1133
1403
|
}
|
|
1134
1404
|
|
|
1135
|
-
uint8_t public_key_bytes[
|
|
1405
|
+
uint8_t public_key_bytes[MLKEM768_PUBLIC_KEY_BYTES];
|
|
1136
1406
|
BCM_mlkem768_generate_key_external_seed(public_key_bytes, out_private_key,
|
|
1137
1407
|
seed);
|
|
1138
1408
|
return bcm_status::not_approved;
|
|
1139
1409
|
}
|
|
1140
1410
|
|
|
1141
|
-
bcm_status BCM_mlkem1024_check_fips(
|
|
1142
|
-
const
|
|
1143
|
-
mlkem::private_key<RANK1024> *priv =
|
|
1411
|
+
bcm_status bssl::BCM_mlkem1024_check_fips(
|
|
1412
|
+
const MLKEM1024_private_key *private_key) {
|
|
1413
|
+
const mlkem::private_key<RANK1024> *priv =
|
|
1144
1414
|
mlkem::private_key_1024_from_external(private_key);
|
|
1145
1415
|
|
|
1146
1416
|
const uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY] = {1, 2, 3, 4};
|
|
1147
|
-
uint8_t ciphertext[
|
|
1148
|
-
uint8_t shared_secret[
|
|
1417
|
+
uint8_t ciphertext[MLKEM1024_CIPHERTEXT_BYTES];
|
|
1418
|
+
uint8_t shared_secret[MLKEM_SHARED_SECRET_BYTES];
|
|
1149
1419
|
mlkem_encap_external_entropy_no_self_test(ciphertext, shared_secret,
|
|
1150
1420
|
&priv->pub, entropy);
|
|
1151
1421
|
|
|
@@ -1153,7 +1423,7 @@ bcm_status BCM_mlkem1024_check_fips(
|
|
|
1153
1423
|
shared_secret[0] ^= 1;
|
|
1154
1424
|
}
|
|
1155
1425
|
|
|
1156
|
-
uint8_t shared_secret2[
|
|
1426
|
+
uint8_t shared_secret2[MLKEM_SHARED_SECRET_BYTES];
|
|
1157
1427
|
mlkem::mlkem_decap_no_self_test(shared_secret2, ciphertext, priv);
|
|
1158
1428
|
if (CRYPTO_memcmp(shared_secret, shared_secret2, sizeof(shared_secret)) !=
|
|
1159
1429
|
0) {
|
|
@@ -1162,10 +1432,10 @@ bcm_status BCM_mlkem1024_check_fips(
|
|
|
1162
1432
|
return bcm_status::approved;
|
|
1163
1433
|
}
|
|
1164
1434
|
|
|
1165
|
-
bcm_status BCM_mlkem1024_generate_key_fips(
|
|
1166
|
-
uint8_t out_encoded_public_key[
|
|
1167
|
-
uint8_t optional_out_seed[
|
|
1168
|
-
|
|
1435
|
+
bcm_status bssl::BCM_mlkem1024_generate_key_fips(
|
|
1436
|
+
uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
|
|
1437
|
+
uint8_t optional_out_seed[MLKEM_SEED_BYTES],
|
|
1438
|
+
MLKEM1024_private_key *out_private_key) {
|
|
1169
1439
|
if (out_encoded_public_key == nullptr || out_private_key == nullptr) {
|
|
1170
1440
|
return bcm_status::failure;
|
|
1171
1441
|
}
|
|
@@ -1174,11 +1444,11 @@ bcm_status BCM_mlkem1024_generate_key_fips(
|
|
|
1174
1444
|
return BCM_mlkem1024_check_fips(out_private_key);
|
|
1175
1445
|
}
|
|
1176
1446
|
|
|
1177
|
-
bcm_infallible BCM_mlkem1024_generate_key(
|
|
1178
|
-
uint8_t out_encoded_public_key[
|
|
1179
|
-
uint8_t optional_out_seed[
|
|
1180
|
-
|
|
1181
|
-
uint8_t seed[
|
|
1447
|
+
bcm_infallible bssl::BCM_mlkem1024_generate_key(
|
|
1448
|
+
uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
|
|
1449
|
+
uint8_t optional_out_seed[MLKEM_SEED_BYTES],
|
|
1450
|
+
MLKEM1024_private_key *out_private_key) {
|
|
1451
|
+
uint8_t seed[MLKEM_SEED_BYTES];
|
|
1182
1452
|
BCM_rand_bytes(seed, sizeof(seed));
|
|
1183
1453
|
CONSTTIME_SECRET(seed, sizeof(seed));
|
|
1184
1454
|
if (optional_out_seed) {
|
|
@@ -1189,66 +1459,80 @@ bcm_infallible BCM_mlkem1024_generate_key(
|
|
|
1189
1459
|
return bcm_infallible::not_approved;
|
|
1190
1460
|
}
|
|
1191
1461
|
|
|
1192
|
-
bcm_status BCM_mlkem1024_private_key_from_seed(
|
|
1193
|
-
|
|
1462
|
+
bcm_status bssl::BCM_mlkem1024_private_key_from_seed(
|
|
1463
|
+
MLKEM1024_private_key *out_private_key, const uint8_t *seed,
|
|
1194
1464
|
size_t seed_len) {
|
|
1195
|
-
if (seed_len !=
|
|
1465
|
+
if (seed_len != MLKEM_SEED_BYTES) {
|
|
1196
1466
|
return bcm_status::failure;
|
|
1197
1467
|
}
|
|
1198
|
-
uint8_t public_key_bytes[
|
|
1468
|
+
uint8_t public_key_bytes[MLKEM1024_PUBLIC_KEY_BYTES];
|
|
1199
1469
|
BCM_mlkem1024_generate_key_external_seed(public_key_bytes, out_private_key,
|
|
1200
1470
|
seed);
|
|
1201
1471
|
return bcm_status::not_approved;
|
|
1202
1472
|
}
|
|
1203
1473
|
|
|
1204
|
-
bcm_infallible BCM_mlkem768_generate_key_external_seed(
|
|
1205
|
-
uint8_t out_encoded_public_key[
|
|
1206
|
-
|
|
1207
|
-
const uint8_t seed[
|
|
1474
|
+
bcm_infallible bssl::BCM_mlkem768_generate_key_external_seed(
|
|
1475
|
+
uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
|
|
1476
|
+
MLKEM768_private_key *out_private_key,
|
|
1477
|
+
const uint8_t seed[MLKEM_SEED_BYTES]) {
|
|
1208
1478
|
mlkem::private_key<RANK768> *priv =
|
|
1209
1479
|
mlkem::private_key_768_from_external(out_private_key);
|
|
1210
1480
|
mlkem_generate_key_external_seed(out_encoded_public_key, priv, seed);
|
|
1211
1481
|
return bcm_infallible::approved;
|
|
1212
1482
|
}
|
|
1213
1483
|
|
|
1214
|
-
bcm_infallible BCM_mlkem1024_generate_key_external_seed(
|
|
1215
|
-
uint8_t out_encoded_public_key[
|
|
1216
|
-
|
|
1217
|
-
const uint8_t seed[
|
|
1484
|
+
bcm_infallible bssl::BCM_mlkem1024_generate_key_external_seed(
|
|
1485
|
+
uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
|
|
1486
|
+
MLKEM1024_private_key *out_private_key,
|
|
1487
|
+
const uint8_t seed[MLKEM_SEED_BYTES]) {
|
|
1218
1488
|
mlkem::private_key<RANK1024> *priv =
|
|
1219
1489
|
mlkem::private_key_1024_from_external(out_private_key);
|
|
1220
1490
|
mlkem_generate_key_external_seed(out_encoded_public_key, priv, seed);
|
|
1221
1491
|
return bcm_infallible::approved;
|
|
1222
1492
|
}
|
|
1223
1493
|
|
|
1224
|
-
bcm_infallible BCM_mlkem768_public_from_private(
|
|
1225
|
-
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1494
|
+
bcm_infallible bssl::BCM_mlkem768_public_from_private(
|
|
1495
|
+
MLKEM768_public_key *out_public_key,
|
|
1496
|
+
const MLKEM768_private_key *private_key) {
|
|
1497
|
+
mlkem::public_key<RANK768> *const pub =
|
|
1228
1498
|
mlkem::public_key_768_from_external(out_public_key);
|
|
1229
|
-
const
|
|
1499
|
+
const mlkem::private_key<RANK768> *const priv =
|
|
1230
1500
|
mlkem::private_key_768_from_external(private_key);
|
|
1231
1501
|
*pub = priv->pub;
|
|
1232
1502
|
return bcm_infallible::approved;
|
|
1233
1503
|
}
|
|
1234
1504
|
|
|
1235
|
-
bcm_infallible BCM_mlkem1024_public_from_private(
|
|
1236
|
-
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1505
|
+
bcm_infallible bssl::BCM_mlkem1024_public_from_private(
|
|
1506
|
+
MLKEM1024_public_key *out_public_key,
|
|
1507
|
+
const MLKEM1024_private_key *private_key) {
|
|
1508
|
+
mlkem::public_key<RANK1024> *const pub =
|
|
1239
1509
|
mlkem::public_key_1024_from_external(out_public_key);
|
|
1240
|
-
const
|
|
1510
|
+
const mlkem::private_key<RANK1024> *const priv =
|
|
1241
1511
|
mlkem::private_key_1024_from_external(private_key);
|
|
1242
1512
|
*pub = priv->pub;
|
|
1243
1513
|
return bcm_infallible::approved;
|
|
1244
1514
|
}
|
|
1245
1515
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1516
|
+
const MLKEM768_public_key *bssl::BCM_mlkem768_public_of_private(
|
|
1517
|
+
const MLKEM768_private_key *private_key) {
|
|
1518
|
+
const mlkem::private_key<RANK768> *const priv =
|
|
1519
|
+
mlkem::private_key_768_from_external(private_key);
|
|
1520
|
+
return mlkem::public_key_768_to_external(&priv->pub);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
const MLKEM1024_public_key *bssl::BCM_mlkem1024_public_of_private(
|
|
1524
|
+
const MLKEM1024_private_key *private_key) {
|
|
1525
|
+
const mlkem::private_key<RANK1024> *const priv =
|
|
1526
|
+
mlkem::private_key_1024_from_external(private_key);
|
|
1527
|
+
return mlkem::public_key_1024_to_external(&priv->pub);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
// Calls `MLKEM768_encap_external_entropy` with random bytes from
|
|
1531
|
+
// `BCM_rand_bytes`
|
|
1532
|
+
bcm_infallible bssl::BCM_mlkem768_encap(
|
|
1533
|
+
uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES],
|
|
1534
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1535
|
+
const MLKEM768_public_key *public_key) {
|
|
1252
1536
|
uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY];
|
|
1253
1537
|
BCM_rand_bytes(entropy, BCM_MLKEM_ENCAP_ENTROPY);
|
|
1254
1538
|
CONSTTIME_SECRET(entropy, BCM_MLKEM_ENCAP_ENTROPY);
|
|
@@ -1257,10 +1541,10 @@ bcm_infallible BCM_mlkem768_encap(
|
|
|
1257
1541
|
return bcm_infallible::approved;
|
|
1258
1542
|
}
|
|
1259
1543
|
|
|
1260
|
-
bcm_infallible BCM_mlkem1024_encap(
|
|
1261
|
-
uint8_t out_ciphertext[
|
|
1262
|
-
uint8_t out_shared_secret[
|
|
1263
|
-
const
|
|
1544
|
+
bcm_infallible bssl::BCM_mlkem1024_encap(
|
|
1545
|
+
uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
|
|
1546
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1547
|
+
const MLKEM1024_public_key *public_key) {
|
|
1264
1548
|
uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY];
|
|
1265
1549
|
BCM_rand_bytes(entropy, BCM_MLKEM_ENCAP_ENTROPY);
|
|
1266
1550
|
CONSTTIME_SECRET(entropy, BCM_MLKEM_ENCAP_ENTROPY);
|
|
@@ -1269,71 +1553,91 @@ bcm_infallible BCM_mlkem1024_encap(
|
|
|
1269
1553
|
return bcm_infallible::approved;
|
|
1270
1554
|
}
|
|
1271
1555
|
|
|
1272
|
-
bcm_infallible BCM_mlkem768_encap_external_entropy(
|
|
1273
|
-
uint8_t out_ciphertext[
|
|
1274
|
-
uint8_t out_shared_secret[
|
|
1275
|
-
const
|
|
1556
|
+
bcm_infallible bssl::BCM_mlkem768_encap_external_entropy(
|
|
1557
|
+
uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES],
|
|
1558
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1559
|
+
const MLKEM768_public_key *public_key,
|
|
1276
1560
|
const uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY]) {
|
|
1277
|
-
const
|
|
1561
|
+
const mlkem::public_key<RANK768> *pub =
|
|
1278
1562
|
mlkem::public_key_768_from_external(public_key);
|
|
1279
1563
|
mlkem_encap_external_entropy(out_ciphertext, out_shared_secret, pub, entropy);
|
|
1280
1564
|
return bcm_infallible::approved;
|
|
1281
1565
|
}
|
|
1282
1566
|
|
|
1283
|
-
bcm_infallible BCM_mlkem1024_encap_external_entropy(
|
|
1284
|
-
uint8_t out_ciphertext[
|
|
1285
|
-
uint8_t out_shared_secret[
|
|
1286
|
-
const
|
|
1567
|
+
bcm_infallible bssl::BCM_mlkem1024_encap_external_entropy(
|
|
1568
|
+
uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
|
|
1569
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1570
|
+
const MLKEM1024_public_key *public_key,
|
|
1287
1571
|
const uint8_t entropy[BCM_MLKEM_ENCAP_ENTROPY]) {
|
|
1288
|
-
const
|
|
1572
|
+
const mlkem::public_key<RANK1024> *pub =
|
|
1289
1573
|
mlkem::public_key_1024_from_external(public_key);
|
|
1290
1574
|
mlkem_encap_external_entropy(out_ciphertext, out_shared_secret, pub, entropy);
|
|
1291
1575
|
return bcm_infallible::approved;
|
|
1292
1576
|
}
|
|
1293
1577
|
|
|
1294
|
-
bcm_status BCM_mlkem768_decap(
|
|
1295
|
-
uint8_t out_shared_secret[
|
|
1578
|
+
bcm_status bssl::BCM_mlkem768_decap(
|
|
1579
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1296
1580
|
const uint8_t *ciphertext, size_t ciphertext_len,
|
|
1297
|
-
const
|
|
1298
|
-
if (ciphertext_len !=
|
|
1299
|
-
BCM_rand_bytes(out_shared_secret,
|
|
1581
|
+
const MLKEM768_private_key *private_key) {
|
|
1582
|
+
if (ciphertext_len != MLKEM768_CIPHERTEXT_BYTES) {
|
|
1583
|
+
BCM_rand_bytes(out_shared_secret, MLKEM_SHARED_SECRET_BYTES);
|
|
1300
1584
|
return bcm_status::failure;
|
|
1301
1585
|
}
|
|
1302
|
-
const
|
|
1586
|
+
const mlkem::private_key<RANK768> *priv =
|
|
1303
1587
|
mlkem::private_key_768_from_external(private_key);
|
|
1304
1588
|
mlkem_decap(out_shared_secret, ciphertext, priv);
|
|
1305
1589
|
return bcm_status::approved;
|
|
1306
1590
|
}
|
|
1307
1591
|
|
|
1308
|
-
bcm_status BCM_mlkem1024_decap(
|
|
1309
|
-
uint8_t out_shared_secret[
|
|
1592
|
+
bcm_status bssl::BCM_mlkem1024_decap(
|
|
1593
|
+
uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
|
|
1310
1594
|
const uint8_t *ciphertext, size_t ciphertext_len,
|
|
1311
|
-
const
|
|
1312
|
-
if (ciphertext_len !=
|
|
1313
|
-
BCM_rand_bytes(out_shared_secret,
|
|
1595
|
+
const MLKEM1024_private_key *private_key) {
|
|
1596
|
+
if (ciphertext_len != MLKEM1024_CIPHERTEXT_BYTES) {
|
|
1597
|
+
BCM_rand_bytes(out_shared_secret, MLKEM_SHARED_SECRET_BYTES);
|
|
1314
1598
|
return bcm_status::failure;
|
|
1315
1599
|
}
|
|
1316
|
-
const
|
|
1600
|
+
const mlkem::private_key<RANK1024> *priv =
|
|
1317
1601
|
mlkem::private_key_1024_from_external(private_key);
|
|
1318
1602
|
mlkem_decap(out_shared_secret, ciphertext, priv);
|
|
1319
1603
|
return bcm_status::approved;
|
|
1320
1604
|
}
|
|
1321
1605
|
|
|
1322
|
-
bcm_status BCM_mlkem768_marshal_public_key(
|
|
1323
|
-
CBB *out, const
|
|
1606
|
+
bcm_status bssl::BCM_mlkem768_marshal_public_key(
|
|
1607
|
+
CBB *out, const MLKEM768_public_key *public_key) {
|
|
1324
1608
|
return mlkem_marshal_public_key(
|
|
1325
1609
|
out, mlkem::public_key_768_from_external(public_key));
|
|
1326
1610
|
}
|
|
1327
1611
|
|
|
1328
|
-
bcm_status BCM_mlkem1024_marshal_public_key(
|
|
1329
|
-
CBB *out, const
|
|
1612
|
+
bcm_status bssl::BCM_mlkem1024_marshal_public_key(
|
|
1613
|
+
CBB *out, const MLKEM1024_public_key *public_key) {
|
|
1330
1614
|
return mlkem_marshal_public_key(
|
|
1331
1615
|
out, mlkem::public_key_1024_from_external(public_key));
|
|
1332
1616
|
}
|
|
1333
1617
|
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1618
|
+
int bssl::BCM_mlkem768_public_keys_equal(const MLKEM768_public_key *a,
|
|
1619
|
+
const MLKEM768_public_key *b) {
|
|
1620
|
+
const auto *pub_a = mlkem::public_key_768_from_external(a);
|
|
1621
|
+
const auto *pub_b = mlkem::public_key_768_from_external(b);
|
|
1622
|
+
if (mlkem_public_keys_equal(pub_a, pub_b)) {
|
|
1623
|
+
return 1;
|
|
1624
|
+
}
|
|
1625
|
+
return 0;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
int bssl::BCM_mlkem1024_public_keys_equal(const MLKEM1024_public_key *a,
|
|
1629
|
+
const MLKEM1024_public_key *b) {
|
|
1630
|
+
const auto *pub_a = mlkem::public_key_1024_from_external(a);
|
|
1631
|
+
const auto *pub_b = mlkem::public_key_1024_from_external(b);
|
|
1632
|
+
if (mlkem_public_keys_equal(pub_a, pub_b)) {
|
|
1633
|
+
return 1;
|
|
1634
|
+
}
|
|
1635
|
+
return 0;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
bcm_status bssl::BCM_mlkem768_parse_public_key(MLKEM768_public_key *public_key,
|
|
1639
|
+
CBS *in) {
|
|
1640
|
+
mlkem::public_key<RANK768> *pub =
|
|
1337
1641
|
mlkem::public_key_768_from_external(public_key);
|
|
1338
1642
|
if (!mlkem_parse_public_key(pub, in)) {
|
|
1339
1643
|
return bcm_status::failure;
|
|
@@ -1341,9 +1645,9 @@ bcm_status BCM_mlkem768_parse_public_key(
|
|
|
1341
1645
|
return bcm_status::approved;
|
|
1342
1646
|
}
|
|
1343
1647
|
|
|
1344
|
-
bcm_status BCM_mlkem1024_parse_public_key(
|
|
1345
|
-
|
|
1346
|
-
|
|
1648
|
+
bcm_status bssl::BCM_mlkem1024_parse_public_key(
|
|
1649
|
+
MLKEM1024_public_key *public_key, CBS *in) {
|
|
1650
|
+
mlkem::public_key<RANK1024> *pub =
|
|
1347
1651
|
mlkem::public_key_1024_from_external(public_key);
|
|
1348
1652
|
if (!mlkem_parse_public_key(pub, in)) {
|
|
1349
1653
|
return bcm_status::failure;
|
|
@@ -1351,9 +1655,9 @@ bcm_status BCM_mlkem1024_parse_public_key(
|
|
|
1351
1655
|
return bcm_status::approved;
|
|
1352
1656
|
}
|
|
1353
1657
|
|
|
1354
|
-
bcm_status BCM_mlkem768_marshal_private_key(
|
|
1355
|
-
CBB *out, const
|
|
1356
|
-
const
|
|
1658
|
+
bcm_status bssl::BCM_mlkem768_marshal_private_key(
|
|
1659
|
+
CBB *out, const MLKEM768_private_key *private_key) {
|
|
1660
|
+
const mlkem::private_key<RANK768> *const priv =
|
|
1357
1661
|
mlkem::private_key_768_from_external(private_key);
|
|
1358
1662
|
if (!mlkem_marshal_private_key(out, priv)) {
|
|
1359
1663
|
return bcm_status::failure;
|
|
@@ -1361,9 +1665,9 @@ bcm_status BCM_mlkem768_marshal_private_key(
|
|
|
1361
1665
|
return bcm_status::approved;
|
|
1362
1666
|
}
|
|
1363
1667
|
|
|
1364
|
-
bcm_status BCM_mlkem1024_marshal_private_key(
|
|
1365
|
-
CBB *out, const
|
|
1366
|
-
const
|
|
1668
|
+
bcm_status bssl::BCM_mlkem1024_marshal_private_key(
|
|
1669
|
+
CBB *out, const MLKEM1024_private_key *private_key) {
|
|
1670
|
+
const mlkem::private_key<RANK1024> *const priv =
|
|
1367
1671
|
mlkem::private_key_1024_from_external(private_key);
|
|
1368
1672
|
if (!mlkem_marshal_private_key(out, priv)) {
|
|
1369
1673
|
return bcm_status::failure;
|
|
@@ -1371,9 +1675,9 @@ bcm_status BCM_mlkem1024_marshal_private_key(
|
|
|
1371
1675
|
return bcm_status::approved;
|
|
1372
1676
|
}
|
|
1373
1677
|
|
|
1374
|
-
bcm_status BCM_mlkem768_parse_private_key(
|
|
1375
|
-
|
|
1376
|
-
|
|
1678
|
+
bcm_status bssl::BCM_mlkem768_parse_private_key(
|
|
1679
|
+
MLKEM768_private_key *out_private_key, CBS *in) {
|
|
1680
|
+
mlkem::private_key<RANK768> *const priv =
|
|
1377
1681
|
mlkem::private_key_768_from_external(out_private_key);
|
|
1378
1682
|
if (!mlkem_parse_private_key(priv, in)) {
|
|
1379
1683
|
return bcm_status::failure;
|
|
@@ -1381,9 +1685,9 @@ bcm_status BCM_mlkem768_parse_private_key(
|
|
|
1381
1685
|
return bcm_status::approved;
|
|
1382
1686
|
}
|
|
1383
1687
|
|
|
1384
|
-
bcm_status BCM_mlkem1024_parse_private_key(
|
|
1385
|
-
|
|
1386
|
-
|
|
1688
|
+
bcm_status bssl::BCM_mlkem1024_parse_private_key(
|
|
1689
|
+
MLKEM1024_private_key *out_private_key, CBS *in) {
|
|
1690
|
+
mlkem::private_key<RANK1024> *const priv =
|
|
1387
1691
|
mlkem::private_key_1024_from_external(out_private_key);
|
|
1388
1692
|
if (!mlkem_parse_private_key(priv, in)) {
|
|
1389
1693
|
return bcm_status::failure;
|
|
@@ -1391,7 +1695,7 @@ bcm_status BCM_mlkem1024_parse_private_key(
|
|
|
1391
1695
|
return bcm_status::approved;
|
|
1392
1696
|
}
|
|
1393
1697
|
|
|
1394
|
-
int boringssl_self_test_mlkem() {
|
|
1698
|
+
int bssl::boringssl_self_test_mlkem() {
|
|
1395
1699
|
return mlkem::fips::keygen_self_test() && mlkem::fips::encap_self_test() &&
|
|
1396
1700
|
mlkem::fips::decap_self_test();
|
|
1397
1701
|
}
|