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,166 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mldsa-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ifndef MLD_CBMC_H
|
|
7
|
+
#define MLD_CBMC_H
|
|
8
|
+
/***************************************************
|
|
9
|
+
* Basic replacements for __CPROVER_XXX contracts
|
|
10
|
+
***************************************************/
|
|
11
|
+
#ifndef CBMC
|
|
12
|
+
|
|
13
|
+
#define __contract__(x)
|
|
14
|
+
#define __loop__(x)
|
|
15
|
+
#define cassert(x)
|
|
16
|
+
|
|
17
|
+
#else /* !CBMC */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
#define __contract__(x) x
|
|
21
|
+
#define __loop__(x) x
|
|
22
|
+
|
|
23
|
+
/* https://diffblue.github.io/cbmc/contracts-assigns.html */
|
|
24
|
+
#define assigns(...) __CPROVER_assigns(__VA_ARGS__)
|
|
25
|
+
|
|
26
|
+
/* https://diffblue.github.io/cbmc/contracts-requires-ensures.html */
|
|
27
|
+
#define requires(...) __CPROVER_requires(__VA_ARGS__)
|
|
28
|
+
#define ensures(...) __CPROVER_ensures(__VA_ARGS__)
|
|
29
|
+
/* https://diffblue.github.io/cbmc/contracts-loops.html */
|
|
30
|
+
#define invariant(...) __CPROVER_loop_invariant(__VA_ARGS__)
|
|
31
|
+
#define decreases(...) __CPROVER_decreases(__VA_ARGS__)
|
|
32
|
+
/* cassert to avoid confusion with in-built assert */
|
|
33
|
+
#define cassert(x) __CPROVER_assert(x, "cbmc assertion failed")
|
|
34
|
+
#define assume(...) __CPROVER_assume(__VA_ARGS__)
|
|
35
|
+
|
|
36
|
+
/***************************************************
|
|
37
|
+
* Macros for "expression" forms that may appear
|
|
38
|
+
* _inside_ top-level contracts.
|
|
39
|
+
***************************************************/
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* function return value - useful inside ensures
|
|
43
|
+
* https://diffblue.github.io/cbmc/contracts-functions.html
|
|
44
|
+
*/
|
|
45
|
+
#define return_value (__CPROVER_return_value)
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* assigns l-value targets
|
|
49
|
+
* https://diffblue.github.io/cbmc/contracts-assigns.html
|
|
50
|
+
*/
|
|
51
|
+
#define object_whole(...) __CPROVER_object_whole(__VA_ARGS__)
|
|
52
|
+
#define memory_slice(...) __CPROVER_object_upto(__VA_ARGS__)
|
|
53
|
+
#define same_object(...) __CPROVER_same_object(__VA_ARGS__)
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
* Pointer-related predicates
|
|
57
|
+
* https://diffblue.github.io/cbmc/contracts-memory-predicates.html
|
|
58
|
+
*/
|
|
59
|
+
#define memory_no_alias(...) __CPROVER_is_fresh(__VA_ARGS__)
|
|
60
|
+
#define readable(...) __CPROVER_r_ok(__VA_ARGS__)
|
|
61
|
+
#define writeable(...) __CPROVER_w_ok(__VA_ARGS__)
|
|
62
|
+
|
|
63
|
+
/* Maximum supported buffer size
|
|
64
|
+
*
|
|
65
|
+
* Larger buffers may be supported, but due to internal modeling constraints
|
|
66
|
+
* in CBMC, the proofs of memory- and type-safety won't be able to run.
|
|
67
|
+
*
|
|
68
|
+
* If you find yourself in need for a buffer size larger than this,
|
|
69
|
+
* please contact the maintainers, so we can prioritize work to relax
|
|
70
|
+
* this somewhat artificial bound.
|
|
71
|
+
*/
|
|
72
|
+
#define MLD_MAX_BUFFER_SIZE (SIZE_MAX >> 12)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* History variables
|
|
77
|
+
* https://diffblue.github.io/cbmc/contracts-history-variables.html
|
|
78
|
+
*/
|
|
79
|
+
#define old(...) __CPROVER_old(__VA_ARGS__)
|
|
80
|
+
#define loop_entry(...) __CPROVER_loop_entry(__VA_ARGS__)
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Quantifiers
|
|
84
|
+
* Note that the range on qvar is _exclusive_ between qvar_lb .. qvar_ub
|
|
85
|
+
* https://diffblue.github.io/cbmc/contracts-quantifiers.html
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
* Prevent clang-format from corrupting CBMC's special ==> operator
|
|
90
|
+
*/
|
|
91
|
+
/* clang-format off */
|
|
92
|
+
#define forall(qvar, qvar_lb, qvar_ub, predicate) \
|
|
93
|
+
__CPROVER_forall \
|
|
94
|
+
{ \
|
|
95
|
+
unsigned qvar; \
|
|
96
|
+
((qvar_lb) <= (qvar) && (qvar) < (qvar_ub)) ==> (predicate) \
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
#define exists(qvar, qvar_lb, qvar_ub, predicate) \
|
|
100
|
+
__CPROVER_exists \
|
|
101
|
+
{ \
|
|
102
|
+
unsigned qvar; \
|
|
103
|
+
((qvar_lb) <= (qvar) && (qvar) < (qvar_ub)) && (predicate) \
|
|
104
|
+
}
|
|
105
|
+
/* clang-format on */
|
|
106
|
+
|
|
107
|
+
/***************************************************
|
|
108
|
+
* Convenience macros for common contract patterns
|
|
109
|
+
***************************************************/
|
|
110
|
+
/*
|
|
111
|
+
* Prevent clang-format from corrupting CBMC's special ==> operator
|
|
112
|
+
*/
|
|
113
|
+
/* clang-format off */
|
|
114
|
+
#define CBMC_CONCAT_(left, right) left##right
|
|
115
|
+
#define CBMC_CONCAT(left, right) CBMC_CONCAT_(left, right)
|
|
116
|
+
|
|
117
|
+
#define array_bound_core(qvar, qvar_lb, qvar_ub, array_var, \
|
|
118
|
+
value_lb, value_ub) \
|
|
119
|
+
__CPROVER_forall \
|
|
120
|
+
{ \
|
|
121
|
+
unsigned qvar; \
|
|
122
|
+
((qvar_lb) <= (qvar) && (qvar) < (qvar_ub)) ==> \
|
|
123
|
+
(((int)(value_lb) <= ((array_var)[(qvar)])) && \
|
|
124
|
+
(((array_var)[(qvar)]) < (int)(value_ub))) \
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#define array_bound(array_var, qvar_lb, qvar_ub, value_lb, value_ub) \
|
|
128
|
+
array_bound_core(CBMC_CONCAT(_cbmc_idx, __COUNTER__), (qvar_lb), \
|
|
129
|
+
(qvar_ub), (array_var), (value_lb), (value_ub))
|
|
130
|
+
|
|
131
|
+
#define array_unchanged_core(qvar, qvar_lb, qvar_ub, array_var) \
|
|
132
|
+
__CPROVER_forall \
|
|
133
|
+
{ \
|
|
134
|
+
unsigned qvar; \
|
|
135
|
+
((qvar_lb) <= (qvar) && (qvar) < (qvar_ub)) ==> \
|
|
136
|
+
((array_var)[(qvar)]) == (old(* (int32_t (*)[(qvar_ub)])(array_var)))[(qvar)] \
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#define array_unchanged(array_var, N) \
|
|
140
|
+
array_unchanged_core(CBMC_CONCAT(_cbmc_idx, __COUNTER__), 0, (N), (array_var))
|
|
141
|
+
|
|
142
|
+
#define array_unchanged_u64_core(qvar, qvar_lb, qvar_ub, array_var) \
|
|
143
|
+
__CPROVER_forall \
|
|
144
|
+
{ \
|
|
145
|
+
unsigned qvar; \
|
|
146
|
+
((qvar_lb) <= (qvar) && (qvar) < (qvar_ub)) ==> \
|
|
147
|
+
((array_var)[(qvar)]) == (old(* (uint64_t (*)[(qvar_ub)])(array_var)))[(qvar)] \
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#define array_unchanged_u64(array_var, N) \
|
|
151
|
+
array_unchanged_u64_core(CBMC_CONCAT(_cbmc_idx, __COUNTER__), 0, (N), (array_var))
|
|
152
|
+
/* clang-format on */
|
|
153
|
+
|
|
154
|
+
/* Wrapper around array_bound operating on absolute values.
|
|
155
|
+
*
|
|
156
|
+
* The absolute value bound `k` is exclusive.
|
|
157
|
+
*
|
|
158
|
+
* Note that since the lower bound in array_bound is inclusive, we have to
|
|
159
|
+
* raise it by 1 here.
|
|
160
|
+
*/
|
|
161
|
+
#define array_abs_bound(arr, lb, ub, k) \
|
|
162
|
+
array_bound((arr), (lb), (ub), -((int)(k)) + 1, (k))
|
|
163
|
+
|
|
164
|
+
#endif /* CBMC */
|
|
165
|
+
|
|
166
|
+
#endif /* !MLD_CBMC_H */
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mldsa-native project authors
|
|
3
|
+
* Copyright (c) The mlkem-native project authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
5
|
+
*/
|
|
6
|
+
#ifndef MLD_COMMON_H
|
|
7
|
+
#define MLD_COMMON_H
|
|
8
|
+
|
|
9
|
+
#ifndef __ASSEMBLER__
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
#define MLD_BUILD_INTERNAL
|
|
15
|
+
|
|
16
|
+
#if defined(MLD_CONFIG_FILE)
|
|
17
|
+
#include MLD_CONFIG_FILE
|
|
18
|
+
#else
|
|
19
|
+
#include "mldsa_native_config.h"
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
#include "params.h"
|
|
23
|
+
#include "sys.h"
|
|
24
|
+
|
|
25
|
+
/* Internal and public API have external linkage by default, but
|
|
26
|
+
* this can be overwritten by the user, e.g. for single-CU builds. */
|
|
27
|
+
#if !defined(MLD_CONFIG_INTERNAL_API_QUALIFIER)
|
|
28
|
+
#define MLD_INTERNAL_API
|
|
29
|
+
#else
|
|
30
|
+
#define MLD_INTERNAL_API MLD_CONFIG_INTERNAL_API_QUALIFIER
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#if !defined(MLD_CONFIG_EXTERNAL_API_QUALIFIER)
|
|
34
|
+
#define MLD_EXTERNAL_API
|
|
35
|
+
#else
|
|
36
|
+
#define MLD_EXTERNAL_API MLD_CONFIG_EXTERNAL_API_QUALIFIER
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#if defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) || \
|
|
40
|
+
defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED)
|
|
41
|
+
#define MLD_MULTILEVEL_BUILD
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
#define MLD_CONCAT_(x1, x2) x1##x2
|
|
45
|
+
#define MLD_CONCAT(x1, x2) MLD_CONCAT_(x1, x2)
|
|
46
|
+
|
|
47
|
+
#if defined(MLD_MULTILEVEL_BUILD)
|
|
48
|
+
#define MLD_ADD_PARAM_SET(s) MLD_CONCAT(s, MLD_CONFIG_PARAMETER_SET)
|
|
49
|
+
#else
|
|
50
|
+
#define MLD_ADD_PARAM_SET(s) s
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
#define MLD_NAMESPACE_PREFIX MLD_CONCAT(MLD_CONFIG_NAMESPACE_PREFIX, _)
|
|
54
|
+
#define MLD_NAMESPACE_PREFIX_KL \
|
|
55
|
+
MLD_CONCAT(MLD_ADD_PARAM_SET(MLD_CONFIG_NAMESPACE_PREFIX), _)
|
|
56
|
+
|
|
57
|
+
/* Functions are prefixed by MLD_CONFIG_NAMESPACE_PREFIX.
|
|
58
|
+
*
|
|
59
|
+
* If multiple parameter sets are used, functions depending on the parameter
|
|
60
|
+
* set are additionally prefixed with 44/65/87. See mldsa_native_config.h.
|
|
61
|
+
*
|
|
62
|
+
* Example: If MLD_CONFIG_NAMESPACE_PREFIX is PQCP_MLDSA_NATIVE, then
|
|
63
|
+
* MLD_NAMESPACE_KL(keypair) becomes PQCP_MLDSA_NATIVE44_keypair/
|
|
64
|
+
* PQCP_MLDSA_NATIVE65_keypair/PQCP_MLDSA_NATIVE87_keypair.
|
|
65
|
+
*/
|
|
66
|
+
#define MLD_NAMESPACE(s) MLD_CONCAT(MLD_NAMESPACE_PREFIX, s)
|
|
67
|
+
#define MLD_NAMESPACE_KL(s) MLD_CONCAT(MLD_NAMESPACE_PREFIX_KL, s)
|
|
68
|
+
|
|
69
|
+
/* On Apple platforms, we need to emit leading underscore
|
|
70
|
+
* in front of assembly symbols. We thus introducee a separate
|
|
71
|
+
* namespace wrapper for ASM symbols. */
|
|
72
|
+
#if !defined(__APPLE__)
|
|
73
|
+
#define MLD_ASM_NAMESPACE(sym) MLD_NAMESPACE(sym)
|
|
74
|
+
#else
|
|
75
|
+
#define MLD_ASM_NAMESPACE(sym) MLD_CONCAT(_, MLD_NAMESPACE(sym))
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
* On X86_64 if control-flow protections (CET) are enabled (through
|
|
80
|
+
* -fcf-protection=), we add an endbr64 instruction at every global function
|
|
81
|
+
* label. See sys.h for more details
|
|
82
|
+
*/
|
|
83
|
+
#if defined(MLD_SYS_X86_64)
|
|
84
|
+
#define MLD_ASM_FN_SYMBOL(sym) MLD_ASM_NAMESPACE(sym) : MLD_CET_ENDBR
|
|
85
|
+
#elif defined(MLD_SYS_ARMV81M_MVE)
|
|
86
|
+
/* clang-format off */
|
|
87
|
+
#define MLD_ASM_FN_SYMBOL(sym) \
|
|
88
|
+
.type MLD_ASM_NAMESPACE(sym), %function; \
|
|
89
|
+
MLD_ASM_NAMESPACE(sym) :
|
|
90
|
+
/* clang-format on */
|
|
91
|
+
#else /* !MLD_SYS_X86_64 && MLD_SYS_ARMV81M_MVE */
|
|
92
|
+
#define MLD_ASM_FN_SYMBOL(sym) MLD_ASM_NAMESPACE(sym) :
|
|
93
|
+
#endif /* !MLD_SYS_X86_64 && !MLD_SYS_ARMV81M_MVE */
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* Output the size of an assembly function.
|
|
97
|
+
*/
|
|
98
|
+
#if defined(__ELF__)
|
|
99
|
+
#define MLD_ASM_FN_SIZE(sym) \
|
|
100
|
+
.size MLD_ASM_NAMESPACE(sym), .- MLD_ASM_NAMESPACE(sym)
|
|
101
|
+
#else
|
|
102
|
+
#define MLD_ASM_FN_SIZE(sym)
|
|
103
|
+
#endif
|
|
104
|
+
|
|
105
|
+
/* We aim to simplify the user's life by supporting builds where
|
|
106
|
+
* all source files are included, even those that are not needed.
|
|
107
|
+
* Those files are appropriately guarded and will be empty when unneeded.
|
|
108
|
+
* The following is to avoid compilers complaining about this. */
|
|
109
|
+
#define MLD_EMPTY_CU(s) extern int MLD_NAMESPACE_KL(empty_cu_##s);
|
|
110
|
+
|
|
111
|
+
/* MLD_CONFIG_NO_ASM takes precedence over MLD_USE_NATIVE_XXX */
|
|
112
|
+
#if defined(MLD_CONFIG_NO_ASM)
|
|
113
|
+
#undef MLD_CONFIG_USE_NATIVE_BACKEND_ARITH
|
|
114
|
+
#undef MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH) && \
|
|
118
|
+
!defined(MLD_CONFIG_ARITH_BACKEND_FILE)
|
|
119
|
+
#error Bad configuration: MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is set, but MLD_CONFIG_ARITH_BACKEND_FILE is not.
|
|
120
|
+
#endif
|
|
121
|
+
|
|
122
|
+
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202) && \
|
|
123
|
+
!defined(MLD_CONFIG_FIPS202_BACKEND_FILE)
|
|
124
|
+
#error Bad configuration: MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 is set, but MLD_CONFIG_FIPS202_BACKEND_FILE is not.
|
|
125
|
+
#endif
|
|
126
|
+
|
|
127
|
+
#if defined(MLD_CONFIG_NO_RANDOMIZED_API) && defined(MLD_CONFIG_KEYGEN_PCT)
|
|
128
|
+
#error Bad configuration: MLD_CONFIG_NO_RANDOMIZED_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_sign_signature()
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH)
|
|
132
|
+
#include MLD_CONFIG_ARITH_BACKEND_FILE
|
|
133
|
+
/* Include to enforce consistency of API and implementation,
|
|
134
|
+
* and conduct sanity checks on the backend.
|
|
135
|
+
*
|
|
136
|
+
* Keep this _after_ the inclusion of the backend; otherwise,
|
|
137
|
+
* the sanity checks won't have an effect. */
|
|
138
|
+
#if defined(MLD_CHECK_APIS) && !defined(__ASSEMBLER__)
|
|
139
|
+
#include "native/api.h"
|
|
140
|
+
#endif
|
|
141
|
+
#endif /* MLD_CONFIG_USE_NATIVE_BACKEND_ARITH */
|
|
142
|
+
|
|
143
|
+
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202)
|
|
144
|
+
#include MLD_CONFIG_FIPS202_BACKEND_FILE
|
|
145
|
+
/* Include to enforce consistency of API and implementation,
|
|
146
|
+
* and conduct sanity checks on the backend.
|
|
147
|
+
*
|
|
148
|
+
* Keep this _after_ the inclusion of the backend; otherwise,
|
|
149
|
+
* the sanity checks won't have an effect. */
|
|
150
|
+
#if defined(MLD_CHECK_APIS) && !defined(__ASSEMBLER__)
|
|
151
|
+
#include "fips202/native/api.h"
|
|
152
|
+
#endif
|
|
153
|
+
#endif /* MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 */
|
|
154
|
+
|
|
155
|
+
#if !defined(MLD_CONFIG_FIPS202_CUSTOM_HEADER)
|
|
156
|
+
#define MLD_FIPS202_HEADER_FILE "fips202/fips202.h"
|
|
157
|
+
#else
|
|
158
|
+
#define MLD_FIPS202_HEADER_FILE MLD_CONFIG_FIPS202_CUSTOM_HEADER
|
|
159
|
+
#endif
|
|
160
|
+
|
|
161
|
+
#if !defined(MLD_CONFIG_FIPS202X4_CUSTOM_HEADER)
|
|
162
|
+
#define MLD_FIPS202X4_HEADER_FILE "fips202/fips202x4.h"
|
|
163
|
+
#else
|
|
164
|
+
#define MLD_FIPS202X4_HEADER_FILE MLD_CONFIG_FIPS202X4_CUSTOM_HEADER
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
/* Standard library function replacements */
|
|
168
|
+
#if !defined(__ASSEMBLER__)
|
|
169
|
+
#if !defined(MLD_CONFIG_CUSTOM_MEMCPY)
|
|
170
|
+
#include <string.h>
|
|
171
|
+
#define mld_memcpy memcpy
|
|
172
|
+
#endif
|
|
173
|
+
|
|
174
|
+
#if !defined(MLD_CONFIG_CUSTOM_MEMSET)
|
|
175
|
+
#include <string.h>
|
|
176
|
+
#define mld_memset memset
|
|
177
|
+
#endif
|
|
178
|
+
|
|
179
|
+
/* Allocation macros for large local structures
|
|
180
|
+
*
|
|
181
|
+
* MLD_ALLOC(v, T, N) declares T *v and attempts to point it to an T[N]
|
|
182
|
+
* MLD_FREE(v, T, N) zeroizes and frees the allocation
|
|
183
|
+
*
|
|
184
|
+
* Default implementation uses stack allocation.
|
|
185
|
+
* Can be overridden by setting the config option MLD_CONFIG_CUSTOM_ALLOC_FREE
|
|
186
|
+
* and defining MLD_CUSTOM_ALLOC and MLD_CUSTOM_FREE.
|
|
187
|
+
*/
|
|
188
|
+
#if defined(MLD_CONFIG_CUSTOM_ALLOC_FREE) != \
|
|
189
|
+
(defined(MLD_CUSTOM_ALLOC) && defined(MLD_CUSTOM_FREE))
|
|
190
|
+
#error Bad configuration: MLD_CONFIG_CUSTOM_ALLOC_FREE must be set together with MLD_CUSTOM_ALLOC and MLD_CUSTOM_FREE
|
|
191
|
+
#endif
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* If the integration wants to provide a context parameter for use in
|
|
195
|
+
* platform-specific hooks, then it should define this parameter.
|
|
196
|
+
*
|
|
197
|
+
* The MLD_CONTEXT_PARAMETERS_n macros are intended to be used with macros
|
|
198
|
+
* defining the function names and expand to either pass or discard the context
|
|
199
|
+
* argument as required by the current build. If there is no context parameter
|
|
200
|
+
* requested then these are removed from the prototypes and from all calls.
|
|
201
|
+
*/
|
|
202
|
+
#ifdef MLD_CONFIG_CONTEXT_PARAMETER
|
|
203
|
+
#define MLD_CONTEXT_PARAMETERS_0(context) (context)
|
|
204
|
+
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
|
|
205
|
+
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
|
|
206
|
+
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
|
|
207
|
+
(arg0, arg1, arg2, context)
|
|
208
|
+
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
209
|
+
(arg0, arg1, arg2, arg3, context)
|
|
210
|
+
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
|
|
211
|
+
(arg0, arg1, arg2, arg3, arg4, context)
|
|
212
|
+
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
|
|
213
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, context)
|
|
214
|
+
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
215
|
+
context) \
|
|
216
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, context)
|
|
217
|
+
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
218
|
+
arg7, context) \
|
|
219
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, context)
|
|
220
|
+
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
221
|
+
arg7, arg8, context) \
|
|
222
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, context)
|
|
223
|
+
#else /* MLD_CONFIG_CONTEXT_PARAMETER */
|
|
224
|
+
#define MLD_CONTEXT_PARAMETERS_0(context) ()
|
|
225
|
+
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
|
|
226
|
+
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
|
|
227
|
+
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
|
|
228
|
+
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
229
|
+
(arg0, arg1, arg2, arg3)
|
|
230
|
+
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
|
|
231
|
+
(arg0, arg1, arg2, arg3, arg4)
|
|
232
|
+
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
|
|
233
|
+
(arg0, arg1, arg2, arg3, arg4, arg5)
|
|
234
|
+
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
235
|
+
context) \
|
|
236
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
|
237
|
+
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
238
|
+
arg7, context) \
|
|
239
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
|
240
|
+
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
241
|
+
arg7, arg8, context) \
|
|
242
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
|
243
|
+
#endif /* !MLD_CONFIG_CONTEXT_PARAMETER */
|
|
244
|
+
|
|
245
|
+
#if defined(MLD_CONFIG_CONTEXT_PARAMETER_TYPE) != \
|
|
246
|
+
defined(MLD_CONFIG_CONTEXT_PARAMETER)
|
|
247
|
+
#error MLD_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLD_CONFIG_CONTEXT_PARAMETER is defined
|
|
248
|
+
#endif
|
|
249
|
+
|
|
250
|
+
#if !defined(MLD_CONFIG_CUSTOM_ALLOC_FREE)
|
|
251
|
+
/* Default: stack allocation */
|
|
252
|
+
|
|
253
|
+
#define MLD_ALLOC(v, T, N, context) \
|
|
254
|
+
MLD_ALIGN T mld_alloc_##v[N]; \
|
|
255
|
+
T *v = mld_alloc_##v
|
|
256
|
+
|
|
257
|
+
/* TODO: This leads to a circular dependency between common and ct.h
|
|
258
|
+
* It just works out before we're at the end of the file, but it's still
|
|
259
|
+
* prone to issues in the future. */
|
|
260
|
+
#include "ct.h"
|
|
261
|
+
#define MLD_FREE(v, T, N, context) \
|
|
262
|
+
do \
|
|
263
|
+
{ \
|
|
264
|
+
mld_zeroize(mld_alloc_##v, sizeof(mld_alloc_##v)); \
|
|
265
|
+
(v) = NULL; \
|
|
266
|
+
} while (0)
|
|
267
|
+
|
|
268
|
+
#else /* !MLD_CONFIG_CUSTOM_ALLOC_FREE */
|
|
269
|
+
|
|
270
|
+
/* Custom allocation */
|
|
271
|
+
|
|
272
|
+
/*
|
|
273
|
+
* The indirection here is necessary to use MLD_CONTEXT_PARAMETERS_3 here.
|
|
274
|
+
*/
|
|
275
|
+
#define MLD_APPLY(f, args) f args
|
|
276
|
+
|
|
277
|
+
#define MLD_ALLOC(v, T, N, context) \
|
|
278
|
+
MLD_APPLY(MLD_CUSTOM_ALLOC, MLD_CONTEXT_PARAMETERS_3(v, T, N, context))
|
|
279
|
+
|
|
280
|
+
#define MLD_FREE(v, T, N, context) \
|
|
281
|
+
do \
|
|
282
|
+
{ \
|
|
283
|
+
if (v != NULL) \
|
|
284
|
+
{ \
|
|
285
|
+
mld_zeroize(v, sizeof(T) * (N)); \
|
|
286
|
+
MLD_APPLY(MLD_CUSTOM_FREE, MLD_CONTEXT_PARAMETERS_3(v, T, N, context)); \
|
|
287
|
+
v = NULL; \
|
|
288
|
+
} \
|
|
289
|
+
} while (0)
|
|
290
|
+
|
|
291
|
+
#endif /* MLD_CONFIG_CUSTOM_ALLOC_FREE */
|
|
292
|
+
|
|
293
|
+
/*
|
|
294
|
+
* We are facing severe CBMC performance issues when using unions.
|
|
295
|
+
* As a temporary workaround, we use unions only when MLD_CONFIG_REDUCE_RAM is
|
|
296
|
+
* set.
|
|
297
|
+
* TODO: Remove the workaround once
|
|
298
|
+
* https://github.com/diffblue/cbmc/issues/8813
|
|
299
|
+
* is resolved
|
|
300
|
+
*/
|
|
301
|
+
#if defined(MLD_CONFIG_REDUCE_RAM)
|
|
302
|
+
#define MLD_UNION_OR_STRUCT union
|
|
303
|
+
#else
|
|
304
|
+
#define MLD_UNION_OR_STRUCT struct
|
|
305
|
+
#endif
|
|
306
|
+
|
|
307
|
+
/****************************** Error codes ***********************************/
|
|
308
|
+
|
|
309
|
+
/* Generic failure condition */
|
|
310
|
+
#define MLD_ERR_FAIL -1
|
|
311
|
+
/* An allocation failed. This can only happen if MLD_CONFIG_CUSTOM_ALLOC_FREE
|
|
312
|
+
* is defined and the provided MLD_CUSTOM_ALLOC can fail. */
|
|
313
|
+
#define MLD_ERR_OUT_OF_MEMORY -2
|
|
314
|
+
/* An rng failure occured. Might be due to insufficient entropy or
|
|
315
|
+
* system misconfiguration. */
|
|
316
|
+
#define MLD_ERR_RNG_FAIL -3
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
#endif /* !__ASSEMBLER__ */
|
|
320
|
+
|
|
321
|
+
#endif /* !MLD_COMMON_H */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* Copyright (c) The mldsa-native project authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
5
|
+
*/
|
|
6
|
+
#include "ct.h"
|
|
7
|
+
|
|
8
|
+
#if !defined(MLD_USE_ASM_VALUE_BARRIER) && \
|
|
9
|
+
!defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
|
|
10
|
+
/*
|
|
11
|
+
* Masking value used in constant-time functions from
|
|
12
|
+
* ct.h to block the compiler's range analysis and
|
|
13
|
+
* thereby reduce the risk of compiler-introduced branches.
|
|
14
|
+
*/
|
|
15
|
+
volatile uint64_t mld_ct_opt_blocker_u64 = 0;
|
|
16
|
+
|
|
17
|
+
#else /* !MLD_USE_ASM_VALUE_BARRIER && !MLD_CONFIG_MULTILEVEL_NO_SHARED */
|
|
18
|
+
|
|
19
|
+
MLD_EMPTY_CU(ct)
|
|
20
|
+
|
|
21
|
+
#endif /* !(!MLD_USE_ASM_VALUE_BARRIER && !MLD_CONFIG_MULTILEVEL_NO_SHARED) */
|