mirror of https://github.com/wolfSSL/wolfssl
Merge pull request #1418 from SparkiDev/sp_armasm
Add assembly code for ARM and 64-bit ARM
This commit is contained in:
commit
a4000ba196
42
configure.ac
42
configure.ac
|
@ -3452,7 +3452,40 @@ if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SP_ECC" = "yes"; then
|
|||
ENABLED_SP=yes
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_SP_ECC"
|
||||
fi
|
||||
AM_CONDITIONAL([BUILD_SP], [test "x$ENABLED_SP" = "xyes"])
|
||||
|
||||
|
||||
AC_ARG_ENABLE([sp-asm],
|
||||
[AS_HELP_STRING([--enable-sp-asm],[Enable Single Precision assembly implementation (default: disabled)])],
|
||||
[ ENABLED_SP_ASM=$enableval ],
|
||||
[ ENABLED_SP_ASM=no ],
|
||||
)
|
||||
if test "$ENABLED_SP_ASM" = "yes"; then
|
||||
if test "$ENABLED_SP" = "no"; then
|
||||
AC_MSG_ERROR([Must have SP enabled: --enable-sp])
|
||||
fi
|
||||
if test "$ENABLED_ASM" = "no"; then
|
||||
AC_MSG_ERROR([Assembly code turned off])
|
||||
fi
|
||||
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_ASM"
|
||||
case $host_cpu in
|
||||
*aarch64*)
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_ARM64_ASM"
|
||||
ENABLED_SP_ARM64_ASM=yes
|
||||
;;
|
||||
*arm*)
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_ARM32_ASM"
|
||||
ENABLED_SP_ARM32_ASM=yes
|
||||
;;
|
||||
*x86_64*)
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_X86_64_ASM"
|
||||
ENABLED_SP_X86_64_ASM=yes
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([ASM not available for CPU. Supported CPUs: x86_64, aarch64, arm])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([sp-math],
|
||||
[AS_HELP_STRING([--enable-sp-math],[Enable Single Precision math implementation only (default: disabled)])],
|
||||
|
@ -3486,6 +3519,13 @@ if test "$ENABLED_SP_MATH" = "yes"; then
|
|||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_MATH"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_SP], [test "x$ENABLED_SP" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_SP_C], [test "x$ENABLED_SP" = "xyes" && test "x$ENABLED_SP_ASM" = "xno" ])
|
||||
AM_CONDITIONAL([BUILD_SP_ARM64], [test "x$ENABLED_SP_ARM64_ASM" = "xyes" ])
|
||||
AM_CONDITIONAL([BUILD_SP_ARM32], [test "x$ENABLED_SP_ARM32_ASM" = "xyes" ])
|
||||
AM_CONDITIONAL([BUILD_SP_X86_64], [test "x$ENABLED_SP_X86_64_ASM" = "xyes" ])
|
||||
AM_CONDITIONAL([BUILD_SP_INT], [test "x$ENABLED_SP_MATH" = "xyes" ])
|
||||
|
||||
# Fast RSA using Intel IPP
|
||||
ippdir="${srcdir}/IPP"
|
||||
ipplib="lib" # if autoconf guesses 32bit system changes lib directory
|
||||
|
|
|
@ -107,10 +107,25 @@ endif
|
|||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_SP
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp.c
|
||||
if BUILD_SP_C
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_c32.c
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_c64.c
|
||||
endif
|
||||
if BUILD_SP_X86_64
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_x86_64.c
|
||||
endif
|
||||
if BUILD_SP_ARM32
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_arm32.c
|
||||
endif
|
||||
if BUILD_SP_ARM64
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_arm64.c
|
||||
endif
|
||||
if BUILD_SP_INT
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_int.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_AES
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes.c
|
||||
|
|
|
@ -20081,12 +20081,8 @@ exit_scke:
|
|||
int DecodePrivateKey(WOLFSSL *ssl, word16* length)
|
||||
{
|
||||
int ret = BAD_FUNC_ARG;
|
||||
#if !defined(NO_RSA) || defined(HAVE_ECC) || defined(HAVE_ED25519)
|
||||
int keySz;
|
||||
word32 idx;
|
||||
#else
|
||||
(void)length;
|
||||
#endif
|
||||
|
||||
/* make sure private key exists */
|
||||
if (ssl->buffers.key == NULL || ssl->buffers.key->buffer == NULL) {
|
||||
|
@ -20197,7 +20193,6 @@ int DecodePrivateKey(WOLFSSL *ssl, word16* length)
|
|||
WOLFSSL_MSG("Using ED25519 private key");
|
||||
|
||||
/* Check it meets the minimum ECC key size requirements. */
|
||||
(void)keySz;
|
||||
if (ED25519_KEY_SIZE < ssl->options.minEccKeySz) {
|
||||
WOLFSSL_MSG("ED25519 key size too small");
|
||||
ERROR_OUT(ECC_KEY_SIZE_E, exit_dpk);
|
||||
|
@ -20212,6 +20207,7 @@ int DecodePrivateKey(WOLFSSL *ssl, word16* length)
|
|||
|
||||
(void)idx;
|
||||
(void)keySz;
|
||||
(void)length;
|
||||
exit_dpk:
|
||||
return ret;
|
||||
}
|
||||
|
@ -24165,6 +24161,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||
#endif
|
||||
|
||||
(void)size;
|
||||
(void)input;
|
||||
|
||||
WOLFSSL_ENTER("DoClientKeyExchange");
|
||||
|
||||
|
|
|
@ -981,7 +981,7 @@ static int wc_ecc_export_x963_compressed(ecc_key*, byte* out, word32* outLen);
|
|||
typedef void* ecc_curve_spec;
|
||||
#else
|
||||
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || !defined(WOLFSSL_SP_MATH)
|
||||
static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_int* a,
|
||||
mp_int* prime, mp_int* order);
|
||||
#endif
|
||||
|
@ -5042,7 +5042,7 @@ static int ecc_check_privkey_gen_helper(ecc_key* key)
|
|||
#endif /* WOLFSSL_VALIDATE_ECC_IMPORT */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || !defined(WOLFSSL_SP_MATH)
|
||||
/* validate order * pubkey = point at infinity, 0 on success */
|
||||
static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_int* a,
|
||||
mp_int* prime, mp_int* order)
|
||||
|
@ -5083,7 +5083,6 @@ static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_int* a,
|
|||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !WOLFSSL_ATECC508A */
|
||||
|
||||
|
||||
|
|
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
|
@ -26,19 +26,33 @@
|
|||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef WOLFSSL_SP_X86_64_ASM
|
||||
#define SP_WORD_SIZE 64
|
||||
|
||||
#define HAVE_INTEL_AVX1
|
||||
#define HAVE_INTEL_AVX2
|
||||
#elif defined(WOLFSSL_SP_ARM64_ASM)
|
||||
#define SP_WORD_SIZE 64
|
||||
#elif defined(WOLFSSL_SP_ARM32_ASM)
|
||||
#define SP_WORD_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef SP_WORD_SIZE
|
||||
#if defined(NO_64BIT) || !defined(HAVE___UINT128_T)
|
||||
#define SP_WORD_SIZE 32
|
||||
#else
|
||||
#define SP_WORD_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_X86_64_BUILD) || !defined(USE_INTEL_SPEEDUP)
|
||||
#ifndef WOLFSSL_SP_ASM
|
||||
#if SP_WORD_SIZE == 32
|
||||
typedef int32_t sp_digit;
|
||||
typedef uint32_t sp_int_digit;
|
||||
#elif SP_WORD_SIZE == 64
|
||||
typedef int64_t sp_digit;
|
||||
typedef uint64_t sp_int_digit;
|
||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
||||
typedef long int128_t __attribute__ ((mode(TI)));
|
||||
#else
|
||||
#error Word size not defined
|
||||
|
|
Loading…
Reference in New Issue