Commit 001eabfd authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: arm/aes update NEON AES module to latest OpenSSL version

This updates the bit sliced AES module to the latest version in the
upstream OpenSSL repository (e620e5ae37bc). This is needed to fix a
bug in the XTS decryption path, where data chunked in a certain way
could trigger the ciphertext stealing code, which is not supposed to
be active in the kernel build (The kernel implementation of XTS only
supports round multiples of the AES block size of 16 bytes, whereas
the conformant OpenSSL implementation of XTS supports inputs of
arbitrary size by applying ciphertext stealing). This is fixed in
the upstream version by adding the missing #ifndef XTS_CHAIN_TWEAK
around the offending instructions.

The upstream code also contains the change applied by Russell to
build the code unconditionally, i.e., even if __LINUX_ARM_ARCH__ < 7,
but implemented slightly differently.

Cc: stable@vger.kernel.org
Fixes: e4e7f10b ("ARM: add support for bit sliced AES using NEON instructions")
Reported-by: default avatarAdrian Kotelba <adrian.kotelba@gmail.com>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: default avatarMilan Broz <gmazyland@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c517d838
...@@ -58,14 +58,18 @@ ...@@ -58,14 +58,18 @@
# define VFP_ABI_FRAME 0 # define VFP_ABI_FRAME 0
# define BSAES_ASM_EXTENDED_KEY # define BSAES_ASM_EXTENDED_KEY
# define XTS_CHAIN_TWEAK # define XTS_CHAIN_TWEAK
# define __ARM_ARCH__ 7 # define __ARM_ARCH__ __LINUX_ARM_ARCH__
# define __ARM_MAX_ARCH__ 7
#endif #endif
#ifdef __thumb__ #ifdef __thumb__
# define adrl adr # define adrl adr
#endif #endif
#if __ARM_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
.arch armv7-a
.fpu neon
.text .text
.syntax unified @ ARMv7-capable assembler is expected to handle this .syntax unified @ ARMv7-capable assembler is expected to handle this
#ifdef __thumb2__ #ifdef __thumb2__
...@@ -74,8 +78,6 @@ ...@@ -74,8 +78,6 @@
.code 32 .code 32
#endif #endif
.fpu neon
.type _bsaes_decrypt8,%function .type _bsaes_decrypt8,%function
.align 4 .align 4
_bsaes_decrypt8: _bsaes_decrypt8:
...@@ -2095,9 +2097,11 @@ bsaes_xts_decrypt: ...@@ -2095,9 +2097,11 @@ bsaes_xts_decrypt:
vld1.8 {q8}, [r0] @ initial tweak vld1.8 {q8}, [r0] @ initial tweak
adr r2, .Lxts_magic adr r2, .Lxts_magic
#ifndef XTS_CHAIN_TWEAK
tst r9, #0xf @ if not multiple of 16 tst r9, #0xf @ if not multiple of 16
it ne @ Thumb2 thing, sanity check in ARM it ne @ Thumb2 thing, sanity check in ARM
subne r9, #0x10 @ subtract another 16 bytes subne r9, #0x10 @ subtract another 16 bytes
#endif
subs r9, #0x80 subs r9, #0x80
blo .Lxts_dec_short blo .Lxts_dec_short
......
...@@ -701,14 +701,18 @@ $code.=<<___; ...@@ -701,14 +701,18 @@ $code.=<<___;
# define VFP_ABI_FRAME 0 # define VFP_ABI_FRAME 0
# define BSAES_ASM_EXTENDED_KEY # define BSAES_ASM_EXTENDED_KEY
# define XTS_CHAIN_TWEAK # define XTS_CHAIN_TWEAK
# define __ARM_ARCH__ 7 # define __ARM_ARCH__ __LINUX_ARM_ARCH__
# define __ARM_MAX_ARCH__ 7
#endif #endif
#ifdef __thumb__ #ifdef __thumb__
# define adrl adr # define adrl adr
#endif #endif
#if __ARM_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
.arch armv7-a
.fpu neon
.text .text
.syntax unified @ ARMv7-capable assembler is expected to handle this .syntax unified @ ARMv7-capable assembler is expected to handle this
#ifdef __thumb2__ #ifdef __thumb2__
...@@ -717,8 +721,6 @@ $code.=<<___; ...@@ -717,8 +721,6 @@ $code.=<<___;
.code 32 .code 32
#endif #endif
.fpu neon
.type _bsaes_decrypt8,%function .type _bsaes_decrypt8,%function
.align 4 .align 4
_bsaes_decrypt8: _bsaes_decrypt8:
...@@ -2076,9 +2078,11 @@ bsaes_xts_decrypt: ...@@ -2076,9 +2078,11 @@ bsaes_xts_decrypt:
vld1.8 {@XMM[8]}, [r0] @ initial tweak vld1.8 {@XMM[8]}, [r0] @ initial tweak
adr $magic, .Lxts_magic adr $magic, .Lxts_magic
#ifndef XTS_CHAIN_TWEAK
tst $len, #0xf @ if not multiple of 16 tst $len, #0xf @ if not multiple of 16
it ne @ Thumb2 thing, sanity check in ARM it ne @ Thumb2 thing, sanity check in ARM
subne $len, #0x10 @ subtract another 16 bytes subne $len, #0x10 @ subtract another 16 bytes
#endif
subs $len, #0x80 subs $len, #0x80
blo .Lxts_dec_short blo .Lxts_dec_short
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment