From a56fe30c2cb8e8b4afc6e2205eb0f5033c75657e Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 14 Jun 2023 14:20:16 -0700 Subject: [PATCH 1/3] Fixes and cleanups for Keil MDK examples. Combine duplicate user_settings.h. Use SP math all by default. Disable old/deprecated algorithms. Add CMSIS RTOS timer support for TLS and benchmark. --- .../MDK-ARM/wolfSSL/config-BARE-METAL.h | 73 ++- IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h | 70 ++- .../MDK-ARM/wolfSSL/config-RTX-TCP-FS.h | 72 ++- IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c | 2 +- IDE/MDK5-ARM/Conf/user_settings.h | 94 +++- IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h | 4 +- .../CryptBenchmark/CryptBenchmark.uvoptx | 2 +- .../CryptBenchmark/CryptBenchmark.uvprojx | 6 +- .../RTE/wolfSSL/user_settings.h | 497 ------------------ IDE/MDK5-ARM/Projects/CryptBenchmark/main.c | 91 ++-- .../Projects/CryptTest/CryptTest.uvoptx | 2 +- .../Projects/CryptTest/CryptTest.uvprojx | 12 +- .../CryptTest/RTE/wolfSSL/user_settings.h | 497 ------------------ IDE/MDK5-ARM/Projects/CryptTest/main.c | 66 +-- .../Projects/EchoClient/EchoClient.uvoptx | 2 +- .../Projects/EchoClient/EchoClient.uvprojx | 4 +- .../EchoClient/RTE/wolfSSL/user_settings.h | 495 ----------------- IDE/MDK5-ARM/Projects/EchoClient/main.c | 68 +-- .../Projects/EchoServer/EchoServer.uvoptx | 2 +- .../Projects/EchoServer/EchoServer.uvprojx | 4 +- .../EchoServer/RTE/wolfSSL/user_settings.h | 497 ------------------ IDE/MDK5-ARM/Projects/EchoServer/main.c | 108 ++-- .../SimpleClient/RTE/wolfSSL/user_settings.h | 497 ------------------ .../Projects/SimpleClient/SimpleClient.uvoptx | 2 +- .../SimpleClient/SimpleClient.uvprojx | 4 +- IDE/MDK5-ARM/Projects/SimpleClient/main.c | 116 ++-- .../SimpleServer/RTE/wolfSSL/user_settings.h | 497 ------------------ .../Projects/SimpleServer/SimpleServer.uvoptx | 2 +- .../SimpleServer/SimpleServer.uvprojx | 4 +- IDE/MDK5-ARM/Projects/SimpleServer/main.c | 73 +-- IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c | 48 +- .../Projects/wolfSSL-Full/wolfsslFull.uvoptx | 2 +- .../Projects/wolfSSL-Full/wolfsslFull.uvprojx | 4 +- .../wolfSSL-Lib/RTE/wolfSSL/user_settings.h | 497 ------------------ .../Projects/wolfSSL-Lib/wolfSSL-Lib.uvoptx | 2 +- .../Projects/wolfSSL-Lib/wolfSSL-Lib.uvprojx | 4 +- IDE/MDK5-ARM/README.md | 54 ++ IDE/MDK5-ARM/Src/ssl-dummy.c | 4 +- IDE/MDK5-ARM/include.am | 9 + IDE/include.am | 3 +- src/internal.c | 7 + src/tls13.c | 16 + wolfcrypt/benchmark/benchmark.c | 8 + 43 files changed, 658 insertions(+), 3863 deletions(-) delete mode 100644 IDE/MDK5-ARM/Projects/CryptBenchmark/RTE/wolfSSL/user_settings.h delete mode 100644 IDE/MDK5-ARM/Projects/CryptTest/RTE/wolfSSL/user_settings.h delete mode 100644 IDE/MDK5-ARM/Projects/EchoClient/RTE/wolfSSL/user_settings.h delete mode 100644 IDE/MDK5-ARM/Projects/EchoServer/RTE/wolfSSL/user_settings.h delete mode 100644 IDE/MDK5-ARM/Projects/SimpleClient/RTE/wolfSSL/user_settings.h delete mode 100644 IDE/MDK5-ARM/Projects/SimpleServer/RTE/wolfSSL/user_settings.h delete mode 100644 IDE/MDK5-ARM/Projects/wolfSSL-Lib/RTE/wolfSSL/user_settings.h create mode 100644 IDE/MDK5-ARM/README.md create mode 100644 IDE/MDK5-ARM/include.am diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h index 1d882ca90..5fc432ce2 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h @@ -165,7 +165,7 @@ #endif // // DSA -#define MDK_CONF_DSA 1 +#define MDK_CONF_DSA 0 #if MDK_CONF_DSA == 0 #define NO_DSA #endif @@ -204,6 +204,60 @@ // // +// Math / Memory +// Math Library +// <0=>SP Math All (sp_int.c) +// <1=>Fast Math (tfm.c) +// <2=>Heap Math (integer.c) +// <3=>SP Math (RSA/DH 2048/3072/4096 and ECC 256/384/521 only) +// <4=>SP Math +ASM (faster) +#define MDK_CONF_MATH 0 +#if MDK_CONF_MATH == 0 + #define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */ +#elif MDK_CONF_MATH == 1 + #define USE_FAST_MATH +#elif MDK_CONF_MATH == 2 + #define USE_INTEGER_HEAP_MATH +#elif MDK_CONF_MATH == 3 || MDK_CONF_MATH == 4 + #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */ + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_DH + #define WOLFSSL_HAVE_SP_ECC + + //#define WOLFSSL_SP_NO_2048 + //#define WOLFSSL_SP_NO_3072 + #define WOLFSSL_SP_4096 + //#define WOLFSSL_SP_NO_256 + //#define WOLFSSL_SP_384 + //#define WOLFSSL_SP_521 + + #define WOLFSSL_SP_SMALL /* use smaller version of code */ + //#define WOLFSSL_SP_NO_MALLOC /* do not use heap */ + //#define WOLFSSL_SP_CACHE_RESISTANT + //#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */ + + #if MDK_CONF_MATH == 4 + /* SP Assembly Speedups - specific to chip type */ + #define WOLFSSL_SP_ASM + + //#define WOLFSSL_SP_ARM32_ASM + //#define WOLFSSL_SP_ARM64_ASM + //#define WOLFSSL_SP_ARM_THUMB_ASM + //#define WOLFSSL_SP_ARM_CORTEX_M_ASM + #endif +#endif + +// Small Stack +#define MDK_CONF_SmallStack 1 +#if MDK_CONF_SmallStack == 0 + #define NO_WOLFSSL_SMALL_STACK + //#define WOLFSSL_SP_NO_MALLOC +#else + #define WOLFSSL_SMALL_STACK +#endif +// +// + // Others // Inline @@ -253,22 +307,9 @@ #define NO_ERROR_STRINGS #endif // - -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// -// Use Fast Math -#define MDK_CONF_FASTMATH 0 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#endif -// - - // + + // // <<< end of configuration section >>> diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h index 256fff09c..51ddbae9b 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h @@ -202,7 +202,7 @@ #endif // // DSA -#define MDK_CONF_DSA 1 +#define MDK_CONF_DSA 0 #if MDK_CONF_DSA == 0 #define NO_DSA #endif @@ -241,6 +241,60 @@ // // +// Math / Memory +// Math Library +// <0=>SP Math All (sp_int.c) +// <1=>Fast Math (tfm.c) +// <2=>Heap Math (integer.c) +// <3=>SP Math (RSA/DH 2048/3072/4096 and ECC 256/384/521 only) +// <4=>SP Math +ASM (faster) +#define MDK_CONF_MATH 0 +#if MDK_CONF_MATH == 0 + #define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */ +#elif MDK_CONF_MATH == 1 + #define USE_FAST_MATH +#elif MDK_CONF_MATH == 2 + #define USE_INTEGER_HEAP_MATH +#elif MDK_CONF_MATH == 3 || MDK_CONF_MATH == 4 + #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */ + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_DH + #define WOLFSSL_HAVE_SP_ECC + + //#define WOLFSSL_SP_NO_2048 + //#define WOLFSSL_SP_NO_3072 + #define WOLFSSL_SP_4096 + //#define WOLFSSL_SP_NO_256 + //#define WOLFSSL_SP_384 + //#define WOLFSSL_SP_521 + + #define WOLFSSL_SP_SMALL /* use smaller version of code */ + //#define WOLFSSL_SP_NO_MALLOC /* do not use heap */ + //#define WOLFSSL_SP_CACHE_RESISTANT + //#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */ + + #if MDK_CONF_MATH == 4 + /* SP Assembly Speedups - specific to chip type */ + #define WOLFSSL_SP_ASM + + //#define WOLFSSL_SP_ARM32_ASM + //#define WOLFSSL_SP_ARM64_ASM + //#define WOLFSSL_SP_ARM_THUMB_ASM + //#define WOLFSSL_SP_ARM_CORTEX_M_ASM + #endif +#endif + +// Small Stack +#define MDK_CONF_SmallStack 1 +#if MDK_CONF_SmallStack == 0 + #define NO_WOLFSSL_SMALL_STACK + //#define WOLFSSL_SP_NO_MALLOC +#else + #define WOLFSSL_SMALL_STACK +#endif +// +// + // Others // Inline @@ -291,20 +345,6 @@ #endif // -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// -// Use Fast Math -#define MDK_CONF_FASTMATH 0 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#endif -// - - // // diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h index 11f1de7e0..e693713c9 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h @@ -224,7 +224,7 @@ #endif // // DSA -#define MDK_CONF_DSA 1 +#define MDK_CONF_DSA 0 #if MDK_CONF_DSA == 0 #define NO_DSA #endif @@ -263,6 +263,60 @@ // // +// Math / Memory +// Math Library +// <0=>SP Math All (sp_int.c) +// <1=>Fast Math (tfm.c) +// <2=>Heap Math (integer.c) +// <3=>SP Math (RSA/DH 2048/3072/4096 and ECC 256/384/521 only) +// <4=>SP Math +ASM (faster) +#define MDK_CONF_MATH 0 +#if MDK_CONF_MATH == 0 + #define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */ +#elif MDK_CONF_MATH == 1 + #define USE_FAST_MATH +#elif MDK_CONF_MATH == 2 + #define USE_INTEGER_HEAP_MATH +#elif MDK_CONF_MATH == 3 || MDK_CONF_MATH == 4 + #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */ + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_DH + #define WOLFSSL_HAVE_SP_ECC + + //#define WOLFSSL_SP_NO_2048 + //#define WOLFSSL_SP_NO_3072 + #define WOLFSSL_SP_4096 + //#define WOLFSSL_SP_NO_256 + //#define WOLFSSL_SP_384 + //#define WOLFSSL_SP_521 + + #define WOLFSSL_SP_SMALL /* use smaller version of code */ + //#define WOLFSSL_SP_NO_MALLOC /* do not use heap */ + //#define WOLFSSL_SP_CACHE_RESISTANT + //#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */ + + #if MDK_CONF_MATH == 4 + /* SP Assembly Speedups - specific to chip type */ + #define WOLFSSL_SP_ASM + + //#define WOLFSSL_SP_ARM32_ASM + //#define WOLFSSL_SP_ARM64_ASM + //#define WOLFSSL_SP_ARM_THUMB_ASM + //#define WOLFSSL_SP_ARM_CORTEX_M_ASM + #endif +#endif + +// Small Stack +#define MDK_CONF_SmallStack 1 +#if MDK_CONF_SmallStack == 0 + #define NO_WOLFSSL_SMALL_STACK + //#define WOLFSSL_SP_NO_MALLOC +#else + #define WOLFSSL_SMALL_STACK +#endif +// +// + // Others // Inline @@ -312,22 +366,6 @@ #define NO_ERROR_STRINGS #endif // - -// Small Stack -#define MDK_CONF_SMALL_STACK 1 -#if MDK_CONF_SMALL_STACK == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// - - // // diff --git a/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c b/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c index b4d20bba8..de71e9941 100644 --- a/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c +++ b/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c @@ -99,7 +99,7 @@ extern void benchmark_test(void) ; extern void SER_Init(void) ; /*----------------------------------------------------------------------------- - * mian entry + * main entry *----------------------------------------------------------------------------*/ /*** This is the parent task entry ***/ diff --git a/IDE/MDK5-ARM/Conf/user_settings.h b/IDE/MDK5-ARM/Conf/user_settings.h index 6aecf095e..eb1b3b9b4 100644 --- a/IDE/MDK5-ARM/Conf/user_settings.h +++ b/IDE/MDK5-ARM/Conf/user_settings.h @@ -21,21 +21,20 @@ #define NO_MAIN_DRIVER #define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME #define SIZEOF_LONG_LONG 8 #define NO_WRITEV #define NO_DEV_RANDOM +#define WOLFSSL_IGNORE_FILE_WARN #define TFM_TIMING_RESISTANT #define ECC_TIMING_RESISTANT #define WC_RSA_BLINDING #define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ +#define WOLFSSL_CURRTIME_OSTICK /* use OS tick for current_time */ #define WOLFSSL_GMTIME - #define NO_MULTIBYTE_PRINT + // <<< Use Configuration Wizard in Context Menu >>> @@ -99,7 +98,7 @@ // File System -#define MDK_CONF_FILESYSTEM 1 +#define MDK_CONF_FILESYSTEM 0 #if MDK_CONF_FILESYSTEM == 0 #define NO_FILESYSTEM #else @@ -109,7 +108,9 @@ // // Network<0=>None <1=>RLnet <2=>User I/O +#ifndef MDK_CONF_NETWORK #define MDK_CONF_NETWORK 1 +#endif #if MDK_CONF_NETWORK == 0 #elif MDK_CONF_NETWORK == 1 #define WOLFSSL_KEIL_TCP_NET @@ -150,7 +151,7 @@ // wolfCrypt Configuration -// Hash/Crypt Algrithm +// Hash/Crypt Algorithm // MD2 #define MDK_CONF_MD2 0 @@ -201,7 +202,7 @@ #endif // // RIPEMD -#define MDK_CONF_RIPEMD 1 +#define MDK_CONF_RIPEMD 0 #if MDK_CONF_RIPEMD == 1 #define WOLFSSL_RIPEMD #endif @@ -275,7 +276,7 @@ // // CAMELLIA -#define MDK_CONF_CAMELLIA 1 +#define MDK_CONF_CAMELLIA 0 #if MDK_CONF_CAMELLIA == 1 #define HAVE_CAMELLIA #endif @@ -287,8 +288,19 @@ #define NO_DH #endif // + +// RSA +#define MDK_CONF_RSA 1 +#if MDK_CONF_RSA == 1 +/* #define RSA_LOW_MEM */ +#else +#define NO_RSA +#endif +// + + // DSA -#define MDK_CONF_DSA 1 +#define MDK_CONF_DSA 0 #if MDK_CONF_DSA == 0 #define NO_DSA #endif @@ -297,7 +309,7 @@ // SRP #define MDK_CONF_SRP 1 #if MDK_CONF_SRP == 1 -#define HAVE_SRP +#define WOLFCRYPT_HAVE_SRP #endif // @@ -412,7 +424,7 @@ // // -// Cert/Key Strage +// Cert/Key Storage // Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) #define MDK_CONF_CERT_BUFF 0 #if MDK_CONF_CERT_BUFF== 1 @@ -432,25 +444,64 @@ #define MDK_CONF_KEY_GEN 0 #if MDK_CONF_KEY_GEN == 1 #define WOLFSSL_KEY_GEN +#define WOLFSSL_OLD_PRIME_CHECK /* use older prime check (faster) */ #endif // // -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT + +// Math / Memory +// Math Library +// <0=>SP Math All (sp_int.c) +// <1=>Fast Math (tfm.c) +// <2=>Heap Math (integer.c) +// <3=>SP Math (RSA/DH 2048/3072/4096 and ECC 256/384/521 only) +// <4=>SP Math +ASM (faster) +#define MDK_CONF_MATH 0 +#if MDK_CONF_MATH == 0 + #define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */ +#elif MDK_CONF_MATH == 1 + #define USE_FAST_MATH +#elif MDK_CONF_MATH == 2 + #define USE_INTEGER_HEAP_MATH +#elif MDK_CONF_MATH == 3 || MDK_CONF_MATH == 4 + #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */ + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_DH + #define WOLFSSL_HAVE_SP_ECC + + //#define WOLFSSL_SP_NO_2048 + //#define WOLFSSL_SP_NO_3072 + #define WOLFSSL_SP_4096 + //#define WOLFSSL_SP_NO_256 + //#define WOLFSSL_SP_384 + //#define WOLFSSL_SP_521 + + #define WOLFSSL_SP_SMALL /* use smaller version of code */ + //#define WOLFSSL_SP_NO_MALLOC /* do not use heap */ + //#define WOLFSSL_SP_CACHE_RESISTANT + //#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */ + + #if MDK_CONF_MATH == 4 + /* SP Assembly Speedups - specific to chip type */ + #define WOLFSSL_SP_ASM + + //#define WOLFSSL_SP_ARM32_ASM + //#define WOLFSSL_SP_ARM64_ASM + //#define WOLFSSL_SP_ARM_THUMB_ASM + //#define WOLFSSL_SP_ARM_CORTEX_M_ASM + #endif #endif -// + // Small Stack #define MDK_CONF_SmallStack 1 #if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK + #define NO_WOLFSSL_SMALL_STACK +#else + #define WOLFSSL_SMALL_STACK #endif -// - +// +// // - /**** wolfSSL Configuration ****/ @@ -465,6 +516,7 @@ #define WC_RSA_PSS #define HAVE_HKDF #define HAVE_FFDHE_2048 +//#define HAVE_FFDHE_3072 #endif // diff --git a/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h b/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h index 673d45376..e6d314a77 100644 --- a/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h +++ b/IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h @@ -1,4 +1,4 @@ -/* wolfssl_KEIL_ARM.h +/* wolfssl_MDK_ARM.h * * Copyright (C) 2006-2023 wolfSSL Inc. * @@ -70,7 +70,7 @@ typedef int socklen_t ; #define tcp_listen wolfssl_tcp_listen #define connect(a,b,c) connect(a, (SOCKADDR *)(b), c) #define SOCKADDR struct sockaddr - + /** KEIL-RL TCPnet ****/ /* TCPnet BSD socket does not have following functions. */ extern char *inet_ntoa(struct in_addr in); diff --git a/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvoptx b/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvoptx index e598c5563..2b06bcce0 100644 --- a/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvoptx +++ b/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvoptx @@ -233,7 +233,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvprojx b/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvprojx index 095377e60..3ef1956d1 100644 --- a/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvprojx +++ b/IDE/MDK5-ARM/Projects/CryptBenchmark/CryptBenchmark.uvprojx @@ -334,7 +334,7 @@ 0 - USE_STM32756G_EVAL USE_IOEXPANDER WOLFSSL_USER_SETTINGS + USE_STM32756G_EVAL USE_IOEXPANDER WOLFSSL_USER_SETTINGS MDK_CONF_NETWORK=0 @@ -383,7 +383,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -791,7 +791,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/CryptBenchmark/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/CryptBenchmark/RTE/wolfSSL/user_settings.h deleted file mode 100644 index f206ad222..000000000 --- a/IDE/MDK5-ARM/Projects/CryptBenchmark/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,497 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define WOLFSSL_MDK5_COMPLv5 -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS<4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet<9=>MQX -// <10=>T-RTOS <11=>uITRON4<12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS<15=>CMSIS RTOSv2<16=>Others -#define MDK_CONF_THREAD 15 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define WOLFSSL_CMSIS_RTOSv2 -#elif MDK_CONF_THREAD == 16 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 0 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c b/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c index 002677f67..1b055e7fa 100644 --- a/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c +++ b/IDE/MDK5-ARM/Projects/CryptBenchmark/main.c @@ -37,11 +37,11 @@ #endif /* Dummy definition for test RTC */ -#define RTC_YEAR 2019 +#define RTC_YEAR 2023 #define RTC_MONTH 1 -#define RTC_DAY 1 +#define RTC_DAY 1 #define RTC_MONTH 1 -#define RTC_DAY 1 +#define RTC_DAY 1 #if defined(STM32F7xx) #include "stm32f7xx_hal.h" @@ -72,22 +72,22 @@ extern uint32_t os_time; uint32_t HAL_GetTick(void) { - #if defined(WOLFSSL_CMSIS_RTOS) - return os_time; - #elif defined(WOLFSSL_CMSIS_RTOSv2) - return osKernelGetTickCount(); - #endif + #if defined(WOLFSSL_CMSIS_RTOS) + return os_time; + #elif defined(WOLFSSL_CMSIS_RTOSv2) + return osKernelGetTickCount(); + #endif } double current_time(int reset) { if (reset) return 0; - #if defined(WOLFSSL_CMSIS_RTOS) - return (double)os_time / 1000.0; - #elif defined(WOLFSSL_CMSIS_RTOSv2) - return (double)osKernelGetTickCount() / 1000.0; - #endif +#if defined(WOLFSSL_CMSIS_RTOS) + return (double)os_time / 1000.0; +#elif defined(WOLFSSL_CMSIS_RTOSv2) + return (double)osKernelGetTickCount() / 1000.0; +#endif } #else @@ -96,28 +96,28 @@ double current_time(int reset) #define DWT ((DWT_Type *) (0xE0001000UL) ) typedef struct { - uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ } DWT_Type; -extern uint32_t SystemCoreClock ; +extern uint32_t SystemCoreClock; double current_time(int reset) { - if(reset) DWT->CYCCNT = 0 ; - return ((double)DWT->CYCCNT/SystemCoreClock) ; + if (reset) DWT->CYCCNT = 0; + return ((double)DWT->CYCCNT/SystemCoreClock); } #endif static time_t epochTime; time_t time(time_t *t) { - return epochTime; + return epochTime; } void setTime(time_t t) { - epochTime = t; + epochTime = t; } /*----------------------------------------------------------------------------- @@ -126,48 +126,51 @@ void setTime(time_t t) #if !defined(NO_FILESYSTEM) #include "rl_fs.h" /* FileSystem definitions */ -static void init_filesystem (void) { - int32_t retv; +static void init_filesystem(void) +{ + int32_t retv; - retv = finit ("M0:"); - if (retv == fsOK) { - retv = fmount ("M0:"); + retv = finit ("M0:"); if (retv == fsOK) { - printf ("Drive M0 ready!\n"); + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed(%d)!\n", retv); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif /*----------------------------------------------------------------------------- - * mian entry + * main entry *----------------------------------------------------------------------------*/ -void benchmark_test(void *arg) ; +void benchmark_test(void *arg); int main() { - void * arg = NULL ; - - MPU_Config(); + void * arg = NULL; + + MPU_Config(); CPU_CACHE_Enable(); HAL_Init(); /* Initialize the HAL Library */ SystemClock_Config(); /* Configure the System Clock */ - #if !defined(NO_FILESYSTEM) +#if !defined(NO_FILESYSTEM) init_filesystem (); - #endif - - setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60); +#endif - printf("=== Start: Crypt Benchmark ===\n") ; - benchmark_test(arg) ; - printf("=== End: Crypt Benchmark ===\n") ; + setTime((RTC_YEAR-1970)*365*24*60*60 + + RTC_MONTH*30*24*60*60 + + RTC_DAY*24*60*60); + printf("=== Start: Crypt Benchmark ===\n"); + benchmark_test(arg); + printf("=== End: Crypt Benchmark ===\n"); + + return 0; } - diff --git a/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvoptx b/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvoptx index e3db5d534..59202259c 100644 --- a/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvoptx +++ b/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvoptx @@ -298,7 +298,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvprojx b/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvprojx index 8e4dcd595..6c1d17fe5 100644 --- a/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvprojx +++ b/IDE/MDK5-ARM/Projects/CryptTest/CryptTest.uvprojx @@ -334,7 +334,7 @@ 0 - USE_STM32756G_EVAL USE_IOEXPANDER WOLFSSL_USER_SETTINGS + USE_STM32756G_EVAL USE_IOEXPANDER WOLFSSL_USER_SETTINGS MDK_CONF_NETWORK=0 @@ -413,7 +413,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -760,14 +760,8 @@ - - RTE\wolfSSL\config-Crypt.h - - - - - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/CryptTest/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/CryptTest/RTE/wolfSSL/user_settings.h deleted file mode 100644 index 80af5e2f7..000000000 --- a/IDE/MDK5-ARM/Projects/CryptTest/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,497 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS <4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet <9=>MQX -// <10=>T-RTOS <11=>uITRON4 <12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS <15=>CMSIS RTOSv2 <16=>Others -#define MDK_CONF_THREAD 15 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define WOLFSSL_CMSIS_RTOSv2 -#elif MDK_CONF_THREAD == 16 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 0 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/CryptTest/main.c b/IDE/MDK5-ARM/Projects/CryptTest/main.c index 3222cc5da..6425e654e 100644 --- a/IDE/MDK5-ARM/Projects/CryptTest/main.c +++ b/IDE/MDK5-ARM/Projects/CryptTest/main.c @@ -34,9 +34,9 @@ #include "cmsis_os2.h" #endif /* Dummy definition for test RTC */ -#define RTC_YEAR 2019 +#define RTC_YEAR 2023 #define RTC_MONTH 1 -#define RTC_DAY 1 +#define RTC_DAY 1 #if defined(STM32F7xx) #include "stm32f7xx_hal.h" @@ -65,19 +65,19 @@ extern uint32_t os_time; #endif uint32_t HAL_GetTick(void) { - #if defined(WOLFSSL_CMSIS_RTOS) - return os_time; - #elif defined(WOLFSSL_CMSIS_RTOSv2) - return osKernelGetTickCount(); - #endif +#if defined(WOLFSSL_CMSIS_RTOS) + return os_time; +#elif defined(WOLFSSL_CMSIS_RTOSv2) + return osKernelGetTickCount(); +#endif } static time_t epochTime; -time_t time(time_t *t){ - return epochTime ; +time_t time(time_t *t) { + return epochTime; } -void setTime(time_t t){ +void setTime(time_t t) { epochTime = t; } @@ -87,48 +87,52 @@ void setTime(time_t t){ #if !defined(NO_FILESYSTEM) #include "rl_fs.h" /* FileSystem definitions */ -static void init_filesystem (void) { - int32_t retv; +static void init_filesystem(void) +{ + int32_t retv; - retv = finit ("M0:"); - if (retv == fsOK) { - retv = fmount ("M0:"); + retv = finit ("M0:"); if (retv == fsOK) { - printf ("Drive M0 ready!\n"); + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed(%d)!\n", retv); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif /*----------------------------------------------------------------------------- - * mian entry + * main entry *----------------------------------------------------------------------------*/ -void wolfcrypt_test(void *arg) ; +void wolfcrypt_test(void *arg); int main() { - void * arg = NULL ; + void * arg = NULL; - MPU_Config(); + MPU_Config(); CPU_CACHE_Enable(); HAL_Init(); /* Initialize the HAL Library */ SystemClock_Config(); /* Configure the System Clock */ - #if !defined(NO_FILESYSTEM) +#if !defined(NO_FILESYSTEM) init_filesystem (); - #endif +#endif - setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60); + setTime((RTC_YEAR-1970)*365*24*60*60 + + RTC_MONTH*30*24*60*60 + + RTC_DAY*24*60*60); - printf("=== Start: Crypt test === \n") ; - wolfcrypt_test(arg) ; - printf("=== End: Crypt test ===\n") ; + printf("=== Start: Crypt test === \n"); + wolfcrypt_test(arg); + printf("=== End: Crypt test ===\n"); + return 0; } diff --git a/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvoptx b/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvoptx index 0348f0834..8a7d23a38 100644 --- a/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvoptx +++ b/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvoptx @@ -328,7 +328,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvprojx b/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvprojx index fdaf17155..735b3c8af 100644 --- a/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvprojx +++ b/IDE/MDK5-ARM/Projects/EchoClient/EchoClient.uvprojx @@ -413,7 +413,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -880,7 +880,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/EchoClient/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/EchoClient/RTE/wolfSSL/user_settings.h deleted file mode 100644 index 4a714d7e1..000000000 --- a/IDE/MDK5-ARM/Projects/EchoClient/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,495 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS <4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet <9=>MQX -// <10=>T-RTOS <11=>uITRON4 <12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS <15=>CMSIS RTOSv2 <16=>Others -#define MDK_CONF_THREAD 14 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 1 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/EchoClient/main.c b/IDE/MDK5-ARM/Projects/EchoClient/main.c index 63d87dc0e..22f27cb15 100644 --- a/IDE/MDK5-ARM/Projects/EchoClient/main.c +++ b/IDE/MDK5-ARM/Projects/EchoClient/main.c @@ -26,7 +26,7 @@ #include "wolfssl/wolfcrypt/settings.h" #include "cmsis_os.h" /* CMSIS RTOS definitions */ -#include "rl_net.h" /* Network definitions */ +#include "rl_net.h" /* Network definitions */ #include #if defined(STM32F7xx) @@ -40,12 +40,9 @@ //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- // RTC: for validate certificate date -// Year <1970-2099> -#define RTC_YEAR 2018 -// Month <1=>Jan<2=>Feb<3=>Mar<4=>Apr<5=>May<6=>Jun<7=>Jul<8=>Aut<9=>Sep<10=>Oct<11=>Nov<12=>Dec +#define RTC_YEAR 2023 #define RTC_MONTH 1 -// Day <1-31> -#define RTC_DAY 1 +#define RTC_DAY 1 // //------------- <<< end of configuration section >>> ----------------------- @@ -69,29 +66,30 @@ static void CPU_CACHE_Enable (void) { #if !defined(NO_FILESYSTEM) #include "rl_fs.h" /* FileSystem definitions */ -static void init_filesystem (void) { - int32_t retv; +static void init_filesystem(void) +{ + int32_t retv; - retv = finit ("M0:"); - if (retv == fsOK) { - retv = fmount ("M0:"); + retv = finit ("M0:"); if (retv == fsOK) { - printf ("Drive M0 ready!\n"); + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed(%d)!\n", retv); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif void net_loop(void const *arg) { - while(1) { + while (1) { net_main (); osThreadYield (); } @@ -103,8 +101,8 @@ osThreadDef(net_loop, osPriorityLow, 2, 0); extern uint32_t os_time; static time_t epochTime; -uint32_t HAL_GetTick(void) { - return os_time; +uint32_t HAL_GetTick(void) { + return os_time; } time_t time(time_t *t){ @@ -133,15 +131,15 @@ double current_time(int reset) #define DWT ((DWT_Type *) (0xE0001000UL) ) typedef struct { - uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ } DWT_Type; extern uint32_t SystemCoreClock ; double current_time(int reset) { - if(reset) DWT->CYCCNT = 0 ; + if (reset) DWT->CYCCNT = 0 ; return ((double)DWT->CYCCNT/SystemCoreClock) ; } #endif @@ -160,20 +158,21 @@ extern void echoclient_test(func_args * args) ; int myoptind = 0; char* myoptarg = NULL; -int main (void) { +int main (void) +{ static char *argv[] = { "client" } ; static func_args args = { 1, argv } ; - MPU_Config(); /* Configure the MPU */ - CPU_CACHE_Enable(); /* Enable the CPU Cache */ - HAL_Init(); /* Initialize the HAL Library */ - SystemClock_Config(); /* Configure the System Clock */ + MPU_Config(); /* Configure the MPU */ + CPU_CACHE_Enable(); /* Enable the CPU Cache */ + HAL_Init(); /* Initialize the HAL Library */ + SystemClock_Config(); /* Configure the System Clock */ - #if !defined(NO_FILESYSTEM) +#if !defined(NO_FILESYSTEM) init_filesystem (); - #endif +#endif net_initialize (); #if defined(DEBUG_WOLFSSL) @@ -181,14 +180,15 @@ int main (void) { wolfSSL_Debugging_ON() ; #endif - setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60); + setTime((RTC_YEAR-1970)*365*24*60*60 + + RTC_MONTH*30*24*60*60 + + RTC_DAY*24*60*60); osThreadCreate (osThread(net_loop), NULL); echoclient_test(&args) ; - while(1) + while (1) { osDelay(1000); - + } } - diff --git a/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvoptx b/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvoptx index 78b693549..65e7c61c8 100644 --- a/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvoptx +++ b/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvoptx @@ -279,7 +279,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvprojx b/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvprojx index 0650169d9..9471fa6b8 100644 --- a/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvprojx +++ b/IDE/MDK5-ARM/Projects/EchoServer/EchoServer.uvprojx @@ -413,7 +413,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -886,7 +886,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/EchoServer/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/EchoServer/RTE/wolfSSL/user_settings.h deleted file mode 100644 index f4c47bf79..000000000 --- a/IDE/MDK5-ARM/Projects/EchoServer/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,497 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS <4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet <9=>MQX -// <10=>T-RTOS <11=>uITRON4 <12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS <15=>CMSIS RTOSv2 <16=>Others -#define MDK_CONF_THREAD 14 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define WOLFSSL_CMSIS_RTOSv2 -#elif MDK_CONF_THREAD == 16 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 1 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/EchoServer/main.c b/IDE/MDK5-ARM/Projects/EchoServer/main.c index deb800f8a..53a27bec0 100644 --- a/IDE/MDK5-ARM/Projects/EchoServer/main.c +++ b/IDE/MDK5-ARM/Projects/EchoServer/main.c @@ -26,7 +26,7 @@ #include "wolfssl/wolfcrypt/settings.h" #include "cmsis_os.h" /* CMSIS RTOS definitions */ -#include "rl_net.h" /* Network definitions */ +#include "rl_net.h" /* Network definitions */ #include #if defined(STM32F7xx) @@ -58,12 +58,9 @@ // // RTC: for validate certificate date -// Year <1970-2099> -#define RTC_YEAR 2018 -// Month <1=>Jan<2=>Feb<3=>Mar<4=>Apr<5=>May<6=>Jun<7=>Jul<8=>Aut<9=>Sep<10=>Oct<11=>Nov<12=>Dec +#define RTC_YEAR 2023 #define RTC_MONTH 1 -// Day <1-31> -#define RTC_DAY 1 +#define RTC_DAY 1 // //------------- <<< end of configuration section >>> ----------------------- @@ -88,22 +85,23 @@ static void CPU_CACHE_Enable (void) { #if !defined(NO_FILESYSTEM) #include "rl_fs.h" /* FileSystem definitions */ -static void init_filesystem (void) { - int32_t retv; +static void init_filesystem(void) +{ + int32_t retv; - retv = finit ("M0:"); - if (retv == fsOK) { - retv = fmount ("M0:"); + retv = finit ("M0:"); if (retv == fsOK) { - printf ("Drive M0 ready!\n"); + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed(%d)!\n", retv); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif @@ -120,20 +118,20 @@ osThreadDef(net_loop, osPriorityLow, 2, 0); #ifdef RTE_CMSIS_RTOS_RTX extern uint32_t os_time; -static time_t epochTime; +static time_t epochTime; -uint32_t HAL_GetTick(void) { - return os_time; +uint32_t HAL_GetTick(void) { + return os_time; } -time_t time(time_t *t){ - return epochTime ; +time_t time(time_t *t) { + return epochTime; } -void setTime(time_t t){ +void setTime(time_t t) { epochTime = t; } -#endif +#endif /* RTE_CMSIS_RTOS_RTX */ #ifdef WOLFSSL_CURRTIME_OSTICK @@ -143,28 +141,27 @@ extern uint32_t os_time; double current_time(int reset) { - if(reset) os_time = 0 ; - return (double)os_time /1000.0; + if (reset) os_time = 0; + return (double)os_time /1000.0; } #else #include #define DWT ((DWT_Type *) (0xE0001000UL) ) -typedef struct -{ - uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ +typedef struct { + uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ } DWT_Type; -extern uint32_t SystemCoreClock ; +extern uint32_t SystemCoreClock; double current_time(int reset) { - if(reset) DWT->CYCCNT = 0 ; - return ((double)DWT->CYCCNT/SystemCoreClock) ; + if (reset) DWT->CYCCNT = 0; + return ((double)DWT->CYCCNT/SystemCoreClock); } -#endif +#endif /* WOLFSSL_CURRTIME_OSTICK */ /*---------------------------------------------------------------------------- Main Thread 'main': Run Network @@ -175,39 +172,42 @@ typedef struct func_args { char** argv; } func_args; -extern void echoserver_test(func_args * args) ; +extern void echoserver_test(func_args * args); int myoptind = 0; char* myoptarg = NULL; -int main (void) { +int main (void) +{ static char *argv[] = - { "server" } ; - static func_args args = { 1, argv } ; + { "server" }; + static func_args args = { 1, argv }; - MPU_Config(); /* Configure the MPU */ - CPU_CACHE_Enable(); /* Enable the CPU Cache */ - HAL_Init(); /* Initialize the HAL Library */ - SystemClock_Config(); /* Configure the System Clock */ + MPU_Config(); /* Configure the MPU */ + CPU_CACHE_Enable(); /* Enable the CPU Cache */ + HAL_Init(); /* Initialize the HAL Library */ + SystemClock_Config(); /* Configure the System Clock */ - #if !defined(NO_FILESYSTEM) +#if !defined(NO_FILESYSTEM) init_filesystem (); - #endif +#endif net_initialize (); - #if defined(DEBUG_WOLFSSL) - printf("Turning ON Debug message\n") ; - wolfSSL_Debugging_ON() ; - #endif +#if defined(DEBUG_WOLFSSL) + printf("Turning ON Debug message\n"); + wolfSSL_Debugging_ON(); +#endif - setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60); + setTime((RTC_YEAR-1970)*365*24*60*60 + + RTC_MONTH*30*24*60*60 + + RTC_DAY*24*60*60); osThreadCreate (osThread(net_loop), NULL); - echoserver_test(&args) ; - printf("echoserver: Terminated\n") ; - while(1) + echoserver_test(&args); + printf("echoserver: Terminated\n"); + + while (1) { osDelay(1000); - + } } - diff --git a/IDE/MDK5-ARM/Projects/SimpleClient/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/SimpleClient/RTE/wolfSSL/user_settings.h deleted file mode 100644 index c14e47240..000000000 --- a/IDE/MDK5-ARM/Projects/SimpleClient/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,497 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS <4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet <9=>MQX -// <10=>T-RTOS <11=>uITRON4 <12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS <15=>CMSIS RTOSv2 <16=>Others -#define MDK_CONF_THREAD 15 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define WOLFSSL_CMSIS_RTOSv2 -#elif MDK_CONF_THREAD == 16 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 1 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvoptx b/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvoptx index 38fdb5408..47f64d8b7 100644 --- a/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvoptx +++ b/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvoptx @@ -298,7 +298,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvprojx b/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvprojx index 913abe82b..7bf9356eb 100644 --- a/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvprojx +++ b/IDE/MDK5-ARM/Projects/SimpleClient/SimpleClient.uvprojx @@ -413,7 +413,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -912,7 +912,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/SimpleClient/main.c b/IDE/MDK5-ARM/Projects/SimpleClient/main.c index 434545853..046154701 100644 --- a/IDE/MDK5-ARM/Projects/SimpleClient/main.c +++ b/IDE/MDK5-ARM/Projects/SimpleClient/main.c @@ -68,12 +68,9 @@ // // RTC: for validate certificate date -// Year <1970-2099> -#define RTC_YEAR 2019 -// Month <1=>Jan<2=>Feb<3=>Mar<4=>Apr<5=>May<6=>Jun<7=>Jul<8=>Aug<9=>Sep<10=>Oct<11=>Nov<12=>Dec +#define RTC_YEAR 2023 #define RTC_MONTH 1 -// Day <1-31> -#define RTC_DAY 1 +#define RTC_DAY 1 // //------------- <<< end of configuration section >>> ----------------------- @@ -96,19 +93,19 @@ extern uint32_t os_time; #endif uint32_t HAL_GetTick(void) { - #if defined(WOLFSSL_CMSIS_RTOS) - return os_time; - #elif defined(WOLFSSL_CMSIS_RTOSv2) - return osKernelGetTickCount(); - #endif +#if defined(WOLFSSL_CMSIS_RTOS) + return os_time; +#elif defined(WOLFSSL_CMSIS_RTOSv2) + return osKernelGetTickCount(); +#endif } static time_t epochTime; -time_t time(time_t *t){ - return epochTime ; +time_t time(time_t *t) { + return epochTime; } -void setTime(time_t t){ +void setTime(time_t t) { epochTime = t; } @@ -129,22 +126,23 @@ double current_time(int reset) #if !defined(NO_FILESYSTEM) #include "rl_fs.h" /* FileSystem definitions */ -static void init_filesystem (void) { - int32_t retv; +static void init_filesystem(void) +{ + int32_t retv; - retv = finit ("M0:"); - if (retv == fsOK) { - retv = fmount ("M0:"); + retv = finit ("M0:"); if (retv == fsOK) { - printf ("Drive M0 ready!\n"); + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed(%d)!\n", retv); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif @@ -156,9 +154,10 @@ void app_main(void *arg) void app_main(void const*arg) #endif { - if(netInitialize () == netOK) - client_test(arg); - else printf("ERROR: netInitialize\n"); + if (netInitialize () == netOK) + client_test(arg); + else + printf("ERROR: netInitialize\n"); } #if defined(WOLFSSL_CMSIS_RTOS) @@ -178,48 +177,51 @@ typedef struct func_args { int myoptind = 0; char* myoptarg = NULL; -int main (void) { +int main (void) +{ static char *argv[] = { "client", "-h", REMOTE_IP, "-p", REMOTE_PORT, - "-v", " ", OTHER_OPTIONS } ; + "-v", " ", OTHER_OPTIONS }; static func_args args = - { sizeof(argv)/sizeof(*argv[0]), argv } ; + { sizeof(argv)/sizeof(*argv[0]), argv }; char *verStr[] = { "SSL3", "TLS1.0", "TLS1.1", "TLS1.2", "TLS1.3"}; #define VERSIZE 2 static char ver[VERSIZE]; - - MPU_Config(); /* Configure the MPU */ - CPU_CACHE_Enable(); /* Enable the CPU Cache */ - HAL_Init(); /* Initialize the HAL Library */ - SystemClock_Config(); /* Configure the System Clock */ - #if defined(WOLFSSL_CMSIS_RTOSv2) - osKernelInitialize(); - #endif - - #if !defined(NO_FILESYSTEM) - init_filesystem (); - #endif - #if defined(DEBUG_WOLFSSL) - printf("Turning ON Debug message\n") ; - wolfSSL_Debugging_ON() ; - #endif + MPU_Config(); /* Configure the MPU */ + CPU_CACHE_Enable(); /* Enable the CPU Cache */ + HAL_Init(); /* Initialize the HAL Library */ + SystemClock_Config(); /* Configure the System Clock */ +#if defined(WOLFSSL_CMSIS_RTOSv2) + osKernelInitialize(); +#endif + +#if !defined(NO_FILESYSTEM) + init_filesystem (); +#endif + +#if defined(DEBUG_WOLFSSL) + printf("Turning ON Debug message\n"); + wolfSSL_Debugging_ON(); +#endif snprintf(ver, VERSIZE, "%d", TLS_VER); argv[6] = ver; - printf("SSL/TLS Client(%d)\n ", (int)(sizeof(argv)/sizeof(argv[0]))) ; - printf(" Remote IP: %s, Port: %s\n Version: %s\n", argv[2], argv[4], verStr[TLS_VER]) ; - printf(" Other options: %s\n", OTHER_OPTIONS); - setTime((time_t)((RTC_YEAR-1970)*365*24*60*60) + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60); - - #if defined(WOLFSSL_CMSIS_RTOS) - osThreadCreate (osThread(app_main), (void *)&args); - #elif defined(WOLFSSL_CMSIS_RTOSv2) - osThreadNew(app_main, (void *)&args, NULL); - #endif - osKernelStart(); + printf("SSL/TLS Client(%d)\n ", (int)(sizeof(argv)/sizeof(argv[0]))); + printf(" Remote IP: %s, Port: %s\n Version: %s\n", + argv[2], argv[4], verStr[TLS_VER]); + printf(" Other options: %s\n", OTHER_OPTIONS); + setTime((time_t)((RTC_YEAR-1970)*365*24*60*60) + + RTC_MONTH*30*24*60*60 + + RTC_DAY*24*60*60); +#if defined(WOLFSSL_CMSIS_RTOS) + osThreadCreate (osThread(app_main), (void *)&args); +#elif defined(WOLFSSL_CMSIS_RTOSv2) + osThreadNew(app_main, (void *)&args, NULL); +#endif + osKernelStart(); } diff --git a/IDE/MDK5-ARM/Projects/SimpleServer/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/SimpleServer/RTE/wolfSSL/user_settings.h deleted file mode 100644 index c14e47240..000000000 --- a/IDE/MDK5-ARM/Projects/SimpleServer/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,497 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS <4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet <9=>MQX -// <10=>T-RTOS <11=>uITRON4 <12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS <15=>CMSIS RTOSv2 <16=>Others -#define MDK_CONF_THREAD 15 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define WOLFSSL_CMSIS_RTOSv2 -#elif MDK_CONF_THREAD == 16 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 1 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvoptx b/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvoptx index 793053daf..2f13b8069 100644 --- a/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvoptx +++ b/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvoptx @@ -298,7 +298,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvprojx b/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvprojx index 33c84cb0e..659c22d0a 100644 --- a/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvprojx +++ b/IDE/MDK5-ARM/Projects/SimpleServer/SimpleServer.uvprojx @@ -413,7 +413,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -912,7 +912,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/SimpleServer/main.c b/IDE/MDK5-ARM/Projects/SimpleServer/main.c index 3f8c196cd..973fdbbe1 100644 --- a/IDE/MDK5-ARM/Projects/SimpleServer/main.c +++ b/IDE/MDK5-ARM/Projects/SimpleServer/main.c @@ -66,11 +66,9 @@ // RTC: for validate certificate date // Year <1970-2099> -#define RTC_YEAR 2019 -// Month <1=>Jan<2=>Feb<3=>Mar<4=>Apr<5=>May<6=>Jun<7=>Jul<8=>Aut<9=>Sep<10=>Oct<11=>Nov<12=>Dec +#define RTC_YEAR 2023 #define RTC_MONTH 1 -// Day <1-31> -#define RTC_DAY 1 +#define RTC_DAY 1 // //------------- <<< end of configuration section >>> ----------------------- @@ -94,22 +92,23 @@ static void CPU_CACHE_Enable (void) { #if !defined(NO_FILESYSTEM) #include "rl_fs.h" /* FileSystem definitions */ -static void init_filesystem (void) { - int32_t retv; +static void init_filesystem(void) +{ + int32_t retv; - retv = finit ("M0:"); - if (retv == fsOK) { - retv = fmount ("M0:"); + retv = finit ("M0:"); if (retv == fsOK) { - printf ("Drive M0 ready!\n"); + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed(%d)!\n", retv); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif @@ -121,20 +120,20 @@ extern uint32_t os_time; uint32_t HAL_GetTick(void) { - #if defined(WOLFSSL_CMSIS_RTOS) - return os_time; - #elif defined(WOLFSSL_CMSIS_RTOSv2) - return osKernelGetTickCount(); - #endif +#if defined(WOLFSSL_CMSIS_RTOS) + return os_time; +#elif defined(WOLFSSL_CMSIS_RTOSv2) + return osKernelGetTickCount(); +#endif } double current_time(int reset) { - #if defined(WOLFSSL_CMSIS_RTOS) - return (double)os_time / 1000.0; - #elif defined(WOLFSSL_CMSIS_RTOSv2) - return (double)osKernelGetTickCount() / 1000.0; - #endif +#if defined(WOLFSSL_CMSIS_RTOS) + return (double)os_time / 1000.0; +#elif defined(WOLFSSL_CMSIS_RTOSv2) + return (double)osKernelGetTickCount() / 1000.0; +#endif } #else @@ -143,8 +142,8 @@ double current_time(int reset) #define DWT ((DWT_Type *) (0xE0001000UL) ) typedef struct { - uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ - uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ } DWT_Type; extern uint32_t SystemCoreClock; @@ -203,22 +202,22 @@ int main(void) { static char *argv[] = { "server", "-p", SERVER_PORT, - "-v", " ", OTHER_OPTIONS } ; + "-v", " ", OTHER_OPTIONS }; static func_args args = - { sizeof(argv)/sizeof(*argv[0]), argv } ; + { sizeof(argv)/sizeof(*argv[0]), argv }; char *verStr[] = { "SSL3", "TLS1.0", "TLS1.1", "TLS1.2", "TLS1.3"}; #define VERSIZE 2 char ver[VERSIZE]; - + MPU_Config(); /* Configure the MPU */ CPU_CACHE_Enable(); /* Enable the CPU Cache */ HAL_Init(); /* Initialize the HAL Library */ SystemClock_Config(); /* Configure the System Clock */ - #if !defined(NO_FILESYSTEM) +#if !defined(NO_FILESYSTEM) init_filesystem (); - #endif +#endif #if defined(WOLFSSL_CMSIS_RTOSv2) osKernelInitialize(); @@ -232,10 +231,12 @@ int main(void) snprintf(ver, VERSIZE, "%d", TLS_VER); argv[4] = ver; - printf("SSL/TLS Server\n ") ; - printf(" Server Port: %s\n Version: %s\n", argv[2], verStr[TLS_VER]) ; - printf(" Other options: %s\n", OTHER_OPTIONS); - setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60); + printf("SSL/TLS Server\n "); + printf(" Server Port: %s\n Version: %s\n", argv[2], verStr[TLS_VER]); + printf(" Other options: %s\n", OTHER_OPTIONS); + setTime((RTC_YEAR-1970)*365*24*60*60 + + RTC_MONTH*30*24*60*60 + + RTC_DAY*24*60*60); #if defined(WOLFSSL_CMSIS_RTOS) osThreadCreate(osThread(app_main), (void *)&args); diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c b/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c index 43bd72980..7eed77205 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Full/main.c @@ -51,22 +51,24 @@ void SystemClock_Config(void) { *----------------------------------------------------------------------------*/ #if !defined(NO_FILESYSTEM) #include "rl_fs.h" -static void init_filesystem (void) { - int32_t retv; - retv = finit ("M0:"); - if (retv == 0) { - retv = fmount ("M0:"); - if (retv == 0) { - printf ("Drive M0 ready!\n"); +static void init_filesystem(void) +{ + int32_t retv; + + retv = finit ("M0:"); + if (retv == fsOK) { + retv = fmount ("M0:"); + if (retv == fsOK) { + printf ("Drive M0 ready!\n"); + } + else { + printf ("Drive M0 mount failed(%d)!\n", retv); + } } else { - printf ("Drive M0 mount failed!\n"); + printf ("Drive M0 initialization failed!\n"); } - } - else { - printf ("Drive M0 initialization failed!\n"); - } } #endif @@ -76,31 +78,31 @@ typedef struct func_args { } func_args; -extern void shell_main(func_args * args) ; +extern void shell_main(func_args * args); /*----------------------------------------------------------------------------- - * mian entry + * main entry *----------------------------------------------------------------------------*/ int myoptind = 0; char* myoptarg = NULL; int main() { - void *arg = NULL ; + void *arg = NULL; - SystemClock_Config() ; + SystemClock_Config(); #if !defined(NO_FILESYSTEM) init_filesystem (); #endif - netInitialize() ; - osDelay(300) ; + netInitialize(); + osDelay(300); - #if defined(DEBUG_WOLFSSL) - printf("Turning ON Debug message\n") ; - wolfSSL_Debugging_ON() ; - #endif +#if defined(DEBUG_WOLFSSL) + printf("Turning ON Debug message\n"); + wolfSSL_Debugging_ON(); +#endif - shell_main(arg) ; + shell_main(arg); } diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvoptx b/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvoptx index 91b3e7f9a..7aac8af8b 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvoptx +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvoptx @@ -300,7 +300,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvprojx b/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvprojx index e38303253..919e7464c 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvprojx +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Full/wolfsslFull.uvprojx @@ -441,7 +441,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -972,7 +972,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Lib/RTE/wolfSSL/user_settings.h b/IDE/MDK5-ARM/Projects/wolfSSL-Lib/RTE/wolfSSL/user_settings.h deleted file mode 100644 index c14e47240..000000000 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Lib/RTE/wolfSSL/user_settings.h +++ /dev/null @@ -1,497 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2023 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - -#define NO_MAIN_DRIVER -#define BENCH_EMBEDDED -#define NO_DEV_RANDOM -#define WOLFSSL_USER_CURRTIME -#define SIZEOF_LONG_LONG 8 -#define NO_WRITEV -#define NO_DEV_RANDOM - -#define TFM_TIMING_RESISTANT -#define ECC_TIMING_RESISTANT -#define WC_RSA_BLINDING - -#define WOLFSSL_USER_CURRTIME /* for benchmark */ -#define WOLFSSL_CURRTIME_OSTICK /* use OS tich for current_time */ -#define WOLFSSL_GMTIME -#define NO_MULTIBYTE_PRINT - -// <<< Use Configuration Wizard in Context Menu >>> - - -// Common options -// MPU<0=>Undefined<1=>STM32F2xx<2=>STM32F4xx<3=>STM32F7xx -#define MDK_CONF_MPU 3 -#if MDK_CONF_MPU == 0 - -#elif MDK_CONF_MPU == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32F2xx -#elif MDK_CONF_MPU == 2 -#define WOLFSSL_STM32_CUBEMX -#define STM32F4xx -#elif MDK_CONF_MPU == 3 -#define WOLFSSL_STM32_CUBEMX -#define STM32F7xx -#endif - -// Thread/RTOS<0=>Single Threaded <1=>FreeRTOS <3=>SafeRTOS <4=>Windows -// <5=>PThread <6=>ThreadX -// <7=>Micrium <8=>EBSnet <9=>MQX -// <10=>T-RTOS <11=>uITRON4 <12=>uTKERNEL2 -// <13=>Frosted <14=>CMSIS RTOS <15=>CMSIS RTOSv2 <16=>Others -#define MDK_CONF_THREAD 15 -#if MDK_CONF_THREAD== 0 -#define SINGLE_THREADED -#elif MDK_CONF_THREAD == 1 -#define FREERTOS -#elif MDK_CONF_THREAD == 3 -#define WOLFSSL_SAFERTOS -#elif MDK_CONF_THREAD == 4 -#define USE_WINDOWS_API -#elif MDK_CONF_THREAD == 5 -#define WOLFSSL_PTHREADS -#elif MDK_CONF_THREAD == 6 -#define THREADX -#define NETX -#elif MDK_CONF_THREAD == 7 -#define MICRIUM -#elif MDK_CONF_THREAD == 8 -#define EBSNET -#elif MDK_CONF_THREAD == 9 -#define FREESCALE_MQX -#define FREESCALE_KSDK_MQX -#elif MDK_CONF_THREAD == 10 -#define WOLFSSL_TIRTOS -#elif MDK_CONF_THREAD == 11 -#define WOLFSSL_uITRON4 -#elif MDK_CONF_THREAD == 12 -#define WOLFSSL_uTKERNEL2 -#elif MDK_CONF_THREAD == 13 -#define WOLFSSL_FROSTED -#elif MDK_CONF_THREAD == 14 -#define WOLFSSL_CMSIS_RTOS -#elif MDK_CONF_THREAD == 15 -#define WOLFSSL_CMSIS_RTOSv2 -#elif MDK_CONF_THREAD == 16 -#define SINGLE_THREADED -#endif - - -// File System -#define MDK_CONF_FILESYSTEM 1 -#if MDK_CONF_FILESYSTEM == 0 -#define NO_FILESYSTEM -#else -#define WOLFSSL_KEIL_FS -#define NO_WOLFSSL_DIR -#endif -// - -// Network<0=>None <1=>RLnet <2=>User I/O -#define MDK_CONF_NETWORK 1 -#if MDK_CONF_NETWORK == 0 -#elif MDK_CONF_NETWORK == 1 -#define WOLFSSL_KEIL_TCP_NET -#elif MDK_CONF_NETWORK == 2 -#define WOLFSSL_USER_IO -#endif - -// Debug options - -// Debug Message -#define MDK_CONF_DebugMessage 0 -#if MDK_CONF_DebugMessage == 1 -#define DEBUG_WOLFSSL -#endif -// -// Check malloc -#define MDK_CONF_CheckMalloc 1 -#if MDK_CONF_CheckMalloc == 1 -#define WOLFSSL_MALLOC_CHECK -#define USE_WOLFSSL_MEMORY -#endif -// -// ErrNo.h -#define MDK_CONF_ErrNo 1 -#if MDK_CONF_ErrNo == 1 -#define HAVE_ERRNO -#endif -// -// Error Strings -#define MDK_CONF_ErrorStrings 1 -#if MDK_CONF_ErrorStrings == 0 -#define NO_ERROR_STRINGS -#endif -// - -// -// - -// wolfCrypt Configuration - -// Hash/Crypt Algrithm - -// MD2 -#define MDK_CONF_MD2 0 -#if MDK_CONF_MD2 == 1 -#define WOLFSSL_MD2 -#endif -// -// MD4 -#define MDK_CONF_MD4 0 -#if MDK_CONF_MD4 == 0 -#define NO_MD4 -#endif -// -// MD5 -#define MDK_CONF_MD5 1 -#if MDK_CONF_MD5 == 0 -#define NO_MD5 -#endif -// -// SHA -#define MDK_CONF_SHA 1 -#if MDK_CONF_SHA == 0 -#define NO_SHA -#endif -// -// SHA-256 -#define MDK_CONF_SHA256 1 -#if MDK_CONF_SHA256 == 0 -#define NO_SHA256 -#endif -// -// SHA-384 -#define MDK_CONF_SHA384 1 -#if MDK_CONF_SHA384 == 1 -#define WOLFSSL_SHA384 -#endif -// -// SHA-512 -#define MDK_CONF_SHA512 1 -#if MDK_CONF_SHA512 == 1 -#define WOLFSSL_SHA512 -#endif -// -// Hash DRBG -#define MDK_CONF_HASHDRBG 1 -#if MDK_CONF_HASHDRBG == 1 -#define HAVE_HASHDRBG -#endif -// -// RIPEMD -#define MDK_CONF_RIPEMD 1 -#if MDK_CONF_RIPEMD == 1 -#define WOLFSSL_RIPEMD -#endif -// -// BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 -#endif -// -// HMAC -#define MDK_CONF_HMAC 1 -#if MDK_CONF_HMAC == 0 -#define NO_HMAC -#endif -// -// HMAC KDF -#define MDK_CONF_HKDF 1 -#if MDK_CONF_HKDF == 1 -#define HAVE_HKDF -#endif -// - -// AES CCM -#define MDK_CONF_AESCCM 1 -#if MDK_CONF_AESCCM == 1 -#define HAVE_AESCCM -#endif -// -// AES GCM -#define MDK_CONF_AESGCM 1 -#if MDK_CONF_AESGCM == 1 -#define HAVE_AESGCM -#endif -// - -// RC4 -#define MDK_CONF_RC4 0 -#if MDK_CONF_RC4 == 0 -#define NO_RC4 -#endif -// - -// CHACHA -#define MDK_CONF_CHACHA 1 -#if MDK_CONF_CHACHA == 1 -#define HAVE_CHACHA -#endif -// - -// POLY1305 -#define MDK_CONF_POLY1305 1 -#if MDK_CONF_POLY1305 == 1 -#define HAVE_POLY1305 -#define HAVE_ONE_TIME_AUTH -#endif -// - -// DES3 -#define MDK_CONF_DES3 1 -#if MDK_CONF_DES3 == 0 -#define NO_DES3 -#endif -// - -// AES -#define MDK_CONF_AES 1 -#if MDK_CONF_AES == 0 -#define NO_AES -#endif -// - -// CAMELLIA -#define MDK_CONF_CAMELLIA 1 -#if MDK_CONF_CAMELLIA == 1 -#define HAVE_CAMELLIA -#endif -// - -// DH -#define MDK_CONF_DH 1 -#if MDK_CONF_DH == 0 -#define NO_DH -#endif -// -// DSA -#define MDK_CONF_DSA 1 -#if MDK_CONF_DSA == 0 -#define NO_DSA -#endif -// - -// SRP -#define MDK_CONF_SRP 1 -#if MDK_CONF_SRP == 1 -#define HAVE_SRP -#endif -// - -// PWDBASED -#define MDK_CONF_PWDBASED 1 -#if MDK_CONF_PWDBASED == 0 -#define NO_PWDBASED -#endif -// - -// ECC -#define MDK_CONF_ECC 1 -#if MDK_CONF_ECC == 1 -#define HAVE_ECC -#endif -// - -// CURVE25519 -#define MDK_CONF_CURVE25519 1 -#if MDK_CONF_CURVE25519 == 1 -#define HAVE_CURVE25519 -#define CURVED25519_SMALL -#endif -// -// CURVE25519 SMALL -#define MDK_CONF_CURVE25519_SMALL 0 -#if MDK_CONF_CURVE25519_SMALL == 1 -#define CURVED25519_SMALL -#endif -// -// ED25519 -#define MDK_CONF_ED25519 1 -#if MDK_CONF_ED25519 == 1 -#define HAVE_ED25519 -#endif -// -// ED25519 SMALL -#define MDK_CONF_ED25519_SMALL 0 -#if MDK_CONF_ED25519_SMALL == 1 -#define ED25519_SMALL -#endif -// -// PKCS7 -#define MDK_CONF_PKCS7 0 -#if MDK_CONF_PKCS7 == 1 -#define HAVE_PKCS7 -#endif -// -// - -// Random Seed, for TEST Only -#define MDK_CONF_RNDSEED 1 -#if MDK_CONF_RNDSEED == 1 -#define WOLFSSL_GENSEED_FORTEST -#endif -// - -// Hardware Crypt (See document for usage) -// Hardware RNG -#define MDK_CONF_STM32F2_RNG 0 -#if MDK_CONF_STM32F2_RNG == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_RNG -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Crypt -#define MDK_CONF_STM32F2_CRYPTO 0 -#if MDK_CONF_STM32F2_CRYPTO == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_CRYPTO -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// Hardware Hash -#define MDK_CONF_STM32F2_HASH 0 -#if MDK_CONF_STM32F2_HASH == 1 -#define WOLFSSL_STM32_CUBEMX -#define STM32_HASH -#define WC_ASYNC_DEV_SIZE 320+24 -#define STM32_HAL_TIMEOUT 0xFF - -#if defined(STM32F2xx) -#define WOLFSSL_STM32F2 -#elif defined(STM32F4xx) -#define WOLFSSL_STM32F4 -#elif defined(STM32F7xx) -#define WOLFSSL_STM32F7 -#endif - -#endif -// -// - -// Cert/Key Strage -// Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes) -#define MDK_CONF_CERT_BUFF 0 -#if MDK_CONF_CERT_BUFF== 1 -#define USE_CERT_BUFFERS_1024 -#elif MDK_CONF_CERT_BUFF == 2 -#define USE_CERT_BUFFERS_2048 -#endif -// -// Cert/Key Generation -// CertGen -#define MDK_CONF_CERT_GEN 0 -#if MDK_CONF_CERT_GEN == 1 -#define WOLFSSL_CERT_GEN -#endif -// -// KeyGen -#define MDK_CONF_KEY_GEN 0 -#if MDK_CONF_KEY_GEN == 1 -#define WOLFSSL_KEY_GEN -#endif -// -// -// Use Fast Math -#define MDK_CONF_FASTMATH 1 -#if MDK_CONF_FASTMATH == 1 -#define USE_FAST_MATH -#define TFM_TIMING_RESISTANT -#endif -// -// Small Stack -#define MDK_CONF_SmallStack 1 -#if MDK_CONF_SmallStack == 0 -#define NO_WOLFSSL_SMALL_STACK -#endif -// - -// - - -/**** wolfSSL Configuration ****/ - -// wolfSSL Configuration - -// TLS 1.3 -#define MDK_CONF_TLS 1 -#if MDK_CONF_TLS == 1 -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define WC_RSA_PSS -#define HAVE_HKDF -#define HAVE_FFDHE_2048 -#endif -// - -// Include Old TLS -#define MDK_CONF_NO_OLDTLS 0 -#if MDK_CONF_NO_OLDTLS == 0 -#define NO_OLD_TLS -#endif -// -// CRL -#define MDK_CONF_CRL 0 -#if MDK_CONF_CRL == 1 -#define HAVE_CRL -#define WOLFSSL_DER_LOAD -#endif -// -// OCSP -#define MDK_CONF_OCSP 0 -#if MDK_CONF_OCSP == 1 -#define HAVE_OCSP -#endif -// -// OpenSSL Extra -#define MDK_CONF_OPENSSL_EXTRA 0 -#if MDK_CONF_OPENSSL_EXTRA == 1 -#define OPENSSL_EXTRA -#endif -// - -// diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvoptx b/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvoptx index 1f0fdd699..d11940ef2 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvoptx +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvoptx @@ -226,7 +226,7 @@ 0 0 0 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h user_settings.h 0 0 diff --git a/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvprojx b/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvprojx index 0d046e502..34f3cba64 100644 --- a/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvprojx +++ b/IDE/MDK5-ARM/Projects/wolfSSL-Lib/wolfSSL-Lib.uvprojx @@ -383,7 +383,7 @@ user_settings.h 5 - .\RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h @@ -832,7 +832,7 @@ - RTE\wolfSSL\user_settings.h + ..\..\Conf\user_settings.h diff --git a/IDE/MDK5-ARM/README.md b/IDE/MDK5-ARM/README.md new file mode 100644 index 000000000..2969076ed --- /dev/null +++ b/IDE/MDK5-ARM/README.md @@ -0,0 +1,54 @@ +# ARM Keil MDK 5 wolfSSL Support + +wolfSSL has a Keil CMSIS pack available that is updated for each release. + +This CMSIS pack contains the wolfCrypt and wolfSSL (TLS) libraries including test, benchmark and example applications. + +## To install the wolfSSL pack + +1) Open the Keil "Pack Installer" +2) Under Generic locate "wolfSSL::wolfSSL" +3) Click "Install" + +## To add the pack to your project + +1) Project -> Manage -> "Runtime Environment" +2) Expand "wolfSSL" and check the boxes for wolfCrypt CORE and wolfSSL CORE. +3) If running the wolfCrypt test or any of the TLS examples check those as well. + +If the wolfSSL::wolfSSL pack isn't showing: +1) Project -> Manage -> "Select Software Packs" +2) Make sure wolfSSL:wolfSSL is selected to "latest" +3) Hit "OK" + +## To configure wolfSSL + +1) Add a pre-processor macro `WOLFSSL_USER_SETTINGS` + - Project -> Options for Target... -> C/C++ -> Preprocessor Symbols -> Define. + - Add `WOLFSSL_USER_SETTINGS` +2) Open the `user_settings.h` file. In wolfSSL -> user_settings.h +3) Configure math library (`MDK_CONF_MATH`). Default 0=SP Math all (sp_int.c) +4) Configure MPU (`MDK_CONF_MPU`): If not STM32, use 0 for none. +5) Configure the RTOS (`MDK_CONF_THREAD`): By default 15 = "CMSIS RTOSv2". For bare-metal use 0. For FreeRTOS use 1. +6) For wolfCrypt only (no TLS) add `#define WOLFCRYPT_ONLY` (resolves GetCA errors) +7) Increase stack/heap (if needed). This is typically in the startup.s, but for RTX is in the `RTX_Config.h`. For CMSIS RTOSv2 stack is set in `osThreadAttr_t` on call to `osThreadNew`. + +## Building + +If getting error for missing GetCA or GetCAByName then include `Src/ssl-dummy.c` or define `WOLFCRYPT_ONLY`. + +If getting an error with missing `current_time` then please implement a function to return elapsed seconds (used by benchmark) like this: + +```c +extern uint32_t os_time; +double current_time(int reset) +{ + if (reset) os_time = 0 ; + return (double)os_time /1000.0; +} +``` + + +## For Support + +For question email support@wolfssl.com diff --git a/IDE/MDK5-ARM/Src/ssl-dummy.c b/IDE/MDK5-ARM/Src/ssl-dummy.c index fdd71c962..7cfd82ec6 100644 --- a/IDE/MDK5-ARM/Src/ssl-dummy.c +++ b/IDE/MDK5-ARM/Src/ssl-dummy.c @@ -29,11 +29,11 @@ Signer* GetCA(void* vp, byte* hash) { - return NULL ; + return NULL; } Signer* GetCAByName(void* vp, byte* hash) { - return NULL ; + return NULL; } diff --git a/IDE/MDK5-ARM/include.am b/IDE/MDK5-ARM/include.am new file mode 100644 index 000000000..ffd0d42e7 --- /dev/null +++ b/IDE/MDK5-ARM/include.am @@ -0,0 +1,9 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +EXTRA_DIST+= IDE/MDK5-ARM/README.md +EXTRA_DIST+= IDE/MDK5-ARM/Conf/user_settings.h +EXTRA_DIST+= IDE/MDK5-ARM/Inc/wolfssl_MDK_ARM.h +EXTRA_DIST+= IDE/MDK5-ARM/Projects +EXTRA_DIST+= IDE/MDK5-ARM/Src/ssl-dummy.c diff --git a/IDE/include.am b/IDE/include.am index 379400d7e..ec6bcd532 100644 --- a/IDE/include.am +++ b/IDE/include.am @@ -53,6 +53,7 @@ include IDE/AURIX/include.am include IDE/MCUEXPRESSO/include.am include IDE/Espressif/include.am include IDE/STARCORE/include.am +include IDE/MDK5-ARM/include.am -EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MDK5-ARM IDE/MYSQL IDE/LPCXPRESSO IDE/HEXIWEAR IDE/Espressif +EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MYSQL IDE/LPCXPRESSO IDE/HEXIWEAR IDE/Espressif EXTRA_DIST+= IDE/OPENSTM32/README.md diff --git a/src/internal.c b/src/internal.c index c6a781afb..ce7958b6d 100644 --- a/src/internal.c +++ b/src/internal.c @@ -9256,6 +9256,13 @@ ProtocolVersion MakeDTLSv1_3(void) return sys_now()/1000; } +#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2) + + word32 LowResTimer(void) + { + return (word32)osKernelGetTickCount() / 1000; + } + #elif defined(WOLFSSL_TIRTOS) word32 LowResTimer(void) diff --git a/src/tls13.c b/src/tls13.c index 4726c8322..257750233 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -1713,6 +1713,14 @@ end: { return sys_now(); } + +#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2) + + word32 TimeNowInMilliseconds(void) + { + return (word32)osKernelGetTickCount(); + } + #elif defined(WOLFSSL_TIRTOS) /* The time in milliseconds. * Used for tickets to represent difference between when first seen and when @@ -1996,6 +2004,14 @@ end: { return sys_now(); } + +#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2) + + sword64 TimeNowInMilliseconds(void) + { + return (sword64)osKernelGetTickCount(); + } + #elif defined(WOLFSSL_TIRTOS) /* The time in milliseconds. * Used for tickets to represent difference between when first seen and when diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 6609a2e20..eb571949a 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -9020,6 +9020,14 @@ void bench_sphincsKeySign(byte level, byte optim) return (double)OSA_TimeGetMsec() / 1000; } +#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2) + + double current_time(int reset) + { + (void)reset; + return (double)osKernelGetTickCount() / 1000.0; + } + #elif defined(WOLFSSL_EMBOS) #include "RTOS.h" From 255aa774f231e896042655dfdbde4ecfe6fdfc3b Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 16 Jun 2023 12:01:30 -0700 Subject: [PATCH 2/3] Updated Keil MDK documentation to note RTOS and TCP default dependency. Fix for inline error due to tracking code being available too broadly. Use current branch for makedistsmall.sh. --- IDE/MDK5-ARM/README.md | 3 + scripts/makedistsmall.sh | 3 +- wolfssl/wolfcrypt/mem_track.h | 157 +++++++++++++++++----------------- 3 files changed, 85 insertions(+), 78 deletions(-) diff --git a/IDE/MDK5-ARM/README.md b/IDE/MDK5-ARM/README.md index 2969076ed..0b6329f38 100644 --- a/IDE/MDK5-ARM/README.md +++ b/IDE/MDK5-ARM/README.md @@ -16,6 +16,8 @@ This CMSIS pack contains the wolfCrypt and wolfSSL (TLS) libraries including tes 2) Expand "wolfSSL" and check the boxes for wolfCrypt CORE and wolfSSL CORE. 3) If running the wolfCrypt test or any of the TLS examples check those as well. +Note: By default the pack's user_settings.h assumes the CMSIS RTOS v2 and Keil TCP packs are also installed. See below for how to change these settings (`MDK_CONF_THREAD` and `MDK_CONF_NETWORK`). + If the wolfSSL::wolfSSL pack isn't showing: 1) Project -> Manage -> "Select Software Packs" 2) Make sure wolfSSL:wolfSSL is selected to "latest" @@ -30,6 +32,7 @@ If the wolfSSL::wolfSSL pack isn't showing: 3) Configure math library (`MDK_CONF_MATH`). Default 0=SP Math all (sp_int.c) 4) Configure MPU (`MDK_CONF_MPU`): If not STM32, use 0 for none. 5) Configure the RTOS (`MDK_CONF_THREAD`): By default 15 = "CMSIS RTOSv2". For bare-metal use 0. For FreeRTOS use 1. +6) Configure the TCP stack (`MDK_CONF_NETWORK`). By default uses Keil TCP `WOLFSSL_KEIL_TCP_NET`. Use 0 for none or 2 for user io callbacks. 6) For wolfCrypt only (no TLS) add `#define WOLFCRYPT_ONLY` (resolves GetCA errors) 7) Increase stack/heap (if needed). This is typically in the startup.s, but for RTX is in the `RTX_Config.h`. For CMSIS RTOSv2 stack is set in `osThreadAttr_t` on call to `osThreadNew`. diff --git a/scripts/makedistsmall.sh b/scripts/makedistsmall.sh index 24bd7f19e..325e5c15a 100755 --- a/scripts/makedistsmall.sh +++ b/scripts/makedistsmall.sh @@ -9,6 +9,7 @@ if [ "$1" == "keep" ]; then KEEP="yes"; else KEEP="no"; fi WOLFSSL_TEMPDIR=$(mktemp -d) || exit $? +WOLFSSL_BRANCH=$(git symbolic-ref --short HEAD) function cleanup_on_exit() { if [ "$KEEP" == "no" ]; @@ -34,7 +35,7 @@ fi echo "Setting up work directory..." git clone -q -n --shared . "$WOLFSSL_TEMPDIR" || exit $? pushd "$WOLFSSL_TEMPDIR" >/dev/null || exit $? -git checkout -q master || exit $? +git checkout -q "$WOLFSSL_BRANCH" # cleanup example directories echo "Removing files not needed..." diff --git a/wolfssl/wolfcrypt/mem_track.h b/wolfssl/wolfcrypt/mem_track.h index 483f14ab7..a375132fb 100644 --- a/wolfssl/wolfcrypt/mem_track.h +++ b/wolfssl/wolfcrypt/mem_track.h @@ -24,8 +24,6 @@ #ifndef WOLFSSL_MEM_TRACK_H #define WOLFSSL_MEM_TRACK_H -#if defined(USE_WOLFSSL_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY) - /* The memory tracker overrides the wolfSSL memory callback system and uses a * static to track the total, peak and currently allocated bytes. * @@ -61,7 +59,9 @@ */ #include "wolfssl/wolfcrypt/settings.h" +#include "wolfssl/wolfcrypt/types.h" #include "wolfssl/wolfcrypt/logging.h" +#include "wolfssl/wolfcrypt/error-crypt.h" #include "wolfssl/wolfcrypt/memory.h" #if defined(WOLFSSL_TRACK_MEMORY) || defined(HAVE_STACK_SIZE) || \ @@ -77,13 +77,14 @@ #endif #endif -#if defined(WOLFSSL_TRACK_MEMORY) - #define DO_MEM_STATS - #if (defined(__linux__) && !defined(WOLFSSL_LINUXKM)) || defined(__MACH__) - #define DO_MEM_LIST - #endif -#endif +/* Track Memory */ +#if defined(WOLFSSL_TRACK_MEMORY) && defined(USE_WOLFSSL_MEMORY) && \ + !defined(WOLFSSL_STATIC_MEMORY) +#define DO_MEM_STATS +#if (defined(__linux__) && !defined(WOLFSSL_LINUXKM)) || defined(__MACH__) + #define DO_MEM_LIST +#endif typedef struct memoryStats { long totalAllocs; /* number of allocations */ @@ -93,12 +94,12 @@ typedef struct memoryStats { long currentBytes; /* total current bytes in use */ #ifdef WOLFSSL_TRACK_MEMORY_VERBOSE long peakAllocsTripOdometer; /* peak number of concurrent allocations, - * subject to reset by - * wolfCrypt_heap_peak_checkpoint() - */ + * subject to reset by + * wolfCrypt_heap_peak_checkpoint() + */ long peakBytesTripOdometer; /* peak concurrent bytes, subject to reset - * by wolfCrypt_heap_peak_checkpoint() - */ + * by wolfCrypt_heap_peak_checkpoint() + */ #endif } memoryStats; @@ -119,7 +120,8 @@ typedef struct memHint { typedef struct memoryTrack { union { memHint hint; - byte alignit[sizeof(memHint) + ((16-1) & ~(16-1))]; /* make sure we have strong alignment */ + /* make sure we have strong alignment */ + byte alignit[sizeof(memHint) + ((16-1) & ~(16-1))]; } u; } memoryTrack; @@ -132,7 +134,7 @@ typedef struct memoryList { } memoryList; #endif -#if defined(WOLFSSL_TRACK_MEMORY) + static memoryStats ourMemStats; #ifdef DO_MEM_LIST @@ -140,7 +142,6 @@ static memoryStats ourMemStats; static memoryList ourMemList; static pthread_mutex_t memLock = PTHREAD_MUTEX_INITIALIZER; #endif -#endif #ifdef WOLFSSL_DEBUG_MEMORY static WC_INLINE void* TrackMalloc(size_t sz, const char* func, @@ -169,7 +170,8 @@ static WC_INLINE void* TrackMalloc(size_t sz) #ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY_PRINT - wc_mem_printf("Alloc: %p -> %u at %s:%d\n", header->thisMemory, (word32)sz, func, line); + wc_mem_printf("Alloc: %p -> %u at %s:%d\n", + header->thisMemory, (word32)sz, func, line); #else (void)func; (void)line; @@ -180,18 +182,23 @@ static WC_INLINE void* TrackMalloc(size_t sz) ourMemStats.totalAllocs++; ourMemStats.totalBytes += sz; ourMemStats.currentBytes += sz; +#ifdef WOLFSSL_TRACK_MEMORY_VERBOSE + if (ourMemStats.peakAllocsTripOdometer < ourMemStats.totalAllocs - + ourMemStats.totalDeallocs) { + ourMemStats.peakAllocsTripOdometer = ourMemStats.totalAllocs - + ourMemStats.totalDeallocs; + } + if (ourMemStats.peakBytesTripOdometer < ourMemStats.currentBytes) +#endif + { #ifdef WOLFSSL_TRACK_MEMORY_VERBOSE - if (ourMemStats.peakAllocsTripOdometer < ourMemStats.totalAllocs - ourMemStats.totalDeallocs) - ourMemStats.peakAllocsTripOdometer = ourMemStats.totalAllocs - ourMemStats.totalDeallocs; - if (ourMemStats.peakBytesTripOdometer < ourMemStats.currentBytes) { ourMemStats.peakBytesTripOdometer = ourMemStats.currentBytes; #endif if (ourMemStats.currentBytes > ourMemStats.peakBytes) ourMemStats.peakBytes = ourMemStats.currentBytes; - #ifdef WOLFSSL_TRACK_MEMORY_VERBOSE } - #endif -#endif +#endif /* DO_MEM_STATS */ + #ifdef DO_MEM_LIST if (pthread_mutex_lock(&memLock) == 0) { #ifdef WOLFSSL_DEBUG_MEMORY @@ -214,7 +221,7 @@ static WC_INLINE void* TrackMalloc(size_t sz) pthread_mutex_unlock(&memLock); } -#endif +#endif /* DO_MEM_LIST */ return header->thisMemory; } @@ -332,7 +339,6 @@ static WC_INLINE void* TrackRealloc(void* ptr, size_t sz) return ret; } -#ifdef WOLFSSL_TRACK_MEMORY static wolfSSL_Malloc_cb mfDefault = NULL; static wolfSSL_Free_cb ffDefault = NULL; static wolfSSL_Realloc_cb rfDefault = NULL; @@ -353,27 +359,26 @@ static WC_INLINE int InitMemoryTracker(void) #ifdef DO_MEM_LIST if (pthread_mutex_lock(&memLock) == 0) +#endif { -#endif + #ifdef DO_MEM_STATS + ourMemStats.totalAllocs = 0; + ourMemStats.totalDeallocs = 0; + ourMemStats.totalBytes = 0; + ourMemStats.peakBytes = 0; + ourMemStats.currentBytes = 0; + #ifdef WOLFSSL_TRACK_MEMORY_VERBOSE + ourMemStats.peakAllocsTripOdometer = 0; + ourMemStats.peakBytesTripOdometer = 0; + #endif + #endif /* DO_MEM_STATS */ -#ifdef DO_MEM_STATS - ourMemStats.totalAllocs = 0; - ourMemStats.totalDeallocs = 0; - ourMemStats.totalBytes = 0; - ourMemStats.peakBytes = 0; - ourMemStats.currentBytes = 0; -#ifdef WOLFSSL_TRACK_MEMORY_VERBOSE - ourMemStats.peakAllocsTripOdometer = 0; - ourMemStats.peakBytesTripOdometer = 0; -#endif -#endif + #ifdef DO_MEM_LIST + XMEMSET(&ourMemList, 0, sizeof(ourMemList)); -#ifdef DO_MEM_LIST - XMEMSET(&ourMemList, 0, sizeof(ourMemList)); - - pthread_mutex_unlock(&memLock); + pthread_mutex_unlock(&memLock); + #endif } -#endif return ret; } @@ -382,36 +387,38 @@ static WC_INLINE void ShowMemoryTracker(void) { #ifdef DO_MEM_LIST if (pthread_mutex_lock(&memLock) == 0) +#endif { -#endif + #ifdef DO_MEM_STATS + wc_mem_printf("total Allocs = %9ld\n", ourMemStats.totalAllocs); + wc_mem_printf("total Deallocs = %9ld\n", ourMemStats.totalDeallocs); + wc_mem_printf("total Bytes = %9ld\n", ourMemStats.totalBytes); + wc_mem_printf("peak Bytes = %9ld\n", ourMemStats.peakBytes); + wc_mem_printf("current Bytes = %9ld\n", ourMemStats.currentBytes); + #endif -#ifdef DO_MEM_STATS - wc_mem_printf("total Allocs = %9ld\n", ourMemStats.totalAllocs); - wc_mem_printf("total Deallocs = %9ld\n", ourMemStats.totalDeallocs); - wc_mem_printf("total Bytes = %9ld\n", ourMemStats.totalBytes); - wc_mem_printf("peak Bytes = %9ld\n", ourMemStats.peakBytes); - wc_mem_printf("current Bytes = %9ld\n", ourMemStats.currentBytes); -#endif - -#ifdef DO_MEM_LIST - if (ourMemList.count > 0) { - /* print list of allocations */ - memHint* header; - for (header = ourMemList.head; header != NULL; header = header->next) { - #ifdef WOLFSSL_DEBUG_MEMORY - wc_mem_printf("Leak: Ptr %p, Size %u, Func %s, Line %d\n", - (byte*)header + sizeof(memHint), (unsigned int)header->thisSize, - header->func, header->line); -#else - wc_mem_printf("Leak: Ptr %p, Size %u\n", - (byte*)header + sizeof(memHint), (unsigned int)header->thisSize); -#endif + #ifdef DO_MEM_LIST + if (ourMemList.count > 0) { + /* print list of allocations */ + memHint* header; + for (header = ourMemList.head; + header != NULL; + header = header->next) { + #ifdef WOLFSSL_DEBUG_MEMORY + wc_mem_printf("Leak: Ptr %p, Size %u, Func %s, Line %d\n", + (byte*)header + sizeof(memHint), + (unsigned int)header->thisSize, header->func, header->line); + #else + wc_mem_printf("Leak: Ptr %p, Size %u\n", + (byte*)header + sizeof(memHint), + (unsigned int)header->thisSize); + #endif + } } - } - pthread_mutex_unlock(&memLock); + pthread_mutex_unlock(&memLock); + #endif } -#endif } static WC_INLINE int CleanupMemoryTracker(void) @@ -419,9 +426,8 @@ static WC_INLINE int CleanupMemoryTracker(void) /* restore default allocators */ return wolfSSL_SetAllocators(mfDefault, ffDefault, rfDefault); } -#endif /* WOLFSSL_TRACK_MEMORY */ - -#endif /* USE_WOLFSSL_MEMORY && !WOLFSSL_STATIC_MEMORY */ +#endif /* WOLFSSL_TRACK_MEMORY && USE_WOLFSSL_MEMORY && \ + !WOLFSSL_STATIC_MEMORY */ #ifdef HAVE_STACK_SIZE @@ -432,10 +438,6 @@ static WC_INLINE int CleanupMemoryTracker(void) #include #include -#include -#include -#include - typedef void* (*thread_func)(void* args); #define STACK_CHECK_VAL 0x01 @@ -557,7 +559,8 @@ int StackSizeHWMReset(void) _ret = StackSizeHWMReset(); \ if ((max >= 0) && (HWM > (ssize_t)(max))) { \ wc_mem_printf( \ - " relative stack usage at %s L%d exceeds designated max %ld bytes.\n", \ + " relative stack usage at %s L%d exceeds designated " \ + "max %ld bytes.\n", \ __FILE__, __LINE__, (long int)(max)); \ _ret = -1; \ } \ @@ -720,7 +723,8 @@ static WC_INLINE int StackSizeCheck_launch(struct func_args* args, return 0; } -static WC_INLINE int StackSizeCheck_reap(pthread_t threadId, void *stack_context) +static WC_INLINE int StackSizeCheck_reap(pthread_t threadId, + void *stack_context) { struct stack_size_debug_context *shim_args = (struct stack_size_debug_context *)stack_context; @@ -755,7 +759,6 @@ static WC_INLINE int StackSizeCheck_reap(pthread_t threadId, void *stack_context return (int)((size_t)status); } - #endif /* HAVE_STACK_SIZE */ From 6f2831a2524fde50dfdfe3b812f653a00d283a32 Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Thu, 22 Jun 2023 16:48:14 -0600 Subject: [PATCH 3/3] Document inline build error & fix --- IDE/MDK5-ARM/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IDE/MDK5-ARM/README.md b/IDE/MDK5-ARM/README.md index 0b6329f38..f78365f74 100644 --- a/IDE/MDK5-ARM/README.md +++ b/IDE/MDK5-ARM/README.md @@ -38,6 +38,9 @@ If the wolfSSL::wolfSSL pack isn't showing: ## Building +If getting an error for an unknown type `inline`, change your project C standard to c99 in the C/C++ options. Alternatively, +add `#define WC_INLINE __inline` to `user_settings.h` to stick to c89 or the default c90. + If getting error for missing GetCA or GetCAByName then include `Src/ssl-dummy.c` or define `WOLFCRYPT_ONLY`. If getting an error with missing `current_time` then please implement a function to return elapsed seconds (used by benchmark) like this: