Skip to content

Commit 25cc52f

Browse files
committed
Move MVE x1 bit-interleaving sources to dev/ and regenerate via autogen
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 278a9ac commit 25cc52f

13 files changed

Lines changed: 833 additions & 486 deletions

dev/fips202/armv81m/mve.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
/* Part of backend API */
1212
#define MLK_USE_FIPS202_X1_NATIVE
1313
#define MLK_USE_FIPS202_X4_NATIVE
14+
#define MLK_USE_FIPS202_X1_XOR_BYTES_NATIVE
15+
#define MLK_USE_FIPS202_X1_EXTRACT_BYTES_NATIVE
1416
#define MLK_USE_FIPS202_X4_XOR_BYTES_NATIVE
1517
#define MLK_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE
18+
1619
/* Guard for assembly files */
1720
#define MLK_FIPS202_ARMV81M_NEED_X1
1821
#define MLK_FIPS202_ARMV81M_NEED_X4
@@ -44,6 +47,45 @@ static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
4447
return mlk_keccak_f1600_x4_native_impl(state);
4548
}
4649

50+
/*
51+
* Native x1 XOR bytes (with on-the-fly bit interleaving)
52+
*/
53+
#define mlk_keccak_f1600_x1_state_xor_bytes_impl \
54+
MLK_NAMESPACE(mlk_keccak_f1600_x1_state_xor_bytes_impl)
55+
void mlk_keccak_f1600_x1_state_xor_bytes_impl(uint64_t *state,
56+
const uint8_t *data,
57+
unsigned offset, unsigned length);
58+
59+
MLK_MUST_CHECK_RETURN_VALUE
60+
static MLK_INLINE int mlk_keccakf1600_xor_bytes_x1_native(uint64_t *state,
61+
const uint8_t *data,
62+
unsigned offset,
63+
unsigned length)
64+
{
65+
mlk_keccak_f1600_x1_state_xor_bytes_impl(state, data, offset, length);
66+
return MLK_NATIVE_FUNC_SUCCESS;
67+
}
68+
69+
/*
70+
* Native x1 extract bytes (with on-the-fly bit de-interleaving)
71+
*/
72+
#define mlk_keccak_f1600_x1_state_extract_bytes_impl \
73+
MLK_NAMESPACE(mlk_keccak_f1600_x1_state_extract_bytes_impl)
74+
void mlk_keccak_f1600_x1_state_extract_bytes_impl(uint64_t *state,
75+
uint8_t *data,
76+
unsigned offset,
77+
unsigned length);
78+
79+
MLK_MUST_CHECK_RETURN_VALUE
80+
static MLK_INLINE int mlk_keccakf1600_extract_bytes_x1_native(uint64_t *state,
81+
uint8_t *data,
82+
unsigned offset,
83+
unsigned length)
84+
{
85+
mlk_keccak_f1600_x1_state_extract_bytes_impl(state, data, offset, length);
86+
return MLK_NATIVE_FUNC_SUCCESS;
87+
}
88+
4789
/*
4890
* Native x4 XOR bytes (with on-the-fly bit interleaving)
4991
*/

dev/fips202/armv81m/src/fips202_native_armv81m.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,18 @@ void mlk_keccak_f1600_x4_state_extract_bytes_asm(void *state, uint8_t *data0,
3535
#define mlk_keccak_f1600_x1_armv7m_asm MLK_NAMESPACE(keccak_f1600_x1_armv7m_asm)
3636
void mlk_keccak_f1600_x1_armv7m_asm(uint32_t state[50], const uint32_t rc[49]);
3737

38+
#define mlk_keccak_f1600_x1_state_xor_bytes_asm \
39+
MLK_NAMESPACE(keccak_f1600_x1_state_xor_bytes_asm)
40+
void mlk_keccak_f1600_x1_state_xor_bytes_asm(uint64_t *state,
41+
const uint8_t *data,
42+
unsigned offset, unsigned length);
43+
44+
#define mlk_keccak_f1600_x1_state_extract_bytes_asm \
45+
MLK_NAMESPACE(keccak_f1600_x1_state_extract_bytes_asm)
46+
void mlk_keccak_f1600_x1_state_extract_bytes_asm(uint64_t *state,
47+
const uint8_t *data,
48+
unsigned offset,
49+
unsigned length);
50+
51+
3852
#endif /* !MLK_DEV_FIPS202_ARMV81M_SRC_FIPS202_NATIVE_ARMV81M_H */

dev/fips202/armv81m/src/keccak_f1600_x1_armv7m.c

Lines changed: 0 additions & 119 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) The mlkem-native project authors
3+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4+
*/
5+
6+
#include "../../../../common.h"
7+
#include "../../../../verify.h"
8+
9+
#if defined(MLK_FIPS202_ARMV81M_NEED_X1) && \
10+
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
11+
12+
#include <stdint.h>
13+
#include "fips202_native_armv81m.h"
14+
15+
void mlk_keccak_f1600_x1_state_extract_bytes_impl(uint64_t *state,
16+
uint8_t *data,
17+
unsigned offset,
18+
unsigned length)
19+
{
20+
mlk_keccak_f1600_x1_state_extract_bytes_asm(state, data, offset, length);
21+
}
22+
23+
void mlk_keccak_f1600_x1_state_xor_bytes_impl(uint64_t *state,
24+
const uint8_t *data,
25+
unsigned offset, unsigned length)
26+
{
27+
mlk_keccak_f1600_x1_state_xor_bytes_asm(state, data, offset, length);
28+
}
29+
30+
31+
#define mlk_keccak_f1600_x1_native_impl \
32+
MLK_NAMESPACE(keccak_f1600_x1_native_impl)
33+
int mlk_keccak_f1600_x1_native_impl(uint64_t *state)
34+
{
35+
/* Run the permutation */
36+
mlk_keccak_f1600_x1_armv7m_asm((void *)state,
37+
mlk_keccakf1600_round_constants);
38+
return MLK_NATIVE_FUNC_SUCCESS;
39+
}
40+
41+
#else /* MLK_FIPS202_ARMV81M_NEED_X1 && !MLK_CONFIG_MULTILEVEL_NO_SHARED */
42+
43+
MLK_EMPTY_CU(keccak_f1600_x1_armv7m)
44+
45+
#endif /* !(MLK_FIPS202_ARMV81M_NEED_X1 && !MLK_CONFIG_MULTILEVEL_NO_SHARED) \
46+
*/
47+
48+
/* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
49+
* Don't modify by hand -- this is auto-generated by scripts/autogen. */
50+
/* Some macros are kept because they are also defined in a header. */
51+
/* Keep: mlk_keccak_f1600_x1_native_impl (mve.h) */

0 commit comments

Comments
 (0)