pq_crypto 0.6.7 → 0.6.9
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/CHANGELOG.md +20 -0
- data/README.md +1 -3
- data/ext/pqcrypto/pqcrypto_ruby_secure.c +41 -11
- data/ext/pqcrypto/pqcrypto_secure.c +501 -296
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +71 -0
- data/ext/pqcrypto/vendor/mldsa-native/README.md +26 -11
- data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +77 -150
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +93 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +74 -59
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +106 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +94 -92
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/capability.h +31 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +55 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +12 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +3 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/auto.h +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +574 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +679 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +5 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +110 -120
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +109 -101
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +97 -93
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +1 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +4 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/fastmul.h +74 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/slowmul.h +77 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/arith_native_rv32im.h +124 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_asm.S +331 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_slowmul_asm.S +381 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_asm.S +304 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_slowmul_asm.S +351 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_poly_pointwise_montgomery_rv32im_asm.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/rv32im_zetas.c +118 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +6 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +2 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +12 -16
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +14 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +23 -27
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +21 -42
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +28 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +87 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +61 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +23 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +55 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +67 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +16 -24
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +27 -21
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +8 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +191 -119
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +16 -42
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +72 -0
- data/ext/pqcrypto/vendor/mlkem-native/README.md +9 -5
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +64 -312
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -34
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +41 -13
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +89 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +50 -46
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/capability.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +4 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +15 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +23 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +11 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +7 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/auto.h +47 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +573 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +678 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +1 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +29 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +156 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +137 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/compress_d5_table.c +43 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d10_table.c +50 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d11_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d4_table.c +44 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d5_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_intt_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d10_aarch64_asm.S +439 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d11_aarch64_asm.S +452 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d4_aarch64_asm.S +106 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d5_aarch64_asm.S +124 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d10_aarch64_asm.S +108 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d11_aarch64_asm.S +116 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d4_aarch64_asm.S +93 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d5_aarch64_asm.S +104 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_frombytes_aarch64_asm.S +84 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_mulcache_compute_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_reduce_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tobytes_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tomont_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_rej_uniform_aarch64_asm.S +112 -104
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +0 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +16 -21
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_intt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_ntt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_reduce_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +5 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +5 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_intt_avx2_asm.S +36 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntt_avx2_asm.S +67 -65
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttfrombytes_avx2_asm.S +8 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntttobytes_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d10_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d11_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d4_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S +118 -115
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S +174 -171
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S +230 -227
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_reduce_avx2_asm.S +17 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_rej_uniform_avx2_asm.S +7 -6
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_tomont_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +4 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +31 -44
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +1 -1
- data/lib/pq_crypto/internal.rb +10 -0
- data/lib/pq_crypto/kem.rb +5 -10
- data/lib/pq_crypto/pkcs8/der.rb +26 -11
- data/lib/pq_crypto/pkcs8/private_key_choice.rb +21 -25
- data/lib/pq_crypto/signature.rb +28 -40
- data/lib/pq_crypto/spki.rb +36 -23
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +36 -1
data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
#include "../../../../common.h"
|
|
13
|
-
#if defined(MLK_FIPS202_X86_64_NEED_X4_AVX2)
|
|
13
|
+
#if (defined(MLK_FIPS202_X86_64_NEED_X4_AVX2) || \
|
|
14
|
+
defined(MLK_FIPS202_X86_64_NEED_X1_AVX512) || \
|
|
15
|
+
defined(MLK_FIPS202_X86_64_NEED_X4_AVX512)) && \
|
|
14
16
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
15
17
|
|
|
16
18
|
#include <stdint.h>
|
|
@@ -29,6 +31,8 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint64_t
|
|
|
29
31
|
0x8000000000008080, 0x0000000080000001, 0x8000000080008008,
|
|
30
32
|
};
|
|
31
33
|
|
|
34
|
+
#if defined(MLK_FIPS202_X86_64_NEED_X4_AVX2)
|
|
35
|
+
|
|
32
36
|
MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint64_t mlk_keccak_rho8[4] = {
|
|
33
37
|
0x0605040302010007,
|
|
34
38
|
0x0e0d0c0b0a09080f,
|
|
@@ -43,10 +47,15 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint64_t mlk_keccak_rho56[4] = {
|
|
|
43
47
|
0x181f1e1d1c1b1a19,
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
#
|
|
47
|
-
|
|
50
|
+
#endif /* MLK_FIPS202_X86_64_NEED_X4_AVX2 */
|
|
51
|
+
|
|
52
|
+
#else /* (MLK_FIPS202_X86_64_NEED_X4_AVX2 || MLK_FIPS202_X86_64_NEED_X1_AVX512 \
|
|
53
|
+
|| MLK_FIPS202_X86_64_NEED_X4_AVX512) && \
|
|
54
|
+
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
48
55
|
|
|
49
56
|
MLK_EMPTY_CU(fips202_x86_64_constants)
|
|
50
57
|
|
|
51
|
-
#endif /* !(MLK_FIPS202_X86_64_NEED_X4_AVX2
|
|
58
|
+
#endif /* !((MLK_FIPS202_X86_64_NEED_X4_AVX2 || \
|
|
59
|
+
MLK_FIPS202_X86_64_NEED_X1_AVX512 || \
|
|
60
|
+
MLK_FIPS202_X86_64_NEED_X4_AVX512) && \
|
|
52
61
|
!MLK_CONFIG_MULTILEVEL_NO_SHARED) */
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
#include "indcpa.h"
|
|
21
|
-
|
|
22
21
|
#include "debug.h"
|
|
23
22
|
#include "randombytes.h"
|
|
24
23
|
#include "sampling.h"
|
|
@@ -398,7 +397,7 @@ __contract__(
|
|
|
398
397
|
* mlk_indcpa_enc(). Uses x4-batched versions of `poly_getnoise` to leverage
|
|
399
398
|
* batched Keccak-f1600.
|
|
400
399
|
*
|
|
401
|
-
* @spec{Implements @[FIPS203, Algorithm 14 (K-PKE.Encrypt)] steps 9-
|
|
400
|
+
* @spec{Implements @[FIPS203, Algorithm 14 (K-PKE.Encrypt)] steps 9-17.}
|
|
402
401
|
*
|
|
403
402
|
* @param[out] sp Output polynomial vector.
|
|
404
403
|
* @param[out] ep Output polynomial vector.
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
#include "kem.h"
|
|
27
|
-
|
|
28
27
|
#include "indcpa.h"
|
|
29
28
|
#include "randombytes.h"
|
|
30
29
|
#include "symmetric.h"
|
|
@@ -176,7 +175,7 @@ static int mlk_check_pct(uint8_t const pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
|
176
175
|
/* Deliberately break PCT for testing purposes */
|
|
177
176
|
if (mlk_break_pct())
|
|
178
177
|
{
|
|
179
|
-
ss_enc[0]
|
|
178
|
+
ss_enc[0] ^= 0xFF;
|
|
180
179
|
}
|
|
181
180
|
#endif /* MLK_CONFIG_KEYGEN_PCT_BREAKAGE_TEST */
|
|
182
181
|
|
|
@@ -452,10 +451,13 @@ int mlk_kem_dec(uint8_t ss[MLKEM_SSBYTES],
|
|
|
452
451
|
mlk_memcpy(tmp, sk + MLKEM_INDCCA_SECRETKEYBYTES - MLKEM_SYMBYTES,
|
|
453
452
|
MLKEM_SYMBYTES);
|
|
454
453
|
mlk_memcpy(tmp + MLKEM_SYMBYTES, ct, MLKEM_INDCCA_CIPHERTEXTBYTES);
|
|
455
|
-
mlk_hash_j(
|
|
454
|
+
mlk_hash_j(buf, tmp, MLKEM_SYMBYTES + MLKEM_INDCCA_CIPHERTEXTBYTES);
|
|
455
|
+
|
|
456
|
+
/* Replace rejection key by true key if fail is 0 */
|
|
457
|
+
mlk_ct_cmov_zero(buf, kr, MLKEM_SYMBYTES, fail);
|
|
456
458
|
|
|
457
|
-
/*
|
|
458
|
-
|
|
459
|
+
/* Write the output buffer only once */
|
|
460
|
+
mlk_memcpy(ss, buf, MLKEM_SYMBYTES);
|
|
459
461
|
|
|
460
462
|
cleanup:
|
|
461
463
|
/* Specification: Partially implements
|
|
@@ -132,7 +132,16 @@ __contract__(
|
|
|
132
132
|
/**
|
|
133
133
|
* Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
|
|
134
134
|
*
|
|
135
|
-
* @spec{Implements @[FIPS203, Algorithm 16, ML-KEM.KeyGen_Internal].
|
|
135
|
+
* @spec{Implements @[FIPS203, Algorithm 16, ML-KEM.KeyGen_Internal]. When
|
|
136
|
+
* `MLK_CONFIG_KEYGEN_PCT` is enabled, also performs the encapsulation-key
|
|
137
|
+
* modulus check, decapsulation-key hash check, and pairwise consistency test
|
|
138
|
+
* described in steps 2-4 of @[FIPS203, Section 7.1, Key pair check].}
|
|
139
|
+
*
|
|
140
|
+
* @note If MLK_CONFIG_KEYGEN_PCT is enabled, the keypair is written to
|
|
141
|
+
* the output buffers before the PCT is run, and zeroized if the PCT
|
|
142
|
+
* fails. A keypair failing the PCT is thus temporarily present in
|
|
143
|
+
* the output buffers. If this is a concern, pass buffers that are
|
|
144
|
+
* not accessible to untrusted parties, and copy out upon success.
|
|
136
145
|
*
|
|
137
146
|
* @param[out] pk Output public key (an already allocated array of
|
|
138
147
|
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
@@ -177,7 +186,16 @@ __contract__(
|
|
|
177
186
|
/**
|
|
178
187
|
* Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
|
|
179
188
|
*
|
|
180
|
-
* @spec{Implements @[FIPS203, Algorithm 19, ML-KEM.KeyGen].
|
|
189
|
+
* @spec{Implements @[FIPS203, Algorithm 19, ML-KEM.KeyGen]. When
|
|
190
|
+
* `MLK_CONFIG_KEYGEN_PCT` is enabled, also performs the encapsulation-key
|
|
191
|
+
* modulus check, decapsulation-key hash check, and pairwise consistency test
|
|
192
|
+
* described in steps 2-4 of @[FIPS203, Section 7.1, Key pair check].}
|
|
193
|
+
*
|
|
194
|
+
* @note If MLK_CONFIG_KEYGEN_PCT is enabled, the keypair is written to
|
|
195
|
+
* the output buffers before the PCT is run, and zeroized if the PCT
|
|
196
|
+
* fails. A keypair failing the PCT is thus temporarily present in
|
|
197
|
+
* the output buffers. If this is a concern, pass buffers that are
|
|
198
|
+
* not accessible to untrusted parties, and copy out upon success.
|
|
181
199
|
*
|
|
182
200
|
* @param[out] pk Output public key (an already allocated array of
|
|
183
201
|
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
@@ -218,7 +236,9 @@ __contract__(
|
|
|
218
236
|
/**
|
|
219
237
|
* Generate ciphertext and shared secret for a given public key.
|
|
220
238
|
*
|
|
221
|
-
* @spec{Implements @[FIPS203, Algorithm 17, ML-KEM.Encaps_Internal]
|
|
239
|
+
* @spec{Implements @[FIPS203, Algorithm 17, ML-KEM.Encaps_Internal] and
|
|
240
|
+
* performs the encapsulation-key modulus check from
|
|
241
|
+
* @[FIPS203, Section 7.2, Encapsulation key check] before using the key.}
|
|
222
242
|
*
|
|
223
243
|
* @param[out] ct Output ciphertext (an already allocated array of
|
|
224
244
|
* MLKEM_INDCCA_CIPHERTEXTBYTES bytes).
|
|
@@ -266,7 +286,9 @@ __contract__(
|
|
|
266
286
|
/**
|
|
267
287
|
* Generate ciphertext and shared secret for a given public key.
|
|
268
288
|
*
|
|
269
|
-
* @spec{Implements @[FIPS203, Algorithm 20, ML-KEM.Encaps]
|
|
289
|
+
* @spec{Implements @[FIPS203, Algorithm 20, ML-KEM.Encaps] and performs the
|
|
290
|
+
* encapsulation-key modulus check from
|
|
291
|
+
* @[FIPS203, Section 7.2, Encapsulation key check] before using the key.}
|
|
270
292
|
*
|
|
271
293
|
* @param[out] ct Output ciphertext (an already allocated array of
|
|
272
294
|
* MLKEM_INDCCA_CIPHERTEXTBYTES bytes).
|
|
@@ -312,7 +334,9 @@ __contract__(
|
|
|
312
334
|
/**
|
|
313
335
|
* Generate shared secret for a given ciphertext and private key.
|
|
314
336
|
*
|
|
315
|
-
* @spec{Implements @[FIPS203, Algorithm 21, ML-KEM.Decaps]
|
|
337
|
+
* @spec{Implements @[FIPS203, Algorithm 21, ML-KEM.Decaps] and performs the
|
|
338
|
+
* decapsulation-key hash check from
|
|
339
|
+
* @[FIPS203, Section 7.3, Decapsulation key check] before using the key.}
|
|
316
340
|
*
|
|
317
341
|
* @param[out] ss Output shared secret (an already allocated array of
|
|
318
342
|
* MLKEM_SSBYTES bytes).
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
#define MLK_USE_NATIVE_POLY_MULCACHE_COMPUTE
|
|
15
15
|
#define MLK_USE_NATIVE_POLYVEC_BASEMUL_ACC_MONTGOMERY_CACHED
|
|
16
16
|
#define MLK_USE_NATIVE_POLY_TOBYTES
|
|
17
|
+
#define MLK_USE_NATIVE_POLY_FROMBYTES
|
|
18
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D4
|
|
19
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D5
|
|
20
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D10
|
|
21
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D11
|
|
22
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D4
|
|
23
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D5
|
|
24
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D10
|
|
25
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D11
|
|
17
26
|
#define MLK_USE_NATIVE_REJ_UNIFORM
|
|
18
27
|
|
|
19
28
|
/* Identifier for this backend so that source and assembly files
|
|
@@ -148,6 +157,153 @@ static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
|
|
|
148
157
|
}
|
|
149
158
|
#endif /* !MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API */
|
|
150
159
|
|
|
160
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
161
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
162
|
+
static MLK_INLINE int mlk_poly_frombytes_native(
|
|
163
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYBYTES])
|
|
164
|
+
{
|
|
165
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
166
|
+
{
|
|
167
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
168
|
+
}
|
|
169
|
+
mlk_poly_frombytes_aarch64_asm(r, a);
|
|
170
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
171
|
+
}
|
|
172
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
173
|
+
|
|
174
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
175
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
176
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
177
|
+
MLKEM_K == 3)
|
|
178
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
179
|
+
static MLK_INLINE int mlk_poly_compress_d4_native(
|
|
180
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4], const int16_t a[MLKEM_N])
|
|
181
|
+
{
|
|
182
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
183
|
+
{
|
|
184
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
185
|
+
}
|
|
186
|
+
mlk_poly_compress_d4_aarch64_asm(r, a);
|
|
187
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
188
|
+
}
|
|
189
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
190
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3) \
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
194
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
195
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
196
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
197
|
+
static MLK_INLINE int mlk_poly_compress_d5_native(
|
|
198
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5], const int16_t a[MLKEM_N])
|
|
199
|
+
{
|
|
200
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
201
|
+
{
|
|
202
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
203
|
+
}
|
|
204
|
+
mlk_poly_compress_d5_aarch64_asm(r, a, mlk_aarch64_compress_d5_table);
|
|
205
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
206
|
+
}
|
|
207
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
208
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
|
|
209
|
+
|
|
210
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
211
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
212
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
213
|
+
MLKEM_K == 3)
|
|
214
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
215
|
+
static MLK_INLINE int mlk_poly_compress_d10_native(
|
|
216
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D10], const int16_t a[MLKEM_N])
|
|
217
|
+
{
|
|
218
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
219
|
+
{
|
|
220
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
221
|
+
}
|
|
222
|
+
mlk_poly_compress_d10_aarch64_asm(r, a);
|
|
223
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
224
|
+
}
|
|
225
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
226
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3) \
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
230
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
231
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
232
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
233
|
+
static MLK_INLINE int mlk_poly_compress_d11_native(
|
|
234
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D11], const int16_t a[MLKEM_N])
|
|
235
|
+
{
|
|
236
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
237
|
+
{
|
|
238
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
239
|
+
}
|
|
240
|
+
mlk_poly_compress_d11_aarch64_asm(r, a);
|
|
241
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
242
|
+
}
|
|
243
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
244
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
|
|
245
|
+
|
|
246
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API) && \
|
|
247
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
248
|
+
MLKEM_K == 3)
|
|
249
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
250
|
+
static MLK_INLINE int mlk_poly_decompress_d4_native(
|
|
251
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4])
|
|
252
|
+
{
|
|
253
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
254
|
+
{
|
|
255
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
256
|
+
}
|
|
257
|
+
mlk_poly_decompress_d4_aarch64_asm(r, a, mlk_aarch64_decompress_d4_table);
|
|
258
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
262
|
+
static MLK_INLINE int mlk_poly_decompress_d10_native(
|
|
263
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D10])
|
|
264
|
+
{
|
|
265
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
266
|
+
{
|
|
267
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
268
|
+
}
|
|
269
|
+
mlk_poly_decompress_d10_aarch64_asm(r, a, mlk_aarch64_decompress_d10_table);
|
|
270
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
271
|
+
}
|
|
272
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
273
|
+
MLKEM_K == 2 || MLKEM_K == 3) */
|
|
274
|
+
|
|
275
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API) && \
|
|
276
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
277
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
278
|
+
static MLK_INLINE int mlk_poly_decompress_d5_native(
|
|
279
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5])
|
|
280
|
+
{
|
|
281
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
282
|
+
{
|
|
283
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
284
|
+
}
|
|
285
|
+
mlk_poly_decompress_d5_aarch64_asm(r, a, mlk_aarch64_decompress_d5_table);
|
|
286
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
287
|
+
}
|
|
288
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
289
|
+
MLKEM_K == 4) */
|
|
290
|
+
|
|
291
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API) && \
|
|
292
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
293
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
294
|
+
static MLK_INLINE int mlk_poly_decompress_d11_native(
|
|
295
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D11])
|
|
296
|
+
{
|
|
297
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
298
|
+
{
|
|
299
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
300
|
+
}
|
|
301
|
+
mlk_poly_decompress_d11_aarch64_asm(r, a, mlk_aarch64_decompress_d11_table);
|
|
302
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
303
|
+
}
|
|
304
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
305
|
+
MLKEM_K == 4) */
|
|
306
|
+
|
|
151
307
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
152
308
|
static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
|
|
153
309
|
const uint8_t *buf,
|
|
@@ -20,6 +20,15 @@
|
|
|
20
20
|
#define mlk_aarch64_zetas_mulcache_twisted_native \
|
|
21
21
|
MLK_NAMESPACE(aarch64_zetas_mulcache_twisted_native)
|
|
22
22
|
#define mlk_rej_uniform_table MLK_NAMESPACE(rej_uniform_table)
|
|
23
|
+
#define mlk_aarch64_decompress_d4_table \
|
|
24
|
+
MLK_NAMESPACE(aarch64_decompress_d4_table)
|
|
25
|
+
#define mlk_aarch64_decompress_d5_table \
|
|
26
|
+
MLK_NAMESPACE(aarch64_decompress_d5_table)
|
|
27
|
+
#define mlk_aarch64_decompress_d10_table \
|
|
28
|
+
MLK_NAMESPACE(aarch64_decompress_d10_table)
|
|
29
|
+
#define mlk_aarch64_decompress_d11_table \
|
|
30
|
+
MLK_NAMESPACE(aarch64_decompress_d11_table)
|
|
31
|
+
#define mlk_aarch64_compress_d5_table MLK_NAMESPACE(aarch64_compress_d5_table)
|
|
23
32
|
|
|
24
33
|
MLK_INTERNAL_DATA_DECLARATION const int16_t
|
|
25
34
|
mlk_aarch64_ntt_zetas_layer12345[80];
|
|
@@ -33,6 +42,14 @@ MLK_INTERNAL_DATA_DECLARATION const int16_t
|
|
|
33
42
|
MLK_INTERNAL_DATA_DECLARATION const int16_t
|
|
34
43
|
mlk_aarch64_zetas_mulcache_twisted_native[128];
|
|
35
44
|
MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_rej_uniform_table[4096];
|
|
45
|
+
MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_aarch64_decompress_d4_table[32];
|
|
46
|
+
MLK_INTERNAL_DATA_DECLARATION const uint8_t
|
|
47
|
+
mlk_aarch64_decompress_d5_table[112];
|
|
48
|
+
MLK_INTERNAL_DATA_DECLARATION const uint8_t
|
|
49
|
+
mlk_aarch64_decompress_d10_table[80];
|
|
50
|
+
MLK_INTERNAL_DATA_DECLARATION const uint8_t
|
|
51
|
+
mlk_aarch64_decompress_d11_table[112];
|
|
52
|
+
MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_aarch64_compress_d5_table[32];
|
|
36
53
|
|
|
37
54
|
#define mlk_ntt_aarch64_asm MLK_NAMESPACE(ntt_aarch64_asm)
|
|
38
55
|
void mlk_ntt_aarch64_asm(int16_t p[256], const int16_t twiddles12345[80],
|
|
@@ -41,12 +58,12 @@ void mlk_ntt_aarch64_asm(int16_t p[256], const int16_t twiddles12345[80],
|
|
|
41
58
|
* in proofs/hol_light/aarch64/proofs/mlkem_ntt_aarch64_asm.ml */
|
|
42
59
|
__contract__(
|
|
43
60
|
requires(memory_no_alias(p, sizeof(int16_t) * MLKEM_N))
|
|
44
|
-
requires(array_abs_bound(p, 0, MLKEM_N,
|
|
61
|
+
requires(array_abs_bound(p, 0, MLKEM_N, MLKEM_Q))
|
|
45
62
|
requires(twiddles12345 == mlk_aarch64_ntt_zetas_layer12345)
|
|
46
63
|
requires(twiddles56 == mlk_aarch64_ntt_zetas_layer67)
|
|
47
64
|
assigns(memory_slice(p, sizeof(int16_t) * MLKEM_N))
|
|
48
65
|
/* check-magic: off */
|
|
49
|
-
ensures(array_abs_bound(p, 0, MLKEM_N,
|
|
66
|
+
ensures(array_abs_bound(p, 0, MLKEM_N, 17390))
|
|
50
67
|
/* check-magic: on */
|
|
51
68
|
);
|
|
52
69
|
|
|
@@ -114,6 +131,123 @@ __contract__(
|
|
|
114
131
|
assigns(memory_slice(r, MLKEM_POLYBYTES))
|
|
115
132
|
);
|
|
116
133
|
|
|
134
|
+
#define mlk_poly_frombytes_aarch64_asm MLK_NAMESPACE(poly_frombytes_aarch64_asm)
|
|
135
|
+
void mlk_poly_frombytes_aarch64_asm(int16_t r[256], const uint8_t a[384])
|
|
136
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
137
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_frombytes_aarch64_asm.ml */
|
|
138
|
+
__contract__(
|
|
139
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
140
|
+
requires(memory_no_alias(a, MLKEM_POLYBYTES))
|
|
141
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
142
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT))
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
#define mlk_poly_compress_d4_aarch64_asm \
|
|
146
|
+
MLK_NAMESPACE(poly_compress_d4_aarch64_asm)
|
|
147
|
+
void mlk_poly_compress_d4_aarch64_asm(uint8_t r[128], const int16_t a[256])
|
|
148
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
149
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_compress_d4_aarch64_asm.ml */
|
|
150
|
+
__contract__(
|
|
151
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D4))
|
|
152
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
153
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
154
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D4))
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
#define mlk_poly_compress_d5_aarch64_asm \
|
|
158
|
+
MLK_NAMESPACE(poly_compress_d5_aarch64_asm)
|
|
159
|
+
void mlk_poly_compress_d5_aarch64_asm(uint8_t r[160], const int16_t a[256],
|
|
160
|
+
const uint8_t table[32])
|
|
161
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
162
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_compress_d5_aarch64_asm.ml */
|
|
163
|
+
__contract__(
|
|
164
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D5))
|
|
165
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
166
|
+
requires(table == mlk_aarch64_compress_d5_table)
|
|
167
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
168
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D5))
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
#define mlk_poly_compress_d10_aarch64_asm \
|
|
172
|
+
MLK_NAMESPACE(poly_compress_d10_aarch64_asm)
|
|
173
|
+
void mlk_poly_compress_d10_aarch64_asm(uint8_t r[320], const int16_t a[256])
|
|
174
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
175
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_compress_d10_aarch64_asm.ml */
|
|
176
|
+
__contract__(
|
|
177
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D10))
|
|
178
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
179
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
180
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D10))
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
#define mlk_poly_compress_d11_aarch64_asm \
|
|
184
|
+
MLK_NAMESPACE(poly_compress_d11_aarch64_asm)
|
|
185
|
+
void mlk_poly_compress_d11_aarch64_asm(uint8_t r[352], const int16_t a[256])
|
|
186
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
187
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_compress_d11_aarch64_asm.ml */
|
|
188
|
+
__contract__(
|
|
189
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D11))
|
|
190
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
191
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
192
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D11))
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
#define mlk_poly_decompress_d4_aarch64_asm \
|
|
196
|
+
MLK_NAMESPACE(poly_decompress_d4_aarch64_asm)
|
|
197
|
+
void mlk_poly_decompress_d4_aarch64_asm(int16_t r[256], const uint8_t a[128],
|
|
198
|
+
const uint8_t table[32])
|
|
199
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
200
|
+
* proofs/hol_light/aarch64/proofs/mlkem_poly_decompress_d4_aarch64_asm.ml */
|
|
201
|
+
__contract__(
|
|
202
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
203
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D4))
|
|
204
|
+
requires(table == mlk_aarch64_decompress_d4_table)
|
|
205
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
206
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
#define mlk_poly_decompress_d5_aarch64_asm \
|
|
210
|
+
MLK_NAMESPACE(poly_decompress_d5_aarch64_asm)
|
|
211
|
+
void mlk_poly_decompress_d5_aarch64_asm(int16_t r[256], const uint8_t a[160],
|
|
212
|
+
const uint8_t table[112])
|
|
213
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
214
|
+
* proofs/hol_light/aarch64/proofs/mlkem_poly_decompress_d5_aarch64_asm.ml */
|
|
215
|
+
__contract__(
|
|
216
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
217
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D5))
|
|
218
|
+
requires(table == mlk_aarch64_decompress_d5_table)
|
|
219
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
220
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
#define mlk_poly_decompress_d10_aarch64_asm \
|
|
224
|
+
MLK_NAMESPACE(poly_decompress_d10_aarch64_asm)
|
|
225
|
+
void mlk_poly_decompress_d10_aarch64_asm(int16_t r[256], const uint8_t a[320],
|
|
226
|
+
const uint8_t table[80])
|
|
227
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
228
|
+
* proofs/hol_light/aarch64/proofs/mlkem_poly_decompress_d10_aarch64_asm.ml */
|
|
229
|
+
__contract__(
|
|
230
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
231
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D10))
|
|
232
|
+
requires(table == mlk_aarch64_decompress_d10_table)
|
|
233
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
234
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
#define mlk_poly_decompress_d11_aarch64_asm \
|
|
238
|
+
MLK_NAMESPACE(poly_decompress_d11_aarch64_asm)
|
|
239
|
+
void mlk_poly_decompress_d11_aarch64_asm(int16_t r[256], const uint8_t a[352],
|
|
240
|
+
const uint8_t table[112])
|
|
241
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
242
|
+
* proofs/hol_light/aarch64/proofs/mlkem_poly_decompress_d11_aarch64_asm.ml */
|
|
243
|
+
__contract__(
|
|
244
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
245
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D11))
|
|
246
|
+
requires(table == mlk_aarch64_decompress_d11_table)
|
|
247
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
248
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
249
|
+
);
|
|
250
|
+
|
|
117
251
|
#define mlk_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm \
|
|
118
252
|
MLK_NAMESPACE(polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm)
|
|
119
253
|
void mlk_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm(
|
|
@@ -168,7 +302,7 @@ __contract__(
|
|
|
168
302
|
#define mlk_rej_uniform_aarch64_asm MLK_NAMESPACE(rej_uniform_aarch64_asm)
|
|
169
303
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
170
304
|
uint64_t mlk_rej_uniform_aarch64_asm(int16_t r[256], const uint8_t *buf,
|
|
171
|
-
|
|
305
|
+
uint64_t buflen, const uint8_t table[4096])
|
|
172
306
|
/* This must be kept in sync with the HOL-Light specification
|
|
173
307
|
* in proofs/hol_light/aarch64/proofs/mlkem_rej_uniform_aarch64_asm.ml. */
|
|
174
308
|
__contract__(
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-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 mlkem-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "../../../common.h"
|
|
13
|
+
|
|
14
|
+
#if defined(MLK_ARITH_BACKEND_AARCH64) && \
|
|
15
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
|
|
16
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
17
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
18
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
19
|
+
|
|
20
|
+
#include "arith_native_aarch64.h"
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Constant vectors used by poly_compress_d5_aarch64_asm:
|
|
24
|
+
* SQRDMULH multiplier (row 0) and TBL indices (row 1).
|
|
25
|
+
* See autogen for details.
|
|
26
|
+
*/
|
|
27
|
+
MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
|
|
28
|
+
mlk_aarch64_compress_d5_table[32] = {
|
|
29
|
+
0x3b, 0x01, 0x3b, 0x01, 0x3b, 0x01, 0x3b, 0x01, 0x3b,
|
|
30
|
+
0x01, 0x3b, 0x01, 0x3b, 0x01, 0x3b, 0x01, /* mult (16-bit lanes) */
|
|
31
|
+
0x00, 0x01, 0x02, 0x03, 0x04, 0x08, 0x09, 0x0a, 0x0b,
|
|
32
|
+
0x0c, 0x04, 0x08, 0x09, 0x0a, 0x0b, 0x0c, /* idx */
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
#else /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
36
|
+
(!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
37
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
|
|
38
|
+
|
|
39
|
+
MLK_EMPTY_CU(aarch64_compress_d5_table)
|
|
40
|
+
|
|
41
|
+
#endif /* !(MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
42
|
+
(!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
43
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4)) */
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-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 mlkem-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "../../../common.h"
|
|
13
|
+
|
|
14
|
+
#if defined(MLK_ARITH_BACKEND_AARCH64) && \
|
|
15
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
|
|
16
|
+
!defined(MLK_CONFIG_NO_DECAPS_API) && \
|
|
17
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
18
|
+
MLKEM_K == 3)
|
|
19
|
+
|
|
20
|
+
#include "arith_native_aarch64.h"
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Constant vectors used by poly_decompress_d10_aarch64_asm:
|
|
24
|
+
* TBL indices for groups starting at bytes 0 and 6 (rows 0, 1),
|
|
25
|
+
* USHL shift amounts (row 2), AND mask (row 3) and SQRDMULH
|
|
26
|
+
* multiplier (row 4). See autogen for details.
|
|
27
|
+
*/
|
|
28
|
+
MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
|
|
29
|
+
mlk_aarch64_decompress_d10_table[80] = {
|
|
30
|
+
0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x05,
|
|
31
|
+
0x06, 0x06, 0x07, 0x07, 0x08, 0x08, 0x09, /* idx0 */
|
|
32
|
+
0x06, 0x07, 0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0b,
|
|
33
|
+
0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, /* idx6 */
|
|
34
|
+
0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfc, 0xff, 0x02,
|
|
35
|
+
0x00, 0x00, 0x00, 0xfe, 0xff, 0xfc, 0xff, /* shifts (16-bit lanes) */
|
|
36
|
+
0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc,
|
|
37
|
+
0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, /* mask (16-bit lanes) */
|
|
38
|
+
0x08, 0x68, 0x08, 0x68, 0x08, 0x68, 0x08, 0x68, 0x08,
|
|
39
|
+
0x68, 0x08, 0x68, 0x08, 0x68, 0x08, 0x68, /* mult (16-bit lanes) */
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
#else /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
43
|
+
!MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
44
|
+
MLKEM_K == 2 || MLKEM_K == 3) */
|
|
45
|
+
|
|
46
|
+
MLK_EMPTY_CU(aarch64_decompress_d10_table)
|
|
47
|
+
|
|
48
|
+
#endif /* !(MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
49
|
+
!MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
50
|
+
MLKEM_K == 2 || MLKEM_K == 3)) */
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-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 mlkem-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "../../../common.h"
|
|
13
|
+
|
|
14
|
+
#if defined(MLK_ARITH_BACKEND_AARCH64) && \
|
|
15
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
|
|
16
|
+
!defined(MLK_CONFIG_NO_DECAPS_API) && \
|
|
17
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
18
|
+
|
|
19
|
+
#include "arith_native_aarch64.h"
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Constant vectors used by poly_decompress_d11_aarch64_asm:
|
|
23
|
+
* TBL indices idx_lo, idx_hi, idx_lo + 5 and idx_hi + 5 (rows
|
|
24
|
+
* 0..3), USHL shift amounts (row 4), AND mask (row 5) and
|
|
25
|
+
* SQRDMULH multiplier (row 6). See autogen for details.
|
|
26
|
+
*/
|
|
27
|
+
MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
|
|
28
|
+
mlk_aarch64_decompress_d11_table[112] = {
|
|
29
|
+
0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05,
|
|
30
|
+
0x06, 0x06, 0x07, 0x08, 0x09, 0x09, 0x0a, /* idx_lo */
|
|
31
|
+
0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07,
|
|
32
|
+
0x08, 0x08, 0x09, 0x0a, 0x0b, 0x0b, 0x0c, /* idx_hi */
|
|
33
|
+
0x05, 0x06, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0a,
|
|
34
|
+
0x0b, 0x0b, 0x0c, 0x0d, 0x0e, 0x0e, 0x0f, /* idx_lo5 */
|
|
35
|
+
0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0c,
|
|
36
|
+
0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, /* idx_hi5 */
|
|
37
|
+
0x01, 0x00, 0xfe, 0xff, 0xfc, 0xff, 0x00, 0x00, 0xfd,
|
|
38
|
+
0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, /* shifts (16-bit lanes) */
|
|
39
|
+
0xfe, 0x0f, 0xfe, 0x0f, 0xfc, 0x1f, 0xfe, 0x0f, 0xfe,
|
|
40
|
+
0x0f, 0xf8, 0x3f, 0xfe, 0x0f, 0xfe, 0x0f, /* mask (16-bit lanes) */
|
|
41
|
+
0x08, 0x68, 0x08, 0x68, 0x04, 0x34, 0x08, 0x68, 0x08,
|
|
42
|
+
0x68, 0x02, 0x1a, 0x08, 0x68, 0x08, 0x68, /* mult (16-bit lanes) */
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
#else /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
46
|
+
!MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
47
|
+
MLKEM_K == 4) */
|
|
48
|
+
|
|
49
|
+
MLK_EMPTY_CU(aarch64_decompress_d11_table)
|
|
50
|
+
|
|
51
|
+
#endif /* !(MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
52
|
+
!MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
|
|
53
|
+
MLKEM_K == 4)) */
|