path: root/crypto/aegis128-neon.c
diff options
authorArd Biesheuvel <>2019-08-12 01:59:12 +0300
committerHerbert Xu <>2019-08-15 21:52:15 +1000
commit198429631a85622da1d08d360ef02cfb84c95919 (patch)
treecaef44903f6bac05a5757847a2df17fd4c8f947e /crypto/aegis128-neon.c
parenta4397635afea5d127548d64e0055ed471ef2d5be (diff)
crypto: arm64/aegis128 - implement plain NEON version
Provide a version of the core AES transform to the aegis128 SIMD code that does not rely on the special AES instructions, but uses plain NEON instructions instead. This allows the SIMD version of the aegis128 driver to be used on arm64 systems that do not implement those instructions (which are not mandatory in the architecture), such as the Raspberry Pi 3. Since GCC makes a mess of this when using the tbl/tbx intrinsics to perform the sbox substitution, preload the Sbox into v16..v31 in this case and use inline asm to emit the tbl/tbx instructions. Clang does not support this approach, nor does it require it, since it does a much better job at code generation, so there we use the intrinsics as usual. Cc: Nick Desaulniers <> Signed-off-by: Ard Biesheuvel <> Acked-by: Nick Desaulniers <> Signed-off-by: Herbert Xu <>
Diffstat (limited to 'crypto/aegis128-neon.c')
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/aegis128-neon.c b/crypto/aegis128-neon.c
index c1c0a1686f67..751f9c195aa4 100644
--- a/crypto/aegis128-neon.c
+++ b/crypto/aegis128-neon.c
@@ -14,9 +14,15 @@ void crypto_aegis128_encrypt_chunk_neon(void *state, void *dst, const void *src,
void crypto_aegis128_decrypt_chunk_neon(void *state, void *dst, const void *src,
unsigned int size);
+int aegis128_have_aes_insn __ro_after_init;
bool crypto_aegis128_have_simd(void)
- return cpu_have_feature(cpu_feature(AES));
+ if (cpu_have_feature(cpu_feature(AES))) {
+ aegis128_have_aes_insn = 1;
+ return true;
+ }
void crypto_aegis128_update_simd(union aegis_block *state, const void *msg)