From 1542482cd5f1550efb5423ff5e06a8f3c170877a Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 18 Nov 2019 12:14:34 -0800 Subject: [PATCH] Cleanup of the MQX file headers for STDIO. Cleanup of fio.h and nio.h includes to use wc_port.h. ZD 9453. --- src/internal.c | 8 +------- src/keys.c | 9 +-------- src/tls13.c | 13 ------------- wolfcrypt/benchmark/benchmark.c | 8 ++------ wolfcrypt/src/asn.c | 15 +-------------- wolfcrypt/src/integer.c | 9 +-------- wolfcrypt/src/logging.c | 7 +------ wolfcrypt/test/test.c | 7 ++----- wolfssl/ssl.h | 10 ---------- wolfssl/wolfcrypt/settings.h | 11 +++++++++-- wolfssl/wolfcrypt/wc_port.h | 22 +++++++++++++++++++++- 11 files changed, 39 insertions(+), 80 deletions(-) diff --git a/src/internal.c b/src/internal.c index ef64900dd..699b55840 100644 --- a/src/internal.c +++ b/src/internal.c @@ -65,13 +65,7 @@ #if defined(DEBUG_WOLFSSL) || defined(SHOW_SECRETS) || \ defined(CHACHA_AEAD_TEST) || defined(WOLFSSL_SESSION_EXPORT_DEBUG) - #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif - #else + #ifndef NO_STDIO_FILESYSTEM #include #endif #endif diff --git a/src/keys.c b/src/keys.c index c1cf23496..27f2e8fc5 100644 --- a/src/keys.c +++ b/src/keys.c @@ -33,13 +33,7 @@ #include #include #if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) - #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif - #else + #ifndef NO_STDIO_FILESYSTEM #include #endif #endif @@ -3659,4 +3653,3 @@ int MakeMasterSecret(WOLFSSL* ssl) } #endif /* WOLFCRYPT_ONLY */ - diff --git a/src/tls13.c b/src/tls13.c index c5939b507..a94a0d0bc 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -106,19 +106,6 @@ #include "libntruencrypt/ntru_crypto.h" #endif -#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG) || \ - defined(CHACHA_AEAD_TEST) || defined(WOLFSSL_SESSION_EXPORT_DEBUG) - #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif - #else - #include - #endif -#endif - #ifdef __sun #include #endif diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index af3da627c..4fc53aa47 100755 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -29,6 +29,7 @@ #include #include +#include /* Macro to disable benchmark */ #ifndef NO_CRYPT_BENCHMARK @@ -48,11 +49,7 @@ /* printf mappings */ #ifdef FREESCALE_MQX #include - #if MQX_USE_IO_OLD - #include - #else - #include - #endif + /* see wc_port.h for fio.h and nio.h includes */ #elif defined(FREESCALE_KSDK_1_3) #include "fsl_debug_console.h" #include "fsl_os_abstraction.h" @@ -93,7 +90,6 @@ #include #include #include - #include "wolfssl/wolfcrypt/wc_port.h" /* for m2mb headers */ #include "m2m_log.h" /* for M2M_LOG_INFO - not standard API */ /* remap printf */ #undef printf diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index fe1635a70..4874cd1a6 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -116,19 +116,6 @@ extern int wc_InitRsaHw(RsaKey* key); #include #endif -#ifdef WOLFSSL_DEBUG_ENCODING - #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif - #else - #include - #endif -#endif - - #ifdef _MSC_VER /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */ #pragma warning(disable: 4996) @@ -7191,7 +7178,7 @@ static int DecodeBasicCaConstraint(const byte* input, int sz, DecodedCert* cert) cert->isCA = FALSE; } else return ret; } else - cert->isCA = (byte)ret; + cert->isCA = (byte)ret; #endif /* If there isn't any more data, return. */ diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index e94c36e11..5c9c232d1 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -63,13 +63,7 @@ #endif #ifdef SHOW_GEN - #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif - #else + #ifndef NO_STDIO_FILESYSTEM #include #endif #endif @@ -5288,4 +5282,3 @@ void mp_dump(const char* desc, mp_int* a, byte verbose) #endif /* USE_FAST_MATH */ #endif /* NO_BIG_INT */ - diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index d86a727c1..ec910f6ec 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -201,11 +201,7 @@ void WOLFSSL_TIME(int count) #ifdef DEBUG_WOLFSSL #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif + /* see wc_port.h for fio.h and nio.h includes */ #elif defined(WOLFSSL_SGX) /* Declare sprintf for ocall */ int sprintf(char* buf, const char *fmt, ...); @@ -798,4 +794,3 @@ void wc_ERR_print_errors_fp(XFILE fp) #endif /* !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) */ #endif /* defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) */ - diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index a64f07ed9..b39e63dc9 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -26,6 +26,7 @@ #include #include +#include #ifndef NO_CRYPT_TEST @@ -47,11 +48,7 @@ #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #include #include - #if MQX_USE_IO_OLD - #include - #else - #include - #endif + /* see wc_port.h for fio.h and nio.h includes */ #elif defined(FREESCALE_KSDK_BM) #include "fsl_debug_console.h" #undef printf diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 425697535..bca5a98cb 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -42,16 +42,6 @@ /* used internally by wolfSSL while OpenSSL types aren't */ #include -#ifndef NO_FILESYSTEM - #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) - #if MQX_USE_IO_OLD - #include - #else - #include - #endif - #endif -#endif - #ifdef WOLFSSL_PREFIX #include "prefix_ssl.h" #endif diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 7fc294862..b8b661b36 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -875,6 +875,11 @@ extern void uITRON4_free(void *p) ; #define TFM_TIMING_RESISTANT #endif +#ifdef FREESCALE_MQX_5_0 + /* use normal Freescale MQX port, but with minor changes for 5.0 */ + #define FREESCALE_MQX +#endif + #ifdef FREESCALE_MQX_4_0 /* use normal Freescale MQX port, but with minor changes for 4.0 */ #define FREESCALE_MQX @@ -885,7 +890,8 @@ extern void uITRON4_free(void *p) ; #include "mqx.h" #ifndef NO_FILESYSTEM #include "mfs.h" - #if MQX_USE_IO_OLD + #if (defined(MQX_USE_IO_OLD) && MQX_USE_IO_OLD) || \ + defined(FREESCALE_MQX_5_0) #include "fio.h" #define NO_STDIO_FILESYSTEM #else @@ -908,7 +914,8 @@ extern void uITRON4_free(void *p) ; #define FREESCALE_COMMON #include #ifndef NO_FILESYSTEM - #if MQX_USE_IO_OLD + #if (defined(MQX_USE_IO_OLD) && MQX_USE_IO_OLD) || \ + defined(FREESCALE_MQX_5_0) #include #else #include diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index a3380a5dc..bb2a9037c 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -42,6 +42,20 @@ #endif #endif + +/* GENERIC INCLUDE SECTION */ +#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) + #include + #if (defined(MQX_USE_IO_OLD) && MQX_USE_IO_OLD) || \ + defined(FREESCALE_MQX_5_0) + #include + #else + #include + #endif +#endif + + +/* THREADING/MUTEX SECTION */ #ifdef USE_WINDOWS_API #ifdef WOLFSSL_GAME_BUILD #include "system/xtl.h" @@ -273,6 +287,8 @@ WOLFSSL_API int wc_SetMutexCb(mutex_cb* cb); WOLFSSL_API int wolfCrypt_Init(void); WOLFSSL_API int wolfCrypt_Cleanup(void); + +/* FILESYSTEM SECTION */ /* filesystem abstraction layer, used by ssl.c */ #ifndef NO_FILESYSTEM @@ -467,6 +483,8 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #endif /* !NO_FILESYSTEM */ + +/* MIN/MAX MACRO SECTION */ /* Windows API defines its own min() macro. */ #if defined(USE_WINDOWS_API) #if defined(min) || defined(WOLFSSL_MYSQL_COMPATIBLE) @@ -477,6 +495,8 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #endif /* max */ #endif /* USE_WINDOWS_API */ + +/* TIME SECTION */ /* Time functions */ #ifndef NO_ASN_TIME #if defined(USER_TIME) @@ -715,6 +735,7 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #endif #endif /* NO_ASN_TIME */ + #ifndef WOLFSSL_LEANPSK char* mystrnstr(const char* s1, const char* s2, unsigned int n); #endif @@ -749,4 +770,3 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #endif #endif /* WOLF_CRYPT_PORT_H */ -