Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neon impl of ChaCha20 (better size & perf) #9701

Open
wants to merge 17 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.d/chacha20-neon.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Features
* ChaCha20 size and performance: add a Neon implementation of ChaCha20 for
Thumb2 and 32 and 64-bit Arm, for Armv7 onwards. At default settings,
this improves performance by around 2x to 2.3x on Aarch64.
5 changes: 5 additions & 0 deletions include/mbedtls/build_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
#define MBEDTLS_ARCH_IS_ARM32
#endif

#if !defined(MBEDTLS_ARCH_IS_THUMB) && \
defined(_M_ARMT) || defined(__thumb__) || defined(__thumb2__)
#define MBEDTLS_ARCH_IS_THUMB
#endif

#if !defined(MBEDTLS_ARCH_IS_X64) && \
(defined(__amd64__) || defined(__x86_64__) || \
((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)))
Expand Down
36 changes: 36 additions & 0 deletions tests/scripts/components-configuration-crypto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,42 @@ END
./tf-psa-crypto/tests/test_suite_shax
}


support_test_chacha20_variations () {
case $(uname -m) in
aarch64) true;;
*) false;;
esac
}

component_test_chacha20_neon_variations () {
msg "ChaCha20 Neon scalar and multiblock variations"

# define minimal config sufficient to test ChaCha20
cat > include/mbedtls/mbedtls_config.h << END
#define MBEDTLS_AES_C
#define MBEDTLS_CHACHA20_C
#define MBEDTLS_ENTROPY_C
#define MBEDTLS_CTR_DRBG_C
#define MBEDTLS_PSA_CRYPTO_C
#define MBEDTLS_PSA_CRYPTO_CONFIG
#define MBEDTLS_SELF_TEST
END

cat > tf-psa-crypto/include/psa/crypto_config.h << END
#define PSA_WANT_ALG_SHA_256 1
END

make clean
for x in 0 1 2 3 4 5 6; do
msg "multiblock = $x"
make clean
make -C tests ../tf-psa-crypto/tests/test_suite_chacha20 CFLAGS="-DMBEDTLS_CHACHA20_NEON_MULTIBLOCK=$x"
./tf-psa-crypto/tests/test_suite_chacha20
done
}


support_build_aes_aesce_armcc () {
support_build_armcc
}
Expand Down
Loading