From cd9f86d921d387fa20d0fc336f24372def7980d5 Mon Sep 17 00:00:00 2001 From: C-Treff Date: Wed, 23 May 2018 10:33:56 +0200 Subject: [PATCH 1/4] time 64bit, test update 64bit settings for time is mandatory for INtime. Changed the project file. Test for ecc_test_buffers was unreliable, as the structs were not initialized befor usage. --- IDE/INTIME-RTOS/libwolfssl.vcxproj | 4 ++-- wolfcrypt/test/test.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/IDE/INTIME-RTOS/libwolfssl.vcxproj b/IDE/INTIME-RTOS/libwolfssl.vcxproj index 5fc200943..72bdd824c 100755 --- a/IDE/INTIME-RTOS/libwolfssl.vcxproj +++ b/IDE/INTIME-RTOS/libwolfssl.vcxproj @@ -192,7 +192,7 @@ Async - _USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + _USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;_USE_64BIT_TIME_T;%(PreprocessorDefinitions) $(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories) $(IntDir) $(IntDir) @@ -211,7 +211,7 @@ Async - _USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + _USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;_USE_64BIT_TIME_T;%(PreprocessorDefinitions) $(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories) $(IntDir) $(IntDir) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 314285f0c..4554cd83a 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -15729,6 +15729,9 @@ int ecc_test_buffers(void) { int verify = 0; word32 x; + memset(&cliKey, 0, sizeof(ecc_key)); + memset(&servKey, 0, sizeof(ecc_key)); + bytes = (size_t)sizeof_ecc_clikey_der_256; /* place client key into ecc_key struct cliKey */ ret = wc_EccPrivateKeyDecode(ecc_clikey_der_256, &idx, &cliKey, From 1d281ce515636c4f9d560fd3a9cd19395110a886 Mon Sep 17 00:00:00 2001 From: C-Treff Date: Thu, 24 May 2018 09:35:46 +0200 Subject: [PATCH 2/4] replace memset by XMEMSET replaced memset with XMEMSET as requested by @dgarske INtime project files cleanup --- IDE/INTIME-RTOS/libwolfssl.vcxproj | 10 ---------- IDE/INTIME-RTOS/wolfExamples.vcxproj | 7 ------- wolfcrypt/test/test.c | 20 ++++++++++---------- wolfssl/test.h | 10 +++++----- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/IDE/INTIME-RTOS/libwolfssl.vcxproj b/IDE/INTIME-RTOS/libwolfssl.vcxproj index 72bdd824c..85bb1d783 100755 --- a/IDE/INTIME-RTOS/libwolfssl.vcxproj +++ b/IDE/INTIME-RTOS/libwolfssl.vcxproj @@ -27,7 +27,6 @@ - @@ -40,7 +39,6 @@ - @@ -194,10 +192,6 @@ Async _USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;_USE_64BIT_TIME_T;%(PreprocessorDefinitions) $(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories) - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir)vc$(PlatformToolsetVersion).pdb @@ -213,10 +207,6 @@ Async _USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;_USE_64BIT_TIME_T;%(PreprocessorDefinitions) $(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories) - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir)vc$(PlatformToolsetVersion).pdb diff --git a/IDE/INTIME-RTOS/wolfExamples.vcxproj b/IDE/INTIME-RTOS/wolfExamples.vcxproj index 81f82318e..81b1e6d4f 100755 --- a/IDE/INTIME-RTOS/wolfExamples.vcxproj +++ b/IDE/INTIME-RTOS/wolfExamples.vcxproj @@ -68,10 +68,6 @@ Async WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) $(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories) - $(IntDir) - $(IntDir) - $(IntDir)vc$(PlatformToolsetVersion).pdb - $(IntDir) @@ -88,10 +84,7 @@ Async WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) $(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories) - $(IntDir) - $(IntDir) $(IntDir)vc$(PlatformToolsetVersion).pdb - $(IntDir) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 4554cd83a..508971ce2 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -12671,7 +12671,7 @@ int openssl_pkey0_test(void) printf("error with encrypt init\n"); return ERR_BASE_PKEY-17; } - memset(out, 0, sizeof(out)); + XMEMSET(out, 0, sizeof(out)); ret = EVP_PKEY_encrypt(enc, out, &outlen, in, sizeof(in)); if (ret != 1) { printf("error encrypting msg\n"); @@ -12680,7 +12680,7 @@ int openssl_pkey0_test(void) show("encrypted msg", out, outlen); - memset(plain, 0, sizeof(plain)); + XMEMSET(plain, 0, sizeof(plain)); ret = EVP_PKEY_decrypt(dec, plain, &outlen, out, keySz); if (ret != 1) { printf("error decrypting msg\n"); @@ -12717,7 +12717,7 @@ int openssl_pkey0_test(void) } #endif - memset(out, 0, sizeof(out)); + XMEMSET(out, 0, sizeof(out)); ret = EVP_PKEY_encrypt(enc, out, &outlen, in, sizeof(in)); if (ret != 1) { printf("error encrypting msg\n"); @@ -12726,7 +12726,7 @@ int openssl_pkey0_test(void) show("encrypted msg", out, outlen); - memset(plain, 0, sizeof(plain)); + XMEMSET(plain, 0, sizeof(plain)); ret = EVP_PKEY_decrypt(dec, plain, &outlen, out, keySz); if (ret != 1) { printf("error decrypting msg\n"); @@ -13017,7 +13017,7 @@ int openssl_evpSig_test() show("message = ", (char *)msg, count); /* sign */ - memset(sig, 0, sizeof(sig)); + XMEMSET(sig, 0, sizeof(sig)); pt = (const void*)msg; ret1 = EVP_SignUpdate(sign, pt, count); ret2 = EVP_SignFinal(sign, sig, &sigSz, prvPkey); @@ -15729,8 +15729,8 @@ int ecc_test_buffers(void) { int verify = 0; word32 x; - memset(&cliKey, 0, sizeof(ecc_key)); - memset(&servKey, 0, sizeof(ecc_key)); + XMEMSET(&cliKey, 0, sizeof(ecc_key)); + XMEMSET(&servKey, 0, sizeof(ecc_key)); bytes = (size_t)sizeof_ecc_clikey_der_256; /* place client key into ecc_key struct cliKey */ @@ -18486,7 +18486,7 @@ int blob_test(void) }; - memset(blob, 0, sizeof(blob)); + XMEMSET(blob, 0, sizeof(blob)); outSz = sizeof(blob); ret = wc_caamCreateBlob((byte*)iv, sizeof(iv), blob, &outSz); if (ret != 0) { @@ -18499,7 +18499,7 @@ int blob_test(void) ERROR_OUT(-8201, exit_blob); } - memset(blob, 0, sizeof(blob)); + XMEMSET(blob, 0, sizeof(blob)); outSz = sizeof(blob); ret = wc_caamCreateBlob((byte*)iv, sizeof(iv), blob, &outSz); if (ret != 0) { @@ -18515,7 +18515,7 @@ int blob_test(void) ERROR_OUT(-8204, exit_blob); } - memset(blob, 0, sizeof(blob)); + XMEMSET(blob, 0, sizeof(blob)); outSz = sizeof(blob); ret = wc_caamCreateBlob((byte*)text, sizeof(text), blob, &outSz); if (ret != 0) { diff --git a/wolfssl/test.h b/wolfssl/test.h index 2c66ee6f5..77dee8474 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -639,7 +639,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer, if (addr == NULL) err_sys("invalid argument to build_addr, addr is NULL"); - memset(addr, 0, sizeof(SOCKADDR_IN_T)); + XMEMSET(addr, 0, sizeof(SOCKADDR_IN_T)); #ifndef TEST_IPV6 /* peer could be in human readable form */ @@ -692,7 +692,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer, int ret; char strPort[80]; - memset(&hints, 0, sizeof(hints)); + XMEMSET(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET_V; if (udp) { @@ -1422,7 +1422,7 @@ static INLINE int myDateCb(int preverify, WOLFSSL_X509_STORE_CTX* store) #ifdef HAVE_EXT_CACHE -static INLINE WOLFSSL_SESSION* mySessGetCb(WOLFSSL* ssl, unsigned char* id, +static INLINE WOLFSSL_SESSION* mySessGetCb(WOLFSSL* ssl, unsigned char* id, int id_len, int* copy) { (void)ssl; @@ -1852,14 +1852,14 @@ static INLINE void SetupAtomicUser(WOLFSSL_CTX* ctx, WOLFSSL* ssl) encCtx = (AtomicEncCtx*)malloc(sizeof(AtomicEncCtx)); if (encCtx == NULL) err_sys("AtomicEncCtx malloc failed"); - memset(encCtx, 0, sizeof(AtomicEncCtx)); + XMEMSET(encCtx, 0, sizeof(AtomicEncCtx)); decCtx = (AtomicDecCtx*)malloc(sizeof(AtomicDecCtx)); if (decCtx == NULL) { free(encCtx); err_sys("AtomicDecCtx malloc failed"); } - memset(decCtx, 0, sizeof(AtomicDecCtx)); + XMEMSET(decCtx, 0, sizeof(AtomicDecCtx)); wolfSSL_CTX_SetMacEncryptCb(ctx, myMacEncryptCb); wolfSSL_SetMacEncryptCtx(ssl, encCtx); From 06e9354629ac62e0694e008abe4f4acc746ece13 Mon Sep 17 00:00:00 2001 From: C-Treff Date: Thu, 24 May 2018 09:48:18 +0200 Subject: [PATCH 3/4] removed tabs --- wolfcrypt/test/test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 508971ce2..b31461a67 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -13017,7 +13017,7 @@ int openssl_evpSig_test() show("message = ", (char *)msg, count); /* sign */ - XMEMSET(sig, 0, sizeof(sig)); + XMEMSET(sig, 0, sizeof(sig)); pt = (const void*)msg; ret1 = EVP_SignUpdate(sign, pt, count); ret2 = EVP_SignFinal(sign, sig, &sigSz, prvPkey); @@ -15729,7 +15729,7 @@ int ecc_test_buffers(void) { int verify = 0; word32 x; - XMEMSET(&cliKey, 0, sizeof(ecc_key)); + XMEMSET(&cliKey, 0, sizeof(ecc_key)); XMEMSET(&servKey, 0, sizeof(ecc_key)); bytes = (size_t)sizeof_ecc_clikey_der_256; @@ -18486,7 +18486,7 @@ int blob_test(void) }; - XMEMSET(blob, 0, sizeof(blob)); + XMEMSET(blob, 0, sizeof(blob)); outSz = sizeof(blob); ret = wc_caamCreateBlob((byte*)iv, sizeof(iv), blob, &outSz); if (ret != 0) { @@ -18499,7 +18499,7 @@ int blob_test(void) ERROR_OUT(-8201, exit_blob); } - XMEMSET(blob, 0, sizeof(blob)); + XMEMSET(blob, 0, sizeof(blob)); outSz = sizeof(blob); ret = wc_caamCreateBlob((byte*)iv, sizeof(iv), blob, &outSz); if (ret != 0) { @@ -18515,7 +18515,7 @@ int blob_test(void) ERROR_OUT(-8204, exit_blob); } - XMEMSET(blob, 0, sizeof(blob)); + XMEMSET(blob, 0, sizeof(blob)); outSz = sizeof(blob); ret = wc_caamCreateBlob((byte*)text, sizeof(text), blob, &outSz); if (ret != 0) { From 5d693b263d3ad1d8e2f2cf2086580b829f54cec5 Mon Sep 17 00:00:00 2001 From: C-Treff Date: Thu, 24 May 2018 09:56:54 +0200 Subject: [PATCH 4/4] removed more tabs --- wolfcrypt/test/test.c | 8 ++++---- wolfssl/test.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index b31461a67..8d6700057 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -12671,7 +12671,7 @@ int openssl_pkey0_test(void) printf("error with encrypt init\n"); return ERR_BASE_PKEY-17; } - XMEMSET(out, 0, sizeof(out)); + XMEMSET(out, 0, sizeof(out)); ret = EVP_PKEY_encrypt(enc, out, &outlen, in, sizeof(in)); if (ret != 1) { printf("error encrypting msg\n"); @@ -12680,7 +12680,7 @@ int openssl_pkey0_test(void) show("encrypted msg", out, outlen); - XMEMSET(plain, 0, sizeof(plain)); + XMEMSET(plain, 0, sizeof(plain)); ret = EVP_PKEY_decrypt(dec, plain, &outlen, out, keySz); if (ret != 1) { printf("error decrypting msg\n"); @@ -12717,7 +12717,7 @@ int openssl_pkey0_test(void) } #endif - XMEMSET(out, 0, sizeof(out)); + XMEMSET(out, 0, sizeof(out)); ret = EVP_PKEY_encrypt(enc, out, &outlen, in, sizeof(in)); if (ret != 1) { printf("error encrypting msg\n"); @@ -12726,7 +12726,7 @@ int openssl_pkey0_test(void) show("encrypted msg", out, outlen); - XMEMSET(plain, 0, sizeof(plain)); + XMEMSET(plain, 0, sizeof(plain)); ret = EVP_PKEY_decrypt(dec, plain, &outlen, out, keySz); if (ret != 1) { printf("error decrypting msg\n"); diff --git a/wolfssl/test.h b/wolfssl/test.h index 77dee8474..1b584c0a0 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -639,7 +639,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer, if (addr == NULL) err_sys("invalid argument to build_addr, addr is NULL"); - XMEMSET(addr, 0, sizeof(SOCKADDR_IN_T)); + XMEMSET(addr, 0, sizeof(SOCKADDR_IN_T)); #ifndef TEST_IPV6 /* peer could be in human readable form */ @@ -692,7 +692,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer, int ret; char strPort[80]; - XMEMSET(&hints, 0, sizeof(hints)); + XMEMSET(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET_V; if (udp) { @@ -1852,14 +1852,14 @@ static INLINE void SetupAtomicUser(WOLFSSL_CTX* ctx, WOLFSSL* ssl) encCtx = (AtomicEncCtx*)malloc(sizeof(AtomicEncCtx)); if (encCtx == NULL) err_sys("AtomicEncCtx malloc failed"); - XMEMSET(encCtx, 0, sizeof(AtomicEncCtx)); + XMEMSET(encCtx, 0, sizeof(AtomicEncCtx)); decCtx = (AtomicDecCtx*)malloc(sizeof(AtomicDecCtx)); if (decCtx == NULL) { free(encCtx); err_sys("AtomicDecCtx malloc failed"); } - XMEMSET(decCtx, 0, sizeof(AtomicDecCtx)); + XMEMSET(decCtx, 0, sizeof(AtomicDecCtx)); wolfSSL_CTX_SetMacEncryptCb(ctx, myMacEncryptCb); wolfSSL_SetMacEncryptCtx(ssl, encCtx);