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
|
@@ -137,19 +137,16 @@ __contract__(ensures(return_value == b))
|
|
|
137
137
|
#pragma CPROVER check push
|
|
138
138
|
#pragma CPROVER check disable "conversion"
|
|
139
139
|
#endif
|
|
140
|
-
|
|
141
|
-
*
|
|
140
|
+
/**
|
|
141
|
+
* Cast uint16 value to int16.
|
|
142
142
|
*
|
|
143
|
-
*
|
|
143
|
+
* @param x Input value.
|
|
144
144
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
* - x >= 32768: returns x - 65536
|
|
151
|
-
*
|
|
152
|
-
**************************************************/
|
|
145
|
+
* @return For uint16_t x, the unique y in int16_t so that x == y mod 2^16.
|
|
146
|
+
* Concretely:
|
|
147
|
+
* - x < 32768: returns x
|
|
148
|
+
* - x >= 32768: returns x - 65536
|
|
149
|
+
*/
|
|
153
150
|
static MLK_ALWAYS_INLINE int16_t mlk_cast_uint16_to_int16(uint16_t x)
|
|
154
151
|
{
|
|
155
152
|
/*
|
|
@@ -165,92 +162,96 @@ static MLK_ALWAYS_INLINE int16_t mlk_cast_uint16_to_int16(uint16_t x)
|
|
|
165
162
|
#pragma CPROVER check pop
|
|
166
163
|
#endif
|
|
167
164
|
|
|
168
|
-
|
|
169
|
-
*
|
|
165
|
+
/**
|
|
166
|
+
* Cast int32 value to uint16 as per C standard.
|
|
170
167
|
*
|
|
171
|
-
*
|
|
168
|
+
* @param x Input value.
|
|
172
169
|
*
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
**************************************************/
|
|
170
|
+
* @return For int32_t x, the unique y in uint16_t so that x == y mod 2^16.
|
|
171
|
+
*/
|
|
176
172
|
static MLK_ALWAYS_INLINE uint16_t mlk_cast_int32_to_uint16(int32_t x)
|
|
177
173
|
{
|
|
178
174
|
return (uint16_t)(x & (int32_t)UINT16_MAX);
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
|
|
182
|
-
*
|
|
177
|
+
/**
|
|
178
|
+
* Cast int16 value to uint16 as per C standard.
|
|
183
179
|
*
|
|
184
|
-
*
|
|
180
|
+
* @param x Input value.
|
|
185
181
|
*
|
|
186
|
-
*
|
|
187
|
-
|
|
188
|
-
**************************************************/
|
|
182
|
+
* @return For int16_t x, the unique y in uint16_t so that x == y mod 2^16.
|
|
183
|
+
*/
|
|
189
184
|
static MLK_ALWAYS_INLINE uint16_t mlk_cast_int16_to_uint16(int32_t x)
|
|
190
185
|
{
|
|
191
|
-
return mlk_cast_int32_to_uint16(
|
|
186
|
+
return mlk_cast_int32_to_uint16(x);
|
|
192
187
|
}
|
|
193
188
|
|
|
194
|
-
|
|
195
|
-
*
|
|
189
|
+
/**
|
|
190
|
+
* Return 0 if input is non-negative, and -1 otherwise.
|
|
196
191
|
*
|
|
197
|
-
*
|
|
192
|
+
* @reference{Embedded in the polynomial compression function in the
|
|
193
|
+
* reference implementation @[REF]. Used as part of signed->unsigned
|
|
194
|
+
* conversion for modular representatives to detect whether the input is
|
|
195
|
+
* negative. This happens in `mlk_poly_reduce()` here, and as part of
|
|
196
|
+
* polynomial compression functions in the reference implementation. See
|
|
197
|
+
* `mlk_poly_reduce()`. We use value barriers to reduce the risk of
|
|
198
|
+
* compiler-introduced branches.}
|
|
198
199
|
*
|
|
199
|
-
*
|
|
200
|
+
* @param x Value to be converted into a mask.
|
|
200
201
|
*
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
/* Reference: Embedded in polynomial compression function in the
|
|
204
|
-
* reference implementation @[REF].
|
|
205
|
-
* - Used as part of signed->unsigned conversion for modular
|
|
206
|
-
* representatives to detect whether the input is negative.
|
|
207
|
-
* This happen in `mlk_poly_reduce()` here, and as part of
|
|
208
|
-
* polynomial compression functions in the reference
|
|
209
|
-
* implementation. See `mlk_poly_reduce()`.
|
|
210
|
-
* - We use value barriers to reduce the risk of
|
|
211
|
-
* compiler-introduced branches. */
|
|
202
|
+
* @return Mask value (0 or 0xFFFF).
|
|
203
|
+
*/
|
|
212
204
|
static MLK_INLINE uint16_t mlk_ct_cmask_neg_i16(int16_t x)
|
|
213
205
|
__contract__(ensures(return_value == ((x < 0) ? 0xFFFF : 0)))
|
|
214
206
|
{
|
|
215
207
|
int32_t tmp = mlk_value_barrier_i32((int32_t)x);
|
|
208
|
+
/*
|
|
209
|
+
* PORTABILITY: Right-shift on a signed integer is
|
|
210
|
+
* implementation-defined for negative left argument.
|
|
211
|
+
* Here, we assume it's sign-preserving "arithmetic" shift right.
|
|
212
|
+
* See (C99 6.5.7 (5))
|
|
213
|
+
*/
|
|
216
214
|
tmp >>= 16;
|
|
217
215
|
return mlk_cast_int32_to_uint16(tmp);
|
|
218
216
|
}
|
|
219
217
|
|
|
220
|
-
|
|
221
|
-
*
|
|
218
|
+
/**
|
|
219
|
+
* Return 0 if input is zero, and -1 otherwise.
|
|
222
220
|
*
|
|
223
|
-
*
|
|
221
|
+
* @reference{Embedded in `cmov_int16()` in the reference implementation
|
|
222
|
+
* @[REF]. Uses a value barrier and shift instead of `b = -b` to convert
|
|
223
|
+
* condition into mask.}
|
|
224
224
|
*
|
|
225
|
-
*
|
|
225
|
+
* @param x Value to be converted into a mask.
|
|
226
226
|
*
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
/* Reference: Embedded in `cmov_int16()` in the reference implementation @[REF].
|
|
230
|
-
* - Use value barrier and shift instead of `b = -b` to
|
|
231
|
-
* convert condition into mask. */
|
|
227
|
+
* @return Mask value (0 or 0xFFFF).
|
|
228
|
+
*/
|
|
232
229
|
static MLK_INLINE uint16_t mlk_ct_cmask_nonzero_u16(uint16_t x)
|
|
233
230
|
__contract__(ensures(return_value == ((x == 0) ? 0 : 0xFFFF)))
|
|
234
231
|
{
|
|
235
232
|
int32_t tmp = mlk_value_barrier_i32(-((int32_t)x));
|
|
233
|
+
/*
|
|
234
|
+
* PORTABILITY: Right-shift on a signed integer is
|
|
235
|
+
* implementation-defined for negative left argument.
|
|
236
|
+
* Here, we assume it's sign-preserving "arithmetic" shift right.
|
|
237
|
+
* See (C99 6.5.7 (5))
|
|
238
|
+
*/
|
|
236
239
|
tmp >>= 16;
|
|
237
240
|
return mlk_cast_int32_to_uint16(tmp);
|
|
238
241
|
}
|
|
239
242
|
|
|
240
|
-
|
|
241
|
-
*
|
|
243
|
+
/**
|
|
244
|
+
* Return 0 if input is zero, and -1 otherwise.
|
|
242
245
|
*
|
|
243
|
-
*
|
|
246
|
+
* @reference{Embedded in `verify()` and `cmov()` in the reference
|
|
247
|
+
* implementation @[REF]. We include a value barrier not present in the
|
|
248
|
+
* reference implementation, to prevent the compiler from realizing that
|
|
249
|
+
* this function returns a mask.}
|
|
244
250
|
*
|
|
245
|
-
*
|
|
251
|
+
* @param x Value to be converted into a mask.
|
|
246
252
|
*
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
/* Reference: Embedded in `verify()` and `cmov()` in the
|
|
250
|
-
* reference implementation @[REF].
|
|
251
|
-
* - We include a value barrier not present in the
|
|
252
|
-
* reference implementation, to prevent the compiler
|
|
253
|
-
* from realizing that this function returns a mask. */
|
|
253
|
+
* @return Mask value (0 or 0xFF).
|
|
254
|
+
*/
|
|
254
255
|
static MLK_INLINE uint8_t mlk_ct_cmask_nonzero_u8(uint8_t x)
|
|
255
256
|
__contract__(ensures(return_value == ((x == 0) ? 0 : 0xFF)))
|
|
256
257
|
{
|
|
@@ -258,39 +259,33 @@ __contract__(ensures(return_value == ((x == 0) ? 0 : 0xFF)))
|
|
|
258
259
|
return (uint8_t)(mask & 0xFF);
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
|
|
288
|
-
* and as part of polynomial compression functions in @[REF].
|
|
289
|
-
* See `mlk_poly_reduce()`.
|
|
290
|
-
* - Barrier to reduce the risk of compiler-introduced branches.
|
|
291
|
-
* For `a = MLKEM_Q_HALF` and `b=0`, also embedded in
|
|
292
|
-
* `poly_frommsg()` from the reference implementation, which uses
|
|
293
|
-
* `cmov_int16()` instead. */
|
|
262
|
+
/**
|
|
263
|
+
* Functionally equivalent to cond ? a : b, but implemented with guards
|
|
264
|
+
* against compiler-introduced branches.
|
|
265
|
+
*
|
|
266
|
+
* @spec{With `a = MLKEM_Q_HALF` and `b=0`, this essentially implements
|
|
267
|
+
* `Decompress_1` @[FIPS203, Eq (4.8)] in `mlk_poly_frommsg()`. With
|
|
268
|
+
* `a = x + MLKEM_Q`, `b = x`, and `cond` indicating whether `x` is negative,
|
|
269
|
+
* implements signed->unsigned conversion of modular representatives.
|
|
270
|
+
* Questions of representation are not considered in the specification
|
|
271
|
+
* @[FIPS203, Section 2.4.1, "The pseudocode is agnostic regarding how an
|
|
272
|
+
* integer modulo 𝑚 is represented in actual implementations"].}
|
|
273
|
+
*
|
|
274
|
+
* @reference{Embedded in the polynomial compression function in the
|
|
275
|
+
* reference implementation @[REF]. Used as part of signed->unsigned
|
|
276
|
+
* conversion for modular representatives. This happens in `mlk_poly_reduce()`
|
|
277
|
+
* here, and as part of polynomial compression functions in @[REF]. See
|
|
278
|
+
* `mlk_poly_reduce()`. Barrier to reduce the risk of compiler-introduced
|
|
279
|
+
* branches. For `a = MLKEM_Q_HALF` and `b=0`, also embedded in
|
|
280
|
+
* `poly_frommsg()` from the reference implementation, which uses
|
|
281
|
+
* `cmov_int16()` instead.}
|
|
282
|
+
*
|
|
283
|
+
* @param a First alternative.
|
|
284
|
+
* @param b Second alternative.
|
|
285
|
+
* @param cond Condition variable.
|
|
286
|
+
*
|
|
287
|
+
* @return @p a if @p cond != 0, else @p b.
|
|
288
|
+
*/
|
|
294
289
|
static MLK_INLINE int16_t mlk_ct_sel_int16(int16_t a, int16_t b, uint16_t cond)
|
|
295
290
|
__contract__(ensures(return_value == (cond ? a : b)))
|
|
296
291
|
{
|
|
@@ -300,53 +295,46 @@ __contract__(ensures(return_value == (cond ? a : b)))
|
|
|
300
295
|
return mlk_cast_uint16_to_int16(res);
|
|
301
296
|
}
|
|
302
297
|
|
|
303
|
-
|
|
304
|
-
*
|
|
298
|
+
/**
|
|
299
|
+
* Functionally equivalent to cond ? a : b, but implemented with guards
|
|
300
|
+
* against compiler-introduced branches.
|
|
305
301
|
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* compiler-introduced branches.
|
|
302
|
+
* @reference{Embedded into `cmov()` in the reference implementation @[REF].
|
|
303
|
+
* Uses a value barrier to get mask from condition value.}
|
|
309
304
|
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
305
|
+
* @param a First alternative.
|
|
306
|
+
* @param b Second alternative.
|
|
307
|
+
* @param cond Condition variable.
|
|
313
308
|
*
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
/* Reference: Embedded into `cmov()` in the reference implementation @[REF].
|
|
317
|
-
* - Use value barrier to get mask from condition value. */
|
|
309
|
+
* @return @p a if @p cond != 0, else @p b.
|
|
310
|
+
*/
|
|
318
311
|
static MLK_INLINE uint8_t mlk_ct_sel_uint8(uint8_t a, uint8_t b, uint8_t cond)
|
|
319
312
|
__contract__(ensures(return_value == (cond ? a : b)))
|
|
320
313
|
{
|
|
321
314
|
return b ^ (mlk_ct_cmask_nonzero_u8(cond) & (a ^ b));
|
|
322
315
|
}
|
|
323
316
|
|
|
324
|
-
|
|
325
|
-
*
|
|
317
|
+
/**
|
|
318
|
+
* Compare two arrays for equality in constant time.
|
|
326
319
|
*
|
|
327
|
-
*
|
|
320
|
+
* @spec{Used to securely compute conditional move in @[FIPS203, Algorithm
|
|
321
|
+
* 18 (ML-KEM.Decaps_Internal, L9-11].}
|
|
328
322
|
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
323
|
+
* @reference{`cmov()` in the reference implementation @[REF]. We return
|
|
324
|
+
* `uint8_t`, not `int`. We use an additional XOR-accumulator in the
|
|
325
|
+
* comparison loop which prevents early abort if the OR-accumulator is 0xFF.
|
|
326
|
+
* We use a value barrier to convert the OR-accumulator into a mask; the
|
|
327
|
+
* reference implementation uses a shift which the compiler can argue to
|
|
328
|
+
* result in either 0 or 0xFF..FF.}
|
|
334
329
|
*
|
|
335
|
-
*
|
|
330
|
+
* @param[in] a First byte array.
|
|
331
|
+
* @param[in] b Second byte array.
|
|
332
|
+
* @param len Length of the byte arrays, upper-bounded to UINT16_MAX to
|
|
333
|
+
* control proof complexity only.
|
|
336
334
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
|
|
340
|
-
*
|
|
341
|
-
**************************************************/
|
|
342
|
-
|
|
343
|
-
/* Reference: `cmov()` in the reference implementation @[REF]
|
|
344
|
-
* - We return `uint8_t`, not `int`.
|
|
345
|
-
* - We use an additional XOR-accumulator in the comparison loop
|
|
346
|
-
* which prevents early abort if the OR-accumulator is 0xFF.
|
|
347
|
-
* - We use a value barrier to convert the OR-accumulator into
|
|
348
|
-
* a mask. The reference implementation uses a shift which the
|
|
349
|
-
* compiler can argue to result in either 0 of 0xFF..FF. */
|
|
335
|
+
* @retval 0 The byte arrays are equal.
|
|
336
|
+
* @retval 0xFF The byte arrays are not equal.
|
|
337
|
+
*/
|
|
350
338
|
static MLK_INLINE uint8_t mlk_ct_memcmp(const uint8_t *a, const uint8_t *b,
|
|
351
339
|
const size_t len)
|
|
352
340
|
__contract__(
|
|
@@ -362,7 +350,8 @@ __contract__(
|
|
|
362
350
|
for (i = 0; i < len; i++)
|
|
363
351
|
__loop__(
|
|
364
352
|
invariant(i <= len)
|
|
365
|
-
invariant((r == 0) == (forall(k, 0, i, (a[k] == b[k]))))
|
|
353
|
+
invariant((r == 0) == (forall(k, 0, i, (a[k] == b[k]))))
|
|
354
|
+
decreases(len - i))
|
|
366
355
|
{
|
|
367
356
|
r |= a[i] ^ b[i];
|
|
368
357
|
/* s is useless, but prevents the loop from being aborted once r=0xff. */
|
|
@@ -379,32 +368,27 @@ __contract__(
|
|
|
379
368
|
return (mlk_value_barrier_u8(mlk_ct_cmask_nonzero_u8(r) ^ s) ^ s);
|
|
380
369
|
}
|
|
381
370
|
|
|
382
|
-
|
|
383
|
-
*
|
|
371
|
+
/**
|
|
372
|
+
* Copy len bytes from x to r if b is zero; don't modify x if b is non-zero.
|
|
373
|
+
* Assumes two's complement representation of negative integers. Runs in
|
|
374
|
+
* constant time.
|
|
384
375
|
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* assumes two's complement representation of negative integers.
|
|
388
|
-
* Runs in constant time.
|
|
376
|
+
* @spec{Used to securely compute conditional move in @[FIPS203, Algorithm
|
|
377
|
+
* 18 (ML-KEM.Decaps_Internal, L9-11].}
|
|
389
378
|
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* uint8_t b: Condition value.
|
|
379
|
+
* @reference{`cmov()` in the reference implementation @[REF]. We move if
|
|
380
|
+
* condition value is `0`, not `1`. We use `mlk_ct_sel_uint8` for
|
|
381
|
+
* constant-time selection.}
|
|
394
382
|
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
/* Reference: `cmov()` in the reference implementation @[REF].
|
|
402
|
-
* - We move if condition value is `0`, not `1`.
|
|
403
|
-
* - We use `mlk_ct_sel_uint8` for constant-time selection. */
|
|
383
|
+
* @param[out] r Output byte array.
|
|
384
|
+
* @param[in] x Input byte array.
|
|
385
|
+
* @param len Number of bytes to be copied.
|
|
386
|
+
* @param b Condition value.
|
|
387
|
+
*/
|
|
404
388
|
static MLK_INLINE void mlk_ct_cmov_zero(uint8_t *r, const uint8_t *x,
|
|
405
389
|
size_t len, uint8_t b)
|
|
406
390
|
__contract__(
|
|
407
|
-
requires(len <=
|
|
391
|
+
requires(len <= UINT32_MAX)
|
|
408
392
|
requires(memory_no_alias(r, len))
|
|
409
393
|
requires(memory_no_alias(x, len))
|
|
410
394
|
assigns(memory_slice(r, len))
|
|
@@ -414,26 +398,24 @@ __contract__(
|
|
|
414
398
|
for (i = 0; i < len; i++)
|
|
415
399
|
__loop__(
|
|
416
400
|
invariant(i <= len)
|
|
417
|
-
invariant(forall(k, 0, i, r[k] == (b == 0 ? x[k] : loop_entry(r)[k])))
|
|
401
|
+
invariant(forall(k, 0, i, r[k] == (b == 0 ? x[k] : loop_entry(r)[k])))
|
|
402
|
+
decreases(len - i))
|
|
418
403
|
{
|
|
419
404
|
r[i] = mlk_ct_sel_uint8(r[i], x[i], b);
|
|
420
405
|
}
|
|
421
406
|
}
|
|
422
407
|
|
|
423
|
-
|
|
424
|
-
*
|
|
408
|
+
/**
|
|
409
|
+
* Force-zeroize a buffer.
|
|
425
410
|
*
|
|
426
|
-
*
|
|
411
|
+
* @spec{Used to implement @[FIPS203, Section 3.3, Destruction of
|
|
412
|
+
* intermediate values].}
|
|
427
413
|
*
|
|
428
|
-
*
|
|
429
|
-
* size_t len: Amount of bytes to be zeroed
|
|
414
|
+
* @reference{Not present in the reference implementation @[REF].}
|
|
430
415
|
*
|
|
431
|
-
*
|
|
432
|
-
* @
|
|
433
|
-
|
|
434
|
-
**************************************************/
|
|
435
|
-
|
|
436
|
-
/* Reference: Not present in the reference implementation @[REF]. */
|
|
416
|
+
* @param[out] ptr Buffer to be zeroed.
|
|
417
|
+
* @param len Number of bytes to be zeroed.
|
|
418
|
+
*/
|
|
437
419
|
#if !defined(MLK_CONFIG_CUSTOM_ZEROIZE)
|
|
438
420
|
#if defined(MLK_SYS_WINDOWS)
|
|
439
421
|
#include <windows.h>
|
data/lib/pq_crypto/version.rb
CHANGED
data/script/vendor_libs.rb
CHANGED
|
@@ -13,17 +13,17 @@ MANIFEST_PATH = File.join(VENDOR_DIR, ".vendored")
|
|
|
13
13
|
PINS = {
|
|
14
14
|
mlkem: {
|
|
15
15
|
repo: "https://github.com/pq-code-package/mlkem-native.git",
|
|
16
|
-
ref: "v1.
|
|
17
|
-
commit: "
|
|
18
|
-
tree_sha256: "
|
|
16
|
+
ref: "v1.2.0",
|
|
17
|
+
commit: "0ba906cb14b1c241476134d7403a811b382ca498",
|
|
18
|
+
tree_sha256: "cc78ed199b8c65abe68635b23a13b294d5a8deb20c8bc7b4d76590c00976bb2d",
|
|
19
19
|
target: "mlkem-native",
|
|
20
20
|
source_dir: "mlkem"
|
|
21
21
|
},
|
|
22
22
|
mldsa: {
|
|
23
23
|
repo: "https://github.com/pq-code-package/mldsa-native.git",
|
|
24
|
-
ref: "v1.0.0-
|
|
25
|
-
commit: "
|
|
26
|
-
tree_sha256: "
|
|
24
|
+
ref: "v1.0.0-beta2",
|
|
25
|
+
commit: "9b0ee84f4cf399043eca59eca4e5f8531ca1d61b",
|
|
26
|
+
tree_sha256: "2887f59926c18a877e8c5a5e30727e84497c357032093d00d7135aedf53f011e",
|
|
27
27
|
target: "mldsa-native",
|
|
28
28
|
source_dir: "mldsa"
|
|
29
29
|
}
|