xref: /linux/arch/arm64/crypto/sm4-ce-core.S (revision 3381df0954199458fa3993db72fb427f0ed1e43b)
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/linkage.h>
4#include <asm/assembler.h>
5
6	.irp		b, 0, 1, 2, 3, 4, 5, 6, 7, 8
7	.set		.Lv\b\().4s, \b
8	.endr
9
10	.macro		sm4e, rd, rn
11	.inst		0xcec08400 | .L\rd | (.L\rn << 5)
12	.endm
13
14	/*
15	 * void sm4_ce_do_crypt(const u32 *rk, u32 *out, const u32 *in);
16	 */
17	.text
18SYM_FUNC_START(sm4_ce_do_crypt)
19	ld1		{v8.4s}, [x2]
20	ld1		{v0.4s-v3.4s}, [x0], #64
21CPU_LE(	rev32		v8.16b, v8.16b		)
22	ld1		{v4.4s-v7.4s}, [x0]
23	sm4e		v8.4s, v0.4s
24	sm4e		v8.4s, v1.4s
25	sm4e		v8.4s, v2.4s
26	sm4e		v8.4s, v3.4s
27	sm4e		v8.4s, v4.4s
28	sm4e		v8.4s, v5.4s
29	sm4e		v8.4s, v6.4s
30	sm4e		v8.4s, v7.4s
31	rev64		v8.4s, v8.4s
32	ext		v8.16b, v8.16b, v8.16b, #8
33CPU_LE(	rev32		v8.16b, v8.16b		)
34	st1		{v8.4s}, [x1]
35	ret
36SYM_FUNC_END(sm4_ce_do_crypt)
37