blob: 751f9c195aa42a0b43916c16362e15b32497000c [file] [log] [blame]
Ard Biesheuvela4397632019-08-12 01:59:11 +03001// 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
11void crypto_aegis128_update_neon(void *state, const void *msg);
12void crypto_aegis128_encrypt_chunk_neon(void *state, void *dst, const void *src,
13 unsigned int size);
14void crypto_aegis128_decrypt_chunk_neon(void *state, void *dst, const void *src,
15 unsigned int size);
16
Ard Biesheuvel19842962019-08-12 01:59:12 +030017int aegis128_have_aes_insn __ro_after_init;
18
Ard Biesheuvela4397632019-08-12 01:59:11 +030019bool crypto_aegis128_have_simd(void)
20{
Ard Biesheuvel19842962019-08-12 01:59:12 +030021 if (cpu_have_feature(cpu_feature(AES))) {
22 aegis128_have_aes_insn = 1;
23 return true;
24 }
25 return IS_ENABLED(CONFIG_ARM64);
Ard Biesheuvela4397632019-08-12 01:59:11 +030026}
27
28void 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
35void 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
43void 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}