diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 08d022781..fe55a680f 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -32,7 +32,8 @@ /* Macro to disable benchmark */ #ifndef NO_CRYPT_BENCHMARK -#ifdef XMALLOC_USER +#if defined(XMALLOC_USER) || defined(FREESCALE_MQX) + /* MQX classic needs for EXIT_FAILURE */ #include /* we're using malloc / free direct here */ #endif diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index 15ce6fa2d..e498bc300 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -149,6 +149,8 @@ static void wolfssl_log(const int logLevel, const char *const logMessage) #elif defined(WOLFSSL_UTASKER) fnDebugMsg((char*)logMessage); fnDebugMsg("\r\n"); +#elif defined(MQX_USE_IO_OLD) + fprintf(_mqxio_stderr, "%s\n", logMessage); #else fprintf(stderr, "%s\n", logMessage); #endif diff --git a/wolfcrypt/src/pkcs12.c b/wolfcrypt/src/pkcs12.c index c233645bb..b7f56e3ac 100644 --- a/wolfcrypt/src/pkcs12.c +++ b/wolfcrypt/src/pkcs12.c @@ -886,6 +886,9 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, case WC_PKCS12_ShroudedKeyBag: /* 668 */ { byte* k; + #ifdef FREESCALE_MQX + byte* tmp; + #endif WOLFSSL_MSG("PKCS12 Shrouded Key Bag found"); if (data[idx++] != (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC)) { @@ -911,11 +914,24 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, if (ret < size) { /* shrink key buffer */ + #ifdef FREESCALE_MQX + /* MQX classic has no realloc */ + tmp = (byte*)XMALLOC(ret, pkcs12->heap, + DYNAMIC_TYPE_PUBLIC_KEY); + if (tmp == NULL) { + XFREE(k, pkcs12->heap, DYNAMIC_TYPE_PUBLIC_KEY); + ERROR_OUT(MEMORY_E, exit_pk12par); + } + XMEMCPY(tmp, k, ret); + XFREE(k, pkcs12->heap, DYNAMIC_TYPE_PUBLIC_KEY); + k = tmp; + #else k = (byte*)XREALLOC(k, ret, pkcs12->heap, DYNAMIC_TYPE_PUBLIC_KEY); if (k == NULL) { ERROR_OUT(MEMORY_E, exit_pk12par); } + #endif } size = ret; diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 8829fbdcc..634eb35aa 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -686,6 +686,7 @@ extern void uITRON4_free(void *p) ; #include "mfs.h" #if MQX_USE_IO_OLD #include "fio.h" + #define NO_STDIO_FILESYSTEM #else #include "nio.h" #endif @@ -694,6 +695,7 @@ extern void uITRON4_free(void *p) ; #include "mutex.h" #endif + #define XMALLOC_OVERRIDE #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s)) #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));} /* Note: MQX has no realloc, using fastmath above */ @@ -804,7 +806,8 @@ extern void uITRON4_free(void *p) ; #ifdef FREESCALE_KSDK_1_3 #include "fsl_device_registers.h" - #else + #elif !defined(FREESCALE_MQX) + /* Classic MQX does not have fsl_common.h */ #include "fsl_common.h" #endif