1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2019 Linaro Ltd <ard.biesheuvel@linaro.org>
4  */
5 
6 #include <asm/cpufeature.h>
7 #include <asm/neon.h>
8 
9 #include "aegis.h"
10 
11 void crypto_aegis128_update_neon(void *state, const void *msg);
12 void crypto_aegis128_encrypt_chunk_neon(void *state, void *dst, const void *src,
13 					unsigned int size);
14 void crypto_aegis128_decrypt_chunk_neon(void *state, void *dst, const void *src,
15 					unsigned int size);
16 
17 int aegis128_have_aes_insn __ro_after_init;
18 
crypto_aegis128_have_simd(void)19 bool crypto_aegis128_have_simd(void)
20 {
21 	if (cpu_have_feature(cpu_feature(AES))) {
22 		aegis128_have_aes_insn = 1;
23 		return true;
24 	}
25 	return IS_ENABLED(CONFIG_ARM64);
26 }
27 
crypto_aegis128_update_simd(union aegis_block * state,const void * msg)28 void crypto_aegis128_update_simd(union aegis_block *state, const void *msg)
29 {
30 	kernel_neon_begin();
31 	crypto_aegis128_update_neon(state, msg);
32 	kernel_neon_end();
33 }
34 
crypto_aegis128_encrypt_chunk_simd(union aegis_block * state,u8 * dst,const u8 * src,unsigned int size)35 void crypto_aegis128_encrypt_chunk_simd(union aegis_block *state, u8 *dst,
36 					const u8 *src, unsigned int size)
37 {
38 	kernel_neon_begin();
39 	crypto_aegis128_encrypt_chunk_neon(state, dst, src, size);
40 	kernel_neon_end();
41 }
42 
crypto_aegis128_decrypt_chunk_simd(union aegis_block * state,u8 * dst,const u8 * src,unsigned int size)43 void crypto_aegis128_decrypt_chunk_simd(union aegis_block *state, u8 *dst,
44 					const u8 *src, unsigned int size)
45 {
46 	kernel_neon_begin();
47 	crypto_aegis128_decrypt_chunk_neon(state, dst, src, size);
48 	kernel_neon_end();
49 }
50