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
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
#define MLD_NAMESPACE_KL(s) MLD_CONCAT(MLD_NAMESPACE_PREFIX_KL, s)
|
|
72
72
|
|
|
73
73
|
/* On Apple platforms, we need to emit leading underscore
|
|
74
|
-
* in front of assembly symbols. We thus
|
|
74
|
+
* in front of assembly symbols. We thus introduce a separate
|
|
75
75
|
* namespace wrapper for ASM symbols. */
|
|
76
76
|
#if !defined(__APPLE__)
|
|
77
77
|
#define MLD_ASM_NAMESPACE(sym) MLD_NAMESPACE(sym)
|
|
@@ -129,15 +129,19 @@
|
|
|
129
129
|
#endif
|
|
130
130
|
|
|
131
131
|
#if defined(MLD_CONFIG_NO_RANDOMIZED_API) && defined(MLD_CONFIG_KEYGEN_PCT)
|
|
132
|
-
#error Bad configuration: MLD_CONFIG_NO_RANDOMIZED_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires
|
|
132
|
+
#error Bad configuration: MLD_CONFIG_NO_RANDOMIZED_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires signature()
|
|
133
133
|
#endif
|
|
134
134
|
|
|
135
135
|
#if defined(MLD_CONFIG_NO_SIGN_API) && defined(MLD_CONFIG_KEYGEN_PCT)
|
|
136
|
-
#error Bad configuration: MLD_CONFIG_NO_SIGN_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires
|
|
136
|
+
#error Bad configuration: MLD_CONFIG_NO_SIGN_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires signature()
|
|
137
137
|
#endif
|
|
138
138
|
|
|
139
139
|
#if defined(MLD_CONFIG_NO_VERIFY_API) && defined(MLD_CONFIG_KEYGEN_PCT)
|
|
140
|
-
#error Bad configuration: MLD_CONFIG_NO_VERIFY_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires
|
|
140
|
+
#error Bad configuration: MLD_CONFIG_NO_VERIFY_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires verify()
|
|
141
|
+
#endif
|
|
142
|
+
|
|
143
|
+
#if defined(MLD_CONFIG_CORE_API_ONLY) && defined(MLD_CONFIG_KEYGEN_PCT)
|
|
144
|
+
#error Bad configuration: MLD_CONFIG_CORE_API_ONLY is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires signature() and verify()
|
|
141
145
|
#endif
|
|
142
146
|
|
|
143
147
|
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH)
|
|
@@ -202,77 +206,31 @@
|
|
|
202
206
|
#error Bad configuration: MLD_CONFIG_CUSTOM_ALLOC_FREE must be set together with MLD_CUSTOM_ALLOC and MLD_CUSTOM_FREE
|
|
203
207
|
#endif
|
|
204
208
|
|
|
205
|
-
/*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
|
|
210
|
-
* defining the function names and expand to either pass or discard the context
|
|
211
|
-
* argument as required by the current build. If there is no context parameter
|
|
212
|
-
* requested then these are removed from the prototypes and from all calls.
|
|
213
|
-
*/
|
|
214
|
-
#ifdef MLD_CONFIG_CONTEXT_PARAMETER
|
|
215
|
-
#define MLD_CONTEXT_PARAMETERS_0(context) (context)
|
|
216
|
-
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
|
|
217
|
-
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
|
|
218
|
-
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
|
|
219
|
-
(arg0, arg1, arg2, context)
|
|
220
|
-
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
221
|
-
(arg0, arg1, arg2, arg3, context)
|
|
222
|
-
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
|
|
223
|
-
(arg0, arg1, arg2, arg3, arg4, context)
|
|
224
|
-
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
|
|
225
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, context)
|
|
226
|
-
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
227
|
-
context) \
|
|
228
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, context)
|
|
229
|
-
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
230
|
-
arg7, context) \
|
|
231
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, context)
|
|
232
|
-
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
233
|
-
arg7, arg8, context) \
|
|
234
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, context)
|
|
235
|
-
#else /* MLD_CONFIG_CONTEXT_PARAMETER */
|
|
236
|
-
#define MLD_CONTEXT_PARAMETERS_0(context) ()
|
|
237
|
-
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
|
|
238
|
-
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
|
|
239
|
-
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
|
|
240
|
-
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
241
|
-
(arg0, arg1, arg2, arg3)
|
|
242
|
-
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
|
|
243
|
-
(arg0, arg1, arg2, arg3, arg4)
|
|
244
|
-
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
|
|
245
|
-
(arg0, arg1, arg2, arg3, arg4, arg5)
|
|
246
|
-
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
247
|
-
context) \
|
|
248
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
|
249
|
-
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
250
|
-
arg7, context) \
|
|
251
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
|
252
|
-
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
253
|
-
arg7, arg8, context) \
|
|
254
|
-
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
|
255
|
-
#endif /* !MLD_CONFIG_CONTEXT_PARAMETER */
|
|
256
|
-
|
|
257
|
-
#if defined(MLD_CONFIG_CONTEXT_PARAMETER_TYPE) != \
|
|
258
|
-
defined(MLD_CONFIG_CONTEXT_PARAMETER)
|
|
259
|
-
#error MLD_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLD_CONFIG_CONTEXT_PARAMETER is defined
|
|
260
|
-
#endif
|
|
209
|
+
/* Context-parameter machinery (MLD_CONTEXT_PARAMETERS_n and related config
|
|
210
|
+
* checks). Kept in a separate, level-generic header for readability; included
|
|
211
|
+
* here so it is available to the allocation macros below and to all consumers
|
|
212
|
+
* of common.h. */
|
|
213
|
+
#include "context.h"
|
|
261
214
|
|
|
262
215
|
#if !defined(MLD_CONFIG_CUSTOM_ALLOC_FREE)
|
|
263
216
|
/* Default: stack allocation */
|
|
264
217
|
|
|
218
|
+
/* This is a declaration macro, not an expression macro: T is a type and v is
|
|
219
|
+
* a declarator, neither of which can be wrapped in parentheses. The
|
|
220
|
+
* bugprone-macro-parentheses diagnostic is therefore a false positive here. */
|
|
265
221
|
#define MLD_ALLOC(v, T, N, context) \
|
|
266
222
|
MLD_ALIGN T mld_alloc_##v[N]; \
|
|
267
|
-
T *v = mld_alloc_##v
|
|
223
|
+
T *v = mld_alloc_##v /* NOLINT(bugprone-macro-parentheses) */
|
|
268
224
|
|
|
269
|
-
/*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
|
|
225
|
+
/* The MLD_FREE macro body references mld_zeroize(), which is declared in
|
|
226
|
+
* ct.h. We deliberately do NOT include ct.h here: doing so would create a
|
|
227
|
+
* circular dependency (ct.h includes common.h), and common.h itself never
|
|
228
|
+
* calls mld_zeroize() -- only the macro expansion does. Each translation
|
|
229
|
+
* unit that uses MLD_FREE therefore includes ct.h directly. */
|
|
273
230
|
#define MLD_FREE(v, T, N, context) \
|
|
274
231
|
do \
|
|
275
232
|
{ \
|
|
233
|
+
MLD_CONTEXT_UNUSED(context); \
|
|
276
234
|
mld_zeroize(mld_alloc_##v, sizeof(mld_alloc_##v)); \
|
|
277
235
|
(v) = NULL; \
|
|
278
236
|
} while (0)
|
|
@@ -304,28 +262,38 @@
|
|
|
304
262
|
|
|
305
263
|
/****************************** Error codes ***********************************/
|
|
306
264
|
|
|
307
|
-
/* Generic failure condition
|
|
308
|
-
|
|
265
|
+
/* Generic failure condition, reserved for failures not covered by a more
|
|
266
|
+
* specific error code. */
|
|
267
|
+
#define MLD_ERR_FAIL (-1)
|
|
309
268
|
/* An allocation failed. This can only happen if MLD_CONFIG_CUSTOM_ALLOC_FREE
|
|
310
269
|
* is defined and the provided MLD_CUSTOM_ALLOC can fail. */
|
|
311
|
-
#define MLD_ERR_OUT_OF_MEMORY -2
|
|
312
|
-
/* An
|
|
270
|
+
#define MLD_ERR_OUT_OF_MEMORY (-2)
|
|
271
|
+
/* An RNG failure occurred. Might be due to insufficient entropy or
|
|
313
272
|
* system misconfiguration. */
|
|
314
|
-
#define MLD_ERR_RNG_FAIL -3
|
|
273
|
+
#define MLD_ERR_RNG_FAIL (-3)
|
|
315
274
|
/* The signing rejection-sampling loop exceeded
|
|
316
275
|
* MLD_CONFIG_MAX_SIGNING_ATTEMPTS iterations without producing a valid
|
|
317
|
-
* signature. With a FIPS 204 Appendix C compliant bound (>=
|
|
276
|
+
* signature. With a FIPS 204 Appendix C compliant bound (>= 821) this
|
|
318
277
|
* has probability < 2^-256. */
|
|
319
|
-
#define MLD_ERR_SIGN_ATTEMPTS_EXHAUSTED -4
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
278
|
+
#define MLD_ERR_SIGN_ATTEMPTS_EXHAUSTED (-4)
|
|
279
|
+
/* Signing was paused before completing, at the request of a caller-provided
|
|
280
|
+
* MLD_CONFIG_SIGN_HOOK_ATTEMPT hook (see mldsa_native_config.h). The caller
|
|
281
|
+
* resumes by re-invoking signing with the same inputs; the attempt hook,
|
|
282
|
+
* together with MLD_CONFIG_SIGN_HOOK_RESUME, decides where to continue. */
|
|
283
|
+
#define MLD_ERR_SIGNING_PAUSED (-5)
|
|
284
|
+
/* Signature verification failed: the signature is not valid for the given
|
|
285
|
+
* message and public key. Returned by the verification API. */
|
|
286
|
+
#define MLD_ERR_INVALID_SIGNATURE (-6)
|
|
287
|
+
/* Secret key validation failed: the secret key is malformed or internally
|
|
288
|
+
* inconsistent. Returned by pk_from_sk. */
|
|
289
|
+
#define MLD_ERR_INVALID_KEY (-7)
|
|
290
|
+
/* The Pairwise Consistency Test failed. Only possible when
|
|
291
|
+
* MLD_CONFIG_KEYGEN_PCT is enabled; signals that the freshly generated key
|
|
292
|
+
* pair failed its sign/verify self-test. */
|
|
293
|
+
#define MLD_ERR_PCT_FAIL (-8)
|
|
294
|
+
/* An argument was invalid, e.g. an unsupported pre-hash algorithm or a context
|
|
295
|
+
* string longer than 255 bytes. */
|
|
296
|
+
#define MLD_ERR_INVALID_ARG (-9)
|
|
329
297
|
|
|
330
298
|
|
|
331
299
|
#endif /* !__ASSEMBLER__ */
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mldsa-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
#ifndef MLD_CONTEXT_H
|
|
6
|
+
#define MLD_CONTEXT_H
|
|
7
|
+
|
|
8
|
+
/* This header is included by common.h once the configuration has been pulled
|
|
9
|
+
* in; it is not meant to be included directly. */
|
|
10
|
+
#if !defined(__ASSEMBLER__)
|
|
11
|
+
|
|
12
|
+
#include <stdint.h>
|
|
13
|
+
#include "cbmc.h"
|
|
14
|
+
#include "sys.h"
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* If the integration wants to provide a context parameter for use in
|
|
18
|
+
* platform-specific hooks, then it should define this parameter.
|
|
19
|
+
*
|
|
20
|
+
* The MLD_CONTEXT_PARAMETERS_n macros are intended to be used with macros
|
|
21
|
+
* defining the function names and expand to either pass or discard the context
|
|
22
|
+
* argument as required by the current build. If there is no context parameter
|
|
23
|
+
* requested then these are removed from the prototypes and from all calls.
|
|
24
|
+
*/
|
|
25
|
+
#ifdef MLD_CONFIG_CONTEXT_PARAMETER
|
|
26
|
+
#define MLD_CONTEXT_PARAMETERS_0(context) (context)
|
|
27
|
+
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
|
|
28
|
+
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
|
|
29
|
+
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
|
|
30
|
+
(arg0, arg1, arg2, context)
|
|
31
|
+
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
32
|
+
(arg0, arg1, arg2, arg3, context)
|
|
33
|
+
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
|
|
34
|
+
(arg0, arg1, arg2, arg3, arg4, context)
|
|
35
|
+
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
|
|
36
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, context)
|
|
37
|
+
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
38
|
+
context) \
|
|
39
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, context)
|
|
40
|
+
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
41
|
+
arg7, context) \
|
|
42
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, context)
|
|
43
|
+
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
44
|
+
arg7, arg8, context) \
|
|
45
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, context)
|
|
46
|
+
#else /* MLD_CONFIG_CONTEXT_PARAMETER */
|
|
47
|
+
#define MLD_CONTEXT_PARAMETERS_0(context) ()
|
|
48
|
+
#define MLD_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
|
|
49
|
+
#define MLD_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
|
|
50
|
+
#define MLD_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
|
|
51
|
+
#define MLD_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
52
|
+
(arg0, arg1, arg2, arg3)
|
|
53
|
+
#define MLD_CONTEXT_PARAMETERS_5(arg0, arg1, arg2, arg3, arg4, context) \
|
|
54
|
+
(arg0, arg1, arg2, arg3, arg4)
|
|
55
|
+
#define MLD_CONTEXT_PARAMETERS_6(arg0, arg1, arg2, arg3, arg4, arg5, context) \
|
|
56
|
+
(arg0, arg1, arg2, arg3, arg4, arg5)
|
|
57
|
+
#define MLD_CONTEXT_PARAMETERS_7(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
58
|
+
context) \
|
|
59
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
|
60
|
+
#define MLD_CONTEXT_PARAMETERS_8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
61
|
+
arg7, context) \
|
|
62
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
|
63
|
+
#define MLD_CONTEXT_PARAMETERS_9(arg0, arg1, arg2, arg3, arg4, arg5, arg6, \
|
|
64
|
+
arg7, arg8, context) \
|
|
65
|
+
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
|
66
|
+
#endif /* !MLD_CONFIG_CONTEXT_PARAMETER */
|
|
67
|
+
|
|
68
|
+
/* Consume a context parameter carried only for the integration's benefit,
|
|
69
|
+
* avoiding -Wunused-parameter; expands to nothing when no context is
|
|
70
|
+
* configured. */
|
|
71
|
+
#if defined(MLD_CONFIG_CONTEXT_PARAMETER)
|
|
72
|
+
#define MLD_CONTEXT_UNUSED(context) ((void)(context))
|
|
73
|
+
#else
|
|
74
|
+
#define MLD_CONTEXT_UNUSED(context) ((void)0)
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#if defined(MLD_CONFIG_CONTEXT_PARAMETER_TYPE) != \
|
|
78
|
+
defined(MLD_CONFIG_CONTEXT_PARAMETER)
|
|
79
|
+
#error MLD_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLD_CONFIG_CONTEXT_PARAMETER is defined
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
/* The signing hooks tie into the rejection-sampling loop. A pausing attempt
|
|
83
|
+
* hook only reproduces the uninterrupted signature if the randomness is fixed
|
|
84
|
+
* across calls, and thus requires the deterministic API.
|
|
85
|
+
* For now we impose that requirement on all three hooks uniformly: enabling any
|
|
86
|
+
* of them requires MLD_CONFIG_NO_RANDOMIZED_API. This also rules out
|
|
87
|
+
* MLD_CONFIG_KEYGEN_PCT (whose PCT needs the randomized signature(), see
|
|
88
|
+
* common.h).
|
|
89
|
+
*
|
|
90
|
+
* A logging-only use (attempt always returns 0; resume/finish merely observe)
|
|
91
|
+
* would be safe with the randomized API too, but the restriction is applied
|
|
92
|
+
* uniformly for now. */
|
|
93
|
+
#if (defined(MLD_CONFIG_SIGN_HOOK_RESUME) || \
|
|
94
|
+
defined(MLD_CONFIG_SIGN_HOOK_ATTEMPT) || \
|
|
95
|
+
defined(MLD_CONFIG_SIGN_HOOK_FINISH)) && \
|
|
96
|
+
!defined(MLD_CONFIG_NO_RANDOMIZED_API)
|
|
97
|
+
#error Signing hooks (MLD_CONFIG_SIGN_HOOK_RESUME / _ATTEMPT / _FINISH) require MLD_CONFIG_NO_RANDOMIZED_API
|
|
98
|
+
#endif /* (MLD_CONFIG_SIGN_HOOK_RESUME || MLD_CONFIG_SIGN_HOOK_ATTEMPT || \
|
|
99
|
+
MLD_CONFIG_SIGN_HOOK_FINISH) && !MLD_CONFIG_NO_RANDOMIZED_API */
|
|
100
|
+
|
|
101
|
+
/* Signing hooks (MLD_CONFIG_SIGN_HOOK_RESUME / _ATTEMPT / _FINISH; documented
|
|
102
|
+
* in mldsa_native_config.h). The following macros route the call sites to
|
|
103
|
+
* mld_sign_hook_*, appending or dropping the context argument; each unset hook
|
|
104
|
+
* uses the dummy below. */
|
|
105
|
+
#define mld_sign_resume mld_sign_hook_resume MLD_CONTEXT_PARAMETERS_0
|
|
106
|
+
#define mld_sign_attempt mld_sign_hook_attempt MLD_CONTEXT_PARAMETERS_1
|
|
107
|
+
#define mld_sign_finish mld_sign_hook_finish MLD_CONTEXT_PARAMETERS_1
|
|
108
|
+
|
|
109
|
+
/* We don't use mld_sign_resume here because MLD_CONTEXT_PARAMETERS_0 is
|
|
110
|
+
* unsuitable for function declarations: it misses `void` as the placeholder
|
|
111
|
+
* argument. */
|
|
112
|
+
#if !defined(MLD_CONFIG_SIGN_HOOK_RESUME)
|
|
113
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
114
|
+
static MLD_INLINE uint16_t mld_sign_hook_resume(
|
|
115
|
+
#if defined(MLD_CONFIG_CONTEXT_PARAMETER)
|
|
116
|
+
MLD_CONFIG_CONTEXT_PARAMETER_TYPE context
|
|
117
|
+
#else
|
|
118
|
+
void
|
|
119
|
+
#endif
|
|
120
|
+
)
|
|
121
|
+
__contract__(assigns() ensures(1))
|
|
122
|
+
{
|
|
123
|
+
MLD_CONTEXT_UNUSED(context);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
#endif /* !MLD_CONFIG_SIGN_HOOK_RESUME */
|
|
127
|
+
|
|
128
|
+
#if !defined(MLD_CONFIG_SIGN_HOOK_ATTEMPT)
|
|
129
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
130
|
+
static MLD_INLINE int mld_sign_attempt(
|
|
131
|
+
uint16_t attempt, MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
|
|
132
|
+
__contract__(assigns() ensures(1))
|
|
133
|
+
{
|
|
134
|
+
((void)attempt);
|
|
135
|
+
MLD_CONTEXT_UNUSED(context);
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
#endif /* !MLD_CONFIG_SIGN_HOOK_ATTEMPT */
|
|
139
|
+
|
|
140
|
+
#if !defined(MLD_CONFIG_SIGN_HOOK_FINISH)
|
|
141
|
+
static MLD_INLINE void mld_sign_finish(
|
|
142
|
+
uint16_t attempt, MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
|
|
143
|
+
__contract__(assigns() ensures(1))
|
|
144
|
+
{
|
|
145
|
+
((void)attempt);
|
|
146
|
+
MLD_CONTEXT_UNUSED(context);
|
|
147
|
+
}
|
|
148
|
+
#endif /* !MLD_CONFIG_SIGN_HOOK_FINISH */
|
|
149
|
+
|
|
150
|
+
#endif /* !__ASSEMBLER__ */
|
|
151
|
+
|
|
152
|
+
#endif /* !MLD_CONTEXT_H */
|
|
@@ -151,7 +151,7 @@ __contract__(ensures(return_value == b))
|
|
|
151
151
|
* @return For uint32_t x, the unique y in int32_t so that x == y mod 2^32.
|
|
152
152
|
* Concretely:
|
|
153
153
|
* - x < 2^31: returns x
|
|
154
|
-
* - x >= 2^31: returns x - 2^
|
|
154
|
+
* - x >= 2^31: returns x - 2^32
|
|
155
155
|
*/
|
|
156
156
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
157
157
|
static MLD_ALWAYS_INLINE int32_t mld_cast_uint32_to_int32(uint32_t x)
|
|
@@ -230,6 +230,12 @@ static MLD_INLINE uint32_t mld_ct_cmask_nonzero_u32(uint32_t x)
|
|
|
230
230
|
__contract__(ensures(return_value == ((x == 0) ? 0 : 0xFFFFFFFF)))
|
|
231
231
|
{
|
|
232
232
|
int64_t tmp = mld_value_barrier_i64(-((int64_t)x));
|
|
233
|
+
/*
|
|
234
|
+
* PORTABILITY: Right-shift on a signed integer is
|
|
235
|
+
* implementation-defined for negative left argument.
|
|
236
|
+
* Here, we assume it's sign-preserving "arithmetic" shift right.
|
|
237
|
+
* See (C99 6.5.7 (5))
|
|
238
|
+
*/
|
|
233
239
|
tmp >>= 32;
|
|
234
240
|
return mld_cast_int64_to_uint32(tmp);
|
|
235
241
|
}
|
|
@@ -259,6 +265,12 @@ __contract__(
|
|
|
259
265
|
)
|
|
260
266
|
{
|
|
261
267
|
int64_t tmp = mld_value_barrier_i64((int64_t)x);
|
|
268
|
+
/*
|
|
269
|
+
* PORTABILITY: Right-shift on a signed integer is
|
|
270
|
+
* implementation-defined for negative left argument.
|
|
271
|
+
* Here, we assume it's sign-preserving "arithmetic" shift right.
|
|
272
|
+
* See (C99 6.5.7 (5))
|
|
273
|
+
*/
|
|
262
274
|
tmp >>= 31;
|
|
263
275
|
return mld_cast_int64_to_uint32(tmp);
|
|
264
276
|
}
|
|
@@ -333,28 +345,29 @@ __contract__(
|
|
|
333
345
|
#if !defined(MLD_CONFIG_CUSTOM_ZEROIZE)
|
|
334
346
|
#if defined(MLD_SYS_WINDOWS)
|
|
335
347
|
#include <windows.h>
|
|
348
|
+
#elif !defined(MLD_HAVE_INLINE_ASM)
|
|
349
|
+
#error No plausibly-secure implementation of mld_zeroize available. Please provide your own using MLD_CONFIG_CUSTOM_ZEROIZE.
|
|
350
|
+
#endif
|
|
351
|
+
|
|
336
352
|
static MLD_INLINE void mld_zeroize(void *ptr, size_t len)
|
|
337
353
|
__contract__(
|
|
354
|
+
requires(len <= UINT32_MAX)
|
|
338
355
|
requires(memory_no_alias(ptr, len))
|
|
339
|
-
assigns(memory_slice(ptr, len))
|
|
340
|
-
|
|
341
|
-
#include <string.h>
|
|
342
|
-
static MLD_INLINE void mld_zeroize(void *ptr, size_t len)
|
|
343
|
-
__contract__(
|
|
344
|
-
requires(memory_no_alias(ptr, len))
|
|
345
|
-
assigns(memory_slice(ptr, len)))
|
|
356
|
+
assigns(memory_slice(ptr, len))
|
|
357
|
+
ensures(array_zeroized_u8((uint8_t *)ptr, len)))
|
|
346
358
|
{
|
|
347
|
-
|
|
359
|
+
#if defined(MLD_SYS_WINDOWS)
|
|
360
|
+
SecureZeroMemory(ptr, len);
|
|
361
|
+
#else
|
|
362
|
+
mld_memset(ptr, 0, len);
|
|
348
363
|
/* This follows OpenSSL and seems sufficient to prevent the compiler
|
|
349
364
|
* from optimizing away the memset.
|
|
350
365
|
*
|
|
351
366
|
* If there was a reliable way to detect availability of memset_s(),
|
|
352
367
|
* that would be preferred. */
|
|
353
368
|
__asm__ __volatile__("" : : "r"(ptr) : "memory");
|
|
369
|
+
#endif /* !MLD_SYS_WINDOWS */
|
|
354
370
|
}
|
|
355
|
-
#else /* !MLD_SYS_WINDOWS && MLD_HAVE_INLINE_ASM */
|
|
356
|
-
#error No plausibly-secure implementation of mld_zeroize available. Please provide your own using MLD_CONFIG_CUSTOM_ZEROIZE.
|
|
357
|
-
#endif /* !MLD_SYS_WINDOWS && !MLD_HAVE_INLINE_ASM */
|
|
358
371
|
#endif /* !MLD_CONFIG_CUSTOM_ZEROIZE */
|
|
359
372
|
|
|
360
373
|
#endif /* !MLD_CT_H */
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
#define MLD_DEBUG_ERROR_HEADER "[ERROR:%s:%04d] "
|
|
21
21
|
|
|
22
|
+
MLD_INTERNAL_API
|
|
22
23
|
void mld_debug_check_assert(const char *file, int line, const int val)
|
|
23
24
|
{
|
|
24
25
|
if (val == 0)
|
|
@@ -29,6 +30,7 @@ void mld_debug_check_assert(const char *file, int line, const int val)
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
MLD_INTERNAL_API
|
|
32
34
|
void mld_debug_check_bounds(const char *file, int line, const int32_t *ptr,
|
|
33
35
|
unsigned len, int64_t lower_bound_exclusive,
|
|
34
36
|
int64_t upper_bound_exclusive)
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* @param val Value asserted to be non-zero.
|
|
20
20
|
*/
|
|
21
21
|
#define mld_debug_check_assert MLD_NAMESPACE(mldsa_debug_assert)
|
|
22
|
+
MLD_INTERNAL_API
|
|
22
23
|
void mld_debug_check_assert(const char *file, int line, const int val);
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -34,6 +35,7 @@ void mld_debug_check_assert(const char *file, int line, const int val);
|
|
|
34
35
|
* @param upper_bound_exclusive Exclusive upper bound.
|
|
35
36
|
*/
|
|
36
37
|
#define mld_debug_check_bounds MLD_NAMESPACE(mldsa_debug_check_bounds)
|
|
38
|
+
MLD_INTERNAL_API
|
|
37
39
|
void mld_debug_check_bounds(const char *file, int line, const int32_t *ptr,
|
|
38
40
|
unsigned len, int64_t lower_bound_exclusive,
|
|
39
41
|
int64_t upper_bound_exclusive);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
#if !defined(MLD_CONFIG_NO_KEYPAIR_API) || !defined(MLD_CONFIG_REDUCE_RAM) || \
|
|
26
26
|
defined(MLD_UNIT_TEST)
|
|
27
|
-
static void mld_keccak_absorb_once_x4(uint64_t *s,
|
|
27
|
+
static void mld_keccak_absorb_once_x4(uint64_t *s, unsigned r,
|
|
28
28
|
const uint8_t *in0, const uint8_t *in1,
|
|
29
29
|
const uint8_t *in2, const uint8_t *in3,
|
|
30
30
|
size_t inlen, uint8_t p)
|
|
@@ -81,7 +81,7 @@ __contract__(
|
|
|
81
81
|
|
|
82
82
|
static void mld_keccak_squeezeblocks_x4(uint8_t *out0, uint8_t *out1,
|
|
83
83
|
uint8_t *out2, uint8_t *out3,
|
|
84
|
-
size_t nblocks, uint64_t *s,
|
|
84
|
+
size_t nblocks, uint64_t *s, unsigned r)
|
|
85
85
|
__contract__(
|
|
86
86
|
requires(r <= sizeof(uint64_t) * MLD_KECCAK_LANES)
|
|
87
87
|
requires(nblocks <= 8 /* somewhat arbitrary bound */)
|
|
@@ -27,13 +27,11 @@
|
|
|
27
27
|
* implementation @[supercop, crypto_hash/keccakc512/simple/]
|
|
28
28
|
* by Ronny Van Keer, and the public domain @[tweetfips] implementation. */
|
|
29
29
|
|
|
30
|
-
#include <assert.h>
|
|
31
|
-
|
|
32
30
|
#include "keccakf1600.h"
|
|
33
31
|
#if !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
|
|
34
32
|
|
|
35
33
|
#define MLD_KECCAK_NROUNDS 24
|
|
36
|
-
#define MLD_KECCAK_ROL(a, offset) ((a << offset) ^ (a >> (64 - offset)))
|
|
34
|
+
#define MLD_KECCAK_ROL(a, offset) (((a) << (offset)) ^ ((a) >> (64 - (offset))))
|
|
37
35
|
|
|
38
36
|
MLD_INTERNAL_API
|
|
39
37
|
void mld_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
|
|
@@ -123,14 +121,14 @@ void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
|
|
|
123
121
|
unsigned char *data3, unsigned offset,
|
|
124
122
|
unsigned length)
|
|
125
123
|
{
|
|
126
|
-
#if defined(
|
|
124
|
+
#if defined(MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES)
|
|
127
125
|
if (mld_keccakf1600_extract_bytes_x4_native(state, data0, data1, data2, data3,
|
|
128
126
|
offset, length) ==
|
|
129
127
|
MLD_NATIVE_FUNC_SUCCESS)
|
|
130
128
|
{
|
|
131
129
|
return;
|
|
132
130
|
}
|
|
133
|
-
#endif /*
|
|
131
|
+
#endif /* MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES */
|
|
134
132
|
mld_keccakf1600x4_extract_bytes_c(state, data0, data1, data2, data3, offset,
|
|
135
133
|
length);
|
|
136
134
|
}
|
|
@@ -173,14 +171,14 @@ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
|
|
|
173
171
|
const unsigned char *data3, unsigned offset,
|
|
174
172
|
unsigned length)
|
|
175
173
|
{
|
|
176
|
-
#if defined(
|
|
174
|
+
#if defined(MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES)
|
|
177
175
|
if (mld_keccakf1600_xor_bytes_x4_native(state, data0, data1, data2, data3,
|
|
178
176
|
offset,
|
|
179
177
|
length) == MLD_NATIVE_FUNC_SUCCESS)
|
|
180
178
|
{
|
|
181
179
|
return;
|
|
182
180
|
}
|
|
183
|
-
#endif /*
|
|
181
|
+
#endif /* MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES */
|
|
184
182
|
mld_keccakf1600x4_xor_bytes_c(state, data0, data1, data2, data3, offset,
|
|
185
183
|
length);
|
|
186
184
|
}
|
|
@@ -188,12 +186,12 @@ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
|
|
|
188
186
|
MLD_INTERNAL_API
|
|
189
187
|
void mld_keccakf1600x4_permute(uint64_t *state)
|
|
190
188
|
{
|
|
191
|
-
#if defined(
|
|
189
|
+
#if defined(MLD_USE_NATIVE_FIPS202_X4)
|
|
192
190
|
if (mld_keccak_f1600_x4_native(state) == MLD_NATIVE_FUNC_SUCCESS)
|
|
193
191
|
{
|
|
194
192
|
return;
|
|
195
193
|
}
|
|
196
|
-
#endif /*
|
|
194
|
+
#endif /* MLD_USE_NATIVE_FIPS202_X4 */
|
|
197
195
|
mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 0);
|
|
198
196
|
mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 1);
|
|
199
197
|
mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 2);
|
|
@@ -491,12 +489,12 @@ __contract__(
|
|
|
491
489
|
MLD_INTERNAL_API
|
|
492
490
|
void mld_keccakf1600_permute(uint64_t *state)
|
|
493
491
|
{
|
|
494
|
-
#if defined(
|
|
492
|
+
#if defined(MLD_USE_NATIVE_FIPS202_X1)
|
|
495
493
|
if (mld_keccak_f1600_x1_native(state) == MLD_NATIVE_FUNC_SUCCESS)
|
|
496
494
|
{
|
|
497
495
|
return;
|
|
498
496
|
}
|
|
499
|
-
#endif /*
|
|
497
|
+
#endif /* MLD_USE_NATIVE_FIPS202_X1 */
|
|
500
498
|
mld_keccakf1600_permute_c(state);
|
|
501
499
|
}
|
|
502
500
|
|
|
@@ -25,13 +25,15 @@
|
|
|
25
25
|
/*
|
|
26
26
|
* Keccak-f1600
|
|
27
27
|
*
|
|
28
|
-
* - On Arm-based Apple CPUs,
|
|
28
|
+
* - On Arm-based Apple CPUs, or CPUs with MLD_SYS_AARCH64_FAST_SHA3 set,
|
|
29
|
+
* we pick a pure Neon implementation.
|
|
29
30
|
* - Otherwise, unless MLD_SYS_AARCH64_SLOW_BARREL_SHIFTER is set,
|
|
30
31
|
* we use lazy-rotation scalar assembly from @[HYBRID].
|
|
31
32
|
* - Otherwise, if MLD_SYS_AARCH64_SLOW_BARREL_SHIFTER is set, we
|
|
32
33
|
* fall back to the standard C implementation.
|
|
33
34
|
*/
|
|
34
|
-
#if defined(__ARM_FEATURE_SHA3) &&
|
|
35
|
+
#if defined(__ARM_FEATURE_SHA3) && \
|
|
36
|
+
(defined(__APPLE__) || defined(MLD_SYS_AARCH64_FAST_SHA3))
|
|
35
37
|
#include "x1_v84a.h"
|
|
36
38
|
#elif !defined(MLD_SYS_AARCH64_SLOW_BARREL_SHIFTER)
|
|
37
39
|
#include "x1_scalar.h"
|
|
@@ -40,26 +42,30 @@
|
|
|
40
42
|
#if (!defined(MLD_CONFIG_NO_KEYPAIR_API) || \
|
|
41
43
|
!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_REDUCE_RAM)) && \
|
|
42
44
|
!defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
|
|
45
|
+
/* Batched, SIMD-based Keccak-f1600 implementations. */
|
|
46
|
+
#if defined(MLD_SYS_AARCH64_NEON)
|
|
47
|
+
|
|
43
48
|
/*
|
|
44
49
|
* Keccak-f1600x2/x4
|
|
45
50
|
*
|
|
46
51
|
* The optimal implementation is highly CPU-specific; see @[HYBRID].
|
|
47
52
|
*
|
|
48
53
|
* For now, if v8.4-A is not implemented, we fall back to Keccak-f1600.
|
|
49
|
-
* If v8.4-A is implemented and we are on an Apple CPU
|
|
50
|
-
* Neon-based implementation.
|
|
51
|
-
* If v8.4-A is implemented and we are
|
|
54
|
+
* If v8.4-A is implemented and we are on an Apple CPU (or a CPU with
|
|
55
|
+
* MLD_SYS_AARCH64_FAST_SHA3 set), we use a plain Neon-based implementation.
|
|
56
|
+
* If v8.4-A is implemented and we are on neither, we use a
|
|
52
57
|
* scalar/Neon/Neon hybrid.
|
|
53
|
-
* The reason for this distinction is that Apple CPUs
|
|
54
|
-
*
|
|
55
|
-
* don't, and ordinary Neon
|
|
58
|
+
* The reason for this distinction is that Apple CPUs (and other CPUs flagged
|
|
59
|
+
* via MLD_SYS_AARCH64_FAST_SHA3) appear to implement the SHA3 instructions on
|
|
60
|
+
* all SIMD units, while Arm CPUs prior to Cortex-X4 don't, and ordinary Neon
|
|
61
|
+
* instructions are still needed.
|
|
56
62
|
*/
|
|
57
63
|
#if defined(__ARM_FEATURE_SHA3)
|
|
58
64
|
/*
|
|
59
|
-
* For Apple-M cores
|
|
60
|
-
* instructions only.
|
|
65
|
+
* For Apple-M cores (and other cores flagged via MLD_SYS_AARCH64_FAST_SHA3),
|
|
66
|
+
* we use a plain implementation leveraging SHA3 instructions only.
|
|
61
67
|
*/
|
|
62
|
-
#if defined(__APPLE__)
|
|
68
|
+
#if defined(__APPLE__) || defined(MLD_SYS_AARCH64_FAST_SHA3)
|
|
63
69
|
#include "x2_v84a.h"
|
|
64
70
|
#else
|
|
65
71
|
#include "x4_v8a_v84a_scalar.h"
|
|
@@ -71,6 +77,8 @@
|
|
|
71
77
|
|
|
72
78
|
#endif /* !__ARM_FEATURE_SHA3 */
|
|
73
79
|
|
|
80
|
+
#endif /* MLD_SYS_AARCH64_NEON */
|
|
81
|
+
|
|
74
82
|
#endif /* (!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_NO_SIGN_API || \
|
|
75
83
|
!MLD_CONFIG_REDUCE_RAM) && !MLD_CONFIG_SERIAL_FIPS202_ONLY */
|
|
76
84
|
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
// Author: Matthias Kannwischer <matthias@kannwischer.eu>
|
|
11
11
|
|
|
12
12
|
/*yaml
|
|
13
|
-
Name:
|
|
13
|
+
Name: keccak_f1600_x1_scalar_aarch64_asm
|
|
14
14
|
Description: AArch64 scalar implementation of Keccak-f[1600] permutation for single state
|
|
15
15
|
Signature: void mld_keccak_f1600_x1_scalar_aarch64_asm(uint64_t state[25], const uint64_t rc[24])
|
|
16
16
|
ABI:
|
|
17
|
+
Architecture: aarch64
|
|
18
|
+
CallingConvention: AAPCS64
|
|
17
19
|
x0:
|
|
18
20
|
type: buffer
|
|
19
21
|
size_bytes: 200
|
|
@@ -67,7 +69,7 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x1_scalar_aarch64_asm)
|
|
|
67
69
|
.cfi_rel_offset x29, 0x70
|
|
68
70
|
.cfi_rel_offset x30, 0x78
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
Lmld_keccak_f1600_x1_scalar_initial:
|
|
71
73
|
mov x26, x1
|
|
72
74
|
str x1, [sp, #0x8]
|
|
73
75
|
ldp x1, x6, [x0]
|
|
@@ -192,7 +194,7 @@ Lkeccak_f1600_x1_scalar_initial:
|
|
|
192
194
|
eor x14, x26, x6, ror #46
|
|
193
195
|
eor x6, x27, x29, ror #41
|
|
194
196
|
|
|
195
|
-
|
|
197
|
+
Lmld_keccak_f1600_x1_scalar_loop:
|
|
196
198
|
eor x0, x15, x11, ror #52
|
|
197
199
|
eor x0, x0, x13, ror #48
|
|
198
200
|
eor x26, x8, x9, ror #57
|
|
@@ -305,7 +307,7 @@ Lkeccak_f1600_x1_scalar_loop:
|
|
|
305
307
|
bic x3, x0, x30, ror #5
|
|
306
308
|
eor x23, x3, x26, ror #52
|
|
307
309
|
eor x3, x29, x30, ror #24
|
|
308
|
-
b.le
|
|
310
|
+
b.le Lmld_keccak_f1600_x1_scalar_loop
|
|
309
311
|
ror x6, x6, #0x2b
|
|
310
312
|
ror x11, x11, #0x32
|
|
311
313
|
ror x21, x21, #0x14
|