forked from wolfSSL/wolfssl
Fix to use QAT for ECC sign and verify when SP is enabled and key was initialized with devId. Fixes issues with wolfCrypt test and QAT not properly calling "again" for the ECC sign, verify and shared secret.
This commit is contained in:
@@ -3322,7 +3322,7 @@ int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len)
|
||||
}
|
||||
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
static WC_INLINE int wc_ecc_alloc_mpint(ecc_key* key, mp_int** mp)
|
||||
{
|
||||
if (key == NULL || mp == NULL)
|
||||
@@ -3362,7 +3362,7 @@ static void wc_ecc_free_async(ecc_key* key)
|
||||
wc_ecc_free_mpint(key, &key->signK);
|
||||
#endif /* HAVE_CAVIUM_V */
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||
|
||||
|
||||
#ifdef HAVE_ECC_DHE
|
||||
@@ -3576,7 +3576,7 @@ static int wc_ecc_shared_secret_gen_async(ecc_key* private_key,
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||
|
||||
int wc_ecc_shared_secret_gen(ecc_key* private_key, ecc_point* point,
|
||||
byte* out, word32 *outlen)
|
||||
@@ -3685,7 +3685,7 @@ int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
wc_ecc_free_async(private_key);
|
||||
#endif
|
||||
private_key->state = ECC_STATE_NONE;
|
||||
@@ -4308,7 +4308,8 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
{
|
||||
int err;
|
||||
mp_int *r = NULL, *s = NULL;
|
||||
#if !defined(WOLFSSL_ASYNC_CRYPT) && !defined(WOLFSSL_SMALL_STACK)
|
||||
#if (!defined(WOLFSSL_ASYNC_CRYPT) || !defined(WC_ASYNC_ENABLE_ECC)) && \
|
||||
!defined(WOLFSSL_SMALL_STACK)
|
||||
mp_int r_lcl, s_lcl;
|
||||
#endif
|
||||
|
||||
@@ -4325,7 +4326,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
err = wc_ecc_alloc_async(key);
|
||||
if (err != 0)
|
||||
return err;
|
||||
@@ -4343,7 +4344,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
XFREE(r, key->heap, DYNAMIC_TYPE_ECC);
|
||||
return MEMORY_E;
|
||||
}
|
||||
#endif
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||
|
||||
switch(key->state) {
|
||||
case ECC_STATE_NONE:
|
||||
@@ -4415,7 +4416,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
wc_ecc_free_async(key);
|
||||
#endif
|
||||
key->state = ECC_STATE_NONE;
|
||||
@@ -4467,8 +4468,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
||||
return WC_KEY_SIZE_E;
|
||||
#else
|
||||
#ifdef WOLFSSL_HAVE_SP_ECC
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
|
||||
defined(WOLFSSL_ASYNC_CRYPT_TEST)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
|
||||
#endif
|
||||
{
|
||||
@@ -4624,7 +4624,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
||||
}
|
||||
#endif /* HAVE_CAVIUM_V || HAVE_INTEL_QA */
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
pubkey = (ecc_key*)XMALLOC(sizeof(ecc_key), key->heap, DYNAMIC_TYPE_ECC);
|
||||
@@ -4795,7 +4795,7 @@ int wc_ecc_free(ecc_key* key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
#ifdef WC_ASYNC_ENABLE_ECC
|
||||
wolfAsync_DevCtxFree(&key->asyncDev, WOLFSSL_ASYNC_MARKER_ECC);
|
||||
#endif
|
||||
@@ -5155,8 +5155,9 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
{
|
||||
int err;
|
||||
mp_int *r = NULL, *s = NULL;
|
||||
#if !defined(WOLFSSL_ASYNC_CRYPT) && !defined(WOLFSSL_SMALL_STACK)
|
||||
mp_int r_lcl[1], s_lcl[1];
|
||||
#if (!defined(WOLFSSL_ASYNC_CRYPT) || !defined(WC_ASYNC_ENABLE_ECC)) && \
|
||||
!defined(WOLFSSL_SMALL_STACK)
|
||||
mp_int r_lcl, s_lcl;
|
||||
#endif
|
||||
|
||||
if (sig == NULL || hash == NULL || res == NULL || key == NULL) {
|
||||
@@ -5171,7 +5172,7 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
err = wc_ecc_alloc_async(key);
|
||||
if (err != 0)
|
||||
return err;
|
||||
@@ -5179,8 +5180,8 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
s = key->s;
|
||||
#else
|
||||
#ifndef WOLFSSL_SMALL_STACK
|
||||
r = r_lcl;
|
||||
s = s_lcl;
|
||||
r = &r_lcl;
|
||||
s = &s_lcl;
|
||||
#else
|
||||
r = (mp_int*)XMALLOC(sizeof(mp_int), key->heap, DYNAMIC_TYPE_ECC);
|
||||
if (r == NULL)
|
||||
@@ -5252,7 +5253,7 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
wc_ecc_free_async(key);
|
||||
#elif defined(WOLFSSL_SMALL_STACK)
|
||||
XFREE(s, key->heap, DYNAMIC_TYPE_ECC);
|
||||
@@ -5376,8 +5377,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
#else
|
||||
#ifdef WOLFSSL_HAVE_SP_ECC
|
||||
#ifndef WOLFSSL_SP_NO_256
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
|
||||
defined(WOLFSSL_ASYNC_CRYPT_TEST)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
|
||||
#endif
|
||||
{
|
||||
@@ -5406,7 +5406,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
}
|
||||
#endif
|
||||
e = e_lcl;
|
||||
#endif
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT && HAVE_CAVIUM_V */
|
||||
|
||||
err = mp_init(e);
|
||||
if (err != MP_OKAY)
|
||||
@@ -5474,7 +5474,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
}
|
||||
#endif /* HAVE_CAVIUM_V || HAVE_INTEL_QA */
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
if (err == MP_OKAY) {
|
||||
@@ -8856,7 +8856,7 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
#endif
|
||||
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
ret = wc_AsyncWait(ret, &privKey->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
if (ret != 0)
|
||||
break;
|
||||
@@ -8892,7 +8892,7 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
AES_ENCRYPTION);
|
||||
if (ret == 0) {
|
||||
ret = wc_AesCbcEncrypt(&aes, out, msg, msgSz);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
||||
ret = wc_AsyncWait(ret, &aes.asyncDev,
|
||||
WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
@@ -9025,7 +9025,7 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
#endif
|
||||
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||
ret = wc_AsyncWait(ret, &privKey->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
if (ret != 0)
|
||||
break;
|
||||
@@ -9093,7 +9093,7 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
if (ret != 0)
|
||||
break;
|
||||
ret = wc_AesCbcDecrypt(&aes, out, msg, msgSz-digestSz);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
||||
ret = wc_AsyncWait(ret, &aes.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
}
|
||||
|
@@ -15192,12 +15192,10 @@ static int ecc_test_vector_item(const eccVector* vector)
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0) {
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_verify_hash(sig, sigSz, (byte*)vector->msg,
|
||||
vector->msgLen, &verify, &userA);
|
||||
}
|
||||
} while (ret == WC_PENDING_E);
|
||||
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
|
||||
@@ -15495,7 +15493,13 @@ static int ecc_test_cdh_vectors(void)
|
||||
|
||||
/* compute ECC Cofactor shared secret */
|
||||
x = sizeof(sharedA);
|
||||
ret = wc_ecc_shared_secret(&priv_key, &pub_key, sharedA, &x);
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &priv_key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&priv_key, &pub_key, sharedA, &x);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0) {
|
||||
goto done;
|
||||
}
|
||||
@@ -15631,14 +15635,28 @@ static int ecc_test_make_pub(WC_RNG* rng)
|
||||
|
||||
#ifdef HAVE_ECC_SIGN
|
||||
tmpSz = FOURK_BUF;
|
||||
ret = wc_ecc_sign_hash(msg, sizeof(msg), tmp, &tmpSz, rng, &key);
|
||||
ret = 0;
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_sign_hash(msg, sizeof(msg), tmp, &tmpSz, rng, &key);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0) {
|
||||
ERROR_OUT(-8324, done);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC_VERIFY
|
||||
/* try verify with private only key */
|
||||
ret = wc_ecc_verify_hash(tmp, tmpSz, msg, sizeof(msg), &verify, &key);
|
||||
ret = 0;
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_verify_hash(tmp, tmpSz, msg, sizeof(msg), &verify, &key);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0) {
|
||||
ERROR_OUT(-8325, done);
|
||||
}
|
||||
@@ -15685,17 +15703,21 @@ static int ecc_test_make_pub(WC_RNG* rng)
|
||||
wc_ecc_init_ex(&pub, HEAP_HINT, devId);
|
||||
ret = wc_ecc_make_key(rng, 32, &pub);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &pub.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
ret = wc_AsyncWait(ret, &pub.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
ERROR_OUT(-8331, done);
|
||||
}
|
||||
|
||||
x = FOURK_BUF;
|
||||
ret = wc_ecc_shared_secret(&key, &pub, exportBuf, &x);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &pub.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0) {
|
||||
ret = wc_ecc_shared_secret(&key, &pub, exportBuf, &x);
|
||||
}
|
||||
} while (ret == WC_PENDING_E);
|
||||
wc_ecc_free(&pub);
|
||||
if (ret != 0) {
|
||||
ERROR_OUT(-8332, done);
|
||||
@@ -15743,7 +15765,7 @@ static int ecc_test_key_gen(WC_RNG* rng, int keySize)
|
||||
|
||||
ret = wc_ecc_make_key(rng, keySize, &userA);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
@@ -15856,7 +15878,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
|
||||
ret = wc_ecc_make_key_ex(rng, keySize, &userA, curve_id);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
@@ -15875,7 +15897,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
|
||||
ret = wc_ecc_make_key_ex(rng, keySize, &userB, curve_id);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
@@ -15893,7 +15915,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&userA, &userB, sharedA, &x);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0) {
|
||||
@@ -15905,7 +15927,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&userB, &userA, sharedB, &y);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0)
|
||||
@@ -15924,13 +15946,25 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
wc_ecc_set_flags(&userB, WC_ECC_FLAG_COFACTOR);
|
||||
|
||||
x = sizeof(sharedA);
|
||||
ret = wc_ecc_shared_secret(&userA, &userB, sharedA, &x);
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&userA, &userB, sharedA, &x);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
y = sizeof(sharedB);
|
||||
ret = wc_ecc_shared_secret(&userB, &userA, sharedB, &y);
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&userB, &userA, sharedB, &y);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
|
||||
@@ -15968,7 +16002,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0)
|
||||
@@ -16005,7 +16039,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0)
|
||||
@@ -16033,7 +16067,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
|
||||
&userA);
|
||||
} while (ret == WC_PENDING_E);
|
||||
@@ -16047,7 +16081,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
|
||||
&verify, &userA);
|
||||
} while (ret == WC_PENDING_E);
|
||||
@@ -16069,7 +16103,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
|
||||
&userA);
|
||||
} while (ret == WC_PENDING_E);
|
||||
@@ -16083,7 +16117,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
|
||||
&verify, &userA);
|
||||
} while (ret == WC_PENDING_E);
|
||||
@@ -16603,10 +16637,14 @@ static int ecc_ssh_test(ecc_key* key)
|
||||
return -8447;
|
||||
|
||||
/* Use API. */
|
||||
ret = wc_ecc_shared_secret_ssh(key, &key->pubkey, out, &outLen);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
ret = 0;
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_shared_secret_ssh(key, &key->pubkey, out, &outLen);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret != 0)
|
||||
return -8448;
|
||||
return 0;
|
||||
@@ -16634,7 +16672,7 @@ static int ecc_def_curve_test(WC_RNG *rng)
|
||||
|
||||
ret = wc_ecc_make_key(rng, 32, &key);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
ret = -8451;
|
||||
@@ -17000,7 +17038,7 @@ static int ecc_test_cert_gen(WC_RNG* rng)
|
||||
|
||||
ret = wc_ecc_make_key(rng, 32, &certPubKey);
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &certPubKey.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
ret = wc_AsyncWait(ret, &certPubKey.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
ERROR_OUT(-8524, exit);
|
||||
@@ -17477,13 +17515,26 @@ int ecc_test_buffers(void) {
|
||||
|
||||
|
||||
x = sizeof(out);
|
||||
ret = wc_ecc_sign_hash(in, inLen, out, &x, &rng, &cliKey);
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &cliKey.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_sign_hash(in, inLen, out, &x, &rng, &cliKey);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret < 0)
|
||||
return -8717;
|
||||
|
||||
XMEMSET(plain, 0, sizeof(plain));
|
||||
|
||||
ret = wc_ecc_verify_hash(out, x, plain, sizeof(plain), &verify, &cliKey);
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &cliKey.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
#endif
|
||||
if (ret == 0)
|
||||
ret = wc_ecc_verify_hash(out, x, plain, sizeof(plain), &verify,
|
||||
&cliKey);
|
||||
} while (ret == WC_PENDING_E);
|
||||
if (ret < 0)
|
||||
return -8718;
|
||||
|
||||
|
Reference in New Issue
Block a user