pq_crypto 0.6.1 → 0.6.3
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 +10 -0
- data/SECURITY.md +7 -0
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- data/ext/pqcrypto/vendor/mldsa-native/README.md +23 -10
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +23 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +114 -58
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +498 -461
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +145 -85
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +456 -422
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +47 -25
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +26 -14
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +56 -81
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +17 -24
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +33 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +67 -87
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +19 -14
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +13 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +84 -10
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +10 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +6 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +22 -15
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +376 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +204 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +259 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1077 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +987 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +16 -10
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +2 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +60 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +48 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +18 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +658 -582
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +5 -100
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +334 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +355 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +8 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/{xkcp.h → keccak_f1600_x4_avx2.h} +11 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +44 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +454 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +37 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +213 -196
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +248 -64
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt_aarch64_asm.S +753 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +129 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +145 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +177 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt_aarch64_asm.S +653 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery_aarch64_asm.S +84 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_aarch64_asm.S +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_aarch64_asm.S +55 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_aarch64_asm.S +86 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_aarch64_asm.S +86 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_aarch64_asm.S +103 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_aarch64_asm.S +111 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_aarch64_asm.S +75 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_aarch64_asm.S +72 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +23 -11
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_aarch64_asm.S +189 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_aarch64_asm.S +137 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_aarch64_asm.S +130 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +520 -516
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +34 -33
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +202 -242
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +25 -17
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +112 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt_avx2_asm.S +2311 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt_avx2_asm.S +2383 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack_avx2_asm.S +238 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4_avx2_asm.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5_avx2_asm.S +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7_avx2_asm.S +187 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_avx2_asm.S +130 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2_asm.S +190 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +9 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +10 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +8 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +8 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +130 -129
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +109 -180
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +169 -150
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +56 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +149 -164
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +52 -57
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +132 -167
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +57 -424
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +167 -474
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +308 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +653 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +22 -29
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +37 -43
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +511 -367
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +456 -417
- data/ext/pqcrypto/vendor/mlkem-native/README.md +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +22 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -36
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +135 -146
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +116 -72
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +351 -415
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +43 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +16 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +57 -31
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +260 -349
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +17 -24
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +35 -37
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +43 -57
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +14 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +5 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +42 -6
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +31 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x1_scalar_asm.S → keccak_f1600_x1_scalar_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x1_v84a_asm.S → keccak_f1600_x1_v84a_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x2_v84a_asm.S → keccak_f1600_x2_v84a_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x4_v8a_scalar_hybrid_asm.S → keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S → keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +10 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +55 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +58 -14
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +57 -16
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -1
- 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/fips202_native_x86_64.h +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/{keccak_f1600_x4_avx2.S → keccak_f1600_x4_avx2_asm.S} +13 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +12 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +167 -136
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +75 -68
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +135 -157
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +15 -13
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +143 -135
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +52 -46
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt.S → intt_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt.S → ntt_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_asm.S → poly_mulcache_compute_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_asm.S → poly_reduce_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_asm.S → poly_tobytes_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_asm.S → poly_tomont_aarch64_asm.S} +10 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k2.S → polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k3.S → polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k4.S → polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_asm.S → rej_uniform_aarch64_asm.S} +12 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +514 -513
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +254 -253
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +6 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +6 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +77 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +24 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +299 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.h +34 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/intt_ppc_asm.S +3222 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/ntt_ppc_asm.S +1651 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/poly_tomont_ppc_asm.S +294 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/reduce_ppc_asm.S +710 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +5 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +18 -16
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +19 -24
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +53 -65
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +20 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +106 -88
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +45 -35
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt.S → intt_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt.S → ntt_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes.S → nttfrombytes_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes.S → ntttobytes_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack.S → nttunpack_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10.S → poly_compress_d10_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11.S → poly_compress_d11_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4.S → poly_compress_d4_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5.S → poly_compress_d5_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10.S → poly_decompress_d10_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11.S → poly_decompress_d11_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4.S → poly_decompress_d4_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5.S → poly_decompress_d5_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{mulcache_compute.S → poly_mulcache_compute_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k2.S → polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k3.S → polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k4.S → polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce.S → reduce_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_asm.S → rej_uniform_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +514 -513
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont.S → tomont_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +61 -57
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +89 -116
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +31 -32
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +226 -301
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +21 -29
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +68 -63
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +37 -48
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +44 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +141 -159
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +86 -71
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +0 -376
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +0 -204
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +0 -259
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +0 -1077
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +0 -987
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +0 -488
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +0 -16
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +0 -753
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +0 -129
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +0 -145
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +0 -177
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +0 -653
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +0 -79
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +0 -53
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +0 -55
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +0 -85
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +0 -85
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +0 -102
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +0 -110
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +0 -72
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +0 -69
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +0 -189
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +0 -135
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +0 -128
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +0 -2311
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +0 -2383
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +0 -239
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +0 -131
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +0 -139
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +0 -155
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +0 -187
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +0 -61
|
@@ -55,26 +55,25 @@
|
|
|
55
55
|
#define mlk_kem_check_pk MLK_NAMESPACE_K(check_pk) MLK_CONTEXT_PARAMETERS_1
|
|
56
56
|
#define mlk_kem_check_sk MLK_NAMESPACE_K(check_sk) MLK_CONTEXT_PARAMETERS_1
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
*
|
|
58
|
+
/**
|
|
59
|
+
* Implements modulus check mandated by FIPS 203, i.e., ensures that
|
|
60
|
+
* coefficients are in [0,q-1].
|
|
60
61
|
*
|
|
61
|
-
*
|
|
62
|
-
* i.e., ensures that coefficients are in [0,q-1].
|
|
62
|
+
* @spec{Implements @[FIPS203, Section 7.2, 'modulus check'].}
|
|
63
63
|
*
|
|
64
|
-
*
|
|
65
|
-
* (an already allocated array of MLKEM_INDCCA_PUBLICKEYBYTES
|
|
66
|
-
* bytes)
|
|
64
|
+
* @reference{Not implemented in the reference implementation @[REF].}
|
|
67
65
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
66
|
+
* @param[in] pk Input public key (an already allocated array of
|
|
67
|
+
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
68
|
+
* @param context Application context. Only present when
|
|
69
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
70
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
72
71
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
* @retval 0 Success.
|
|
73
|
+
* @retval MLK_ERR_FAIL Modulus check failed.
|
|
74
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
75
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
76
|
+
*/
|
|
78
77
|
MLK_EXTERNAL_API
|
|
79
78
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
80
79
|
int mlk_kem_check_pk(const uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
@@ -86,27 +85,25 @@ __contract__(
|
|
|
86
85
|
);
|
|
87
86
|
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
*
|
|
88
|
+
/**
|
|
89
|
+
* Implements public key hash check mandated by FIPS 203, i.e., ensures that
|
|
90
|
+
* sk[768𝑘+32 ∶ 768𝑘+64] = H(pk) = H(sk[384𝑘 : 768𝑘+32]).
|
|
91
91
|
*
|
|
92
|
-
*
|
|
93
|
-
* i.e., ensures that
|
|
94
|
-
* sk[768𝑘+32 ∶ 768𝑘+64] = H(pk)= H(sk[384𝑘 : 768𝑘+32])
|
|
92
|
+
* @spec{Implements @[FIPS203, Section 7.3, 'hash check'].}
|
|
95
93
|
*
|
|
96
|
-
*
|
|
97
|
-
* (an already allocated array of MLKEM_INDCCA_SECRETKEYBYTES
|
|
98
|
-
* bytes)
|
|
94
|
+
* @reference{Not implemented in the reference implementation @[REF].}
|
|
99
95
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
96
|
+
* @param[in] sk Input private key (an already allocated array of
|
|
97
|
+
* MLKEM_INDCCA_SECRETKEYBYTES bytes).
|
|
98
|
+
* @param context Application context. Only present when
|
|
99
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
100
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
104
101
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
* @retval 0 Success.
|
|
103
|
+
* @retval MLK_ERR_FAIL Public key hash check failed.
|
|
104
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
105
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
106
|
+
*/
|
|
110
107
|
MLK_EXTERNAL_API
|
|
111
108
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
112
109
|
int mlk_kem_check_sk(const uint8_t sk[MLKEM_INDCCA_SECRETKEYBYTES],
|
|
@@ -117,31 +114,26 @@ __contract__(
|
|
|
117
114
|
return_value == MLK_ERR_OUT_OF_MEMORY)
|
|
118
115
|
);
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
* used and an allocation via MLK_CUSTOM_ALLOC returned NULL.
|
|
141
|
-
*
|
|
142
|
-
* Specification: Implements @[FIPS203, Algorithm 16, ML-KEM.KeyGen_Internal]
|
|
143
|
-
*
|
|
144
|
-
**************************************************/
|
|
117
|
+
/**
|
|
118
|
+
* Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
|
|
119
|
+
*
|
|
120
|
+
* @spec{Implements @[FIPS203, Algorithm 16, ML-KEM.KeyGen_Internal].}
|
|
121
|
+
*
|
|
122
|
+
* @param[out] pk Output public key (an already allocated array of
|
|
123
|
+
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
124
|
+
* @param[out] sk Output private key (an already allocated array of
|
|
125
|
+
* MLKEM_INDCCA_SECRETKEYBYTES bytes).
|
|
126
|
+
* @param[in] coins Input randomness (an already allocated array filled
|
|
127
|
+
* with 2*MLKEM_SYMBYTES random bytes).
|
|
128
|
+
* @param context Application context. Only present when
|
|
129
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
130
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
131
|
+
*
|
|
132
|
+
* @retval 0 Success.
|
|
133
|
+
* @retval MLK_ERR_FAIL MLK_CONFIG_KEYGEN_PCT enabled and PCT failed.
|
|
134
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
135
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
136
|
+
*/
|
|
145
137
|
MLK_EXTERNAL_API
|
|
146
138
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
147
139
|
int mlk_kem_keypair_derand(uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
@@ -159,29 +151,25 @@ __contract__(
|
|
|
159
151
|
return_value == MLK_ERR_RNG_FAIL)
|
|
160
152
|
);
|
|
161
153
|
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
* Specification: Implements @[FIPS203, Algorithm 19, ML-KEM.KeyGen]
|
|
183
|
-
*
|
|
184
|
-
**************************************************/
|
|
154
|
+
/**
|
|
155
|
+
* Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
|
|
156
|
+
*
|
|
157
|
+
* @spec{Implements @[FIPS203, Algorithm 19, ML-KEM.KeyGen].}
|
|
158
|
+
*
|
|
159
|
+
* @param[out] pk Output public key (an already allocated array of
|
|
160
|
+
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
161
|
+
* @param[out] sk Output private key (an already allocated array of
|
|
162
|
+
* MLKEM_INDCCA_SECRETKEYBYTES bytes).
|
|
163
|
+
* @param context Application context. Only present when
|
|
164
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
165
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
166
|
+
*
|
|
167
|
+
* @retval 0 Success.
|
|
168
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
169
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
170
|
+
* @retval MLK_ERR_RNG_FAIL Random number generation failed.
|
|
171
|
+
* @retval MLK_ERR_FAIL MLK_CONFIG_KEYGEN_PCT enabled and PCT failed.
|
|
172
|
+
*/
|
|
185
173
|
MLK_EXTERNAL_API
|
|
186
174
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
187
175
|
int mlk_kem_keypair(uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
@@ -197,33 +185,29 @@ __contract__(
|
|
|
197
185
|
return_value == MLK_ERR_RNG_FAIL)
|
|
198
186
|
);
|
|
199
187
|
|
|
200
|
-
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
|
|
223
|
-
*
|
|
224
|
-
* Specification: Implements @[FIPS203, Algorithm 17, ML-KEM.Encaps_Internal]
|
|
225
|
-
*
|
|
226
|
-
**************************************************/
|
|
188
|
+
/**
|
|
189
|
+
* Generate ciphertext and shared secret for a given public key.
|
|
190
|
+
*
|
|
191
|
+
* @spec{Implements @[FIPS203, Algorithm 17, ML-KEM.Encaps_Internal].}
|
|
192
|
+
*
|
|
193
|
+
* @param[out] ct Output ciphertext (an already allocated array of
|
|
194
|
+
* MLKEM_INDCCA_CIPHERTEXTBYTES bytes).
|
|
195
|
+
* @param[out] ss Output shared secret (an already allocated array of
|
|
196
|
+
* MLKEM_SSBYTES bytes).
|
|
197
|
+
* @param[in] pk Input public key (an already allocated array of
|
|
198
|
+
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
199
|
+
* @param[in] coins Input randomness (an already allocated array filled
|
|
200
|
+
* with MLKEM_SYMBYTES random bytes).
|
|
201
|
+
* @param context Application context. Only present when
|
|
202
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
203
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
204
|
+
*
|
|
205
|
+
* @retval 0 Success.
|
|
206
|
+
* @retval MLK_ERR_FAIL The 'modulus check' @[FIPS203, Section 7.2]
|
|
207
|
+
* for the public key failed.
|
|
208
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
209
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
210
|
+
*/
|
|
227
211
|
MLK_EXTERNAL_API
|
|
228
212
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
229
213
|
int mlk_kem_enc_derand(uint8_t ct[MLKEM_INDCCA_CIPHERTEXTBYTES],
|
|
@@ -242,31 +226,28 @@ __contract__(
|
|
|
242
226
|
return_value == MLK_ERR_OUT_OF_MEMORY)
|
|
243
227
|
);
|
|
244
228
|
|
|
245
|
-
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
|
|
267
|
-
* Specification: Implements @[FIPS203, Algorithm 20, ML-KEM.Encaps]
|
|
268
|
-
*
|
|
269
|
-
**************************************************/
|
|
229
|
+
/**
|
|
230
|
+
* Generate ciphertext and shared secret for a given public key.
|
|
231
|
+
*
|
|
232
|
+
* @spec{Implements @[FIPS203, Algorithm 20, ML-KEM.Encaps].}
|
|
233
|
+
*
|
|
234
|
+
* @param[out] ct Output ciphertext (an already allocated array of
|
|
235
|
+
* MLKEM_INDCCA_CIPHERTEXTBYTES bytes).
|
|
236
|
+
* @param[out] ss Output shared secret (an already allocated array of
|
|
237
|
+
* MLKEM_SSBYTES bytes).
|
|
238
|
+
* @param[in] pk Input public key (an already allocated array of
|
|
239
|
+
* MLKEM_INDCCA_PUBLICKEYBYTES bytes).
|
|
240
|
+
* @param context Application context. Only present when
|
|
241
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
242
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
243
|
+
*
|
|
244
|
+
* @retval 0 Success.
|
|
245
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
246
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
247
|
+
* @retval MLK_ERR_RNG_FAIL Random number generation failed.
|
|
248
|
+
* @retval MLK_ERR_FAIL The 'modulus check' @[FIPS203, Section 7.2]
|
|
249
|
+
* for the public key failed.
|
|
250
|
+
*/
|
|
270
251
|
MLK_EXTERNAL_API
|
|
271
252
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
272
253
|
int mlk_kem_enc(uint8_t ct[MLKEM_INDCCA_CIPHERTEXTBYTES],
|
|
@@ -284,30 +265,27 @@ __contract__(
|
|
|
284
265
|
return_value == MLK_ERR_RNG_FAIL)
|
|
285
266
|
);
|
|
286
267
|
|
|
287
|
-
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
|
|
308
|
-
* Specification: Implements @[FIPS203, Algorithm 21, ML-KEM.Decaps]
|
|
309
|
-
*
|
|
310
|
-
**************************************************/
|
|
268
|
+
/**
|
|
269
|
+
* Generate shared secret for a given ciphertext and private key.
|
|
270
|
+
*
|
|
271
|
+
* @spec{Implements @[FIPS203, Algorithm 21, ML-KEM.Decaps].}
|
|
272
|
+
*
|
|
273
|
+
* @param[out] ss Output shared secret (an already allocated array of
|
|
274
|
+
* MLKEM_SSBYTES bytes).
|
|
275
|
+
* @param[in] ct Input ciphertext (an already allocated array of
|
|
276
|
+
* MLKEM_INDCCA_CIPHERTEXTBYTES bytes).
|
|
277
|
+
* @param[in] sk Input private key (an already allocated array of
|
|
278
|
+
* MLKEM_INDCCA_SECRETKEYBYTES bytes).
|
|
279
|
+
* @param context Application context. Only present when
|
|
280
|
+
* MLK_CONFIG_CONTEXT_PARAMETER is defined; type set by
|
|
281
|
+
* MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
|
|
282
|
+
*
|
|
283
|
+
* @retval 0 Success.
|
|
284
|
+
* @retval MLK_ERR_FAIL The 'hash check' @[FIPS203, Section 7.3]
|
|
285
|
+
* for the secret key failed.
|
|
286
|
+
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
287
|
+
* MLK_CUSTOM_ALLOC returned NULL.
|
|
288
|
+
*/
|
|
311
289
|
MLK_EXTERNAL_API
|
|
312
290
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
313
291
|
int mlk_kem_dec(uint8_t ss[MLKEM_SSBYTES],
|
|
@@ -28,30 +28,30 @@
|
|
|
28
28
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
29
29
|
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
|
|
30
30
|
{
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
mlk_ntt_aarch64_asm(data, mlk_aarch64_ntt_zetas_layer12345,
|
|
32
|
+
mlk_aarch64_ntt_zetas_layer67);
|
|
33
33
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
37
37
|
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
38
38
|
{
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
mlk_intt_aarch64_asm(data, mlk_aarch64_invntt_zetas_layer12345,
|
|
40
|
+
mlk_aarch64_invntt_zetas_layer67);
|
|
41
41
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
45
45
|
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
46
46
|
{
|
|
47
|
-
|
|
47
|
+
mlk_poly_reduce_aarch64_asm(data);
|
|
48
48
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
52
52
|
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
53
53
|
{
|
|
54
|
-
|
|
54
|
+
mlk_poly_tomont_aarch64_asm(data);
|
|
55
55
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -59,8 +59,9 @@ MLK_MUST_CHECK_RETURN_VALUE
|
|
|
59
59
|
static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
|
|
60
60
|
const int16_t y[MLKEM_N])
|
|
61
61
|
{
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
mlk_poly_mulcache_compute_aarch64_asm(
|
|
63
|
+
x, y, mlk_aarch64_zetas_mulcache_native,
|
|
64
|
+
mlk_aarch64_zetas_mulcache_twisted_native);
|
|
64
65
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -70,7 +71,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k2_native(
|
|
|
70
71
|
int16_t r[MLKEM_N], const int16_t a[2 * MLKEM_N],
|
|
71
72
|
const int16_t b[2 * MLKEM_N], const int16_t b_cache[2 * (MLKEM_N / 2)])
|
|
72
73
|
{
|
|
73
|
-
|
|
74
|
+
mlk_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm(r, a, b, b_cache);
|
|
74
75
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
75
76
|
}
|
|
76
77
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 */
|
|
@@ -81,7 +82,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k3_native(
|
|
|
81
82
|
int16_t r[MLKEM_N], const int16_t a[3 * MLKEM_N],
|
|
82
83
|
const int16_t b[3 * MLKEM_N], const int16_t b_cache[3 * (MLKEM_N / 2)])
|
|
83
84
|
{
|
|
84
|
-
|
|
85
|
+
mlk_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm(r, a, b, b_cache);
|
|
85
86
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
86
87
|
}
|
|
87
88
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 3 */
|
|
@@ -92,7 +93,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
|
|
|
92
93
|
int16_t r[MLKEM_N], const int16_t a[4 * MLKEM_N],
|
|
93
94
|
const int16_t b[4 * MLKEM_N], const int16_t b_cache[4 * (MLKEM_N / 2)])
|
|
94
95
|
{
|
|
95
|
-
|
|
96
|
+
mlk_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm(r, a, b, b_cache);
|
|
96
97
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
97
98
|
}
|
|
98
99
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
@@ -101,7 +102,7 @@ MLK_MUST_CHECK_RETURN_VALUE
|
|
|
101
102
|
static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
|
|
102
103
|
const int16_t a[MLKEM_N])
|
|
103
104
|
{
|
|
104
|
-
|
|
105
|
+
mlk_poly_tobytes_aarch64_asm(r, a);
|
|
105
106
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -115,7 +116,8 @@ static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
|
|
|
115
116
|
{
|
|
116
117
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
117
118
|
}
|
|
118
|
-
return (int)
|
|
119
|
+
return (int)mlk_rej_uniform_aarch64_asm(r, buf, buflen,
|
|
120
|
+
mlk_rej_uniform_table);
|
|
119
121
|
}
|
|
120
122
|
#endif /* !__ASSEMBLER__ */
|
|
121
123
|
|