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,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* NOTE: You can remove this file unless you compile with MLKEM_DEBUG. */
|
|
7
|
+
|
|
8
|
+
#include "common.h"
|
|
9
|
+
|
|
10
|
+
#if !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(MLKEM_DEBUG)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#include <stdio.h>
|
|
14
|
+
#include <stdlib.h>
|
|
15
|
+
#include "debug.h"
|
|
16
|
+
|
|
17
|
+
#define MLK_DEBUG_ERROR_HEADER "[ERROR:%s:%04d] "
|
|
18
|
+
|
|
19
|
+
void mlk_debug_check_assert(const char *file, int line, const int val)
|
|
20
|
+
{
|
|
21
|
+
if (val == 0)
|
|
22
|
+
{
|
|
23
|
+
fprintf(stderr, MLK_DEBUG_ERROR_HEADER "Assertion failed (value %d)\n",
|
|
24
|
+
file, line, val);
|
|
25
|
+
exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void mlk_debug_check_bounds(const char *file, int line, const int16_t *ptr,
|
|
30
|
+
unsigned len, int lower_bound_exclusive,
|
|
31
|
+
int upper_bound_exclusive)
|
|
32
|
+
{
|
|
33
|
+
int err = 0;
|
|
34
|
+
unsigned i;
|
|
35
|
+
for (i = 0; i < len; i++)
|
|
36
|
+
{
|
|
37
|
+
int16_t val = ptr[i];
|
|
38
|
+
if (!(val > lower_bound_exclusive && val < upper_bound_exclusive))
|
|
39
|
+
{
|
|
40
|
+
fprintf(
|
|
41
|
+
stderr,
|
|
42
|
+
MLK_DEBUG_ERROR_HEADER
|
|
43
|
+
"Bounds assertion failed: Index %u, value %d out of bounds (%d,%d)\n",
|
|
44
|
+
file, line, i, (int)val, lower_bound_exclusive,
|
|
45
|
+
upper_bound_exclusive);
|
|
46
|
+
err = 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (err == 1)
|
|
51
|
+
{
|
|
52
|
+
exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED && MLKEM_DEBUG */
|
|
57
|
+
|
|
58
|
+
MLK_EMPTY_CU(debug)
|
|
59
|
+
|
|
60
|
+
#endif /* !(!MLK_CONFIG_MULTILEVEL_NO_SHARED && MLKEM_DEBUG) */
|
|
61
|
+
|
|
62
|
+
/* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
|
|
63
|
+
* Don't modify by hand -- this is auto-generated by scripts/autogen. */
|
|
64
|
+
#undef MLK_DEBUG_ERROR_HEADER
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
#ifndef MLK_DEBUG_H
|
|
6
|
+
#define MLK_DEBUG_H
|
|
7
|
+
#include "common.h"
|
|
8
|
+
|
|
9
|
+
#if defined(MLKEM_DEBUG)
|
|
10
|
+
|
|
11
|
+
/*************************************************
|
|
12
|
+
* Name: mlk_assert
|
|
13
|
+
*
|
|
14
|
+
* Description: Check debug assertion
|
|
15
|
+
*
|
|
16
|
+
* Prints an error message to stderr and calls
|
|
17
|
+
* exit(1) if not.
|
|
18
|
+
*
|
|
19
|
+
* Arguments: - file: filename
|
|
20
|
+
* - line: line number
|
|
21
|
+
* - val: Value asserted to be non-zero
|
|
22
|
+
**************************************************/
|
|
23
|
+
#define mlk_debug_check_assert MLK_NAMESPACE(mlkem_debug_assert)
|
|
24
|
+
void mlk_debug_check_assert(const char *file, int line, const int val);
|
|
25
|
+
|
|
26
|
+
/*************************************************
|
|
27
|
+
* Name: mlk_debug_check_bounds
|
|
28
|
+
*
|
|
29
|
+
* Description: Check whether values in an array of int16_t
|
|
30
|
+
* are within specified bounds.
|
|
31
|
+
*
|
|
32
|
+
* Prints an error message to stderr and calls
|
|
33
|
+
* exit(1) if not.
|
|
34
|
+
*
|
|
35
|
+
* Arguments: - file: filename
|
|
36
|
+
* - line: line number
|
|
37
|
+
* - ptr: Base of array to be checked
|
|
38
|
+
* - len: Number of int16_t in ptr
|
|
39
|
+
* - lower_bound_exclusive: Exclusive lower bound
|
|
40
|
+
* - upper_bound_exclusive: Exclusive upper bound
|
|
41
|
+
**************************************************/
|
|
42
|
+
#define mlk_debug_check_bounds MLK_NAMESPACE(mlkem_debug_check_bounds)
|
|
43
|
+
void mlk_debug_check_bounds(const char *file, int line, const int16_t *ptr,
|
|
44
|
+
unsigned len, int lower_bound_exclusive,
|
|
45
|
+
int upper_bound_exclusive);
|
|
46
|
+
|
|
47
|
+
/* Check assertion, calling exit() upon failure
|
|
48
|
+
*
|
|
49
|
+
* val: Value that's asserted to be non-zero
|
|
50
|
+
*/
|
|
51
|
+
#define mlk_assert(val) mlk_debug_check_assert(__FILE__, __LINE__, (val))
|
|
52
|
+
|
|
53
|
+
/* Check bounds in array of int16_t's
|
|
54
|
+
* ptr: Base of int16_t array; will be explicitly cast to int16_t*,
|
|
55
|
+
* so you may pass a byte-compatible type such as mlk_poly or mlk_polyvec.
|
|
56
|
+
* len: Number of int16_t in array
|
|
57
|
+
* value_lb: Inclusive lower value bound
|
|
58
|
+
* value_ub: Exclusive upper value bound */
|
|
59
|
+
#define mlk_assert_bound(ptr, len, value_lb, value_ub) \
|
|
60
|
+
mlk_debug_check_bounds(__FILE__, __LINE__, (const int16_t *)(ptr), (len), \
|
|
61
|
+
(value_lb) - 1, (value_ub))
|
|
62
|
+
|
|
63
|
+
/* Check absolute bounds in array of int16_t's
|
|
64
|
+
* ptr: Base of array, expression of type int16_t*
|
|
65
|
+
* len: Number of int16_t in array
|
|
66
|
+
* value_abs_bd: Exclusive absolute upper bound */
|
|
67
|
+
#define mlk_assert_abs_bound(ptr, len, value_abs_bd) \
|
|
68
|
+
mlk_assert_bound((ptr), (len), (-(value_abs_bd) + 1), (value_abs_bd))
|
|
69
|
+
|
|
70
|
+
/* Version of bounds assertions for 2-dimensional arrays */
|
|
71
|
+
#define mlk_assert_bound_2d(ptr, len0, len1, value_lb, value_ub) \
|
|
72
|
+
mlk_assert_bound((ptr), ((len0) * (len1)), (value_lb), (value_ub))
|
|
73
|
+
|
|
74
|
+
#define mlk_assert_abs_bound_2d(ptr, len0, len1, value_abs_bd) \
|
|
75
|
+
mlk_assert_abs_bound((ptr), ((len0) * (len1)), (value_abs_bd))
|
|
76
|
+
|
|
77
|
+
/* When running CBMC, convert debug assertions into proof obligations */
|
|
78
|
+
#elif defined(CBMC)
|
|
79
|
+
#include "cbmc.h"
|
|
80
|
+
|
|
81
|
+
#define mlk_assert(val) cassert(val)
|
|
82
|
+
|
|
83
|
+
#define mlk_assert_bound(ptr, len, value_lb, value_ub) \
|
|
84
|
+
cassert(array_bound(((int16_t *)(ptr)), 0, (len), (value_lb), (value_ub)))
|
|
85
|
+
|
|
86
|
+
#define mlk_assert_abs_bound(ptr, len, value_abs_bd) \
|
|
87
|
+
cassert(array_abs_bound(((int16_t *)(ptr)), 0, (len), (value_abs_bd)))
|
|
88
|
+
|
|
89
|
+
/* Because of https://github.com/diffblue/cbmc/issues/8570, we can't
|
|
90
|
+
* just use a single flattened array_bound(...) here. */
|
|
91
|
+
#define mlk_assert_bound_2d(ptr, M, N, value_lb, value_ub) \
|
|
92
|
+
cassert(forall(kN, 0, (M), \
|
|
93
|
+
array_bound(&((int16_t (*)[(N)])(ptr))[kN][0], 0, (N), \
|
|
94
|
+
(value_lb), (value_ub))))
|
|
95
|
+
|
|
96
|
+
#define mlk_assert_abs_bound_2d(ptr, M, N, value_abs_bd) \
|
|
97
|
+
cassert(forall(kN, 0, (M), \
|
|
98
|
+
array_abs_bound(&((int16_t (*)[(N)])(ptr))[kN][0], 0, (N), \
|
|
99
|
+
(value_abs_bd))))
|
|
100
|
+
|
|
101
|
+
#else /* !MLKEM_DEBUG && CBMC */
|
|
102
|
+
|
|
103
|
+
#define mlk_assert(val) \
|
|
104
|
+
do \
|
|
105
|
+
{ \
|
|
106
|
+
} while (0)
|
|
107
|
+
#define mlk_assert_bound(ptr, len, value_lb, value_ub) \
|
|
108
|
+
do \
|
|
109
|
+
{ \
|
|
110
|
+
} while (0)
|
|
111
|
+
#define mlk_assert_abs_bound(ptr, len, value_abs_bd) \
|
|
112
|
+
do \
|
|
113
|
+
{ \
|
|
114
|
+
} while (0)
|
|
115
|
+
|
|
116
|
+
#define mlk_assert_bound_2d(ptr, len0, len1, value_lb, value_ub) \
|
|
117
|
+
do \
|
|
118
|
+
{ \
|
|
119
|
+
} while (0)
|
|
120
|
+
|
|
121
|
+
#define mlk_assert_abs_bound_2d(ptr, len0, len1, value_abs_bd) \
|
|
122
|
+
do \
|
|
123
|
+
{ \
|
|
124
|
+
} while (0)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
#endif /* !MLKEM_DEBUG && !CBMC */
|
|
128
|
+
#endif /* !MLK_DEBUG_H */
|
|
@@ -0,0 +1,251 @@
|
|
|
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
|
+
* - [mupq]
|
|
15
|
+
* Common files for pqm4, pqm3, pqriscv
|
|
16
|
+
* Kannwischer, Petri, Rijneveld, Schwabe, Stoffelen
|
|
17
|
+
* https://github.com/mupq/mupq
|
|
18
|
+
*
|
|
19
|
+
* - [supercop]
|
|
20
|
+
* SUPERCOP benchmarking framework
|
|
21
|
+
* Daniel J. Bernstein
|
|
22
|
+
* http://bench.cr.yp.to/supercop.html
|
|
23
|
+
*
|
|
24
|
+
* - [tweetfips]
|
|
25
|
+
* 'tweetfips202' FIPS202 implementation
|
|
26
|
+
* Van Assche, Bernstein, Schwabe
|
|
27
|
+
* https://keccak.team/2015/tweetfips202.html
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/* Based on the CC0 implementation from @[mupq] and the public domain
|
|
31
|
+
* implementation @[supercop, crypto_hash/keccakc512/simple/]
|
|
32
|
+
* by Ronny Van Keer, and the public domain @[tweetfips] implementation. */
|
|
33
|
+
|
|
34
|
+
#include "../common.h"
|
|
35
|
+
#if !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
#include "../verify.h"
|
|
39
|
+
#include "fips202.h"
|
|
40
|
+
#include "keccakf1600.h"
|
|
41
|
+
|
|
42
|
+
/*************************************************
|
|
43
|
+
* Name: mlk_keccak_absorb_once
|
|
44
|
+
*
|
|
45
|
+
* Description: Absorb step of Keccak;
|
|
46
|
+
* non-incremental, starts by zeroeing the state.
|
|
47
|
+
*
|
|
48
|
+
* WARNING: Must only be called once.
|
|
49
|
+
*
|
|
50
|
+
* Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak
|
|
51
|
+
* state
|
|
52
|
+
* - unsigned r: rate in bytes (e.g., 168 for SHAKE128)
|
|
53
|
+
* - const uint8_t *m: pointer to input to be absorbed into s
|
|
54
|
+
* - size_t mlen: length of input in bytes
|
|
55
|
+
* - uint8_t p: domain-separation byte for different
|
|
56
|
+
* Keccak-derived functions
|
|
57
|
+
**************************************************/
|
|
58
|
+
static void mlk_keccak_absorb_once(uint64_t *s, unsigned r, const uint8_t *m,
|
|
59
|
+
size_t mlen, uint8_t p)
|
|
60
|
+
__contract__(
|
|
61
|
+
requires(mlen <= MLK_MAX_BUFFER_SIZE)
|
|
62
|
+
requires(r <= sizeof(uint64_t) * MLK_KECCAK_LANES)
|
|
63
|
+
requires(memory_no_alias(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
64
|
+
requires(memory_no_alias(m, mlen))
|
|
65
|
+
assigns(memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES)))
|
|
66
|
+
{
|
|
67
|
+
/* Initialize state */
|
|
68
|
+
size_t i;
|
|
69
|
+
for (i = 0; i < 25; ++i)
|
|
70
|
+
__loop__(invariant(i <= 25))
|
|
71
|
+
{
|
|
72
|
+
s[i] = 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
while (mlen >= r)
|
|
76
|
+
__loop__(
|
|
77
|
+
assigns(mlen, m, memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
78
|
+
invariant(mlen <= loop_entry(mlen))
|
|
79
|
+
invariant(m == loop_entry(m) + (loop_entry(mlen) - mlen)))
|
|
80
|
+
{
|
|
81
|
+
mlk_keccakf1600_xor_bytes(s, m, 0, r);
|
|
82
|
+
mlk_keccakf1600_permute(s);
|
|
83
|
+
mlen -= r;
|
|
84
|
+
m += r;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* At this point, mlen < r, so the truncations to unsigned are safe below. */
|
|
88
|
+
|
|
89
|
+
if (mlen > 0)
|
|
90
|
+
{
|
|
91
|
+
mlk_keccakf1600_xor_bytes(s, m, 0, (unsigned int)mlen);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (mlen == r - 1)
|
|
95
|
+
{
|
|
96
|
+
p |= 128;
|
|
97
|
+
mlk_keccakf1600_xor_bytes(s, &p, (unsigned int)mlen, 1);
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
{
|
|
101
|
+
mlk_keccakf1600_xor_bytes(s, &p, (unsigned int)mlen, 1);
|
|
102
|
+
p = 128;
|
|
103
|
+
mlk_keccakf1600_xor_bytes(s, &p, r - 1, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*************************************************
|
|
108
|
+
* Name: mlk_keccak_squeezeblocks
|
|
109
|
+
*
|
|
110
|
+
* Description: block-level Keccak squeeze
|
|
111
|
+
*
|
|
112
|
+
* Arguments: - uint8_t *h: pointer to output bytes
|
|
113
|
+
* - size_t nblocks: number of blocks to be squeezed
|
|
114
|
+
* - uint64_t *s_inc: pointer to input/output state
|
|
115
|
+
* - unsigned r: rate in bytes (e.g., 168 for SHAKE128)
|
|
116
|
+
**************************************************/
|
|
117
|
+
static void mlk_keccak_squeezeblocks(uint8_t *h, size_t nblocks, uint64_t *s,
|
|
118
|
+
unsigned r)
|
|
119
|
+
__contract__(
|
|
120
|
+
requires(r <= sizeof(uint64_t) * MLK_KECCAK_LANES)
|
|
121
|
+
requires(nblocks <= 8 /* somewhat arbitrary bound */)
|
|
122
|
+
requires(memory_no_alias(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
123
|
+
requires(memory_no_alias(h, nblocks * r))
|
|
124
|
+
assigns(memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
125
|
+
assigns(memory_slice(h, nblocks * r)))
|
|
126
|
+
{
|
|
127
|
+
while (nblocks > 0)
|
|
128
|
+
__loop__(
|
|
129
|
+
assigns(h, nblocks,
|
|
130
|
+
memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES),
|
|
131
|
+
memory_slice(h, nblocks * r))
|
|
132
|
+
invariant(nblocks <= loop_entry(nblocks) &&
|
|
133
|
+
h == loop_entry(h) + r * (loop_entry(nblocks) - nblocks)))
|
|
134
|
+
{
|
|
135
|
+
mlk_keccakf1600_permute(s);
|
|
136
|
+
mlk_keccakf1600_extract_bytes(s, h, 0, r);
|
|
137
|
+
h += r;
|
|
138
|
+
nblocks--;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/*************************************************
|
|
143
|
+
* Name: mlk_keccak_squeeze_once
|
|
144
|
+
*
|
|
145
|
+
* Description: Keccak squeeze; can be called on byte-level
|
|
146
|
+
*
|
|
147
|
+
* WARNING: This must only be called once.
|
|
148
|
+
*
|
|
149
|
+
* Arguments: - uint8_t *h: pointer to output bytes
|
|
150
|
+
* - size_t outlen: number of bytes to be squeezed
|
|
151
|
+
* - uint64_t *s_inc: pointer to Keccak state
|
|
152
|
+
* - unsigned r: rate in bytes (e.g., 168 for SHAKE128)
|
|
153
|
+
**************************************************/
|
|
154
|
+
static void mlk_keccak_squeeze_once(uint8_t *h, size_t outlen, uint64_t *s,
|
|
155
|
+
unsigned r)
|
|
156
|
+
__contract__(
|
|
157
|
+
requires(outlen <= MLK_MAX_BUFFER_SIZE)
|
|
158
|
+
requires(r <= sizeof(uint64_t) * MLK_KECCAK_LANES)
|
|
159
|
+
requires(memory_no_alias(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
160
|
+
requires(memory_no_alias(h, outlen))
|
|
161
|
+
assigns(memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
162
|
+
assigns(memory_slice(h, outlen)))
|
|
163
|
+
{
|
|
164
|
+
size_t len;
|
|
165
|
+
while (outlen > 0)
|
|
166
|
+
__loop__(
|
|
167
|
+
assigns(len, h, outlen,
|
|
168
|
+
memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES),
|
|
169
|
+
memory_slice(h, outlen))
|
|
170
|
+
invariant(outlen <= loop_entry(outlen) &&
|
|
171
|
+
h == loop_entry(h) + (loop_entry(outlen) - outlen)))
|
|
172
|
+
{
|
|
173
|
+
mlk_keccakf1600_permute(s);
|
|
174
|
+
|
|
175
|
+
if (outlen < r)
|
|
176
|
+
{
|
|
177
|
+
len = outlen;
|
|
178
|
+
}
|
|
179
|
+
else
|
|
180
|
+
{
|
|
181
|
+
len = r;
|
|
182
|
+
}
|
|
183
|
+
mlk_keccakf1600_extract_bytes(s, h, 0, (unsigned int)len);
|
|
184
|
+
h += len;
|
|
185
|
+
outlen -= len;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void mlk_shake128_absorb_once(mlk_shake128ctx *state, const uint8_t *input,
|
|
190
|
+
size_t inlen)
|
|
191
|
+
{
|
|
192
|
+
mlk_keccak_absorb_once(state->ctx, SHAKE128_RATE, input, inlen, 0x1F);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
void mlk_shake128_squeezeblocks(uint8_t *output, size_t nblocks,
|
|
196
|
+
mlk_shake128ctx *state)
|
|
197
|
+
{
|
|
198
|
+
mlk_keccak_squeezeblocks(output, nblocks, state->ctx, SHAKE128_RATE);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
void mlk_shake128_init(mlk_shake128ctx *state) { (void)state; }
|
|
202
|
+
void mlk_shake128_release(mlk_shake128ctx *state)
|
|
203
|
+
{
|
|
204
|
+
/* Specification: Partially implements
|
|
205
|
+
* @[FIPS203, Section 3.3, Destruction of intermediate values] */
|
|
206
|
+
mlk_zeroize(state, sizeof(mlk_shake128ctx));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
typedef mlk_shake128ctx mlk_shake256ctx;
|
|
210
|
+
void mlk_shake256(uint8_t *output, size_t outlen, const uint8_t *input,
|
|
211
|
+
size_t inlen)
|
|
212
|
+
{
|
|
213
|
+
mlk_shake256ctx state;
|
|
214
|
+
/* Absorb input */
|
|
215
|
+
mlk_keccak_absorb_once(state.ctx, SHAKE256_RATE, input, inlen, 0x1F);
|
|
216
|
+
/* Squeeze output */
|
|
217
|
+
mlk_keccak_squeeze_once(output, outlen, state.ctx, SHAKE256_RATE);
|
|
218
|
+
/* Specification: Partially implements
|
|
219
|
+
* @[FIPS203, Section 3.3, Destruction of intermediate values] */
|
|
220
|
+
mlk_zeroize(&state, sizeof(state));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
void mlk_sha3_256(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
224
|
+
{
|
|
225
|
+
uint64_t ctx[25];
|
|
226
|
+
/* Absorb input */
|
|
227
|
+
mlk_keccak_absorb_once(ctx, SHA3_256_RATE, input, inlen, 0x06);
|
|
228
|
+
/* Squeeze output */
|
|
229
|
+
mlk_keccak_squeeze_once(output, 32, ctx, SHA3_256_RATE);
|
|
230
|
+
/* Specification: Partially implements
|
|
231
|
+
* @[FIPS203, Section 3.3, Destruction of intermediate values] */
|
|
232
|
+
mlk_zeroize(ctx, sizeof(ctx));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
void mlk_sha3_512(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
236
|
+
{
|
|
237
|
+
uint64_t ctx[25];
|
|
238
|
+
/* Absorb input */
|
|
239
|
+
mlk_keccak_absorb_once(ctx, SHA3_512_RATE, input, inlen, 0x06);
|
|
240
|
+
/* Squeeze output */
|
|
241
|
+
mlk_keccak_squeeze_once(output, 64, ctx, SHA3_512_RATE);
|
|
242
|
+
/* Specification: Partially implements
|
|
243
|
+
* @[FIPS203, Section 3.3, Destruction of intermediate values] */
|
|
244
|
+
mlk_zeroize(ctx, sizeof(ctx));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
248
|
+
|
|
249
|
+
MLK_EMPTY_CU(fips202)
|
|
250
|
+
|
|
251
|
+
#endif /* MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
#ifndef MLK_FIPS202_FIPS202_H
|
|
6
|
+
#define MLK_FIPS202_FIPS202_H
|
|
7
|
+
|
|
8
|
+
#include "../cbmc.h"
|
|
9
|
+
#include "../common.h"
|
|
10
|
+
|
|
11
|
+
#define SHAKE128_RATE 168
|
|
12
|
+
#define SHAKE256_RATE 136
|
|
13
|
+
#define SHA3_256_RATE 136
|
|
14
|
+
#define SHA3_384_RATE 104
|
|
15
|
+
#define SHA3_512_RATE 72
|
|
16
|
+
|
|
17
|
+
/* Context for non-incremental API */
|
|
18
|
+
typedef struct
|
|
19
|
+
{
|
|
20
|
+
uint64_t ctx[25];
|
|
21
|
+
} MLK_ALIGN mlk_shake128ctx;
|
|
22
|
+
|
|
23
|
+
#define mlk_shake128_absorb_once MLK_NAMESPACE(shake128_absorb_once)
|
|
24
|
+
/*************************************************
|
|
25
|
+
* Name: mlk_shake128_absorb_once
|
|
26
|
+
*
|
|
27
|
+
* Description: One-shot absorb step of the SHAKE128 XOF.
|
|
28
|
+
*
|
|
29
|
+
* For call-sites (in mlkem-native):
|
|
30
|
+
* - This function MUST ONLY be called straight after
|
|
31
|
+
* mlk_shake128_init().
|
|
32
|
+
* - This function MUST ONLY be called once.
|
|
33
|
+
*
|
|
34
|
+
* Consequently, for providers of custom FIPS202 code
|
|
35
|
+
* to be used with mlkem-native:
|
|
36
|
+
* - You may assume that the input context is
|
|
37
|
+
* freshly initialized via mlk_shake128_init().
|
|
38
|
+
* - You may assume that this function is
|
|
39
|
+
* called exactly once.
|
|
40
|
+
*
|
|
41
|
+
* Arguments: - mlk_shake128ctx *state: pointer to SHAKE128 context
|
|
42
|
+
* - const uint8_t *input: pointer to input to be absorbed into
|
|
43
|
+
* the state
|
|
44
|
+
* - size_t inlen: length of input in bytes
|
|
45
|
+
**************************************************/
|
|
46
|
+
void mlk_shake128_absorb_once(mlk_shake128ctx *state, const uint8_t *input,
|
|
47
|
+
size_t inlen)
|
|
48
|
+
__contract__(
|
|
49
|
+
requires(inlen <= MLK_MAX_BUFFER_SIZE)
|
|
50
|
+
requires(memory_no_alias(state, sizeof(mlk_shake128ctx)))
|
|
51
|
+
requires(memory_no_alias(input, inlen))
|
|
52
|
+
assigns(memory_slice(state, sizeof(mlk_shake128ctx)))
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
#define mlk_shake128_squeezeblocks MLK_NAMESPACE(shake128_squeezeblocks)
|
|
56
|
+
/*************************************************
|
|
57
|
+
* Name: mlk_shake128_squeezeblocks
|
|
58
|
+
*
|
|
59
|
+
* Description: Squeeze step of SHAKE128 XOF. Squeezes full blocks of
|
|
60
|
+
* SHAKE128_RATE bytes each. Modifies the state. Can be called
|
|
61
|
+
* multiple times to keep squeezing, i.e., is incremental.
|
|
62
|
+
*
|
|
63
|
+
* Arguments: - uint8_t *output: pointer to output blocks
|
|
64
|
+
* - size_t nblocks: number of blocks to be squeezed (written
|
|
65
|
+
* to output)
|
|
66
|
+
* - mlk_shake128ctx *state: pointer to in/output Keccak state
|
|
67
|
+
**************************************************/
|
|
68
|
+
void mlk_shake128_squeezeblocks(uint8_t *output, size_t nblocks,
|
|
69
|
+
mlk_shake128ctx *state)
|
|
70
|
+
__contract__(
|
|
71
|
+
requires(nblocks <= 8 /* somewhat arbitrary bound */)
|
|
72
|
+
requires(memory_no_alias(state, sizeof(mlk_shake128ctx)))
|
|
73
|
+
requires(memory_no_alias(output, nblocks * SHAKE128_RATE))
|
|
74
|
+
assigns(memory_slice(output, nblocks * SHAKE128_RATE), memory_slice(state, sizeof(mlk_shake128ctx)))
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
#define mlk_shake128_init MLK_NAMESPACE(shake128_init)
|
|
78
|
+
void mlk_shake128_init(mlk_shake128ctx *state);
|
|
79
|
+
|
|
80
|
+
#define mlk_shake128_release MLK_NAMESPACE(shake128_release)
|
|
81
|
+
void mlk_shake128_release(mlk_shake128ctx *state);
|
|
82
|
+
|
|
83
|
+
/* One-stop SHAKE256 call. Aliasing between input and
|
|
84
|
+
* output is not permitted */
|
|
85
|
+
#define mlk_shake256 MLK_NAMESPACE(shake256)
|
|
86
|
+
/*************************************************
|
|
87
|
+
* Name: mlk_shake256
|
|
88
|
+
*
|
|
89
|
+
* Description: SHAKE256 XOF with non-incremental API
|
|
90
|
+
*
|
|
91
|
+
* Arguments: - uint8_t *output: pointer to output
|
|
92
|
+
* - size_t outlen: requested output length in bytes
|
|
93
|
+
* - const uint8_t *input: pointer to input
|
|
94
|
+
* - size_t inlen: length of input in bytes
|
|
95
|
+
**************************************************/
|
|
96
|
+
void mlk_shake256(uint8_t *output, size_t outlen, const uint8_t *input,
|
|
97
|
+
size_t inlen)
|
|
98
|
+
__contract__(
|
|
99
|
+
requires(inlen <= MLK_MAX_BUFFER_SIZE)
|
|
100
|
+
requires(outlen <= MLK_MAX_BUFFER_SIZE)
|
|
101
|
+
requires(memory_no_alias(input, inlen))
|
|
102
|
+
requires(memory_no_alias(output, outlen))
|
|
103
|
+
assigns(memory_slice(output, outlen))
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/* One-stop SHA3_256 call. Aliasing between input and
|
|
107
|
+
* output is not permitted */
|
|
108
|
+
#define SHA3_256_HASHBYTES 32
|
|
109
|
+
#define mlk_sha3_256 MLK_NAMESPACE(sha3_256)
|
|
110
|
+
/*************************************************
|
|
111
|
+
* Name: mlk_sha3_256
|
|
112
|
+
*
|
|
113
|
+
* Description: SHA3-256 with non-incremental API
|
|
114
|
+
*
|
|
115
|
+
* Arguments: - uint8_t *output: pointer to output
|
|
116
|
+
* - const uint8_t *input: pointer to input
|
|
117
|
+
* - size_t inlen: length of input in bytes
|
|
118
|
+
**************************************************/
|
|
119
|
+
void mlk_sha3_256(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
120
|
+
__contract__(
|
|
121
|
+
requires(inlen <= MLK_MAX_BUFFER_SIZE)
|
|
122
|
+
requires(memory_no_alias(input, inlen))
|
|
123
|
+
requires(memory_no_alias(output, SHA3_256_HASHBYTES))
|
|
124
|
+
assigns(memory_slice(output, SHA3_256_HASHBYTES))
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
/* One-stop SHA3_512 call. Aliasing between input and
|
|
128
|
+
* output is not permitted */
|
|
129
|
+
#define SHA3_512_HASHBYTES 64
|
|
130
|
+
#define mlk_sha3_512 MLK_NAMESPACE(sha3_512)
|
|
131
|
+
/*************************************************
|
|
132
|
+
* Name: mlk_sha3_512
|
|
133
|
+
*
|
|
134
|
+
* Description: SHA3-512 with non-incremental API
|
|
135
|
+
*
|
|
136
|
+
* Arguments: - uint8_t *output: pointer to output
|
|
137
|
+
* - const uint8_t *input: pointer to input
|
|
138
|
+
* - size_t inlen: length of input in bytes
|
|
139
|
+
**************************************************/
|
|
140
|
+
void mlk_sha3_512(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
141
|
+
__contract__(
|
|
142
|
+
requires(inlen <= MLK_MAX_BUFFER_SIZE)
|
|
143
|
+
requires(memory_no_alias(input, inlen))
|
|
144
|
+
requires(memory_no_alias(output, SHA3_512_HASHBYTES))
|
|
145
|
+
assigns(memory_slice(output, SHA3_512_HASHBYTES))
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
#if !defined(MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202) || \
|
|
149
|
+
!defined(MLK_USE_FIPS202_X4_NATIVE)
|
|
150
|
+
/* If you provide your own FIPS-202 implementation where the x4-
|
|
151
|
+
* Keccak-f1600-x4 implementation falls back to 4-fold Keccak-f1600,
|
|
152
|
+
* set this to gain a small speedup. */
|
|
153
|
+
#define FIPS202_X4_DEFAULT_IMPLEMENTATION
|
|
154
|
+
#endif /* !MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 || !MLK_USE_FIPS202_X4_NATIVE \
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
#endif /* !MLK_FIPS202_FIPS202_H */
|