crypto: arm64/chacha – fix hchacha_block_neon() for big endian [Linux 5.0]

crypto: arm64/chacha – fix hchacha_block_neon() for big endian [Linux 5.0]

This Linux kernel change "crypto: arm64/chacha – fix hchacha_block_neon() for big endian" is included in the Linux 5.0 release. This change is authored by Eric Biggers <ebiggers [at] google.com> on Fri Feb 22 22:54:08 2019 -0800. The commit for this change in Linux stable tree is f86d17e (patch).

crypto: arm64/chacha - fix hchacha_block_neon() for big endian

On big endian arm64 kernels, the xchacha20-neon and xchacha12-neon
self-tests fail because hchacha_block_neon() outputs little endian words
but the C code expects native endianness.  Fix it to output the words in
native endianness (which also makes it match the arm32 version).

Fixes: cc7cf991e9eb ("crypto: arm64/chacha20 - add XChaCha20 support")
Signed-off-by: Eric Biggers <[email protected]>
Reviewed-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/arm64/crypto/chacha-neon-core.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/crypto/chacha-neon-core.S b/arch/arm64/crypto/chacha-neon-core.S
index bfb80e1..706c4e1 100644
--- a/arch/arm64/crypto/chacha-neon-core.S
+++ b/arch/arm64/crypto/chacha-neon-core.S
@@ -158,8 +158,8 @@ ENTRY(hchacha_block_neon)
    mov     w3, w2
    bl      chacha_permute

-   st1     {v0.16b}, [x1], #16
-   st1     {v3.16b}, [x1]
+   st1     {v0.4s}, [x1], #16
+   st1     {v3.4s}, [x1]

    ldp     x29, x30, [sp], #16
    ret

Leave a Reply

Your email address will not be published. Required fields are marked *