pq_crypto 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +1 -3
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +71 -0
- data/ext/pqcrypto/vendor/mldsa-native/README.md +26 -11
- data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +77 -150
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +93 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +74 -59
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +106 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +94 -92
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/capability.h +31 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +55 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +12 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +3 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/auto.h +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +574 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +679 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +5 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +110 -120
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +109 -101
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +97 -93
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +1 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +4 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/fastmul.h +74 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/slowmul.h +77 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/arith_native_rv32im.h +124 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_asm.S +331 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_slowmul_asm.S +381 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_asm.S +304 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_slowmul_asm.S +351 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_poly_pointwise_montgomery_rv32im_asm.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/rv32im_zetas.c +118 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +6 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +2 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +12 -16
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +14 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +23 -27
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +21 -42
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +28 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +87 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +61 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +23 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +55 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +67 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +16 -24
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +27 -21
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +8 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +191 -119
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +16 -42
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +72 -0
- data/ext/pqcrypto/vendor/mlkem-native/README.md +9 -5
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +64 -312
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -34
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +41 -13
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +89 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +50 -46
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/capability.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +4 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +15 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +23 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +11 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +7 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/auto.h +47 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +573 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +678 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +1 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +29 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +156 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +137 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/compress_d5_table.c +43 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d10_table.c +50 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d11_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d4_table.c +44 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d5_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_intt_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d10_aarch64_asm.S +439 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d11_aarch64_asm.S +452 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d4_aarch64_asm.S +106 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d5_aarch64_asm.S +124 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d10_aarch64_asm.S +108 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d11_aarch64_asm.S +116 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d4_aarch64_asm.S +93 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d5_aarch64_asm.S +104 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_frombytes_aarch64_asm.S +84 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_mulcache_compute_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_reduce_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tobytes_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tomont_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_rej_uniform_aarch64_asm.S +112 -104
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +0 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +16 -21
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_intt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_ntt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_reduce_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +5 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +5 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_intt_avx2_asm.S +36 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntt_avx2_asm.S +67 -65
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttfrombytes_avx2_asm.S +8 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntttobytes_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d10_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d11_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d4_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S +118 -115
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S +174 -171
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S +230 -227
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_reduce_avx2_asm.S +17 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_rej_uniform_avx2_asm.S +7 -6
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_tomont_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +4 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +31 -44
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +1 -1
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +36 -1
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
#define MLK_COMMON_H
|
|
23
23
|
|
|
24
24
|
#ifndef __ASSEMBLER__
|
|
25
|
+
#include <stddef.h>
|
|
25
26
|
#include <stdint.h>
|
|
26
27
|
#endif
|
|
27
28
|
|
|
@@ -33,9 +34,31 @@
|
|
|
33
34
|
#include "mlkem_native_config.h"
|
|
34
35
|
#endif
|
|
35
36
|
|
|
37
|
+
#include "capability.h"
|
|
36
38
|
#include "params.h"
|
|
37
39
|
#include "sys.h"
|
|
38
40
|
|
|
41
|
+
#if !defined(MLK_CONFIG_NO_ASM) && (defined(__GNUC__) || defined(__clang__))
|
|
42
|
+
#define MLK_HAVE_INLINE_ASM
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#if defined(MLK_CONFIG_CT_TESTING_ENABLED) && !defined(__ASSEMBLER__)
|
|
46
|
+
#include <valgrind/memcheck.h>
|
|
47
|
+
#define MLK_CT_TESTING_SECRET(ptr, len) \
|
|
48
|
+
VALGRIND_MAKE_MEM_UNDEFINED((ptr), (len))
|
|
49
|
+
#define MLK_CT_TESTING_DECLASSIFY(ptr, len) \
|
|
50
|
+
VALGRIND_MAKE_MEM_DEFINED((ptr), (len))
|
|
51
|
+
#else /* MLK_CONFIG_CT_TESTING_ENABLED && !__ASSEMBLER__ */
|
|
52
|
+
#define MLK_CT_TESTING_SECRET(ptr, len) \
|
|
53
|
+
do \
|
|
54
|
+
{ \
|
|
55
|
+
} while (0)
|
|
56
|
+
#define MLK_CT_TESTING_DECLASSIFY(ptr, len) \
|
|
57
|
+
do \
|
|
58
|
+
{ \
|
|
59
|
+
} while (0)
|
|
60
|
+
#endif /* !(MLK_CONFIG_CT_TESTING_ENABLED && !__ASSEMBLER__) */
|
|
61
|
+
|
|
39
62
|
/* Internal and public API have external linkage by default, but
|
|
40
63
|
* this can be overwritten by the user, e.g. for single-CU builds. */
|
|
41
64
|
#if !defined(MLK_CONFIG_INTERNAL_API_QUALIFIER)
|
|
@@ -201,11 +224,18 @@
|
|
|
201
224
|
/* Allocation macros for large local structures
|
|
202
225
|
*
|
|
203
226
|
* MLK_ALLOC(v, T, N) declares T *v and attempts to point it to an T[N]
|
|
227
|
+
* Additionally, if non-NULL, the value of v must respect
|
|
228
|
+
* MLK_DEFAULT_ALIGN alignment
|
|
204
229
|
* MLK_FREE(v, T, N) zeroizes and frees the allocation
|
|
205
230
|
*
|
|
206
231
|
* Default implementation uses stack allocation.
|
|
207
232
|
* Can be overridden by setting the config option MLK_CONFIG_CUSTOM_ALLOC_FREE
|
|
208
233
|
* and defining MLK_CUSTOM_ALLOC and MLK_CUSTOM_FREE.
|
|
234
|
+
*
|
|
235
|
+
* Plain malloc() does not guarantee MLK_DEFAULT_ALIGN alignment.
|
|
236
|
+
* For examples of custom allocators that meet this requirement, see
|
|
237
|
+
* test/configs/custom_heap_alloc_config.h or the allocator in
|
|
238
|
+
* test/src/test_alloc.c configured by test/configs/test_alloc_config.h.
|
|
209
239
|
*/
|
|
210
240
|
#if defined(MLK_CONFIG_CUSTOM_ALLOC_FREE) != \
|
|
211
241
|
(defined(MLK_CUSTOM_ALLOC) && defined(MLK_CUSTOM_FREE))
|
|
@@ -677,6 +677,7 @@ void mlk_poly_frombytes(mlk_poly *r, const uint8_t a[MLKEM_POLYBYTES])
|
|
|
677
677
|
ret = mlk_poly_frombytes_native(r->coeffs, a);
|
|
678
678
|
if (ret == MLK_NATIVE_FUNC_SUCCESS)
|
|
679
679
|
{
|
|
680
|
+
mlk_assert_bound(r, MLKEM_N, 0, MLKEM_UINT12_LIMIT);
|
|
680
681
|
return;
|
|
681
682
|
}
|
|
682
683
|
#endif /* MLK_USE_NATIVE_POLY_FROMBYTES */
|
|
@@ -127,7 +127,7 @@ __contract__(
|
|
|
127
127
|
static MLK_INLINE int16_t mlk_scalar_decompress_d4(uint8_t u)
|
|
128
128
|
__contract__(
|
|
129
129
|
requires(0 <= u && u < 16)
|
|
130
|
-
ensures(return_value <= (MLKEM_Q - 1))
|
|
130
|
+
ensures(0 <= return_value && return_value <= (MLKEM_Q - 1))
|
|
131
131
|
)
|
|
132
132
|
{
|
|
133
133
|
/* The return value is in 0..MLKEM_Q-1, hence not altered by the
|
|
@@ -518,8 +518,7 @@ void mlk_poly_decompress_d11(mlk_poly *r,
|
|
|
518
518
|
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) || !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
519
519
|
#define mlk_poly_tobytes MLK_NAMESPACE(poly_tobytes)
|
|
520
520
|
/**
|
|
521
|
-
* Serialization of a polynomial.
|
|
522
|
-
* unsigned form before serialization.
|
|
521
|
+
* Serialization of a polynomial.
|
|
523
522
|
*
|
|
524
523
|
* @spec{Implements ByteEncode_12 @[FIPS203, Algorithm 5]. Extended to
|
|
525
524
|
* vectors as per @[FIPS203, 2.4.8 Applying Algorithms to Arrays].}
|
|
@@ -570,7 +569,7 @@ __contract__(
|
|
|
570
569
|
* @spec{Implements `Decompress_1 (ByteDecode_1 (a))`: ByteDecode_d
|
|
571
570
|
* @[FIPS203, Algorithm 6], Decompress_d @[FIPS203, Eq (4.8)], extended to
|
|
572
571
|
* vectors as per @[FIPS203, 2.4.8 Applying Algorithms to Arrays].
|
|
573
|
-
* `Decompress_1 (ByteDecode_1 (w))` appears in @[FIPS203, Algorithm
|
|
572
|
+
* `Decompress_1 (ByteDecode_1 (w))` appears in @[FIPS203, Algorithm 14
|
|
574
573
|
* (K-PKE.Encrypt), L20].}
|
|
575
574
|
*
|
|
576
575
|
* @param[out] r Output polynomial.
|
|
@@ -594,7 +593,7 @@ __contract__(
|
|
|
594
593
|
* @spec{Implements `ByteEncode_1 (Compress_1 (a))`: ByteEncode_d
|
|
595
594
|
* @[FIPS203, Algorithm 5], Compress_d @[FIPS203, Eq (4.7)], extended to
|
|
596
595
|
* vectors as per @[FIPS203, 2.4.8 Applying Algorithms to Arrays].
|
|
597
|
-
* `ByteEncode_1 (Compress_1 (w))` appears in @[FIPS203, Algorithm
|
|
596
|
+
* `ByteEncode_1 (Compress_1 (w))` appears in @[FIPS203, Algorithm 15
|
|
598
597
|
* (K-PKE.Decrypt), L7].}
|
|
599
598
|
*
|
|
600
599
|
* @param[out] msg Output message.
|
|
@@ -184,19 +184,23 @@ __contract__(
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
MLK_INTERNAL_API
|
|
187
188
|
void mlk_shake128_absorb_once(mlk_shake128ctx *state, const uint8_t *input,
|
|
188
189
|
size_t inlen)
|
|
189
190
|
{
|
|
190
191
|
mlk_keccak_absorb_once(state->ctx, SHAKE128_RATE, input, inlen, 0x1F);
|
|
191
192
|
}
|
|
192
193
|
|
|
194
|
+
MLK_INTERNAL_API
|
|
193
195
|
void mlk_shake128_squeezeblocks(uint8_t *output, size_t nblocks,
|
|
194
196
|
mlk_shake128ctx *state)
|
|
195
197
|
{
|
|
196
198
|
mlk_keccak_squeezeblocks(output, nblocks, state->ctx, SHAKE128_RATE);
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
MLK_INTERNAL_API
|
|
199
202
|
void mlk_shake128_init(mlk_shake128ctx *state) { (void)state; }
|
|
203
|
+
MLK_INTERNAL_API
|
|
200
204
|
void mlk_shake128_release(mlk_shake128ctx *state)
|
|
201
205
|
{
|
|
202
206
|
/* Specification: Partially implements
|
|
@@ -204,7 +208,15 @@ void mlk_shake128_release(mlk_shake128ctx *state)
|
|
|
204
208
|
mlk_zeroize(state, sizeof(mlk_shake128ctx));
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API) || \
|
|
212
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) && \
|
|
213
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
214
|
+
MLKEM_K == 4)) || \
|
|
215
|
+
(defined(MLK_CONFIG_SERIAL_FIPS202_ONLY) && \
|
|
216
|
+
(!defined(MLK_CONFIG_NO_KEYPAIR_API) || \
|
|
217
|
+
!defined(MLK_CONFIG_NO_ENCAPS_API)))
|
|
207
218
|
typedef mlk_shake128ctx mlk_shake256ctx;
|
|
219
|
+
MLK_INTERNAL_API
|
|
208
220
|
void mlk_shake256(uint8_t *output, size_t outlen, const uint8_t *input,
|
|
209
221
|
size_t inlen)
|
|
210
222
|
{
|
|
@@ -217,7 +229,9 @@ void mlk_shake256(uint8_t *output, size_t outlen, const uint8_t *input,
|
|
|
217
229
|
* @[FIPS203, Section 3.3, Destruction of intermediate values] */
|
|
218
230
|
mlk_zeroize(&state, sizeof(state));
|
|
219
231
|
}
|
|
232
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API || (!MLK_CONFIG_NO_ENCAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 4)) || (MLK_CONFIG_SERIAL_FIPS202_ONLY && (!MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API)) */
|
|
220
233
|
|
|
234
|
+
MLK_INTERNAL_API
|
|
221
235
|
void mlk_sha3_256(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
222
236
|
{
|
|
223
237
|
uint64_t ctx[25];
|
|
@@ -230,6 +244,7 @@ void mlk_sha3_256(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
|
230
244
|
mlk_zeroize(ctx, sizeof(ctx));
|
|
231
245
|
}
|
|
232
246
|
|
|
247
|
+
MLK_INTERNAL_API
|
|
233
248
|
void mlk_sha3_512(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
234
249
|
{
|
|
235
250
|
uint64_t ctx[25];
|
|
@@ -38,6 +38,7 @@ typedef struct
|
|
|
38
38
|
* @param[in] input Input to be absorbed into the state.
|
|
39
39
|
* @param inlen Length of input in bytes.
|
|
40
40
|
*/
|
|
41
|
+
MLK_INTERNAL_API
|
|
41
42
|
void mlk_shake128_absorb_once(mlk_shake128ctx *state, const uint8_t *input,
|
|
42
43
|
size_t inlen)
|
|
43
44
|
__contract__(
|
|
@@ -57,6 +58,7 @@ __contract__(
|
|
|
57
58
|
* @param nblocks Number of blocks to be squeezed (written to output).
|
|
58
59
|
* @param[in,out] state Keccak state.
|
|
59
60
|
*/
|
|
61
|
+
MLK_INTERNAL_API
|
|
60
62
|
void mlk_shake128_squeezeblocks(uint8_t *output, size_t nblocks,
|
|
61
63
|
mlk_shake128ctx *state)
|
|
62
64
|
__contract__(
|
|
@@ -67,11 +69,25 @@ __contract__(
|
|
|
67
69
|
);
|
|
68
70
|
|
|
69
71
|
#define mlk_shake128_init MLK_NAMESPACE(shake128_init)
|
|
72
|
+
MLK_INTERNAL_API
|
|
70
73
|
void mlk_shake128_init(mlk_shake128ctx *state);
|
|
71
74
|
|
|
72
75
|
#define mlk_shake128_release MLK_NAMESPACE(shake128_release)
|
|
76
|
+
MLK_INTERNAL_API
|
|
73
77
|
void mlk_shake128_release(mlk_shake128ctx *state);
|
|
74
78
|
|
|
79
|
+
/* mlk_shake256 is only used
|
|
80
|
+
* - in decapsulation, for the implicit rejection hash J,
|
|
81
|
+
* - in encapsulation for ML-KEM-512 and ML-KEM-1024, for sampling e2,
|
|
82
|
+
* - in key generation and encapsulation, if MLK_CONFIG_SERIAL_FIPS202_ONLY
|
|
83
|
+
* is set. */
|
|
84
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API) || \
|
|
85
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) && \
|
|
86
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
87
|
+
MLKEM_K == 4)) || \
|
|
88
|
+
(defined(MLK_CONFIG_SERIAL_FIPS202_ONLY) && \
|
|
89
|
+
(!defined(MLK_CONFIG_NO_KEYPAIR_API) || \
|
|
90
|
+
!defined(MLK_CONFIG_NO_ENCAPS_API)))
|
|
75
91
|
/* One-stop SHAKE256 call. Aliasing between input and
|
|
76
92
|
* output is not permitted */
|
|
77
93
|
#define mlk_shake256 MLK_NAMESPACE(shake256)
|
|
@@ -83,6 +99,7 @@ void mlk_shake128_release(mlk_shake128ctx *state);
|
|
|
83
99
|
* @param[in] input Input buffer.
|
|
84
100
|
* @param inlen Length of input in bytes.
|
|
85
101
|
*/
|
|
102
|
+
MLK_INTERNAL_API
|
|
86
103
|
void mlk_shake256(uint8_t *output, size_t outlen, const uint8_t *input,
|
|
87
104
|
size_t inlen)
|
|
88
105
|
__contract__(
|
|
@@ -92,6 +109,10 @@ __contract__(
|
|
|
92
109
|
requires(memory_no_alias(output, outlen))
|
|
93
110
|
assigns(memory_slice(output, outlen))
|
|
94
111
|
);
|
|
112
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API || (!MLK_CONFIG_NO_ENCAPS_API && \
|
|
113
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 4)) \
|
|
114
|
+
|| (MLK_CONFIG_SERIAL_FIPS202_ONLY && (!MLK_CONFIG_NO_KEYPAIR_API || \
|
|
115
|
+
!MLK_CONFIG_NO_ENCAPS_API)) */
|
|
95
116
|
|
|
96
117
|
/* One-stop SHA3_256 call. Aliasing between input and
|
|
97
118
|
* output is not permitted */
|
|
@@ -104,6 +125,7 @@ __contract__(
|
|
|
104
125
|
* @param[in] input Input buffer.
|
|
105
126
|
* @param inlen Length of input in bytes.
|
|
106
127
|
*/
|
|
128
|
+
MLK_INTERNAL_API
|
|
107
129
|
void mlk_sha3_256(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
108
130
|
__contract__(
|
|
109
131
|
requires(inlen <= MLK_MAX_BUFFER_SIZE)
|
|
@@ -123,6 +145,7 @@ __contract__(
|
|
|
123
145
|
* @param[in] input Input buffer.
|
|
124
146
|
* @param inlen Length of input in bytes.
|
|
125
147
|
*/
|
|
148
|
+
MLK_INTERNAL_API
|
|
126
149
|
void mlk_sha3_512(uint8_t *output, const uint8_t *input, size_t inlen)
|
|
127
150
|
__contract__(
|
|
128
151
|
requires(inlen <= MLK_MAX_BUFFER_SIZE)
|
|
@@ -131,14 +154,6 @@ __contract__(
|
|
|
131
154
|
assigns(memory_slice(output, SHA3_512_HASHBYTES))
|
|
132
155
|
);
|
|
133
156
|
|
|
134
|
-
#if !defined(MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202) || \
|
|
135
|
-
!defined(MLK_USE_NATIVE_FIPS202_X4)
|
|
136
|
-
/* If you provide your own FIPS-202 implementation where the x4-
|
|
137
|
-
* Keccak-f1600-x4 implementation falls back to 4-fold Keccak-f1600,
|
|
138
|
-
* set this to gain a small speedup. */
|
|
139
|
-
#define FIPS202_X4_DEFAULT_IMPLEMENTATION
|
|
140
|
-
#endif /* !MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 || !MLK_USE_NATIVE_FIPS202_X4 \
|
|
141
|
-
*/
|
|
142
157
|
|
|
143
158
|
|
|
144
159
|
#endif /* !MLK_FIPS202_FIPS202_H */
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
#include "../common.h"
|
|
16
|
-
#if !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
16
|
+
#if !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
|
|
17
|
+
!defined(MLK_CONFIG_SERIAL_FIPS202_ONLY)
|
|
17
18
|
|
|
18
19
|
#include "../verify.h"
|
|
19
20
|
#include "fips202.h"
|
|
@@ -117,6 +118,7 @@ __contract__(
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
|
|
121
|
+
MLK_INTERNAL_API
|
|
120
122
|
void mlk_shake128x4_absorb_once(mlk_shake128x4ctx *state, const uint8_t *in0,
|
|
121
123
|
const uint8_t *in1, const uint8_t *in2,
|
|
122
124
|
const uint8_t *in3, size_t inlen)
|
|
@@ -126,6 +128,7 @@ void mlk_shake128x4_absorb_once(mlk_shake128x4ctx *state, const uint8_t *in0,
|
|
|
126
128
|
inlen, 0x1F);
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
MLK_INTERNAL_API
|
|
129
132
|
void mlk_shake128x4_squeezeblocks(uint8_t *out0, uint8_t *out1, uint8_t *out2,
|
|
130
133
|
uint8_t *out3, size_t nblocks,
|
|
131
134
|
mlk_shake128x4ctx *state)
|
|
@@ -134,7 +137,9 @@ void mlk_shake128x4_squeezeblocks(uint8_t *out0, uint8_t *out1, uint8_t *out2,
|
|
|
134
137
|
SHAKE128_RATE);
|
|
135
138
|
}
|
|
136
139
|
|
|
140
|
+
MLK_INTERNAL_API
|
|
137
141
|
void mlk_shake128x4_init(mlk_shake128x4ctx *state) { (void)state; }
|
|
142
|
+
MLK_INTERNAL_API
|
|
138
143
|
void mlk_shake128x4_release(mlk_shake128x4ctx *state)
|
|
139
144
|
{
|
|
140
145
|
/* Specification: Partially implements
|
|
@@ -161,6 +166,7 @@ static void mlk_shake256x4_squeezeblocks(uint8_t *out0, uint8_t *out1,
|
|
|
161
166
|
SHAKE256_RATE);
|
|
162
167
|
}
|
|
163
168
|
|
|
169
|
+
MLK_INTERNAL_API
|
|
164
170
|
void mlk_shake256x4(uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3,
|
|
165
171
|
size_t outlen, const uint8_t *in0, const uint8_t *in1,
|
|
166
172
|
const uint8_t *in2, const uint8_t *in3, size_t inlen)
|
|
@@ -200,8 +206,10 @@ void mlk_shake256x4(uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3,
|
|
|
200
206
|
mlk_zeroize(tmp3, sizeof(tmp3));
|
|
201
207
|
}
|
|
202
208
|
|
|
203
|
-
#else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED
|
|
209
|
+
#else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED && !MLK_CONFIG_SERIAL_FIPS202_ONLY \
|
|
210
|
+
*/
|
|
204
211
|
|
|
205
212
|
MLK_EMPTY_CU(fips202x4)
|
|
206
213
|
|
|
207
|
-
#endif /* MLK_CONFIG_MULTILEVEL_NO_SHARED
|
|
214
|
+
#endif /* !(!MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
215
|
+
!MLK_CONFIG_SERIAL_FIPS202_ONLY) */
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
#include "../cbmc.h"
|
|
10
10
|
#include "../common.h"
|
|
11
|
-
|
|
12
11
|
#include "fips202.h"
|
|
13
12
|
#include "keccakf1600.h"
|
|
14
13
|
|
|
14
|
+
#if !defined(MLK_CONFIG_SERIAL_FIPS202_ONLY)
|
|
15
15
|
/** Context for the non-incremental 4-way SHAKE128 API. */
|
|
16
16
|
typedef struct
|
|
17
17
|
{
|
|
@@ -20,6 +20,7 @@ typedef struct
|
|
|
20
20
|
} MLK_ALIGN mlk_shake128x4ctx;
|
|
21
21
|
|
|
22
22
|
#define mlk_shake128x4_absorb_once MLK_NAMESPACE(shake128x4_absorb_once)
|
|
23
|
+
MLK_INTERNAL_API
|
|
23
24
|
void mlk_shake128x4_absorb_once(mlk_shake128x4ctx *state, const uint8_t *in0,
|
|
24
25
|
const uint8_t *in1, const uint8_t *in2,
|
|
25
26
|
const uint8_t *in3, size_t inlen)
|
|
@@ -34,6 +35,7 @@ __contract__(
|
|
|
34
35
|
);
|
|
35
36
|
|
|
36
37
|
#define mlk_shake128x4_squeezeblocks MLK_NAMESPACE(shake128x4_squeezeblocks)
|
|
38
|
+
MLK_INTERNAL_API
|
|
37
39
|
void mlk_shake128x4_squeezeblocks(uint8_t *out0, uint8_t *out1, uint8_t *out2,
|
|
38
40
|
uint8_t *out3, size_t nblocks,
|
|
39
41
|
mlk_shake128x4ctx *state)
|
|
@@ -52,12 +54,15 @@ __contract__(
|
|
|
52
54
|
);
|
|
53
55
|
|
|
54
56
|
#define mlk_shake128x4_init MLK_NAMESPACE(shake128x4_init)
|
|
57
|
+
MLK_INTERNAL_API
|
|
55
58
|
void mlk_shake128x4_init(mlk_shake128x4ctx *state);
|
|
56
59
|
|
|
57
60
|
#define mlk_shake128x4_release MLK_NAMESPACE(shake128x4_release)
|
|
61
|
+
MLK_INTERNAL_API
|
|
58
62
|
void mlk_shake128x4_release(mlk_shake128x4ctx *state);
|
|
59
63
|
|
|
60
64
|
#define mlk_shake256x4 MLK_NAMESPACE(shake256x4)
|
|
65
|
+
MLK_INTERNAL_API
|
|
61
66
|
void mlk_shake256x4(uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3,
|
|
62
67
|
size_t outlen, const uint8_t *in0, const uint8_t *in1,
|
|
63
68
|
const uint8_t *in2, const uint8_t *in3, size_t inlen)
|
|
@@ -77,5 +82,6 @@ __contract__(
|
|
|
77
82
|
assigns(memory_slice(out2, outlen))
|
|
78
83
|
assigns(memory_slice(out3, outlen))
|
|
79
84
|
);
|
|
85
|
+
#endif /* !MLK_CONFIG_SERIAL_FIPS202_ONLY */
|
|
80
86
|
|
|
81
87
|
#endif /* !MLK_FIPS202_FIPS202X4_H */
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
#define MLK_KECCAK_NROUNDS 24
|
|
34
34
|
#define MLK_KECCAK_ROL(a, offset) (((a) << (offset)) ^ ((a) >> (64 - (offset))))
|
|
35
35
|
|
|
36
|
+
MLK_INTERNAL_API
|
|
36
37
|
void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
|
|
37
38
|
unsigned offset, unsigned length)
|
|
38
39
|
{
|
|
@@ -56,6 +57,7 @@ void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
|
|
|
56
57
|
#endif /* !MLK_SYS_LITTLE_ENDIAN */
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
MLK_INTERNAL_API
|
|
59
61
|
void mlk_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
|
|
60
62
|
unsigned offset, unsigned length)
|
|
61
63
|
{
|
|
@@ -80,6 +82,7 @@ void mlk_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
|
|
|
80
82
|
#endif /* !MLK_SYS_LITTLE_ENDIAN */
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
#if !defined(MLK_CONFIG_SERIAL_FIPS202_ONLY)
|
|
83
86
|
static void mlk_keccakf1600x4_extract_bytes_c(uint64_t *state,
|
|
84
87
|
unsigned char *data0,
|
|
85
88
|
unsigned char *data1,
|
|
@@ -110,6 +113,7 @@ __contract__(
|
|
|
110
113
|
length);
|
|
111
114
|
}
|
|
112
115
|
|
|
116
|
+
MLK_INTERNAL_API
|
|
113
117
|
void mlk_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
|
|
114
118
|
unsigned char *data1, unsigned char *data2,
|
|
115
119
|
unsigned char *data3, unsigned offset,
|
|
@@ -158,6 +162,7 @@ __contract__(
|
|
|
158
162
|
length);
|
|
159
163
|
}
|
|
160
164
|
|
|
165
|
+
MLK_INTERNAL_API
|
|
161
166
|
void mlk_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
|
|
162
167
|
const unsigned char *data1,
|
|
163
168
|
const unsigned char *data2,
|
|
@@ -176,6 +181,7 @@ void mlk_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
|
|
|
176
181
|
length);
|
|
177
182
|
}
|
|
178
183
|
|
|
184
|
+
MLK_INTERNAL_API
|
|
179
185
|
void mlk_keccakf1600x4_permute(uint64_t *state)
|
|
180
186
|
{
|
|
181
187
|
#if defined(MLK_USE_NATIVE_FIPS202_X4)
|
|
@@ -189,6 +195,7 @@ void mlk_keccakf1600x4_permute(uint64_t *state)
|
|
|
189
195
|
mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 2);
|
|
190
196
|
mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 3);
|
|
191
197
|
}
|
|
198
|
+
#endif /* !MLK_CONFIG_SERIAL_FIPS202_ONLY */
|
|
192
199
|
|
|
193
200
|
static const uint64_t mlk_KeccakF_RoundConstants[MLK_KECCAK_NROUNDS] = {
|
|
194
201
|
(uint64_t)0x0000000000000001ULL, (uint64_t)0x0000000000008082ULL,
|
|
@@ -476,6 +483,7 @@ __contract__(
|
|
|
476
483
|
state[24] = Asu;
|
|
477
484
|
}
|
|
478
485
|
|
|
486
|
+
MLK_INTERNAL_API
|
|
479
487
|
void mlk_keccakf1600_permute(uint64_t *state)
|
|
480
488
|
{
|
|
481
489
|
#if defined(MLK_USE_NATIVE_FIPS202_X1)
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
#define mlk_keccakf1600_extract_bytes MLK_NAMESPACE(keccakf1600_extract_bytes)
|
|
21
|
+
MLK_INTERNAL_API
|
|
21
22
|
void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
|
|
22
23
|
unsigned offset, unsigned length)
|
|
23
24
|
__contract__(
|
|
@@ -29,6 +30,7 @@ __contract__(
|
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
#define mlk_keccakf1600_xor_bytes MLK_NAMESPACE(keccakf1600_xor_bytes)
|
|
33
|
+
MLK_INTERNAL_API
|
|
32
34
|
void mlk_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
|
|
33
35
|
unsigned offset, unsigned length)
|
|
34
36
|
__contract__(
|
|
@@ -39,8 +41,10 @@ __contract__(
|
|
|
39
41
|
assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
40
42
|
);
|
|
41
43
|
|
|
44
|
+
#if !defined(MLK_CONFIG_SERIAL_FIPS202_ONLY)
|
|
42
45
|
#define mlk_keccakf1600x4_extract_bytes \
|
|
43
46
|
MLK_NAMESPACE(keccakf1600x4_extract_bytes)
|
|
47
|
+
MLK_INTERNAL_API
|
|
44
48
|
void mlk_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
|
|
45
49
|
unsigned char *data1, unsigned char *data2,
|
|
46
50
|
unsigned char *data3, unsigned offset,
|
|
@@ -60,6 +64,7 @@ __contract__(
|
|
|
60
64
|
);
|
|
61
65
|
|
|
62
66
|
#define mlk_keccakf1600x4_xor_bytes MLK_NAMESPACE(keccakf1600x4_xor_bytes)
|
|
67
|
+
MLK_INTERNAL_API
|
|
63
68
|
void mlk_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
|
|
64
69
|
const unsigned char *data1,
|
|
65
70
|
const unsigned char *data2,
|
|
@@ -82,13 +87,16 @@ __contract__(
|
|
|
82
87
|
|
|
83
88
|
|
|
84
89
|
#define mlk_keccakf1600x4_permute MLK_NAMESPACE(keccakf1600x4_permute)
|
|
90
|
+
MLK_INTERNAL_API
|
|
85
91
|
void mlk_keccakf1600x4_permute(uint64_t *state)
|
|
86
92
|
__contract__(
|
|
87
93
|
requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
|
|
88
94
|
assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
|
|
89
95
|
);
|
|
96
|
+
#endif /* !MLK_CONFIG_SERIAL_FIPS202_ONLY */
|
|
90
97
|
|
|
91
98
|
#define mlk_keccakf1600_permute MLK_NAMESPACE(keccakf1600_permute)
|
|
99
|
+
MLK_INTERNAL_API
|
|
92
100
|
void mlk_keccakf1600_permute(uint64_t *state)
|
|
93
101
|
__contract__(
|
|
94
102
|
requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
#include "../../../../common.h"
|
|
36
|
-
#if defined(
|
|
36
|
+
#if defined(MLK_SYS_AARCH64) && \
|
|
37
|
+
defined(MLK_FIPS202_AARCH64_NEED_X1_SCALAR) && \
|
|
37
38
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
38
39
|
|
|
39
40
|
/*
|
|
@@ -344,6 +345,8 @@ Lmlk_keccak_f1600_x1_scalar_loop:
|
|
|
344
345
|
stp x5, x10, [x0, #0xa0]
|
|
345
346
|
stp x15, x20, [x0, #0xb0]
|
|
346
347
|
str x25, [x0, #0xc0]
|
|
348
|
+
stp xzr, xzr, [sp]
|
|
349
|
+
stp xzr, xzr, [sp, #0x10]
|
|
347
350
|
ldp x19, x20, [sp, #0x20]
|
|
348
351
|
.cfi_restore x19
|
|
349
352
|
.cfi_restore x20
|
|
@@ -369,7 +372,7 @@ Lmlk_keccak_f1600_x1_scalar_loop:
|
|
|
369
372
|
|
|
370
373
|
MLK_ASM_FN_SIZE(keccak_f1600_x1_scalar_aarch64_asm)
|
|
371
374
|
|
|
372
|
-
#endif /* MLK_FIPS202_AARCH64_NEED_X1_SCALAR && \
|
|
375
|
+
#endif /* MLK_SYS_AARCH64 && MLK_FIPS202_AARCH64_NEED_X1_SCALAR && \
|
|
373
376
|
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
374
377
|
|
|
375
378
|
#if defined(__ELF__)
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
//
|
|
50
50
|
|
|
51
51
|
#include "../../../../common.h"
|
|
52
|
-
#if defined(
|
|
52
|
+
#if defined(MLK_SYS_AARCH64_NEON) && defined(__ARM_FEATURE_SHA3) && \
|
|
53
|
+
defined(MLK_FIPS202_AARCH64_NEED_X1_V84A) && \
|
|
53
54
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
54
55
|
|
|
55
|
-
#if defined(__ARM_FEATURE_SHA3)
|
|
56
56
|
|
|
57
57
|
/*
|
|
58
58
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
@@ -196,9 +196,9 @@ Lmlk_keccak_f1600_x1_v84a_loop:
|
|
|
196
196
|
|
|
197
197
|
MLK_ASM_FN_SIZE(keccak_f1600_x1_v84a_aarch64_asm)
|
|
198
198
|
|
|
199
|
-
#endif /* __ARM_FEATURE_SHA3 */
|
|
200
199
|
|
|
201
|
-
#endif /*
|
|
200
|
+
#endif /* MLK_SYS_AARCH64_NEON && __ARM_FEATURE_SHA3 && \
|
|
201
|
+
MLK_FIPS202_AARCH64_NEED_X1_V84A && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
|
|
202
202
|
*/
|
|
203
203
|
|
|
204
204
|
#if defined(__ELF__)
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
//
|
|
50
50
|
|
|
51
51
|
#include "../../../../common.h"
|
|
52
|
-
#if defined(
|
|
52
|
+
#if defined(MLK_SYS_AARCH64_NEON) && defined(__ARM_FEATURE_SHA3) && \
|
|
53
|
+
defined(MLK_FIPS202_AARCH64_NEED_X2_V84A) && \
|
|
53
54
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
54
55
|
|
|
55
|
-
#if defined(__ARM_FEATURE_SHA3)
|
|
56
56
|
|
|
57
57
|
/*
|
|
58
58
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
@@ -251,9 +251,9 @@ Lmlk_keccak_f1600_x2_v84a_loop:
|
|
|
251
251
|
|
|
252
252
|
MLK_ASM_FN_SIZE(keccak_f1600_x2_v84a_aarch64_asm)
|
|
253
253
|
|
|
254
|
-
#endif /* __ARM_FEATURE_SHA3 */
|
|
255
254
|
|
|
256
|
-
#endif /*
|
|
255
|
+
#endif /* MLK_SYS_AARCH64_NEON && __ARM_FEATURE_SHA3 && \
|
|
256
|
+
MLK_FIPS202_AARCH64_NEED_X2_V84A && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
|
|
257
257
|
*/
|
|
258
258
|
|
|
259
259
|
#if defined(__ELF__)
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
#include "../../../../common.h"
|
|
37
|
-
#if defined(
|
|
37
|
+
#if defined(MLK_SYS_AARCH64_NEON) && \
|
|
38
|
+
defined(MLK_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID) && \
|
|
38
39
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
39
40
|
|
|
40
41
|
/*
|
|
@@ -1034,6 +1035,10 @@ Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_done:
|
|
|
1034
1035
|
str d24, [x0]
|
|
1035
1036
|
trn2 v25.2d, v24.2d, v24.2d
|
|
1036
1037
|
str d25, [x4]
|
|
1038
|
+
stp xzr, xzr, [sp]
|
|
1039
|
+
stp xzr, xzr, [sp, #0x10]
|
|
1040
|
+
str xzr, [sp, #0x20]
|
|
1041
|
+
str xzr, [sp, #0xd0]
|
|
1037
1042
|
ldp d8, d9, [sp, #0x90]
|
|
1038
1043
|
.cfi_restore d8
|
|
1039
1044
|
.cfi_restore d9
|
|
@@ -1071,8 +1076,8 @@ Lmlk_keccak_f1600_x4_v8a_scalar_hybrid_done:
|
|
|
1071
1076
|
|
|
1072
1077
|
MLK_ASM_FN_SIZE(keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm)
|
|
1073
1078
|
|
|
1074
|
-
#endif /*
|
|
1075
|
-
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
1079
|
+
#endif /* MLK_SYS_AARCH64_NEON && MLK_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID \
|
|
1080
|
+
&& !MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
1076
1081
|
|
|
1077
1082
|
#if defined(__ELF__)
|
|
1078
1083
|
.section .note.GNU-stack,"",%progbits
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
#include "../../../../common.h"
|
|
37
|
-
#if defined(
|
|
37
|
+
#if defined(MLK_SYS_AARCH64_NEON) && defined(__ARM_FEATURE_SHA3) && \
|
|
38
|
+
defined(MLK_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID) && \
|
|
38
39
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
39
40
|
|
|
40
|
-
#if defined(__ARM_FEATURE_SHA3)
|
|
41
41
|
|
|
42
42
|
/*
|
|
43
43
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
@@ -942,6 +942,10 @@ Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_done:
|
|
|
942
942
|
str d24, [x0]
|
|
943
943
|
trn2 v25.2d, v24.2d, v24.2d
|
|
944
944
|
str d25, [x4]
|
|
945
|
+
stp xzr, xzr, [sp]
|
|
946
|
+
stp xzr, xzr, [sp, #0x10]
|
|
947
|
+
str xzr, [sp, #0x20]
|
|
948
|
+
str xzr, [sp, #0xd0]
|
|
945
949
|
ldp d8, d9, [sp, #0x90]
|
|
946
950
|
.cfi_restore d8
|
|
947
951
|
.cfi_restore d9
|
|
@@ -979,9 +983,9 @@ Lmlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_done:
|
|
|
979
983
|
|
|
980
984
|
MLK_ASM_FN_SIZE(keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm)
|
|
981
985
|
|
|
982
|
-
#endif /* __ARM_FEATURE_SHA3 */
|
|
983
986
|
|
|
984
|
-
#endif /*
|
|
987
|
+
#endif /* MLK_SYS_AARCH64_NEON && __ARM_FEATURE_SHA3 && \
|
|
988
|
+
MLK_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID && \
|
|
985
989
|
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
986
990
|
|
|
987
991
|
#if defined(__ELF__)
|
data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S
CHANGED
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
// 784 S[0][24]_odd, S[1][24]_odd, S[2][24]_odd, S[3][24]_odd
|
|
67
67
|
|
|
68
68
|
#include "../../../../common.h"
|
|
69
|
-
#if defined(
|
|
69
|
+
#if defined(MLK_SYS_ARMV81M_MVE) && \
|
|
70
|
+
defined(MLK_FIPS202_ARMV81M_NEED_X4) && \
|
|
70
71
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
|
|
71
72
|
|
|
72
73
|
/*
|
|
@@ -709,7 +710,8 @@ Lmlk_keccak_f1600_x4_mve_asm_roundend:
|
|
|
709
710
|
|
|
710
711
|
MLK_ASM_FN_SIZE(keccak_f1600_x4_mve_asm)
|
|
711
712
|
|
|
712
|
-
#endif /* MLK_FIPS202_ARMV81M_NEED_X4 &&
|
|
713
|
+
#endif /* MLK_SYS_ARMV81M_MVE && MLK_FIPS202_ARMV81M_NEED_X4 && \
|
|
714
|
+
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
|
|
713
715
|
|
|
714
716
|
#if defined(__ELF__)
|
|
715
717
|
.section .note.GNU-stack,"",%progbits
|