pq_crypto 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +56 -0
- data/CHANGELOG.md +62 -0
- data/GET_STARTED.md +366 -40
- data/README.md +76 -233
- data/SECURITY.md +107 -82
- data/ext/pqcrypto/extconf.rb +169 -87
- data/ext/pqcrypto/mldsa_api.h +1 -48
- data/ext/pqcrypto/mlkem_api.h +1 -18
- data/ext/pqcrypto/pq_externalmu.c +89 -204
- data/ext/pqcrypto/pqcrypto_native_api.h +129 -0
- data/ext/pqcrypto/pqcrypto_ruby_secure.c +484 -84
- data/ext/pqcrypto/pqcrypto_secure.c +203 -78
- data/ext/pqcrypto/pqcrypto_secure.h +53 -14
- data/ext/pqcrypto/pqcrypto_version.h +7 -0
- data/ext/pqcrypto/randombytes.h +9 -0
- data/ext/pqcrypto/vendor/.vendored +10 -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/algorithm_registry.rb +200 -0
- data/lib/pq_crypto/hybrid_kem.rb +1 -12
- data/lib/pq_crypto/kem.rb +104 -13
- data/lib/pq_crypto/pkcs8.rb +387 -0
- data/lib/pq_crypto/serialization.rb +1 -14
- data/lib/pq_crypto/signature.rb +123 -17
- data/lib/pq_crypto/spki.rb +131 -0
- data/lib/pq_crypto/version.rb +1 -1
- data/lib/pq_crypto.rb +79 -20
- data/script/vendor_libs.rb +88 -155
- metadata +241 -73
- 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-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-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
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
|
|
7
|
+
#ifndef MLD_NATIVE_AARCH64_META_H
|
|
8
|
+
#define MLD_NATIVE_AARCH64_META_H
|
|
9
|
+
|
|
10
|
+
/* Set of primitives that this backend replaces */
|
|
11
|
+
#define MLD_USE_NATIVE_NTT
|
|
12
|
+
#define MLD_USE_NATIVE_INTT
|
|
13
|
+
#define MLD_USE_NATIVE_REJ_UNIFORM
|
|
14
|
+
#define MLD_USE_NATIVE_REJ_UNIFORM_ETA2
|
|
15
|
+
#define MLD_USE_NATIVE_REJ_UNIFORM_ETA4
|
|
16
|
+
#define MLD_USE_NATIVE_POLY_DECOMPOSE_32
|
|
17
|
+
#define MLD_USE_NATIVE_POLY_DECOMPOSE_88
|
|
18
|
+
#define MLD_USE_NATIVE_POLY_CADDQ
|
|
19
|
+
#define MLD_USE_NATIVE_POLY_USE_HINT_32
|
|
20
|
+
#define MLD_USE_NATIVE_POLY_USE_HINT_88
|
|
21
|
+
#define MLD_USE_NATIVE_POLY_CHKNORM
|
|
22
|
+
#define MLD_USE_NATIVE_POLYZ_UNPACK_17
|
|
23
|
+
#define MLD_USE_NATIVE_POLYZ_UNPACK_19
|
|
24
|
+
#define MLD_USE_NATIVE_POINTWISE_MONTGOMERY
|
|
25
|
+
#define MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L4
|
|
26
|
+
#define MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L5
|
|
27
|
+
#define MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7
|
|
28
|
+
|
|
29
|
+
/* Identifier for this backend so that source and assembly files
|
|
30
|
+
* in the build can be appropriately guarded. */
|
|
31
|
+
#define MLD_ARITH_BACKEND_AARCH64
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#if !defined(__ASSEMBLER__)
|
|
35
|
+
#include "../api.h"
|
|
36
|
+
#include "src/arith_native_aarch64.h"
|
|
37
|
+
|
|
38
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
39
|
+
static MLD_INLINE int mld_ntt_native(int32_t data[MLDSA_N])
|
|
40
|
+
{
|
|
41
|
+
mld_ntt_asm(data, mld_aarch64_ntt_zetas_layer123456,
|
|
42
|
+
mld_aarch64_ntt_zetas_layer78);
|
|
43
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
47
|
+
static MLD_INLINE int mld_intt_native(int32_t data[MLDSA_N])
|
|
48
|
+
{
|
|
49
|
+
mld_intt_asm(data, mld_aarch64_intt_zetas_layer78,
|
|
50
|
+
mld_aarch64_intt_zetas_layer123456);
|
|
51
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
55
|
+
static MLD_INLINE int mld_rej_uniform_native(int32_t *r, unsigned len,
|
|
56
|
+
const uint8_t *buf,
|
|
57
|
+
unsigned buflen)
|
|
58
|
+
{
|
|
59
|
+
if (len != MLDSA_N ||
|
|
60
|
+
buflen % 24 != 0) /* NEON support is mandatory for AArch64 */
|
|
61
|
+
{
|
|
62
|
+
return MLD_NATIVE_FUNC_FALLBACK;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Safety: outlen is at most MLDSA_N, hence, this cast is safe. */
|
|
66
|
+
return (int)mld_rej_uniform_asm(r, buf, buflen, mld_rej_uniform_table);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_ETA == 2
|
|
70
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
71
|
+
static MLD_INLINE int mld_rej_uniform_eta2_native(int32_t *r, unsigned len,
|
|
72
|
+
const uint8_t *buf,
|
|
73
|
+
unsigned buflen)
|
|
74
|
+
{
|
|
75
|
+
uint64_t outlen;
|
|
76
|
+
/* AArch64 implementation assumes specific buffer lengths */
|
|
77
|
+
if (len != MLDSA_N || buflen != MLD_AARCH64_REJ_UNIFORM_ETA2_BUFLEN)
|
|
78
|
+
{
|
|
79
|
+
return MLD_NATIVE_FUNC_FALLBACK;
|
|
80
|
+
}
|
|
81
|
+
/* Constant time: Inputs and outputs to this function are secret.
|
|
82
|
+
* It is safe to leak which coefficients are accepted/rejected.
|
|
83
|
+
* The assembly implementation must not leak any other information about the
|
|
84
|
+
* accepted coefficients. Constant-time testing cannot cover this, and we
|
|
85
|
+
* hence have to manually verify the assembly.
|
|
86
|
+
* We declassify prior the input data and mark the outputs as secret.
|
|
87
|
+
*/
|
|
88
|
+
MLD_CT_TESTING_DECLASSIFY(buf, buflen);
|
|
89
|
+
outlen = mld_rej_uniform_eta2_asm(r, buf, buflen, mld_rej_uniform_eta_table);
|
|
90
|
+
MLD_CT_TESTING_SECRET(r, sizeof(int32_t) * outlen);
|
|
91
|
+
/* Safety: outlen is at most MLDSA_N and, hence, this cast is safe. */
|
|
92
|
+
return (int)outlen;
|
|
93
|
+
}
|
|
94
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 2 */
|
|
95
|
+
|
|
96
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_ETA == 4
|
|
97
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
98
|
+
static MLD_INLINE int mld_rej_uniform_eta4_native(int32_t *r, unsigned len,
|
|
99
|
+
const uint8_t *buf,
|
|
100
|
+
unsigned buflen)
|
|
101
|
+
{
|
|
102
|
+
uint64_t outlen;
|
|
103
|
+
/* AArch64 implementation assumes specific buffer lengths */
|
|
104
|
+
if (len != MLDSA_N || buflen != MLD_AARCH64_REJ_UNIFORM_ETA4_BUFLEN)
|
|
105
|
+
{
|
|
106
|
+
return MLD_NATIVE_FUNC_FALLBACK;
|
|
107
|
+
}
|
|
108
|
+
/* Constant time: Inputs and outputs to this function are secret.
|
|
109
|
+
* It is safe to leak which coefficients are accepted/rejected.
|
|
110
|
+
* The assembly implementation must not leak any other information about the
|
|
111
|
+
* accepted coefficients. Constant-time testing cannot cover this, and we
|
|
112
|
+
* hence have to manually verify the assembly.
|
|
113
|
+
* We declassify prior the input data and mark the outputs as secret.
|
|
114
|
+
*/
|
|
115
|
+
MLD_CT_TESTING_DECLASSIFY(buf, buflen);
|
|
116
|
+
outlen = mld_rej_uniform_eta4_asm(r, buf, buflen, mld_rej_uniform_eta_table);
|
|
117
|
+
MLD_CT_TESTING_SECRET(r, sizeof(int32_t) * outlen);
|
|
118
|
+
/* Safety: outlen is at most MLDSA_N and, hence, this cast is safe. */
|
|
119
|
+
return (int)outlen;
|
|
120
|
+
}
|
|
121
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 4 */
|
|
122
|
+
|
|
123
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
124
|
+
(MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
|
|
125
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
126
|
+
static MLD_INLINE int mld_poly_decompose_32_native(int32_t *a1, int32_t *a0)
|
|
127
|
+
{
|
|
128
|
+
mld_poly_decompose_32_asm(a1, a0);
|
|
129
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
130
|
+
}
|
|
131
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
|
|
132
|
+
|| MLD_CONFIG_PARAMETER_SET == 87 */
|
|
133
|
+
|
|
134
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
|
|
135
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
136
|
+
static MLD_INLINE int mld_poly_decompose_88_native(int32_t *a1, int32_t *a0)
|
|
137
|
+
{
|
|
138
|
+
mld_poly_decompose_88_asm(a1, a0);
|
|
139
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
140
|
+
}
|
|
141
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44 \
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
145
|
+
static MLD_INLINE int mld_poly_caddq_native(int32_t a[MLDSA_N])
|
|
146
|
+
{
|
|
147
|
+
mld_poly_caddq_asm(a);
|
|
148
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
152
|
+
(MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
|
|
153
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
154
|
+
static MLD_INLINE int mld_poly_use_hint_32_native(int32_t *b, const int32_t *a,
|
|
155
|
+
const int32_t *h)
|
|
156
|
+
{
|
|
157
|
+
mld_poly_use_hint_32_asm(b, a, h);
|
|
158
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
159
|
+
}
|
|
160
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
|
|
161
|
+
|| MLD_CONFIG_PARAMETER_SET == 87 */
|
|
162
|
+
|
|
163
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
|
|
164
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
165
|
+
static MLD_INLINE int mld_poly_use_hint_88_native(int32_t *b, const int32_t *a,
|
|
166
|
+
const int32_t *h)
|
|
167
|
+
{
|
|
168
|
+
mld_poly_use_hint_88_asm(b, a, h);
|
|
169
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
170
|
+
}
|
|
171
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44 \
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
175
|
+
static MLD_INLINE int mld_poly_chknorm_native(const int32_t *a, int32_t B)
|
|
176
|
+
{
|
|
177
|
+
return mld_poly_chknorm_asm(a, B);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
|
|
181
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
182
|
+
static MLD_INLINE int mld_polyz_unpack_17_native(int32_t *r, const uint8_t *buf)
|
|
183
|
+
{
|
|
184
|
+
mld_polyz_unpack_17_asm(r, buf, mld_polyz_unpack_17_indices);
|
|
185
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
186
|
+
}
|
|
187
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44 \
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
191
|
+
(MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
|
|
192
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
193
|
+
static MLD_INLINE int mld_polyz_unpack_19_native(int32_t *r, const uint8_t *buf)
|
|
194
|
+
{
|
|
195
|
+
mld_polyz_unpack_19_asm(r, buf, mld_polyz_unpack_19_indices);
|
|
196
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
197
|
+
}
|
|
198
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
|
|
199
|
+
|| MLD_CONFIG_PARAMETER_SET == 87 */
|
|
200
|
+
|
|
201
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
202
|
+
static MLD_INLINE int mld_poly_pointwise_montgomery_native(
|
|
203
|
+
int32_t out[MLDSA_N], const int32_t in0[MLDSA_N],
|
|
204
|
+
const int32_t in1[MLDSA_N])
|
|
205
|
+
{
|
|
206
|
+
mld_poly_pointwise_montgomery_asm(out, in0, in1);
|
|
207
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_L == 4
|
|
211
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
212
|
+
static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l4_native(
|
|
213
|
+
int32_t w[MLDSA_N], const int32_t u[4][MLDSA_N],
|
|
214
|
+
const int32_t v[4][MLDSA_N])
|
|
215
|
+
{
|
|
216
|
+
mld_polyvecl_pointwise_acc_montgomery_l4_asm(w, (const int32_t *)u,
|
|
217
|
+
(const int32_t *)v);
|
|
218
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
219
|
+
}
|
|
220
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 4 */
|
|
221
|
+
|
|
222
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_L == 5
|
|
223
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
224
|
+
static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l5_native(
|
|
225
|
+
int32_t w[MLDSA_N], const int32_t u[5][MLDSA_N],
|
|
226
|
+
const int32_t v[5][MLDSA_N])
|
|
227
|
+
{
|
|
228
|
+
mld_polyvecl_pointwise_acc_montgomery_l5_asm(w, (const int32_t *)u,
|
|
229
|
+
(const int32_t *)v);
|
|
230
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
231
|
+
}
|
|
232
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 5 */
|
|
233
|
+
|
|
234
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_L == 7
|
|
235
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
236
|
+
static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l7_native(
|
|
237
|
+
int32_t w[MLDSA_N], const int32_t u[7][MLDSA_N],
|
|
238
|
+
const int32_t v[7][MLDSA_N])
|
|
239
|
+
{
|
|
240
|
+
mld_polyvecl_pointwise_acc_montgomery_l7_asm(w, (const int32_t *)u,
|
|
241
|
+
(const int32_t *)v);
|
|
242
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
243
|
+
}
|
|
244
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 7 */
|
|
245
|
+
|
|
246
|
+
#endif /* !__ASSEMBLER__ */
|
|
247
|
+
#endif /* !MLD_NATIVE_AARCH64_META_H */
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mldsa-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* WARNING: This file is auto-generated from scripts/autogen
|
|
8
|
+
* in the mldsa-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "../../../common.h"
|
|
13
|
+
|
|
14
|
+
#if defined(MLD_ARITH_BACKEND_AARCH64) && \
|
|
15
|
+
!defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
|
|
16
|
+
|
|
17
|
+
#include "arith_native_aarch64.h"
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* Table of zeta values used in the AArch64 forward NTT
|
|
21
|
+
* See autogen for details.
|
|
22
|
+
*/
|
|
23
|
+
MLD_ALIGN const int32_t mld_aarch64_ntt_zetas_layer123456[] = {
|
|
24
|
+
-3572223, -915382907, 3765607, 964937599, 3761513, 963888510,
|
|
25
|
+
-3201494, -820383522, -2883726, -738955404, -3145678, -806080660,
|
|
26
|
+
-3201430, -820367122, 0, 0, -601683, -154181397,
|
|
27
|
+
-3370349, -863652652, -4063053, -1041158200, 3602218, 923069133,
|
|
28
|
+
3182878, 815613168, 2740543, 702264730, -3586446, -919027554,
|
|
29
|
+
0, 0, 3542485, 907762539, 2663378, 682491182,
|
|
30
|
+
-1674615, -429120452, -3110818, -797147778, 2101410, 538486762,
|
|
31
|
+
3704823, 949361686, 1159875, 297218217, 0, 0,
|
|
32
|
+
2682288, 687336873, -3524442, -903139016, -434125, -111244624,
|
|
33
|
+
394148, 101000509, 928749, 237992130, 1095468, 280713909,
|
|
34
|
+
-3506380, -898510625, 0, 0, 2129892, 545785280,
|
|
35
|
+
676590, 173376332, -1335936, -342333886, 2071829, 530906624,
|
|
36
|
+
-4018989, -1029866791, 3241972, 830756018, 2156050, 552488273,
|
|
37
|
+
0, 0, 3764867, 964747974, -3227876, -827143915,
|
|
38
|
+
1714295, 439288460, 3415069, 875112161, 1759347, 450833045,
|
|
39
|
+
-817536, -209493775, -3574466, -915957677, 0, 0,
|
|
40
|
+
-1005239, -257592709, 2453983, 628833668, 1460718, 374309300,
|
|
41
|
+
3756790, 962678241, -1935799, -496048908, -1716988, -439978542,
|
|
42
|
+
-3950053, -1012201926, 0, 0, 557458, 142848732,
|
|
43
|
+
-642628, -164673562, -3585098, -918682129, -2897314, -742437332,
|
|
44
|
+
3192354, 818041395, 556856, 142694469, 3870317, 991769559,
|
|
45
|
+
0, 0, -1221177, -312926867, 2815639, 721508096,
|
|
46
|
+
2283733, 585207070, 2917338, 747568486, 1853806, 475038184,
|
|
47
|
+
3345963, 857403734, 1858416, 476219497, 0, 0,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
MLD_ALIGN const int32_t mld_aarch64_ntt_zetas_layer78[] = {
|
|
51
|
+
3073009, 1277625, -2635473, 3852015, 787459213,
|
|
52
|
+
327391679, -675340520, 987079667, 1753, -2659525,
|
|
53
|
+
2660408, -59148, 449207, -681503850, 681730119,
|
|
54
|
+
-15156688, -1935420, -1455890, -1780227, 2772600,
|
|
55
|
+
-495951789, -373072124, -456183549, 710479343, 4183372,
|
|
56
|
+
-3222807, -3121440, -274060, 1071989969, -825844983,
|
|
57
|
+
-799869667, -70227934, 1182243, 636927, -3956745,
|
|
58
|
+
-3284915, 302950022, 163212680, -1013916752, -841760171,
|
|
59
|
+
87208, -3965306, -2296397, -3716946, 22347069,
|
|
60
|
+
-1016110510, -588452222, -952468207, 2508980, 2028118,
|
|
61
|
+
1937570, -3815725, 642926661, 519705671, 496502727,
|
|
62
|
+
-977780347, -27812, 1009365, -1979497, -3956944,
|
|
63
|
+
-7126831, 258649997, -507246529, -1013967746, 822541,
|
|
64
|
+
-2454145, 1596822, -3759465, 210776307, -628875181,
|
|
65
|
+
409185979, -963363710, 2811291, -2983781, -1109516,
|
|
66
|
+
4158088, 720393920, -764594519, -284313712, 1065510939,
|
|
67
|
+
-1685153, 2678278, -3551006, -250446, -431820817,
|
|
68
|
+
686309310, -909946047, -64176841, -3410568, -3768948,
|
|
69
|
+
635956, -2455377, -873958779, -965793731, 162963861,
|
|
70
|
+
-629190881, 1528066, 482649, 1148858, -2962264,
|
|
71
|
+
391567239, 123678909, 294395108, -759080783, -4146264,
|
|
72
|
+
2192938, 2387513, -268456, -1062481036, 561940831,
|
|
73
|
+
611800717, -68791907, -1772588, -1727088, -3611750,
|
|
74
|
+
-3180456, -454226054, -442566669, -925511710, -814992530,
|
|
75
|
+
-565603, 169688, 2462444, -3334383, -144935890,
|
|
76
|
+
43482586, 631001801, -854436357, 3747250, 1239911,
|
|
77
|
+
3195676, 1254190, 960233614, 317727459, 818892658,
|
|
78
|
+
321386456, 2296099, -3838479, 2642980, -12417,
|
|
79
|
+
588375860, -983611064, 677264190, -3181859, -4166425,
|
|
80
|
+
-3488383, 1987814, -3197248, -1067647297, -893898890,
|
|
81
|
+
509377762, -819295484, 2998219, -89301, -1354892,
|
|
82
|
+
-1310261, 768294260, -22883400, -347191365, -335754661,
|
|
83
|
+
141835, 2513018, 613238, -2218467, 36345249,
|
|
84
|
+
643961400, 157142369, -568482643, 1736313, 235407,
|
|
85
|
+
-3250154, 3258457, 444930577, 60323094, -832852657,
|
|
86
|
+
834980303, -458740, 4040196, 2039144, -818761,
|
|
87
|
+
-117552223, 1035301089, 522531086, -209807681, -1921994,
|
|
88
|
+
-3472069, -1879878, -2178965, -492511373, -889718424,
|
|
89
|
+
-481719139, -558360247, -2579253, 1787943, -2391089,
|
|
90
|
+
-2254727, -660934133, 458160776, -612717067, -577774276,
|
|
91
|
+
-1623354, -2374402, 586241, 527981, -415984810,
|
|
92
|
+
-608441020, 150224382, 135295244, 2105286, -2033807,
|
|
93
|
+
-1179613, -2743411, 539479988, -521163479, -302276083,
|
|
94
|
+
-702999655, 3482206, -4182915, -1300016, -2362063,
|
|
95
|
+
892316032, -1071872863, -333129378, -605279149, -1476985,
|
|
96
|
+
2491325, 507927, -724804, -378477722, 638402564,
|
|
97
|
+
130156402, -185731180, 1994046, -1393159, -1187885,
|
|
98
|
+
-1834526, 510974714, -356997292, -304395785, -470097680,
|
|
99
|
+
-1317678, 2461387, 3035980, 621164, -337655269,
|
|
100
|
+
630730945, 777970524, 159173408, -3033742, 2647994,
|
|
101
|
+
-2612853, 749577, -777397036, 678549029, -669544140,
|
|
102
|
+
192079267, -338420, 3009748, 4148469, -4022750,
|
|
103
|
+
-86720197, 771248568, 1063046068, -1030830548, 3901472,
|
|
104
|
+
-1226661, 2925816, 3374250, 999753034, -314332144,
|
|
105
|
+
749740976, 864652284, 3980599, -1615530, 1665318,
|
|
106
|
+
1163598, 1020029345, -413979908, 426738094, 298172236,
|
|
107
|
+
2569011, 1723229, 2028038, -3369273, 658309618,
|
|
108
|
+
441577800, 519685171, -863376927, 1356448, -2775755,
|
|
109
|
+
2683270, -2778788, 347590090, -711287812, 687588511,
|
|
110
|
+
-712065019, 3994671, -1370517, 3363542, 545376,
|
|
111
|
+
1023635298, -351195274, 861908357, 139752717, -11879,
|
|
112
|
+
3020393, 214880, -770441, -3043996, 773976352,
|
|
113
|
+
55063046, -197425671, -3467665, 2312838, -653275,
|
|
114
|
+
-459163, -888589898, 592665232, -167401858, -117660617,
|
|
115
|
+
3105558, 508145, 860144, 140244, 795799901,
|
|
116
|
+
130212265, 220412084, 35937555, -1103344, -553718,
|
|
117
|
+
3430436, -1514152, -282732136, -141890356, 879049958,
|
|
118
|
+
-388001774, 348812, -327848, 1011223, -2354215,
|
|
119
|
+
89383150, -84011120, 259126110, -603268097, -2185084,
|
|
120
|
+
2358373, -3014420, 2926054, -559928242, 604333585,
|
|
121
|
+
-772445769, 749801963, 3123762, -2193087, -1716814,
|
|
122
|
+
-392707, 800464680, -561979013, -439933955, -100631253,
|
|
123
|
+
-3818627, -1922253, -2236726, 1744507, -978523985,
|
|
124
|
+
-492577742, -573161516, 447030292, -303005, -3974485,
|
|
125
|
+
1900052, 1054478, -77645096, -1018462631, 486888731,
|
|
126
|
+
270210213, 3531229, -3773731, -781875, -731434,
|
|
127
|
+
904878186, -967019376, -200355636, -187430119,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
MLD_ALIGN const int32_t mld_aarch64_intt_zetas_layer78[] = {
|
|
131
|
+
-1744507, 2236726, 1922253, 3818627, -447030292, 573161516,
|
|
132
|
+
492577742, 978523985, 731434, 781875, 3773731, -3531229,
|
|
133
|
+
187430119, 200355636, 967019376, -904878186, -1054478, -1900052,
|
|
134
|
+
3974485, 303005, -270210213, -486888731, 1018462631, 77645096,
|
|
135
|
+
2354215, -1011223, 327848, -348812, 603268097, -259126110,
|
|
136
|
+
84011120, -89383150, 392707, 1716814, 2193087, -3123762,
|
|
137
|
+
100631253, 439933955, 561979013, -800464680, -2926054, 3014420,
|
|
138
|
+
-2358373, 2185084, -749801963, 772445769, -604333585, 559928242,
|
|
139
|
+
459163, 653275, -2312838, 3467665, 117660617, 167401858,
|
|
140
|
+
-592665232, 888589898, 1514152, -3430436, 553718, 1103344,
|
|
141
|
+
388001774, -879049958, 141890356, 282732136, -140244, -860144,
|
|
142
|
+
-508145, -3105558, -35937555, -220412084, -130212265, -795799901,
|
|
143
|
+
2778788, -2683270, 2775755, -1356448, 712065019, -687588511,
|
|
144
|
+
711287812, -347590090, 770441, -214880, -3020393, 11879,
|
|
145
|
+
197425671, -55063046, -773976352, 3043996, -545376, -3363542,
|
|
146
|
+
1370517, -3994671, -139752717, -861908357, 351195274, -1023635298,
|
|
147
|
+
-3374250, -2925816, 1226661, -3901472, -864652284, -749740976,
|
|
148
|
+
314332144, -999753034, 3369273, -2028038, -1723229, -2569011,
|
|
149
|
+
863376927, -519685171, -441577800, -658309618, -1163598, -1665318,
|
|
150
|
+
1615530, -3980599, -298172236, -426738094, 413979908, -1020029345,
|
|
151
|
+
-621164, -3035980, -2461387, 1317678, -159173408, -777970524,
|
|
152
|
+
-630730945, 337655269, 4022750, -4148469, -3009748, 338420,
|
|
153
|
+
1030830548, -1063046068, -771248568, 86720197, -749577, 2612853,
|
|
154
|
+
-2647994, 3033742, -192079267, 669544140, -678549029, 777397036,
|
|
155
|
+
2362063, 1300016, 4182915, -3482206, 605279149, 333129378,
|
|
156
|
+
1071872863, -892316032, 1834526, 1187885, 1393159, -1994046,
|
|
157
|
+
470097680, 304395785, 356997292, -510974714, 724804, -507927,
|
|
158
|
+
-2491325, 1476985, 185731180, -130156402, -638402564, 378477722,
|
|
159
|
+
2254727, 2391089, -1787943, 2579253, 577774276, 612717067,
|
|
160
|
+
-458160776, 660934133, 2743411, 1179613, 2033807, -2105286,
|
|
161
|
+
702999655, 302276083, 521163479, -539479988, -527981, -586241,
|
|
162
|
+
2374402, 1623354, -135295244, -150224382, 608441020, 415984810,
|
|
163
|
+
-3258457, 3250154, -235407, -1736313, -834980303, 832852657,
|
|
164
|
+
-60323094, -444930577, 2178965, 1879878, 3472069, 1921994,
|
|
165
|
+
558360247, 481719139, 889718424, 492511373, 818761, -2039144,
|
|
166
|
+
-4040196, 458740, 209807681, -522531086, -1035301089, 117552223,
|
|
167
|
+
3197248, -1987814, 3488383, 4166425, 819295484, -509377762,
|
|
168
|
+
893898890, 1067647297, 2218467, -613238, -2513018, -141835,
|
|
169
|
+
568482643, -157142369, -643961400, -36345249, 1310261, 1354892,
|
|
170
|
+
89301, -2998219, 335754661, 347191365, 22883400, -768294260,
|
|
171
|
+
3334383, -2462444, -169688, 565603, 854436357, -631001801,
|
|
172
|
+
-43482586, 144935890, 12417, -2642980, 3838479, -2296099,
|
|
173
|
+
3181859, -677264190, 983611064, -588375860, -1254190, -3195676,
|
|
174
|
+
-1239911, -3747250, -321386456, -818892658, -317727459, -960233614,
|
|
175
|
+
2962264, -1148858, -482649, -1528066, 759080783, -294395108,
|
|
176
|
+
-123678909, -391567239, 3180456, 3611750, 1727088, 1772588,
|
|
177
|
+
814992530, 925511710, 442566669, 454226054, 268456, -2387513,
|
|
178
|
+
-2192938, 4146264, 68791907, -611800717, -561940831, 1062481036,
|
|
179
|
+
-4158088, 1109516, 2983781, -2811291, -1065510939, 284313712,
|
|
180
|
+
764594519, -720393920, 2455377, -635956, 3768948, 3410568,
|
|
181
|
+
629190881, -162963861, 965793731, 873958779, 250446, 3551006,
|
|
182
|
+
-2678278, 1685153, 64176841, 909946047, -686309310, 431820817,
|
|
183
|
+
3815725, -1937570, -2028118, -2508980, 977780347, -496502727,
|
|
184
|
+
-519705671, -642926661, 3759465, -1596822, 2454145, -822541,
|
|
185
|
+
963363710, -409185979, 628875181, -210776307, 3956944, 1979497,
|
|
186
|
+
-1009365, 27812, 1013967746, 507246529, -258649997, 7126831,
|
|
187
|
+
274060, 3121440, 3222807, -4183372, 70227934, 799869667,
|
|
188
|
+
825844983, -1071989969, 3716946, 2296397, 3965306, -87208,
|
|
189
|
+
952468207, 588452222, 1016110510, -22347069, 3284915, 3956745,
|
|
190
|
+
-636927, -1182243, 841760171, 1013916752, -163212680, -302950022,
|
|
191
|
+
-3852015, 2635473, -1277625, -3073009, -987079667, 675340520,
|
|
192
|
+
-327391679, -787459213, -2772600, 1780227, 1455890, 1935420,
|
|
193
|
+
-710479343, 456183549, 373072124, 495951789, 59148, -2660408,
|
|
194
|
+
2659525, -1753, 15156688, -681730119, 681503850, -449207,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
MLD_ALIGN const int32_t mld_aarch64_intt_zetas_layer123456[] = {
|
|
198
|
+
-2283733, -585207070, 0, 0, -1858416, -476219497,
|
|
199
|
+
-3345963, -857403734, -2815639, -721508096, 0, 0,
|
|
200
|
+
-1853806, -475038184, -2917338, -747568486, 3585098, 918682129,
|
|
201
|
+
0, 0, -3870317, -991769559, -556856, -142694469,
|
|
202
|
+
642628, 164673562, 0, 0, -3192354, -818041395,
|
|
203
|
+
2897314, 742437332, -1460718, -374309300, 0, 0,
|
|
204
|
+
3950053, 1012201926, 1716988, 439978542, -2453983, -628833668,
|
|
205
|
+
0, 0, 1935799, 496048908, -3756790, -962678241,
|
|
206
|
+
-1714295, -439288460, 0, 0, 3574466, 915957677,
|
|
207
|
+
817536, 209493775, 3227876, 827143915, 0, 0,
|
|
208
|
+
-1759347, -450833045, -3415069, -875112161, 1335936, 342333886,
|
|
209
|
+
0, 0, -2156050, -552488273, -3241972, -830756018,
|
|
210
|
+
-676590, -173376332, 0, 0, 4018989, 1029866791,
|
|
211
|
+
-2071829, -530906624, 434125, 111244624, 0, 0,
|
|
212
|
+
3506380, 898510625, -1095468, -280713909, 3524442, 903139016,
|
|
213
|
+
0, 0, -928749, -237992130, -394148, -101000509,
|
|
214
|
+
1674615, 429120452, 0, 0, -1159875, -297218217,
|
|
215
|
+
-3704823, -949361686, -2663378, -682491182, 0, 0,
|
|
216
|
+
-2101410, -538486762, 3110818, 797147778, 4063053, 1041158200,
|
|
217
|
+
0, 0, 3586446, 919027554, -2740543, -702264730,
|
|
218
|
+
3370349, 863652652, 0, 0, -3182878, -815613168,
|
|
219
|
+
-3602218, -923069133, -294725, -75523344, -3761513, -963888510,
|
|
220
|
+
-3765607, -964937599, 3201430, 820367122, 3145678, 806080660,
|
|
221
|
+
2883726, 738955404, 3201494, 820383522, 1221177, 312926867,
|
|
222
|
+
-557458, -142848732, 1005239, 257592709, -3764867, -964747974,
|
|
223
|
+
-2129892, -545785280, -2682288, -687336873, -3542485, -907762539,
|
|
224
|
+
601683, 154181397, 0, 0,
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
#else /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_MULTILEVEL_NO_SHARED */
|
|
228
|
+
|
|
229
|
+
MLD_EMPTY_CU(aarch64_zetas)
|
|
230
|
+
|
|
231
|
+
#endif /* !(MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_MULTILEVEL_NO_SHARED) */
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
|
|
7
|
+
#ifndef MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H
|
|
8
|
+
#define MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H
|
|
9
|
+
|
|
10
|
+
#include "../../../cbmc.h"
|
|
11
|
+
#include "../../../common.h"
|
|
12
|
+
|
|
13
|
+
#define mld_aarch64_ntt_zetas_layer123456 \
|
|
14
|
+
MLD_NAMESPACE(aarch64_ntt_zetas_layer123456)
|
|
15
|
+
#define mld_aarch64_ntt_zetas_layer78 MLD_NAMESPACE(aarch64_ntt_zetas_layer78)
|
|
16
|
+
|
|
17
|
+
#define mld_aarch64_intt_zetas_layer78 MLD_NAMESPACE(aarch64_intt_zetas_layer78)
|
|
18
|
+
#define mld_aarch64_intt_zetas_layer123456 \
|
|
19
|
+
MLD_NAMESPACE(aarch64_intt_zetas_layer123456)
|
|
20
|
+
|
|
21
|
+
extern const int32_t mld_aarch64_ntt_zetas_layer123456[];
|
|
22
|
+
extern const int32_t mld_aarch64_ntt_zetas_layer78[];
|
|
23
|
+
|
|
24
|
+
extern const int32_t mld_aarch64_intt_zetas_layer78[];
|
|
25
|
+
extern const int32_t mld_aarch64_intt_zetas_layer123456[];
|
|
26
|
+
|
|
27
|
+
#define mld_rej_uniform_table MLD_NAMESPACE(rej_uniform_table)
|
|
28
|
+
extern const uint8_t mld_rej_uniform_table[];
|
|
29
|
+
#define mld_rej_uniform_eta_table MLD_NAMESPACE(rej_uniform_eta_table)
|
|
30
|
+
extern const uint8_t mld_rej_uniform_eta_table[];
|
|
31
|
+
|
|
32
|
+
#define mld_polyz_unpack_17_indices MLD_NAMESPACE(polyz_unpack_17_indices)
|
|
33
|
+
extern const uint8_t mld_polyz_unpack_17_indices[];
|
|
34
|
+
#define mld_polyz_unpack_19_indices MLD_NAMESPACE(polyz_unpack_19_indices)
|
|
35
|
+
extern const uint8_t mld_polyz_unpack_19_indices[];
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* Sampling 256 coefficients mod 15 using rejection sampling from 4 bits.
|
|
40
|
+
* Expected number of required bytes: (256 * (16/15))/2 = 136.5 bytes.
|
|
41
|
+
* We sample 1 block (=136 bytes) of SHAKE256_RATE output initially.
|
|
42
|
+
* Sampling 2 blocks initially results in slightly worse performance.
|
|
43
|
+
*/
|
|
44
|
+
#define MLD_AARCH64_REJ_UNIFORM_ETA2_BUFLEN (1 * 136)
|
|
45
|
+
/*
|
|
46
|
+
* Sampling 256 coefficients mod 9 using rejection sampling from 4 bits.
|
|
47
|
+
* Expected number of required bytes: (256 * (16/9))/2 = 227.5 bytes.
|
|
48
|
+
* We sample 2 blocks (=272 bytes) of SHAKE256_RATE output initially.
|
|
49
|
+
*/
|
|
50
|
+
#define MLD_AARCH64_REJ_UNIFORM_ETA4_BUFLEN (2 * 136)
|
|
51
|
+
|
|
52
|
+
#define mld_ntt_asm MLD_NAMESPACE(ntt_asm)
|
|
53
|
+
void mld_ntt_asm(int32_t *r, const int32_t *zetas_l123456,
|
|
54
|
+
const int32_t *zetas_l78)
|
|
55
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
56
|
+
* in proofs/hol_light/aarch64/proofs/mldsa_ntt.ml */
|
|
57
|
+
__contract__(
|
|
58
|
+
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
|
|
59
|
+
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
|
|
60
|
+
requires(zetas_l123456 == mld_aarch64_ntt_zetas_layer123456)
|
|
61
|
+
requires(zetas_l78 == mld_aarch64_ntt_zetas_layer78)
|
|
62
|
+
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
|
|
63
|
+
/* check-magic: off */
|
|
64
|
+
ensures(array_abs_bound(r, 0, MLDSA_N, 75423753))
|
|
65
|
+
/* check-magic: on */
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
#define mld_intt_asm MLD_NAMESPACE(intt_asm)
|
|
69
|
+
void mld_intt_asm(int32_t *, const int32_t *, const int32_t *);
|
|
70
|
+
|
|
71
|
+
#define mld_rej_uniform_asm MLD_NAMESPACE(rej_uniform_asm)
|
|
72
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
73
|
+
uint64_t mld_rej_uniform_asm(int32_t *r, const uint8_t *buf, unsigned buflen,
|
|
74
|
+
const uint8_t *table);
|
|
75
|
+
|
|
76
|
+
#define mld_rej_uniform_eta2_asm MLD_NAMESPACE(rej_uniform_eta2_asm)
|
|
77
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
78
|
+
uint64_t mld_rej_uniform_eta2_asm(int32_t *r, const uint8_t *buf,
|
|
79
|
+
unsigned buflen, const uint8_t *table);
|
|
80
|
+
|
|
81
|
+
#define mld_rej_uniform_eta4_asm MLD_NAMESPACE(rej_uniform_eta4_asm)
|
|
82
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
83
|
+
uint64_t mld_rej_uniform_eta4_asm(int32_t *r, const uint8_t *buf,
|
|
84
|
+
unsigned buflen, const uint8_t *table);
|
|
85
|
+
|
|
86
|
+
#define mld_poly_decompose_32_asm MLD_NAMESPACE(poly_decompose_32_asm)
|
|
87
|
+
void mld_poly_decompose_32_asm(int32_t *a1, int32_t *a0);
|
|
88
|
+
|
|
89
|
+
#define mld_poly_decompose_88_asm MLD_NAMESPACE(poly_decompose_88_asm)
|
|
90
|
+
void mld_poly_decompose_88_asm(int32_t *a1, int32_t *a0);
|
|
91
|
+
|
|
92
|
+
#define mld_poly_caddq_asm MLD_NAMESPACE(poly_caddq_asm)
|
|
93
|
+
void mld_poly_caddq_asm(int32_t *a)
|
|
94
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
95
|
+
* in proofs/hol_light/aarch64/proofs/mldsa_poly_caddq.ml */
|
|
96
|
+
__contract__(
|
|
97
|
+
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
|
|
98
|
+
requires(array_abs_bound(a, 0, MLDSA_N, MLDSA_Q))
|
|
99
|
+
assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
|
|
100
|
+
ensures(array_bound(a, 0, MLDSA_N, 0, MLDSA_Q))
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
#define mld_poly_use_hint_32_asm MLD_NAMESPACE(poly_use_hint_32_asm)
|
|
104
|
+
void mld_poly_use_hint_32_asm(int32_t *b, const int32_t *a, const int32_t *h);
|
|
105
|
+
|
|
106
|
+
#define mld_poly_use_hint_88_asm MLD_NAMESPACE(poly_use_hint_88_asm)
|
|
107
|
+
void mld_poly_use_hint_88_asm(int32_t *b, const int32_t *a, const int32_t *h);
|
|
108
|
+
|
|
109
|
+
#define mld_poly_chknorm_asm MLD_NAMESPACE(poly_chknorm_asm)
|
|
110
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
111
|
+
int mld_poly_chknorm_asm(const int32_t *a, int32_t B)
|
|
112
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
113
|
+
* in proofs/hol_light/aarch64/proofs/mldsa_poly_chknorm.ml */
|
|
114
|
+
__contract__(
|
|
115
|
+
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
|
|
116
|
+
/* HOL Light precondition: abs(ival(x i)) < 2^31, i.e., a[i] != INT32_MIN */
|
|
117
|
+
requires(forall(k0, 0, MLDSA_N, a[k0] > INT32_MIN))
|
|
118
|
+
ensures(return_value == 0 || return_value == 1)
|
|
119
|
+
ensures((return_value == 0) == array_abs_bound(a, 0, MLDSA_N, B))
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
#define mld_polyz_unpack_17_asm MLD_NAMESPACE(polyz_unpack_17_asm)
|
|
123
|
+
void mld_polyz_unpack_17_asm(int32_t *r, const uint8_t *buf,
|
|
124
|
+
const uint8_t *indices);
|
|
125
|
+
|
|
126
|
+
#define mld_polyz_unpack_19_asm MLD_NAMESPACE(polyz_unpack_19_asm)
|
|
127
|
+
void mld_polyz_unpack_19_asm(int32_t *r, const uint8_t *buf,
|
|
128
|
+
const uint8_t *indices);
|
|
129
|
+
|
|
130
|
+
#define mld_poly_pointwise_montgomery_asm \
|
|
131
|
+
MLD_NAMESPACE(poly_pointwise_montgomery_asm)
|
|
132
|
+
void mld_poly_pointwise_montgomery_asm(int32_t *, const int32_t *,
|
|
133
|
+
const int32_t *);
|
|
134
|
+
|
|
135
|
+
#define mld_polyvecl_pointwise_acc_montgomery_l4_asm \
|
|
136
|
+
MLD_NAMESPACE(polyvecl_pointwise_acc_montgomery_l4_asm)
|
|
137
|
+
void mld_polyvecl_pointwise_acc_montgomery_l4_asm(int32_t *, const int32_t *,
|
|
138
|
+
const int32_t *);
|
|
139
|
+
|
|
140
|
+
#define mld_polyvecl_pointwise_acc_montgomery_l5_asm \
|
|
141
|
+
MLD_NAMESPACE(polyvecl_pointwise_acc_montgomery_l5_asm)
|
|
142
|
+
void mld_polyvecl_pointwise_acc_montgomery_l5_asm(int32_t *, const int32_t *,
|
|
143
|
+
const int32_t *);
|
|
144
|
+
|
|
145
|
+
#define mld_polyvecl_pointwise_acc_montgomery_l7_asm \
|
|
146
|
+
MLD_NAMESPACE(polyvecl_pointwise_acc_montgomery_l7_asm)
|
|
147
|
+
void mld_polyvecl_pointwise_acc_montgomery_l7_asm(int32_t *, const int32_t *,
|
|
148
|
+
const int32_t *);
|
|
149
|
+
|
|
150
|
+
#endif /* !MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H */
|