pq_crypto 0.6.3 → 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/.github/workflows/ci.yml +149 -17
- data/CHANGELOG.md +73 -0
- data/GET_STARTED.md +1 -1
- data/README.md +7 -2
- data/ext/pqcrypto/extconf.rb +264 -24
- 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 +41 -43
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
#define mlk_check_pct MLK_ADD_PARAM_SET(mlk_check_pct) MLK_CONTEXT_PARAMETERS_2
|
|
38
38
|
/* End of parameter set namespacing */
|
|
39
39
|
|
|
40
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
40
41
|
/* Reference: Not implemented in the reference implementation @[REF]. */
|
|
41
42
|
MLK_EXTERNAL_API
|
|
42
43
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
@@ -68,8 +69,10 @@ cleanup:
|
|
|
68
69
|
MLK_FREE(p, mlk_polyvec, 1, context);
|
|
69
70
|
return ret;
|
|
70
71
|
}
|
|
72
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API */
|
|
71
73
|
|
|
72
74
|
|
|
75
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
73
76
|
/* Reference: Not implemented in the reference implementation @[REF]. */
|
|
74
77
|
MLK_EXTERNAL_API
|
|
75
78
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
@@ -113,7 +116,9 @@ cleanup:
|
|
|
113
116
|
MLK_FREE(test, uint8_t, MLKEM_SYMBYTES, context);
|
|
114
117
|
return ret;
|
|
115
118
|
}
|
|
119
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
116
120
|
|
|
121
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
117
122
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
118
123
|
static int mlk_check_pct(uint8_t const pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
119
124
|
uint8_t const sk[MLKEM_INDCCA_SECRETKEYBYTES],
|
|
@@ -207,6 +212,7 @@ static int mlk_check_pct(uint8_t const pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
|
207
212
|
* - We optionally include PCT which is not present in
|
|
208
213
|
* the reference code. */
|
|
209
214
|
MLK_EXTERNAL_API
|
|
215
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
210
216
|
int mlk_kem_keypair_derand(uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
211
217
|
uint8_t sk[MLKEM_INDCCA_SECRETKEYBYTES],
|
|
212
218
|
const uint8_t coins[2 * MLKEM_SYMBYTES],
|
|
@@ -282,7 +288,9 @@ cleanup:
|
|
|
282
288
|
return ret;
|
|
283
289
|
}
|
|
284
290
|
#endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
|
|
291
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
285
292
|
|
|
293
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
286
294
|
/* Reference: `crypto_kem_enc_derand()` in the reference implementation @[REF]
|
|
287
295
|
* - We include public key check
|
|
288
296
|
* - We include stack buffer zeroization */
|
|
@@ -368,7 +376,9 @@ cleanup:
|
|
|
368
376
|
return ret;
|
|
369
377
|
}
|
|
370
378
|
#endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
|
|
379
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API */
|
|
371
380
|
|
|
381
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
372
382
|
/* Reference: `crypto_kem_dec()` in the reference implementation @[REF]
|
|
373
383
|
* - We include secret key check
|
|
374
384
|
* - We include stack buffer zeroization */
|
|
@@ -440,6 +450,7 @@ cleanup:
|
|
|
440
450
|
|
|
441
451
|
return ret;
|
|
442
452
|
}
|
|
453
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
443
454
|
|
|
444
455
|
/* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
|
|
445
456
|
* Don't modify by hand -- this is auto-generated by scripts/autogen. */
|
|
@@ -46,14 +46,24 @@
|
|
|
46
46
|
|
|
47
47
|
#endif /* MLK_CHECK_APIS */
|
|
48
48
|
|
|
49
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
49
50
|
#define mlk_kem_keypair_derand \
|
|
50
51
|
MLK_NAMESPACE_K(keypair_derand) MLK_CONTEXT_PARAMETERS_3
|
|
52
|
+
#if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
|
|
51
53
|
#define mlk_kem_keypair MLK_NAMESPACE_K(keypair) MLK_CONTEXT_PARAMETERS_2
|
|
54
|
+
#endif
|
|
55
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
56
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
52
57
|
#define mlk_kem_enc_derand MLK_NAMESPACE_K(enc_derand) MLK_CONTEXT_PARAMETERS_4
|
|
58
|
+
#if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
|
|
53
59
|
#define mlk_kem_enc MLK_NAMESPACE_K(enc) MLK_CONTEXT_PARAMETERS_3
|
|
54
|
-
#
|
|
60
|
+
#endif
|
|
55
61
|
#define mlk_kem_check_pk MLK_NAMESPACE_K(check_pk) MLK_CONTEXT_PARAMETERS_1
|
|
62
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API */
|
|
63
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
64
|
+
#define mlk_kem_dec MLK_NAMESPACE_K(dec) MLK_CONTEXT_PARAMETERS_3
|
|
56
65
|
#define mlk_kem_check_sk MLK_NAMESPACE_K(check_sk) MLK_CONTEXT_PARAMETERS_1
|
|
66
|
+
#endif
|
|
57
67
|
|
|
58
68
|
/**
|
|
59
69
|
* Implements modulus check mandated by FIPS 203, i.e., ensures that
|
|
@@ -74,6 +84,7 @@
|
|
|
74
84
|
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
75
85
|
* MLK_CUSTOM_ALLOC returned NULL.
|
|
76
86
|
*/
|
|
87
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
77
88
|
MLK_EXTERNAL_API
|
|
78
89
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
79
90
|
int mlk_kem_check_pk(const uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
|
|
@@ -83,6 +94,7 @@ __contract__(
|
|
|
83
94
|
ensures(return_value == 0 || return_value == MLK_ERR_FAIL ||
|
|
84
95
|
return_value == MLK_ERR_OUT_OF_MEMORY)
|
|
85
96
|
);
|
|
97
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API */
|
|
86
98
|
|
|
87
99
|
|
|
88
100
|
/**
|
|
@@ -104,6 +116,7 @@ __contract__(
|
|
|
104
116
|
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
105
117
|
* MLK_CUSTOM_ALLOC returned NULL.
|
|
106
118
|
*/
|
|
119
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
107
120
|
MLK_EXTERNAL_API
|
|
108
121
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
109
122
|
int mlk_kem_check_sk(const uint8_t sk[MLKEM_INDCCA_SECRETKEYBYTES],
|
|
@@ -113,7 +126,9 @@ __contract__(
|
|
|
113
126
|
ensures(return_value == 0 || return_value == MLK_ERR_FAIL ||
|
|
114
127
|
return_value == MLK_ERR_OUT_OF_MEMORY)
|
|
115
128
|
);
|
|
129
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
116
130
|
|
|
131
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
117
132
|
/**
|
|
118
133
|
* Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
|
|
119
134
|
*
|
|
@@ -151,6 +166,7 @@ __contract__(
|
|
|
151
166
|
return_value == MLK_ERR_RNG_FAIL)
|
|
152
167
|
);
|
|
153
168
|
|
|
169
|
+
#if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
|
|
154
170
|
/**
|
|
155
171
|
* Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
|
|
156
172
|
*
|
|
@@ -184,6 +200,8 @@ __contract__(
|
|
|
184
200
|
return_value == MLK_ERR_OUT_OF_MEMORY ||
|
|
185
201
|
return_value == MLK_ERR_RNG_FAIL)
|
|
186
202
|
);
|
|
203
|
+
#endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
|
|
204
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
187
205
|
|
|
188
206
|
/**
|
|
189
207
|
* Generate ciphertext and shared secret for a given public key.
|
|
@@ -208,6 +226,7 @@ __contract__(
|
|
|
208
226
|
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
209
227
|
* MLK_CUSTOM_ALLOC returned NULL.
|
|
210
228
|
*/
|
|
229
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
211
230
|
MLK_EXTERNAL_API
|
|
212
231
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
213
232
|
int mlk_kem_enc_derand(uint8_t ct[MLKEM_INDCCA_CIPHERTEXTBYTES],
|
|
@@ -226,6 +245,7 @@ __contract__(
|
|
|
226
245
|
return_value == MLK_ERR_OUT_OF_MEMORY)
|
|
227
246
|
);
|
|
228
247
|
|
|
248
|
+
#if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
|
|
229
249
|
/**
|
|
230
250
|
* Generate ciphertext and shared secret for a given public key.
|
|
231
251
|
*
|
|
@@ -264,6 +284,8 @@ __contract__(
|
|
|
264
284
|
return_value == MLK_ERR_OUT_OF_MEMORY ||
|
|
265
285
|
return_value == MLK_ERR_RNG_FAIL)
|
|
266
286
|
);
|
|
287
|
+
#endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
|
|
288
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API */
|
|
267
289
|
|
|
268
290
|
/**
|
|
269
291
|
* Generate shared secret for a given ciphertext and private key.
|
|
@@ -286,6 +308,7 @@ __contract__(
|
|
|
286
308
|
* @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
|
|
287
309
|
* MLK_CUSTOM_ALLOC returned NULL.
|
|
288
310
|
*/
|
|
311
|
+
#if !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
289
312
|
MLK_EXTERNAL_API
|
|
290
313
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
291
314
|
int mlk_kem_dec(uint8_t ss[MLKEM_SSBYTES],
|
|
@@ -300,5 +323,6 @@ __contract__(
|
|
|
300
323
|
ensures(return_value == 0 || return_value == MLK_ERR_FAIL ||
|
|
301
324
|
return_value == MLK_ERR_OUT_OF_MEMORY)
|
|
302
325
|
);
|
|
326
|
+
#endif /* !MLK_CONFIG_NO_DECAPS_API */
|
|
303
327
|
|
|
304
328
|
#endif /* !MLK_KEM_H */
|
|
@@ -28,37 +28,61 @@
|
|
|
28
28
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
29
29
|
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
|
|
30
30
|
{
|
|
31
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
32
|
+
{
|
|
33
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
34
|
+
}
|
|
31
35
|
mlk_ntt_aarch64_asm(data, mlk_aarch64_ntt_zetas_layer12345,
|
|
32
36
|
mlk_aarch64_ntt_zetas_layer67);
|
|
33
37
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
36
41
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
37
42
|
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
38
43
|
{
|
|
44
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
45
|
+
{
|
|
46
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
47
|
+
}
|
|
39
48
|
mlk_intt_aarch64_asm(data, mlk_aarch64_invntt_zetas_layer12345,
|
|
40
49
|
mlk_aarch64_invntt_zetas_layer67);
|
|
41
50
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
42
51
|
}
|
|
52
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
43
53
|
|
|
44
54
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
45
55
|
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
46
56
|
{
|
|
57
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
58
|
+
{
|
|
59
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
60
|
+
}
|
|
47
61
|
mlk_poly_reduce_aarch64_asm(data);
|
|
48
62
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
49
63
|
}
|
|
50
64
|
|
|
65
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
|
|
51
66
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
52
67
|
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
53
68
|
{
|
|
69
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
70
|
+
{
|
|
71
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
72
|
+
}
|
|
54
73
|
mlk_poly_tomont_aarch64_asm(data);
|
|
55
74
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
56
75
|
}
|
|
76
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
|
|
57
77
|
|
|
58
78
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
59
79
|
static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
|
|
60
80
|
const int16_t y[MLKEM_N])
|
|
61
81
|
{
|
|
82
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
83
|
+
{
|
|
84
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
85
|
+
}
|
|
62
86
|
mlk_poly_mulcache_compute_aarch64_asm(
|
|
63
87
|
x, y, mlk_aarch64_zetas_mulcache_native,
|
|
64
88
|
mlk_aarch64_zetas_mulcache_twisted_native);
|
|
@@ -71,6 +95,10 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k2_native(
|
|
|
71
95
|
int16_t r[MLKEM_N], const int16_t a[2 * MLKEM_N],
|
|
72
96
|
const int16_t b[2 * MLKEM_N], const int16_t b_cache[2 * (MLKEM_N / 2)])
|
|
73
97
|
{
|
|
98
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
99
|
+
{
|
|
100
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
101
|
+
}
|
|
74
102
|
mlk_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm(r, a, b, b_cache);
|
|
75
103
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
76
104
|
}
|
|
@@ -82,6 +110,10 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k3_native(
|
|
|
82
110
|
int16_t r[MLKEM_N], const int16_t a[3 * MLKEM_N],
|
|
83
111
|
const int16_t b[3 * MLKEM_N], const int16_t b_cache[3 * (MLKEM_N / 2)])
|
|
84
112
|
{
|
|
113
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
114
|
+
{
|
|
115
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
116
|
+
}
|
|
85
117
|
mlk_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm(r, a, b, b_cache);
|
|
86
118
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
87
119
|
}
|
|
@@ -93,26 +125,36 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
|
|
|
93
125
|
int16_t r[MLKEM_N], const int16_t a[4 * MLKEM_N],
|
|
94
126
|
const int16_t b[4 * MLKEM_N], const int16_t b_cache[4 * (MLKEM_N / 2)])
|
|
95
127
|
{
|
|
128
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
129
|
+
{
|
|
130
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
131
|
+
}
|
|
96
132
|
mlk_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm(r, a, b, b_cache);
|
|
97
133
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
98
134
|
}
|
|
99
135
|
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
100
136
|
|
|
137
|
+
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) || !defined(MLK_CONFIG_NO_ENCAPS_API)
|
|
101
138
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
102
139
|
static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
|
|
103
140
|
const int16_t a[MLKEM_N])
|
|
104
141
|
{
|
|
142
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
|
|
143
|
+
{
|
|
144
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
145
|
+
}
|
|
105
146
|
mlk_poly_tobytes_aarch64_asm(r, a);
|
|
106
147
|
return MLK_NATIVE_FUNC_SUCCESS;
|
|
107
148
|
}
|
|
149
|
+
#endif /* !MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API */
|
|
108
150
|
|
|
109
151
|
MLK_MUST_CHECK_RETURN_VALUE
|
|
110
152
|
static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
|
|
111
153
|
const uint8_t *buf,
|
|
112
154
|
unsigned buflen)
|
|
113
155
|
{
|
|
114
|
-
if (len != MLKEM_N ||
|
|
115
|
-
buflen % 24 != 0)
|
|
156
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON) || len != MLKEM_N ||
|
|
157
|
+
buflen % 24 != 0)
|
|
116
158
|
{
|
|
117
159
|
return MLK_NATIVE_FUNC_FALLBACK;
|
|
118
160
|
}
|
|
@@ -79,6 +79,7 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const int16_t
|
|
|
79
79
|
10129, 10129, -3878, -3878, -11566, -11566,
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
|
|
82
83
|
MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const int16_t
|
|
83
84
|
mlk_aarch64_invntt_zetas_layer12345[80] = {
|
|
84
85
|
1583, 15582, -821, -8081, 1355, 13338, 0, 0, -569,
|
|
@@ -138,6 +139,7 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const int16_t
|
|
|
138
139
|
1041, -1637, -1637, -583, -583, -17, -17, 10247, 10247,
|
|
139
140
|
-16113, -16113, -5739, -5739, -167, -167,
|
|
140
141
|
};
|
|
142
|
+
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
|
|
141
143
|
|
|
142
144
|
MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const int16_t
|
|
143
145
|
mlk_aarch64_zetas_mulcache_native[128] = {
|
|
@@ -38,7 +38,7 @@ MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_rej_uniform_table[4096];
|
|
|
38
38
|
void mlk_ntt_aarch64_asm(int16_t p[256], const int16_t twiddles12345[80],
|
|
39
39
|
const int16_t twiddles56[384])
|
|
40
40
|
/* This must be kept in sync with the HOL-Light specification
|
|
41
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
41
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_ntt_aarch64_asm.ml */
|
|
42
42
|
__contract__(
|
|
43
43
|
requires(memory_no_alias(p, sizeof(int16_t) * MLKEM_N))
|
|
44
44
|
requires(array_abs_bound(p, 0, MLKEM_N, 8192))
|
|
@@ -54,7 +54,7 @@ __contract__(
|
|
|
54
54
|
void mlk_intt_aarch64_asm(int16_t p[256], const int16_t twiddles12345[80],
|
|
55
55
|
const int16_t twiddles56[384])
|
|
56
56
|
/* This must be kept in sync with the HOL-Light specification
|
|
57
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
57
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_intt_aarch64_asm.ml */
|
|
58
58
|
__contract__(
|
|
59
59
|
requires(memory_no_alias(p, sizeof(int16_t) * MLKEM_N))
|
|
60
60
|
requires(twiddles12345 == mlk_aarch64_invntt_zetas_layer12345)
|
|
@@ -68,7 +68,7 @@ __contract__(
|
|
|
68
68
|
#define mlk_poly_reduce_aarch64_asm MLK_NAMESPACE(poly_reduce_aarch64_asm)
|
|
69
69
|
void mlk_poly_reduce_aarch64_asm(int16_t p[256])
|
|
70
70
|
/* This must be kept in sync with the HOL-Light specification
|
|
71
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
71
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_reduce_aarch64_asm.ml */
|
|
72
72
|
__contract__(
|
|
73
73
|
requires(memory_no_alias(p, sizeof(int16_t) * MLKEM_N))
|
|
74
74
|
assigns(memory_slice(p, sizeof(int16_t) * MLKEM_N))
|
|
@@ -78,7 +78,7 @@ __contract__(
|
|
|
78
78
|
#define mlk_poly_tomont_aarch64_asm MLK_NAMESPACE(poly_tomont_aarch64_asm)
|
|
79
79
|
void mlk_poly_tomont_aarch64_asm(int16_t p[256])
|
|
80
80
|
/* This must be kept in sync with the HOL-Light specification
|
|
81
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
81
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_tomont_aarch64_asm.ml */
|
|
82
82
|
__contract__(
|
|
83
83
|
requires(memory_no_alias(p, sizeof(int16_t) * MLKEM_N))
|
|
84
84
|
assigns(memory_slice(p, sizeof(int16_t) * MLKEM_N))
|
|
@@ -92,7 +92,8 @@ void mlk_poly_mulcache_compute_aarch64_asm(int16_t cache[128],
|
|
|
92
92
|
const int16_t zetas[128],
|
|
93
93
|
const int16_t zetas_twisted[128])
|
|
94
94
|
/* This must be kept in sync with the HOL-Light specification
|
|
95
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
95
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_mulcache_compute_aarch64_asm.ml
|
|
96
|
+
*/
|
|
96
97
|
__contract__(
|
|
97
98
|
requires(memory_no_alias(cache, sizeof(int16_t) * (MLKEM_N / 2)))
|
|
98
99
|
requires(memory_no_alias(mlk_poly, sizeof(int16_t) * MLKEM_N))
|
|
@@ -105,7 +106,7 @@ __contract__(
|
|
|
105
106
|
#define mlk_poly_tobytes_aarch64_asm MLK_NAMESPACE(poly_tobytes_aarch64_asm)
|
|
106
107
|
void mlk_poly_tobytes_aarch64_asm(uint8_t r[384], const int16_t a[256])
|
|
107
108
|
/* This must be kept in sync with the HOL-Light specification
|
|
108
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
109
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_poly_tobytes_aarch64_asm.ml */
|
|
109
110
|
__contract__(
|
|
110
111
|
requires(memory_no_alias(r, MLKEM_POLYBYTES))
|
|
111
112
|
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
@@ -119,7 +120,7 @@ void mlk_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm(
|
|
|
119
120
|
int16_t r[256], const int16_t a[512], const int16_t b[512],
|
|
120
121
|
const int16_t b_cache[256])
|
|
121
122
|
/* This must be kept in sync with the HOL-Light specification in
|
|
122
|
-
* proofs/hol_light/aarch64/proofs/
|
|
123
|
+
* proofs/hol_light/aarch64/proofs/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.ml.
|
|
123
124
|
*/
|
|
124
125
|
__contract__(
|
|
125
126
|
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
@@ -136,7 +137,7 @@ void mlk_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm(
|
|
|
136
137
|
int16_t r[256], const int16_t a[768], const int16_t b[768],
|
|
137
138
|
const int16_t b_cache[384])
|
|
138
139
|
/* This must be kept in sync with the HOL-Light specification in
|
|
139
|
-
* proofs/hol_light/aarch64/proofs/
|
|
140
|
+
* proofs/hol_light/aarch64/proofs/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.ml.
|
|
140
141
|
*/
|
|
141
142
|
__contract__(
|
|
142
143
|
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
@@ -153,7 +154,7 @@ void mlk_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm(
|
|
|
153
154
|
int16_t r[256], const int16_t a[1024], const int16_t b[1024],
|
|
154
155
|
const int16_t b_cache[512])
|
|
155
156
|
/* This must be kept in sync with the HOL-Light specification in
|
|
156
|
-
* proofs/hol_light/aarch64/proofs/
|
|
157
|
+
* proofs/hol_light/aarch64/proofs/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.ml.
|
|
157
158
|
*/
|
|
158
159
|
__contract__(
|
|
159
160
|
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
@@ -169,7 +170,7 @@ MLK_MUST_CHECK_RETURN_VALUE
|
|
|
169
170
|
uint64_t mlk_rej_uniform_aarch64_asm(int16_t r[256], const uint8_t *buf,
|
|
170
171
|
unsigned buflen, const uint8_t table[4096])
|
|
171
172
|
/* This must be kept in sync with the HOL-Light specification
|
|
172
|
-
* in proofs/hol_light/aarch64/proofs/
|
|
173
|
+
* in proofs/hol_light/aarch64/proofs/mlkem_rej_uniform_aarch64_asm.ml. */
|
|
173
174
|
__contract__(
|
|
174
175
|
requires(buflen % 24 == 0)
|
|
175
176
|
requires(memory_no_alias(buf, buflen))
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
Description: AArch64 ML-KEM inverse NTT following @[NeonNTT] and @[SLOTHY_Paper]
|
|
25
25
|
Signature: void mlk_intt_aarch64_asm(int16_t p[256], const int16_t twiddles12345[80], const int16_t twiddles56[384])
|
|
26
26
|
ABI:
|
|
27
|
+
Architecture: aarch64
|
|
28
|
+
CallingConvention: AAPCS64
|
|
29
|
+
Features: [NEON]
|
|
27
30
|
x0:
|
|
28
31
|
type: buffer
|
|
29
32
|
size_bytes: 512
|
|
@@ -48,11 +51,14 @@
|
|
|
48
51
|
*/
|
|
49
52
|
|
|
50
53
|
#include "../../../common.h"
|
|
51
|
-
#if defined(MLK_ARITH_BACKEND_AARCH64) &&
|
|
54
|
+
#if defined(MLK_ARITH_BACKEND_AARCH64) && \
|
|
55
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
|
|
56
|
+
(!defined(MLK_CONFIG_NO_ENCAPS_API) || \
|
|
57
|
+
!defined(MLK_CONFIG_NO_DECAPS_API))
|
|
52
58
|
|
|
53
59
|
/*
|
|
54
60
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
55
|
-
* dev/aarch64_opt/src/
|
|
61
|
+
* dev/aarch64_opt/src/mlkem_intt_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
|
|
56
62
|
*/
|
|
57
63
|
|
|
58
64
|
.text
|
|
@@ -200,7 +206,7 @@ MLK_ASM_FN_SYMBOL(intt_aarch64_asm)
|
|
|
200
206
|
mls v24.8h, v19.8h, v7.h[0]
|
|
201
207
|
sub x4, x4, #0x2
|
|
202
208
|
|
|
203
|
-
|
|
209
|
+
Lmlk_intt_layer4567_start:
|
|
204
210
|
add v16.8h, v21.8h, v10.8h
|
|
205
211
|
mul v18.8h, v6.8h, v15.8h
|
|
206
212
|
sub v19.8h, v20.8h, v25.8h
|
|
@@ -293,8 +299,8 @@ Lintt_layer4567_start:
|
|
|
293
299
|
sqrdmulh v31.8h, v8.8h, v11.h[5]
|
|
294
300
|
sub v14.8h, v21.8h, v10.8h
|
|
295
301
|
stur q0, [x3, #-0x30]
|
|
296
|
-
|
|
297
|
-
cbnz x4,
|
|
302
|
+
sub x4, x4, #0x1
|
|
303
|
+
cbnz x4, Lmlk_intt_layer4567_start
|
|
298
304
|
mul v15.8h, v6.8h, v15.8h
|
|
299
305
|
sub v22.8h, v20.8h, v25.8h
|
|
300
306
|
add v4.8h, v21.8h, v10.8h
|
|
@@ -442,7 +448,7 @@ Lintt_layer4567_start:
|
|
|
442
448
|
sqrdmulh v10.8h, v10.8h, v0.h[1]
|
|
443
449
|
sub x4, x4, #0x2
|
|
444
450
|
|
|
445
|
-
|
|
451
|
+
Lmlk_intt_layer123_start:
|
|
446
452
|
sub v12.8h, v3.8h, v30.8h
|
|
447
453
|
mul v11.8h, v21.8h, v1.h[0]
|
|
448
454
|
add v28.8h, v4.8h, v8.8h
|
|
@@ -519,8 +525,8 @@ Lintt_layer123_start:
|
|
|
519
525
|
sqrdmulh v9.8h, v13.8h, v0.h[1]
|
|
520
526
|
str q17, [x0, #0x130]
|
|
521
527
|
mul v17.8h, v19.8h, v0.h[0]
|
|
522
|
-
|
|
523
|
-
cbnz x4,
|
|
528
|
+
sub x4, x4, #0x1
|
|
529
|
+
cbnz x4, Lmlk_intt_layer123_start
|
|
524
530
|
mls v23.8h, v10.8h, v7.h[0]
|
|
525
531
|
ldr q11, [x0, #0x190]
|
|
526
532
|
str q18, [x0, #0x100]
|
|
@@ -621,7 +627,8 @@ Lintt_layer123_start:
|
|
|
621
627
|
|
|
622
628
|
MLK_ASM_FN_SIZE(intt_aarch64_asm)
|
|
623
629
|
|
|
624
|
-
#endif /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED
|
|
630
|
+
#endif /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
631
|
+
(!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) */
|
|
625
632
|
|
|
626
633
|
#if defined(__ELF__)
|
|
627
634
|
.section .note.GNU-stack,"",%progbits
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
Description: AArch64 ML-KEM forward NTT following @[NeonNTT] and @[SLOTHY_Paper]
|
|
25
25
|
Signature: void mlk_ntt_aarch64_asm(int16_t p[256], const int16_t twiddles12345[80], const int16_t twiddles56[384])
|
|
26
26
|
ABI:
|
|
27
|
+
Architecture: aarch64
|
|
28
|
+
CallingConvention: AAPCS64
|
|
29
|
+
Features: [NEON]
|
|
27
30
|
x0:
|
|
28
31
|
type: buffer
|
|
29
32
|
size_bytes: 512
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
|
|
53
56
|
/*
|
|
54
57
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
55
|
-
* dev/aarch64_opt/src/
|
|
58
|
+
* dev/aarch64_opt/src/mlkem_ntt_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
|
|
56
59
|
*/
|
|
57
60
|
|
|
58
61
|
.text
|
|
@@ -144,7 +147,7 @@ MLK_ASM_FN_SYMBOL(ntt_aarch64_asm)
|
|
|
144
147
|
mul v4.8h, v5.8h, v1.h[0]
|
|
145
148
|
sub x4, x4, #0x2
|
|
146
149
|
|
|
147
|
-
|
|
150
|
+
Lmlk_ntt_layer123_start:
|
|
148
151
|
mls v23.8h, v15.8h, v7.h[0]
|
|
149
152
|
ldr q6, [x0, #0x190]
|
|
150
153
|
ldr q15, [x0, #0x90]
|
|
@@ -221,8 +224,8 @@ Lntt_layer123_start:
|
|
|
221
224
|
add v28.8h, v13.8h, v23.8h
|
|
222
225
|
sub v13.8h, v13.8h, v23.8h
|
|
223
226
|
mul v23.8h, v20.8h, v0.h[2]
|
|
224
|
-
|
|
225
|
-
cbnz x4,
|
|
227
|
+
sub x4, x4, #0x1
|
|
228
|
+
cbnz x4, Lmlk_ntt_layer123_start
|
|
226
229
|
sqrdmulh v3.8h, v5.8h, v1.h[1]
|
|
227
230
|
mls v23.8h, v15.8h, v7.h[0]
|
|
228
231
|
ldr q5, [x0, #0x190]
|
|
@@ -396,7 +399,7 @@ Lntt_layer123_start:
|
|
|
396
399
|
mls v23.8h, v16.8h, v7.h[0]
|
|
397
400
|
sub x4, x4, #0x2
|
|
398
401
|
|
|
399
|
-
|
|
402
|
+
Lmlk_ntt_layer4567_start:
|
|
400
403
|
ldr q19, [x2, #0x50]
|
|
401
404
|
sub v31.8h, v30.8h, v23.8h
|
|
402
405
|
mls v0.8h, v29.8h, v7.h[0]
|
|
@@ -468,8 +471,8 @@ Lntt_layer4567_start:
|
|
|
468
471
|
sub v30.8h, v21.8h, v17.8h
|
|
469
472
|
mul v0.8h, v16.8h, v1.8h
|
|
470
473
|
trn1 v28.4s, v6.4s, v12.4s
|
|
471
|
-
|
|
472
|
-
cbnz x4,
|
|
474
|
+
sub x4, x4, #0x1
|
|
475
|
+
cbnz x4, Lmlk_ntt_layer4567_start
|
|
473
476
|
add v22.8h, v11.8h, v8.8h
|
|
474
477
|
mul v27.8h, v27.8h, v4.h[2]
|
|
475
478
|
trn2 v17.4s, v6.4s, v12.4s
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
Description: Compute multiplication cache for polynomial
|
|
9
9
|
Signature: void mlk_poly_mulcache_compute_aarch64_asm(int16_t cache[128], const int16_t mlk_poly[256], const int16_t zetas[128], const int16_t zetas_twisted[128])
|
|
10
10
|
ABI:
|
|
11
|
+
Architecture: aarch64
|
|
12
|
+
CallingConvention: AAPCS64
|
|
13
|
+
Features: [NEON]
|
|
11
14
|
x0:
|
|
12
15
|
type: buffer
|
|
13
16
|
size_bytes: 256
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
|
|
42
45
|
/*
|
|
43
46
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
44
|
-
* dev/aarch64_opt/src/
|
|
47
|
+
* dev/aarch64_opt/src/mlkem_poly_mulcache_compute_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
|
|
45
48
|
*/
|
|
46
49
|
|
|
47
50
|
.text
|
|
@@ -79,7 +82,7 @@ MLK_ASM_FN_SYMBOL(poly_mulcache_compute_aarch64_asm)
|
|
|
79
82
|
lsr x4, x4, #1
|
|
80
83
|
sub x4, x4, #0x2
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
Lmlk_poly_mulcache_compute_loop_start:
|
|
83
86
|
str q5, [x0], #0x10
|
|
84
87
|
sqrdmulh v22.8h, v29.8h, v17.8h
|
|
85
88
|
ldr q28, [x2], #0x10
|
|
@@ -99,7 +102,7 @@ Lpoly_mulcache_compute_loop_start:
|
|
|
99
102
|
str q26, [x0], #0x10
|
|
100
103
|
mul v26.8h, v23.8h, v18.8h
|
|
101
104
|
subs x4, x4, #0x1
|
|
102
|
-
cbnz x4,
|
|
105
|
+
cbnz x4, Lmlk_poly_mulcache_compute_loop_start
|
|
103
106
|
mls v26.8h, v4.8h, v6.h[0]
|
|
104
107
|
str q5, [x0], #0x10
|
|
105
108
|
ldr q5, [x2], #0x10
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
Description: Barrett reduction of polynomial coefficients
|
|
9
9
|
Signature: void mlk_poly_reduce_aarch64_asm(int16_t p[256])
|
|
10
10
|
ABI:
|
|
11
|
+
Architecture: aarch64
|
|
12
|
+
CallingConvention: AAPCS64
|
|
13
|
+
Features: [NEON]
|
|
11
14
|
x0:
|
|
12
15
|
type: buffer
|
|
13
16
|
size_bytes: 512
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
|
|
24
27
|
/*
|
|
25
28
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
26
|
-
* dev/aarch64_opt/src/
|
|
29
|
+
* dev/aarch64_opt/src/mlkem_poly_reduce_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
|
|
27
30
|
*/
|
|
28
31
|
|
|
29
32
|
.text
|
|
@@ -64,7 +67,7 @@ MLK_ASM_FN_SYMBOL(poly_reduce_aarch64_asm)
|
|
|
64
67
|
and v31.16b, v3.16b, v31.16b
|
|
65
68
|
sub x1, x1, #0x2
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
Lmlk_poly_reduce_loop_start:
|
|
68
71
|
add v21.8h, v18.8h, v21.8h
|
|
69
72
|
ldur q18, [x0, #-0x20]
|
|
70
73
|
add v25.8h, v0.8h, v31.8h
|
|
@@ -98,7 +101,7 @@ Lpoly_reduce_loop_start:
|
|
|
98
101
|
and v31.16b, v3.16b, v20.16b
|
|
99
102
|
sqdmulh v2.8h, v26.8h, v4.h[0]
|
|
100
103
|
subs x1, x1, #0x1
|
|
101
|
-
cbnz x1,
|
|
104
|
+
cbnz x1, Lmlk_poly_reduce_loop_start
|
|
102
105
|
add v28.8h, v0.8h, v31.8h
|
|
103
106
|
ldur q29, [x0, #-0x10]
|
|
104
107
|
add v21.8h, v18.8h, v21.8h
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
Description: Convert polynomial to byte representation
|
|
9
9
|
Signature: void mlk_poly_tobytes_aarch64_asm(uint8_t r[384], const int16_t a[256])
|
|
10
10
|
ABI:
|
|
11
|
+
Architecture: aarch64
|
|
12
|
+
CallingConvention: AAPCS64
|
|
13
|
+
Features: [NEON]
|
|
11
14
|
x0:
|
|
12
15
|
type: buffer
|
|
13
16
|
size_bytes: 384
|
|
@@ -25,11 +28,14 @@
|
|
|
25
28
|
*/
|
|
26
29
|
|
|
27
30
|
#include "../../../common.h"
|
|
28
|
-
#if defined(MLK_ARITH_BACKEND_AARCH64) &&
|
|
31
|
+
#if defined(MLK_ARITH_BACKEND_AARCH64) && \
|
|
32
|
+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
|
|
33
|
+
(!defined(MLK_CONFIG_NO_KEYPAIR_API) || \
|
|
34
|
+
!defined(MLK_CONFIG_NO_ENCAPS_API))
|
|
29
35
|
|
|
30
36
|
/*
|
|
31
37
|
* WARNING: This file is auto-derived from the mlkem-native source file
|
|
32
|
-
* dev/aarch64_opt/src/
|
|
38
|
+
* dev/aarch64_opt/src/mlkem_poly_tobytes_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
|
|
33
39
|
*/
|
|
34
40
|
|
|
35
41
|
.text
|
|
@@ -64,7 +70,7 @@ MLK_ASM_FN_SYMBOL(poly_tobytes_aarch64_asm)
|
|
|
64
70
|
lsr x2, x2, #1
|
|
65
71
|
sub x2, x2, #0x2
|
|
66
72
|
|
|
67
|
-
|
|
73
|
+
Lmlk_poly_tobytes_loop_start:
|
|
68
74
|
uzp1 v25.8h, v17.8h, v27.8h
|
|
69
75
|
uzp2 v31.8h, v17.8h, v27.8h
|
|
70
76
|
uzp1 v24.8h, v16.8h, v23.8h
|
|
@@ -86,7 +92,7 @@ Lpoly_tobytes_loop_start:
|
|
|
86
92
|
xtn v28.8b, v24.8h
|
|
87
93
|
shrn v30.8b, v6.8h, #0x4
|
|
88
94
|
subs x2, x2, #0x1
|
|
89
|
-
cbnz x2,
|
|
95
|
+
cbnz x2, Lmlk_poly_tobytes_loop_start
|
|
90
96
|
uzp2 v7.8h, v17.8h, v27.8h
|
|
91
97
|
uzp1 v25.8h, v17.8h, v27.8h
|
|
92
98
|
uzp2 v0.8h, v16.8h, v23.8h
|
|
@@ -110,7 +116,8 @@ Lpoly_tobytes_loop_start:
|
|
|
110
116
|
|
|
111
117
|
MLK_ASM_FN_SIZE(poly_tobytes_aarch64_asm)
|
|
112
118
|
|
|
113
|
-
#endif /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED
|
|
119
|
+
#endif /* MLK_ARITH_BACKEND_AARCH64 && !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
|
|
120
|
+
(!MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API) */
|
|
114
121
|
|
|
115
122
|
#if defined(__ELF__)
|
|
116
123
|
.section .note.GNU-stack,"",%progbits
|