mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 08:10:55 +02:00
Merge pull request #10767 from SparkiDev/ppc64_ppc32_asm_1
PPC64/PPC32 ASM: AES, SHA-2, SHA-3
This commit is contained in:
@@ -924,6 +924,7 @@ WOLFSSL_SECURE_RENEGOTIATION_ON_BY_DEFAULT
|
||||
WOLFSSL_SERVER_EXAMPLE
|
||||
WOLFSSL_SETTINGS_FILE
|
||||
WOLFSSL_SHA256_ALT_CH_MAJ
|
||||
WOLFSSL_SHA3_PPC64_BLOCKS_N
|
||||
WOLFSSL_SHA512_HASHTYPE
|
||||
WOLFSSL_SHUTDOWNONCE
|
||||
WOLFSSL_SILABS_TRNG
|
||||
|
||||
+64
-1
@@ -3943,6 +3943,7 @@ then
|
||||
done
|
||||
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC32_ASM"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DEXTERNAL_OPTS_OPENVPN"
|
||||
AC_MSG_NOTICE([32-bit PowerPC assembly for SHA-256])
|
||||
ENABLED_PPC32_ASM=yes
|
||||
|
||||
@@ -3951,6 +3952,11 @@ then
|
||||
else
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_PPC32_ASM"
|
||||
fi
|
||||
if test "$ENABLED_PPC32_ASM_INLINE_REG" = "yes"; then
|
||||
# The inline-register variant names GPRs (r0..r31) in inline assembly,
|
||||
# which the PowerPC assembler only accepts with -mregnames.
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC32_ASM_INLINE_REG -Wa,-mregnames"
|
||||
fi
|
||||
if test "$ENABLED_PPC32_ASM_SMALL" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC32_ASM_SMALL"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_PPC32_ASM_SMALL"
|
||||
@@ -3986,8 +3992,14 @@ then
|
||||
small)
|
||||
ENABLED_PPC64_ASM_SMALL=yes
|
||||
;;
|
||||
crypto)
|
||||
ENABLED_PPC64_ASM_CRYPTO=yes
|
||||
;;
|
||||
power8)
|
||||
ENABLED_PPC64_ASM_POWER8=yes
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid RISC-V option [yes,inline,small]: $ENABLED_PPC64_ASM.])
|
||||
AC_MSG_ERROR([Invalid PPC64 option [yes,inline,small,crypto,power8]: $ENABLED_PPC64_ASM.])
|
||||
break
|
||||
;;
|
||||
esac
|
||||
@@ -4007,6 +4019,20 @@ if test "$ENABLED_PPC64_ASM_SMALL" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC64_ASM_SMALL"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_PPC64_ASM_SMALL"
|
||||
fi
|
||||
# POWER8 vector-crypto (vshasigmaw) SHA-256, selected at run time. The
|
||||
# generated code marks the relevant function/section as POWER8 itself, so no
|
||||
# global -mcpu=power8 is needed and the rest of the library stays portable.
|
||||
if test "$ENABLED_PPC64_ASM_CRYPTO" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC64_ASM_CRYPTO"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_PPC64_ASM_CRYPTO"
|
||||
fi
|
||||
# POWER8 VSX (vrld) SHA-3, selected at run time. Like the crypto variant the
|
||||
# generated code marks its own function/section as POWER8, so no global
|
||||
# -mcpu=power8 is needed and the rest of the library stays portable.
|
||||
if test "$ENABLED_PPC64_ASM_POWER8" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC64_ASM_POWER8"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_PPC64_ASM_POWER8"
|
||||
fi
|
||||
|
||||
|
||||
# Xilinx hardened crypto
|
||||
@@ -4691,6 +4717,9 @@ fi
|
||||
if test "$ENABLED_SHA512" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA512"
|
||||
# The SHA-512 transform is asm on some targets (PPC); the .S is guarded by
|
||||
# WOLFSSL_SHA512/WOLFSSL_SHA384 so the assembler needs the macro too.
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SHA512"
|
||||
fi
|
||||
|
||||
# SHA-256 Hash DRBG (SP 800-90A) -- sub-option of hashdrbg
|
||||
@@ -4734,6 +4763,7 @@ fi
|
||||
if test "$ENABLED_SHA384" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA384"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SHA384"
|
||||
fi
|
||||
|
||||
|
||||
@@ -7431,6 +7461,9 @@ fi
|
||||
if test "$ENABLED_SHA3" != "no"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA3"
|
||||
# The SHA-3 block transform is asm on some targets (PPC); the .S is guarded
|
||||
# by WOLFSSL_SHA3 so the assembler needs the macro too.
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SHA3"
|
||||
fi
|
||||
|
||||
# Set SHAKE128 flags
|
||||
@@ -11843,28 +11876,54 @@ then
|
||||
if test "$ENABLED_AESGCM" = "word32"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DGCM_WORD32"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DGCM_WORD32"
|
||||
ENABLED_AESGCM=yes
|
||||
fi
|
||||
|
||||
if test "$ENABLED_AESGCM" = "small" || test "$ENABLED_LOWRESOURCE" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DGCM_SMALL"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DGCM_SMALL"
|
||||
ENABLED_AESGCM=yes
|
||||
fi
|
||||
|
||||
if test "$ENABLED_AESGCM" = "table"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DGCM_TABLE"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DGCM_TABLE"
|
||||
ENABLED_AESGCM=yes
|
||||
fi
|
||||
|
||||
if test "$ENABLED_AESGCM" = "4bit"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DGCM_TABLE_4BIT"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DGCM_TABLE_4BIT"
|
||||
ENABLED_AESGCM=yes
|
||||
fi
|
||||
|
||||
# The GCM table layout macro must reach assembled (.S) sources too: the
|
||||
# PPC asm GCM_gmult_len is a single file with both layouts guarded by
|
||||
# GCM_TABLE / GCM_TABLE_4BIT. Default (no explicit table choice) is 4bit.
|
||||
case " $AM_CCASFLAGS " in
|
||||
*" -DGCM_TABLE "*|*" -DGCM_TABLE_4BIT "*|*" -DGCM_SMALL "*|*" -DGCM_WORD32 "*) ;;
|
||||
*) AM_CCASFLAGS="$AM_CCASFLAGS -DGCM_TABLE_4BIT" ;;
|
||||
esac
|
||||
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DHAVE_AESGCM"
|
||||
fi
|
||||
# AES-CTR may be turned on by many presets above; mirror the feature macro to
|
||||
# the assembler flags so the AES_CTR_encrypt in the PPC asm is emitted.
|
||||
if test "$ENABLED_AESCTR" = "yes"
|
||||
then
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_AES_COUNTER"
|
||||
fi
|
||||
# Asm sources include settings.h, which enforces that AES-XTS streaming
|
||||
# requires AES-XTS. Mirror the base WOLFSSL_AES_XTS macro to the assembler
|
||||
# flags so that check is satisfied (it is otherwise only set for C sources).
|
||||
if test "$ENABLED_AESXTS" = "yes"
|
||||
then
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_AES_XTS"
|
||||
fi
|
||||
if test "$ENABLED_AESGCM_STREAM" != "no"
|
||||
then
|
||||
@@ -12993,6 +13052,10 @@ if test "$ENABLED_PPC64_ASM_INLINE_REG" = "yes"
|
||||
then
|
||||
ENABLED_PPC64_ASM="inline C Reg"
|
||||
fi
|
||||
if test "$ENABLED_PPC64_ASM_CRYPTO" = "yes"
|
||||
then
|
||||
ENABLED_PPC64_ASM="$ENABLED_PPC64_ASM + crypto"
|
||||
fi
|
||||
echo " * PPC64 ASM $ENABLED_PPC64_ASM"
|
||||
echo " * Write duplicate: $ENABLED_WRITEDUP"
|
||||
echo " * Xilinx Hardware Acc.: $ENABLED_XILINX"
|
||||
|
||||
+220
@@ -258,6 +258,18 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-aes-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_AESNI
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/aes_asm.S
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/aes_x86_64_asm.S
|
||||
@@ -338,6 +350,14 @@ endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_SHA512
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha512.c
|
||||
@@ -394,6 +414,26 @@ endif !BUILD_X86_ASM
|
||||
endif !BUILD_ARMASM
|
||||
endif !BUILD_ARMASM_NEON
|
||||
endif !BUILD_RISCV_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
endif BUILD_SHA512
|
||||
|
||||
if BUILD_SHA3
|
||||
@@ -425,6 +465,24 @@ endif BUILD_ARMASM
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha3.c
|
||||
endif BUILD_RISCV_ASM
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
if !BUILD_X86_ASM
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/sha3_asm.S
|
||||
@@ -532,6 +590,18 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-aes-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_AESNI
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/aes_asm.S
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/aes_x86_64_asm.S
|
||||
@@ -608,6 +678,14 @@ endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_SHA512
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha512.c
|
||||
@@ -662,6 +740,26 @@ endif BUILD_INTELASM
|
||||
endif !BUILD_ARMASM
|
||||
endif !BUILD_ARMASM_NEON
|
||||
endif !BUILD_RISCV_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
endif BUILD_SHA512
|
||||
|
||||
if BUILD_SHA3
|
||||
@@ -693,6 +791,24 @@ endif BUILD_ARMASM
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha3.c
|
||||
endif BUILD_RISCV_ASM
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/sha3_asm.S
|
||||
endif
|
||||
@@ -940,6 +1056,14 @@ endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_SHA512
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha512.c
|
||||
@@ -994,6 +1118,26 @@ endif BUILD_INTELASM
|
||||
endif !BUILD_ARMASM
|
||||
endif !BUILD_ARMASM_NEON
|
||||
endif !BUILD_RISCV_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
endif BUILD_SHA512
|
||||
|
||||
if BUILD_SHA3
|
||||
@@ -1025,6 +1169,24 @@ endif BUILD_ARMASM
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha3.c
|
||||
endif BUILD_RISCV_ASM
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/sha3_asm.S
|
||||
endif
|
||||
@@ -1294,6 +1456,14 @@ endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha256-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
endif !BUILD_FIPS_V2_PLUS
|
||||
|
||||
if BUILD_AFALG
|
||||
@@ -1420,6 +1590,18 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-aes-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-aes-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
|
||||
if BUILD_AFALG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/af_alg/afalg_aes.c
|
||||
endif BUILD_AFALG
|
||||
@@ -1509,6 +1691,26 @@ endif !BUILD_X86_ASM
|
||||
endif !BUILD_ARMASM
|
||||
endif !BUILD_ARMASM_NEON
|
||||
endif !BUILD_RISCV_ASM
|
||||
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha512-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha512-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
endif BUILD_SHA512
|
||||
endif !BUILD_FIPS_V2_PLUS
|
||||
|
||||
@@ -1542,6 +1744,24 @@ endif BUILD_ARMASM
|
||||
if BUILD_RISCV_ASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-sha3.c
|
||||
endif BUILD_RISCV_ASM
|
||||
if BUILD_PPC64_ASM
|
||||
if BUILD_PPC64_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm_c.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc64/ppc64-sha3-asm.S
|
||||
endif !BUILD_PPC64_ASM_INLINE
|
||||
endif BUILD_PPC64_ASM
|
||||
if BUILD_PPC32_ASM
|
||||
if BUILD_PPC32_ASM_INLINE
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_c.c
|
||||
else
|
||||
if BUILD_PPC32_ASM_INLINE_REG
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm_cr.c
|
||||
else
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/ppc32/ppc32-sha3-asm.S
|
||||
endif !BUILD_PPC32_ASM_INLINE_REG
|
||||
endif !BUILD_PPC32_ASM_INLINE
|
||||
endif BUILD_PPC32_ASM
|
||||
if !BUILD_X86_ASM
|
||||
if BUILD_INTELASM
|
||||
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/sha3_asm.S
|
||||
|
||||
@@ -4807,6 +4807,15 @@ static void print_cpu_features(void)
|
||||
if (IS_AARCH64_SHA3(cpuid_flags)) printf(" sha3");
|
||||
if (IS_AARCH64_SM3(cpuid_flags)) printf(" sm3");
|
||||
if (IS_AARCH64_SM4(cpuid_flags)) printf(" sm4");
|
||||
#endif
|
||||
#ifdef HAVE_CPUID_PPC64
|
||||
printf("PPC64 -");
|
||||
if (IS_PPC64_ALTIVEC(cpuid_flags)) printf(" altivec");
|
||||
if (IS_PPC64_VSX(cpuid_flags)) printf(" vsx");
|
||||
if (IS_PPC64_VEC_CRYPTO(cpuid_flags)) printf(" vcrypto");
|
||||
if (IS_PPC64_ARCH_2_07(cpuid_flags)) printf(" arch_2_07");
|
||||
if (IS_PPC64_ARCH_3_00(cpuid_flags)) printf(" arch_3_00");
|
||||
if (IS_PPC64_ARCH_3_1(cpuid_flags)) printf(" arch_3_1");
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
+21
-21
@@ -1189,7 +1189,7 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(Aes* aes, const byte* inBlock,
|
||||
}
|
||||
#endif /* HAVE_AES_DECRYPT && WOLFSSL_AES_DIRECT */
|
||||
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
|
||||
#if defined(WOLFSSL_AES_DIRECT) || defined(HAVE_AESCCM) || \
|
||||
defined(WOLFSSL_AESGCM_STREAM) || defined(HAVE_AESGCM)
|
||||
@@ -4891,7 +4891,7 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(Aes* aes, const byte* inBlock,
|
||||
return AesSetKey(aes, userKey, keylen, iv, dir);
|
||||
}
|
||||
#endif /* WOLFSSL_AES_DIRECT || WOLFSSL_AES_COUNTER */
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
static int AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
|
||||
const byte* iv, int dir)
|
||||
{
|
||||
@@ -6932,7 +6932,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
|
||||
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
word32 blocks;
|
||||
int ret;
|
||||
#endif
|
||||
@@ -6945,7 +6945,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
blocks = sz / WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS
|
||||
@@ -7021,7 +7021,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
AES_CBC_encrypt(in, out, sz, (const unsigned char*)aes->key,
|
||||
aes->rounds, (unsigned char*)aes->reg);
|
||||
return 0;
|
||||
@@ -7136,7 +7136,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
/* Software AES - CBC Decrypt */
|
||||
int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
word32 blocks;
|
||||
int ret;
|
||||
#endif
|
||||
@@ -7164,7 +7164,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
blocks = sz / WC_AES_BLOCK_SIZE;
|
||||
#endif
|
||||
if (sz % WC_AES_BLOCK_SIZE) {
|
||||
@@ -7257,7 +7257,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
#endif
|
||||
#endif /* __aarch64__ || WOLFSSL_ARMASM_NO_HW_CRYPTO */
|
||||
return 0;
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
AES_CBC_decrypt(in, out, sz, (const unsigned char*)aes->key,
|
||||
aes->rounds, (unsigned char*)aes->reg);
|
||||
return 0;
|
||||
@@ -7621,7 +7621,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
!defined(WOLFSSL_ARMASM_NO_HW_CRYPTO))
|
||||
byte scratch[WC_AES_BLOCK_SIZE];
|
||||
#endif
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
int ret = 0;
|
||||
#endif
|
||||
word32 processed;
|
||||
@@ -7744,7 +7744,7 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
}
|
||||
#endif /* __aarch64__ || WOLFSSL_ARMASM_NO_HW_CRYPTO */
|
||||
return 0;
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
{
|
||||
word32 numBlocks;
|
||||
byte* tmp = (byte*)aes->tmp + WC_AES_BLOCK_SIZE - aes->left;
|
||||
@@ -8584,7 +8584,7 @@ static void GCM_gmult_len_armasm_C(
|
||||
#elif defined(WOLFSSL_ARMASM)
|
||||
#define GCM_GMULT_LEN(gcm, x, a, len) \
|
||||
GCM_gmult_len_NEON(x, (const byte*)((gcm)->H), a, len)
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
static void GCM_gmult_len_armasm_C(
|
||||
byte* x, const byte* h, const unsigned char* a, unsigned long len)
|
||||
{
|
||||
@@ -8628,7 +8628,7 @@ static void GCM_gmult_len_armasm_C(
|
||||
#define GCM_GMULT_LEN(gcm, x, a, len) \
|
||||
GCM_gmult_len(x, (const byte**)((gcm)->M0), a, len)
|
||||
#endif
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
#define GCM_GMULT_LEN(gcm, x, a, len) \
|
||||
GCM_gmult_len(x, (const byte**)((gcm)->M0), a, len)
|
||||
#else
|
||||
@@ -8928,7 +8928,7 @@ void GHASH(Gcm* gcm, const byte* a, word32 aSz, const byte* c,
|
||||
#endif
|
||||
|
||||
/* PPC64 assembly */
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
#define GCM_GMULT_LEN(gcm, x, a, len) \
|
||||
GCM_gmult_len(x, (const byte**)((gcm)->M0), a, len)
|
||||
#define GMULT(x, m) \
|
||||
@@ -10448,7 +10448,7 @@ static WARN_UNUSED_RESULT int wc_AesGcmEncrypt_STM32(
|
||||
|
||||
#endif /* STM32_CRYPTO_AES_GCM */
|
||||
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
#ifdef WOLFSSL_AESNI
|
||||
/* For performance reasons, this code needs to be not inlined. */
|
||||
WARN_UNUSED_RESULT int AES_GCM_encrypt_C(
|
||||
@@ -10569,7 +10569,7 @@ WARN_UNUSED_RESULT int AES_GCM_encrypt_C(
|
||||
return ret;
|
||||
}
|
||||
#elif (defined(__aarch64__) || defined(WOLFSSL_ARMASM_NO_HW_CRYPTO)) || \
|
||||
defined(WOLFSSL_PPC64_ASM)
|
||||
(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
static int AES_GCM_encrypt_ASM(Aes* aes, byte* out, const byte* in,
|
||||
word32 sz, const byte* iv, word32 ivSz, byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
@@ -10830,7 +10830,7 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
authTagSz, authIn, authInSz);
|
||||
}
|
||||
#endif /* __aarch64__ || WOLFSSL_ARMASM_NO_HW_CRYPTO */
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
ret = AES_GCM_encrypt_ASM(aes, out, in, sz, iv, ivSz, authTag, authTagSz,
|
||||
authIn, authInSz);
|
||||
#else
|
||||
@@ -11193,7 +11193,7 @@ static WARN_UNUSED_RESULT int wc_AesGcmDecrypt_STM32(
|
||||
|
||||
#endif /* STM32_CRYPTO_AES_GCM */
|
||||
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
#ifdef WOLFSSL_AESNI
|
||||
/* For performance reasons, this code needs to be not inlined. */
|
||||
int WARN_UNUSED_RESULT AES_GCM_decrypt_C(
|
||||
@@ -11343,7 +11343,7 @@ int WARN_UNUSED_RESULT AES_GCM_decrypt_C(
|
||||
return ret;
|
||||
}
|
||||
#elif (defined(__aarch64__) || defined(WOLFSSL_ARMASM_NO_HW_CRYPTO)) || \
|
||||
defined(WOLFSSL_PPC64_ASM)
|
||||
(defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
static int AES_GCM_decrypt_ASM(Aes* aes, byte* out, const byte* in,
|
||||
word32 sz, const byte* iv, word32 ivSz, const byte* authTag,
|
||||
word32 authTagSz, const byte* authIn, word32 authInSz)
|
||||
@@ -11602,7 +11602,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
authTagSz, authIn, authInSz);
|
||||
}
|
||||
#endif /* __aarch64__ || WOLFSSL_ARMASM_NO_HW_CRYPTO */
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
{
|
||||
ret = AES_GCM_decrypt_ASM(aes, out, in, sz, iv, ivSz, authTag,
|
||||
authTagSz, authIn, authInSz);
|
||||
@@ -15142,7 +15142,7 @@ static WARN_UNUSED_RESULT int _AesEcbEncrypt(
|
||||
aes->rounds);
|
||||
}
|
||||
#endif
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
AES_ECB_encrypt(in, out, sz, (const unsigned char*)aes->key, aes->rounds);
|
||||
ret = 0;
|
||||
#else
|
||||
@@ -15241,7 +15241,7 @@ static WARN_UNUSED_RESULT int _AesEcbDecrypt(
|
||||
aes->rounds);
|
||||
}
|
||||
#endif
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#elif (defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM))
|
||||
AES_ECB_decrypt(in, out, sz, (const unsigned char*)aes->key, aes->rounds);
|
||||
ret = 0;
|
||||
#else
|
||||
|
||||
+103
-1
@@ -24,7 +24,7 @@
|
||||
#include <wolfssl/wolfcrypt/cpuid.h>
|
||||
|
||||
#if defined(HAVE_CPUID) || defined(HAVE_CPUID_INTEL) || \
|
||||
defined(HAVE_CPUID_AARCH64)
|
||||
defined(HAVE_CPUID_AARCH64) || defined(HAVE_CPUID_PPC64)
|
||||
static cpuid_flags_atomic_t cpuid_flags = WC_CPUID_ATOMIC_INITIALIZER;
|
||||
#endif
|
||||
|
||||
@@ -373,6 +373,108 @@
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#elif defined(HAVE_CPUID_PPC64)
|
||||
|
||||
/* PowerPC feature bits as reported through the ELF auxiliary vector
|
||||
* (see <asm/cputable.h>). Defined here so a kernel header is not required. */
|
||||
#ifndef AT_HWCAP2
|
||||
#define AT_HWCAP2 26
|
||||
#endif
|
||||
#ifndef PPC_FEATURE_HAS_ALTIVEC
|
||||
#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 /* AT_HWCAP */
|
||||
#endif
|
||||
#ifndef PPC_FEATURE_HAS_VSX
|
||||
#define PPC_FEATURE_HAS_VSX 0x00000080 /* AT_HWCAP */
|
||||
#endif
|
||||
#ifndef PPC_FEATURE2_ARCH_2_07
|
||||
#define PPC_FEATURE2_ARCH_2_07 0x80000000 /* AT_HWCAP2 */
|
||||
#endif
|
||||
#ifndef PPC_FEATURE2_VEC_CRYPTO
|
||||
#define PPC_FEATURE2_VEC_CRYPTO 0x02000000 /* AT_HWCAP2 */
|
||||
#endif
|
||||
#ifndef PPC_FEATURE2_ARCH_3_00
|
||||
#define PPC_FEATURE2_ARCH_3_00 0x00800000 /* AT_HWCAP2 */
|
||||
#endif
|
||||
#ifndef PPC_FEATURE2_ARCH_3_1
|
||||
#define PPC_FEATURE2_ARCH_3_1 0x00040000 /* AT_HWCAP2 */
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(__GLIBC__)
|
||||
#include <sys/auxv.h>
|
||||
|
||||
static WC_INLINE void cpuid_set_flags(void)
|
||||
{
|
||||
if (WOLFSSL_ATOMIC_LOAD(cpuid_flags) == WC_CPUID_INITIALIZER) {
|
||||
cpuid_flags_t new_cpuid_flags = 0,
|
||||
old_cpuid_flags = WC_CPUID_INITIALIZER;
|
||||
unsigned long hwcap = getauxval(AT_HWCAP);
|
||||
unsigned long hwcap2 = getauxval(AT_HWCAP2);
|
||||
|
||||
if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
|
||||
new_cpuid_flags |= CPUID_ALTIVEC;
|
||||
if (hwcap & PPC_FEATURE_HAS_VSX)
|
||||
new_cpuid_flags |= CPUID_VSX;
|
||||
if (hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
||||
new_cpuid_flags |= CPUID_ARCH_2_07;
|
||||
if (hwcap2 & PPC_FEATURE2_VEC_CRYPTO)
|
||||
new_cpuid_flags |= CPUID_VEC_CRYPTO;
|
||||
if (hwcap2 & PPC_FEATURE2_ARCH_3_00)
|
||||
new_cpuid_flags |= CPUID_ARCH_3_00;
|
||||
if (hwcap2 & PPC_FEATURE2_ARCH_3_1)
|
||||
new_cpuid_flags |= CPUID_ARCH_3_1;
|
||||
|
||||
(void)wolfSSL_Atomic_Uint_CompareExchange
|
||||
(&cpuid_flags, &old_cpuid_flags, new_cpuid_flags);
|
||||
}
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/auxv.h>
|
||||
|
||||
static WC_INLINE void cpuid_set_flags(void)
|
||||
{
|
||||
if (WOLFSSL_ATOMIC_LOAD(cpuid_flags) == WC_CPUID_INITIALIZER) {
|
||||
cpuid_flags_t new_cpuid_flags = 0,
|
||||
old_cpuid_flags = WC_CPUID_INITIALIZER;
|
||||
unsigned long hwcap = 0, hwcap2 = 0;
|
||||
|
||||
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
|
||||
elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
|
||||
|
||||
if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
|
||||
new_cpuid_flags |= CPUID_ALTIVEC;
|
||||
if (hwcap & PPC_FEATURE_HAS_VSX)
|
||||
new_cpuid_flags |= CPUID_VSX;
|
||||
if (hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
||||
new_cpuid_flags |= CPUID_ARCH_2_07;
|
||||
if (hwcap2 & PPC_FEATURE2_VEC_CRYPTO)
|
||||
new_cpuid_flags |= CPUID_VEC_CRYPTO;
|
||||
if (hwcap2 & PPC_FEATURE2_ARCH_3_00)
|
||||
new_cpuid_flags |= CPUID_ARCH_3_00;
|
||||
if (hwcap2 & PPC_FEATURE2_ARCH_3_1)
|
||||
new_cpuid_flags |= CPUID_ARCH_3_1;
|
||||
|
||||
(void)wolfSSL_Atomic_Uint_CompareExchange
|
||||
(&cpuid_flags, &old_cpuid_flags, new_cpuid_flags);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* No run-time detection available - report no acceleration. */
|
||||
static WC_INLINE void cpuid_set_flags(void)
|
||||
{
|
||||
if (WOLFSSL_ATOMIC_LOAD(cpuid_flags) == WC_CPUID_INITIALIZER) {
|
||||
cpuid_flags_t new_cpuid_flags = 0,
|
||||
old_cpuid_flags = WC_CPUID_INITIALIZER;
|
||||
#ifdef WOLFSSL_PPC64_ASM_POWER8
|
||||
new_cpuid_flags |= CPUID_ARCH_2_07;
|
||||
#endif
|
||||
#ifdef WOLFSSL_PPC64_ASM_CRYPTO
|
||||
new_cpuid_flags |= CPUID_VEC_CRYPTO;
|
||||
#endif
|
||||
(void)wolfSSL_Atomic_Uint_CompareExchange
|
||||
(&cpuid_flags, &old_cpuid_flags, new_cpuid_flags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#elif defined(HAVE_CPUID)
|
||||
static WC_INLINE void cpuid_set_flags(void)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@
|
||||
* ../wolfssl/wolfcrypt/src/port/ppc32/ppc32-sha256-asm.S
|
||||
*/
|
||||
|
||||
#include <wolfssl/wolfcrypt/libwolfssl_sources_asm.h>
|
||||
|
||||
#ifdef WOLFSSL_PPC32_ASM
|
||||
#ifndef WOLFSSL_PPC32_ASM_INLINE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+9961
-2374
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+58
-3
@@ -126,6 +126,7 @@ on the specific device platform.
|
||||
(defined(WOLFSSL_HAVE_PSA) && !defined(WOLFSSL_PSA_NO_HASH)) || \
|
||||
defined(WOLFSSL_RENESAS_RX64_HASH) || \
|
||||
defined(WOLFSSL_PPC32_ASM) || \
|
||||
defined(WOLFSSL_PPC64_ASM) || \
|
||||
defined(WOLFSSL_ARMASM) || \
|
||||
(defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \
|
||||
(defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))))
|
||||
@@ -242,6 +243,8 @@ on the specific device platform.
|
||||
#define SHA256_UPDATE_REV_BYTES(ctx) 0 /* reverse not needed on update */
|
||||
#elif defined(WOLFSSL_PPC32_ASM)
|
||||
#define SHA256_UPDATE_REV_BYTES(ctx) 0
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#define SHA256_UPDATE_REV_BYTES(ctx) 0
|
||||
#elif defined(WOLFSSL_ARMASM)
|
||||
#define SHA256_UPDATE_REV_BYTES(ctx) 0
|
||||
#else
|
||||
@@ -1121,11 +1124,47 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
#elif defined(WOLFSSL_RENESAS_RX64_HASH)
|
||||
|
||||
/* implemented in wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c */
|
||||
#elif defined(WOLFSSL_PPC32_ASM) && !defined(WOLF_CRYPTO_CB_ONLY_SHA256)
|
||||
#elif (defined(WOLFSSL_PPC32_ASM) || defined(WOLFSSL_PPC64_ASM)) && \
|
||||
!defined(WOLF_CRYPTO_CB_ONLY_SHA256)
|
||||
|
||||
extern void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
|
||||
word32 len);
|
||||
|
||||
#if defined(WOLFSSL_PPC64_ASM) && defined(WOLFSSL_PPC64_ASM_CRYPTO)
|
||||
/* POWER8+ has a vector SHA-256 sigma instruction (vshasigmaw). When built
|
||||
* in, select that implementation at run time if the CPU supports it.
|
||||
*
|
||||
* A run-time flag with direct calls is used rather than a function pointer:
|
||||
* an indirect call would require an ELFv1 function descriptor, whereas direct
|
||||
* calls work under both the ELFv1 and ELFv2 ABIs. */
|
||||
extern void Transform_Sha256_Len_crypto(wc_Sha256* sha256, const byte* data,
|
||||
word32 len);
|
||||
|
||||
/* -1 = not yet determined, 0 = base, 1 = vector-crypto */
|
||||
static int sha256_use_crypto = -1;
|
||||
|
||||
/* Detect CPU support via the central cpuid module. Idempotent - safe to call
|
||||
* from multiple threads as all callers compute the same value. */
|
||||
static void Sha256_SetTransform(void)
|
||||
{
|
||||
if (sha256_use_crypto < 0) {
|
||||
sha256_use_crypto = IS_PPC64_VEC_CRYPTO(cpuid_get_flags()) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
static WC_INLINE void SHA256_TRANSFORM_LEN(wc_Sha256* sha256, const byte* data,
|
||||
word32 len)
|
||||
{
|
||||
if (sha256_use_crypto)
|
||||
Transform_Sha256_Len_crypto(sha256, data, len);
|
||||
else
|
||||
Transform_Sha256_Len(sha256, data, len);
|
||||
}
|
||||
#else
|
||||
#define Sha256_SetTransform() WC_DO_NOTHING
|
||||
#define SHA256_TRANSFORM_LEN(s, d, l) Transform_Sha256_Len((s), (d), (l))
|
||||
#endif
|
||||
|
||||
int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -1136,20 +1175,31 @@ int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
Sha256_SetTransform();
|
||||
|
||||
sha256->heap = heap;
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
sha256->devId = devId;
|
||||
sha256->devCtx = NULL;
|
||||
#else
|
||||
(void)devId;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha256->W = NULL;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int Transform_Sha256(wc_Sha256* sha256, const byte* data)
|
||||
{
|
||||
Transform_Sha256_Len(sha256, data, WC_SHA256_BLOCK_SIZE);
|
||||
SHA256_TRANSFORM_LEN(sha256, data, WC_SHA256_BLOCK_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define XTRANSFORM Transform_Sha256
|
||||
#define XTRANSFORM_LEN Transform_Sha256_Len
|
||||
#define XTRANSFORM_LEN(s, d, l) SHA256_TRANSFORM_LEN((s), (d), (l))
|
||||
|
||||
#elif defined(WOLFSSL_ARMASM) && !defined(WOLF_CRYPTO_CB_ONLY_SHA256)
|
||||
|
||||
@@ -2254,6 +2304,11 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
|
||||
Sha256_SetTransform();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(WOLFSSL_PPC64_ASM) && defined(WOLFSSL_PPC64_ASM_CRYPTO)
|
||||
/* SHA-224 shares the SHA-256 transform; select the base/vector-crypto
|
||||
* implementation at run time (sets sha256_use_crypto). */
|
||||
Sha256_SetTransform();
|
||||
#endif
|
||||
#ifdef WOLFSSL_HASH_FLAGS
|
||||
sha224->flags = 0;
|
||||
#endif
|
||||
|
||||
+48
-2
@@ -124,7 +124,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_RISCV_ASM)
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_RISCV_ASM) && \
|
||||
!defined(WOLFSSL_PPC64_ASM) && !defined(WOLFSSL_PPC32_ASM)
|
||||
|
||||
#ifdef WOLFSSL_SHA3_SMALL
|
||||
/* Rotate a 64-bit value left.
|
||||
@@ -604,7 +605,52 @@ void BlockSha3(word64* s)
|
||||
}
|
||||
#endif /* WC_SHA3_SW_KECCAK */
|
||||
#endif /* !WOLFSSL_SHA3_SMALL */
|
||||
#endif /* !WOLFSSL_ARMASM && !WOLFSSL_RISCV_ASM */
|
||||
#endif /* !WOLFSSL_ARMASM && !WOLFSSL_RISCV_ASM && !WOLFSSL_PPC64_ASM &&
|
||||
* !WOLFSSL_PPC32_ASM */
|
||||
|
||||
#if defined(WOLFSSL_PPC64_ASM)
|
||||
#if defined(WOLFSSL_PPC64_ASM_POWER8)
|
||||
/* PowerPC64 provides two Keccak-f[1600] implementations: the scalar
|
||||
* BlockSha3_base and a POWER8 (PowerISA 2.07) VSX BlockSha3_power8 (which uses
|
||||
* vrld/mtvsrd). Select the POWER8 one at run time when the CPU is POWER8 or
|
||||
* later.
|
||||
*
|
||||
* A run-time flag with direct calls is used rather than a function pointer: an
|
||||
* indirect call would require an ELFv1 function descriptor, whereas direct
|
||||
* calls work under both the ELFv1 and ELFv2 ABIs. */
|
||||
#include <wolfssl/wolfcrypt/cpuid.h>
|
||||
|
||||
/* -1 = not yet determined, 0 = base, 1 = POWER8 */
|
||||
static int sha3_use_power8 = -1;
|
||||
|
||||
void BlockSha3(word64* s)
|
||||
{
|
||||
if (sha3_use_power8 < 0) {
|
||||
word32 f = cpuid_get_flags();
|
||||
/* The VSX permutation is only worthwhile where the scalar issue width
|
||||
* does not already win. POWER9 (PowerISA 3.0 but not 3.1) has enough
|
||||
* scalar throughput that BlockSha3_base is faster, so use the VSX path
|
||||
* only on POWER8 and on POWER10 (3.1) or later. */
|
||||
sha3_use_power8 = IS_PPC64_ARCH_2_07(f) &&
|
||||
(!IS_PPC64_ARCH_3_00(f) || IS_PPC64_ARCH_3_1(f));
|
||||
}
|
||||
|
||||
if (sha3_use_power8)
|
||||
BlockSha3_power8(s);
|
||||
else
|
||||
BlockSha3_base(s);
|
||||
}
|
||||
#else
|
||||
/* Only the scalar implementation is built; call it directly (no run-time
|
||||
* dispatch, no function pointer). */
|
||||
void BlockSha3(word64* s)
|
||||
{
|
||||
BlockSha3_base(s);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Scalar PowerPC32 assembly provides BlockSha3 directly (see
|
||||
* wolfcrypt/src/port/ppc32/ppc32-sha3-asm.S), so nothing is needed here. */
|
||||
|
||||
#ifdef WC_SHA3_SW_KECCAK
|
||||
#if defined(BIG_ENDIAN_ORDER)
|
||||
|
||||
+72
-7
@@ -1501,11 +1501,71 @@ static void Sha512_SetTransform(void)
|
||||
transform_check = 1;
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
|
||||
/* Scalar (base instruction) SHA-512 transform for big-endian PowerPC (32- and
|
||||
* 64-bit). The asm loads the message words directly, so no byte reversal is
|
||||
* needed and the (sha512, data, len) form is used just like the ARM assembly. */
|
||||
extern void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data,
|
||||
word32 len);
|
||||
|
||||
#if defined(WOLFSSL_PPC64_ASM) && defined(WOLFSSL_PPC64_ASM_CRYPTO)
|
||||
/* POWER8+ has a vector SHA-512 sigma instruction (vshasigmad). When built
|
||||
* in, select that implementation at run time if the CPU supports it.
|
||||
*
|
||||
* A run-time flag with direct calls is used rather than a function pointer:
|
||||
* an indirect call would require an ELFv1 function descriptor, whereas direct
|
||||
* calls work under both the ELFv1 and ELFv2 ABIs. */
|
||||
extern void Transform_Sha512_Len_crypto(wc_Sha512* sha512, const byte* data,
|
||||
word32 len);
|
||||
|
||||
/* -1 = not yet determined, 0 = base, 1 = vector-crypto */
|
||||
static int sha512_use_crypto = -1;
|
||||
|
||||
/* Detect CPU support via the central cpuid module on first use. Idempotent -
|
||||
* safe to call from multiple threads as all callers compute the same value. */
|
||||
static WC_INLINE void SHA512_TRANSFORM_LEN(wc_Sha512* sha512, const byte* data,
|
||||
word32 len)
|
||||
{
|
||||
if (sha512_use_crypto < 0)
|
||||
sha512_use_crypto = IS_PPC64_VEC_CRYPTO(cpuid_get_flags()) != 0;
|
||||
|
||||
if (sha512_use_crypto)
|
||||
Transform_Sha512_Len_crypto(sha512, data, len);
|
||||
else
|
||||
Transform_Sha512_Len(sha512, data, len);
|
||||
}
|
||||
/* SHA512_TRANSFORM_LEN is a function here, not a macro, so signal that a
|
||||
* dispatcher is provided - otherwise the generic fallback below sees
|
||||
* !defined(SHA512_TRANSFORM_LEN) and shadows it with a base-only macro. */
|
||||
#define SHA512_HAVE_TRANSFORM_LEN
|
||||
#else
|
||||
#define SHA512_TRANSFORM_LEN(s, d, l) Transform_Sha512_Len((s), (d), (l))
|
||||
#define SHA512_HAVE_TRANSFORM_LEN
|
||||
#endif
|
||||
|
||||
static WC_INLINE int Transform_Sha512(wc_Sha512* sha512, const byte* data)
|
||||
{
|
||||
SHA512_TRANSFORM_LEN(sha512, data, WC_SHA512_BLOCK_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define Sha512_SetTransform() WC_DO_NOTHING
|
||||
|
||||
#else
|
||||
#define Transform_Sha512(sha512) _Transform_Sha512(sha512)
|
||||
|
||||
#endif
|
||||
|
||||
/* For platforms that share the (sha512, data, len) block-loop call below but
|
||||
* don't provide their own dispatcher (e.g. ARM), call the length transform
|
||||
* directly. */
|
||||
#if (defined(WOLFSSL_ARMASM) || defined(WOLFSSL_PPC64_ASM) || \
|
||||
defined(WOLFSSL_PPC32_ASM)) && \
|
||||
!defined(SHA512_TRANSFORM_LEN) && !defined(SHA512_HAVE_TRANSFORM_LEN)
|
||||
#define SHA512_TRANSFORM_LEN(s, d, l) Transform_Sha512_Len((s), (d), (l))
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
|
||||
static int InitSha512_Family(wc_Sha512* sha512, void* heap, int devId,
|
||||
@@ -1611,7 +1671,7 @@ int wc_InitSha512_256_ex(wc_Sha512* sha512, void* heap, int devId)
|
||||
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
|
||||
#ifndef WOLFSSL_ARMASM
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM) && !defined(WOLFSSL_PPC32_ASM)
|
||||
|
||||
static const word64 K512[80] = {
|
||||
W64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd),
|
||||
@@ -1803,7 +1863,7 @@ static WC_INLINE int Sha512Update(wc_Sha512* sha512, const byte* data, word32 le
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
Transform_Sha512(sha512, (const byte*)sha512->buffer);
|
||||
#elif !defined(WOLFSSL_ESP32_CRYPT) || \
|
||||
defined(NO_WOLFSSL_ESP32_CRYPT_HASH) || \
|
||||
@@ -1829,11 +1889,11 @@ static WC_INLINE int Sha512Update(wc_Sha512* sha512, const byte* data, word32 le
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_ARMASM)
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
if (len >= WC_SHA512_BLOCK_SIZE) {
|
||||
word32 blocksLen = len & ~((word32)WC_SHA512_BLOCK_SIZE-1);
|
||||
|
||||
Transform_Sha512_Len(sha512, data, blocksLen);
|
||||
SHA512_TRANSFORM_LEN(sha512, data, blocksLen);
|
||||
data += blocksLen;
|
||||
len -= blocksLen;
|
||||
}
|
||||
@@ -1993,7 +2053,7 @@ int wc_Sha512Update(wc_Sha512* sha512, const byte* data, word32 len)
|
||||
|
||||
static WC_INLINE int Sha512Final(wc_Sha512* sha512)
|
||||
{
|
||||
#ifndef WOLFSSL_ARMASM
|
||||
#if !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PPC64_ASM) && !defined(WOLFSSL_PPC32_ASM)
|
||||
int ret;
|
||||
#endif
|
||||
byte* local;
|
||||
@@ -2041,7 +2101,7 @@ static WC_INLINE int Sha512Final(wc_Sha512* sha512)
|
||||
}
|
||||
|
||||
#endif /* LITTLE_ENDIAN_ORDER */
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
Transform_Sha512(sha512, (const byte*)sha512->buffer);
|
||||
#else
|
||||
#if defined(WOLFSSL_USE_ESP32_CRYPT_HASH_HW) && \
|
||||
@@ -2122,7 +2182,7 @@ static WC_INLINE int Sha512Final(wc_Sha512* sha512)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
Transform_Sha512(sha512, (const byte*)sha512->buffer);
|
||||
#else
|
||||
#if !defined(WOLFSSL_ESP32_CRYPT) || \
|
||||
@@ -2389,6 +2449,11 @@ int wc_Sha512Transform(wc_Sha512* sha, const unsigned char* data)
|
||||
ByteReverseWords64(buffer, (word64*)data, WC_SHA512_BLOCK_SIZE);
|
||||
Transform_Sha512(sha, (const byte*)buffer);
|
||||
ret = 0;
|
||||
#elif defined(WOLFSSL_PPC64_ASM) || defined(WOLFSSL_PPC32_ASM)
|
||||
/* PPC assembly uses the (sha, data) form and reads the block directly
|
||||
* (big-endian native - any little-endian reversal was done above). */
|
||||
(void)buffer;
|
||||
ret = Transform_Sha512(sha, data);
|
||||
#else
|
||||
XMEMCPY(buffer, sha->buffer, WC_SHA512_BLOCK_SIZE);
|
||||
XMEMCPY(sha->buffer, data, WC_SHA512_BLOCK_SIZE);
|
||||
|
||||
@@ -1159,6 +1159,28 @@ WOLFSSL_LOCAL void AES_XTS_decrypt(const byte* in, byte* out, word32 sz,
|
||||
#endif
|
||||
#endif /* WOLFSSL_PPC64_ASM */
|
||||
|
||||
#if defined(WOLFSSL_PPC32_ASM)
|
||||
WOLFSSL_LOCAL void AES_set_encrypt_key(const unsigned char* key, word32 len,
|
||||
unsigned char* ks);
|
||||
WOLFSSL_LOCAL void AES_invert_key(unsigned char* ks, word32 rounds);
|
||||
WOLFSSL_LOCAL void AES_ECB_encrypt(const unsigned char* in, unsigned char* out,
|
||||
unsigned long len, const unsigned char* ks, int nr);
|
||||
WOLFSSL_LOCAL void AES_ECB_decrypt(const unsigned char* in, unsigned char* out,
|
||||
unsigned long len, const unsigned char* ks, int nr);
|
||||
WOLFSSL_LOCAL void AES_CBC_encrypt(const unsigned char* in, unsigned char* out,
|
||||
unsigned long len, const unsigned char* ks, int nr, unsigned char* iv);
|
||||
WOLFSSL_LOCAL void AES_CBC_decrypt(const unsigned char* in, unsigned char* out,
|
||||
unsigned long len, const unsigned char* ks, int nr, unsigned char* iv);
|
||||
WOLFSSL_LOCAL void AES_CTR_encrypt(const unsigned char* in, unsigned char* out,
|
||||
unsigned long len, const unsigned char* ks, int nr, unsigned char* ctr);
|
||||
#if defined(GCM_TABLE) || defined(GCM_TABLE_4BIT)
|
||||
WOLFSSL_LOCAL void GCM_gmult_len(byte* x, const byte** m,
|
||||
const unsigned char* data, unsigned long len);
|
||||
#endif
|
||||
WOLFSSL_LOCAL void AES_GCM_encrypt(const unsigned char* in, unsigned char* out,
|
||||
unsigned long len, const unsigned char* ks, int nr, unsigned char* ctr);
|
||||
#endif /* WOLFSSL_PPC32_ASM */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#define HAVE_CPUID
|
||||
#define HAVE_CPUID_AARCH64
|
||||
#endif
|
||||
#if defined(WOLFSSL_PPC64_ASM) && !defined(WOLFSSL_NO_ASM)
|
||||
#define HAVE_CPUID
|
||||
#define HAVE_CPUID_PPC64
|
||||
#endif
|
||||
|
||||
#define WC_CPUID_INITIALIZER 0xffffffffU
|
||||
typedef word32 cpuid_flags_t;
|
||||
@@ -105,6 +109,29 @@ typedef word32 cpuid_flags_t;
|
||||
#define IS_AARCH64_SM4(f) (WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_SM4)
|
||||
#define IS_AARCH64_SB(f) (WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_SB)
|
||||
|
||||
#elif defined(HAVE_CPUID_PPC64)
|
||||
|
||||
#define CPUID_ALTIVEC 0x0001 /* VMX / AltiVec */
|
||||
#define CPUID_VSX 0x0002 /* Vector-Scalar Extension */
|
||||
#define CPUID_ARCH_2_07 0x0004 /* POWER8 / PowerISA 2.07 */
|
||||
#define CPUID_VEC_CRYPTO 0x0008 /* Vector crypto: vshasigmaw, vcipher,
|
||||
* vpmsumd, ... */
|
||||
#define CPUID_ARCH_3_00 0x0010 /* POWER9 / PowerISA 3.0 */
|
||||
#define CPUID_ARCH_3_1 0x0020 /* POWER10 / PowerISA 3.1 */
|
||||
|
||||
#define IS_PPC64_ALTIVEC(f) \
|
||||
(WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_ALTIVEC)
|
||||
#define IS_PPC64_VSX(f) \
|
||||
(WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_VSX)
|
||||
#define IS_PPC64_ARCH_2_07(f) \
|
||||
(WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_ARCH_2_07)
|
||||
#define IS_PPC64_VEC_CRYPTO(f) \
|
||||
(WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_VEC_CRYPTO)
|
||||
#define IS_PPC64_ARCH_3_00(f) \
|
||||
(WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_ARCH_3_00)
|
||||
#define IS_PPC64_ARCH_3_1(f) \
|
||||
(WOLFSSL_ATOMIC_COERCE_UINT(f) & CPUID_ARCH_3_1)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CPUID
|
||||
|
||||
@@ -272,6 +272,11 @@ WOLFSSL_LOCAL void BlockSha3(word64 *s);
|
||||
WOLFSSL_LOCAL void BlockSha3_crypto(word64 *s);
|
||||
#endif
|
||||
WOLFSSL_LOCAL void BlockSha3_base(word64 *s);
|
||||
#elif defined(WOLFSSL_PPC64_ASM)
|
||||
#ifdef WOLFSSL_PPC64_ASM_POWER8
|
||||
WOLFSSL_LOCAL void BlockSha3_power8(word64 *s);
|
||||
#endif
|
||||
WOLFSSL_LOCAL void BlockSha3_base(word64 *s);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user