Adds ECC non-blocking sign/verify support when used with SP math. New --enable-sp=nonblock and --enable-ecc=nonblock options. Example ./configure --enable-ecc=nonblock --enable-sp=yes,nonblock.

This commit is contained in:
David Garske
2020-07-16 16:06:22 -07:00
parent 080ccd9820
commit 547144bc9c
13 changed files with 11216 additions and 108 deletions
+27 -13
View File
@@ -1545,13 +1545,18 @@ then
ENABLED_ECC="yes"
fi
if test "$ENABLED_ECC" = "yes"
if test "$ENABLED_ECC" != "no"
then
AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256"
if test "$ENABLED_ECC_SHAMIR" = "yes" && test "$ENABLED_LOWRESOURCE" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DECC_SHAMIR"
fi
if test "$ENABLED_ECC" = "nonblock"
then
AM_CFLAGS="$AM_CFLAGS -DWC_ECC_NONBLOCK"
fi
fi
@@ -3206,7 +3211,7 @@ then
ENABLED_ENCRYPT_THEN_MAC=yes
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SNI -DHAVE_MAX_FRAGMENT -DHAVE_TRUNCATED_HMAC -DHAVE_ALPN -DHAVE_TRUSTED_CA"
# Check the ECC supported curves prereq
AS_IF([test "x$ENABLED_ECC" = "xyes" || test "x$ENABLED_CURVE25519" = "xyes" || test "x$ENABLED_TLS13" = "xyes"],
AS_IF([test "x$ENABLED_ECC" != "xno" || test "x$ENABLED_CURVE25519" = "xyes" || test "x$ENABLED_TLS13" = "xyes"],
[ENABLED_SUPPORTED_CURVES=yes
AM_CFLAGS="$AM_CFLAGS -DHAVE_SUPPORTED_CURVES"])
fi
@@ -3762,7 +3767,7 @@ then
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_SNI -DHAVE_MAX_FRAGMENT -DHAVE_TRUNCATED_HMAC"
# Check the ECC supported curves prereq
AS_IF([test "x$ENABLED_ECC" = "xyes" || test "x$ENABLED_CURVE25519" = "xyes"],
AS_IF([test "x$ENABLED_ECC" != "xno" || test "x$ENABLED_CURVE25519" = "xyes"],
[ENABLED_SUPPORTED_CURVES=yes
AM_CFLAGS="$AM_CFLAGS -DHAVE_SUPPORTED_CURVES"])
fi
@@ -3905,7 +3910,7 @@ then
AC_MSG_ERROR([please enable psk if disabling asn.])
fi
if test "x$ENABLED_ECC" = "xyes" && test "x$ENABLED_ASN" = "xno"
if test "x$ENABLED_ECC" != "xno" && test "x$ENABLED_ASN" = "xno"
then
AC_MSG_ERROR([please disable ecc if disabling asn.])
fi
@@ -4251,6 +4256,7 @@ ENABLED_SP_ECC=no
ENABLED_SP_EC_256=no
ENABLED_SP_EC_384=no
ENABLED_SP_NO_MALLOC=no
ENABLED_SP_NONBLOCK=no
for v in `echo $ENABLED_SP | tr "," " "`
do
case $v in
@@ -4267,6 +4273,7 @@ do
ENABLED_SP_EC_384=yes
fi
;;
yes)
ENABLED_SP_RSA=yes
ENABLED_SP_DH=yes
@@ -4279,6 +4286,7 @@ do
ENABLED_SP_EC_384=yes
fi
;;
no)
;;
@@ -4312,7 +4320,6 @@ do
ENABLED_SP_DH=yes
ENABLED_SP_FF_2048=yes
;;
smallrsa2048)
ENABLED_SP_SMALL=yes
ENABLED_SP_RSA=yes
@@ -4334,7 +4341,6 @@ do
ENABLED_SP_DH=yes
ENABLED_SP_FF_3072=yes
;;
smallrsa3072)
ENABLED_SP_SMALL=yes
ENABLED_SP_RSA=yes
@@ -4351,19 +4357,16 @@ do
ENABLED_SP_DH=yes
ENABLED_SP_FF_4096=yes
;;
4096 | +4096)
ENABLED_SP_RSA=yes
ENABLED_SP_DH=yes
ENABLED_SP_FF_4096=yes
;;
smallrsa4096)
ENABLED_SP_SMALL=yes
ENABLED_SP_RSA=yes
ENABLED_SP_FF_4096=yes
;;
rsa4096)
ENABLED_SP_RSA=yes
ENABLED_SP_FF_4096=yes
@@ -4373,6 +4376,13 @@ do
ENABLED_SP_NO_MALLOC=yes
;;
nonblock)
# Requires small and no malloc
ENABLED_SP_NONBLOCK=yes
ENABLED_SP_NO_MALLOC=yes
ENABLED_SP_SMALL=yes
;;
*)
AC_MSG_ERROR([Invalid choice of Single Precision length in bits [256, 2048, 3072]: $ENABLED_SP.])
break;;
@@ -4404,7 +4414,7 @@ if test "$ENABLED_SP_RSA" = "yes" || test "$ENABLED_SP_DH" = "yes"; then
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SP_4096"
fi
fi
if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SP_ECC" = "yes"; then
if test "$ENABLED_ECC" != "no" && test "$ENABLED_SP_ECC" = "yes"; then
ENABLED_SP=yes
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_SP_ECC"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_HAVE_SP_ECC"
@@ -4425,6 +4435,10 @@ if test "$ENABLED_SP_NO_MALLOC" = "yes"; then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_NO_MALLOC"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SP_NO_MALLOC"
fi
if test "$ENABLED_SP_NONBLOCK" = "yes"; then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SP_NONBLOCK"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SP_NONBLOCK"
fi
AC_ARG_ENABLE([sp-asm],
@@ -4908,7 +4922,7 @@ AS_CASE(["$CFLAGS $CPPFLAGS"],[*'WOLFSSL_TRUST_PEER_CERT'*],[ENABLED_TRUSTED_PEE
# dertermine if we have key validation mechanism
if test "x$ENABLED_ECC" = "xyes" || test "x$ENABLED_RSA" = "xyes"
if test "x$ENABLED_ECC" != "xno" || test "x$ENABLED_RSA" = "xyes"
then
if test "x$ENABLED_ASN" = "xyes"
then
@@ -5046,7 +5060,7 @@ then
ENABLED_AESKEYWRAP="yes"
AM_CFLAGS="$AM_CFLAGS -DHAVE_AES_KEYWRAP -DWOLFSSL_AES_DIRECT"
fi
if test "x$ENABLED_X963KDF" = "xno" && test "$ENABLED_ECC" = "yes"
if test "x$ENABLED_X963KDF" = "xno" && test "$ENABLED_ECC" != "no"
then
ENABLED_X963KDF="yes"
AM_CFLAGS="$AM_CFLAGS -DHAVE_X963_KDF"
@@ -5218,7 +5232,7 @@ AM_CONDITIONAL([BUILD_BLAKE2],[test "x$ENABLED_BLAKE2" = "xyes" || test "x$ENABL
AM_CONDITIONAL([BUILD_BLAKE2S],[test "x$ENABLED_BLAKE2S" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_SHA512],[test "x$ENABLED_SHA512" = "xyes" || test "x$ENABLED_SHA384" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_DSA],[test "x$ENABLED_DSA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_ECC],[test "x$ENABLED_ECC" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_ECC],[test "x$ENABLED_ECC" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_ED25519],[test "x$ENABLED_ED25519" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_ED25519_SMALL],[test "x$ENABLED_ED25519_SMALL" = "xyes"])
AM_CONDITIONAL([BUILD_FEMATH], [test "x$ENABLED_FEMATH" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
+118 -90
View File
@@ -48,7 +48,7 @@ Possible ECC enable options:
* WOLFSSL_CUSTOM_CURVES: Allow non-standard curves. default: off
* Includes the curve "a" variable in calculation
* ECC_DUMP_OID: Enables dump of OID encoding and sum default: off
* ECC_CACHE_CURVE: Enables cache of curve info to improve perofrmance
* ECC_CACHE_CURVE: Enables cache of curve info to improve performance
default: off
* FP_ECC: ECC Fixed Point Cache default: off
* USE_ECC_B_PARAM: Enable ECC curve B param default: off
@@ -56,6 +56,10 @@ Possible ECC enable options:
* WOLFSSL_ECC_CURVE_STATIC: default off (on for windows)
For the ECC curve paramaters `ecc_set_type` use fixed
array for hex string
* WC_ECC_NONBLOCK: Enable non-blocking support for sign/verify.
Requires SP with WOLFSSL_SP_NONBLOCK
* WC_ECC_NONBLOCK_ONLY Enable the non-blocking function only, no fall-back to
normal blocking API's
*/
/*
@@ -4891,60 +4895,54 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
}
#ifdef WOLFSSL_SP_MATH
#ifndef WOLFSSL_SP_NO_256
if (key->idx != ECC_CUSTOM_IDX && ecc_sets[key->idx].id == ECC_SECP256R1) {
#ifndef WOLFSSL_ECDSA_SET_K
return sp_ecc_sign_256(in, inlen, rng, &key->k, r, s, NULL, key->heap);
#else
return sp_ecc_sign_256(in, inlen, rng, &key->k, r, s, key->sign_k,
key->heap);
#endif
if (key->idx == ECC_CUSTOM_IDX ||
(ecc_sets[key->idx].id != ECC_SECP256R1 &&
ecc_sets[key->idx].id != ECC_SECP384R1)) {
return WC_KEY_SIZE_E;
}
#endif
#ifdef WOLFSSL_SP_384
if (key->idx != ECC_CUSTOM_IDX && ecc_sets[key->idx].id == ECC_SECP384R1) {
#ifndef WOLFSSL_ECDSA_SET_K
return sp_ecc_sign_384(in, inlen, rng, &key->k, r, s, NULL, key->heap);
#else
return sp_ecc_sign_384(in, inlen, rng, &key->k, r, s, key->sign_k,
key->heap);
#endif
}
#endif
return WC_KEY_SIZE_E;
#else
#ifdef WOLFSSL_HAVE_SP_ECC
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
#endif
{
#ifndef WOLFSSL_SP_NO_256
if (key->idx != ECC_CUSTOM_IDX &&
ecc_sets[key->idx].id == ECC_SECP256R1) {
#ifndef WOLFSSL_ECDSA_SET_K
return sp_ecc_sign_256(in, inlen, rng, &key->k, r, s, NULL,
key->heap);
#else
return sp_ecc_sign_256(in, inlen, rng, &key->k, r, s, key->sign_k,
key->heap);
#endif
}
#endif
#ifdef WOLFSSL_SP_384
if (key->idx != ECC_CUSTOM_IDX &&
ecc_sets[key->idx].id == ECC_SECP384R1) {
#ifndef WOLFSSL_ECDSA_SET_K
return sp_ecc_sign_384(in, inlen, rng, &key->k, r, s, NULL,
key->heap);
#else
return sp_ecc_sign_384(in, inlen, rng, &key->k, r, s, key->sign_k,
key->heap);
#endif
}
#endif
}
#endif /* WOLFSSL_HAVE_SP_ECC */
#if defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_HAVE_SP_ECC)
if (key->idx != ECC_CUSTOM_IDX
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
&& key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC
#endif
) {
#ifdef WOLFSSL_ECDSA_SET_K
mp_int* sign_k = key->sign_k;
#else
mp_int* sign_k = NULL;
#endif
#ifndef WOLFSSL_SP_NO_256
if (ecc_sets[key->idx].id == ECC_SECP256R1) {
#ifdef WC_ECC_NONBLOCK
if (key->nb_ctx) {
return sp_ecc_sign_256_nb(&key->nb_ctx->sp_ctx, in, inlen, rng, &key->k, r, s, sign_k, key->heap);
}
#endif
#ifndef WC_ECC_NONBLOCK_ONLY
return sp_ecc_sign_256(in, inlen, rng, &key->k, r, s, sign_k, key->heap);
#else
return NOT_COMPILED_IN;
#endif
}
#endif
#ifdef WOLFSSL_SP_384
if (ecc_sets[key->idx].id == ECC_SECP384R1) {
#ifdef WC_ECC_NONBLOCK
if (key->nb_ctx) {
return sp_ecc_sign_384_nb(&key->nb_ctx->sp_ctx, in, inlen, rng, &key->k, r, s, sign_k, key->heap);
}
#endif
#ifndef WC_ECC_NONBLOCK_ONLY
return sp_ecc_sign_384(in, inlen, rng, &key->k, r, s, sign_k, key->heap);
#else
return NOT_COMPILED_IN;
#endif
}
#endif
}
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
defined(WOLFSSL_ASYNC_CRYPT_TEST)
@@ -4962,6 +4960,9 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
}
#endif
#ifndef WOLFSSL_SP_MATH
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_CAVIUM_V)
err = wc_ecc_alloc_mpint(key, &key->e);
if (err != 0) {
@@ -5288,7 +5289,7 @@ int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key)
#endif /* WOLFSSL_ECDSA_SET_K */
#endif /* WOLFSSL_ATECC508A && WOLFSSL_CRYPTOCELL*/
#endif /* HAVE_ECC_SIGN */
#endif /* !HAVE_ECC_SIGN */
#ifdef WOLFSSL_CUSTOM_CURVES
void wc_ecc_free_curve(const ecc_set_type* curve, void* heap)
@@ -5992,44 +5993,57 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
key->pubkey.z, r, s, res, key->heap);
}
#endif
#if defined(WOLFSSL_SP_MATH) && !defined(FREESCALE_LTC_ECC)
#ifndef WOLFSSL_SP_NO_256
if (key->idx != ECC_CUSTOM_IDX && ecc_sets[key->idx].id == ECC_SECP256R1) {
return sp_ecc_verify_256(hash, hashlen, key->pubkey.x, key->pubkey.y,
key->pubkey.z, r, s, res, key->heap);
}
#endif
#ifdef WOLFSSL_SP_384
if (key->idx != ECC_CUSTOM_IDX && ecc_sets[key->idx].id == ECC_SECP384R1) {
return sp_ecc_verify_384(hash, hashlen, key->pubkey.x, key->pubkey.y,
key->pubkey.z, r, s, res, key->heap);
}
#endif
return WC_KEY_SIZE_E;
#else
#if defined WOLFSSL_HAVE_SP_ECC && !defined(FREESCALE_LTC_ECC)
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
#endif
{
#ifndef WOLFSSL_SP_NO_256
if (key->idx != ECC_CUSTOM_IDX &&
ecc_sets[key->idx].id == ECC_SECP256R1) {
return sp_ecc_verify_256(hash, hashlen, key->pubkey.x,
key->pubkey.y, key->pubkey.z,r, s, res,
key->heap);
}
#endif /* WOLFSSL_SP_NO_256 */
#ifdef WOLFSSL_SP_384
if (key->idx != ECC_CUSTOM_IDX &&
ecc_sets[key->idx].id == ECC_SECP384R1) {
return sp_ecc_verify_384(hash, hashlen, key->pubkey.x,
key->pubkey.y, key->pubkey.z,r, s, res,
key->heap);
}
#endif /* WOLFSSL_SP_384 */
if (key->idx == ECC_CUSTOM_IDX ||
(ecc_sets[key->idx].id != ECC_SECP256R1 &&
ecc_sets[key->idx].id != ECC_SECP384R1)) {
return WC_KEY_SIZE_E;
}
#endif /* WOLFSSL_HAVE_SP_ECC */
#endif
#if (defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_HAVE_SP_ECC)) && !defined(FREESCALE_LTC_ECC)
if (key->idx != ECC_CUSTOM_IDX
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
&& key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC
#endif
) {
#ifndef WOLFSSL_SP_NO_256
if (ecc_sets[key->idx].id == ECC_SECP256R1) {
#ifdef WC_ECC_NONBLOCK
if (key->nb_ctx) {
return sp_ecc_verify_256_nb(&key->nb_ctx->sp_ctx, hash, hashlen,
key->pubkey.x, key->pubkey.y, key->pubkey.z, r, s, res, key->heap);
}
#endif
#ifndef WC_ECC_NONBLOCK_ONLY
return sp_ecc_verify_256(hash, hashlen, key->pubkey.x,
key->pubkey.y, key->pubkey.z, r, s, res, key->heap);
#else
return NOT_COMPILED_IN;
#endif
}
#endif
#ifdef WOLFSSL_SP_384
if (ecc_sets[key->idx].id == ECC_SECP384R1) {
#ifdef WC_ECC_NONBLOCK
if (key->nb_ctx) {
return sp_ecc_verify_384_nb(&key->nb_ctx->sp_ctx, hash, hashlen,
key->pubkey.x, key->pubkey.y, key->pubkey.z, r, s, res, key->heap);
}
#endif
#ifndef WC_ECC_NONBLOCK_ONLY
return sp_ecc_verify_384(hash, hashlen, key->pubkey.x,
key->pubkey.y, key->pubkey.z, r, s, res, key->heap);
#else
return NOT_COMPILED_IN;
#endif
}
#endif
}
#endif
#if !defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC)
ALLOC_CURVE_SPECS(ECC_CURVE_FIELD_COUNT);
@@ -6287,7 +6301,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
wc_ecc_curve_free(curve);
FREE_CURVE_SPECS();
#endif /* WOLFSSL_SP_MATH */
#endif /* !WOLFSSL_SP_MATH || FREESCALE_LTC_ECC */
#endif /* WOLFSSL_ATECC508A */
(void)keySz;
@@ -10816,4 +10830,18 @@ int wc_X963_KDF(enum wc_HashType type, const byte* secret, word32 secretSz,
}
#endif /* HAVE_X963_KDF */
#ifdef WC_ECC_NONBLOCK
/* Enable ECC support for non-blocking operations */
int wc_ecc_set_nonblock(ecc_key *key, ecc_nb_ctx_t* ctx)
{
if (key) {
if (ctx) {
XMEMSET(ctx, 0, sizeof(ecc_nb_ctx_t));
}
key->nb_ctx = ctx;
}
return 0;
}
#endif /* WC_ECC_NONBLOCK */
#endif /* HAVE_ECC */
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
+9 -3
View File
@@ -38,8 +38,10 @@
* WOLFSSL_HAVE_SP_RSA: Enable SP RSA support
* WOLFSSL_HAVE_SP_DH: Enable SP DH support
* WOLFSSL_HAVE_SP_ECC: Enable SP ECC support
* WOLFSSL_SP_MATH: Use only single precision math and algorithms it supports (no fastmath tfm.c or normal integer.c)
* WOLFSSL_SP_SMALL: Use smaller version of code and avoid large stack variables
* WOLFSSL_SP_MATH: Use only single precision math and algorithms
* it supports (no fastmath tfm.c or normal integer.c)
* WOLFSSL_SP_SMALL: Use smaller version of code and avoid large
* stack variables
* WOLFSSL_SP_NO_MALLOC: Always use stack, no heap XMALLOC/XFREE allowed
* WOLFSSL_SP_NO_2048: Disable RSA/DH 2048-bit support
* WOLFSSL_SP_NO_3072: Disable RSA/DH 3072-bit support
@@ -52,8 +54,12 @@
* WOLFSSL_SP_ARM32_ASM Enable Aarch32 assembly speedups
* WOLFSSL_SP_ARM64_ASM Enable Aarch64 assembly speedups
* WOLFSSL_SP_ARM_CORTEX_M_ASM Enable Cortex-M assembly speedups
* WOLFSSL_SP_ARM_THUMB_ASM Enable ARM Thumb assembly speedups (used with -mthumb)
* WOLFSSL_SP_ARM_THUMB_ASM Enable ARM Thumb assembly speedups
* (used with -mthumb)
* SP_WORD_SIZE Force 32 or 64 bit mode
* WOLFSSL_SP_NONBLOCK Enables "non blocking" mode for SP math, which
* will return FP_WOULDBLOCK for long operations and function must be
* called again until complete.
*/
#ifdef WOLFSSL_SP_MATH
File diff suppressed because it is too large Load Diff
+25
View File
@@ -58,6 +58,11 @@
#include <wolfssl/wolfcrypt/port/arm/cryptoCell.h>
#endif
#ifdef WOLFSSL_HAVE_SP_ECC
#include <wolfssl/wolfcrypt/sp_int.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -353,6 +358,19 @@ enum {
#endif
};
/* ECC non-blocking */
#ifdef WC_ECC_NONBLOCK
typedef struct ecc_nb_ctx {
#if defined(WOLFSSL_HAVE_SP_ECC) && defined(WOLFSSL_SP_NONBLOCK)
sp_ecc_ctx_t sp_ctx;
#else
/* build configuration not supported */
#error ECC non-blocking only supports SP (--enable-sp=nonblock)
#endif
} ecc_nb_ctx_t;
#endif /* WC_ECC_NONBLOCK */
/* An ECC Key */
struct ecc_key {
int type; /* Public or Private */
@@ -413,6 +431,9 @@ struct ecc_key {
#ifdef WOLFSSL_DSP
remote_handle64 handle;
#endif
#ifdef WC_ECC_NONBLOCK
ecc_nb_ctx_t* nb_ctx;
#endif
};
@@ -757,6 +778,10 @@ int sp_dsp_ecc_verify_256(remote_handle64 handle, const byte* hash, word32 hashL
mp_int* pY, mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
#endif
#ifdef WC_ECC_NONBLOCK
WOLFSSL_API int wc_ecc_set_nonblock(ecc_key *key, ecc_nb_ctx_t* ctx);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
+12 -1
View File
@@ -141,7 +141,18 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ);
int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym);
#endif /*ifdef WOLFSSL_HAVE_SP_ECC */
#ifdef WOLFSSL_SP_NONBLOCK
int sp_ecc_sign_256_nb(sp_ecc_ctx_t* ctx, const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
mp_int* rm, mp_int* sm, mp_int* km, void* heap);
int sp_ecc_verify_256_nb(sp_ecc_ctx_t* ctx, const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY,
mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
int sp_ecc_sign_384_nb(sp_ecc_ctx_t* ctx, const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
mp_int* rm, mp_int* sm, mp_int* km, void* heap);
int sp_ecc_verify_384_nb(sp_ecc_ctx_t* ctx, const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY,
mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
#endif /* WOLFSSL_SP_NONBLOCK */
#endif /* WOLFSSL_HAVE_SP_ECC */
#ifdef __cplusplus
+13 -1
View File
@@ -109,6 +109,17 @@
#define SP_MASK (sp_digit)(-1)
#if defined(WOLFSSL_HAVE_SP_ECC) && defined(WOLFSSL_SP_NONBLOCK)
typedef struct sp_ecc_ctx {
#ifdef WOLFSSL_SP_384
byte data[48*80]; /* stack data */
#else
byte data[32*80]; /* stack data */
#endif
} sp_ecc_ctx_t;
#endif
#ifdef WOLFSSL_SP_MATH
#include <wolfssl/wolfcrypt/random.h>
@@ -216,7 +227,6 @@ MP_API void sp_rshb(sp_int* a, int n, sp_int* r);
MP_API int sp_mul_d(sp_int* a, sp_int_digit n, sp_int* r);
#define MP_OKAY 0
#define MP_NO 0
#define MP_YES 1
@@ -226,8 +236,10 @@ MP_API int sp_mul_d(sp_int* a, sp_int_digit n, sp_int* r);
#define MP_EQ 0
#define MP_LT -1
#define MP_OKAY 0
#define MP_MEM -2
#define MP_VAL -3
#define FP_WOULDBLOCK -4
#define DIGIT_BIT SP_WORD_SIZE
#define MP_MASK SP_MASK