pq_crypto 0.6.4 → 0.6.5
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 +46 -0
- data/README.md +5 -0
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/README.md +2 -4
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +98 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +8 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +21 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +45 -44
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +36 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +13 -30
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +42 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +5 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +5 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +6 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +11 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +25 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_aarch64_asm.S → mlkem_poly_mulcache_compute_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +25 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10_avx2_asm.S → mlkem_poly_compress_d10_avx2_asm.S} +34 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11_avx2_asm.S → mlkem_poly_compress_d11_avx2_asm.S} +33 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4_avx2_asm.S → mlkem_poly_compress_d4_avx2_asm.S} +34 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5_avx2_asm.S → mlkem_poly_compress_d5_avx2_asm.S} +33 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10_avx2_asm.S → mlkem_poly_decompress_d10_avx2_asm.S} +32 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11_avx2_asm.S → mlkem_poly_decompress_d11_avx2_asm.S} +32 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4_avx2_asm.S → mlkem_poly_decompress_d4_avx2_asm.S} +32 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5_avx2_asm.S → mlkem_poly_decompress_d5_avx2_asm.S} +32 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_mulcache_compute_avx2_asm.S → mlkem_poly_mulcache_compute_avx2_asm.S} +29 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +35 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +35 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +35 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_avx2_asm.S → mlkem_rej_uniform_avx2_asm.S} +40 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +19 -1
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +3 -3
- metadata +40 -42
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
Description: Run rejection sampling on uniform random bytes to generate uniform random integers mod q
|
|
9
9
|
Signature: uint64_t mlk_rej_uniform_aarch64_asm(int16_t r[256], const uint8_t *buf, unsigned buflen, const uint8_t table[4096])
|
|
10
10
|
ABI:
|
|
11
|
+
Architecture: aarch64
|
|
12
|
+
CallingConvention: AAPCS64
|
|
13
|
+
Features: [NEON]
|
|
11
14
|
x0:
|
|
12
15
|
type: buffer
|
|
13
16
|
size_bytes: 512
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
|
|
43
46
|
/*
|
|
44
47
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
45
|
-
* dev/aarch64_opt/src/
|
|
48
|
+
* dev/aarch64_opt/src/mlkem_rej_uniform_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
|
|
46
49
|
*/
|
|
47
50
|
|
|
48
51
|
.text
|
|
@@ -70,23 +73,23 @@ MLK_ASM_FN_SYMBOL(rej_uniform_aarch64_asm)
|
|
|
70
73
|
mov x11, #0x0 // =0
|
|
71
74
|
eor v16.16b, v16.16b, v16.16b
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
Lmlk_rej_uniform_initial_zero:
|
|
74
77
|
str q16, [x7], #0x40
|
|
75
78
|
stur q16, [x7, #-0x30]
|
|
76
79
|
stur q16, [x7, #-0x20]
|
|
77
80
|
stur q16, [x7, #-0x10]
|
|
78
81
|
add x11, x11, #0x20
|
|
79
82
|
cmp x11, #0x100
|
|
80
|
-
b.lt
|
|
83
|
+
b.lt Lmlk_rej_uniform_initial_zero
|
|
81
84
|
mov x7, x8
|
|
82
85
|
mov x9, #0x0 // =0
|
|
83
86
|
mov x4, #0x100 // =256
|
|
84
87
|
cmp x2, #0x30
|
|
85
|
-
b.lo
|
|
88
|
+
b.lo Lmlk_rej_uniform_loop48_end
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
Lmlk_rej_uniform_loop48:
|
|
88
91
|
cmp x9, x4
|
|
89
|
-
b.hs
|
|
92
|
+
b.hs Lmlk_rej_uniform_memory_copy
|
|
90
93
|
sub x2, x2, #0x30
|
|
91
94
|
ld3 { v0.16b, v1.16b, v2.16b }, [x1], #48
|
|
92
95
|
zip1 v4.16b, v0.16b, v1.16b
|
|
@@ -150,14 +153,13 @@ Lrej_uniform_loop48:
|
|
|
150
153
|
add x9, x9, x12
|
|
151
154
|
add x9, x9, x14
|
|
152
155
|
cmp x2, #0x30
|
|
153
|
-
b.hs
|
|
156
|
+
b.hs Lmlk_rej_uniform_loop48
|
|
154
157
|
|
|
155
|
-
|
|
158
|
+
Lmlk_rej_uniform_loop48_end:
|
|
156
159
|
cmp x9, x4
|
|
157
|
-
b.hs
|
|
160
|
+
b.hs Lmlk_rej_uniform_memory_copy
|
|
158
161
|
cmp x2, #0x18
|
|
159
|
-
b.lo
|
|
160
|
-
sub x2, x2, #0x18
|
|
162
|
+
b.lo Lmlk_rej_uniform_memory_copy
|
|
161
163
|
ld3 { v0.8b, v1.8b, v2.8b }, [x1], #24
|
|
162
164
|
zip1 v4.16b, v0.16b, v1.16b
|
|
163
165
|
zip1 v5.16b, v1.16b, v2.16b
|
|
@@ -186,17 +188,16 @@ Lrej_uniform_loop48_end:
|
|
|
186
188
|
st1 { v16.8h }, [x7]
|
|
187
189
|
add x7, x7, x12, lsl #1
|
|
188
190
|
st1 { v17.8h }, [x7]
|
|
189
|
-
add x7, x7, x13, lsl #1
|
|
190
191
|
add x9, x9, x12
|
|
191
192
|
add x9, x9, x13
|
|
192
193
|
|
|
193
|
-
|
|
194
|
+
Lmlk_rej_uniform_memory_copy:
|
|
194
195
|
cmp x9, x4
|
|
195
196
|
csel x9, x9, x4, lo
|
|
196
197
|
mov x11, #0x0 // =0
|
|
197
198
|
mov x7, x8
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
Lmlk_rej_uniform_final_copy:
|
|
200
201
|
ldr q16, [x7], #0x40
|
|
201
202
|
ldur q17, [x7, #-0x30]
|
|
202
203
|
ldur q18, [x7, #-0x20]
|
|
@@ -207,11 +208,10 @@ Lrej_uniform_final_copy:
|
|
|
207
208
|
stur q19, [x0, #-0x10]
|
|
208
209
|
add x11, x11, #0x20
|
|
209
210
|
cmp x11, #0x100
|
|
210
|
-
b.lt
|
|
211
|
+
b.lt Lmlk_rej_uniform_final_copy
|
|
211
212
|
mov x0, x9
|
|
212
|
-
b Lrej_uniform_return
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
Lmlk_rej_uniform_return:
|
|
215
215
|
add sp, sp, #0x240
|
|
216
216
|
.cfi_adjust_cfa_offset -0x240
|
|
217
217
|
ret
|
|
@@ -144,7 +144,8 @@ __contract__(
|
|
|
144
144
|
ensures(array_bound(p, 0, MLKEM_N, 0, MLKEM_Q)));
|
|
145
145
|
#endif /* MLK_USE_NATIVE_NTT_CUSTOM_ORDER */
|
|
146
146
|
|
|
147
|
-
#if defined(MLK_USE_NATIVE_INTT)
|
|
147
|
+
#if defined(MLK_USE_NATIVE_INTT) && \
|
|
148
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API))
|
|
148
149
|
/**
|
|
149
150
|
* Compute the inverse negacyclic number-theoretic transform (NTT) of a
|
|
150
151
|
* polynomial in place.
|
|
@@ -168,7 +169,8 @@ __contract__(
|
|
|
168
169
|
ensures((return_value == MLK_NATIVE_FUNC_SUCCESS) ==> array_abs_bound(p, 0, MLKEM_N, MLK_INVNTT_BOUND))
|
|
169
170
|
ensures((return_value == MLK_NATIVE_FUNC_FALLBACK) ==> array_unchanged(p, MLKEM_N))
|
|
170
171
|
);
|
|
171
|
-
#endif /* MLK_USE_NATIVE_INTT
|
|
172
|
+
#endif /* MLK_USE_NATIVE_INTT && (!MLK_CONFIG_NO_ENCAPS_API || \
|
|
173
|
+
!MLK_CONFIG_NO_DECAPS_API) */
|
|
172
174
|
|
|
173
175
|
#if defined(MLK_USE_NATIVE_POLY_REDUCE)
|
|
174
176
|
/**
|
|
@@ -191,7 +193,7 @@ __contract__(
|
|
|
191
193
|
);
|
|
192
194
|
#endif /* MLK_USE_NATIVE_POLY_REDUCE */
|
|
193
195
|
|
|
194
|
-
#if defined(MLK_USE_NATIVE_POLY_TOMONT)
|
|
196
|
+
#if defined(MLK_USE_NATIVE_POLY_TOMONT) && !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
195
197
|
/**
|
|
196
198
|
* In-place conversion of all coefficients of a polynomial from the normal
|
|
197
199
|
* domain to the Montgomery domain.
|
|
@@ -210,7 +212,7 @@ __contract__(
|
|
|
210
212
|
ensures((return_value == MLK_NATIVE_FUNC_SUCCESS) ==> array_abs_bound(p, 0, MLKEM_N, MLKEM_Q))
|
|
211
213
|
ensures((return_value == MLK_NATIVE_FUNC_FALLBACK) ==> array_unchanged(p, MLKEM_N))
|
|
212
214
|
);
|
|
213
|
-
#endif /* MLK_USE_NATIVE_POLY_TOMONT */
|
|
215
|
+
#endif /* MLK_USE_NATIVE_POLY_TOMONT && !MLK_CONFIG_NO_KEYPAIR_API */
|
|
214
216
|
|
|
215
217
|
#if defined(MLK_USE_NATIVE_POLY_MULCACHE_COMPUTE)
|
|
216
218
|
/**
|
|
@@ -340,7 +342,9 @@ __contract__(
|
|
|
340
342
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
341
343
|
#endif /* MLK_USE_NATIVE_POLYVEC_BASEMUL_ACC_MONTGOMERY_CACHED */
|
|
342
344
|
|
|
343
|
-
#if defined(MLK_USE_NATIVE_POLY_TOBYTES)
|
|
345
|
+
#if defined(MLK_USE_NATIVE_POLY_TOBYTES) && \
|
|
346
|
+
(!defined(MLK_CONFIG_NO_KEYPAIR_API) || \
|
|
347
|
+
!defined(MLK_CONFIG_NO_ENCAPS_API))
|
|
344
348
|
/**
|
|
345
349
|
* Serialization of a polynomial with unsigned canonical coefficients.
|
|
346
350
|
*
|
|
@@ -362,9 +366,11 @@ __contract__(
|
|
|
362
366
|
assigns(memory_slice(r, MLKEM_POLYBYTES))
|
|
363
367
|
ensures(return_value == MLK_NATIVE_FUNC_SUCCESS || return_value == MLK_NATIVE_FUNC_FALLBACK)
|
|
364
368
|
);
|
|
365
|
-
#endif /* MLK_USE_NATIVE_POLY_TOBYTES
|
|
369
|
+
#endif /* MLK_USE_NATIVE_POLY_TOBYTES && (!MLK_CONFIG_NO_KEYPAIR_API || \
|
|
370
|
+
!MLK_CONFIG_NO_ENCAPS_API) */
|
|
366
371
|
|
|
367
|
-
#if defined(MLK_USE_NATIVE_POLY_FROMBYTES)
|
|
372
|
+
#if defined(MLK_USE_NATIVE_POLY_FROMBYTES) && \
|
|
373
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API))
|
|
368
374
|
/**
|
|
369
375
|
* Deserialization of a polynomial.
|
|
370
376
|
*
|
|
@@ -386,7 +392,8 @@ __contract__(
|
|
|
386
392
|
ensures(return_value == MLK_NATIVE_FUNC_SUCCESS || return_value == MLK_NATIVE_FUNC_FALLBACK)
|
|
387
393
|
ensures((return_value == MLK_NATIVE_FUNC_SUCCESS) ==> array_bound(a, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT))
|
|
388
394
|
);
|
|
389
|
-
#endif /* MLK_USE_NATIVE_POLY_FROMBYTES
|
|
395
|
+
#endif /* MLK_USE_NATIVE_POLY_FROMBYTES && (!MLK_CONFIG_NO_ENCAPS_API || \
|
|
396
|
+
!MLK_CONFIG_NO_DECAPS_API) */
|
|
390
397
|
|
|
391
398
|
#if defined(MLK_USE_NATIVE_REJ_UNIFORM)
|
|
392
399
|
/**
|
|
@@ -419,6 +426,7 @@ __contract__(
|
|
|
419
426
|
);
|
|
420
427
|
#endif /* MLK_USE_NATIVE_REJ_UNIFORM */
|
|
421
428
|
|
|
429
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
422
430
|
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || (MLKEM_K == 2 || MLKEM_K == 3)
|
|
423
431
|
#if defined(MLK_USE_NATIVE_POLY_COMPRESS_D4)
|
|
424
432
|
/**
|
|
@@ -470,6 +478,7 @@ __contract__(
|
|
|
470
478
|
ensures(return_value == MLK_NATIVE_FUNC_SUCCESS || return_value == MLK_NATIVE_FUNC_FALLBACK));
|
|
471
479
|
#endif /* MLK_USE_NATIVE_POLY_COMPRESS_D10 */
|
|
472
480
|
|
|
481
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
473
482
|
#if defined(MLK_USE_NATIVE_POLY_DECOMPRESS_D4)
|
|
474
483
|
/**
|
|
475
484
|
* De-serialization and subsequent decompression (4 bits) of a polynomial;
|
|
@@ -525,6 +534,7 @@ __contract__(
|
|
|
525
534
|
ensures(return_value == MLK_NATIVE_FUNC_SUCCESS || return_value == MLK_NATIVE_FUNC_FALLBACK)
|
|
526
535
|
ensures((return_value == MLK_NATIVE_FUNC_SUCCESS) ==> array_bound(r, 0, MLKEM_N, 0, MLKEM_Q)));
|
|
527
536
|
#endif /* MLK_USE_NATIVE_POLY_DECOMPRESS_D10 */
|
|
537
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
528
538
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3 */
|
|
529
539
|
|
|
530
540
|
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4
|
|
@@ -578,6 +588,7 @@ __contract__(
|
|
|
578
588
|
ensures(return_value == MLK_NATIVE_FUNC_SUCCESS || return_value == MLK_NATIVE_FUNC_FALLBACK));
|
|
579
589
|
#endif /* MLK_USE_NATIVE_POLY_COMPRESS_D11 */
|
|
580
590
|
|
|
591
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
581
592
|
#if defined(MLK_USE_NATIVE_POLY_DECOMPRESS_D5)
|
|
582
593
|
/**
|
|
583
594
|
* De-serialization and subsequent decompression (5 bits) of a polynomial;
|
|
@@ -633,6 +644,8 @@ __contract__(
|
|
|
633
644
|
ensures(return_value == MLK_NATIVE_FUNC_SUCCESS || return_value == MLK_NATIVE_FUNC_FALLBACK)
|
|
634
645
|
ensures((return_value == MLK_NATIVE_FUNC_SUCCESS) ==> array_bound(r, 0, MLKEM_N, 0, MLKEM_Q)));
|
|
635
646
|
#endif /* MLK_USE_NATIVE_POLY_DECOMPRESS_D11 */
|
|
647
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
636
648
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
649
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
637
650
|
|
|
638
651
|
#endif /* !MLK_NATIVE_API_H */
|
|
@@ -37,6 +37,7 @@ static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
|
|
|
37
37
|
#endif
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
40
41
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
41
42
|
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
42
43
|
{
|
|
@@ -48,6 +49,7 @@ static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
|
48
49
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
49
50
|
#endif
|
|
50
51
|
}
|
|
52
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
51
53
|
|
|
52
54
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
53
55
|
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
@@ -61,6 +63,7 @@ static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
|
61
63
|
#endif
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
64
67
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
65
68
|
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
66
69
|
{
|
|
@@ -72,6 +75,7 @@ static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
|
72
75
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
73
76
|
#endif
|
|
74
77
|
}
|
|
78
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
75
79
|
#endif /* !__ASSEMBLER__ */
|
|
76
80
|
|
|
77
81
|
#endif /* !MLK_NATIVE_PPC64LE_META_H */
|
|
@@ -8,11 +8,34 @@
|
|
|
8
8
|
|
|
9
9
|
#include "../../../common.h"
|
|
10
10
|
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
|
|
11
|
-
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
|
|
11
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__) && \
|
|
12
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
13
|
+
!defined(MLK_CONFIG_NO_DECAPS_API))
|
|
14
|
+
/*yaml
|
|
15
|
+
Name: intt_ppc_asm
|
|
16
|
+
Description: PowerPC64 VSX inverse NTT
|
|
17
|
+
Signature: void mlk_intt_ppc_asm(int16_t *r, const int16_t *qdata)
|
|
18
|
+
ABI:
|
|
19
|
+
Architecture: powerpc64le
|
|
20
|
+
CallingConvention: ELFv2
|
|
21
|
+
Features: [VSX]
|
|
22
|
+
r3:
|
|
23
|
+
type: buffer
|
|
24
|
+
size_bytes: 512
|
|
25
|
+
permissions: read/write
|
|
26
|
+
c_parameter: int16_t *r
|
|
27
|
+
description: Input/output polynomial (256 x int16_t)
|
|
28
|
+
r4:
|
|
29
|
+
type: buffer
|
|
30
|
+
size_bytes: 4144
|
|
31
|
+
permissions: read-only
|
|
32
|
+
c_parameter: const int16_t *qdata
|
|
33
|
+
description: Precomputed constants (2072 x int16_t)
|
|
34
|
+
*/
|
|
12
35
|
|
|
13
36
|
/*
|
|
14
37
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
15
|
-
* dev/ppc64le/src/
|
|
38
|
+
* dev/ppc64le/src/mlkem_intt_ppc_asm.S using scripts/simpasm. Do not modify it directly.
|
|
16
39
|
*/
|
|
17
40
|
|
|
18
41
|
.text
|
|
@@ -84,7 +107,7 @@ MLK_ASM_FN_SYMBOL(intt_ppc_asm)
|
|
|
84
107
|
mtctr 8
|
|
85
108
|
xxlor 37, 0, 0
|
|
86
109
|
|
|
87
|
-
|
|
110
|
+
mlk_intt_ppc_asm_Loopf:
|
|
88
111
|
lxvd2x 57, 0, 3
|
|
89
112
|
lxvd2x 58, 10, 3
|
|
90
113
|
lxvd2x 62, 11, 3
|
|
@@ -129,7 +152,7 @@ intt_ppc_asm_Loopf:
|
|
|
129
152
|
stxvd2x 55, 17, 3
|
|
130
153
|
stxvd2x 60, 18, 3
|
|
131
154
|
addi 3, 3, 128
|
|
132
|
-
bdnz
|
|
155
|
+
bdnz mlk_intt_ppc_asm_Loopf
|
|
133
156
|
addi 3, 3, -512
|
|
134
157
|
nop
|
|
135
158
|
nop
|
|
@@ -3215,7 +3238,8 @@ intt_ppc_asm_Loopf:
|
|
|
3215
3238
|
MLK_ASM_FN_SIZE(intt_ppc_asm)
|
|
3216
3239
|
|
|
3217
3240
|
#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
|
|
3218
|
-
&& __POWER8_VECTOR__
|
|
3241
|
+
&& __POWER8_VECTOR__ && (!MLK_CONFIG_NO_ENCAPS_API || \
|
|
3242
|
+
!MLK_CONFIG_NO_DECAPS_API) */
|
|
3219
3243
|
|
|
3220
3244
|
#if defined(__ELF__)
|
|
3221
3245
|
.section .note.GNU-stack,"",%progbits
|
|
@@ -9,10 +9,31 @@
|
|
|
9
9
|
#include "../../../common.h"
|
|
10
10
|
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
|
|
11
11
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
|
|
12
|
+
/*yaml
|
|
13
|
+
Name: ntt_ppc_asm
|
|
14
|
+
Description: PowerPC64 VSX forward NTT
|
|
15
|
+
Signature: void mlk_ntt_ppc_asm(int16_t *r, const int16_t *qdata)
|
|
16
|
+
ABI:
|
|
17
|
+
Architecture: powerpc64le
|
|
18
|
+
CallingConvention: ELFv2
|
|
19
|
+
Features: [VSX]
|
|
20
|
+
r3:
|
|
21
|
+
type: buffer
|
|
22
|
+
size_bytes: 512
|
|
23
|
+
permissions: read/write
|
|
24
|
+
c_parameter: int16_t *r
|
|
25
|
+
description: Input/output polynomial (256 x int16_t)
|
|
26
|
+
r4:
|
|
27
|
+
type: buffer
|
|
28
|
+
size_bytes: 4144
|
|
29
|
+
permissions: read-only
|
|
30
|
+
c_parameter: const int16_t *qdata
|
|
31
|
+
description: Precomputed constants (2072 x int16_t)
|
|
32
|
+
*/
|
|
12
33
|
|
|
13
34
|
/*
|
|
14
35
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
15
|
-
* dev/ppc64le/src/
|
|
36
|
+
* dev/ppc64le/src/mlkem_ntt_ppc_asm.S using scripts/simpasm. Do not modify it directly.
|
|
16
37
|
*/
|
|
17
38
|
|
|
18
39
|
.text
|
|
@@ -15,11 +15,33 @@
|
|
|
15
15
|
|
|
16
16
|
#include "../../../common.h"
|
|
17
17
|
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
|
|
18
|
-
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
|
|
18
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__) && \
|
|
19
|
+
!defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
20
|
+
/*yaml
|
|
21
|
+
Name: poly_tomont_ppc_asm
|
|
22
|
+
Description: PowerPC64 VSX conversion to Montgomery form
|
|
23
|
+
Signature: void mlk_poly_tomont_ppc_asm(int16_t *r, const int16_t *qdata)
|
|
24
|
+
ABI:
|
|
25
|
+
Architecture: powerpc64le
|
|
26
|
+
CallingConvention: ELFv2
|
|
27
|
+
Features: [VSX]
|
|
28
|
+
r3:
|
|
29
|
+
type: buffer
|
|
30
|
+
size_bytes: 512
|
|
31
|
+
permissions: read/write
|
|
32
|
+
c_parameter: int16_t *r
|
|
33
|
+
description: Input/output polynomial (256 x int16_t)
|
|
34
|
+
r4:
|
|
35
|
+
type: buffer
|
|
36
|
+
size_bytes: 4144
|
|
37
|
+
permissions: read-only
|
|
38
|
+
c_parameter: const int16_t *qdata
|
|
39
|
+
description: Precomputed constants (2072 x int16_t)
|
|
40
|
+
*/
|
|
19
41
|
|
|
20
42
|
/*
|
|
21
43
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
22
|
-
* dev/ppc64le/src/
|
|
44
|
+
* dev/ppc64le/src/mlkem_poly_tomont_ppc_asm.S using scripts/simpasm. Do not modify it directly.
|
|
23
45
|
*/
|
|
24
46
|
|
|
25
47
|
.text
|
|
@@ -287,7 +309,7 @@ MLK_ASM_FN_SYMBOL(poly_tomont_ppc_asm)
|
|
|
287
309
|
MLK_ASM_FN_SIZE(poly_tomont_ppc_asm)
|
|
288
310
|
|
|
289
311
|
#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
|
|
290
|
-
&& __POWER8_VECTOR__ */
|
|
312
|
+
&& __POWER8_VECTOR__ && !MLK_CONFIG_NO_KEYPAIR_API */
|
|
291
313
|
|
|
292
314
|
#if defined(__ELF__)
|
|
293
315
|
.section .note.GNU-stack,"",%progbits
|
|
@@ -8,10 +8,31 @@
|
|
|
8
8
|
#include "../../../common.h"
|
|
9
9
|
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
|
|
10
10
|
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
|
|
11
|
+
/*yaml
|
|
12
|
+
Name: reduce_ppc_asm
|
|
13
|
+
Description: PowerPC64 VSX modular reduction
|
|
14
|
+
Signature: void mlk_reduce_ppc_asm(int16_t *r, const int16_t *qdata)
|
|
15
|
+
ABI:
|
|
16
|
+
Architecture: powerpc64le
|
|
17
|
+
CallingConvention: ELFv2
|
|
18
|
+
Features: [VSX]
|
|
19
|
+
r3:
|
|
20
|
+
type: buffer
|
|
21
|
+
size_bytes: 512
|
|
22
|
+
permissions: read/write
|
|
23
|
+
c_parameter: int16_t *r
|
|
24
|
+
description: Input/output polynomial (256 x int16_t)
|
|
25
|
+
r4:
|
|
26
|
+
type: buffer
|
|
27
|
+
size_bytes: 4144
|
|
28
|
+
permissions: read-only
|
|
29
|
+
c_parameter: const int16_t *qdata
|
|
30
|
+
description: Precomputed constants (2072 x int16_t)
|
|
31
|
+
*/
|
|
11
32
|
|
|
12
33
|
/*
|
|
13
34
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
14
|
-
* dev/ppc64le/src/
|
|
35
|
+
* dev/ppc64le/src/mlkem_reduce_ppc_asm.S using scripts/simpasm. Do not modify it directly.
|
|
15
36
|
*/
|
|
16
37
|
|
|
17
38
|
.text
|
|
@@ -40,6 +40,7 @@ static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
|
|
|
40
40
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
43
44
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
44
45
|
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
45
46
|
{
|
|
@@ -52,13 +53,16 @@ static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
|
52
53
|
mlk_rv64v_poly_invntt_tomont(data);
|
|
53
54
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
54
55
|
}
|
|
56
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
55
57
|
|
|
58
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
56
59
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
57
60
|
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
58
61
|
{
|
|
59
62
|
mlk_rv64v_poly_tomont(data);
|
|
60
63
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
61
64
|
}
|
|
65
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
62
66
|
|
|
63
67
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
64
68
|
static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
#define mlk_rv64v_poly_ntt MLK_NAMESPACE(ntt_riscv64)
|
|
11
11
|
void mlk_rv64v_poly_ntt(int16_t *);
|
|
12
12
|
|
|
13
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
13
14
|
#define mlk_rv64v_poly_invntt_tomont MLK_NAMESPACE(intt_riscv64)
|
|
14
15
|
void mlk_rv64v_poly_invntt_tomont(int16_t *r);
|
|
16
|
+
#endif
|
|
15
17
|
|
|
16
18
|
#define mlk_rv64v_poly_basemul_mont_add_k2 MLK_NAMESPACE(basemul_add_k2_riscv64)
|
|
17
19
|
void mlk_rv64v_poly_basemul_mont_add_k2(int16_t *r, const int16_t *a,
|
|
@@ -25,8 +27,10 @@ void mlk_rv64v_poly_basemul_mont_add_k3(int16_t *r, const int16_t *a,
|
|
|
25
27
|
void mlk_rv64v_poly_basemul_mont_add_k4(int16_t *r, const int16_t *a,
|
|
26
28
|
const int16_t *b);
|
|
27
29
|
|
|
30
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
28
31
|
#define mlk_rv64v_poly_tomont MLK_NAMESPACE(tomont_riscv64)
|
|
29
32
|
void mlk_rv64v_poly_tomont(int16_t *r);
|
|
33
|
+
#endif
|
|
30
34
|
|
|
31
35
|
#define mlk_rv64v_poly_reduce MLK_NAMESPACE(reduce_riscv64)
|
|
32
36
|
void mlk_rv64v_poly_reduce(int16_t *r);
|
|
@@ -78,8 +78,8 @@ static MLK_INLINE vint16m1_t fq_barrett(vint16m1_t a, size_t vl)
|
|
|
78
78
|
* masked ops, and Zvkt's DIEL guarantee does not cover the v0 mask
|
|
79
79
|
* register. Using an arithmetic-shift sign mask keeps all operands in the
|
|
80
80
|
* Zvkt-covered set and matches the idiom used in the portable C
|
|
81
|
-
* (mlk_ct_cmask_neg_i16, verify.h) and AArch64
|
|
82
|
-
* implementations. */
|
|
81
|
+
* (mlk_ct_cmask_neg_i16, verify.h) and AArch64
|
|
82
|
+
* (mlkem_poly_reduce_aarch64_asm.S) implementations. */
|
|
83
83
|
|
|
84
84
|
static MLK_INLINE vint16m1_t fq_cadd(vint16m1_t rx, size_t vl)
|
|
85
85
|
{
|
|
@@ -324,6 +324,7 @@ void mlk_rv64v_poly_ntt(int16_t *r)
|
|
|
324
324
|
&r[0xe0], mlk_rv64v_ntt2(__riscv_vcreate_v_i16m1_i16m2(ve, vf), ze), vl2);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
327
328
|
/* Reverse / Gentleman-Sande butterfly operation */
|
|
328
329
|
|
|
329
330
|
#define MLK_RVV_GS_BFLY_RX(u0, u1, ut, uc, vl) \
|
|
@@ -604,6 +605,7 @@ void mlk_rv64v_poly_invntt_tomont(int16_t *r)
|
|
|
604
605
|
__riscv_vse16_v_i16m1(&r[0xe0], ve, vl);
|
|
605
606
|
__riscv_vse16_v_i16m1(&r[0xf0], vf, vl);
|
|
606
607
|
}
|
|
608
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
607
609
|
|
|
608
610
|
/* ML-KEM's middle field GF(3329)[X]/(X^2) multiplication */
|
|
609
611
|
|
|
@@ -682,6 +684,7 @@ void mlk_rv64v_poly_basemul_mont_add_k4(int16_t *r, const int16_t *a,
|
|
|
682
684
|
}
|
|
683
685
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
684
686
|
|
|
687
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
685
688
|
/**
|
|
686
689
|
* In-place conversion of all coefficients of a polynomial from the normal
|
|
687
690
|
* domain to the Montgomery domain.
|
|
@@ -700,6 +703,7 @@ void mlk_rv64v_poly_tomont(int16_t *r)
|
|
|
700
703
|
__riscv_vse16_v_i16m1(&r[i], vec, vl);
|
|
701
704
|
}
|
|
702
705
|
}
|
|
706
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
703
707
|
|
|
704
708
|
/**
|
|
705
709
|
* Apply Barrett reduction to all coefficients of a polynomial. For details
|
|
@@ -68,6 +68,7 @@ static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
|
|
|
68
68
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
71
72
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
72
73
|
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
73
74
|
{
|
|
@@ -79,6 +80,7 @@ static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
|
79
80
|
mlk_invntt_avx2_asm(data, mlk_qdata);
|
|
80
81
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
81
82
|
}
|
|
83
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
82
84
|
|
|
83
85
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
84
86
|
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
@@ -92,6 +94,7 @@ static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
|
92
94
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
95
98
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
96
99
|
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
97
100
|
{
|
|
@@ -103,6 +106,7 @@ static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
|
103
106
|
mlk_tomont_avx2_asm(data);
|
|
104
107
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
105
108
|
}
|
|
109
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
106
110
|
|
|
107
111
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
108
112
|
static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
|
|
@@ -165,6 +169,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
|
|
|
165
169
|
}
|
|
166
170
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
167
171
|
|
|
172
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) || !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
168
173
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
169
174
|
static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
|
|
170
175
|
const int16_t a[MLKEM_N])
|
|
@@ -177,7 +182,9 @@ static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
|
|
|
177
182
|
mlk_ntttobytes_avx2_asm(r, a);
|
|
178
183
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
179
184
|
}
|
|
185
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API */
|
|
180
186
|
|
|
187
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
181
188
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
182
189
|
static MLK_INLINE int mlk_poly_frombytes_native(
|
|
183
190
|
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYBYTES])
|
|
@@ -190,8 +197,12 @@ static MLK_INLINE int mlk_poly_frombytes_native(
|
|
|
190
197
|
mlk_nttfrombytes_avx2_asm(r, a);
|
|
191
198
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
192
199
|
}
|
|
200
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
193
201
|
|
|
194
|
-
#if defined(
|
|
202
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
203
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
204
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
|
|
205
|
+
MLKEM_K == 3)
|
|
195
206
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
196
207
|
static MLK_INLINE int mlk_poly_compress_d4_native(
|
|
197
208
|
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4], const int16_t a[MLKEM_N])
|
|
@@ -218,6 +229,7 @@ static MLK_INLINE int mlk_poly_compress_d10_native(
|
|
|
218
229
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
219
230
|
}
|
|
220
231
|
|
|
232
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
221
233
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
222
234
|
static MLK_INLINE int mlk_poly_decompress_d4_native(
|
|
223
235
|
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4])
|
|
@@ -243,9 +255,14 @@ static MLK_INLINE int mlk_poly_decompress_d10_native(
|
|
|
243
255
|
mlk_poly_decompress_d10_avx2_asm(r, a, mlk_decompress_d10_data);
|
|
244
256
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
245
257
|
}
|
|
246
|
-
#endif /*
|
|
247
|
-
|
|
248
|
-
|
|
258
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
259
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
260
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3) \
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
#if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
264
|
+
!defined(MLK_CONFIG_NO_DECAPS_API)) && \
|
|
265
|
+
(defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
|
|
249
266
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
250
267
|
static MLK_INLINE int mlk_poly_compress_d5_native(
|
|
251
268
|
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5], const int16_t a[MLKEM_N])
|
|
@@ -272,6 +289,7 @@ static MLK_INLINE int mlk_poly_compress_d11_native(
|
|
|
272
289
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
273
290
|
}
|
|
274
291
|
|
|
292
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
275
293
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
276
294
|
static MLK_INLINE int mlk_poly_decompress_d5_native(
|
|
277
295
|
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5])
|
|
@@ -297,7 +315,9 @@ static MLK_INLINE int mlk_poly_decompress_d11_native(
|
|
|
297
315
|
mlk_poly_decompress_d11_avx2_asm(r, a, mlk_decompress_d11_data);
|
|
298
316
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
299
317
|
}
|
|
300
|
-
#endif /*
|
|
318
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
319
|
+
#endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
|
|
320
|
+
(MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
|
|
301
321
|
|
|
302
322
|
#endif /* !__ASSEMBLER__ */
|
|
303
323
|
|