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
|
@@ -100,30 +100,54 @@
|
|
|
100
100
|
/* #define MLK_CONFIG_EXTERNAL_API_QUALIFIER */
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
103
|
+
* MLK_CONFIG_NO_KEYPAIR_API
|
|
104
104
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
|
|
105
|
+
* By default, mlkem-native includes support for generating key pairs.
|
|
106
|
+
* If you don't need this, set MLK_CONFIG_NO_KEYPAIR_API to exclude
|
|
107
|
+
* keypair and keypair_derand, and all internal
|
|
108
|
+
* APIs only needed by those functions.
|
|
109
|
+
*/
|
|
110
|
+
/* #define MLK_CONFIG_NO_KEYPAIR_API */
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* MLK_CONFIG_NO_ENCAPS_API
|
|
110
114
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
115
|
+
* By default, mlkem-native includes support for encapsulation. If you
|
|
116
|
+
* don't need this, set MLK_CONFIG_NO_ENCAPS_API to exclude
|
|
117
|
+
* enc, enc_derand, check_pk, and
|
|
118
|
+
* all internal APIs only needed by those functions.
|
|
119
|
+
*
|
|
120
|
+
* @note Setting this option is incompatible with MLK_CONFIG_KEYGEN_PCT
|
|
121
|
+
* as the current PCT implementation requires enc().
|
|
113
122
|
*/
|
|
114
|
-
/* #define
|
|
123
|
+
/* #define MLK_CONFIG_NO_ENCAPS_API */
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* MLK_CONFIG_NO_DECAPS_API
|
|
127
|
+
*
|
|
128
|
+
* By default, mlkem-native includes support for decapsulation. If you
|
|
129
|
+
* don't need this, set MLK_CONFIG_NO_DECAPS_API to exclude
|
|
130
|
+
* dec, check_sk, and all internal APIs only
|
|
131
|
+
* needed by those functions.
|
|
132
|
+
*
|
|
133
|
+
* @note Setting this option is incompatible with MLK_CONFIG_KEYGEN_PCT
|
|
134
|
+
* as the current PCT implementation requires dec().
|
|
135
|
+
*/
|
|
136
|
+
/* #define MLK_CONFIG_NO_DECAPS_API */
|
|
115
137
|
|
|
116
138
|
/**
|
|
117
|
-
*
|
|
139
|
+
* MLK_CONFIG_NO_RANDOMIZED_API
|
|
118
140
|
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
141
|
+
* If this option is set, mlkem-native will be built without the randomized
|
|
142
|
+
* API functions (keypair and enc). This allows users
|
|
143
|
+
* to build mlkem-native without providing a randombytes() implementation
|
|
144
|
+
* if they only need the deterministic API (keypair_derand,
|
|
145
|
+
* enc_derand, dec).
|
|
122
146
|
*
|
|
123
|
-
* @note
|
|
124
|
-
*
|
|
147
|
+
* @note This option is incompatible with MLK_CONFIG_KEYGEN_PCT as the
|
|
148
|
+
* current PCT implementation requires enc().
|
|
125
149
|
*/
|
|
126
|
-
/* #define
|
|
150
|
+
/* #define MLK_CONFIG_NO_RANDOMIZED_API */
|
|
127
151
|
|
|
128
152
|
/**
|
|
129
153
|
* MLK_CONFIG_CONSTANTS_ONLY
|
|
@@ -292,7 +316,7 @@
|
|
|
292
316
|
* implementation, different from the one shipped with mlkem-native.
|
|
293
317
|
*
|
|
294
318
|
* If set, it must be the name of a file serving as the replacement for
|
|
295
|
-
* mlkem/fips202/fips202.h, and exposing the same API (see FIPS202.md).
|
|
319
|
+
* mlkem/src/fips202/fips202.h, and exposing the same API (see FIPS202.md).
|
|
296
320
|
*/
|
|
297
321
|
/* #define MLK_CONFIG_FIPS202_CUSTOM_HEADER "SOME_FILE.h" */
|
|
298
322
|
|
|
@@ -305,7 +329,7 @@
|
|
|
305
329
|
* implementation, different from the one shipped with mlkem-native.
|
|
306
330
|
*
|
|
307
331
|
* If set, it must be the name of a file serving as the replacement for
|
|
308
|
-
* mlkem/fips202/fips202x4.h, and exposing the same API (see FIPS202.md).
|
|
332
|
+
* mlkem/src/fips202/fips202x4.h, and exposing the same API (see FIPS202.md).
|
|
309
333
|
*/
|
|
310
334
|
/* #define MLK_CONFIG_FIPS202X4_CUSTOM_HEADER "SOME_FILE.h" */
|
|
311
335
|
|
|
@@ -313,25 +337,35 @@
|
|
|
313
337
|
* MLK_CONFIG_CUSTOM_ZEROIZE
|
|
314
338
|
*
|
|
315
339
|
* In compliance with @[FIPS203, Section 3.3], mlkem-native zeroizes
|
|
316
|
-
* intermediate
|
|
340
|
+
* intermediate buffers before returning from function calls. By default,
|
|
341
|
+
* those buffers are allocated from the stack; if MLK_CONFIG_CUSTOM_ALLOC_FREE
|
|
342
|
+
* is set, they are (mostly -- few exceptions remain at present) allocated from
|
|
343
|
+
* the configured custom allocator.
|
|
344
|
+
*
|
|
345
|
+
* mlkem-native also zeroizes caller-owned output buffers as needed to uphold
|
|
346
|
+
* the API convention that outputs be either unmodified or zeroized upon
|
|
347
|
+
* failure.
|
|
317
348
|
*
|
|
318
349
|
* Set this option and define `mlk_zeroize` if you want to use a custom
|
|
319
|
-
* method to zeroize intermediate
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
350
|
+
* method to zeroize intermediate and output buffers.
|
|
351
|
+
*
|
|
352
|
+
* The default implementation uses SecureZeroMemory on Windows and a
|
|
353
|
+
* memset + compiler barrier otherwise. If neither of those is available on
|
|
354
|
+
* the target platform, compilation will fail, and you will need to use
|
|
355
|
+
* MLK_CONFIG_CUSTOM_ZEROIZE to provide a custom implementation of
|
|
356
|
+
* `mlk_zeroize()`.
|
|
357
|
+
*
|
|
358
|
+
* @warning
|
|
359
|
+
* The zeroization conducted by mlkem-native reduces the likelihood of data
|
|
360
|
+
* leaking on the stack or custom allocators, but it does not eliminate it.
|
|
361
|
+
* For example, the C standard makes no guarantee about where a compiler
|
|
362
|
+
* allocates local structures and whether/where it makes copies of them.
|
|
363
|
+
* Also, in addition to entire structures, there may also be potentially
|
|
364
|
+
* exploitable leakage of individual values on the stack. If you need
|
|
365
|
+
* bullet-proof zeroization of the stack, you need to consider additional
|
|
366
|
+
* measures instead of what this feature provides. In this case, you can
|
|
367
|
+
* set mlk_zeroize to a no-op. Note that in this case you are also responsible
|
|
368
|
+
* for zeroizing output buffers upon failure.
|
|
335
369
|
*/
|
|
336
370
|
/* #define MLK_CONFIG_CUSTOM_ZEROIZE
|
|
337
371
|
#if !defined(__ASSEMBLER__)
|
|
@@ -422,7 +456,7 @@
|
|
|
422
456
|
*
|
|
423
457
|
* @warning This option is experimental. Its scope, configuration and
|
|
424
458
|
* function/macro signatures may change at any time. We expect a
|
|
425
|
-
* stable API
|
|
459
|
+
* stable API in a future version.
|
|
426
460
|
*
|
|
427
461
|
* @note Even if this option is set, some allocations further down the call
|
|
428
462
|
* stack will still be made from the stack, consuming up to 3KB of
|
|
@@ -549,8 +583,8 @@
|
|
|
549
583
|
* can be exported.
|
|
550
584
|
*
|
|
551
585
|
* Set this option if such a check should be implemented. In this case,
|
|
552
|
-
*
|
|
553
|
-
*
|
|
586
|
+
* keypair_derand and keypair will return
|
|
587
|
+
* MLK_ERR_PCT_FAIL if the PCT failed.
|
|
554
588
|
*
|
|
555
589
|
* @note This feature will drastically lower the performance of key
|
|
556
590
|
* generation.
|
|
@@ -634,7 +668,11 @@
|
|
|
634
668
|
* e.g., PQCP_MLKEM_NATIVE_MLKEM512_
|
|
635
669
|
*/
|
|
636
670
|
|
|
637
|
-
#if
|
|
671
|
+
#if defined(MLK_CONFIG_MULTILEVEL_BUILD)
|
|
672
|
+
/* In a multi-level build the parameter set is appended by the namespacing
|
|
673
|
+
* machinery, so the default prefix must not embed it. */
|
|
674
|
+
#define MLK_DEFAULT_NAMESPACE_PREFIX PQCP_MLKEM_NATIVE_MLKEM
|
|
675
|
+
#elif MLK_CONFIG_PARAMETER_SET == 512
|
|
638
676
|
#define MLK_DEFAULT_NAMESPACE_PREFIX PQCP_MLKEM_NATIVE_MLKEM512
|
|
639
677
|
#elif MLK_CONFIG_PARAMETER_SET == 768
|
|
640
678
|
#define MLK_DEFAULT_NAMESPACE_PREFIX PQCP_MLKEM_NATIVE_MLKEM768
|
|
@@ -180,8 +180,33 @@
|
|
|
180
180
|
|
|
181
181
|
#define array_unchanged_u64(array_var, N) \
|
|
182
182
|
array_unchanged_u64_core(CBMC_CONCAT(_cbmc_idx, __COUNTER__), 0, (N), (array_var))
|
|
183
|
+
|
|
184
|
+
#define array_unchanged_u8_core(qvar, array_var, N) \
|
|
185
|
+
forall(qvar, 0, (N), \
|
|
186
|
+
((array_var)[(qvar)]) == (old(* (uint8_t (*)[(N)])(array_var)))[(qvar)])
|
|
187
|
+
|
|
188
|
+
#define array_unchanged_u8(array_var, N) \
|
|
189
|
+
array_unchanged_u8_core(CBMC_CONCAT(_cbmc_idx, __COUNTER__), (array_var), (N))
|
|
190
|
+
|
|
191
|
+
#define array_zeroized_u8_core(qvar, array_var, N) \
|
|
192
|
+
forall(qvar, 0, (N), ((array_var)[(qvar)]) == 0)
|
|
193
|
+
|
|
194
|
+
#define array_zeroized_u8(array_var, N) \
|
|
195
|
+
array_zeroized_u8_core(CBMC_CONCAT(_cbmc_idx, __COUNTER__), (array_var), (N))
|
|
183
196
|
/* clang-format on */
|
|
184
197
|
|
|
198
|
+
/*
|
|
199
|
+
* Output-buffer discipline on failure, as documented in API-CONVENTIONS.md:
|
|
200
|
+
* when a function fails, each caller-owned output buffer is left either
|
|
201
|
+
* fully unchanged or fully zeroized -- never holding partially computed or
|
|
202
|
+
* stale data that could be mistaken for a valid result.
|
|
203
|
+
*
|
|
204
|
+
* Note the disjunction is over the buffer as a whole: it is not enough for
|
|
205
|
+
* each byte to be individually either unchanged or zero.
|
|
206
|
+
*/
|
|
207
|
+
#define array_unchanged_or_zeroized_u8(array_var, N) \
|
|
208
|
+
(array_unchanged_u8((array_var), (N)) || array_zeroized_u8((array_var), (N)))
|
|
209
|
+
|
|
185
210
|
/* Wrapper around array_bound operating on absolute values.
|
|
186
211
|
*
|
|
187
212
|
* The absolute value bound `k` is exclusive.
|
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
* Copyright (c) The mlkem-native project authors
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
/* References
|
|
7
|
+
* ==========
|
|
8
|
+
*
|
|
9
|
+
* - [FIPS140_3_IG]
|
|
10
|
+
* Implementation Guidance for FIPS 140-3 and the Cryptographic Module
|
|
11
|
+
* Validation Program
|
|
12
|
+
* National Institute of Standards and Technology
|
|
13
|
+
* https://csrc.nist.gov/projects/cryptographic-module-validation-program/fips-140-3-ig-announcements
|
|
14
|
+
*
|
|
15
|
+
* - [FIPS203]
|
|
16
|
+
* FIPS 203 Module-Lattice-Based Key-Encapsulation Mechanism Standard
|
|
17
|
+
* National Institute of Standards and Technology
|
|
18
|
+
* https://csrc.nist.gov/pubs/fips/203/final
|
|
19
|
+
*/
|
|
20
|
+
|
|
5
21
|
#ifndef MLK_COMMON_H
|
|
6
22
|
#define MLK_COMMON_H
|
|
7
23
|
|
|
@@ -64,7 +80,7 @@
|
|
|
64
80
|
#define MLK_NAMESPACE_K(s) MLK_CONCAT(MLK_NAMESPACE_PREFIX_K, s)
|
|
65
81
|
|
|
66
82
|
/* On Apple platforms, we need to emit leading underscore
|
|
67
|
-
* in front of assembly symbols. We thus
|
|
83
|
+
* in front of assembly symbols. We thus introduce a separate
|
|
68
84
|
* namespace wrapper for ASM symbols. */
|
|
69
85
|
#if !defined(__APPLE__)
|
|
70
86
|
#define MLK_ASM_NAMESPACE(sym) MLK_NAMESPACE(sym)
|
|
@@ -122,7 +138,15 @@
|
|
|
122
138
|
#endif
|
|
123
139
|
|
|
124
140
|
#if defined(MLK_CONFIG_NO_RANDOMIZED_API) && defined(MLK_CONFIG_KEYGEN_PCT)
|
|
125
|
-
#error Bad configuration: MLK_CONFIG_NO_RANDOMIZED_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires
|
|
141
|
+
#error Bad configuration: MLK_CONFIG_NO_RANDOMIZED_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires enc()
|
|
142
|
+
#endif
|
|
143
|
+
|
|
144
|
+
#if defined(MLK_CONFIG_NO_ENCAPS_API) && defined(MLK_CONFIG_KEYGEN_PCT)
|
|
145
|
+
#error Bad configuration: MLK_CONFIG_NO_ENCAPS_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires enc()
|
|
146
|
+
#endif
|
|
147
|
+
|
|
148
|
+
#if defined(MLK_CONFIG_NO_DECAPS_API) && defined(MLK_CONFIG_KEYGEN_PCT)
|
|
149
|
+
#error Bad configuration: MLK_CONFIG_NO_DECAPS_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires dec()
|
|
126
150
|
#endif
|
|
127
151
|
|
|
128
152
|
#if defined(MLK_CONFIG_USE_NATIVE_BACKEND_ARITH)
|
|
@@ -188,36 +212,11 @@
|
|
|
188
212
|
#error Bad configuration: MLK_CONFIG_CUSTOM_ALLOC_FREE must be set together with MLK_CUSTOM_ALLOC and MLK_CUSTOM_FREE
|
|
189
213
|
#endif
|
|
190
214
|
|
|
191
|
-
/*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
|
|
196
|
-
* defining the function names and expand to either pass or discard the context
|
|
197
|
-
* argument as required by the current build. If there is no context parameter
|
|
198
|
-
* requested then these are removed from the prototypes and from all calls.
|
|
199
|
-
*/
|
|
200
|
-
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
201
|
-
#define MLK_CONTEXT_PARAMETERS_0(context) (context)
|
|
202
|
-
#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
|
|
203
|
-
#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
|
|
204
|
-
#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
|
|
205
|
-
(arg0, arg1, arg2, context)
|
|
206
|
-
#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
207
|
-
(arg0, arg1, arg2, arg3, context)
|
|
208
|
-
#else /* MLK_CONFIG_CONTEXT_PARAMETER */
|
|
209
|
-
#define MLK_CONTEXT_PARAMETERS_0(context) ()
|
|
210
|
-
#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
|
|
211
|
-
#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
|
|
212
|
-
#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
|
|
213
|
-
#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
214
|
-
(arg0, arg1, arg2, arg3)
|
|
215
|
-
#endif /* !MLK_CONFIG_CONTEXT_PARAMETER */
|
|
216
|
-
|
|
217
|
-
#if defined(MLK_CONFIG_CONTEXT_PARAMETER_TYPE) != \
|
|
218
|
-
defined(MLK_CONFIG_CONTEXT_PARAMETER)
|
|
219
|
-
#error MLK_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLK_CONFIG_CONTEXT_PARAMETER is defined
|
|
220
|
-
#endif
|
|
215
|
+
/* Context-parameter machinery (MLK_CONTEXT_PARAMETERS_n and related config
|
|
216
|
+
* checks). Kept in a separate, level-generic header for readability; included
|
|
217
|
+
* here so it is available to the allocation macros below and to all consumers
|
|
218
|
+
* of common.h. */
|
|
219
|
+
#include "context.h"
|
|
221
220
|
|
|
222
221
|
#if !defined(MLK_CONFIG_CUSTOM_ALLOC_FREE)
|
|
223
222
|
/* Default: stack allocation */
|
|
@@ -237,6 +236,7 @@
|
|
|
237
236
|
#define MLK_FREE(v, T, N, context) \
|
|
238
237
|
do \
|
|
239
238
|
{ \
|
|
239
|
+
MLK_CONTEXT_UNUSED(context); \
|
|
240
240
|
mlk_zeroize(mlk_alloc_##v, sizeof(mlk_alloc_##v)); \
|
|
241
241
|
(v) = NULL; \
|
|
242
242
|
} while (0)
|
|
@@ -268,14 +268,28 @@
|
|
|
268
268
|
|
|
269
269
|
/****************************** Error codes ***********************************/
|
|
270
270
|
|
|
271
|
-
/* Generic failure condition
|
|
271
|
+
/* Generic failure condition. Currently not returned by any function;
|
|
272
|
+
* reserved for failures that no more specific code covers. */
|
|
272
273
|
#define MLK_ERR_FAIL (-1)
|
|
273
274
|
/* An allocation failed. This can only happen if MLK_CONFIG_CUSTOM_ALLOC_FREE
|
|
274
275
|
* is defined and the provided MLK_CUSTOM_ALLOC can fail. */
|
|
275
276
|
#define MLK_ERR_OUT_OF_MEMORY (-2)
|
|
276
|
-
/* An
|
|
277
|
+
/* An RNG failure occurred. Might be due to insufficient entropy or
|
|
277
278
|
* system misconfiguration. */
|
|
278
279
|
#define MLK_ERR_RNG_FAIL (-3)
|
|
280
|
+
/* Public key validation failed: the @[FIPS203, Section 7.2, 'modulus check']
|
|
281
|
+
* found a coefficient outside [0,q-1]. Returned by check_pk and by the
|
|
282
|
+
* encapsulation API. */
|
|
283
|
+
#define MLK_ERR_INVALID_PK (-4)
|
|
284
|
+
/* Secret key validation failed: the @[FIPS203, Section 7.3, 'hash check']
|
|
285
|
+
* found the embedded public key hash inconsistent. Returned by check_sk and
|
|
286
|
+
* by the decapsulation API. */
|
|
287
|
+
#define MLK_ERR_INVALID_SK (-5)
|
|
288
|
+
/* The 'Pairwise Consistency Test' @[FIPS140_3_IG, p.87] and
|
|
289
|
+
* @[FIPS203, Section 7.1, Pairwise Consistency] failed. Only possible when
|
|
290
|
+
* MLK_CONFIG_KEYGEN_PCT is enabled; signals that the freshly generated key
|
|
291
|
+
* pair failed its encaps/decaps self-test. */
|
|
292
|
+
#define MLK_ERR_PCT_FAIL (-6)
|
|
279
293
|
|
|
280
294
|
#endif /* !__ASSEMBLER__ */
|
|
281
295
|
|
|
@@ -26,7 +26,10 @@
|
|
|
26
26
|
#include "debug.h"
|
|
27
27
|
#include "verify.h"
|
|
28
28
|
|
|
29
|
-
#if defined(
|
|
29
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
30
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
31
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
32
|
+
MLKEM_K == 3)
|
|
30
33
|
/* Reference: `poly_compress()` in the reference implementation @[REF],
|
|
31
34
|
* for ML-KEM-{512,768}.
|
|
32
35
|
* - In contrast to the reference implementation, we assume
|
|
@@ -158,6 +161,7 @@ __contract__(
|
|
|
158
161
|
mlk_poly_compress_d10_c(r, a);
|
|
159
162
|
}
|
|
160
163
|
|
|
164
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
161
165
|
/* Reference: `poly_decompress()` in the reference implementation @[REF],
|
|
162
166
|
* for ML-KEM-{512,768}. */
|
|
163
167
|
MLK_STATIC_TESTABLE void mlk_poly_decompress_d4_c(
|
|
@@ -268,9 +272,14 @@ __contract__(
|
|
|
268
272
|
|
|
269
273
|
mlk_poly_decompress_d10_c(r, a);
|
|
270
274
|
}
|
|
271
|
-
#endif /*
|
|
272
|
-
|
|
273
|
-
|
|
275
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
276
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
277
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3) \
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
281
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
282
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
274
283
|
/* Reference: `poly_compress()` in the reference implementation @[REF],
|
|
275
284
|
* for ML-KEM-1024.
|
|
276
285
|
* - In contrast to the reference implementation, we assume
|
|
@@ -409,6 +418,7 @@ __contract__(
|
|
|
409
418
|
mlk_poly_compress_d11_c(r, a);
|
|
410
419
|
}
|
|
411
420
|
|
|
421
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
412
422
|
/* Reference: `poly_decompress()` in the reference implementation @[REF],
|
|
413
423
|
* for ML-KEM-1024. */
|
|
414
424
|
MLK_STATIC_TESTABLE void mlk_poly_decompress_d5_c(
|
|
@@ -554,8 +564,11 @@ __contract__(
|
|
|
554
564
|
mlk_poly_decompress_d11_c(r, a);
|
|
555
565
|
}
|
|
556
566
|
|
|
557
|
-
#endif /*
|
|
567
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
568
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
569
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
|
|
558
570
|
|
|
571
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) || !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
559
572
|
/* Reference: `poly_tobytes()` in the reference implementation @[REF].
|
|
560
573
|
* - In contrast to the reference implementation, we assume
|
|
561
574
|
* unsigned canonical coefficients here.
|
|
@@ -620,7 +633,9 @@ void mlk_poly_tobytes(uint8_t r[MLKEM_POLYBYTES], const mlk_poly *a)
|
|
|
620
633
|
|
|
621
634
|
mlk_poly_tobytes_c(r, a);
|
|
622
635
|
}
|
|
636
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API */
|
|
623
637
|
|
|
638
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
624
639
|
/* Reference: `poly_frombytes()` in the reference implementation @[REF]. */
|
|
625
640
|
MLK_STATIC_TESTABLE void mlk_poly_frombytes_c(mlk_poly *r,
|
|
626
641
|
const uint8_t a[MLKEM_POLYBYTES])
|
|
@@ -668,7 +683,9 @@ void mlk_poly_frombytes(mlk_poly *r, const uint8_t a[MLKEM_POLYBYTES])
|
|
|
668
683
|
|
|
669
684
|
mlk_poly_frombytes_c(r, a);
|
|
670
685
|
}
|
|
686
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
671
687
|
|
|
688
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
672
689
|
/* Reference: `poly_frommsg()` in the reference implementation @[REF].
|
|
673
690
|
* - We use a value barrier around the bit-selection mask to
|
|
674
691
|
* reduce the risk of compiler-introduced branches.
|
|
@@ -706,7 +723,9 @@ void mlk_poly_frommsg(mlk_poly *r, const uint8_t msg[MLKEM_INDCPA_MSGBYTES])
|
|
|
706
723
|
}
|
|
707
724
|
mlk_assert_abs_bound(r, MLKEM_N, MLKEM_Q);
|
|
708
725
|
}
|
|
726
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
709
727
|
|
|
728
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
710
729
|
/* Reference: `poly_tomsg()` in the reference implementation @[REF].
|
|
711
730
|
* - In contrast to the reference implementation, we assume
|
|
712
731
|
* unsigned canonical coefficients here.
|
|
@@ -735,6 +754,7 @@ void mlk_poly_tomsg(uint8_t msg[MLKEM_INDCPA_MSGBYTES], const mlk_poly *r)
|
|
|
735
754
|
}
|
|
736
755
|
}
|
|
737
756
|
}
|
|
757
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
738
758
|
|
|
739
759
|
#else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
740
760
|
|
|
@@ -333,6 +333,7 @@ __contract__(
|
|
|
333
333
|
return (int16_t)((((uint32_t)u * MLKEM_Q) + 1024) >> 11);
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
336
337
|
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || (MLKEM_K == 2 || MLKEM_K == 3)
|
|
337
338
|
#define mlk_poly_compress_d4 MLK_NAMESPACE(poly_compress_d4)
|
|
338
339
|
/**
|
|
@@ -374,6 +375,7 @@ MLK_INTERNAL_API
|
|
|
374
375
|
void mlk_poly_compress_d10(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D10],
|
|
375
376
|
const mlk_poly *a);
|
|
376
377
|
|
|
378
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
377
379
|
#define mlk_poly_decompress_d4 MLK_NAMESPACE(poly_decompress_d4)
|
|
378
380
|
/**
|
|
379
381
|
* De-serialization and subsequent decompression (4 bits) of a polynomial;
|
|
@@ -419,6 +421,7 @@ void mlk_poly_decompress_d4(mlk_poly *r,
|
|
|
419
421
|
MLK_INTERNAL_API
|
|
420
422
|
void mlk_poly_decompress_d10(mlk_poly *r,
|
|
421
423
|
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D10]);
|
|
424
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
422
425
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3 */
|
|
423
426
|
|
|
424
427
|
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4
|
|
@@ -462,6 +465,7 @@ MLK_INTERNAL_API
|
|
|
462
465
|
void mlk_poly_compress_d11(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D11],
|
|
463
466
|
const mlk_poly *a);
|
|
464
467
|
|
|
468
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
465
469
|
#define mlk_poly_decompress_d5 MLK_NAMESPACE(poly_decompress_d5)
|
|
466
470
|
/**
|
|
467
471
|
* De-serialization and subsequent decompression (5 bits) of a polynomial;
|
|
@@ -507,8 +511,11 @@ void mlk_poly_decompress_d5(mlk_poly *r,
|
|
|
507
511
|
MLK_INTERNAL_API
|
|
508
512
|
void mlk_poly_decompress_d11(mlk_poly *r,
|
|
509
513
|
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D11]);
|
|
514
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
510
515
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
516
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
511
517
|
|
|
518
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) || !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
512
519
|
#define mlk_poly_tobytes MLK_NAMESPACE(poly_tobytes)
|
|
513
520
|
/**
|
|
514
521
|
* Serialization of a polynomial. Signed coefficients are converted to
|
|
@@ -529,8 +536,10 @@ __contract__(
|
|
|
529
536
|
requires(array_bound(a->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
|
|
530
537
|
assigns(memory_slice(r, MLKEM_POLYBYTES))
|
|
531
538
|
);
|
|
539
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API */
|
|
532
540
|
|
|
533
541
|
|
|
542
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
534
543
|
#define mlk_poly_frombytes MLK_NAMESPACE(poly_frombytes)
|
|
535
544
|
/**
|
|
536
545
|
* De-serialization of a polynomial.
|
|
@@ -550,8 +559,10 @@ __contract__(
|
|
|
550
559
|
assigns(memory_slice(r, sizeof(mlk_poly)))
|
|
551
560
|
ensures(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT))
|
|
552
561
|
);
|
|
562
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
553
563
|
|
|
554
564
|
|
|
565
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
555
566
|
#define mlk_poly_frommsg MLK_NAMESPACE(poly_frommsg)
|
|
556
567
|
/**
|
|
557
568
|
* Convert a 32-byte message to a polynomial.
|
|
@@ -573,7 +584,9 @@ __contract__(
|
|
|
573
584
|
assigns(memory_slice(r, sizeof(mlk_poly)))
|
|
574
585
|
ensures(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
|
|
575
586
|
);
|
|
587
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
576
588
|
|
|
589
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
577
590
|
#define mlk_poly_tomsg MLK_NAMESPACE(poly_tomsg)
|
|
578
591
|
/**
|
|
579
592
|
* Convert a polynomial to a 32-byte message.
|
|
@@ -595,5 +608,6 @@ __contract__(
|
|
|
595
608
|
requires(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
|
|
596
609
|
assigns(memory_slice(msg, MLKEM_INDCPA_MSGBYTES))
|
|
597
610
|
);
|
|
611
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
598
612
|
|
|
599
613
|
#endif /* !MLK_COMPRESS_H */
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
#ifndef MLK_CONTEXT_H
|
|
6
|
+
#define MLK_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
|
+
|
|
11
|
+
/*
|
|
12
|
+
* If the integration wants to provide a context parameter for use in
|
|
13
|
+
* platform-specific hooks, then it should define this parameter.
|
|
14
|
+
*
|
|
15
|
+
* The MLK_CONTEXT_PARAMETERS_n macros are intended to be used with macros
|
|
16
|
+
* defining the function names and expand to either pass or discard the context
|
|
17
|
+
* argument as required by the current build. If there is no context parameter
|
|
18
|
+
* requested then these are removed from the prototypes and from all calls.
|
|
19
|
+
*/
|
|
20
|
+
#ifdef MLK_CONFIG_CONTEXT_PARAMETER
|
|
21
|
+
#define MLK_CONTEXT_PARAMETERS_0(context) (context)
|
|
22
|
+
#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
|
|
23
|
+
#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
|
|
24
|
+
#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
|
|
25
|
+
(arg0, arg1, arg2, context)
|
|
26
|
+
#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
27
|
+
(arg0, arg1, arg2, arg3, context)
|
|
28
|
+
#else /* MLK_CONFIG_CONTEXT_PARAMETER */
|
|
29
|
+
#define MLK_CONTEXT_PARAMETERS_0(context) ()
|
|
30
|
+
#define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
|
|
31
|
+
#define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
|
|
32
|
+
#define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
|
|
33
|
+
#define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
|
|
34
|
+
(arg0, arg1, arg2, arg3)
|
|
35
|
+
#endif /* !MLK_CONFIG_CONTEXT_PARAMETER */
|
|
36
|
+
|
|
37
|
+
/* Consume a context parameter carried only for the integration's benefit,
|
|
38
|
+
* avoiding -Wunused-parameter; expands to nothing when no context is
|
|
39
|
+
* configured. */
|
|
40
|
+
#if defined(MLK_CONFIG_CONTEXT_PARAMETER)
|
|
41
|
+
#define MLK_CONTEXT_UNUSED(context) ((void)(context))
|
|
42
|
+
#else
|
|
43
|
+
#define MLK_CONTEXT_UNUSED(context) ((void)0)
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
#if defined(MLK_CONFIG_CONTEXT_PARAMETER_TYPE) != \
|
|
47
|
+
defined(MLK_CONFIG_CONTEXT_PARAMETER)
|
|
48
|
+
#error MLK_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLK_CONFIG_CONTEXT_PARAMETER is defined
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
#endif /* !MLK_CONTEXT_H */
|
|
@@ -132,12 +132,12 @@ __contract__(
|
|
|
132
132
|
);
|
|
133
133
|
|
|
134
134
|
#if !defined(MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202) || \
|
|
135
|
-
!defined(
|
|
135
|
+
!defined(MLK_USE_NATIVE_FIPS202_X4)
|
|
136
136
|
/* If you provide your own FIPS-202 implementation where the x4-
|
|
137
137
|
* Keccak-f1600-x4 implementation falls back to 4-fold Keccak-f1600,
|
|
138
138
|
* set this to gain a small speedup. */
|
|
139
139
|
#define FIPS202_X4_DEFAULT_IMPLEMENTATION
|
|
140
|
-
#endif /* !MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 || !
|
|
140
|
+
#endif /* !MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 || !MLK_USE_NATIVE_FIPS202_X4 \
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
143
|
|
|
@@ -115,14 +115,14 @@ void mlk_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
|
|
|
115
115
|
unsigned char *data3, unsigned offset,
|
|
116
116
|
unsigned length)
|
|
117
117
|
{
|
|
118
|
-
#if defined(
|
|
118
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES)
|
|
119
119
|
if (mlk_keccakf1600_extract_bytes_x4_native(state, data0, data1, data2, data3,
|
|
120
120
|
offset, length) ==
|
|
121
121
|
MLK_NATIVE_FUNC_SUCCESS)
|
|
122
122
|
{
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
#endif /*
|
|
125
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES */
|
|
126
126
|
mlk_keccakf1600x4_extract_bytes_c(state, data0, data1, data2, data3, offset,
|
|
127
127
|
length);
|
|
128
128
|
}
|
|
@@ -164,26 +164,26 @@ void mlk_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
|
|
|
164
164
|
const unsigned char *data3, unsigned offset,
|
|
165
165
|
unsigned length)
|
|
166
166
|
{
|
|
167
|
-
#if defined(
|
|
167
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES)
|
|
168
168
|
if (mlk_keccakf1600_xor_bytes_x4_native(state, data0, data1, data2, data3,
|
|
169
169
|
offset,
|
|
170
170
|
length) == MLK_NATIVE_FUNC_SUCCESS)
|
|
171
171
|
{
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
-
#endif /*
|
|
174
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES */
|
|
175
175
|
mlk_keccakf1600x4_xor_bytes_c(state, data0, data1, data2, data3, offset,
|
|
176
176
|
length);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
void mlk_keccakf1600x4_permute(uint64_t *state)
|
|
180
180
|
{
|
|
181
|
-
#if defined(
|
|
181
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X4)
|
|
182
182
|
if (mlk_keccak_f1600_x4_native(state) == MLK_NATIVE_FUNC_SUCCESS)
|
|
183
183
|
{
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
-
#endif /*
|
|
186
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X4 */
|
|
187
187
|
mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 0);
|
|
188
188
|
mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 1);
|
|
189
189
|
mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 2);
|
|
@@ -478,12 +478,12 @@ __contract__(
|
|
|
478
478
|
|
|
479
479
|
void mlk_keccakf1600_permute(uint64_t *state)
|
|
480
480
|
{
|
|
481
|
-
#if defined(
|
|
481
|
+
#if defined(MLK_USE_NATIVE_FIPS202_X1)
|
|
482
482
|
if (mlk_keccak_f1600_x1_native(state) == MLK_NATIVE_FUNC_SUCCESS)
|
|
483
483
|
{
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
|
-
#endif /*
|
|
486
|
+
#endif /* MLK_USE_NATIVE_FIPS202_X1 */
|
|
487
487
|
mlk_keccakf1600_permute_c(state);
|
|
488
488
|
}
|
|
489
489
|
|