1
0
mirror of https://github.com/wolfSSL/wolfssl.git synced 2026-10-24 04:09:07 +03:00

sp: support ECC non-blocking for the large implementation with tables and windowing

This commit is contained in:
David Garske
2026-10-13 18:28:43 -07:00
parent 28bc7540dd
commit 2f7c94fe7e
12 changed files with 10920 additions and 1338 deletions

View File

@@ -234,5 +234,29 @@
"--enable-sp=yes,nonblock", "--enable-riscv-asm", "--enable-sp-asm", "--disable-examples",
"CPPFLAGS=-Wdeclaration-after-statement -DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"],
"check": false,
"run": [["env", "QEMU_LD_PREFIX=/usr/riscv64-linux-gnu", "./wolfcrypt/test/testwolfcrypt"]]},
{"name": "arm64-sp-nonblock-fast", "minutes": 2.5,
"cc": "ccache aarch64-linux-gnu-gcc",
"comment": "ECC non-blocking on the SP assembly implementation without the small math: the table and window non-blocking multiplies. Key gen, sign and the base point half of verify use sp_<curve>_ecc_mulmod_base_<n>_nb; shared secret and the other half of verify use sp_<curve>_ecc_mulmod_<n>_nb. No WOLFSSL_VALIDATE_ECC_KEYGEN here, so the non-blocking key gen and shared secret test cases run.",
"configure": ["--host=aarch64-linux-gnu", "--enable-ecc=nonblock",
"--enable-sp=yes,nonblocklarge", "--enable-sp-asm", "--disable-examples",
"CPPFLAGS=-Wdeclaration-after-statement -DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"],
"check": false,
"run": [["env", "QEMU_LD_PREFIX=/usr/aarch64-linux-gnu", "./wolfcrypt/test/testwolfcrypt"]]},
{"name": "armhf-sp-nonblock-fast", "minutes": 2.5,
"cc": "ccache arm-linux-gnueabihf-gcc",
"comment": "ECC non-blocking on the SP assembly implementation without the small math: the table and window non-blocking multiplies. Key gen, sign and the base point half of verify use sp_<curve>_ecc_mulmod_base_<n>_nb; shared secret and the other half of verify use sp_<curve>_ecc_mulmod_<n>_nb. No WOLFSSL_VALIDATE_ECC_KEYGEN here, so the non-blocking key gen and shared secret test cases run.",
"configure": ["--host=arm-linux-gnueabihf", "--enable-ecc=nonblock",
"--enable-sp=yes,nonblocklarge", "--enable-sp-asm", "--disable-examples",
"CPPFLAGS=-Wdeclaration-after-statement -DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"],
"check": false,
"run": [["env", "QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf", "./wolfcrypt/test/testwolfcrypt"]]},
{"name": "riscv64-sp-nonblock-fast", "minutes": 2.5,
"cc": "ccache riscv64-linux-gnu-gcc",
"comment": "ECC non-blocking on the SP assembly implementation without the small math: the table and window non-blocking multiplies. Key gen, sign and the base point half of verify use sp_<curve>_ecc_mulmod_base_<n>_nb; shared secret and the other half of verify use sp_<curve>_ecc_mulmod_<n>_nb. No WOLFSSL_VALIDATE_ECC_KEYGEN here, so the non-blocking key gen and shared secret test cases run.",
"configure": ["--host=riscv64-linux-gnu", "--enable-ecc=nonblock",
"--enable-sp=yes,nonblocklarge", "--enable-riscv-asm", "--enable-sp-asm", "--disable-examples",
"CPPFLAGS=-Wdeclaration-after-statement -DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK -DWC_ECC_NONBLOCK_ONLY"],
"check": false,
"run": [["env", "QEMU_LD_PREFIX=/usr/riscv64-linux-gnu", "./wolfcrypt/test/testwolfcrypt"]]}
]

View File

