From 18806772320dfa7e6f842d4f0c4d6295be8f746b Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 11 May 2017 16:18:19 -0700 Subject: [PATCH 1/4] Disable wc_scrypt tests that use high memory for BENCH_EMBEDDED. --- wolfcrypt/test/test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index fbed19234..97788b7a1 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -8932,6 +8932,8 @@ int scrypt_test(void) if (XMEMCMP(derived, verify2, sizeof(verify2)) != 0) return -6003; + /* Don't run these test on embedded, since they use large mallocs */ +#ifndef BENCH_EMBEDDED ret = wc_scrypt(derived, (byte*)"pleaseletmein", 13, (byte*)"SodiumChloride", 14, 14, 8, 1, sizeof(verify3)); if (ret != 0) @@ -8947,6 +8949,7 @@ int scrypt_test(void) if (XMEMCMP(derived, verify4, sizeof(verify4)) != 0) return -6007; #endif +#endif /* !BENCH_EMBEDDED */ return 0; } From 720f3fdad200d08db09e0a28899bbc8eac1e2be6 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 23 May 2017 15:00:55 -0700 Subject: [PATCH 2/4] Fixed a few minor build errors with async enabled. --- wolfssl/internal.h | 2 +- wolfssl/wolfcrypt/curve25519.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 568fb7e86..e17d8840b 100755 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -2999,7 +2999,7 @@ typedef struct HS_Hashes { #ifdef WOLFSSL_ASYNC_CRYPT - #define MAX_ASYNC_ARGS 16 + #define MAX_ASYNC_ARGS 18 typedef void (*FreeArgsCb)(struct WOLFSSL* ssl, void* pArgs); struct WOLFSSL_ASYNC { diff --git a/wolfssl/wolfcrypt/curve25519.h b/wolfssl/wolfcrypt/curve25519.h index fb4a96c29..85b036d14 100644 --- a/wolfssl/wolfcrypt/curve25519.h +++ b/wolfssl/wolfcrypt/curve25519.h @@ -30,6 +30,10 @@ #include #include +#ifdef WOLFSSL_ASYNC_CRYPT + #include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -50,7 +54,7 @@ typedef struct { #ifdef FREESCALE_LTC_ECC byte pointY[CURVE25519_KEYSIZE]; #endif -}ECPoint; +} ECPoint; /* A CURVE25519 Key */ typedef struct curve25519_key { @@ -61,6 +65,10 @@ typedef struct curve25519_key { curves (idx >= 0) or user supplied */ ECPoint p; /* public key */ ECPoint k; /* private key */ + +#ifdef WOLFSSL_ASYNC_CRYPT + WC_ASYNC_DEV asyncDev; +#endif } curve25519_key; enum { From 64de29f277f6129b0f9a0395fcb766859759ddeb Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 23 May 2017 15:23:58 -0700 Subject: [PATCH 3/4] Fix for wolfCrypt test with enable-all and asynccrypt. --- wolfcrypt/test/test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 97788b7a1..535a60fab 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -7728,6 +7728,9 @@ static int dh_generate_test(WC_RNG *rng) /* Use API. */ ret = wc_DhGenerateKeyPair(&smallKey, rng, priv, &privSz, pub, &pubSz); +#if defined(WOLFSSL_ASYNC_CRYPT) + ret = wc_AsyncWait(ret, &smallKey.asyncDev, WC_ASYNC_FLAG_NONE); +#endif if (ret != 0) { ret = -5707; } From c1664bd1a03b79a77853d418238c899ae1963e04 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 23 May 2017 15:41:42 -0700 Subject: [PATCH 4/4] Fixes for async with benchmark tool. --- wolfcrypt/benchmark/benchmark.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 3ca221509..faed120ce 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -3072,9 +3072,15 @@ void bench_eccEncrypt(void) } ret = wc_ecc_make_key(&rng, keySize, &userA); +#ifdef WOLFSSL_ASYNC_CRYPT + ret = wc_AsyncWait(ret, &userA.asyncDev, WC_ASYNC_FLAG_NONE); +#endif if (ret != 0) goto exit; ret = wc_ecc_make_key(&rng, keySize, &userB); +#ifdef WOLFSSL_ASYNC_CRYPT + ret = wc_AsyncWait(ret, &userB.asyncDev, WC_ASYNC_FLAG_NONE); +#endif if (ret != 0) goto exit;