Experimental support for Intel and ARM ASM with Zephyr. Related to issue #7116.

pull/7325/head
David Garske 2024-03-18 13:40:10 -07:00
parent 03e306a98f
commit face8b6e43
6 changed files with 77 additions and 1 deletions

View File

@ -128,6 +128,37 @@ if(CONFIG_WOLFSSL)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/psa/psa_pkcbs.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/st/stm32.c)
if(CONFIG_WOLFCRYPT_ARMASM)
# tested with board: "qemu_kvm_arm64"
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-aes.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-sha256.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-sha512.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-sha512-asm_c.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-poly1305.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-chacha.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/port/arm/armv8-curve25519_c.c)
set(MCPU_FLAGS "-mcpu=cortex-a53+crypto -mstrict-align")
#set(MCPU_FLAGS "-mcpu=generic+crypto -mstrict-align")
endif()
if(CONFIG_WOLFCRYPT_INTELASM)
# tested with board: "qemu_x86_64"
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha256_asm.S)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha512_asm.S)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/sha3_asm.S)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/chacha_asm.S)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/poly1305_asm.S)
# issues with aesni
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/aes_asm.S)
#zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/aes_gcm_x86_asm.S)
#set(MCPU_FLAGS "-march=native -maes -msse4 -mpclmul ")
endif()
zephyr_library_link_libraries(wolfSSL)
target_compile_definitions(wolfSSL INTERFACE WOLFSSL_ZEPHYR)

View File

@ -70,6 +70,19 @@ config WOLFCRYPT_FIPS
Enables FIPS support in wolfCrypt. Requires the wolfSSL FIPS ready
download that includes fips.c/fips_test.c.
config WOLFCRYPT_ARMASM
bool "wolfCrypt ARM Assembly support"
depends on WOLFSSL_BUILTIN
help
wolfCrypt ARM (ARMv8/ARMv7) assembly support for AES, SHA-2, SHA-3,
ChaCha20/Poly1305 and Curve25519
config WOLFCRYPT_INTELASM
bool "wolfCrypt Intel Assembly support"
depends on WOLFSSL_BUILTIN
help
wolfCrypt Intel Aassembly support (AVX/AVX2/AESNI)
config WOLFSSL_DEBUG
bool "wolfSSL debug activation"
depends on WOLFSSL_BUILTIN

View File

@ -26,6 +26,10 @@ CONFIG_LOG_BUFFER_SIZE=15360
#CONFIG_WOLFSSL_DEBUG=y
# Entropy
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y
# Optional ARM or Intel Assembly
#CONFIG_WOLFCRYPT_ARMASM=y
#CONFIG_WOLFCRYPT_INTELASM=y

View File

@ -24,6 +24,6 @@ CONFIG_LOG_BUFFER_SIZE=15360
#CONFIG_WOLFSSL_DEBUG=y
# Entropy
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y

View File

@ -1,6 +1,7 @@
# Kernel options
CONFIG_MAIN_STACK_SIZE=16384
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_INIT_STACKS=y
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=65536

View File

@ -380,6 +380,33 @@ extern "C" {
#endif
#endif
/* ------------------------------------------------------------------------- */
/* Assembly Speedups for Symmetric Algorithms */
/* ------------------------------------------------------------------------- */
#ifdef CONFIG_WOLFCRYPT_ARMASM
#define WOLFSSL_ARMASM
#define WOLFSSL_NO_HASH_RAW
#define WOLFSSL_ARMASM_INLINE /* use inline .c versions */
#define WOLFSSL_ARMASM_NO_HW_CRYPTO /* enable if processor does not support aes/sha instructions */
#define WOLFSSL_ARMASM_NO_NEON
/* Default is ARMv8 */
#if 0 /* ARMv7 */
#define WOLFSSL_ARM_ARCH 7
#endif
#endif
#ifdef CONFIG_WOLFCRYPT_INTELASM
#define USE_INTEL_SPEEDUP
#define WOLFSSL_X86_64_BUILD /* 64-bit */
//#define WOLFSSL_X86_BUILD /* 32-bit */
/* Issues with building AESNI "_mm_aesimc_si128" always_inline */
//#define WOLFSSL_AESNI
#endif
/* ------------------------------------------------------------------------- */
/* Debugging */