@@ -89,6 +89,15 @@
"configure": ["--enable-ecc=nonblock", "--enable-sp=yes,nonblock",
"--enable-sp-asm", "--enable-intelasm",
"CPPFLAGS=-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"]},
{"name": "nonblock-sp-asm-fast", "minutes": 3.0,
"comment": "Same but without the small math, so the non-blocking ECC state machines and the table-based blocking paths are built together.",
"configure": ["--enable-ecc=nonblock", "--enable-sp=yes,nonblocklarge",
"--enable-sp-asm", "--enable-intelasm",
"CPPFLAGS=-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"]},
{"name": "nonblock-sp-c64-fast", "minutes": 4.2,
"comment": "Non-blocking ECC on the portable C implementation without the small math; RSA/DH non-block are left off because their mod_exp only exists in the small variant.",
"configure": ["--enable-ecc=nonblock", "--enable-sp=yes,nonblocklarge", "--disable-sp-asm",
"CPPFLAGS=-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"]},
{"name": "all-asn-template", "minutes": 3.5,
"configure": ["--enable-all", "--enable-asn=template"]},
{"name": "tls13-dtls13-session-misc", "minutes": 3.3,

View File

@@ -1130,7 +1130,7 @@ fi
# Single Precision maths implementation
AC_ARG_ENABLE([sp],
[AS_HELP_STRING([--enable-sp],[Enable Single Precision maths implementation, comma separated options include small, smallstack, nomalloc, nonblock and notransposedtable (default: disabled)])],
[AS_HELP_STRING([--enable-sp],[Enable Single Precision maths implementation, comma separated options include small, smallstack, nomalloc, nonblock, nonblocklarge and notransposedtable (default: disabled)])],
[ ENABLED_SP=$enableval ],
[ ENABLED_SP=$ENABLED_SP_DEFAULT ],
)
@@ -11763,6 +11763,14 @@ do
ENABLED_SP_SMALL=yes
;;
nonblocklarge)
# Non-blocking ECC with the large implementation's tables and windowing.
# Requires no malloc. Small is still forced below when RSA/DH non-blocking
# is requested on the C implementation.
ENABLED_SP_NONBLOCK=yes
ENABLED_SP_NO_MALLOC=yes
;;
asm)
ENABLED_SP_ASM=yes
;;
@@ -12005,6 +12013,17 @@ if test "$ENABLED_SP_ASM" = "yes" && test "$ENABLED_SP" = "yes"; then
esac
fi
# Non-blocking RSA/DH mod_exp only exists in the small variant of the C
# implementation. Checked here, after the host checks that can still
# turn the assembly off.
if test "$ENABLED_SP_NONBLOCK" = "yes" && test "$ENABLED_SP_ASM" != "yes" && \
test "$ENABLED_SP_SMALL" != "yes" && \
{ test "$enable_rsa" = "nonblock" || test "$enable_dh" = "nonblock"; }; then
ENABLED_SP_SMALL=yes
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_SMALL"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SP_SMALL"
fi
if test "$ENABLED_SP_ASM" = "yes" && test "$ENABLED_SP" = "yes"; then
if test "$ENABLED_SP_NONBLOCK" = "yes" && \
{ test "$enable_rsa" = "nonblock" || test "$enable_dh" = "nonblock"; }; then

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

View File

@@ -401,7 +401,16 @@ extern "C" {
#if defined(WOLFSSL_HAVE_SP_ECC) && defined(WOLFSSL_SP_NONBLOCK)
/* Non-blocking ECC operation context. */
typedef struct sp_ecc_ctx {
#ifndef WOLFSSL_SP_SMALL
/* Large implementation: verify keeps a table of 33 points. */
#ifdef WOLFSSL_SP_521
XALIGNED(4) byte data[66*340]; /* stack data */
#elif defined(WOLFSSL_SP_384)
XALIGNED(4) byte data[48*330]; /* stack data */
#else
XALIGNED(4) byte data[32*340]; /* stack data */
#endif
#elif defined(WOLFSSL_SP_521)
XALIGNED(4) byte data[66*80]; /* stack data */
#elif defined(WOLFSSL_SP_384)
XALIGNED(4) byte data[48*80]; /* stack data */