Merge tag 'riscv-for-linus-6.4-mw1' of git://git.kernel.org/pub/scm/linux/kernel...
[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"
10
52828263 11void crypto_aegis128_init_neon(void *state, const void *key, const void *iv);
a4397635
AB
12void crypto_aegis128_update_neon(void *state, const void *msg);
13void crypto_aegis128_encrypt_chunk_neon(void *state, void *dst, const void *src,
14 unsigned int size);
15void crypto_aegis128_decrypt_chunk_neon(void *state, void *dst, const void *src,
16 unsigned int size);
97b70180
AB
17int crypto_aegis128_final_neon(void *state, void *tag_xor,
18 unsigned int assoclen,
19 unsigned int cryptlen,
20 unsigned int authsize);
a4397635 21
19842963
AB
22int aegis128_have_aes_insn __ro_after_init;
23
a4397635
AB
24bool crypto_aegis128_have_simd(void)
25{
19842963
AB
26 if (cpu_have_feature(cpu_feature(AES))) {
27 aegis128_have_aes_insn = 1;
28 return true;
29 }
30 return IS_ENABLED(CONFIG_ARM64);
a4397635
AB
31}
32
09149997 33void crypto_aegis128_init_simd(struct aegis_state *state,
52828263
AB
34 const union aegis_block *key,
35 const u8 *iv)
36{
37 kernel_neon_begin();
38 crypto_aegis128_init_neon(state, key, iv);
39 kernel_neon_end();
40}
41
09149997 42void crypto_aegis128_update_simd(struct aegis_state *state, const void *msg)
a4397635
AB
43{
44 kernel_neon_begin();
45 crypto_aegis128_update_neon(state, msg);
46 kernel_neon_end();
47}
48
09149997 49void crypto_aegis128_encrypt_chunk_simd(struct aegis_state *state, u8 *dst,
a4397635
AB
50 const u8 *src, unsigned int size)
51{
52 kernel_neon_begin();
53 crypto_aegis128_encrypt_chunk_neon(state, dst, src, size);
54 kernel_neon_end();
55}
56
09149997 57void crypto_aegis128_decrypt_chunk_simd(struct aegis_state *state, u8 *dst,
a4397635
AB
58 const u8 *src, unsigned int size)
59{
60 kernel_neon_begin();
61 crypto_aegis128_decrypt_chunk_neon(state, dst, src, size);
62 kernel_neon_end();
63}
52828263 64
09149997 65int crypto_aegis128_final_simd(struct aegis_state *state,
97b70180
AB
66 union aegis_block *tag_xor,
67 unsigned int assoclen,
68 unsigned int cryptlen,
69 unsigned int authsize)
52828263 70{
97b70180
AB
71 int ret;
72
52828263 73 kernel_neon_begin();
97b70180
AB
74 ret = crypto_aegis128_final_neon(state, tag_xor, assoclen, cryptlen,
75 authsize);
52828263 76 kernel_neon_end();
97b70180
AB
77
78 return ret;
52828263 79}