SP C, SP int: improve performance

In SP C: Improve performance of large digit mul and sqr.
In SP int: include optimized 16 digit mul and sqr when compiling SAKKE.
This commit is contained in:
Sean Parkinson 2022-12-05 14:17:09 +10:00
parent b99f5e5041
commit 22141faf16
3 changed files with 2420 additions and 2320 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9193,7 +9193,9 @@ static int _sp_mul_12(const sp_int* a, const sp_int* b, sp_int* r)
#endif /* SP_WORD_SIZE == 32 */
#endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if defined(SQR_MUL_ASM) && (defined(WOLFSSL_SP_INT_LARGE_COMBA) || \
(!defined(WOLFSSL_SP_MATH) && defined(WOLFCRYPT_HAVE_SAKKE) && \
(SP_WORD_SIZE == 64)))
#if SP_INT_DIGITS >= 32
/* Multiply a by b and store in r: r = a * b
*
@ -9614,7 +9616,10 @@ static int _sp_mul_16(const sp_int* a, const sp_int* b, sp_int* r)
return err;
}
#endif /* SP_INT_DIGITS >= 32 */
#endif /* SQR_MUL_ASM && (WOLFSSL_SP_INT_LARGE_COMBA || !WOLFSSL_SP_MATH &&
* WOLFCRYPT_HAVE_SAKKE && SP_WORD_SIZE == 64 */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 48
/* Multiply a by b and store in r: r = a * b
*
@ -11163,13 +11168,18 @@ int sp_mul(const sp_int* a, const sp_int* b, sp_int* r)
#endif /* SQR_MUL_ASM */
#endif /* SP_WORD_SIZE == 32 */
#endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if defined(SQR_MUL_ASM) && (defined(WOLFSSL_SP_INT_LARGE_COMBA) || \
(!defined(WOLFSSL_SP_MATH) && defined(WOLFCRYPT_HAVE_SAKKE) && \
(SP_WORD_SIZE == 64)))
#if SP_INT_DIGITS >= 32
if ((a->used == 16) && (b->used == 16)) {
err = _sp_mul_16(a, b, r);
}
else
#endif /* SP_INT_DIGITS >= 32 */
#endif /* SQR_MUL_ASM && (WOLFSSL_SP_INT_LARGE_COMBA || !WOLFSSL_SP_MATH &&
* WOLFCRYPT_HAVE_SAKKE && SP_WORD_SIZE == 64 */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 48
if ((a->used == 24) && (b->used == 24)) {
err = _sp_mul_24(a, b, r);
@ -14374,7 +14384,9 @@ static int _sp_sqr_12(const sp_int* a, sp_int* r)
#endif /* SP_WORD_SIZE == 32 */
#endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if defined(SQR_MUL_ASM) && (defined(WOLFSSL_SP_INT_LARGE_COMBA) || \
(!defined(WOLFSSL_SP_MATH) && defined(WOLFCRYPT_HAVE_SAKKE) && \
(SP_WORD_SIZE == 64)))
#if SP_INT_DIGITS >= 32
/* Square a and store in r. r = a * a
*
@ -14702,7 +14714,10 @@ static int _sp_sqr_16(const sp_int* a, sp_int* r)
return err;
}
#endif /* SP_INT_DIGITS >= 32 */
#endif /* SQR_MUL_ASM && (WOLFSSL_SP_INT_LARGE_COMBA || !WOLFSSL_SP_MATH &&
* WOLFCRYPT_HAVE_SAKKE && SP_WORD_SIZE == 64 */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 48
/* Square a and store in r. r = a * a
*
@ -15903,13 +15918,18 @@ int sp_sqr(const sp_int* a, sp_int* r)
#endif /* SQR_MUL_ASM */
#endif /* SP_WORD_SIZE == 32 */
#endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if defined(SQR_MUL_ASM) && (defined(WOLFSSL_SP_INT_LARGE_COMBA) || \
(!defined(WOLFSSL_SP_MATH) && defined(WOLFCRYPT_HAVE_SAKKE) && \
(SP_WORD_SIZE == 64)))
#if SP_INT_DIGITS >= 32
if (a->used == 16) {
err = _sp_sqr_16(a, r);
}
else
#endif /* SP_INT_DIGITS >= 32 */
#endif /* SQR_MUL_ASM && (WOLFSSL_SP_INT_LARGE_COMBA || !WOLFSSL_SP_MATH &&
* WOLFCRYPT_HAVE_SAKKE && SP_WORD_SIZE == 64 */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 48
if (a->used == 24) {
err = _sp_sqr_24(a, r);