Merge branch 'read-phy-address-of-switch-from-device-tree-on-mt7530-dsa-subdriver'
[linux-block.git] / crypto / aegis128-neon.c
CommitLineData
a4397635
AB
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"
4e3901fa 10#include "aegis-neon.h"
a4397635 11
19842963
AB
12int aegis128_have_aes_insn __ro_after_init;
13
a4397635
AB
14bool crypto_aegis128_have_simd(void)
15{
19842963
AB
16 if (cpu_have_feature(cpu_feature(AES))) {
17 aegis128_have_aes_insn = 1;
18 return true;
19 }
20 return IS_ENABLED(CONFIG_ARM64);
a4397635
AB
21}
22
09149997 23void crypto_aegis128_init_simd(struct aegis_state *state,
52828263
AB
24 const union aegis_block *key,
25 const u8 *iv)
26{
27 kernel_neon_begin();
28 crypto_aegis128_init_neon(state, key, iv);
29 kernel_neon_end();
30}
31
09149997 32void crypto_aegis128_update_simd(struct aegis_state *state, const void *msg)
a4397635
AB
33{
34 kernel_neon_begin();
35 crypto_aegis128_update_neon(state, msg);
36 kernel_neon_end();
37}
38
09149997 39void crypto_aegis128_encrypt_chunk_simd(struct aegis_state *state, u8 *dst,
a4397635
AB
40 const u8 *src, unsigned int size)
41{
42 kernel_neon_begin();
43 crypto_aegis128_encrypt_chunk_neon(state, dst, src, size);
44 kernel_neon_end();
45}
46
09149997 47void crypto_aegis128_decrypt_chunk_simd(struct aegis_state *state, u8 *dst,
a4397635
AB
48 const u8 *src, unsigned int size)
49{
50 kernel_neon_begin();
51 crypto_aegis128_decrypt_chunk_neon(state, dst, src, size);
52 kernel_neon_end();
53}
52828263 54
09149997 55int crypto_aegis128_final_simd(struct aegis_state *state,
97b70180
AB
56 union aegis_block *tag_xor,
57 unsigned int assoclen,
58 unsigned int cryptlen,
59 unsigned int authsize)
52828263 60{
97b70180
AB
61 int ret;
62
52828263 63 kernel_neon_begin();
97b70180
AB
64 ret = crypto_aegis128_final_neon(state, tag_xor, assoclen, cryptlen,
65 authsize);
52828263 66 kernel_neon_end();
97b70180
AB
67
68 return ret;
52828263 69}