SP: Thumb assembly for older Keil compilers and optimize

Improve the generated instructions for multiplying 32 bits by 32 bits
and squaring 32 bits with 64 bit results.
Minimize loads in montgomery reduction, mul and sqr.
Pull conditional subtract into montgomery reduction assembly code.
Added unrolled square and multiply
Define WOLFSSL_SP_LARGE_CODE to use the unrolled versions.
This commit is contained in:
Sean Parkinson
2021-07-28 08:46:35 +10:00
parent 998c7a9cb9
commit 6300989937
6 changed files with 144290 additions and 17811 deletions

View File

@@ -50,7 +50,7 @@
#ifdef WOLFSSL_SP_ARM32_ASM
#define SP_PRINT_NUM(var, name, total, words, bits) \
do { \
int ii \
int ii; \
fprintf(stderr, name "=0x"); \
for (ii = words - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \

View File

@@ -50,7 +50,7 @@
#ifdef WOLFSSL_SP_ARM64_ASM
#define SP_PRINT_NUM(var, name, total, words, bits) \
do { \
int ii \
int ii; \
fprintf(stderr, name "=0x"); \
for (ii = words - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \

File diff suppressed because it is too large Load Diff

View File

@@ -59,7 +59,7 @@
#ifdef WOLFSSL_SP_ARM_CORTEX_M_ASM
#define SP_PRINT_NUM(var, name, total, words, bits) \
do { \
int ii \
int ii; \
fprintf(stderr, name "=0x"); \
for (ii = words - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \

View File

@@ -12340,9 +12340,6 @@ int sp_read_unsigned_bin(sp_int* a, const byte* in, word32 inSz)
return err;
}
#if (!defined(NO_DH) || defined(HAVE_ECC) || defined(WC_RSA_BLINDING) || \
defined(WOLFSSL_RSA_PUBLIC_ONLY)) && (!defined(WOLFSSL_RSA_VERIFY_ONLY) || \
defined(HAVE_ECC_KEY_EXPORT))
/* Convert the multi-precision number to an array of bytes in big-endian format.
*
* The array must be large enough for encoded number - use mp_unsigned_bin_size
@@ -12358,8 +12355,6 @@ int sp_to_unsigned_bin(sp_int* a, byte* out)
{
return sp_to_unsigned_bin_len(a, out, sp_unsigned_bin_size(a));
}
#endif /* (!NO_DH || HAVE_ECC || WC_RSA_BLINDING || WOLFSSL_RSA_PUBLIC_ONLY)
&& !WOLFSSL_RSA_VERIFY_ONLY */
/* Convert the multi-precision number to an array of bytes in big-endian format.
*

View File

@@ -50,7 +50,7 @@
#ifdef WOLFSSL_SP_X86_64_ASM
#define SP_PRINT_NUM(var, name, total, words, bits) \
do { \
int ii \
int ii; \
fprintf(stderr, name "=0x"); \
for (ii = words - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \