diff --git a/IDE/IAR-EWARM/Projects/user_settings.h b/IDE/IAR-EWARM/Projects/user_settings.h index 5e4f36e9a..2652f6df1 100644 --- a/IDE/IAR-EWARM/Projects/user_settings.h +++ b/IDE/IAR-EWARM/Projects/user_settings.h @@ -8,6 +8,7 @@ #define NO_DEV_RANDOM #define USE_CERT_BUFFERS_2048 #define WOLFSSL_USER_CURRTIME +#define SIZEOF_LONG_LONG 8 #define CUSTOM_RAND_GENERATE custom_rand_generate /* warning "write a real random seed!!!!, just for testing now" */ diff --git a/src/internal.c b/src/internal.c index e0cf2fb5c..d041268d4 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1423,9 +1423,9 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap) /* In case contexts are held in array and don't want to free actual ctx */ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) { +#ifdef HAVE_CERTIFICATE_STATUS_REQUEST_V2 int i; - - (void)i; +#endif #ifdef HAVE_WOLF_EVENT wolfEventQueue_Free(&ctx->event_queue); @@ -1438,14 +1438,14 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) #ifndef NO_DH XFREE(ctx->serverDH_G.buffer, ctx->heap, DYNAMIC_TYPE_DH); XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH); -#endif +#endif /* !NO_DH */ #ifdef SINGLE_THREADED if (ctx->rng) { wc_FreeRng(ctx->rng); XFREE(ctx->rng, ctx->heap, DYNAMIC_TYPE_RNG); } -#endif +#endif /* SINGLE_THREADED */ #ifndef NO_CERTS FreeDer(&ctx->privateKey); @@ -1455,16 +1455,15 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) if (ctx->ourCert) { XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); } - #endif + #endif /* KEEP_OUR_CERT */ FreeDer(&ctx->certChain); wolfSSL_CertManagerFree(ctx->cm); -#endif +#endif /* !NO_CERTS */ #ifdef HAVE_TLS_EXTENSIONS TLSX_FreeAll(ctx->extensions, ctx->heap); #ifndef NO_WOLFSSL_SERVER - #if defined(HAVE_CERTIFICATE_STATUS_REQUEST) \ || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) if (ctx->certOcspRequest) { @@ -1473,29 +1472,28 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) } #endif -#if defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) +#ifdef HAVE_CERTIFICATE_STATUS_REQUEST_V2 for (i = 0; i < MAX_CHAIN_DEPTH; i++) { if (ctx->chainOcspRequest[i]) { FreeOcspRequest(ctx->chainOcspRequest[i]); XFREE(ctx->chainOcspRequest[i], ctx->heap, DYNAMIC_TYPE_OCSP_REQUEST); } } -#endif - -#endif /* NO_WOLFSSL_SERVER */ +#endif /* HAVE_CERTIFICATE_STATUS_REQUEST_V2 */ +#endif /* !NO_WOLFSSL_SERVER */ #endif /* HAVE_TLS_EXTENSIONS */ + #ifdef WOLFSSL_STATIC_MEMORY if (ctx->heap != NULL) { #ifdef WOLFSSL_HEAP_TEST /* avoid derefrencing a test value */ - if (ctx->heap != (void*)WOLFSSL_HEAP_TEST) { + if (ctx->heap != (void*)WOLFSSL_HEAP_TEST) #endif - WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)(ctx->heap); - wc_FreeMutex(&((WOLFSSL_HEAP*)(hint->memory))->memory_mutex); -#ifdef WOLFSSL_HEAP_TEST + { + WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)(ctx->heap); + wc_FreeMutex(&((WOLFSSL_HEAP*)(hint->memory))->memory_mutex); } -#endif } #endif /* WOLFSSL_STATIC_MEMORY */ } diff --git a/src/ssl.c b/src/ssl.c index 6397d65ab..644320a8e 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -19931,8 +19931,9 @@ WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx) InitDecodedCert(cert, chain->certs[idx].buffer, chain->certs[idx].length, NULL); - if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0) + if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0) { WOLFSSL_MSG("Failed to parse cert"); + } else { x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL, DYNAMIC_TYPE_X509); @@ -20730,7 +20731,7 @@ int wolfSSL_PEM_write_bio_X509(WOLFSSL_BIO *bp, WOLFSSL_X509 *x) { } -#ifndef NO_DH +#if defined(OPENSSL_EXTRA) && !defined(NO_DH) /* Intialize ctx->dh with dh's params. Return SSL_SUCCESS on ok */ long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh) { @@ -20771,7 +20772,7 @@ long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh) return pSz > 0 && gSz > 0 ? ret : SSL_FATAL_ERROR; } -#endif /* NO_DH */ +#endif /* OPENSSL_EXTRA && !NO_DH */ #endif /* HAVE_LIGHTY || HAVE_STUNNEL || WOLFSSL_MYSQL_COMPATIBLE */ diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 067d8b288..01ba38cc6 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3855,9 +3855,9 @@ int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, #ifdef HAVE_COMP_KEY else return wc_ecc_export_x963_compressed(key, out, outLen); -#endif - +#else return NOT_COMPILED_IN; +#endif } #endif /* HAVE_ECC_KEY_EXPORT */ @@ -5221,7 +5221,8 @@ static int add_entry(int idx, ecc_point *g) static int build_lut(int idx, mp_int* a, mp_int* modulus, mp_digit mp, mp_int* mu) { - unsigned x, y, err, bitlen, lut_gap; + int err; + unsigned x, y, bitlen, lut_gap; mp_int tmp; if (mp_init(&tmp) != MP_OKAY) @@ -5367,8 +5368,8 @@ static int accel_fp_mul(int idx, mp_int* k, ecc_point *R, mp_int* a, #else unsigned char kb[KB_SIZE]; #endif - int x; - unsigned y, z = 0, err, bitlen, bitpos, lut_gap, first; + int x, err; + unsigned y, z = 0, bitlen, bitpos, lut_gap, first; mp_int tk, order; if (mp_init_multi(&tk, &order, NULL, NULL, NULL, NULL) != MP_OKAY) @@ -5516,8 +5517,8 @@ static int accel_fp_mul2add(int idx1, int idx2, #else unsigned char kb[2][KB_SIZE]; #endif - int x; - unsigned y, z, err, bitlen, bitpos, lut_gap, first, zA, zB; + int x, err; + unsigned y, z, bitlen, bitpos, lut_gap, first, zA, zB; mp_int tka, tkb, order; if (mp_init_multi(&tka, &tkb, &order, NULL, NULL, NULL) != MP_OKAY) diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index ba96866e7..0519f8351 100644 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -812,13 +812,13 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz, return BAD_FUNC_ARG; #ifdef WOLFSSL_SMALL_STACK - tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); + tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) return MEMORY_E; - prk = (byte*)XMALLOC(MAX_DIGEST_SIZE, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); + prk = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (prk == NULL) { - XFREE(tmp, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } #endif @@ -870,8 +870,8 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz, } #ifdef WOLFSSL_SMALL_STACK - XFREE(tmp, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); - XFREE(prk, myHmac.heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(prk, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c index a0581fe35..e1df3277c 100644 --- a/wolfcrypt/src/misc.c +++ b/wolfcrypt/src/misc.c @@ -50,6 +50,12 @@ #else + +#if defined(__ICCARM__) + #include +#endif + + #ifdef INTEL_INTRINSICS #include /* get intrinsic definitions */ diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 942d27f51..096d4c178 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -3562,9 +3562,9 @@ static int wc_PKCS7_DecodeUnprotectedAttributes(PKCS7* pkcs7, byte* pkiMsg, /* save attribute value bytes and size */ if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0) { - return ASN_PARSE_E; XFREE(attrib->oid, pkcs7->heap, DYNAMIC_TYPE_PKCS); XFREE(attrib, pkcs7->heap, DYNAMIC_TYPE_PKCS); + return ASN_PARSE_E; } if ((pkiMsgSz - idx) < (word32)length) {