2019-08-11 15:59:11 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Linaro Ltd <ard.biesheuvel@linaro.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/cpufeature.h>
|
|
|
|
#include <asm/neon.h>
|
|
|
|
|
|
|
|
#include "aegis.h"
|
2023-05-16 13:28:48 -07:00
|
|
|
#include "aegis-neon.h"
|
2019-08-11 15:59:11 -07:00
|
|
|
|
2019-08-11 15:59:12 -07:00
|
|
|
int aegis128_have_aes_insn __ro_after_init;
|
|
|
|
|
2019-08-11 15:59:11 -07:00
|
|
|
bool crypto_aegis128_have_simd(void)
|
|
|
|
{
|
2019-08-11 15:59:12 -07:00
|
|
|
if (cpu_have_feature(cpu_feature(AES))) {
|
|
|
|
aegis128_have_aes_insn = 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return IS_ENABLED(CONFIG_ARM64);
|
2019-08-11 15:59:11 -07:00
|
|
|
}
|
|
|
|
|
2021-03-07 22:41:32 -07:00
|
|
|
void crypto_aegis128_init_simd(struct aegis_state *state,
|
2019-10-14 09:16:45 -07:00
|
|
|
const union aegis_block *key,
|
|
|
|
const u8 *iv)
|
|
|
|
{
|
|
|
|
kernel_neon_begin();
|
|
|
|
crypto_aegis128_init_neon(state, key, iv);
|
|
|
|
kernel_neon_end();
|
|
|
|
}
|
|
|
|
|
2021-03-07 22:41:32 -07:00
|
|
|
void crypto_aegis128_update_simd(struct aegis_state *state, const void *msg)
|
2019-08-11 15:59:11 -07:00
|
|
|
{
|
|
|
|
kernel_neon_begin();
|
|
|
|
crypto_aegis128_update_neon(state, msg);
|
|
|
|
kernel_neon_end();
|
|
|
|
}
|
|
|
|
|
2021-03-07 22:41:32 -07:00
|
|
|
void crypto_aegis128_encrypt_chunk_simd(struct aegis_state *state, u8 *dst,
|
2019-08-11 15:59:11 -07:00
|
|
|
const u8 *src, unsigned int size)
|
|
|
|
{
|
|
|
|
kernel_neon_begin();
|
|
|
|
crypto_aegis128_encrypt_chunk_neon(state, dst, src, size);
|
|
|
|
kernel_neon_end();
|
|
|
|
}
|
|
|
|
|
2021-03-07 22:41:32 -07:00
|
|
|
void crypto_aegis128_decrypt_chunk_simd(struct aegis_state *state, u8 *dst,
|
2019-08-11 15:59:11 -07:00
|
|
|
const u8 *src, unsigned int size)
|
|
|
|
{
|
|
|
|
kernel_neon_begin();
|
|
|
|
crypto_aegis128_decrypt_chunk_neon(state, dst, src, size);
|
|
|
|
kernel_neon_end();
|
|
|
|
}
|
2019-10-14 09:16:45 -07:00
|
|
|
|
2021-03-07 22:41:32 -07:00
|
|
|
int crypto_aegis128_final_simd(struct aegis_state *state,
|
2020-11-17 06:32:13 -07:00
|
|
|
union aegis_block *tag_xor,
|
|
|
|
unsigned int assoclen,
|
|
|
|
unsigned int cryptlen,
|
|
|
|
unsigned int authsize)
|
2019-10-14 09:16:45 -07:00
|
|
|
{
|
2020-11-17 06:32:13 -07:00
|
|
|
int ret;
|
|
|
|
|
2019-10-14 09:16:45 -07:00
|
|
|
kernel_neon_begin();
|
2020-11-17 06:32:13 -07:00
|
|
|
ret = crypto_aegis128_final_neon(state, tag_xor, assoclen, cryptlen,
|
|
|
|
authsize);
|
2019-10-14 09:16:45 -07:00
|
|
|
kernel_neon_end();
|
2020-11-17 06:32:13 -07:00
|
|
|
|
|
|
|
return ret;
|
2019-10-14 09:16:45 -07:00
|
|
|
}
|