pq_crypto 0.6.1 → 0.6.2
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 +5 -0
- data/SECURITY.md +7 -0
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +4 -4
- 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/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +3 -3
- metadata +41 -35
- 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
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) The mlkem-native project authors
|
|
3
2
|
* Copyright (c) The mldsa-native project authors
|
|
4
3
|
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
5
4
|
*/
|
|
6
5
|
|
|
6
|
+
/*
|
|
7
|
+
* WARNING: This file is auto-generated from scripts/autogen
|
|
8
|
+
* in the mldsa-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
7
12
|
#include "../../../../common.h"
|
|
8
13
|
|
|
9
14
|
#if (defined(MLD_FIPS202_AARCH64_NEED_X1_SCALAR) || \
|
|
@@ -15,15 +20,16 @@
|
|
|
15
20
|
|
|
16
21
|
#include "fips202_native_aarch64.h"
|
|
17
22
|
|
|
18
|
-
MLD_ALIGN const uint64_t
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
MLD_ALIGN MLD_INTERNAL_DATA_DEFINITION const uint64_t
|
|
24
|
+
mld_keccakf1600_round_constants[24] = {
|
|
25
|
+
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
|
|
26
|
+
0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
|
|
27
|
+
0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
|
|
28
|
+
0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
|
|
29
|
+
0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
|
|
30
|
+
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
|
31
|
+
0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
|
|
32
|
+
0x8000000000008080, 0x0000000080000001, 0x8000000080008008,
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
#else /* (MLD_FIPS202_AARCH64_NEED_X1_SCALAR || \
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
19
19
|
static MLD_INLINE int mld_keccak_f1600_x1_native(uint64_t *state)
|
|
20
20
|
{
|
|
21
|
-
|
|
21
|
+
mld_keccak_f1600_x1_scalar_aarch64_asm(state,
|
|
22
|
+
mld_keccakf1600_round_constants);
|
|
22
23
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
23
24
|
}
|
|
24
25
|
#endif /* !__ASSEMBLER__ */
|
|
@@ -27,7 +27,7 @@ static MLD_INLINE int mld_keccak_f1600_x1_native(uint64_t *state)
|
|
|
27
27
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
mld_keccak_f1600_x1_v84a_aarch64_asm(state, mld_keccakf1600_round_constants);
|
|
31
31
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
32
32
|
}
|
|
33
33
|
#endif /* !__ASSEMBLER__ */
|
|
@@ -28,8 +28,10 @@ static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
|
|
|
28
28
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
mld_keccak_f1600_x2_v84a_aarch64_asm(state + 0 * 25,
|
|
32
|
+
mld_keccakf1600_round_constants);
|
|
33
|
+
mld_keccak_f1600_x2_v84a_aarch64_asm(state + 2 * 25,
|
|
34
|
+
mld_keccakf1600_round_constants);
|
|
33
35
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
34
36
|
}
|
|
35
37
|
#endif /* !__ASSEMBLER__ */
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
19
19
|
static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
|
|
20
20
|
{
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
mld_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(
|
|
22
|
+
state, mld_keccakf1600_round_constants);
|
|
23
23
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
24
24
|
}
|
|
25
25
|
#endif /* !__ASSEMBLER__ */
|
|
@@ -27,7 +27,7 @@ static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
|
|
|
27
27
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
mld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm(
|
|
31
31
|
state, mld_keccakf1600_round_constants);
|
|
32
32
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
33
33
|
}
|
|
@@ -66,4 +66,64 @@ __contract__(
|
|
|
66
66
|
);
|
|
67
67
|
#endif /* MLD_USE_FIPS202_X4_NATIVE */
|
|
68
68
|
|
|
69
|
+
/*
|
|
70
|
+
* Native x4 XOR bytes and extract bytes interface.
|
|
71
|
+
*
|
|
72
|
+
* These functions allow backends to provide optimized implementations for
|
|
73
|
+
* XORing input data into the state and extracting output data from the state.
|
|
74
|
+
* This is particularly useful for backends that use a different internal state
|
|
75
|
+
* representation (e.g., bit-interleaved), as conversion can happen during
|
|
76
|
+
* XOR/extract rather than before/after each permutation.
|
|
77
|
+
*
|
|
78
|
+
* NOTE: We assume that the custom representation of the zero state is the
|
|
79
|
+
* all-zero state.
|
|
80
|
+
*
|
|
81
|
+
* MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE: Backend provides native XOR bytes
|
|
82
|
+
* MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE: Backend provides native extract
|
|
83
|
+
* bytes
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
#if defined(MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE)
|
|
87
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
88
|
+
static MLD_INLINE int mld_keccakf1600_xor_bytes_x4_native(
|
|
89
|
+
uint64_t *state, const unsigned char *data0, const unsigned char *data1,
|
|
90
|
+
const unsigned char *data2, const unsigned char *data3, unsigned offset,
|
|
91
|
+
unsigned length)
|
|
92
|
+
__contract__(
|
|
93
|
+
requires(0 <= offset && offset <= 25 * sizeof(uint64_t) &&
|
|
94
|
+
0 <= length && length <= 25 * sizeof(uint64_t) - offset)
|
|
95
|
+
requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
|
|
96
|
+
requires(memory_no_alias(data0, length))
|
|
97
|
+
requires((data0 == data1 &&
|
|
98
|
+
data0 == data2 &&
|
|
99
|
+
data0 == data3) ||
|
|
100
|
+
(memory_no_alias(data1, length) &&
|
|
101
|
+
memory_no_alias(data2, length) &&
|
|
102
|
+
memory_no_alias(data3, length)))
|
|
103
|
+
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
|
|
104
|
+
ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS)
|
|
105
|
+
ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4)));
|
|
106
|
+
#endif /* MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE */
|
|
107
|
+
|
|
108
|
+
#if defined(MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE)
|
|
109
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
110
|
+
static MLD_INLINE int mld_keccakf1600_extract_bytes_x4_native(
|
|
111
|
+
uint64_t *state, unsigned char *data0, unsigned char *data1,
|
|
112
|
+
unsigned char *data2, unsigned char *data3, unsigned offset,
|
|
113
|
+
unsigned length)
|
|
114
|
+
__contract__(
|
|
115
|
+
requires(0 <= offset && offset <= 25 * sizeof(uint64_t) &&
|
|
116
|
+
0 <= length && length <= 25 * sizeof(uint64_t) - offset)
|
|
117
|
+
requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
|
|
118
|
+
requires(memory_no_alias(data0, length))
|
|
119
|
+
requires(memory_no_alias(data1, length))
|
|
120
|
+
requires(memory_no_alias(data2, length))
|
|
121
|
+
requires(memory_no_alias(data3, length))
|
|
122
|
+
assigns(memory_slice(data0, length))
|
|
123
|
+
assigns(memory_slice(data1, length))
|
|
124
|
+
assigns(memory_slice(data2, length))
|
|
125
|
+
assigns(memory_slice(data3, length))
|
|
126
|
+
ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS));
|
|
127
|
+
#endif /* MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE */
|
|
128
|
+
|
|
69
129
|
#endif /* !MLD_FIPS202_NATIVE_API_H */
|
|
@@ -11,12 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
/* Part of backend API */
|
|
13
13
|
#define MLD_USE_FIPS202_X4_NATIVE
|
|
14
|
+
#define MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE
|
|
15
|
+
#define MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE
|
|
14
16
|
/* Guard for assembly file */
|
|
15
17
|
#define MLD_FIPS202_ARMV81M_NEED_X4
|
|
16
18
|
|
|
17
19
|
#if !defined(__ASSEMBLER__)
|
|
18
20
|
#include "../api.h"
|
|
19
21
|
|
|
22
|
+
/*
|
|
23
|
+
* Native x4 permutation
|
|
24
|
+
* State is kept in bit-interleaved format.
|
|
25
|
+
*/
|
|
20
26
|
#define mld_keccak_f1600_x4_native_impl \
|
|
21
27
|
MLD_NAMESPACE(keccak_f1600_x4_native_impl)
|
|
22
28
|
int mld_keccak_f1600_x4_native_impl(uint64_t *state);
|
|
@@ -27,6 +33,48 @@ static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
|
|
|
27
33
|
return mld_keccak_f1600_x4_native_impl(state);
|
|
28
34
|
}
|
|
29
35
|
|
|
36
|
+
/*
|
|
37
|
+
* Native x4 XOR bytes (with on-the-fly bit interleaving)
|
|
38
|
+
*/
|
|
39
|
+
#define mld_keccak_f1600_x4_state_xor_bytes \
|
|
40
|
+
MLD_NAMESPACE(keccak_f1600_x4_state_xor_bytes_asm)
|
|
41
|
+
void mld_keccak_f1600_x4_state_xor_bytes(void *state, const uint8_t *data0,
|
|
42
|
+
const uint8_t *data1,
|
|
43
|
+
const uint8_t *data2,
|
|
44
|
+
const uint8_t *data3, unsigned offset,
|
|
45
|
+
unsigned length);
|
|
46
|
+
|
|
47
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
48
|
+
static MLD_INLINE int mld_keccakf1600_xor_bytes_x4_native(
|
|
49
|
+
uint64_t *state, const uint8_t *data0, const uint8_t *data1,
|
|
50
|
+
const uint8_t *data2, const uint8_t *data3, unsigned offset,
|
|
51
|
+
unsigned length)
|
|
52
|
+
{
|
|
53
|
+
mld_keccak_f1600_x4_state_xor_bytes(state, data0, data1, data2, data3, offset,
|
|
54
|
+
length);
|
|
55
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Native x4 extract bytes (with on-the-fly bit de-interleaving)
|
|
60
|
+
*/
|
|
61
|
+
#define mld_keccak_f1600_x4_state_extract_bytes \
|
|
62
|
+
MLD_NAMESPACE(keccak_f1600_x4_state_extract_bytes_asm)
|
|
63
|
+
void mld_keccak_f1600_x4_state_extract_bytes(void *state, uint8_t *data0,
|
|
64
|
+
uint8_t *data1, uint8_t *data2,
|
|
65
|
+
uint8_t *data3, unsigned offset,
|
|
66
|
+
unsigned length);
|
|
67
|
+
|
|
68
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
69
|
+
static MLD_INLINE int mld_keccakf1600_extract_bytes_x4_native(
|
|
70
|
+
uint64_t *state, uint8_t *data0, uint8_t *data1, uint8_t *data2,
|
|
71
|
+
uint8_t *data3, unsigned offset, unsigned length)
|
|
72
|
+
{
|
|
73
|
+
mld_keccak_f1600_x4_state_extract_bytes(state, data0, data1, data2, data3,
|
|
74
|
+
offset, length);
|
|
75
|
+
return MLD_NATIVE_FUNC_SUCCESS;
|
|
76
|
+
}
|
|
77
|
+
|
|
30
78
|
#endif /* !__ASSEMBLER__ */
|
|
31
79
|
|
|
32
80
|
#endif /* !MLD_FIPS202_NATIVE_ARMV81M_MVE_H */
|
data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h
CHANGED
|
@@ -11,10 +11,27 @@
|
|
|
11
11
|
/* Keccak round constants in bit-interleaved form */
|
|
12
12
|
#define mld_keccakf1600_round_constants \
|
|
13
13
|
MLD_NAMESPACE(keccakf1600_round_constants)
|
|
14
|
-
|
|
14
|
+
MLD_INTERNAL_DATA_DECLARATION const uint32_t
|
|
15
|
+
mld_keccakf1600_round_constants[48];
|
|
15
16
|
|
|
16
17
|
#define mld_keccak_f1600_x4_mve_asm MLD_NAMESPACE(keccak_f1600_x4_mve_asm)
|
|
17
18
|
void mld_keccak_f1600_x4_mve_asm(uint64_t state[100], uint64_t tmpstate[100],
|
|
18
19
|
const uint32_t rc[48]);
|
|
19
20
|
|
|
21
|
+
#define mld_keccak_f1600_x4_state_xor_bytes_asm \
|
|
22
|
+
MLD_NAMESPACE(keccak_f1600_x4_state_xor_bytes_asm)
|
|
23
|
+
void mld_keccak_f1600_x4_state_xor_bytes_asm(void *state, const uint8_t *d0,
|
|
24
|
+
const uint8_t *d1,
|
|
25
|
+
const uint8_t *d2,
|
|
26
|
+
const uint8_t *d3, unsigned offset,
|
|
27
|
+
unsigned length);
|
|
28
|
+
|
|
29
|
+
#define mld_keccak_f1600_x4_state_extract_bytes_asm \
|
|
30
|
+
MLD_NAMESPACE(keccak_f1600_x4_state_extract_bytes_asm)
|
|
31
|
+
void mld_keccak_f1600_x4_state_extract_bytes_asm(void *state, uint8_t *data0,
|
|
32
|
+
uint8_t *data1, uint8_t *data2,
|
|
33
|
+
uint8_t *data3,
|
|
34
|
+
unsigned offset,
|
|
35
|
+
unsigned length);
|
|
36
|
+
|
|
20
37
|
#endif /* !MLD_FIPS202_NATIVE_ARMV81M_SRC_FIPS202_NATIVE_ARMV81M_H */
|