pq_crypto 0.4.2 → 0.5.1
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/.github/workflows/ci.yml +27 -2
- data/CHANGELOG.md +59 -0
- data/GET_STARTED.md +21 -16
- data/README.md +26 -0
- data/SECURITY.md +22 -16
- data/ext/pqcrypto/extconf.rb +183 -99
- data/ext/pqcrypto/mldsa_api.h +1 -118
- data/ext/pqcrypto/mlkem_api.h +1 -42
- data/ext/pqcrypto/pq_externalmu.c +88 -216
- data/ext/pqcrypto/pqcrypto_native_api.h +132 -0
- data/ext/pqcrypto/pqcrypto_ruby_secure.c +234 -12
- data/ext/pqcrypto/pqcrypto_secure.c +429 -334
- data/ext/pqcrypto/pqcrypto_secure.h +13 -45
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/randombytes.h +9 -0
- data/ext/pqcrypto/vendor/.vendored +12 -5
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +105 -0
- data/ext/pqcrypto/vendor/mldsa-native/LICENSE +286 -0
- data/ext/pqcrypto/vendor/mldsa-native/META.yml +24 -0
- data/ext/pqcrypto/vendor/mldsa-native/README.md +221 -0
- data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +8 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +721 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +975 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +724 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +723 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +166 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +321 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.c +21 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +385 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +73 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +130 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +277 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +244 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +182 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +117 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +438 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +105 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +71 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +62 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +376 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +204 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +259 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1077 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +987 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +41 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +26 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +35 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +37 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +27 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +36 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +69 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +32 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +20 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +638 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +136 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +52 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +29 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +488 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +16 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/xkcp.h +31 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +247 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +231 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +150 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +753 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +129 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +145 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +177 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +653 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +79 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +55 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +85 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +85 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +102 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +110 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +72 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +69 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +40 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +189 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +135 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +128 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +543 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +62 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +649 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +23 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +315 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +124 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +2311 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +2383 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +239 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +131 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +187 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +61 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +52 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +102 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +104 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +91 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +93 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +126 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +160 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +293 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +224 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +77 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +991 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +393 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +946 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +360 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +877 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +725 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +249 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +1511 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +806 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +268 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +104 -0
- data/ext/pqcrypto/vendor/mlkem-native/LICENSE +294 -0
- data/ext/pqcrypto/vendor/mlkem-native/META.yml +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/README.md +223 -0
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +86 -0
- data/ext/pqcrypto/vendor/mlkem-native/SECURITY.md +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +23 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +660 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +538 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +681 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +709 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +174 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +274 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +717 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +688 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +64 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +128 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +251 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +158 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +208 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +80 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +463 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +98 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +70 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +375 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +203 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +258 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1076 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +986 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +46 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +34 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +35 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +26 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +35 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +117 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/README.md +10 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +79 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +35 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +667 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +40 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +51 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +290 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +314 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +28 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +33 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +41 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2.S +451 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +51 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +622 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +156 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +446 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +326 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/README.md +16 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +122 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +174 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +177 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/intt.S +628 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/ntt.S +562 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_mulcache_compute_asm.S +127 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_reduce_asm.S +150 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tobytes_asm.S +117 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tomont_asm.S +98 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +261 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +314 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +368 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_asm.S +226 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +542 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +637 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/README.md +11 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +128 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +45 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +81 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +145 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_izetas.inc +27 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +805 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas.inc +27 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas_basemul.inc +39 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/README.md +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +304 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +309 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +94 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +45 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +102 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/intt.S +719 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mulcache_compute.S +90 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntt.S +639 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttfrombytes.S +193 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntttobytes.S +181 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttunpack.S +174 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d10.S +382 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d11.S +448 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d4.S +163 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d5.S +220 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d10.S +228 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d11.S +277 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d4.S +180 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d5.S +192 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +502 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +750 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +998 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/reduce.S +218 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_asm.S +103 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +544 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/tomont.S +155 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/params.h +76 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +572 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +317 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +502 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +668 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +60 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +362 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +118 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/symmetric.h +70 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +260 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.c +20 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +464 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/zetas.inc +30 -0
- data/lib/pq_crypto/hybrid_kem.rb +10 -1
- data/lib/pq_crypto/version.rb +1 -1
- data/lib/pq_crypto.rb +5 -1
- data/script/vendor_libs.rb +228 -154
- metadata +236 -160
- data/ext/pqcrypto/vendor/pqclean/common/aes.c +0 -639
- data/ext/pqcrypto/vendor/pqclean/common/aes.h +0 -64
- data/ext/pqcrypto/vendor/pqclean/common/compat.h +0 -73
- data/ext/pqcrypto/vendor/pqclean/common/crypto_declassify.h +0 -7
- data/ext/pqcrypto/vendor/pqclean/common/fips202.c +0 -928
- data/ext/pqcrypto/vendor/pqclean/common/fips202.h +0 -166
- data/ext/pqcrypto/vendor/pqclean/common/keccak2x/feat.S +0 -168
- data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.c +0 -684
- data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.h +0 -60
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SIMD256.c +0 -1028
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SnP.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-unrolling.macros +0 -198
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile +0 -8
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile.Microsoft_nmake +0 -8
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/SIMD256-config.h +0 -3
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/align.h +0 -34
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/brg_endian.h +0 -142
- data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.c +0 -101
- data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.h +0 -39
- data/ext/pqcrypto/vendor/pqclean/common/randombytes.c +0 -355
- data/ext/pqcrypto/vendor/pqclean/common/randombytes.h +0 -27
- data/ext/pqcrypto/vendor/pqclean/common/sha2.c +0 -769
- data/ext/pqcrypto/vendor/pqclean/common/sha2.h +0 -173
- data/ext/pqcrypto/vendor/pqclean/common/sp800-185.c +0 -156
- data/ext/pqcrypto/vendor/pqclean/common/sp800-185.h +0 -27
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/api.h +0 -18
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.c +0 -83
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.h +0 -11
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.c +0 -327
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.h +0 -22
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.c +0 -164
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.h +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.c +0 -146
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/params.h +0 -36
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.c +0 -311
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.h +0 -37
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.c +0 -198
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.h +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.c +0 -41
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric-shake.c +0 -71
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric.h +0 -30
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.c +0 -67
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/api.h +0 -18
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.c +0 -108
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.h +0 -11
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.c +0 -327
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.h +0 -22
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.c +0 -164
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.h +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.c +0 -146
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/params.h +0 -36
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.c +0 -299
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.h +0 -37
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.c +0 -188
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.h +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.c +0 -41
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric-shake.c +0 -71
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric.h +0 -30
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.c +0 -67
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/api.h +0 -18
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.c +0 -83
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.h +0 -11
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.c +0 -327
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.h +0 -22
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.c +0 -164
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.h +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.c +0 -146
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/params.h +0 -36
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.c +0 -299
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.h +0 -37
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.c +0 -188
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.h +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.c +0 -41
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric-shake.c +0 -71
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric.h +0 -30
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.c +0 -67
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/api.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.h +0 -10
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.c +0 -261
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.h +0 -31
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/params.h +0 -44
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.c +0 -848
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.h +0 -52
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.c +0 -415
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.h +0 -65
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.c +0 -69
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.h +0 -17
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.c +0 -407
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.h +0 -47
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric-shake.c +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric.h +0 -34
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/api.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.h +0 -10
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.c +0 -261
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.h +0 -31
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/params.h +0 -44
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.c +0 -799
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.h +0 -52
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.c +0 -415
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.h +0 -65
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.c +0 -69
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.h +0 -17
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.c +0 -92
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.c +0 -407
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.h +0 -47
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric-shake.c +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric.h +0 -34
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/api.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.h +0 -10
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.c +0 -261
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.h +0 -31
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/params.h +0 -44
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.c +0 -823
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.h +0 -52
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.c +0 -415
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.h +0 -65
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.c +0 -69
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.h +0 -17
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.c +0 -92
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.c +0 -407
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.h +0 -47
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric-shake.c +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric.h +0 -34
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* References
|
|
7
|
+
* ==========
|
|
8
|
+
*
|
|
9
|
+
* - [FIPS203]
|
|
10
|
+
* FIPS 203 Module-Lattice-Based Key-Encapsulation Mechanism Standard
|
|
11
|
+
* National Institute of Standards and Technology
|
|
12
|
+
* https://csrc.nist.gov/pubs/fips/203/final
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
#ifndef MLK_H
|
|
16
|
+
#define MLK_H
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* Public API for mlkem-native.
|
|
20
|
+
*
|
|
21
|
+
* This header defines the public API of a single build of mlkem-native.
|
|
22
|
+
*
|
|
23
|
+
* Make sure the configuration file is in the include path
|
|
24
|
+
* (this is "mlkem_native_config.h" by default, or MLK_CONFIG_FILE if defined).
|
|
25
|
+
*
|
|
26
|
+
* # Multi-level builds
|
|
27
|
+
*
|
|
28
|
+
* This header specifies a build of mlkem-native for a fixed security level.
|
|
29
|
+
* If you need multiple security levels, leave the security level unspecified
|
|
30
|
+
* in the configuration file and include this header multiple times, setting
|
|
31
|
+
* MLK_CONFIG_PARAMETER_SET accordingly for each, and #undef'ing the MLK_H
|
|
32
|
+
* guard to allow multiple inclusions.
|
|
33
|
+
*
|
|
34
|
+
* # Legacy configuration (deprecated)
|
|
35
|
+
*
|
|
36
|
+
* Instead of providing the config file used for the build, you can
|
|
37
|
+
* alternatively set the following configuration options prior to
|
|
38
|
+
* including this header.
|
|
39
|
+
*
|
|
40
|
+
* This method of configuration is deprecated.
|
|
41
|
+
* It will be removed in mlkem-native-v2.
|
|
42
|
+
*
|
|
43
|
+
* - MLK_CONFIG_API_PARAMETER_SET [required]
|
|
44
|
+
*
|
|
45
|
+
* The parameter set used for the build; 512, 768, or 1024.
|
|
46
|
+
*
|
|
47
|
+
* - MLK_CONFIG_API_NAMESPACE_PREFIX [required]
|
|
48
|
+
*
|
|
49
|
+
* The namespace prefix used for the build.
|
|
50
|
+
*
|
|
51
|
+
* NOTE:
|
|
52
|
+
* For a multi-level build, you must include the 512/768/1024 suffixes
|
|
53
|
+
* in MLK_CONFIG_API_NAMESPACE_PREFIX.
|
|
54
|
+
*
|
|
55
|
+
* - MLK_CONFIG_API_NO_SUPERCOP [optional]
|
|
56
|
+
*
|
|
57
|
+
* By default, this header will also expose the mlkem-native API in the
|
|
58
|
+
* SUPERCOP naming convention crypto_kem_xxx. If you don't want/need this,
|
|
59
|
+
* set MLK_CONFIG_API_NO_SUPERCOP. You must set this for a multi-level build.
|
|
60
|
+
*
|
|
61
|
+
* - MLK_CONFIG_API_CONSTANTS_ONLY [optional]
|
|
62
|
+
*
|
|
63
|
+
* If you don't want this header to expose any function declarations,
|
|
64
|
+
* but only constants for the sizes of key material, set
|
|
65
|
+
* MLK_CONFIG_API_CONSTANTS_ONLY. In this case, you don't need to set
|
|
66
|
+
* MLK_CONFIG_API_PARAMETER_SET or MLK_CONFIG_API_NAMESPACE_PREFIX,
|
|
67
|
+
* nor include a configuration.
|
|
68
|
+
*
|
|
69
|
+
* - MLK_CONFIG_API_QUALIFIER [optional]
|
|
70
|
+
*
|
|
71
|
+
* Qualifier to apply to external API.
|
|
72
|
+
*
|
|
73
|
+
******************************************************************************/
|
|
74
|
+
|
|
75
|
+
/******************************* Key sizes ************************************/
|
|
76
|
+
|
|
77
|
+
/* Sizes of cryptographic material, per parameter set */
|
|
78
|
+
/* See mlkem/common.h for the arithmetic expressions giving rise to these */
|
|
79
|
+
/* check-magic: off */
|
|
80
|
+
#define MLKEM512_SECRETKEYBYTES 1632
|
|
81
|
+
#define MLKEM512_PUBLICKEYBYTES 800
|
|
82
|
+
#define MLKEM512_CIPHERTEXTBYTES 768
|
|
83
|
+
|
|
84
|
+
#define MLKEM768_SECRETKEYBYTES 2400
|
|
85
|
+
#define MLKEM768_PUBLICKEYBYTES 1184
|
|
86
|
+
#define MLKEM768_CIPHERTEXTBYTES 1088
|
|
87
|
+
|
|
88
|
+
#define MLKEM1024_SECRETKEYBYTES 3168
|
|
89
|
+
#define MLKEM1024_PUBLICKEYBYTES 1568
|
|
90
|
+
#define MLKEM1024_CIPHERTEXTBYTES 1568
|
|
91
|
+
/* check-magic: on */
|
|
92
|
+
|
|
93
|
+
/* Size of randomness coins in bytes (level-independent) */
|
|
94
|
+
#define MLKEM_SYMBYTES 32
|
|
95
|
+
#define MLKEM512_SYMBYTES MLKEM_SYMBYTES
|
|
96
|
+
#define MLKEM768_SYMBYTES MLKEM_SYMBYTES
|
|
97
|
+
#define MLKEM1024_SYMBYTES MLKEM_SYMBYTES
|
|
98
|
+
/* Size of shared secret in bytes (level-independent) */
|
|
99
|
+
#define MLKEM_BYTES 32
|
|
100
|
+
#define MLKEM512_BYTES MLKEM_BYTES
|
|
101
|
+
#define MLKEM768_BYTES MLKEM_BYTES
|
|
102
|
+
#define MLKEM1024_BYTES MLKEM_BYTES
|
|
103
|
+
|
|
104
|
+
/* Sizes of cryptographic material, as a function of LVL=512,768,1024 */
|
|
105
|
+
#define MLKEM_SECRETKEYBYTES_(LVL) MLKEM##LVL##_SECRETKEYBYTES
|
|
106
|
+
#define MLKEM_PUBLICKEYBYTES_(LVL) MLKEM##LVL##_PUBLICKEYBYTES
|
|
107
|
+
#define MLKEM_CIPHERTEXTBYTES_(LVL) MLKEM##LVL##_CIPHERTEXTBYTES
|
|
108
|
+
#define MLKEM_SECRETKEYBYTES(LVL) MLKEM_SECRETKEYBYTES_(LVL)
|
|
109
|
+
#define MLKEM_PUBLICKEYBYTES(LVL) MLKEM_PUBLICKEYBYTES_(LVL)
|
|
110
|
+
#define MLKEM_CIPHERTEXTBYTES(LVL) MLKEM_CIPHERTEXTBYTES_(LVL)
|
|
111
|
+
|
|
112
|
+
/****************************** Error codes ***********************************/
|
|
113
|
+
|
|
114
|
+
/* Generic failure condition */
|
|
115
|
+
#define MLK_ERR_FAIL -1
|
|
116
|
+
/* An allocation failed. This can only happen if MLK_CONFIG_CUSTOM_ALLOC_FREE
|
|
117
|
+
* is defined and the provided MLK_CUSTOM_ALLOC can fail. */
|
|
118
|
+
#define MLK_ERR_OUT_OF_MEMORY -2
|
|
119
|
+
/* An rng failure occured. Might be due to insufficient entropy or
|
|
120
|
+
* system misconfiguration. */
|
|
121
|
+
#define MLK_ERR_RNG_FAIL -3
|
|
122
|
+
|
|
123
|
+
/****************************** Function API **********************************/
|
|
124
|
+
|
|
125
|
+
#define MLK_API_CONCAT_(x, y) x##y
|
|
126
|
+
#define MLK_API_CONCAT(x, y) MLK_API_CONCAT_(x, y)
|
|
127
|
+
#define MLK_API_CONCAT_UNDERSCORE(x, y) MLK_API_CONCAT(MLK_API_CONCAT(x, _), y)
|
|
128
|
+
|
|
129
|
+
#if !defined(MLK_CONFIG_API_PARAMETER_SET)
|
|
130
|
+
/* Recommended configuration via same config file as used for the build. */
|
|
131
|
+
|
|
132
|
+
/* For now, we derive the legacy API configuration MLK_CONFIG_API_XXX from
|
|
133
|
+
* the config file. In mlkem-native-v2, this will be removed and we will
|
|
134
|
+
* exclusively work with MLK_CONFIG_XXX. */
|
|
135
|
+
|
|
136
|
+
/* You need to make sure the config file is in the include path. */
|
|
137
|
+
#if defined(MLK_CONFIG_FILE)
|
|
138
|
+
#include MLK_CONFIG_FILE
|
|
139
|
+
#else
|
|
140
|
+
#include "mlkem_native_config.h"
|
|
141
|
+
#endif
|
|
142
|
+
|
|
143
|
+
#define MLK_CONFIG_API_PARAMETER_SET MLK_CONFIG_PARAMETER_SET
|
|
144
|
+
|
|
145
|
+
#if defined(MLK_CONFIG_MULTILEVEL_BUILD)
|
|
146
|
+
#define MLK_CONFIG_API_NAMESPACE_PREFIX \
|
|
147
|
+
MLK_API_CONCAT(MLK_CONFIG_NAMESPACE_PREFIX, MLK_CONFIG_PARAMETER_SET)
|
|
148
|
+
#else
|
|
149
|
+
#define MLK_CONFIG_API_NAMESPACE_PREFIX MLK_CONFIG_NAMESPACE_PREFIX
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
#if defined(MLK_CONFIG_NO_SUPERCOP)
|
|
153
|
+
#define MLK_CONFIG_API_NO_SUPERCOP
|
|
154
|
+
#endif
|
|
155
|
+
|
|
156
|
+
#if defined(MLK_CONFIG_CONSTANTS_ONLY)
|
|
157
|
+
#define MLK_CONFIG_API_CONSTANTS_ONLY
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
#if defined(MLK_CONFIG_EXTERNAL_API_QUALIFIER)
|
|
161
|
+
#define MLK_CONFIG_API_QUALIFIER MLK_CONFIG_EXTERNAL_API_QUALIFIER
|
|
162
|
+
#endif
|
|
163
|
+
|
|
164
|
+
#else /* !MLK_CONFIG_API_PARAMETER_SET */
|
|
165
|
+
|
|
166
|
+
#define MLK_API_LEGACY_CONFIG
|
|
167
|
+
|
|
168
|
+
#endif /* MLK_CONFIG_API_PARAMETER_SET */
|
|
169
|
+
|
|
170
|
+
#define MLK_API_NAMESPACE(sym) \
|
|
171
|
+
MLK_API_CONCAT_UNDERSCORE(MLK_CONFIG_API_NAMESPACE_PREFIX, sym)
|
|
172
|
+
|
|
173
|
+
#if defined(__GNUC__) || defined(clang)
|
|
174
|
+
#define MLK_API_MUST_CHECK_RETURN_VALUE __attribute__((warn_unused_result))
|
|
175
|
+
#else
|
|
176
|
+
#define MLK_API_MUST_CHECK_RETURN_VALUE
|
|
177
|
+
#endif
|
|
178
|
+
|
|
179
|
+
#if defined(MLK_CONFIG_API_QUALIFIER)
|
|
180
|
+
#define MLK_API_QUALIFIER MLK_CONFIG_API_QUALIFIER
|
|
181
|
+
#else
|
|
182
|
+
#define MLK_API_QUALIFIER
|
|
183
|
+
#endif
|
|
184
|
+
|
|
185
|
+
#if !defined(MLK_CONFIG_API_CONSTANTS_ONLY)
|
|
186
|
+
|
|
187
|
+
#include <stdint.h>
|
|
188
|
+
|
|
189
|
+
#ifdef __cplusplus
|
|
190
|
+
extern "C"
|
|
191
|
+
{
|
|
192
|
+
#endif
|
|
193
|
+
|
|
194
|
+
/*************************************************
|
|
195
|
+
* Name: crypto_kem_keypair_derand
|
|
196
|
+
*
|
|
197
|
+
* Description: Generates public and private key
|
|
198
|
+
* for CCA-secure ML-KEM key encapsulation mechanism
|
|
199
|
+
*
|
|
200
|
+
* Arguments: - uint8_t pk[]: pointer to output public key, an array of
|
|
201
|
+
* length MLKEM{512,768,1024}_PUBLICKEYBYTES bytes.
|
|
202
|
+
* - uint8_t sk[]: pointer to output private key, an array of
|
|
203
|
+
* of MLKEM{512,768,1024}_SECRETKEYBYTES bytes.
|
|
204
|
+
* - uint8_t *coins: pointer to input randomness, an array of
|
|
205
|
+
* 2*MLKEM_SYMBYTES uniformly random bytes.
|
|
206
|
+
*
|
|
207
|
+
* Returns: - 0: On success
|
|
208
|
+
* - MLK_ERR_FAIL: If MLK_CONFIG_KEYGEN_PCT is enabled and the
|
|
209
|
+
* PCT failed.
|
|
210
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
211
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
212
|
+
*
|
|
213
|
+
* Specification: Implements @[FIPS203, Algorithm 16, ML-KEM.KeyGen_Internal]
|
|
214
|
+
*
|
|
215
|
+
**************************************************/
|
|
216
|
+
MLK_API_QUALIFIER
|
|
217
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
218
|
+
int MLK_API_NAMESPACE(keypair_derand)(
|
|
219
|
+
uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
220
|
+
uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
221
|
+
const uint8_t coins[2 * MLKEM_SYMBYTES]
|
|
222
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
223
|
+
,
|
|
224
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
225
|
+
#endif
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
#if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
|
|
230
|
+
/*************************************************
|
|
231
|
+
* Name: crypto_kem_keypair
|
|
232
|
+
*
|
|
233
|
+
* Description: Generates public and private key
|
|
234
|
+
* for CCA-secure ML-KEM key encapsulation mechanism
|
|
235
|
+
*
|
|
236
|
+
* Arguments: - uint8_t *pk: pointer to output public key, an array of
|
|
237
|
+
* MLKEM{512,768,1024}_PUBLICKEYBYTES bytes.
|
|
238
|
+
* - uint8_t *sk: pointer to output private key, an array of
|
|
239
|
+
* MLKEM{512,768,1024}_SECRETKEYBYTES bytes.
|
|
240
|
+
*
|
|
241
|
+
* Returns: - 0: On success
|
|
242
|
+
* - MLK_ERR_FAIL: If MLK_CONFIG_KEYGEN_PCT is enabled and the
|
|
243
|
+
* PCT failed.
|
|
244
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
245
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
246
|
+
* - MLK_ERR_RNG_FAIL: Random number generation failed.
|
|
247
|
+
*
|
|
248
|
+
* Specification: Implements @[FIPS203, Algorithm 19, ML-KEM.KeyGen]
|
|
249
|
+
*
|
|
250
|
+
**************************************************/
|
|
251
|
+
MLK_API_QUALIFIER
|
|
252
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
253
|
+
int MLK_API_NAMESPACE(keypair)(
|
|
254
|
+
uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
255
|
+
uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
|
|
256
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
257
|
+
,
|
|
258
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
259
|
+
#endif
|
|
260
|
+
);
|
|
261
|
+
#endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
|
|
262
|
+
|
|
263
|
+
/*************************************************
|
|
264
|
+
* Name: crypto_kem_enc_derand
|
|
265
|
+
*
|
|
266
|
+
* Description: Generates cipher text and shared
|
|
267
|
+
* secret for given public key
|
|
268
|
+
*
|
|
269
|
+
* Arguments: - uint8_t *ct: pointer to output cipher text, an array of
|
|
270
|
+
* MLKEM{512,768,1024}_CIPHERTEXTBYTES bytes.
|
|
271
|
+
* - uint8_t *ss: pointer to output shared secret, an array of
|
|
272
|
+
* MLKEM_BYTES bytes.
|
|
273
|
+
* - const uint8_t *pk: pointer to input public key, an array of
|
|
274
|
+
* MLKEM{512,768,1024}_PUBLICKEYBYTES bytes.
|
|
275
|
+
* - const uint8_t *coins: pointer to input randomness, an array of
|
|
276
|
+
* MLKEM_SYMBYTES bytes.
|
|
277
|
+
*
|
|
278
|
+
* Returns: - 0 on success
|
|
279
|
+
* - MLK_ERR_FAIL: If the 'modulus check' @[FIPS203, Section 7.2]
|
|
280
|
+
* for the public key fails.
|
|
281
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
282
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
283
|
+
*
|
|
284
|
+
* Specification: Implements @[FIPS203, Algorithm 17, ML-KEM.Encaps_Internal]
|
|
285
|
+
*
|
|
286
|
+
**************************************************/
|
|
287
|
+
MLK_API_QUALIFIER
|
|
288
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
289
|
+
int MLK_API_NAMESPACE(enc_derand)(
|
|
290
|
+
uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
291
|
+
uint8_t ss[MLKEM_BYTES],
|
|
292
|
+
const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
293
|
+
const uint8_t coins[MLKEM_SYMBYTES]
|
|
294
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
295
|
+
,
|
|
296
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
297
|
+
#endif
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
#if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
|
|
301
|
+
/*************************************************
|
|
302
|
+
* Name: crypto_kem_enc
|
|
303
|
+
*
|
|
304
|
+
* Description: Generates cipher text and shared
|
|
305
|
+
* secret for given public key
|
|
306
|
+
*
|
|
307
|
+
* Arguments: - uint8_t *ct: pointer to output cipher text, an array of
|
|
308
|
+
* MLKEM{512,768,1024}_CIPHERTEXTBYTES bytes.
|
|
309
|
+
* - uint8_t *ss: pointer to output shared secret, an array of
|
|
310
|
+
* MLKEM_BYTES bytes.
|
|
311
|
+
* - const uint8_t *pk: pointer to input public key, an array of
|
|
312
|
+
* MLKEM{512,768,1024}_PUBLICKEYBYTES bytes.
|
|
313
|
+
*
|
|
314
|
+
* Returns: - 0 on success
|
|
315
|
+
* - MLK_ERR_FAIL: If the 'modulus check' @[FIPS203, Section 7.2]
|
|
316
|
+
* for the public key fails.
|
|
317
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
318
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
319
|
+
* - MLK_ERR_RNG_FAIL: Random number generation failed.
|
|
320
|
+
*
|
|
321
|
+
* Specification: Implements @[FIPS203, Algorithm 20, ML-KEM.Encaps]
|
|
322
|
+
*
|
|
323
|
+
**************************************************/
|
|
324
|
+
MLK_API_QUALIFIER
|
|
325
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
326
|
+
int MLK_API_NAMESPACE(enc)(
|
|
327
|
+
uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
328
|
+
uint8_t ss[MLKEM_BYTES],
|
|
329
|
+
const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
|
|
330
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
331
|
+
,
|
|
332
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
333
|
+
#endif
|
|
334
|
+
);
|
|
335
|
+
#endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
|
|
336
|
+
|
|
337
|
+
/*************************************************
|
|
338
|
+
* Name: crypto_kem_dec
|
|
339
|
+
*
|
|
340
|
+
* Description: Generates shared secret for given
|
|
341
|
+
* cipher text and private key
|
|
342
|
+
*
|
|
343
|
+
* Arguments: - uint8_t *ss: pointer to output shared secret, an array of
|
|
344
|
+
* MLKEM_BYTES bytes.
|
|
345
|
+
* - const uint8_t *ct: pointer to input cipher text, an array of
|
|
346
|
+
* MLKEM{512,768,1024}_CIPHERTEXTBYTES bytes.
|
|
347
|
+
* - const uint8_t *sk: pointer to input private key, an array of
|
|
348
|
+
* MLKEM{512,768,1024}_SECRETKEYBYTES bytes.
|
|
349
|
+
*
|
|
350
|
+
* Returns: - 0 on success
|
|
351
|
+
* - MLK_ERR_FAIL: If the 'hash check' @[FIPS203, Section 7.3]
|
|
352
|
+
* for the secret key fails.
|
|
353
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
354
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
355
|
+
*
|
|
356
|
+
* Specification: Implements @[FIPS203, Algorithm 21, ML-KEM.Decaps]
|
|
357
|
+
*
|
|
358
|
+
**************************************************/
|
|
359
|
+
MLK_API_QUALIFIER
|
|
360
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
361
|
+
int MLK_API_NAMESPACE(dec)(
|
|
362
|
+
uint8_t ss[MLKEM_BYTES],
|
|
363
|
+
const uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)],
|
|
364
|
+
const uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
|
|
365
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
366
|
+
,
|
|
367
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
368
|
+
#endif
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
/*************************************************
|
|
373
|
+
* Name: crypto_kem_check_pk
|
|
374
|
+
*
|
|
375
|
+
* Description: Implements modulus check mandated by FIPS 203,
|
|
376
|
+
* i.e., ensures that coefficients are in [0,q-1].
|
|
377
|
+
*
|
|
378
|
+
* Arguments: - const uint8_t *pk: pointer to input public key, an array of
|
|
379
|
+
* MLKEM{512,768,1024}_PUBLICKEYBYTES bytes.
|
|
380
|
+
*
|
|
381
|
+
* Returns: - 0 on success
|
|
382
|
+
* - MLK_ERR_FAIL: If the modulus check failed.
|
|
383
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
384
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
385
|
+
*
|
|
386
|
+
* Specification: Implements @[FIPS203, Section 7.2, 'modulus check']
|
|
387
|
+
*
|
|
388
|
+
**************************************************/
|
|
389
|
+
MLK_API_QUALIFIER
|
|
390
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
391
|
+
int MLK_API_NAMESPACE(check_pk)(
|
|
392
|
+
const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
|
|
393
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
394
|
+
,
|
|
395
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
396
|
+
#endif
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
/*************************************************
|
|
400
|
+
* Name: crypto_kem_check_sk
|
|
401
|
+
*
|
|
402
|
+
* Description: Implements public key hash check mandated by FIPS 203,
|
|
403
|
+
* i.e., ensures that
|
|
404
|
+
* sk[768𝑘+32 ∶ 768𝑘+64] = H(pk)= H(sk[384𝑘 : 768𝑘+32])
|
|
405
|
+
*
|
|
406
|
+
* Arguments: - const uint8_t *sk: pointer to input private key, an array of
|
|
407
|
+
* MLKEM{512,768,1024}_SECRETKEYBYTES bytes.
|
|
408
|
+
*
|
|
409
|
+
* Returns: - 0 on success
|
|
410
|
+
* - MLK_ERR_FAIL: If the public key hash check failed.
|
|
411
|
+
* - MLK_ERR_OUT_OF_MEMORY: If MLK_CONFIG_CUSTOM_ALLOC_FREE is
|
|
412
|
+
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
413
|
+
*
|
|
414
|
+
* Specification: Implements @[FIPS203, Section 7.3, 'hash check']
|
|
415
|
+
*
|
|
416
|
+
**************************************************/
|
|
417
|
+
MLK_API_QUALIFIER
|
|
418
|
+
MLK_API_MUST_CHECK_RETURN_VALUE
|
|
419
|
+
int MLK_API_NAMESPACE(check_sk)(
|
|
420
|
+
const uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
|
|
421
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
422
|
+
,
|
|
423
|
+
MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
424
|
+
#endif
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
#ifdef __cplusplus
|
|
428
|
+
}
|
|
429
|
+
#endif
|
|
430
|
+
|
|
431
|
+
/****************************** SUPERCOP API *********************************/
|
|
432
|
+
|
|
433
|
+
#if !defined(MLK_CONFIG_API_NO_SUPERCOP)
|
|
434
|
+
/* Export API in SUPERCOP naming scheme CRYPTO_xxx / crypto_kem_xxx */
|
|
435
|
+
#define CRYPTO_SECRETKEYBYTES MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)
|
|
436
|
+
#define CRYPTO_PUBLICKEYBYTES MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)
|
|
437
|
+
#define CRYPTO_CIPHERTEXTBYTES \
|
|
438
|
+
MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)
|
|
439
|
+
#define CRYPTO_SYMBYTES MLKEM_SYMBYTES
|
|
440
|
+
#define CRYPTO_BYTES MLKEM_BYTES
|
|
441
|
+
|
|
442
|
+
#define crypto_kem_keypair_derand MLK_API_NAMESPACE(keypair_derand)
|
|
443
|
+
#define crypto_kem_keypair MLK_API_NAMESPACE(keypair)
|
|
444
|
+
#define crypto_kem_enc_derand MLK_API_NAMESPACE(enc_derand)
|
|
445
|
+
#define crypto_kem_enc MLK_API_NAMESPACE(enc)
|
|
446
|
+
#define crypto_kem_dec MLK_API_NAMESPACE(dec)
|
|
447
|
+
#define crypto_kem_check_pk MLK_API_NAMESPACE(check_pk)
|
|
448
|
+
#define crypto_kem_check_sk MLK_API_NAMESPACE(check_sk)
|
|
449
|
+
|
|
450
|
+
#else /* !MLK_CONFIG_API_NO_SUPERCOP */
|
|
451
|
+
|
|
452
|
+
/* If the SUPERCOP API is not needed, we can undefine the various helper macros
|
|
453
|
+
* above. Otherwise, they are needed for lazy evaluation of crypto_kem_xxx. */
|
|
454
|
+
#if !defined(MLK_API_LEGACY_CONFIG)
|
|
455
|
+
#undef MLK_CONFIG_API_PARAMETER_SET
|
|
456
|
+
#undef MLK_CONFIG_API_NAMESPACE_PREFIX
|
|
457
|
+
#undef MLK_CONFIG_API_NO_SUPERCOP
|
|
458
|
+
#undef MLK_CONFIG_API_CONSTANTS_ONLY
|
|
459
|
+
#undef MLK_CONFIG_API_QUALIFIER
|
|
460
|
+
#endif /* !MLK_API_LEGACY_CONFIG */
|
|
461
|
+
|
|
462
|
+
#undef MLK_API_CONCAT
|
|
463
|
+
#undef MLK_API_CONCAT_
|
|
464
|
+
#undef MLK_API_CONCAT_UNDERSCORE
|
|
465
|
+
#undef MLK_API_NAMESPACE
|
|
466
|
+
#undef MLK_API_MUST_CHECK_RETURN_VALUE
|
|
467
|
+
#undef MLK_API_QUALIFIER
|
|
468
|
+
#undef MLK_API_LEGACY_CONFIG
|
|
469
|
+
|
|
470
|
+
#endif /* MLK_CONFIG_API_NO_SUPERCOP */
|
|
471
|
+
#endif /* !MLK_CONFIG_API_CONSTANTS_ONLY */
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
/***************************** Memory Usage **********************************/
|
|
475
|
+
|
|
476
|
+
/*
|
|
477
|
+
* By default mlkem-native performs all memory allocations on the stack.
|
|
478
|
+
* Alternatively, mlkem-native supports custom allocation of large structures
|
|
479
|
+
* through the `MLK_CONFIG_CUSTOM_ALLOC_FREE` configuration option.
|
|
480
|
+
* See mlkem_native_config.h for details.
|
|
481
|
+
*
|
|
482
|
+
* `MLK_TOTAL_ALLOC_{512,768,1024}_{KEYPAIR,ENCAPS,DECAPS}` indicates the
|
|
483
|
+
* maximum (accumulative) allocation via MLK_ALLOC for each parameter set and
|
|
484
|
+
* operation. Note that some stack allocation remains even when using custom
|
|
485
|
+
* allocators, so these values are lower than total stack usage with the default
|
|
486
|
+
* stack-only allocation.
|
|
487
|
+
*
|
|
488
|
+
* These constants may be used to implement custom allocations using a
|
|
489
|
+
* fixed-sized buffer and a simple allocator (e.g., bump allocator).
|
|
490
|
+
*/
|
|
491
|
+
/* check-magic: off */
|
|
492
|
+
#define MLK_TOTAL_ALLOC_512_KEYPAIR_NO_PCT 5824
|
|
493
|
+
#define MLK_TOTAL_ALLOC_512_KEYPAIR_PCT 10048
|
|
494
|
+
#define MLK_TOTAL_ALLOC_512_ENCAPS 8384
|
|
495
|
+
#define MLK_TOTAL_ALLOC_512_DECAPS 9152
|
|
496
|
+
#define MLK_TOTAL_ALLOC_768_KEYPAIR_NO_PCT 10176
|
|
497
|
+
#define MLK_TOTAL_ALLOC_768_KEYPAIR_PCT 15552
|
|
498
|
+
#define MLK_TOTAL_ALLOC_768_ENCAPS 13248
|
|
499
|
+
#define MLK_TOTAL_ALLOC_768_DECAPS 14336
|
|
500
|
+
#define MLK_TOTAL_ALLOC_1024_KEYPAIR_NO_PCT 15552
|
|
501
|
+
#define MLK_TOTAL_ALLOC_1024_KEYPAIR_PCT 22400
|
|
502
|
+
#define MLK_TOTAL_ALLOC_1024_ENCAPS 19136
|
|
503
|
+
#define MLK_TOTAL_ALLOC_1024_DECAPS 20704
|
|
504
|
+
/* check-magic: on */
|
|
505
|
+
|
|
506
|
+
/*
|
|
507
|
+
* MLK_TOTAL_ALLOC_*_KEYPAIR adapts based on MLK_CONFIG_KEYGEN_PCT.
|
|
508
|
+
* For legacy config, we don't know which options are used, so assume
|
|
509
|
+
* the worst case (PCT enabled).
|
|
510
|
+
*/
|
|
511
|
+
#if defined(MLK_API_LEGACY_CONFIG) || defined(MLK_CONFIG_KEYGEN_PCT)
|
|
512
|
+
#define MLK_TOTAL_ALLOC_512_KEYPAIR MLK_TOTAL_ALLOC_512_KEYPAIR_PCT
|
|
513
|
+
#define MLK_TOTAL_ALLOC_768_KEYPAIR MLK_TOTAL_ALLOC_768_KEYPAIR_PCT
|
|
514
|
+
#define MLK_TOTAL_ALLOC_1024_KEYPAIR MLK_TOTAL_ALLOC_1024_KEYPAIR_PCT
|
|
515
|
+
#else
|
|
516
|
+
#define MLK_TOTAL_ALLOC_512_KEYPAIR MLK_TOTAL_ALLOC_512_KEYPAIR_NO_PCT
|
|
517
|
+
#define MLK_TOTAL_ALLOC_768_KEYPAIR MLK_TOTAL_ALLOC_768_KEYPAIR_NO_PCT
|
|
518
|
+
#define MLK_TOTAL_ALLOC_1024_KEYPAIR MLK_TOTAL_ALLOC_1024_KEYPAIR_NO_PCT
|
|
519
|
+
#endif
|
|
520
|
+
|
|
521
|
+
#define MLK_MAX3_(a, b, c) \
|
|
522
|
+
((a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c)))
|
|
523
|
+
|
|
524
|
+
/*
|
|
525
|
+
* `MLK_TOTAL_ALLOC_{512,768,1024}` is the maximum across all operations for
|
|
526
|
+
* each parameter set.
|
|
527
|
+
*/
|
|
528
|
+
#define MLK_TOTAL_ALLOC_512 \
|
|
529
|
+
MLK_MAX3_(MLK_TOTAL_ALLOC_512_KEYPAIR, MLK_TOTAL_ALLOC_512_ENCAPS, \
|
|
530
|
+
MLK_TOTAL_ALLOC_512_DECAPS)
|
|
531
|
+
#define MLK_TOTAL_ALLOC_768 \
|
|
532
|
+
MLK_MAX3_(MLK_TOTAL_ALLOC_768_KEYPAIR, MLK_TOTAL_ALLOC_768_ENCAPS, \
|
|
533
|
+
MLK_TOTAL_ALLOC_768_DECAPS)
|
|
534
|
+
#define MLK_TOTAL_ALLOC_1024 \
|
|
535
|
+
MLK_MAX3_(MLK_TOTAL_ALLOC_1024_KEYPAIR, MLK_TOTAL_ALLOC_1024_ENCAPS, \
|
|
536
|
+
MLK_TOTAL_ALLOC_1024_DECAPS)
|
|
537
|
+
|
|
538
|
+
#endif /* !MLK_H */
|