forked from wolfSSL/wolfssl
Merge pull request #2114 from dgarske/qat_bench
Fixes and improvements for async / QuickAssist
This commit is contained in:
@@ -934,8 +934,9 @@ static THREAD_LS_T byte* bench_iv = NULL;
|
|||||||
/* print final stat */
|
/* print final stat */
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
if (bstat->type == BENCH_STAT_SYM) {
|
if (bstat->type == BENCH_STAT_SYM) {
|
||||||
printf("%-12s%s %8.3f MB/s\n", bstat->desc,
|
printf("%-16s%s %8.3f %s/s\n", bstat->desc,
|
||||||
BENCH_ASYNC_GET_NAME(bstat->doAsync), bstat->perfsec);
|
BENCH_ASYNC_GET_NAME(bstat->doAsync), bstat->perfsec,
|
||||||
|
base2 ? "MB" : "mB");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("%-5s %4d %-9s %s %.3f ops/sec\n",
|
printf("%-5s %4d %-9s %s %.3f ops/sec\n",
|
||||||
@@ -1203,7 +1204,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_aescbc(0);
|
bench_aescbc(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_aescbc(1);
|
bench_aescbc(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1213,7 +1215,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_aesgcm(0);
|
bench_aesgcm(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_aesgcm(1);
|
bench_aesgcm(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1223,7 +1226,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_aesecb(0);
|
bench_aesecb(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_aesecb(1);
|
bench_aesecb(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1255,7 +1259,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_arc4(0);
|
bench_arc4(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ARC4)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ARC4) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_arc4(1);
|
bench_arc4(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1281,7 +1286,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_des(0);
|
bench_des(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_3DES)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_3DES) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_des(1);
|
bench_des(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1296,7 +1302,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_md5(0);
|
bench_md5(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_MD5)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_MD5) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_md5(1);
|
bench_md5(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1310,7 +1317,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha(0);
|
bench_sha(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha(1);
|
bench_sha(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1320,7 +1328,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha224(0);
|
bench_sha224(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA224)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA224) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha224(1);
|
bench_sha224(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1330,7 +1339,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha256(0);
|
bench_sha256(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA256)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA256) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha256(1);
|
bench_sha256(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1340,7 +1350,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha384(0);
|
bench_sha384(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA384)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA384) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha384(1);
|
bench_sha384(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1350,7 +1361,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha512(0);
|
bench_sha512(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha512(1);
|
bench_sha512(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1361,7 +1373,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha3_224(0);
|
bench_sha3_224(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha3_224(1);
|
bench_sha3_224(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1371,7 +1384,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha3_256(0);
|
bench_sha3_256(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha3_256(1);
|
bench_sha3_256(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1381,7 +1395,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha3_384(0);
|
bench_sha3_384(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha3_384(1);
|
bench_sha3_384(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1391,7 +1406,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_sha3_512(0);
|
bench_sha3_512(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_sha3_512(1);
|
bench_sha3_512(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1416,7 +1432,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_hmac_md5(0);
|
bench_hmac_md5(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) && \
|
||||||
|
defined(WC_ASYNC_ENABLE_MD5) && !defined(NO_HW_BENCH)
|
||||||
bench_hmac_md5(1);
|
bench_hmac_md5(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1426,7 +1443,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_hmac_sha(0);
|
bench_hmac_sha(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) && \
|
||||||
|
defined(WC_ASYNC_ENABLE_SHA) && !defined(NO_HW_BENCH)
|
||||||
bench_hmac_sha(1);
|
bench_hmac_sha(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1436,7 +1454,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_hmac_sha224(0);
|
bench_hmac_sha224(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA224)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) && \
|
||||||
|
defined(WC_ASYNC_ENABLE_SHA224) && !defined(NO_HW_BENCH)
|
||||||
bench_hmac_sha224(1);
|
bench_hmac_sha224(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1446,7 +1465,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_hmac_sha256(0);
|
bench_hmac_sha256(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA256)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) && \
|
||||||
|
defined(WC_ASYNC_ENABLE_SHA256) && !defined(NO_HW_BENCH)
|
||||||
bench_hmac_sha256(1);
|
bench_hmac_sha256(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1456,7 +1476,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_hmac_sha384(0);
|
bench_hmac_sha384(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA384)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) && \
|
||||||
|
defined(WC_ASYNC_ENABLE_SHA384) && !defined(NO_HW_BENCH)
|
||||||
bench_hmac_sha384(1);
|
bench_hmac_sha384(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1466,7 +1487,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_hmac_sha512(0);
|
bench_hmac_sha512(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC) && \
|
||||||
|
defined(WC_ASYNC_ENABLE_SHA512) && !defined(NO_HW_BENCH)
|
||||||
bench_hmac_sha512(1);
|
bench_hmac_sha512(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1489,7 +1511,8 @@ static void* benchmarks_do(void* args)
|
|||||||
bench_rsaKeyGen(0);
|
bench_rsaKeyGen(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA_KEYGEN)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA_KEYGEN) \
|
||||||
|
&& !defined(NO_HW_BENCH)
|
||||||
if (bench_asym_algs & BENCH_RSA_SZ) {
|
if (bench_asym_algs & BENCH_RSA_SZ) {
|
||||||
bench_rsaKeyGen_size(1, bench_size);
|
bench_rsaKeyGen_size(1, bench_size);
|
||||||
}
|
}
|
||||||
@@ -1503,7 +1526,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_rsa(0);
|
bench_rsa(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_rsa(1);
|
bench_rsa(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1513,7 +1537,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_rsa_key(0, bench_size);
|
bench_rsa_key(0, bench_size);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_rsa_key(1, bench_size);
|
bench_rsa_key(1, bench_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1525,7 +1550,8 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_dh(0);
|
bench_dh(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_DH)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_DH) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_dh(1);
|
bench_dh(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1543,18 +1569,17 @@ static void* benchmarks_do(void* args)
|
|||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_eccMakeKey(0);
|
bench_eccMakeKey(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
|
||||||
/* async supported in simulator only */
|
!defined(NO_HW_BENCH)
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT_TEST
|
bench_eccMakeKey(1);
|
||||||
bench_eccMakeKey(1);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (bench_all || (bench_asym_algs & BENCH_ECC)) {
|
if (bench_all || (bench_asym_algs & BENCH_ECC)) {
|
||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
bench_ecc(0);
|
bench_ecc(0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
|
||||||
|
!defined(NO_HW_BENCH)
|
||||||
bench_ecc(1);
|
bench_ecc(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1701,8 +1726,13 @@ int benchmark_test(void *args)
|
|||||||
|
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WC_NO_ASYNC_THREADING)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WC_NO_ASYNC_THREADING)
|
||||||
{
|
{
|
||||||
int i;
|
int i, numCpus;
|
||||||
int numCpus = wc_AsyncGetNumberOfCpus();
|
|
||||||
|
#ifdef WC_ASYNC_BENCH_THREAD_COUNT
|
||||||
|
numCpus = WC_ASYNC_BENCH_THREAD_COUNT;
|
||||||
|
#else
|
||||||
|
numCpus = wc_AsyncGetNumberOfCpus();
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("CPUs: %d\n", numCpus);
|
printf("CPUs: %d\n", numCpus);
|
||||||
|
|
||||||
|
@@ -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)
|
static WC_INLINE int wc_ecc_alloc_mpint(ecc_key* key, mp_int** mp)
|
||||||
{
|
{
|
||||||
if (key == NULL || mp == NULL)
|
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);
|
wc_ecc_free_mpint(key, &key->signK);
|
||||||
#endif /* HAVE_CAVIUM_V */
|
#endif /* HAVE_CAVIUM_V */
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_ECC_DHE
|
#ifdef HAVE_ECC_DHE
|
||||||
@@ -3576,7 +3576,7 @@ static int wc_ecc_shared_secret_gen_async(ecc_key* private_key,
|
|||||||
|
|
||||||
return err;
|
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,
|
int wc_ecc_shared_secret_gen(ecc_key* private_key, ecc_point* point,
|
||||||
byte* out, word32 *outlen)
|
byte* out, word32 *outlen)
|
||||||
@@ -3685,7 +3685,7 @@ int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
wc_ecc_free_async(private_key);
|
wc_ecc_free_async(private_key);
|
||||||
#endif
|
#endif
|
||||||
private_key->state = ECC_STATE_NONE;
|
private_key->state = ECC_STATE_NONE;
|
||||||
@@ -4322,7 +4322,8 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
mp_int *r = NULL, *s = NULL;
|
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;
|
mp_int r_lcl, s_lcl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -4339,7 +4340,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
err = wc_ecc_alloc_async(key);
|
err = wc_ecc_alloc_async(key);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
return err;
|
return err;
|
||||||
@@ -4357,7 +4358,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
|||||||
XFREE(r, key->heap, DYNAMIC_TYPE_ECC);
|
XFREE(r, key->heap, DYNAMIC_TYPE_ECC);
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||||
|
|
||||||
switch(key->state) {
|
switch(key->state) {
|
||||||
case ECC_STATE_NONE:
|
case ECC_STATE_NONE:
|
||||||
@@ -4429,7 +4430,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
wc_ecc_free_async(key);
|
wc_ecc_free_async(key);
|
||||||
#endif
|
#endif
|
||||||
key->state = ECC_STATE_NONE;
|
key->state = ECC_STATE_NONE;
|
||||||
@@ -4481,8 +4482,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||||||
return WC_KEY_SIZE_E;
|
return WC_KEY_SIZE_E;
|
||||||
#else
|
#else
|
||||||
#ifdef WOLFSSL_HAVE_SP_ECC
|
#ifdef WOLFSSL_HAVE_SP_ECC
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
defined(WOLFSSL_ASYNC_CRYPT_TEST)
|
|
||||||
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
|
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -4638,7 +4638,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_CAVIUM_V || HAVE_INTEL_QA */
|
#endif /* HAVE_CAVIUM_V || HAVE_INTEL_QA */
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
pubkey = (ecc_key*)XMALLOC(sizeof(ecc_key), key->heap, DYNAMIC_TYPE_ECC);
|
pubkey = (ecc_key*)XMALLOC(sizeof(ecc_key), key->heap, DYNAMIC_TYPE_ECC);
|
||||||
@@ -4809,7 +4809,7 @@ int wc_ecc_free(ecc_key* key)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
#ifdef WC_ASYNC_ENABLE_ECC
|
#ifdef WC_ASYNC_ENABLE_ECC
|
||||||
wolfAsync_DevCtxFree(&key->asyncDev, WOLFSSL_ASYNC_MARKER_ECC);
|
wolfAsync_DevCtxFree(&key->asyncDev, WOLFSSL_ASYNC_MARKER_ECC);
|
||||||
#endif
|
#endif
|
||||||
@@ -5169,8 +5169,9 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
mp_int *r = NULL, *s = NULL;
|
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)) && \
|
||||||
mp_int r_lcl[1], s_lcl[1];
|
!defined(WOLFSSL_SMALL_STACK)
|
||||||
|
mp_int r_lcl, s_lcl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sig == NULL || hash == NULL || res == NULL || key == NULL) {
|
if (sig == NULL || hash == NULL || res == NULL || key == NULL) {
|
||||||
@@ -5185,7 +5186,7 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
err = wc_ecc_alloc_async(key);
|
err = wc_ecc_alloc_async(key);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
return err;
|
return err;
|
||||||
@@ -5193,8 +5194,8 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
|||||||
s = key->s;
|
s = key->s;
|
||||||
#else
|
#else
|
||||||
#ifndef WOLFSSL_SMALL_STACK
|
#ifndef WOLFSSL_SMALL_STACK
|
||||||
r = r_lcl;
|
r = &r_lcl;
|
||||||
s = s_lcl;
|
s = &s_lcl;
|
||||||
#else
|
#else
|
||||||
r = (mp_int*)XMALLOC(sizeof(mp_int), key->heap, DYNAMIC_TYPE_ECC);
|
r = (mp_int*)XMALLOC(sizeof(mp_int), key->heap, DYNAMIC_TYPE_ECC);
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
@@ -5266,7 +5267,7 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
wc_ecc_free_async(key);
|
wc_ecc_free_async(key);
|
||||||
#elif defined(WOLFSSL_SMALL_STACK)
|
#elif defined(WOLFSSL_SMALL_STACK)
|
||||||
XFREE(s, key->heap, DYNAMIC_TYPE_ECC);
|
XFREE(s, key->heap, DYNAMIC_TYPE_ECC);
|
||||||
@@ -5390,8 +5391,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
#else
|
#else
|
||||||
#ifdef WOLFSSL_HAVE_SP_ECC
|
#ifdef WOLFSSL_HAVE_SP_ECC
|
||||||
#ifndef WOLFSSL_SP_NO_256
|
#ifndef WOLFSSL_SP_NO_256
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
defined(WOLFSSL_ASYNC_CRYPT_TEST)
|
|
||||||
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
|
if (key->asyncDev.marker != WOLFSSL_ASYNC_MARKER_ECC)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -5420,7 +5420,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
e = e_lcl;
|
e = e_lcl;
|
||||||
#endif
|
#endif /* WOLFSSL_ASYNC_CRYPT && HAVE_CAVIUM_V */
|
||||||
|
|
||||||
err = mp_init(e);
|
err = mp_init(e);
|
||||||
if (err != MP_OKAY)
|
if (err != MP_OKAY)
|
||||||
@@ -5488,7 +5488,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_CAVIUM_V || HAVE_INTEL_QA */
|
#endif /* HAVE_CAVIUM_V || HAVE_INTEL_QA */
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_ECC */
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
if (err == MP_OKAY) {
|
if (err == MP_OKAY) {
|
||||||
@@ -8870,7 +8870,7 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
do {
|
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);
|
ret = wc_AsyncWait(ret, &privKey->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
@@ -8906,7 +8906,7 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
|||||||
AES_ENCRYPTION);
|
AES_ENCRYPTION);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_AesCbcEncrypt(&aes, out, msg, msgSz);
|
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,
|
ret = wc_AsyncWait(ret, &aes.asyncDev,
|
||||||
WC_ASYNC_FLAG_NONE);
|
WC_ASYNC_FLAG_NONE);
|
||||||
#endif
|
#endif
|
||||||
@@ -9039,7 +9039,7 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
do {
|
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);
|
ret = wc_AsyncWait(ret, &privKey->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
@@ -9107,7 +9107,7 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
ret = wc_AesCbcDecrypt(&aes, out, msg, msgSz-digestSz);
|
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);
|
ret = wc_AsyncWait(ret, &aes.asyncDev, WC_ASYNC_FLAG_NONE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -15278,12 +15278,10 @@ static int ecc_test_vector_item(const eccVector* vector)
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0) {
|
if (ret == 0)
|
||||||
ret = wc_ecc_verify_hash(sig, sigSz, (byte*)vector->msg,
|
ret = wc_ecc_verify_hash(sig, sigSz, (byte*)vector->msg,
|
||||||
vector->msgLen, &verify, &userA);
|
vector->msgLen, &verify, &userA);
|
||||||
}
|
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
@@ -15581,7 +15579,13 @@ static int ecc_test_cdh_vectors(void)
|
|||||||
|
|
||||||
/* compute ECC Cofactor shared secret */
|
/* compute ECC Cofactor shared secret */
|
||||||
x = sizeof(sharedA);
|
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) {
|
if (ret != 0) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -15717,14 +15721,28 @@ static int ecc_test_make_pub(WC_RNG* rng)
|
|||||||
|
|
||||||
#ifdef HAVE_ECC_SIGN
|
#ifdef HAVE_ECC_SIGN
|
||||||
tmpSz = FOURK_BUF;
|
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) {
|
if (ret != 0) {
|
||||||
ERROR_OUT(-8324, done);
|
ERROR_OUT(-8324, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ECC_VERIFY
|
#ifdef HAVE_ECC_VERIFY
|
||||||
/* try verify with private only key */
|
/* 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) {
|
if (ret != 0) {
|
||||||
ERROR_OUT(-8325, done);
|
ERROR_OUT(-8325, done);
|
||||||
}
|
}
|
||||||
@@ -15771,14 +15789,21 @@ static int ecc_test_make_pub(WC_RNG* rng)
|
|||||||
wc_ecc_init_ex(&pub, HEAP_HINT, devId);
|
wc_ecc_init_ex(&pub, HEAP_HINT, devId);
|
||||||
ret = wc_ecc_make_key(rng, 32, &pub);
|
ret = wc_ecc_make_key(rng, 32, &pub);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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
|
#endif
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ERROR_OUT(-8331, done);
|
ERROR_OUT(-8331, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = FOURK_BUF;
|
x = FOURK_BUF;
|
||||||
ret = wc_ecc_shared_secret(&key, &pub, exportBuf, &x);
|
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);
|
wc_ecc_free(&pub);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ERROR_OUT(-8332, done);
|
ERROR_OUT(-8332, done);
|
||||||
@@ -15826,7 +15851,7 @@ static int ecc_test_key_gen(WC_RNG* rng, int keySize)
|
|||||||
|
|
||||||
ret = wc_ecc_make_key(rng, keySize, &userA);
|
ret = wc_ecc_make_key(rng, keySize, &userA);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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
|
#endif
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto done;
|
goto done;
|
||||||
@@ -15939,7 +15964,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);
|
ret = wc_ecc_make_key_ex(rng, keySize, &userA, curve_id);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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
|
#endif
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto done;
|
goto done;
|
||||||
@@ -15958,7 +15983,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);
|
ret = wc_ecc_make_key_ex(rng, keySize, &userB, curve_id);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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
|
#endif
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto done;
|
goto done;
|
||||||
@@ -15976,7 +16001,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_shared_secret(&userA, &userB, sharedA, &x);
|
ret = wc_ecc_shared_secret(&userA, &userB, sharedA, &x);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
@@ -15988,7 +16013,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_shared_secret(&userB, &userA, sharedB, &y);
|
ret = wc_ecc_shared_secret(&userB, &userA, sharedB, &y);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -16007,13 +16032,25 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
wc_ecc_set_flags(&userB, WC_ECC_FLAG_COFACTOR);
|
wc_ecc_set_flags(&userB, WC_ECC_FLAG_COFACTOR);
|
||||||
|
|
||||||
x = sizeof(sharedA);
|
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) {
|
if (ret != 0) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
y = sizeof(sharedB);
|
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)
|
if (ret != 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
@@ -16051,7 +16088,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
|
ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -16088,7 +16125,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
|
ret = wc_ecc_shared_secret(&userB, &pubKey, sharedB, &y);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -16116,7 +16153,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
|
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
|
||||||
&userA);
|
&userA);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
@@ -16130,7 +16167,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
|
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
|
||||||
&verify, &userA);
|
&verify, &userA);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
@@ -16152,7 +16189,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
|
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
|
||||||
&userA);
|
&userA);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
@@ -16166,7 +16203,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
|||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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_CALL_AGAIN);
|
||||||
#endif
|
#endif
|
||||||
if (ret >= 0)
|
if (ret == 0)
|
||||||
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
|
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
|
||||||
&verify, &userA);
|
&verify, &userA);
|
||||||
} while (ret == WC_PENDING_E);
|
} while (ret == WC_PENDING_E);
|
||||||
@@ -16686,7 +16723,14 @@ static int ecc_ssh_test(ecc_key* key)
|
|||||||
return -8447;
|
return -8447;
|
||||||
|
|
||||||
/* Use API. */
|
/* Use API. */
|
||||||
ret = wc_ecc_shared_secret_ssh(key, &key->pubkey, out, &outLen);
|
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)
|
if (ret != 0)
|
||||||
return -8448;
|
return -8448;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -16714,7 +16758,7 @@ static int ecc_def_curve_test(WC_RNG *rng)
|
|||||||
|
|
||||||
ret = wc_ecc_make_key(rng, 32, &key);
|
ret = wc_ecc_make_key(rng, 32, &key);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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
|
#endif
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ret = -8451;
|
ret = -8451;
|
||||||
@@ -17080,7 +17124,7 @@ static int ecc_test_cert_gen(WC_RNG* rng)
|
|||||||
|
|
||||||
ret = wc_ecc_make_key(rng, 32, &certPubKey);
|
ret = wc_ecc_make_key(rng, 32, &certPubKey);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#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
|
#endif
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ERROR_OUT(-8524, exit);
|
ERROR_OUT(-8524, exit);
|
||||||
@@ -17557,13 +17601,26 @@ int ecc_test_buffers(void) {
|
|||||||
|
|
||||||
|
|
||||||
x = sizeof(out);
|
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)
|
if (ret < 0)
|
||||||
return -8717;
|
return -8717;
|
||||||
|
|
||||||
XMEMSET(plain, 0, sizeof(plain));
|
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)
|
if (ret < 0)
|
||||||
return -8718;
|
return -8718;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user