Merge tag 'block-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / crypto / aegis128-neon.c
blob94d591a002a4737cd73369d9100e2fea5b15b11e
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2019 Linaro Ltd <ard.biesheuvel@linaro.org>
4 */
6 #include <asm/cpufeature.h>
7 #include <asm/neon.h>
9 #include "aegis.h"
11 void crypto_aegis128_init_neon(void *state, const void *key, const void *iv);
12 void crypto_aegis128_update_neon(void *state, const void *msg);
13 void crypto_aegis128_encrypt_chunk_neon(void *state, void *dst, const void *src,
14 unsigned int size);
15 void crypto_aegis128_decrypt_chunk_neon(void *state, void *dst, const void *src,
16 unsigned int size);
17 int crypto_aegis128_final_neon(void *state, void *tag_xor,
18 unsigned int assoclen,
19 unsigned int cryptlen,
20 unsigned int authsize);
22 int aegis128_have_aes_insn __ro_after_init;
24 bool crypto_aegis128_have_simd(void)
26 if (cpu_have_feature(cpu_feature(AES))) {
27 aegis128_have_aes_insn = 1;
28 return true;
30 return IS_ENABLED(CONFIG_ARM64);
33 void crypto_aegis128_init_simd(union aegis_block *state,
34 const union aegis_block *key,
35 const u8 *iv)
37 kernel_neon_begin();
38 crypto_aegis128_init_neon(state, key, iv);
39 kernel_neon_end();
42 void crypto_aegis128_update_simd(union aegis_block *state, const void *msg)
44 kernel_neon_begin();
45 crypto_aegis128_update_neon(state, msg);
46 kernel_neon_end();
49 void crypto_aegis128_encrypt_chunk_simd(union aegis_block *state, u8 *dst,
50 const u8 *src, unsigned int size)
52 kernel_neon_begin();
53 crypto_aegis128_encrypt_chunk_neon(state, dst, src, size);
54 kernel_neon_end();
57 void crypto_aegis128_decrypt_chunk_simd(union aegis_block *state, u8 *dst,
58 const u8 *src, unsigned int size)
60 kernel_neon_begin();
61 crypto_aegis128_decrypt_chunk_neon(state, dst, src, size);
62 kernel_neon_end();
65 int crypto_aegis128_final_simd(union aegis_block *state,
66 union aegis_block *tag_xor,
67 unsigned int assoclen,
68 unsigned int cryptlen,
69 unsigned int authsize)
71 int ret;
73 kernel_neon_begin();
74 ret = crypto_aegis128_final_neon(state, tag_xor, assoclen, cryptlen,
75 authsize);
76 kernel_neon_end();
78 return ret;