pq_crypto 0.6.4 → 0.6.6
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 +180 -0
- data/README.md +7 -0
- data/ext/pqcrypto/extconf.rb +4 -1
- data/ext/pqcrypto/pq_externalmu.c +35 -0
- data/ext/pqcrypto/pqcrypto_native_api.h +85 -75
- data/ext/pqcrypto/pqcrypto_ruby_secure.c +16 -9
- data/ext/pqcrypto/pqcrypto_secure.c +43 -33
- data/ext/pqcrypto/pqcrypto_secure.h +52 -47
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +5 -2
- data/ext/pqcrypto/vendor/mldsa-native/LICENSE +21 -2
- data/ext/pqcrypto/vendor/mldsa-native/README.md +20 -7
- data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +160 -0
- data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +2 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +85 -59
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +292 -348
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +122 -76
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +184 -86
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +49 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +49 -81
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +152 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +25 -12
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +2 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +2 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +2 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +9 -11
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +19 -11
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +7 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +7 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +12 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +12 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +3 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +3 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +11 -11
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +9 -22
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +5 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +62 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +87 -54
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{intt_aarch64_asm.S → mldsa_intt_aarch64_asm.S} +39 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{ntt_aarch64_asm.S → mldsa_ntt_aarch64_asm.S} +39 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{pointwise_montgomery_aarch64_asm.S → mldsa_pointwise_montgomery_aarch64_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_caddq_aarch64_asm.S → mldsa_poly_caddq_aarch64_asm.S} +19 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_chknorm_aarch64_asm.S → mldsa_poly_chknorm_aarch64_asm.S} +24 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_32_aarch64_asm.S → mldsa_poly_decompose_32_aarch64_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_88_aarch64_asm.S → mldsa_poly_decompose_88_aarch64_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_32_aarch64_asm.S → mldsa_poly_use_hint_32_aarch64_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_88_aarch64_asm.S → mldsa_poly_use_hint_88_aarch64_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S} +31 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S} +31 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S} +31 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_17_aarch64_asm.S → mldsa_polyz_unpack_17_aarch64_asm.S} +31 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_19_aarch64_asm.S → mldsa_polyz_unpack_19_aarch64_asm.S} +31 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mldsa_rej_uniform_aarch64_asm.S} +48 -15
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta2_aarch64_asm.S → mldsa_rej_uniform_eta2_aarch64_asm.S} +42 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta4_aarch64_asm.S → mldsa_rej_uniform_eta4_aarch64_asm.S} +42 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +11 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +3 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +28 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +171 -49
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{intt_avx2_asm.S → mldsa_intt_avx2_asm.S} +23 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{ntt_avx2_asm.S → mldsa_ntt_avx2_asm.S} +23 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{nttunpack_avx2_asm.S → mldsa_nttunpack_avx2_asm.S} +17 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l4_avx2_asm.S → mldsa_pointwise_acc_l4_avx2_asm.S} +37 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l5_avx2_asm.S → mldsa_pointwise_acc_l5_avx2_asm.S} +37 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l7_avx2_asm.S → mldsa_pointwise_acc_l7_avx2_asm.S} +37 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_avx2_asm.S → mldsa_pointwise_avx2_asm.S} +31 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{poly_caddq_avx2_asm.S → mldsa_poly_caddq_avx2_asm.S} +18 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +27 -36
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +42 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +93 -17
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +74 -15
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +97 -11
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +7 -38
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +49 -7
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +16 -17
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +26 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +3 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +18 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +15 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +28 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +311 -246
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +245 -240
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +64 -5
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/LICENSE +21 -3
- data/ext/pqcrypto/vendor/mlkem-native/README.md +4 -6
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +211 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +25 -34
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +79 -142
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +62 -71
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +77 -39
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +48 -34
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +51 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +3 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +3 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +11 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +8 -22
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +20 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +39 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +64 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_aarch64_asm.S → mlkem_poly_mulcache_compute_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +45 -25
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10_avx2_asm.S → mlkem_poly_compress_d10_avx2_asm.S} +34 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11_avx2_asm.S → mlkem_poly_compress_d11_avx2_asm.S} +33 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4_avx2_asm.S → mlkem_poly_compress_d4_avx2_asm.S} +34 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5_avx2_asm.S → mlkem_poly_compress_d5_avx2_asm.S} +33 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10_avx2_asm.S → mlkem_poly_decompress_d10_avx2_asm.S} +32 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11_avx2_asm.S → mlkem_poly_decompress_d11_avx2_asm.S} +32 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4_avx2_asm.S → mlkem_poly_decompress_d4_avx2_asm.S} +32 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5_avx2_asm.S → mlkem_poly_decompress_d5_avx2_asm.S} +32 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_mulcache_compute_avx2_asm.S → mlkem_poly_mulcache_compute_avx2_asm.S} +29 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +35 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +35 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +35 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_avx2_asm.S → mlkem_rej_uniform_avx2_asm.S} +40 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +21 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +11 -10
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +79 -79
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +0 -52
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +0 -157
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +0 -157
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +0 -103
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +0 -105
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +0 -94
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +0 -96
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +0 -126
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +0 -157
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +0 -141
|
@@ -24,38 +24,44 @@
|
|
|
24
24
|
/*
|
|
25
25
|
* Keccak-f1600
|
|
26
26
|
*
|
|
27
|
-
* - On Arm-based Apple CPUs,
|
|
27
|
+
* - On Arm-based Apple CPUs, or if MLK_SYS_AARCH64_FAST_SHA3 is set,
|
|
28
|
+
* we pick a pure Neon implementation.
|
|
28
29
|
* - Otherwise, unless MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER is set,
|
|
29
30
|
* we use lazy-rotation scalar assembly from @[HYBRID].
|
|
30
31
|
* - Otherwise, if MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER is set, we
|
|
31
32
|
* fall back to the standard C implementation.
|
|
32
33
|
*/
|
|
33
|
-
#if defined(__ARM_FEATURE_SHA3) &&
|
|
34
|
+
#if defined(__ARM_FEATURE_SHA3) && \
|
|
35
|
+
(defined(__APPLE__) || defined(MLK_SYS_AARCH64_FAST_SHA3))
|
|
34
36
|
#include "x1_v84a.h"
|
|
35
37
|
#elif !defined(MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER)
|
|
36
38
|
#include "x1_scalar.h"
|
|
37
39
|
#endif
|
|
38
40
|
|
|
41
|
+
/* Batched, SIMD-based Keccak-f1600 implementations. */
|
|
42
|
+
#if defined(MLK_SYS_AARCH64_NEON)
|
|
43
|
+
|
|
39
44
|
/*
|
|
40
45
|
* Keccak-f1600x2/x4
|
|
41
46
|
*
|
|
42
47
|
* The optimal implementation is highly CPU-specific; see @[HYBRID].
|
|
43
48
|
*
|
|
44
49
|
* For now, if v8.4-A is not implemented, we fall back to Keccak-f1600.
|
|
45
|
-
* If v8.4-A is implemented and we are on an Apple CPU
|
|
46
|
-
* Neon-based
|
|
47
|
-
*
|
|
48
|
-
* scalar/Neon/Neon hybrid.
|
|
49
|
-
* The reason for this distinction is that Apple CPUs
|
|
50
|
-
* the SHA3 instructions on all SIMD
|
|
51
|
-
* don't, and ordinary Neon
|
|
50
|
+
* If v8.4-A is implemented and we are on an Apple CPU or
|
|
51
|
+
* MLK_SYS_AARCH64_FAST_SHA3 is set, we use a plain Neon-based
|
|
52
|
+
* implementation.
|
|
53
|
+
* Otherwise, if v8.4-A is implemented, we use a scalar/Neon/Neon hybrid.
|
|
54
|
+
* The reason for this distinction is that Apple CPUs (and CPUs flagged with
|
|
55
|
+
* MLK_SYS_AARCH64_FAST_SHA3) implement the SHA3 instructions on all SIMD
|
|
56
|
+
* units, while Arm CPUs prior to Cortex-X4 don't, and ordinary Neon
|
|
57
|
+
* instructions are still needed.
|
|
52
58
|
*/
|
|
53
59
|
#if defined(__ARM_FEATURE_SHA3)
|
|
54
60
|
/*
|
|
55
|
-
* For Apple-M cores
|
|
56
|
-
* instructions only.
|
|
61
|
+
* For Apple-M cores (and CPUs flagged with MLK_SYS_AARCH64_FAST_SHA3), we
|
|
62
|
+
* use a plain implementation leveraging SHA3 instructions only.
|
|
57
63
|
*/
|
|
58
|
-
#if defined(__APPLE__)
|
|
64
|
+
#if defined(__APPLE__) || defined(MLK_SYS_AARCH64_FAST_SHA3)
|
|
59
65
|
#include "x2_v84a.h"
|
|
60
66
|
#else
|
|
61
67
|
#include "x4_v8a_v84a_scalar.h"
|
|
@@ -67,4 +73,6 @@
|
|
|
67
73
|
|
|
68
74
|
#endif /* !__ARM_FEATURE_SHA3 */
|
|
69
75
|
|
|
76
|
+
#endif /* MLK_SYS_AARCH64_NEON */
|
|
77
|
+
|
|
70
78
|
#endif /* !MLK_FIPS202_NATIVE_AARCH64_AUTO_H */
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
Description: AArch64 scalar implementation of Keccak-f[1600] permutation for single state
|
|
14
14
|
Signature: void mlk_keccak_f1600_x1_scalar_aarch64_asm(uint64_t state[25], const uint64_t rc[24])
|
|
15
15
|
ABI:
|
|
16
|
+
Architecture: aarch64
|
|
17
|
+
CallingConvention: AAPCS64
|
|
16
18
|
x0:
|
|
17
19
|
type: buffer
|
|
18
20
|
size_bytes: 200
|
|
@@ -66,7 +68,7 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x1_scalar_aarch64_asm)
|
|
|
66
68
|
.cfi_rel_offset x29, 0x70
|
|
67
69
|
.cfi_rel_offset x30, 0x78
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
Lmlk_keccak_f1600_x1_scalar_initial:
|
|
70
72
|
mov x26, x1
|
|
71
73
|
str x1, [sp, #0x8]
|
|
72
74
|
ldp x1, x6, [x0]
|
|
@@ -191,7 +193,7 @@ Lkeccak_f1600_x1_scalar_initial:
|
|
|
191
193
|
eor x14, x26, x6, ror #46
|
|
192
194
|
eor x6, x27, x29, ror #41
|
|
193
195
|
|
|
194
|
-
|
|
196
|
+
Lmlk_keccak_f1600_x1_scalar_loop:
|
|
195
197
|
eor x0, x15, x11, ror #52
|
|
196
198
|
eor x0, x0, x13, ror #48
|
|
197
199
|
eor x26, x8, x9, ror #57
|
|
@@ -304,7 +306,7 @@ Lkeccak_f1600_x1_scalar_loop:
|
|
|
304
306
|
bic x3, x0, x30, ror #5
|
|
305
307
|
eor x23, x3, x26, ror #52
|
|
306
308
|
eor x3, x29, x30, ror #24
|
|
307
|
-
b.le
|
|
309
|
+
b.le Lmlk_keccak_f1600_x1_scalar_loop
|
|
308
310
|
ror x6, x6, #0x2b
|
|
309
311
|
ror x11, x11, #0x32
|
|
310
312
|
ror x21, x21, #0x14
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
Description: AArch64 ARMv8.4-A implementation of Keccak-f[1600] permutation for single state
|
|
20
20
|
Signature: void mlk_keccak_f1600_x1_v84a_aarch64_asm(uint64_t state[25], const uint64_t rc[24])
|
|
21
21
|
ABI:
|
|
22
|
+
Architecture: aarch64
|
|
23
|
+
CallingConvention: AAPCS64
|
|
24
|
+
Features: [NEON, SHA3]
|
|
22
25
|
x0:
|
|
23
26
|
type: buffer
|
|
24
27
|
size_bytes: 200
|
|
@@ -91,7 +94,7 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x1_v84a_aarch64_asm)
|
|
|
91
94
|
ldr d24, [x0, #0xc0]
|
|
92
95
|
mov x2, #0x18 // =24
|
|
93
96
|
|
|
94
|
-
|
|
97
|
+
Lmlk_keccak_f1600_x1_v84a_loop:
|
|
95
98
|
eor3 v30.16b, v0.16b, v5.16b, v10.16b
|
|
96
99
|
eor3 v29.16b, v1.16b, v6.16b, v11.16b
|
|
97
100
|
eor3 v28.16b, v2.16b, v7.16b, v12.16b
|
|
@@ -160,7 +163,7 @@ Lkeccak_f1600_x1_v84a_loop:
|
|
|
160
163
|
bcax v4.16b, v4.16b, v27.16b, v30.16b
|
|
161
164
|
eor v0.16b, v0.16b, v31.16b
|
|
162
165
|
sub x2, x2, #0x1
|
|
163
|
-
cbnz x2,
|
|
166
|
+
cbnz x2, Lmlk_keccak_f1600_x1_v84a_loop
|
|
164
167
|
stp d0, d1, [x0]
|
|
165
168
|
stp d2, d3, [x0, #0x10]
|
|
166
169
|
stp d4, d5, [x0, #0x20]
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
Description: AArch64 ARMv8.4-A implementation of Keccak-f[1600] permutation for two sequential states
|
|
20
20
|
Signature: void mlk_keccak_f1600_x2_v84a_aarch64_asm(uint64_t state[50], const uint64_t rc[24])
|
|
21
21
|
ABI:
|
|
22
|
+
Architecture: aarch64
|
|
23
|
+
CallingConvention: AAPCS64
|
|
24
|
+
Features: [NEON, SHA3]
|
|
22
25
|
x0:
|
|
23
26
|
type: buffer
|
|
24
27
|
size_bytes: 400
|
|
@@ -118,7 +121,7 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x2_v84a_aarch64_asm)
|
|
|
118
121
|
trn1 v24.2d, v25.2d, v27.2d
|
|
119
122
|
mov x2, #0x18 // =24
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
Lmlk_keccak_f1600_x2_v84a_loop:
|
|
122
125
|
eor3 v30.16b, v0.16b, v5.16b, v10.16b
|
|
123
126
|
eor3 v29.16b, v1.16b, v6.16b, v11.16b
|
|
124
127
|
eor3 v28.16b, v2.16b, v7.16b, v12.16b
|
|
@@ -187,7 +190,7 @@ Lkeccak_f1600_x2_v84a_loop:
|
|
|
187
190
|
bcax v4.16b, v4.16b, v27.16b, v30.16b
|
|
188
191
|
eor v0.16b, v0.16b, v31.16b
|
|
189
192
|
sub x2, x2, #0x1
|
|
190
|
-
cbnz x2,
|
|
193
|
+
cbnz x2, Lmlk_keccak_f1600_x2_v84a_loop
|
|
191
194
|
sub x0, x0, #0xc0
|
|
192
195
|
add x2, x0, #0xc8
|
|
193
196
|
trn1 v25.2d, v0.2d, v1.2d
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
Description: AArch64 hybrid scalar/vector implementation of Keccak-f[1600] permutation for four sequential states
|
|
14
14
|
Signature: void mlk_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(uint64_t state[100], const uint64_t rc[24])
|
|
15
15
|
ABI:
|
|
16
|
+
Architecture: aarch64
|
|
17
|
+
CallingConvention: AAPCS64
|
|
18
|
+
Features: [NEON]
|
|
16
19
|
x0:
|
|
17
20
|
type: buffer
|
|
18
21
|
size_bytes: 800
|
|
@@ -140,7 +143,7 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm)
|
|
|
140
143
|
ldr x25, [x0, #0xc0]
|
|
141
144
|
sub x0, x0, #0x190
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_initial:
|
|
144
147
|
eor x30, x24, x25
|
|
145
148
|
eor x27, x9, x10
|
|
146
149
|
eor v30.16b, v0.16b, v5.16b
|
|
@@ -523,7 +526,7 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_initial:
|
|
|
523
526
|
str x30, [sp, #0x10]
|
|
524
527
|
eor v0.16b, v0.16b, v28.16b
|
|
525
528
|
|
|
526
|
-
|
|
529
|
+
Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_loop:
|
|
527
530
|
eor x0, x15, x11, ror #52
|
|
528
531
|
eor x0, x0, x13, ror #48
|
|
529
532
|
eor v30.16b, v0.16b, v5.16b
|
|
@@ -911,8 +914,8 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_loop:
|
|
|
911
914
|
str x30, [sp, #0x10]
|
|
912
915
|
eor v0.16b, v0.16b, v28.16b
|
|
913
916
|
|
|
914
|
-
|
|
915
|
-
b.le
|
|
917
|
+
Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_loop_end:
|
|
918
|
+
b.le Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_loop
|
|
916
919
|
ror x2, x2, #0x3d
|
|
917
920
|
ror x3, x3, #0x27
|
|
918
921
|
ror x4, x4, #0x36
|
|
@@ -938,7 +941,7 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_loop_end:
|
|
|
938
941
|
ror x25, x25, #0x9
|
|
939
942
|
ldr x30, [sp, #0x20]
|
|
940
943
|
cmp x30, #0x1
|
|
941
|
-
b.eq
|
|
944
|
+
b.eq Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_done
|
|
942
945
|
mov x30, #0x1 // =1
|
|
943
946
|
str x30, [sp, #0x20]
|
|
944
947
|
ldr x0, [sp]
|
|
@@ -972,9 +975,9 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_loop_end:
|
|
|
972
975
|
ldp x15, x20, [x0, #0xb0]
|
|
973
976
|
ldr x25, [x0, #0xc0]
|
|
974
977
|
sub x0, x0, #0x258
|
|
975
|
-
b
|
|
978
|
+
b Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_initial
|
|
976
979
|
|
|
977
|
-
|
|
980
|
+
Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_done:
|
|
978
981
|
ldr x0, [sp]
|
|
979
982
|
add x0, x0, #0x258
|
|
980
983
|
stp x1, x6, [x0]
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
Description: AArch64 hybrid scalar/vector implementation of Keccak-f[1600] permutation for four sequential states with ARMv8.4-A optimizations
|
|
14
14
|
Signature: void mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm(uint64_t state[100], const uint64_t rc[24])
|
|
15
15
|
ABI:
|
|
16
|
+
Architecture: aarch64
|
|
17
|
+
CallingConvention: AAPCS64
|
|
18
|
+
Features: [NEON, SHA3]
|
|
16
19
|
x0:
|
|
17
20
|
type: buffer
|
|
18
21
|
size_bytes: 800
|
|
@@ -142,7 +145,7 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm)
|
|
|
142
145
|
ldr x25, [x0, #0xc0]
|
|
143
146
|
sub x0, x0, #0x190
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_initial:
|
|
146
149
|
eor x30, x24, x25
|
|
147
150
|
eor x27, x9, x10
|
|
148
151
|
eor3 v30.16b, v0.16b, v5.16b, v10.16b
|
|
@@ -478,7 +481,7 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_initial:
|
|
|
478
481
|
str x30, [sp, #0x10]
|
|
479
482
|
eor v0.16b, v0.16b, v28.16b
|
|
480
483
|
|
|
481
|
-
|
|
484
|
+
Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_loop:
|
|
482
485
|
eor x0, x15, x11, ror #52
|
|
483
486
|
eor x0, x0, x13, ror #48
|
|
484
487
|
eor3 v30.16b, v0.16b, v5.16b, v10.16b
|
|
@@ -819,8 +822,8 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop:
|
|
|
819
822
|
str x30, [sp, #0x10]
|
|
820
823
|
eor v0.16b, v0.16b, v28.16b
|
|
821
824
|
|
|
822
|
-
|
|
823
|
-
b.le
|
|
825
|
+
Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
|
|
826
|
+
b.le Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_loop
|
|
824
827
|
ror x2, x2, #0x3d
|
|
825
828
|
ror x3, x3, #0x27
|
|
826
829
|
ror x4, x4, #0x36
|
|
@@ -846,7 +849,7 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
|
|
|
846
849
|
ror x25, x25, #0x9
|
|
847
850
|
ldr x30, [sp, #0x20]
|
|
848
851
|
cmp x30, #0x1
|
|
849
|
-
b.eq
|
|
852
|
+
b.eq Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_done
|
|
850
853
|
mov x30, #0x1 // =1
|
|
851
854
|
str x30, [sp, #0x20]
|
|
852
855
|
ldr x0, [sp]
|
|
@@ -880,9 +883,9 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
|
|
|
880
883
|
ldp x15, x20, [x0, #0xb0]
|
|
881
884
|
ldr x25, [x0, #0xc0]
|
|
882
885
|
sub x0, x0, #0x258
|
|
883
|
-
b
|
|
886
|
+
b Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_initial
|
|
884
887
|
|
|
885
|
-
|
|
888
|
+
Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_done:
|
|
886
889
|
ldr x0, [sp]
|
|
887
890
|
add x0, x0, #0x258
|
|
888
891
|
stp x1, x6, [x0]
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#endif
|
|
12
12
|
|
|
13
13
|
/* Part of backend API */
|
|
14
|
-
#define
|
|
14
|
+
#define MLK_USE_NATIVE_FIPS202_X1
|
|
15
15
|
/* Guard for assembly file */
|
|
16
16
|
#define MLK_FIPS202_AARCH64_NEED_X1_V84A
|
|
17
17
|
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
22
22
|
static MLK_INLINE int mlk_keccak_f1600_x1_native(uint64_t *state)
|
|
23
23
|
{
|
|
24
|
-
if (!mlk_sys_check_capability(
|
|
24
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) ||
|
|
25
|
+
!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_SHA3))
|
|
25
26
|
{
|
|
26
27
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
27
28
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#endif
|
|
12
12
|
|
|
13
13
|
/* Part of backend API */
|
|
14
|
-
#define
|
|
14
|
+
#define MLK_USE_NATIVE_FIPS202_X4
|
|
15
15
|
/* Guard for assembly file */
|
|
16
16
|
#define MLK_FIPS202_AARCH64_NEED_X2_V84A
|
|
17
17
|
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
22
22
|
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
|
|
23
23
|
{
|
|
24
|
-
if (!mlk_sys_check_capability(
|
|
24
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) ||
|
|
25
|
+
!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_SHA3))
|
|
25
26
|
{
|
|
26
27
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
27
28
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#define MLK_FIPS202_NATIVE_AARCH64_X4_V8A_SCALAR_H
|
|
8
8
|
|
|
9
9
|
/* Part of backend API */
|
|
10
|
-
#define
|
|
10
|
+
#define MLK_USE_NATIVE_FIPS202_X4
|
|
11
11
|
/* Guard for assembly file */
|
|
12
12
|
#define MLK_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID
|
|
13
13
|
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
18
18
|
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
|
|
19
19
|
{
|
|
20
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
|
|
21
|
+
{
|
|
22
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
mlk_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(
|
|
21
26
|
state, mlk_keccakf1600_round_constants);
|
|
22
27
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#endif
|
|
12
12
|
|
|
13
13
|
/* Part of backend API */
|
|
14
|
-
#define
|
|
14
|
+
#define MLK_USE_NATIVE_FIPS202_X4
|
|
15
15
|
/* Guard for assembly file */
|
|
16
16
|
#define MLK_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID
|
|
17
17
|
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
22
22
|
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
|
|
23
23
|
{
|
|
24
|
-
if (!mlk_sys_check_capability(
|
|
24
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) ||
|
|
25
|
+
!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_SHA3))
|
|
25
26
|
{
|
|
26
27
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
27
28
|
}
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
* A _backend_ is a specific implementation of parts of this interface.
|
|
30
30
|
*
|
|
31
31
|
* You can replace 1-fold or 4-fold batched Keccak-F1600.
|
|
32
|
-
* To enable, set
|
|
32
|
+
* To enable, set MLK_USE_NATIVE_FIPS202_X1 or MLK_USE_NATIVE_FIPS202_X4
|
|
33
33
|
* in your backend, and define the inline wrappers mlk_keccak_f1600_x1_native()
|
|
34
34
|
* and/or mlk_keccak_f1600_x4_native(), respectively, to forward to your
|
|
35
35
|
* implementation.
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
#if defined(
|
|
38
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X1)
|
|
39
39
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
40
40
|
static MLK_INLINE int mlk_keccak_f1600_x1_native(uint64_t *state)
|
|
41
41
|
__contract__(
|
|
@@ -43,8 +43,8 @@ __contract__(
|
|
|
43
43
|
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
|
|
44
44
|
ensures(return_value == MLK_NATIVE_FUNC_FALLBACK || return_value == MLK_NATIVE_FUNC_SUCCESS)
|
|
45
45
|
ensures((return_value == MLK_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 1)));
|
|
46
|
-
#endif /*
|
|
47
|
-
#if defined(
|
|
46
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X1 */
|
|
47
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X4)
|
|
48
48
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
49
49
|
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
|
|
50
50
|
__contract__(
|
|
@@ -52,7 +52,7 @@ __contract__(
|
|
|
52
52
|
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
|
|
53
53
|
ensures(return_value == MLK_NATIVE_FUNC_FALLBACK || return_value == MLK_NATIVE_FUNC_SUCCESS)
|
|
54
54
|
ensures((return_value == MLK_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4)));
|
|
55
|
-
#endif /*
|
|
55
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X4 */
|
|
56
56
|
|
|
57
57
|
/*
|
|
58
58
|
* Native x4 XOR bytes and extract bytes interface.
|
|
@@ -66,12 +66,12 @@ __contract__(
|
|
|
66
66
|
* NOTE: We assume that the custom representation of the zero state is the
|
|
67
67
|
* all-zero state.
|
|
68
68
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
69
|
+
* MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES: Backend provides native XOR bytes
|
|
70
|
+
* MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES: Backend provides native extract
|
|
71
71
|
* bytes
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
|
-
#if defined(
|
|
74
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES)
|
|
75
75
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
76
76
|
static MLK_INLINE int mlk_keccakf1600_xor_bytes_x4_native(
|
|
77
77
|
uint64_t *state, const unsigned char *data0, const unsigned char *data1,
|
|
@@ -91,9 +91,9 @@ __contract__(
|
|
|
91
91
|
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
|
|
92
92
|
ensures(return_value == MLK_NATIVE_FUNC_FALLBACK || return_value == MLK_NATIVE_FUNC_SUCCESS)
|
|
93
93
|
ensures((return_value == MLK_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4)));
|
|
94
|
-
#endif /*
|
|
94
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES */
|
|
95
95
|
|
|
96
|
-
#if defined(
|
|
96
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES)
|
|
97
97
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
98
98
|
static MLK_INLINE int mlk_keccakf1600_extract_bytes_x4_native(
|
|
99
99
|
uint64_t *state, unsigned char *data0, unsigned char *data1,
|
|
@@ -112,6 +112,6 @@ __contract__(
|
|
|
112
112
|
assigns(memory_slice(data2, length))
|
|
113
113
|
assigns(memory_slice(data3, length))
|
|
114
114
|
ensures(return_value == MLK_NATIVE_FUNC_FALLBACK || return_value == MLK_NATIVE_FUNC_SUCCESS));
|
|
115
|
-
#endif /*
|
|
115
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES */
|
|
116
116
|
|
|
117
117
|
#endif /* !MLK_FIPS202_NATIVE_API_H */
|
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
#define MLK_FIPS202_NATIVE_ARMV81M
|
|
10
10
|
|
|
11
11
|
/* Part of backend API */
|
|
12
|
-
#define
|
|
13
|
-
#define
|
|
14
|
-
#define
|
|
12
|
+
#define MLK_USE_NATIVE_FIPS202_X4
|
|
13
|
+
#define MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES
|
|
14
|
+
#define MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES
|
|
15
15
|
/* Guard for assembly file */
|
|
16
16
|
#define MLK_FIPS202_ARMV81M_NEED_X4
|
|
17
17
|
|
|
18
18
|
#if !defined(__ASSEMBLER__)
|
|
19
19
|
#include "../api.h"
|
|
20
|
+
#include "src/fips202_native_armv81m.h"
|
|
20
21
|
|
|
21
22
|
/*
|
|
22
23
|
* Native x4 permutation
|
|
@@ -35,42 +36,27 @@ static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
|
|
|
35
36
|
/*
|
|
36
37
|
* Native x4 XOR bytes (with on-the-fly bit interleaving)
|
|
37
38
|
*/
|
|
38
|
-
#define mlk_keccak_f1600_x4_state_xor_bytes \
|
|
39
|
-
MLK_NAMESPACE(keccak_f1600_x4_state_xor_bytes_asm)
|
|
40
|
-
void mlk_keccak_f1600_x4_state_xor_bytes(void *state, const uint8_t *data0,
|
|
41
|
-
const uint8_t *data1,
|
|
42
|
-
const uint8_t *data2,
|
|
43
|
-
const uint8_t *data3, unsigned offset,
|
|
44
|
-
unsigned length);
|
|
45
|
-
|
|
46
39
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
47
40
|
static MLK_INLINE int mlk_keccakf1600_xor_bytes_x4_native(
|
|
48
41
|
uint64_t *state, const uint8_t *data0, const uint8_t *data1,
|
|
49
42
|
const uint8_t *data2, const uint8_t *data3, unsigned offset,
|
|
50
43
|
unsigned length)
|
|
51
44
|
{
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
mlk_keccak_f1600_x4_state_xor_bytes_asm(state, data0, data1, data2, data3,
|
|
46
|
+
offset, length);
|
|
54
47
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
55
48
|
}
|
|
56
49
|
|
|
57
50
|
/*
|
|
58
51
|
* Native x4 extract bytes (with on-the-fly bit de-interleaving)
|
|
59
52
|
*/
|
|
60
|
-
#define mlk_keccak_f1600_x4_state_extract_bytes \
|
|
61
|
-
MLK_NAMESPACE(keccak_f1600_x4_state_extract_bytes_asm)
|
|
62
|
-
void mlk_keccak_f1600_x4_state_extract_bytes(void *state, uint8_t *data0,
|
|
63
|
-
uint8_t *data1, uint8_t *data2,
|
|
64
|
-
uint8_t *data3, unsigned offset,
|
|
65
|
-
unsigned length);
|
|
66
|
-
|
|
67
53
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
68
54
|
static MLK_INLINE int mlk_keccakf1600_extract_bytes_x4_native(
|
|
69
55
|
uint64_t *state, uint8_t *data0, uint8_t *data1, uint8_t *data2,
|
|
70
56
|
uint8_t *data3, unsigned offset, unsigned length)
|
|
71
57
|
{
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
mlk_keccak_f1600_x4_state_extract_bytes_asm(state, data0, data1, data2, data3,
|
|
59
|
+
offset, length);
|
|
74
60
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
75
61
|
}
|
|
76
62
|
|
data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
Description: Armv8.1-M MVE implementation of batched (x4) Keccak-f[1600] permutation using bit-interleaved state
|
|
10
10
|
Signature: void mlk_keccak_f1600_x4_mve_asm(void *state, void *tmpstate, const uint32_t *rc)
|
|
11
11
|
ABI:
|
|
12
|
+
Architecture: armv81m
|
|
13
|
+
CallingConvention: AAPCS32
|
|
14
|
+
Features: [MVE]
|
|
12
15
|
r0:
|
|
13
16
|
type: buffer
|
|
14
17
|
size_bytes: 800
|
|
@@ -111,9 +114,9 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_mve_asm)
|
|
|
111
114
|
vldrw.u32 q0, [r3]
|
|
112
115
|
vldrw.u32 q1, [r2]
|
|
113
116
|
vldrw.u32 q2, [r2, #32]
|
|
114
|
-
wls lr, lr,
|
|
117
|
+
wls lr, lr, Lmlk_keccak_f1600_x4_mve_asm_roundend @ imm = #0x8c0
|
|
115
118
|
|
|
116
|
-
|
|
119
|
+
Lmlk_keccak_f1600_x4_mve_asm_roundstart:
|
|
117
120
|
vldrw.u32 q6, [r2, #112]
|
|
118
121
|
veor q7, q6, q2
|
|
119
122
|
vldrw.u32 q2, [r2, #80]
|
|
@@ -674,10 +677,10 @@ Lkeccak_f1600_x4_mve_asm_roundstart:
|
|
|
674
677
|
veor q0, q4, q6
|
|
675
678
|
vstrw.32 q0, [r5]
|
|
676
679
|
|
|
677
|
-
|
|
678
|
-
le lr,
|
|
680
|
+
Lmlk_keccak_f1600_x4_mve_asm_roundend_pre:
|
|
681
|
+
le lr, Lmlk_keccak_f1600_x4_mve_asm_roundstart @ imm = #-0x8c0
|
|
679
682
|
|
|
680
|
-
|
|
683
|
+
Lmlk_keccak_f1600_x4_mve_asm_roundend:
|
|
681
684
|
add sp, #0x80
|
|
682
685
|
.cfi_adjust_cfa_offset -0x80
|
|
683
686
|
vpop {d8, d9, d10, d11, d12, d13, d14, d15}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// Overview
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
// MVE/Helium implementation of KeccakF1600x4_StateExtractBytes
|
|
12
|
-
// (inverse of
|
|
12
|
+
// (inverse of keccak_f1600_x4_state_xor_bytes_mve.S).
|
|
13
13
|
//
|
|
14
14
|
// void KeccakF1600x4_StateExtractBytes(state, d0, d1, d2, d3, offset, length)
|
|
15
15
|
//
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
|
|
63
63
|
/*
|
|
64
64
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
65
|
-
* dev/fips202/armv81m/src/
|
|
65
|
+
* dev/fips202/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S using scripts/simpasm. Do not modify it directly.
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
.thumb
|
|
@@ -99,13 +99,13 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_extract_bytes_asm)
|
|
|
99
99
|
ldr.w r10, [sp, #0x6c]
|
|
100
100
|
ldr r6, [sp, #0x70]
|
|
101
101
|
cmp r6, #0x0
|
|
102
|
-
beq.w
|
|
102
|
+
beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x2ea
|
|
103
103
|
and r5, r10, #0x7
|
|
104
104
|
bic r9, r10, #0x7
|
|
105
105
|
add.w r8, r0, r9, lsl #1
|
|
106
106
|
add.w r7, r8, #0x190
|
|
107
107
|
cmp r5, #0x0
|
|
108
|
-
beq.w
|
|
108
|
+
beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_pre_main @ imm = #0x112
|
|
109
109
|
vldrw.u32 q0, [r8], #16
|
|
110
110
|
vldrw.u32 q1, [r7], #16
|
|
111
111
|
vrev32.16 q2, q0
|
|
@@ -175,22 +175,22 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_extract_bytes_asm)
|
|
|
175
175
|
vstrbt.8 q3, [r4], #4
|
|
176
176
|
subs.w r6, r6, lr
|
|
177
177
|
cmp r6, #0x0
|
|
178
|
-
beq.w
|
|
178
|
+
beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x1cc
|
|
179
179
|
vmov q7[2], q7[0], r1, r3
|
|
180
180
|
vmov q7[3], q7[1], r2, r4
|
|
181
|
-
b
|
|
181
|
+
b Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_body @ imm = #0xe
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
Lmlk_keccak_f1600_x4_state_extract_bytes_asm_pre_main:
|
|
184
184
|
vmov q7[2], q7[0], r1, r3
|
|
185
185
|
vmov q7[3], q7[1], r2, r4
|
|
186
186
|
mov.w r12, #0x4
|
|
187
187
|
vsub.i32 q7, q7, r12
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_body:
|
|
190
190
|
lsr.w lr, r6, #0x3
|
|
191
|
-
wls lr, lr,
|
|
191
|
+
wls lr, lr, Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_end @ imm = #0xb4
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_start:
|
|
194
194
|
vldrw.u32 q0, [r8], #16
|
|
195
195
|
vldrw.u32 q1, [r7], #16
|
|
196
196
|
vrev32.16 q2, q0
|
|
@@ -235,11 +235,11 @@ Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_start:
|
|
|
235
235
|
vorr q1, q1, q3
|
|
236
236
|
vstrw.32 q0, [q7, #4]!
|
|
237
237
|
vstrw.32 q1, [q7, #4]!
|
|
238
|
-
le lr,
|
|
238
|
+
le lr, Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_start @ imm = #-0xb4
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
|
|
241
241
|
ands r6, r6, #0x7
|
|
242
|
-
beq
|
|
242
|
+
beq Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0xee
|
|
243
243
|
mov.w r12, #0x4
|
|
244
244
|
vadd.i32 q7, q7, r12
|
|
245
245
|
vmov r1, r3, q7[2], q7[0]
|
|
@@ -301,7 +301,7 @@ Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
|
|
|
301
301
|
vstrbt.8 q2, [r3], #4
|
|
302
302
|
vstrbt.8 q3, [r4], #4
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit:
|
|
305
305
|
vpop {d8, d9, d10, d11, d12, d13, d14, d15}
|
|
306
306
|
.cfi_restore d8
|
|
307
307
|
.cfi_restore d9
|