From 9ec9ace7eaca9cbbf7b50d5f90b379948f6fc7a2 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 28 Oct 2021 16:19:18 -0600 Subject: [PATCH 1/7] adding kdf.c to IDE builds --- IDE/Android/Android.bp | 1 + IDE/ECLIPSE/DEOS/deos_wolfssl/.project | 5 +++++ IDE/GCC-ARM/Makefile.common | 1 + IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp | 3 +++ .../wolfcrypt_lib.ewp | 3 +++ .../wolfcrypt_lib.ewt | 3 +++ .../embOS/custom_port/README_custom_port | 1 + IDE/INTIME-RTOS/libwolfssl.vcxproj | 1 + IDE/KDS/.project | 5 +++++ IDE/LINUX-SGX/sgx_t_static.mk | 1 + IDE/M68K/Makefile | 1 + IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvopt | 13 +++++++++++++ IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvproj | 15 +++++++++++++++ IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp | 1 + IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp | 1 + IDE/Renesas/e2studio/GR-ROSE/wolfssl/.project | 5 +++++ IDE/Renesas/e2studio/Projects/wolfssl/.project | 5 +++++ IDE/Renesas/e2studio/RA6M3/wolfssl/.project | 5 +++++ .../e2studio/RX72NEnvisionKit/wolfssl/.project | 5 +++++ IDE/VS-ARM/wolfssl.vcxproj | 1 + IDE/VS-AZURE-SPHERE/wolfssl.vcxproj | 3 ++- IDE/XilinxSDK/2019_2/wolfCrypt_example/.project | 5 +++++ 22 files changed, 83 insertions(+), 1 deletion(-) diff --git a/IDE/Android/Android.bp b/IDE/Android/Android.bp index 3be3b13c6..2a13dfdcb 100644 --- a/IDE/Android/Android.bp +++ b/IDE/Android/Android.bp @@ -67,6 +67,7 @@ cc_library_shared { "./wolfcrypt/src/ge_low_mem.c", "./wolfcrypt/src/ge_operations.c", "./wolfcrypt/src/hash.c", + "./wolfcrypt/src/kdf.c", "./wolfcrypt/src/hc128.c", "./wolfcrypt/src/hmac.c", "./wolfcrypt/src/idea.c", diff --git a/IDE/ECLIPSE/DEOS/deos_wolfssl/.project b/IDE/ECLIPSE/DEOS/deos_wolfssl/.project index 769c9630e..05b86a93a 100644 --- a/IDE/ECLIPSE/DEOS/deos_wolfssl/.project +++ b/IDE/ECLIPSE/DEOS/deos_wolfssl/.project @@ -414,6 +414,11 @@ 1 WOLFSSL_ROOT/wolfcrypt/src/ge_operations.c + + wolfcrypt/src/kdf.c + 1 + WOLFSSL_ROOT/wolfcrypt/src/kdf.c + wolfcrypt/src/hash.c 1 diff --git a/IDE/GCC-ARM/Makefile.common b/IDE/GCC-ARM/Makefile.common index a98fd55b0..2687a4b3c 100644 --- a/IDE/GCC-ARM/Makefile.common +++ b/IDE/GCC-ARM/Makefile.common @@ -138,6 +138,7 @@ SRC_C += ../../wolfcrypt/src/ge_448.c SRC_C += ../../wolfcrypt/src/ge_low_mem.c SRC_C += ../../wolfcrypt/src/ge_operations.c SRC_C += ../../wolfcrypt/src/hash.c +SRC_C += ../../wolfcrypt/src/kdf.c SRC_C += ../../wolfcrypt/src/integer.c SRC_C += ../../wolfcrypt/src/logging.c SRC_C += ../../wolfcrypt/src/md5.c diff --git a/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp b/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp index db1c3e4e3..f8320e199 100644 --- a/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp +++ b/IDE/IAR-EWARM/Projects/lib/wolfSSL-Lib.ewp @@ -1975,6 +1975,9 @@ $PROJ_DIR$\..\..\..\..\wolfcrypt\src\hash.c + + $PROJ_DIR$\..\..\..\..\wolfcrypt\src\kdf.c + $PROJ_DIR$\..\..\..\..\wolfcrypt\src\hc128.c diff --git a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp index 3dd4eac93..58ee9e08c 100644 --- a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp +++ b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewp @@ -1956,6 +1956,9 @@ $PROJ_DIR$\..\..\..\..\..\wolfcrypt\src\hash.c + + $PROJ_DIR$\..\..\..\..\..\wolfcrypt\src\kdf.c + $PROJ_DIR$\..\..\..\..\..\wolfcrypt\src\hmac.c diff --git a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewt b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewt index 8dfc682f0..62d87fb24 100644 --- a/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewt +++ b/IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_wolfcrypt_lib_SAMV71_XULT/wolfcrypt_lib.ewt @@ -2346,6 +2346,9 @@ $PROJ_DIR$\..\..\..\..\..\wolfcrypt\src\hash.c + + $PROJ_DIR$\..\..\..\..\..\wolfcrypt\src\kdf.c + $PROJ_DIR$\..\..\..\..\..\wolfcrypt\src\hmac.c diff --git a/IDE/IAR-EWARM/embOS/custom_port/README_custom_port b/IDE/IAR-EWARM/embOS/custom_port/README_custom_port index 3d13bc56d..643bc6177 100644 --- a/IDE/IAR-EWARM/embOS/custom_port/README_custom_port +++ b/IDE/IAR-EWARM/embOS/custom_port/README_custom_port @@ -45,6 +45,7 @@ wolfssl (latest version) # hmac.c tfm.c # # md4.c wc_encrypt.c # # md5.c wc_port.c # + # kdf.c # #---------------------------------------------# 5. Once those are all added go to diff --git a/IDE/INTIME-RTOS/libwolfssl.vcxproj b/IDE/INTIME-RTOS/libwolfssl.vcxproj index 85bb1d783..ca7360756 100755 --- a/IDE/INTIME-RTOS/libwolfssl.vcxproj +++ b/IDE/INTIME-RTOS/libwolfssl.vcxproj @@ -46,6 +46,7 @@ + diff --git a/IDE/KDS/.project b/IDE/KDS/.project index d83ae5ca4..90424c9c7 100644 --- a/IDE/KDS/.project +++ b/IDE/KDS/.project @@ -165,6 +165,11 @@ 1 PARENT-2-PROJECT_LOC/wolfcrypt/src/hash.c + + src/wolfcrypt-src/kdf.c + 1 + PARENT-2-PROJECT_LOC/wolfcrypt/src/kdf.c + src/wolfcrypt-src/hc128.c 1 diff --git a/IDE/LINUX-SGX/sgx_t_static.mk b/IDE/LINUX-SGX/sgx_t_static.mk index 41ff666f2..891350a78 100644 --- a/IDE/LINUX-SGX/sgx_t_static.mk +++ b/IDE/LINUX-SGX/sgx_t_static.mk @@ -61,6 +61,7 @@ Wolfssl_C_Files :=$(WOLFSSL_ROOT)/wolfcrypt/src/aes.c\ $(WOLFSSL_ROOT)/wolfcrypt/src/ecc.c\ $(WOLFSSL_ROOT)/wolfcrypt/src/error.c\ $(WOLFSSL_ROOT)/wolfcrypt/src/hash.c\ + $(WOLFSSL_ROOT)/wolfcrypt/src/kdf.c\ $(WOLFSSL_ROOT)/wolfcrypt/src/hc128.c\ $(WOLFSSL_ROOT)/wolfcrypt/src/hmac.c\ $(WOLFSSL_ROOT)/wolfcrypt/src/integer.c\ diff --git a/IDE/M68K/Makefile b/IDE/M68K/Makefile index 5f4da0c22..ee507dc92 100644 --- a/IDE/M68K/Makefile +++ b/IDE/M68K/Makefile @@ -20,6 +20,7 @@ CSRCS := ../../wolfcrypt/src/rsa.c \ ../../wolfcrypt/src/memory.c \ ../../wolfcrypt/src/coding.c \ ../../wolfcrypt/src/hash.c \ + ../../wolfcrypt/src/kdf.c \ ../../wolfcrypt/src/hmac.c \ ../../wolfcrypt/src/md5.c \ ../../wolfcrypt/src/wc_port.c \ diff --git a/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvopt b/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvopt index 2cecde47e..250dbb517 100644 --- a/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvopt +++ b/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvopt @@ -1181,6 +1181,19 @@ 0 0 + + 1 + 48 + 1 + 0 + 0 + 0 + 0 + ..\..\..\wolfcrypt\src\kdf.c + kdf.c + 0 + 0 + diff --git a/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvproj b/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvproj index 1cac8782a..a97cea8c2 100644 --- a/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvproj +++ b/IDE/MDK-ARM/Projects/MDK-ARM-wolfSSL-Lib.uvproj @@ -626,6 +626,11 @@ 1 ..\..\..\wolfcrypt\src\hash.c + + kdf.c + 1 + ..\..\..\wolfcrypt\src\kdf.c + misc.c 1 @@ -1335,6 +1340,11 @@ 1 ..\..\..\wolfcrypt\src\hash.c + + kdf.c + 1 + ..\..\..\wolfcrypt\src\kdf.c + misc.c 1 @@ -2044,6 +2054,11 @@ 1 ..\..\..\wolfcrypt\src\hash.c + + kdf.c + 1 + ..\..\..\wolfcrypt\src\kdf.c + misc.c 1 diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp b/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp index 74388ddac..2706be5f8 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp +++ b/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp @@ -71,6 +71,7 @@ + diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp b/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp index 2cd93b21f..81ecc568a 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp +++ b/IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp @@ -73,6 +73,7 @@ + diff --git a/IDE/Renesas/e2studio/GR-ROSE/wolfssl/.project b/IDE/Renesas/e2studio/GR-ROSE/wolfssl/.project index 46ee10091..a2f1351e7 100644 --- a/IDE/Renesas/e2studio/GR-ROSE/wolfssl/.project +++ b/IDE/Renesas/e2studio/GR-ROSE/wolfssl/.project @@ -214,6 +214,11 @@ 1 PARENT-5-PROJECT_LOC/wolfcrypt/src/hash.c + + wolfcrypt/src/kdf.c + 1 + PARENT-5-PROJECT_LOC/wolfcrypt/src/kdf.c + wolfcrypt/src/hc128.c 1 diff --git a/IDE/Renesas/e2studio/Projects/wolfssl/.project b/IDE/Renesas/e2studio/Projects/wolfssl/.project index 46ee10091..a2f1351e7 100644 --- a/IDE/Renesas/e2studio/Projects/wolfssl/.project +++ b/IDE/Renesas/e2studio/Projects/wolfssl/.project @@ -214,6 +214,11 @@ 1 PARENT-5-PROJECT_LOC/wolfcrypt/src/hash.c + + wolfcrypt/src/kdf.c + 1 + PARENT-5-PROJECT_LOC/wolfcrypt/src/kdf.c + wolfcrypt/src/hc128.c 1 diff --git a/IDE/Renesas/e2studio/RA6M3/wolfssl/.project b/IDE/Renesas/e2studio/RA6M3/wolfssl/.project index 33ff60268..05649a287 100644 --- a/IDE/Renesas/e2studio/RA6M3/wolfssl/.project +++ b/IDE/Renesas/e2studio/RA6M3/wolfssl/.project @@ -215,6 +215,11 @@ 1 PARENT-5-PROJECT_LOC/wolfcrypt/src/hash.c + + wolfcrypt/kdf.c + 1 + PARENT-5-PROJECT_LOC/wolfcrypt/src/kdf.c + wolfcrypt/hc128.c 1 diff --git a/IDE/Renesas/e2studio/RX72NEnvisionKit/wolfssl/.project b/IDE/Renesas/e2studio/RX72NEnvisionKit/wolfssl/.project index 46ee10091..a2f1351e7 100644 --- a/IDE/Renesas/e2studio/RX72NEnvisionKit/wolfssl/.project +++ b/IDE/Renesas/e2studio/RX72NEnvisionKit/wolfssl/.project @@ -214,6 +214,11 @@ 1 PARENT-5-PROJECT_LOC/wolfcrypt/src/hash.c + + wolfcrypt/src/kdf.c + 1 + PARENT-5-PROJECT_LOC/wolfcrypt/src/kdf.c + wolfcrypt/src/hc128.c 1 diff --git a/IDE/VS-ARM/wolfssl.vcxproj b/IDE/VS-ARM/wolfssl.vcxproj index 6769f429b..561aa76c2 100644 --- a/IDE/VS-ARM/wolfssl.vcxproj +++ b/IDE/VS-ARM/wolfssl.vcxproj @@ -63,6 +63,7 @@ + diff --git a/IDE/VS-AZURE-SPHERE/wolfssl.vcxproj b/IDE/VS-AZURE-SPHERE/wolfssl.vcxproj index fbd3dbb30..752a96ce9 100644 --- a/IDE/VS-AZURE-SPHERE/wolfssl.vcxproj +++ b/IDE/VS-AZURE-SPHERE/wolfssl.vcxproj @@ -45,6 +45,7 @@ + @@ -132,4 +133,4 @@ - \ No newline at end of file + diff --git a/IDE/XilinxSDK/2019_2/wolfCrypt_example/.project b/IDE/XilinxSDK/2019_2/wolfCrypt_example/.project index c814955a7..f85a59460 100644 --- a/IDE/XilinxSDK/2019_2/wolfCrypt_example/.project +++ b/IDE/XilinxSDK/2019_2/wolfCrypt_example/.project @@ -505,6 +505,11 @@ 1 PARENT-4-PROJECT_LOC/wolfcrypt/src/hash.c + + src/wolfcrypt/src/kdf.c + 1 + PARENT-4-PROJECT_LOC/wolfcrypt/src/kdf.c + src/wolfcrypt/src/hc128.c 1 From e10e3a92b8b0226dc19ab6b2be4c53822489a628 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 28 Oct 2021 16:27:45 -0600 Subject: [PATCH 2/7] add kdf.c to cmake build --- cmake/functions.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 1cfdc8c73..aa4f1c90d 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -451,7 +451,8 @@ function(generate_lib_src_list LIB_SOURCES) endif() list(APPEND LIB_SOURCES - wolfcrypt/src/hash.c + wolfcrypt/src/hash.c + wolfcrypt/src/kdf.c wolfcrypt/src/cpuid.c) if(NOT BUILD_FIPS_RAND) From 8775823fa00c6d1b763d8e99f4e8c3944d3db76e Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 28 Oct 2021 17:11:56 -0600 Subject: [PATCH 3/7] handling edge cases with ecc import and decrypt functions --- wolfcrypt/src/ecc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 766122a6e..d6f354a49 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -8799,11 +8799,12 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key, DECLARE_CURVE_SPECS(curve, 3); ALLOC_CURVE_SPECS(3, err); - if (err == MP_OKAY && - mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL) != MP_OKAY) - err = MEMORY_E; - else - did_init = 1; + if (err == MP_OKAY) { + if (mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL) != MP_OKAY) + err = MEMORY_E; + else + did_init = 1; + } /* load curve info */ if (err == MP_OKAY) @@ -12117,6 +12118,11 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, #endif pubKey = peerKey; } + else { + /* if a public key was passed in we should free it here before init + * and import */ + wc_ecc_free(pubKey); + } if (ret == 0) { ret = wc_ecc_init_ex(pubKey, privKey->heap, INVALID_DEVID); } From 03bc45c5b12d6a3fc7b210f2691959e2dd7c9841 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Fri, 29 Oct 2021 10:51:24 -0600 Subject: [PATCH 4/7] check if private key exists before using with private key check function --- src/ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssl.c b/src/ssl.c index db597a303..7a5975e26 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -7747,7 +7747,7 @@ int wolfSSL_CTX_check_private_key(const WOLFSSL_CTX* ctx) WOLFSSL_ENTER("wolfSSL_CTX_check_private_key"); - if (ctx == NULL || ctx->certificate == NULL) { + if (ctx == NULL || ctx->certificate == NULL || ctx->privateKey == NULL) { return WOLFSSL_FAILURE; } From 1d91ccb41b9737aca83509031578a8254e57a646 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Fri, 29 Oct 2021 13:12:43 -0600 Subject: [PATCH 5/7] remove exe bit on example.c and server.c --- examples/client/client.c | 0 examples/server/server.c | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/client/client.c mode change 100755 => 100644 examples/server/server.c diff --git a/examples/client/client.c b/examples/client/client.c old mode 100755 new mode 100644 diff --git a/examples/server/server.c b/examples/server/server.c old mode 100755 new mode 100644 From 6ba55edd500d271814911374bb8da40b72dd3dca Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 29 Oct 2021 14:37:39 -0600 Subject: [PATCH 6/7] fix async warnings --- tests/api.c | 36 +++++++++++++++++++++++++++++++-- wolfcrypt/benchmark/benchmark.c | 23 ++++++++++++--------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/tests/api.c b/tests/api.c index 975250734..81aa480b1 100644 --- a/tests/api.c +++ b/tests/api.c @@ -4586,7 +4586,9 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args) } #endif + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -4788,7 +4790,9 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) goto done; } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -4982,7 +4986,9 @@ static void test_client_nofail(void* args, cbType cb) cbf->ssl_ready(ssl); } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5163,7 +5169,9 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args cbf->ssl_ready(ssl); } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5221,7 +5229,9 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args goto done; } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5348,7 +5358,9 @@ static void test_client_verifyDepth(void* args) goto done; } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5539,7 +5551,9 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) callbacks->ssl_ready(ssl); + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5703,7 +5717,9 @@ static void run_wolfssl_client(void* args) if (callbacks->ssl_ready) callbacks->ssl_ready(ssl); + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5720,7 +5736,9 @@ static void run_wolfssl_client(void* args) /*err_sys("SSL_connect failed");*/ } else { + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -5733,7 +5751,9 @@ static void run_wolfssl_client(void* args) } while (err == WC_PENDING_E); AssertIntEQ(len, ret); + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -6029,7 +6049,9 @@ static void test_client_get_finished(void* args, cbType cb) cbf->ssl_ready(ssl); } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -6055,11 +6077,13 @@ static void test_client_get_finished(void* args, cbType cb) XMEMSET(client_side_msg2, 0, MD_MAX_SIZE); msg_len = wolfSSL_get_peer_finished(ssl, client_side_msg2, MD_MAX_SIZE); AssertIntGE(msg_len, 0); - + if (cb != NULL) (cb)(ctx, ssl); - + + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -6075,7 +6099,9 @@ static void test_client_get_finished(void* args, cbType cb) goto done; } + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -38771,7 +38797,9 @@ static void test_wolfSSL_SESSION(void) tcp_connect(&sockfd, wolfSSLIP, ready.port, 0, 0, ssl); AssertIntEQ(wolfSSL_set_fd(ssl, sockfd), SSL_SUCCESS); + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -38784,7 +38812,9 @@ static void test_wolfSSL_SESSION(void) } while (err == WC_PENDING_E); AssertIntEQ(ret, WOLFSSL_SUCCESS); + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { @@ -38797,7 +38827,9 @@ static void test_wolfSSL_SESSION(void) } while (err == WC_PENDING_E); AssertIntEQ(ret, (int)XSTRLEN(sendGET)); + #ifdef WOLFSSL_ASYNC_CRYPT err = 0; /* Reset error */ + #endif do { #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 76f355902..35f5457e6 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -1090,19 +1090,21 @@ typedef enum bench_stat_type { const char* algo, int strength, const char* desc, int doAsync, double perfsec, const char* perftype, int ret) { - bench_stats_t* bstat; + bench_stats_t* bstat = NULL; /* protect bench_stats_head and bench_stats_tail access */ pthread_mutex_lock(&bench_lock); - /* locate existing in list */ - for (bstat = bench_stats_head; bstat != NULL; bstat = bstat->next) { - /* match based on algo, strength and desc */ - if (XSTRNCMP(bstat->algo, algo, BENCH_MAX_NAME_SZ) == 0 && - bstat->strength == strength && - bstat->desc == desc && - bstat->doAsync == doAsync) { - break; + if (algo != NULL) { + /* locate existing in list */ + for (bstat = bench_stats_head; bstat != NULL; bstat = bstat->next) { + /* match based on algo, strength and desc */ + if (XSTRNCMP(bstat->algo, algo, BENCH_MAX_NAME_SZ) == 0 && + bstat->strength == strength && + bstat->desc == desc && + bstat->doAsync == doAsync) { + break; + } } } @@ -1126,7 +1128,8 @@ typedef enum bench_stat_type { } if (bstat) { bstat->type = type; - XSTRNCPY(bstat->algo, algo, BENCH_MAX_NAME_SZ); + if (algo != NULL) + XSTRNCPY(bstat->algo, algo, BENCH_MAX_NAME_SZ); bstat->strength = strength; bstat->desc = desc; bstat->doAsync = doAsync; From fb7baf28cad9548cfe6f4b97d95e25fbff200bc7 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Fri, 29 Oct 2021 16:55:05 -0600 Subject: [PATCH 7/7] fix for xcode build and revert cmake change --- IDE/XCODE/wolfssl-FIPS.xcodeproj/project.pbxproj | 9 +++++++++ IDE/XCODE/wolfssl.xcodeproj/project.pbxproj | 10 ++++++++++ cmake/functions.cmake | 1 - 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/IDE/XCODE/wolfssl-FIPS.xcodeproj/project.pbxproj b/IDE/XCODE/wolfssl-FIPS.xcodeproj/project.pbxproj index 76ba5c6e6..e3d726ec8 100644 --- a/IDE/XCODE/wolfssl-FIPS.xcodeproj/project.pbxproj +++ b/IDE/XCODE/wolfssl-FIPS.xcodeproj/project.pbxproj @@ -169,6 +169,8 @@ 522DBE131B792A190031F454 /* wc_encrypt.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 522DBE121B7929E70031F454 /* wc_encrypt.h */; }; 525BE5BA1B38853E0054BBCD /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 525BE5B91B38853E0054BBCD /* hash.c */; }; 525BE5BC1B3885750054BBCD /* hash.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 525BE5BB1B3885580054BBCD /* hash.h */; }; + 6AC85136272CAFEC00F2B32A /* kdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AC85135272CAFEC00F2B32A /* kdf.c */; }; + 6AC85137272CAFEC00F2B32A /* kdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AC85135272CAFEC00F2B32A /* kdf.c */; }; A4A54DF71BC5C3E0002866CD /* wolfcrypt_first.c in Sources */ = {isa = PBXBuildFile; fileRef = 5216481B1A8AC2990062516A /* wolfcrypt_first.c */; }; A4A54DF81BC5C3E0002866CD /* hmac.c in Sources */ = {isa = PBXBuildFile; fileRef = 521648141A8AC2990062516A /* hmac.c */; }; A4A54DF91BC5C3E0002866CD /* random.c in Sources */ = {isa = PBXBuildFile; fileRef = 521648161A8AC2990062516A /* random.c */; }; @@ -786,6 +788,8 @@ 525BE5B91B38853E0054BBCD /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hash.c; path = ../../wolfcrypt/src/hash.c; sourceTree = ""; }; 525BE5BB1B3885580054BBCD /* hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hash.h; path = ../../wolfssl/wolfcrypt/hash.h; sourceTree = ""; }; 52B1344D16F3C9E800C07B32 /* libwolfssl_fips_ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libwolfssl_fips_ios.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 6AC85135272CAFEC00F2B32A /* kdf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = kdf.c; path = ../../wolfcrypt/src/kdf.c; sourceTree = ""; }; + 6AC8513A272CB01200F2B32A /* kdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = kdf.h; path = ../../wolfssl/wolfcrypt/kdf.h; sourceTree = ""; }; A4A54DF41BC5C380002866CD /* user_settings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = user_settings.h; sourceTree = ""; }; A4A54EA11BC5C3E0002866CD /* libwolfssl_fips_osx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libwolfssl_fips_osx.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -909,6 +913,7 @@ 525BE5BB1B3885580054BBCD /* hash.h */, 5216466F1A8993770062516A /* hc128.h */, 521646701A8993770062516A /* hmac.h */, + 6AC8513A272CB01200F2B32A /* kdf.h */, 521646721A8993770062516A /* integer.h */, 521646731A8993770062516A /* logging.h */, 521646741A8993770062516A /* md2.h */, @@ -983,6 +988,7 @@ 525BE5B91B38853E0054BBCD /* hash.c */, 5216461D1A8992CC0062516A /* hc128.c */, 5216461E1A8992CC0062516A /* hmac.c */, + 6AC85135272CAFEC00F2B32A /* kdf.c */, 5216461F1A8992CC0062516A /* integer.c */, 521646201A8992CC0062516A /* logging.c */, 521646211A8992CC0062516A /* md2.c */, @@ -1116,6 +1122,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 52B1344416F3C9E800C07B32; @@ -1177,6 +1184,7 @@ 5216464F1A8992CC0062516A /* sha256.c in Sources */, 521646371A8992CC0062516A /* chacha.c in Sources */, 521646471A8992CC0062516A /* pkcs7.c in Sources */, + 6AC85136272CAFEC00F2B32A /* kdf.c in Sources */, 5216460E1A89928E0062516A /* sniffer.c in Sources */, 521646421A8992CC0062516A /* md2.c in Sources */, 521646381A8992CC0062516A /* coding.c in Sources */, @@ -1239,6 +1247,7 @@ A4A54E1F1BC5C3E0002866CD /* sha256.c in Sources */, A4A54E201BC5C3E0002866CD /* chacha.c in Sources */, A4A54E211BC5C3E0002866CD /* pkcs7.c in Sources */, + 6AC85137272CAFEC00F2B32A /* kdf.c in Sources */, A4A54E221BC5C3E0002866CD /* sniffer.c in Sources */, A4A54E231BC5C3E0002866CD /* md2.c in Sources */, A4A54E241BC5C3E0002866CD /* coding.c in Sources */, diff --git a/IDE/XCODE/wolfssl.xcodeproj/project.pbxproj b/IDE/XCODE/wolfssl.xcodeproj/project.pbxproj index e23fc7c67..8f2ba4009 100644 --- a/IDE/XCODE/wolfssl.xcodeproj/project.pbxproj +++ b/IDE/XCODE/wolfssl.xcodeproj/project.pbxproj @@ -356,6 +356,9 @@ 522DBE0F1B7927A50031F454 /* wc_encrypt.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 522DBE0E1B7927290031F454 /* wc_encrypt.h */; }; 525BE5341B3869110054BBCD /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 525BE5331B3869110054BBCD /* hash.c */; }; 525BE5361B3869780054BBCD /* hash.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 525BE5351B3869430054BBCD /* hash.h */; }; + 6AC85129272CAF2E00F2B32A /* kdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AC85128272CAF2E00F2B32A /* kdf.c */; }; + 6AC8512A272CAF2E00F2B32A /* kdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AC85128272CAF2E00F2B32A /* kdf.c */; }; + 6AC8512B272CAF2E00F2B32A /* kdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AC85128272CAF2E00F2B32A /* kdf.c */; }; A4DAE3062493F1C700CEF51F /* tls13.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DAE3052493F1C700CEF51F /* tls13.c */; }; A4DAE3072493F1C700CEF51F /* tls13.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DAE3052493F1C700CEF51F /* tls13.c */; }; A4DAE3082493F1C700CEF51F /* tls13.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DAE3052493F1C700CEF51F /* tls13.c */; }; @@ -1187,6 +1190,8 @@ 525BE5331B3869110054BBCD /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hash.c; path = ../../wolfcrypt/src/hash.c; sourceTree = ""; }; 525BE5351B3869430054BBCD /* hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hash.h; path = ../../wolfssl/wolfcrypt/hash.h; sourceTree = ""; }; 52B1344D16F3C9E800C07B32 /* libwolfssl_ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libwolfssl_ios.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 6AC85128272CAF2E00F2B32A /* kdf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = kdf.c; path = ../../wolfcrypt/src/kdf.c; sourceTree = ""; }; + 6AC8513B272CB04F00F2B32A /* kdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = kdf.h; path = ../../wolfssl/wolfcrypt/kdf.h; sourceTree = ""; }; A45EA7091BC5995E00A8614A /* user_settings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = user_settings.h; sourceTree = ""; }; A4DAE3052493F1C700CEF51F /* tls13.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tls13.c; path = ../../src/tls13.c; sourceTree = ""; }; A4DAE3092493F21700CEF51F /* srp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srp.c; path = ../../wolfcrypt/src/srp.c; sourceTree = ""; }; @@ -1340,6 +1345,7 @@ 525BE5351B3869430054BBCD /* hash.h */, 5216466F1A8993770062516A /* hc128.h */, 521646701A8993770062516A /* hmac.h */, + 6AC8513B272CB04F00F2B32A /* kdf.h */, 521646721A8993770062516A /* integer.h */, 521646731A8993770062516A /* logging.h */, 521646741A8993770062516A /* md2.h */, @@ -1434,6 +1440,7 @@ 525BE5331B3869110054BBCD /* hash.c */, 5216461D1A8992CC0062516A /* hc128.c */, 5216461E1A8992CC0062516A /* hmac.c */, + 6AC85128272CAF2E00F2B32A /* kdf.c */, A4DAE3192493F21900CEF51F /* idea.c */, 5216461F1A8992CC0062516A /* integer.c */, 521646201A8992CC0062516A /* logging.c */, @@ -1656,6 +1663,7 @@ 30B060681C6DDB2B00D46008 /* hash.c in Sources */, A4DAE34C2493F21900CEF51F /* idea.c in Sources */, 30B060691C6DDB2B00D46008 /* hc128.c in Sources */, + 6AC8512B272CAF2E00F2B32A /* kdf.c in Sources */, 30B0606A1C6DDB2B00D46008 /* hmac.c in Sources */, A4DAE3572493F29E00CEF51F /* sp_dsp32.c in Sources */, A4DAE3282493F21900CEF51F /* fe_448.c in Sources */, @@ -1742,6 +1750,7 @@ 520775AB2239ABBE00087711 /* sp_int.c in Sources */, 521646431A8992CC0062516A /* md4.c in Sources */, 521646321A8992CC0062516A /* aes.c in Sources */, + 6AC85129272CAF2E00F2B32A /* kdf.c in Sources */, 521646391A8992CC0062516A /* des3.c in Sources */, 521646351A8992CC0062516A /* blake2b.c in Sources */, 520775AD2239ABCD00087711 /* chacha20_poly1305.c in Sources */, @@ -1828,6 +1837,7 @@ A4F318701BC58B1700FDF2BB /* md2.c in Sources */, A4DAE34B2493F21900CEF51F /* idea.c in Sources */, A4F318651BC58B1700FDF2BB /* md4.c in Sources */, + 6AC8512A272CAF2E00F2B32A /* kdf.c in Sources */, A4F3185E1BC58B1700FDF2BB /* md5.c in Sources */, A4DAE3562493F29E00CEF51F /* sp_dsp32.c in Sources */, A4DAE3272493F21900CEF51F /* fe_448.c in Sources */, diff --git a/cmake/functions.cmake b/cmake/functions.cmake index aa4f1c90d..f8d3abc17 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -452,7 +452,6 @@ function(generate_lib_src_list LIB_SOURCES) list(APPEND LIB_SOURCES wolfcrypt/src/hash.c - wolfcrypt/src/kdf.c wolfcrypt/src/cpuid.c) if(NOT BUILD_FIPS_RAND)