mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #3160 from dgarske/ecc_nb_noctx
Fix for ECC non-blocking only to allow calling without context setpull/3164/head
commit
7883156f49
|
@ -4913,6 +4913,11 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||
#else
|
||||
mp_int* sign_k = NULL;
|
||||
#endif
|
||||
#if defined(WC_ECC_NONBLOCK) && defined(WC_ECC_NONBLOCK_ONLY)
|
||||
/* perform blocking call to non-blocking function */
|
||||
ecc_nb_ctx_t nb_ctx;
|
||||
XMEMSET(&nb_ctx, 0, sizeof(nb_ctx));
|
||||
#endif
|
||||
#ifndef WOLFSSL_SP_NO_256
|
||||
if (ecc_sets[key->idx].id == ECC_SECP256R1) {
|
||||
#ifdef WC_ECC_NONBLOCK
|
||||
|
@ -4920,12 +4925,17 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||
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
|
||||
#ifdef WC_ECC_NONBLOCK_ONLY
|
||||
do { /* perform blocking call to non-blocking function */
|
||||
err = sp_ecc_sign_256_nb(&nb_ctx.sp_ctx, in, inlen, rng,
|
||||
&key->k, r, s, sign_k, key->heap);
|
||||
} while (err == FP_WOULDBLOCK);
|
||||
return err;
|
||||
#endif
|
||||
#endif /* WC_ECC_NONBLOCK */
|
||||
#if !defined(WC_ECC_NONBLOCK) || (defined(WC_ECC_NONBLOCK) && !defined(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
|
||||
|
@ -4936,12 +4946,17 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||
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
|
||||
#ifdef WC_ECC_NONBLOCK_ONLY
|
||||
do { /* perform blocking call to non-blocking function */
|
||||
err = sp_ecc_sign_384_nb(&nb_ctx.sp_ctx, in, inlen, rng,
|
||||
&key->k, r, s, sign_k, key->heap);
|
||||
} while (err == FP_WOULDBLOCK);
|
||||
return err;
|
||||
#endif
|
||||
#endif /* WC_ECC_NONBLOCK */
|
||||
#if !defined(WC_ECC_NONBLOCK) || (defined(WC_ECC_NONBLOCK) && !defined(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
|
||||
|
@ -6013,6 +6028,11 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||
&& key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC
|
||||
#endif
|
||||
) {
|
||||
#if defined(WC_ECC_NONBLOCK) && defined(WC_ECC_NONBLOCK_ONLY)
|
||||
/* perform blocking call to non-blocking function */
|
||||
ecc_nb_ctx_t nb_ctx;
|
||||
XMEMSET(&nb_ctx, 0, sizeof(nb_ctx));
|
||||
#endif
|
||||
#ifndef WOLFSSL_SP_NO_256
|
||||
if (ecc_sets[key->idx].id == ECC_SECP256R1) {
|
||||
#ifdef WC_ECC_NONBLOCK
|
||||
|
@ -6021,12 +6041,18 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||
key->pubkey.x, key->pubkey.y, key->pubkey.z, r, s, res,
|
||||
key->heap);
|
||||
}
|
||||
#endif
|
||||
#ifndef WC_ECC_NONBLOCK_ONLY
|
||||
#ifdef WC_ECC_NONBLOCK_ONLY
|
||||
do { /* perform blocking call to non-blocking function */
|
||||
err = sp_ecc_verify_256_nb(&nb_ctx->sp_ctx, hash, hashlen,
|
||||
key->pubkey.x, key->pubkey.y, key->pubkey.z, r, s, res,
|
||||
key->heap);
|
||||
} while (err == FP_WOULDBLOCK);
|
||||
return err;
|
||||
#endif
|
||||
#endif /* WC_ECC_NONBLOCK */
|
||||
#if !defined(WC_ECC_NONBLOCK) || (defined(WC_ECC_NONBLOCK) && !defined(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
|
||||
|
@ -6038,12 +6064,18 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||
key->pubkey.x, key->pubkey.y, key->pubkey.z, r, s, res,
|
||||
key->heap);
|
||||
}
|
||||
#endif
|
||||
#ifndef WC_ECC_NONBLOCK_ONLY
|
||||
#ifdef WC_ECC_NONBLOCK_ONLY
|
||||
do { /* perform blocking call to non-blocking function */
|
||||
err = sp_ecc_verify_384_nb(&nb_ctx.sp_ctx, hash, hashlen,
|
||||
key->pubkey.x, key->pubkey.y, key->pubkey.z, r, s, res,
|
||||
key->heap);
|
||||
} while (err == FP_WOULDBLOCK);
|
||||
return err;
|
||||
#endif
|
||||
#endif /* WC_ECC_NONBLOCK */
|
||||
#if !defined(WC_ECC_NONBLOCK) || (defined(WC_ECC_NONBLOCK) && !defined(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
|
||||
|
|
Loading…
Reference in New Issue