From 95658be0ce57df2a9770e1789fa1bfbf22b5261b Mon Sep 17 00:00:00 2001 From: Kiwamu Okabe Date: Thu, 14 Dec 2017 12:47:21 +0900 Subject: [PATCH 1/4] WICED wolfCrypt-TLS_cli_srv-Https_cli --- .cproject | 356 +++------ .project | 1 + IDE/WICED-STUDIO/README | 60 ++ IDE/WICED-STUDIO/user_settings.h | 5 + IDE/WICED-STUDIO/user_settings_folder/README | 1 + .../user_settings_folder/user_settings.h | 716 ++++++++++++++++++ IDE/WICED-STUDIO/wolfssl_lib.mk | 74 ++ wolfcrypt/src/random.c | 18 +- wolfcrypt/src/wc_port.c | 21 + wolfcrypt/test/test.c | 3 +- wolfssl/wolfcrypt/rsa.h | 4 + wolfssl/wolfcrypt/settings.h | 9 + wolfssl/wolfcrypt/wc_port.h | 6 + wolfssl/wolfio.h | 3 +- 14 files changed, 1041 insertions(+), 236 deletions(-) create mode 100644 IDE/WICED-STUDIO/README create mode 100644 IDE/WICED-STUDIO/user_settings.h create mode 100644 IDE/WICED-STUDIO/user_settings_folder/README create mode 100644 IDE/WICED-STUDIO/user_settings_folder/user_settings.h create mode 100644 IDE/WICED-STUDIO/wolfssl_lib.mk diff --git a/.cproject b/.cproject index 1db9a198e..9e1980344 100644 --- a/.cproject +++ b/.cproject @@ -1,266 +1,156 @@ - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - <?xml version="1.0" encoding="UTF-8"?> -<TargetConfig> -<Properties property_0="" property_2="LPC18x7_43x7_2x512_BootA.cfx" property_3="NXP" property_4="LPC18S37" property_count="5" version="70200"/> -<infoList vendor="NXP"><info chip="LPC18S37" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC18S37" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC18S37</name> -<family>LPC18xx</family> -<vendor>NXP (formerly Philips)</vendor> -<reset board="None" core="Real" sys="Real"/> -<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/> -<memory can_program="true" id="Flash" is_ro="true" type="Flash"/> -<memory id="RAM" type="RAM"/> -<memory id="Periph" is_volatile="true" type="Peripheral"/> -<memoryInstance derived_from="Flash" id="MFlashA512" location="0x1a000000" size="0x80000"/> -<memoryInstance derived_from="Flash" id="MFlashB512" location="0x1b000000" size="0x80000"/> -<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/> -<memoryInstance derived_from="RAM" id="RamLoc40" location="0x10080000" size="0xa000"/> -<memoryInstance derived_from="RAM" id="RamAHB32" location="0x20000000" size="0x8000"/> -<memoryInstance derived_from="RAM" id="RamAHB16" location="0x20008000" size="0x4000"/> -<memoryInstance derived_from="RAM" id="RamAHB_ETB16" location="0x2000c000" size="0x4000"/> -<prog_flash blocksz="0x2000" location="0x1a000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> -<prog_flash blocksz="0x10000" location="0x1a010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/> -<prog_flash blocksz="0x2000" location="0x1b000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> -<prog_flash blocksz="0x10000" location="0x1b010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/> -<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/> -<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/> -<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/> -<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/> -<peripheralInstance derived_from="SCT" id="SCT" location="0x40000000"/> -<peripheralInstance derived_from="GPDMA" id="GPDMA" location="0x40002000"/> -<peripheralInstance derived_from="SPIFI" id="SPIFI" location="0x40003000"/> -<peripheralInstance derived_from="SDMMC" id="SDMMC" location="0x40004000"/> -<peripheralInstance derived_from="EMC" id="EMC" location="0x40005000"/> -<peripheralInstance derived_from="USB0" id="USB0" location="0x40006000"/> -<peripheralInstance derived_from="USB1" id="USB1" location="0x40007000"/> -<peripheralInstance derived_from="EEPROM" id="EEPROM" location="0x4000e000"/> -<peripheralInstance derived_from="ETHERNET" id="ETHERNET" location="0x40010000"/> -<peripheralInstance derived_from="ATIMER" id="ATIMER" location="0x40040000"/> -<peripheralInstance derived_from="REGFILE" id="REGFILE" location="0x40041000"/> -<peripheralInstance derived_from="PMC" id="PMC" location="0x40042000"/> -<peripheralInstance derived_from="CREG" id="CREG" location="0x40043000"/> -<peripheralInstance derived_from="EVENTROUTER" id="EVENTROUTER" location="0x40044000"/> -<peripheralInstance derived_from="RTC" id="RTC" location="0x40046000"/> -<peripheralInstance derived_from="CGU" id="CGU" location="0x40050000"/> -<peripheralInstance derived_from="CCU1" id="CCU1" location="0x40051000"/> -<peripheralInstance derived_from="CCU2" id="CCU2" location="0x40052000"/> -<peripheralInstance derived_from="RGU" id="RGU" location="0x40053000"/> -<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40080000"/> -<peripheralInstance derived_from="USART0" id="USART0" location="0x40081000"/> -<peripheralInstance derived_from="USART2" id="USART2" location="0x400c1000"/> -<peripheralInstance derived_from="USART3" id="USART3" location="0x400c2000"/> -<peripheralInstance derived_from="UART1" id="UART1" location="0x40082000"/> -<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40083000"/> -<peripheralInstance derived_from="SSP1" id="SSP1" location="0x400c5000"/> -<peripheralInstance derived_from="TIMER0" id="TIMER0" location="0x40084000"/> -<peripheralInstance derived_from="TIMER1" id="TIMER1" location="0x40085000"/> -<peripheralInstance derived_from="TIMER2" id="TIMER2" location="0x400c3000"/> -<peripheralInstance derived_from="TIMER3" id="TIMER3" location="0x400c4000"/> -<peripheralInstance derived_from="SCU" id="SCU" location="0x40086000"/> -<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x40087000"/> -<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x40088000"/> -<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40089000"/> -<peripheralInstance derived_from="MCPWM" id="MCPWM" location="0x400a0000"/> -<peripheralInstance derived_from="I2C0" id="I2C0" location="0x400a1000"/> -<peripheralInstance derived_from="I2C1" id="I2C1" location="0x400e0000"/> -<peripheralInstance derived_from="I2S0" id="I2S0" location="0x400a2000"/> -<peripheralInstance derived_from="I2S1" id="I2S1" location="0x400a3000"/> -<peripheralInstance derived_from="C-CAN1" id="C-CAN1" location="0x400a4000"/> -<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x400c0000"/> -<peripheralInstance derived_from="QEI" id="QEI" location="0x400c6000"/> -<peripheralInstance derived_from="GIMA" id="GIMA" location="0x400c7000"/> -<peripheralInstance derived_from="DAC" id="DAC" location="0x400e1000"/> -<peripheralInstance derived_from="C-CAN0" id="C-CAN0" location="0x400e2000"/> -<peripheralInstance derived_from="ADC0" id="ADC0" location="0x400e3000"/> -<peripheralInstance derived_from="ADC1" id="ADC1" location="0x400e4000"/> -<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x400f4000"/> -</chip> -<processor><name gcc_name="cortex-m3">Cortex-M3</name> -<family>Cortex-M</family> -</processor> -<link href="nxp_lpc18xx_peripheral.xme" show="embed" type="simple"/> -</info> -</infoList> -</TargetConfig> - - - + + + + - - - + + + + + + + diff --git a/.project b/.project index fc8bc2812..1cbbe3e6c 100644 --- a/.project +++ b/.project @@ -24,5 +24,6 @@ org.eclipse.cdt.core.cnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.core.ccnature diff --git a/IDE/WICED-STUDIO/README b/IDE/WICED-STUDIO/README new file mode 100644 index 000000000..c93e5b7bb --- /dev/null +++ b/IDE/WICED-STUDIO/README @@ -0,0 +1,60 @@ +The wolfSSL examples in the WICED SDK requires a server application. wolfSSL +provides an easy solution in the /examples/ directory. Run the autogen +script and configure the library with necessary functionality, see ./configure -h for a +list of configure options. Finally, run make and make check to ensure the +library built successfully. You can install wolfSSL on your system with make +install if you wish. + +Run ./examples/server/server -h for a list of server options. If you would like +to test the server, you may run the client against it using your localhost. An +example of how to run the server: + ./examples/server/server -b -d -r -p 50007 + +Contained within this directory are components that you will need, make sure to +verify that you have access to: + 1. user_settings_folder + 2. wolfssl_lib.mk + +The other directories and files contained within this directory are packaged with +the wolfSSL WICED repository. The directories and files are: + 1. wolfCrypt - a snip that may be used with an existing project or if you + require the ability to add the files to a different version. This snip + runs the wolfCrypt test suite. + 2. wolfSSL_tls_client - a client snip that runs a TLS client over the WICED + TCP application. + 3. WICED.mk and BESL.mk - internal makefiles for the WICED SDK to include and + compile the wolfSSL library. + 4. Create a user_settings.h dummy file in . + +WICED SDK 6.1 with wolfSSL is available in the wolfSSL repository on github. +You will need to clone both the wolfSSL library and the WICED SDK project from +www.github.com/wolfssl. You will need to download and install the WICED +software from the Cypress website. Once you have installed the WICED SDK software: + 1. Replace the necessary directory, 43xxx_Wi-Fi in the WICED framework with + the cloned wolfSSL WICED project. + 2. Create a directory called 'wolfssl_lib.' The path should be: + 43xxx_Wi-Fi/WICED/security/BESL/wolfssl_lib. + 3. Drop in or link the wolfSSL library into the wolfssl_lib directory you + just created. + 4. The user_settings_folder directory should be placed in wolfSSL's + /wolfssl/. It should be placed at the same level as the openssl + directory. This file provides the configure options for compiling + wolfSSL with your project. + 5. The wolfssl_lib.mk should be placed at the same level as the wolfSSL + library within wolfssl_lib. The directory structure should be + WICED/security/BESL/wolfssl_lib/ and + WICED/security/BESL/wolfssl_lib/wolfssl_lib.mk. + +You can now build and use the wolfSSL and wolfCrypt snips within the WICED SDK. +Cypress includes great documentation and getting started videos to learn how to +build and run the snips as a starting off point for your project. + +wolfSSL provides a wolfCrypt and TLS Client application in the WICED snips. We +will be adding additional functionality incramentally. + + +wolfSSL acknowledges that TLS v1.3 and DTLS are not functional in the TLS client +application. The development of these features will be done incrementally. A TLS +server application and wolfQTT technology will also be added to WICED in the future. + + diff --git a/IDE/WICED-STUDIO/user_settings.h b/IDE/WICED-STUDIO/user_settings.h new file mode 100644 index 000000000..1bccdedda --- /dev/null +++ b/IDE/WICED-STUDIO/user_settings.h @@ -0,0 +1,5 @@ + +/* + * Dummy file. Place at the root level of wolfSSLl library. + * File is used with the WICED Studio software. + */ diff --git a/IDE/WICED-STUDIO/user_settings_folder/README b/IDE/WICED-STUDIO/user_settings_folder/README new file mode 100644 index 000000000..b26054b99 --- /dev/null +++ b/IDE/WICED-STUDIO/user_settings_folder/README @@ -0,0 +1 @@ +The user settings directory should be placed in wolfssl at the same level as the openssl and wolfcrypt directory. \ No newline at end of file diff --git a/IDE/WICED-STUDIO/user_settings_folder/user_settings.h b/IDE/WICED-STUDIO/user_settings_folder/user_settings.h new file mode 100644 index 000000000..622560f24 --- /dev/null +++ b/IDE/WICED-STUDIO/user_settings_folder/user_settings.h @@ -0,0 +1,716 @@ +/* user_settings.h + * + * Copyright (C) 2006-2018 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 + */ + +/* Custom wolfSSL user settings for GCC ARM */ + +#ifndef WOLFSSL_USER_SETTINGS_H +#define WOLFSSL_USER_SETTINGS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------------------------------------------------------------------- */ +/* Platform */ +/* ------------------------------------------------------------------------- */ +#undef WOLFSSL_GENERAL_ALIGNMENT +#define WOLFSSL_GENERAL_ALIGNMENT 4 + +#undef SINGLE_THREADED +#if 0 + #define SINGLE_THREADED +#endif + +#undef WOLFSSL_SMALL_STACK +#if 1 + #define WOLFSSL_SMALL_STACK +#endif + +#undef WOLFSSL_USER_IO +#define WOLFSSL_USER_IO + + +/* ------------------------------------------------------------------------- */ +/* Math Configuration */ +/* ------------------------------------------------------------------------- */ +#undef USE_FAST_MATH +#define USE_FAST_MATH + +#undef SIZEOF_LONG_LONG +#define SIZEOF_LONG_LONG 8 + +#undef USE_FAST_MATH +#if 1 + #define USE_FAST_MATH + + #undef TFM_TIMING_RESISTANT + #define TFM_TIMING_RESISTANT + + /* Optimizations */ + //#define TFM_ARM +#endif + +/* Wolf Single Precision Math */ +#undef WOLFSSL_SP +#if 0 + #define WOLFSSL_SP + #define WOLFSSL_SP_SMALL + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_DH + #define WOLFSSL_HAVE_SP_ECC + #define WOLFSSL_SP_CACHE_RESISTANT + //#define WOLFSSL_SP_MATH + + /* 64 or 32 bit version */ + //#define WOLFSSL_SP_ARM32_ASM + //#define WOLFSSL_SP_ARM64_ASM +#endif + +/* ------------------------------------------------------------------------- */ +/* FIPS - Requires eval or license from wolfSSL */ +/* ------------------------------------------------------------------------- */ +#undef HAVE_FIPS +#if 0 + #define HAVE_FIPS + + #undef HAVE_FIPS_VERSION + #define HAVE_FIPS_VERSION 2 + + #ifdef SINGLE_THREADED + #undef NO_THREAD_LS + #define NO_THREAD_LS + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Crypto */ +/* ------------------------------------------------------------------------- */ +/* RSA */ +#undef NO_RSA +#if 1 + #ifdef USE_FAST_MATH + /* Maximum math bits (Max RSA key bits * 2) */ + #undef FP_MAX_BITS + #define FP_MAX_BITS 4096 + #endif + + /* half as much memory but twice as slow */ + #undef RSA_LOW_MEM + //#define RSA_LOW_MEM + + /* Enables blinding mode, to prevent timing attacks */ + #if 1 + #undef WC_RSA_BLINDING + #define WC_RSA_BLINDING + #else + #undef WC_NO_HARDEN + #define WC_NO_HARDEN + #endif + + /* RSA PSS Support */ + #if 0 + #define WC_RSA_PSS + #endif + + #if 0 + #define WC_RSA_NO_PADDING + #endif +#else + #define NO_RSA +#endif + +/* ECC */ +#undef HAVE_ECC +#if 1 + #define HAVE_ECC + + /* Manually define enabled curves */ + #undef ECC_USER_CURVES + #define ECC_USER_CURVES + + #ifdef ECC_USER_CURVES + /* Manual Curve Selection */ + //#define HAVE_ECC192 + //#define HAVE_ECC224 + #undef NO_ECC256 + //#define HAVE_ECC384 + //#define HAVE_ECC521 + #endif + + /* Fixed point cache (speeds repeated operations against same private key) */ + #undef FP_ECC + //#define FP_ECC + #ifdef FP_ECC + /* Bits / Entries */ + #undef FP_ENTRIES + #define FP_ENTRIES 2 + #undef FP_LUT + #define FP_LUT 4 + #endif + + /* Optional ECC calculation method */ + /* Note: doubles heap usage, but slightly faster */ + #undef ECC_SHAMIR + #define ECC_SHAMIR + + #undef TFM_ECC256 + #define TFM_ECC256 + + /* Reduces heap usage, but slower */ + #undef ECC_TIMING_RESISTANT + #define ECC_TIMING_RESISTANT + + /* Enable cofactor support */ + #ifdef HAVE_FIPS + #undef HAVE_ECC_CDH + #define HAVE_ECC_CDH + #endif + + /* Validate import */ + #ifdef HAVE_FIPS + #undef WOLFSSL_VALIDATE_ECC_IMPORT + #define WOLFSSL_VALIDATE_ECC_IMPORT + #endif + + /* Compressed Key Support */ + #undef HAVE_COMP_KEY + //#define HAVE_COMP_KEY + + /* Use alternate ECC size for ECC math */ + #ifdef USE_FAST_MATH + #ifdef NO_RSA + /* Custom fastmath size if not using RSA */ + /* MAX = ROUND32(ECC BITS 256) + SIZE_OF_MP_DIGIT(32) */ + #undef FP_MAX_BITS + #define FP_MAX_BITS (256 + 32) + #else + #undef ALT_ECC_SIZE + #define ALT_ECC_SIZE + #endif + + /* Speedups specific to curve */ + #ifndef NO_ECC256 + #undef TFM_ECC256 + #define TFM_ECC256 + #endif + #endif +#endif + +/* DH */ +#undef NO_DH +#if 1 + /* Use table for DH instead of -lm (math) lib dependency */ + #if 0 + #define WOLFSSL_DH_CONST + #define HAVE_FFDHE_2048 + #define HAVE_FFDHE_4096 + //#define HAVE_FFDHE_6144 + //#define HAVE_FFDHE_8192 + #endif + + #ifdef HAVE_FIPS + #define WOLFSSL_VALIDATE_FFC_IMPORT + #define HAVE_FFDHE_Q + #endif +#else + #define NO_DH +#endif + + +/* AES */ +#undef NO_AES +#if 1 + #undef HAVE_AES_CBC + #define HAVE_AES_CBC + + #undef HAVE_AESGCM + #define HAVE_AESGCM + + /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */ + #define GCM_SMALL + + #undef WOLFSSL_AES_DIRECT + //#define WOLFSSL_AES_DIRECT + + #undef HAVE_AES_ECB + //#define HAVE_AES_ECB + + #undef WOLFSSL_AES_COUNTER + //#define WOLFSSL_AES_COUNTER + + #undef HAVE_AESCCM + #define HAVE_AESCCM +#else + #define NO_AES +#endif + + +/* DES3 */ +#undef NO_DES3 +#if 1 +#else + #define NO_DES3 +#endif + +/* ChaCha20 / Poly1305 */ +#undef HAVE_CHACHA +#undef HAVE_POLY1305 +#if 1 + #define HAVE_CHACHA + #define HAVE_POLY1305 + + /* Needed for Poly1305 */ + #undef HAVE_ONE_TIME_AUTH + #define HAVE_ONE_TIME_AUTH +#endif + +/* Ed25519 / Curve25519 */ +#undef HAVE_CURVE25519 +#undef HAVE_ED25519 +#if 0 + #define HAVE_CURVE25519 + #define HAVE_ED25519 /* ED25519 Requires SHA512 */ + + /* Optionally use small math (less flash usage, but much slower) */ + #if 1 + #define CURVED25519_SMALL + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Hashing */ +/* ------------------------------------------------------------------------- */ +/* Sha */ +#undef NO_SHA +#if 1 + /* 1k smaller, but 25% slower */ + #define USE_SLOW_SHA +#else + #define NO_SHA +#endif + +/* Sha256 */ +#undef NO_SHA256 +#if 1 + /* not unrolled - ~2k smaller and ~25% slower */ + //#define USE_SLOW_SHA256 + + /* Sha224 */ + #if 1 + #define WOLFSSL_SHA224 + #endif +#else + #define NO_SHA256 +#endif + +/* Sha512 */ +#undef WOLFSSL_SHA512 +#if 1 + #define WOLFSSL_SHA512 + + /* Sha384 */ + #undef WOLFSSL_SHA384 + #if 1 + #define WOLFSSL_SHA384 + #endif + + #undef WOLFSSL_SHA224 + #if 1 + #define WOLFSSL_SHA224 + #endif + + /* over twice as small, but 50% slower */ + //#define USE_SLOW_SHA512 +#endif + +/* Sha3 */ +#undef WOLFSSL_SHA3 +#if 0 + #define WOLFSSL_SHA3 +#endif + +/* MD5 */ +#undef NO_MD5 +#if 1 + +#else + #define NO_MD5 +#endif + +/* HKDF */ +#undef HAVE_HKDF +#if 1 + #define HAVE_HKDF +#endif + +/* CMAC */ +#undef WOLFSSL_CMAC +#if 0 + #define WOLFSSL_CMAC +#endif + + +/* ------------------------------------------------------------------------- */ +/* Benchmark / Test */ +/* ------------------------------------------------------------------------- */ +/* Use reduced benchmark / test sizes */ +#undef BENCH_EMBEDDED +#define BENCH_EMBEDDED + +#undef USE_CERT_BUFFERS_2048 +#define USE_CERT_BUFFERS_2048 + +#undef USE_CERT_BUFFERS_1024 +#define USE_CERT_BUFFERS_1024 + +#undef USE_CERT_BUFFERS_256 +#define USE_CERT_BUFFERS_256 + + +/* ------------------------------------------------------------------------- */ +/* Debugging */ +/* ------------------------------------------------------------------------- */ + +#undef DEBUG_WOLFSSL +#undef NO_ERROR_STRINGS +#if 1 + #define DEBUG_WOLFSSL +#else + #if 0 + #define NO_ERROR_STRINGS + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Memory */ +/* ------------------------------------------------------------------------- */ + +/* Override Memory API's */ +#if 0 + #undef XMALLOC_OVERRIDE + #define XMALLOC_OVERRIDE + + /* prototypes for user heap override functions */ + /* Note: Realloc only required for normal math */ + #include /* for size_t */ + extern void *myMalloc(size_t n, void* heap, int type); + extern void myFree(void *p, void* heap, int type); + extern void *myRealloc(void *p, size_t n, void* heap, int type); + + #define XMALLOC(n, h, t) myMalloc(n, h, t) + #define XFREE(p, h, t) myFree(p, h, t) + #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t) +#endif + +#if 0 + /* Static memory requires fast math */ + #define WOLFSSL_STATIC_MEMORY + + /* Disable fallback malloc/free */ + #define WOLFSSL_NO_MALLOC + #if 1 + #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */ + #endif +#endif + +/* Memory callbacks */ +#if 0 + #undef USE_WOLFSSL_MEMORY + #define USE_WOLFSSL_MEMORY + + /* Use this to measure / print heap usage */ + #if 1 + #undef WOLFSSL_TRACK_MEMORY + #define WOLFSSL_TRACK_MEMORY + + #undef WOLFSSL_DEBUG_MEMORY + #define WOLFSSL_DEBUG_MEMORY + #endif +#else + #ifndef WOLFSSL_STATIC_MEMORY + #define NO_WOLFSSL_MEMORY + /* Otherwise we will use stdlib malloc, free and realloc */ + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Port */ +/* ------------------------------------------------------------------------- */ + +/* Override Current Time */ +/* Allows custom "custom_time()" function to be used for benchmark */ +#define WOLFSSL_USER_CURRTIME +#define WOLFSSL_GMTIME +//#define USER_TICKS +extern unsigned long my_time(unsigned long* timer); +#if 0 + #define XTIME my_time +#endif + + +/* ------------------------------------------------------------------------- */ +/* RNG */ +/* ------------------------------------------------------------------------- */ + +/* Seed Source */ +/* Size of returned HW RNG value */ +//#define CUSTOM_RAND_TYPE unsigned int +extern unsigned int my_rng_seed_gen(void); +#undef CUSTOM_RAND_GENERATE +//#define CUSTOM_RAND_GENERATE my_rng_seed_gen + +/* Choose RNG method */ +#if 1 + /* Use built-in P-RNG (SHA256 based) with HW RNG */ + /* P-RNG + HW RNG (P-RNG is ~8K) */ + #undef HAVE_HASHDRBG + #define HAVE_HASHDRBG +#else + #undef WC_NO_HASHDRBG + #define WC_NO_HASHDRBG + + /* Bypass P-RNG and use only HW RNG */ + extern int my_rng_gen_block(unsigned char* output, unsigned int sz); + #undef CUSTOM_RAND_GENERATE_BLOCK + #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block +#endif + + +/* ------------------------------------------------------------------------- */ +/* Custom Standard Lib */ +/* ------------------------------------------------------------------------- */ +/* Allows override of all standard library functions */ +#undef STRING_USER +#if 1 + #define STRING_USER + + #include + + #undef USE_WOLF_STRSEP + #define USE_WOLF_STRSEP + #define XSTRSEP(s1,d) wc_strsep((s1),(d)) + + #undef USE_WOLF_STRTOK + #define USE_WOLF_STRTOK + #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr)) + + #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n)) + + #define XMEMCPY(d,s,l) memcpy((d),(s),(l)) + #define XMEMSET(b,c,l) memset((b),(c),(l)) + #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n)) + #define XMEMMOVE(d,s,l) memmove((d),(s),(l)) + + #define XSTRLEN(s1) strlen((s1)) + #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) + #define XSTRSTR(s1,s2) strstr((s1),(s2)) + + #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n)) + #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n)) + #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n)) + + #define XSNPRINTF snprintf +#endif + + + +/* ------------------------------------------------------------------------- */ +/* Enable Features */ +/* ------------------------------------------------------------------------- */ +#undef WOLFSSL_TLS13 +#if 0 + #define WOLFSSL_TLS13 +#endif + +#undef WOLFSSL_KEY_GEN +#if 0 + #define WOLFSSL_KEY_GEN +#endif + +#if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN) + #define WOLFSSL_OLD_PRIME_CHECK +#endif + +#undef KEEP_PEER_CERT +//#define KEEP_PEER_CERT + +#undef HAVE_COMP_KEY +//#define HAVE_COMP_KEY + +#undef HAVE_TLS_EXTENSIONS +#define HAVE_TLS_EXTENSIONS + +#undef HAVE_SUPPORTED_CURVES +#define HAVE_SUPPORTED_CURVES + +#undef WOLFSSL_BASE64_ENCODE +#define WOLFSSL_BASE64_ENCODE + +/* TLS Session Cache */ +#if 1 + #define SMALL_SESSION_CACHE +#else + #define NO_SESSION_CACHE +#endif + +#undef HAVE_EXTENDED_MASTER +#define HAVE_EXTENDED_MASTER + +#undef HAVE_TRUNCATED_HMAC +#define HAVE_TRUNCATED_HMAC + +#undef WOLFSSL_ALLOW_TLSV10 +#define WOLFSSL_ALLOW_TLSV10 + + + +#undef HAVE_MAX_FRAGMENT +#if 0 + /* Set maximum fragment size. */ + #define HAVE_MAX_FRAGMENT +#endif + +#if 1 + #define FP_MAX_BITS_ECC 512 +#endif + +/* ------------------------------------------------------------------------- */ +/* TCP STACK */ +/* ------------------------------------------------------------------------- */ +#undef HAVE_NETX +#if 1 + #define HAVE_NETX +#endif +#undef WOLFSSL_LWIP +#if 0 + #define WOLFSSL_LWIP +#endif + +/* ------------------------------------------------------------------------- */ +/* RTOS */ +/* ------------------------------------------------------------------------- */ +#undef THREADX +#if 1 + #define THREADX + #undef THREADX_NO_DC_PRINTF + #if 1 + #define THREADX_NO_DC_PRINTF + #endif +#endif + +/* ------------------------------------------------------------------------- */ +/* Disable Features */ +/* ------------------------------------------------------------------------- */ +#undef NO_WOLFSSL_SERVER +//#define NO_WOLFSSL_SERVER + +#undef NO_WOLFSSL_CLIENT +//#define NO_WOLFSSL_CLIENT + +#undef NO_CRYPT_TEST +//#define NO_CRYPT_TEST + +#undef NO_CRYPT_BENCHMARK +//#define NO_CRYPT_BENCHMARK + +#undef WOLFCRYPT_ONLY +//#define WOLFCRYPT_ONLY + +/* In-lining of misc.c functions */ +/* If defined, must include wolfcrypt/src/misc.c in build */ +/* Slower, but about 1k smaller */ +#undef NO_INLINE +//#define NO_INLINE + +#undef NO_FILESYSTEM +#define NO_FILESYSTEM + +#undef NO_WRITEV +#define NO_WRITEV + +#undef NO_MAIN_DRIVER +#define NO_MAIN_DRIVER + +#undef NO_DEV_RANDOM +#define NO_DEV_RANDOM + +#undef NO_DSA +//#define NO_DSA + +#undef NO_RC4 +//#define NO_RC4 + +#undef NO_OLD_TLS +//#define NO_OLD_TLS + +#undef NO_HC128 +//#define NO_HC128 + +#undef NO_RABBIT +//#define NO_RABBIT + +#undef NO_PSK +#define NO_PSK + +#undef NO_MD4 +//#define NO_MD4 + +#undef NO_PWDBASED +#define NO_PWDBASED + +#undef NO_CODING +//#define NO_CODING + +#undef NO_ASN_TIME +//#define NO_ASN_TIME + +#undef NO_CERTS +//#define NO_CERTS + +#undef NO_SIG_WRAPPER +//#define NO_SIG_WRAPPER + +#undef NO_OLD_WC_NAMES +//#define NO_OLD_WC_NAMES + +#undef NO_WOLFSSL_DIR +//#define NO_WOLFSSL_DIR + +/* ------------------------------------------------------------------------- */ +/* WICED SDK */ +/* ------------------------------------------------------------------------- */ +#undef WOLFSSL_WICED +#if 1 + #define WOLFSSL_WICED + #undef WICED_MBEDTLS +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* WOLFSSL_USER_SETTINGS_H */ diff --git a/IDE/WICED-STUDIO/wolfssl_lib.mk b/IDE/WICED-STUDIO/wolfssl_lib.mk new file mode 100644 index 000000000..8977e8058 --- /dev/null +++ b/IDE/WICED-STUDIO/wolfssl_lib.mk @@ -0,0 +1,74 @@ + # error-ssl.h + # + # Copyright (C) 2006-2017 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 + + + +NAME := wolfSSL + +$(NAME)_SOURCES += wolfssl/src/internal.c \ + wolfssl/src/keys.c \ + wolfssl/src/ssl.c \ + wolfssl/src/tls.c \ + wolfssl/src/wolfio.c \ + wolfssl/wolfcrypt/src/aes.c \ + wolfssl/wolfcrypt/src/asn.c \ + wolfssl/wolfcrypt/src/chacha.c \ + wolfssl/wolfcrypt/src/chacha20_poly1305.c \ + wolfssl/wolfcrypt/src/coding.c \ + wolfssl/wolfcrypt/src/cpuid.c \ + wolfssl/wolfcrypt/src/des3.c \ + wolfssl/wolfcrypt/src/dh.c \ + wolfssl/wolfcrypt/src/ecc.c \ + wolfssl/wolfcrypt/src/error.c \ + wolfssl/wolfcrypt/src/hash.c \ + wolfssl/wolfcrypt/src/hmac.c \ + wolfssl/wolfcrypt/src/logging.c \ + wolfssl/wolfcrypt/src/md4.c \ + wolfssl/wolfcrypt/src/md5.c \ + wolfssl/wolfcrypt/src/memory.c \ + wolfssl/wolfcrypt/src/poly1305.c \ + wolfssl/wolfcrypt/src/random.c \ + wolfssl/wolfcrypt/src/rsa.c \ + wolfssl/wolfcrypt/src/sha.c \ + wolfssl/wolfcrypt/src/sha256.c \ + wolfssl/wolfcrypt/src/sha3.c \ + wolfssl/wolfcrypt/src/sha512.c \ + wolfssl/wolfcrypt/src/signature.c \ + wolfssl/wolfcrypt/src/tfm.c \ + wolfssl/wolfcrypt/src/wc_encrypt.c \ + wolfssl/wolfcrypt/src/wc_port.c \ + wolfssl/wolfcrypt/src/wolfmath.c \ + wolfssl/wolfcrypt/test/test.c \ + wolfssl/wolfcrypt/src/ripemd.c \ + wolfssl/wolfcrypt/src/dsa.c \ + wolfssl/wolfcrypt/src/arc4.c \ + wolfssl/wolfcrypt/src/rabbit.c \ + wolfssl/wolfcrypt/src/curve25519.c \ + wolfssl/wolfcrypt/src/ed25519.c + +GLOBAL_INCLUDES += wolfssl \ + user_settings_folder \ + + +GLOBAL_DEFINES += WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME=$(shell $(PERL) -e "print time()") \ + WOLFSSL_USER_SETTINGS + + +GLOBAL_CFLAGS += -g1 diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 16aa57896..3bb20980d 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -134,7 +134,8 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b) #include "fsl_trng.h" #elif defined(FREESCALE_KSDK_2_0_RNGA) #include "fsl_rnga.h" - +#elif defined(WOLFSSL_WICED) + #include "wiced_crypto.h" #elif defined(NO_DEV_RANDOM) #elif defined(CUSTOM_RAND_GENERATE) #elif defined(CUSTOM_RAND_GENERATE_BLOCK) @@ -2048,6 +2049,21 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return ret; } +#elif defined(WOLFSSL_WICED) + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + + (void)os; + if (output == NULL || UINT16_MAX < sz) { + return BUFFER_E; + } + + wiced_crypto_get_random((void*) output, sz); + + return 0; + } + #elif defined(IDIRECT_DEV_RANDOM) extern int getRandom( int sz, unsigned char *output ); diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index e717e57ba..ea1b304e2 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -1855,6 +1855,27 @@ time_t z_time(time_t * timer) #endif /* WOLFSSL_ZEPHYR */ + +#if defined(WOLFSSL_WICED) + #ifndef WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME + #error Please define WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME at build time. + #endif /* WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME */ + +time_t wiced_pseudo_unix_epoch_time(time_t * timer) +{ + time_t epoch_time; + + /* The time() function return uptime on WICED platform. */ + epoch_time = time(NULL) + WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME; + + if (timer != NULL) { + *timer = epoch_time; + } + + return epoch_time; +} + +#endif /* WOLFSSL_WICED */ #endif /* !NO_ASN_TIME */ #ifndef WOLFSSL_LEANPSK diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index e3df4f272..643086cbf 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -25,6 +25,7 @@ #endif #include +#include #ifdef XMALLOC_USER #include /* we're using malloc / free direct here */ @@ -200,7 +201,7 @@ #endif -#ifdef THREADX +#if defined(THREADX) && !defined(WOLFSSL_WICED) /* since just testing, use THREADX log printf instead */ int dc_log_printf(char*, ...); #undef printf diff --git a/wolfssl/wolfcrypt/rsa.h b/wolfssl/wolfcrypt/rsa.h index 86d4b93e1..05271ac1d 100644 --- a/wolfssl/wolfcrypt/rsa.h +++ b/wolfssl/wolfcrypt/rsa.h @@ -100,6 +100,10 @@ enum { #endif #endif +#if !defined(NO_OLD_WC_NAMES) + #define RSA_PUBLIC WC_RSA_PUBLIC +#endif + enum { RSA_PUBLIC = 0, RSA_PRIVATE = 1, diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index fd568f5cc..159d4a766 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -172,6 +172,11 @@ /* Uncomment next line if building for using XILINX */ /* #define WOLFSSL_XILINX */ +/* Uncomment the next line when using WICED Studio. */ +/* #ifndef WOLFSSL_WICED + #define WOLFSSL_WICED + #endif +*/ /* Uncomment next line if building for Nucleus 1.2 */ /* #define WOLFSSL_NUCLEUS_1_2 */ @@ -217,6 +222,10 @@ #define SIZEOF_LONG_LONG 8 #endif +#if defined(WOLFSSL_WICED) + #include "wolfssl/user_settings_folder/user_settings.h" +#endif + #ifdef THREADX #define SIZEOF_LONG_LONG 8 #endif diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 429559300..6255a1ac7 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -500,6 +500,12 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define USE_WOLF_TM #define USE_WOLF_TIME_T +#elif defined(WOLFSSL_WICED) + #include + time_t wiced_pseudo_unix_epoch_time(time_t * timer); + #define XTIME(t1) wiced_pseudo_unix_epoch_time((t1)) + #define HAVE_GMTIME_R + #elif defined(IDIRECT_DEV_TIME) /*Gets the timestamp from cloak software owned by VT iDirect in place of time() from */ diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index 83b27749a..a37b43f91 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -131,7 +131,8 @@ #elif defined(EBSNET) #include "rtipapi.h" /* errno */ #include "socket.h" - #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_CONTIKI) + #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) \ + && !defined(WOLFSSL_CONTIKI) && !defined(WOLFSSL_WICED) #include #include #include From 8a47af0edc588ed14b118014ad19e6fe52d69152 Mon Sep 17 00:00:00 2001 From: jrblixt Date: Tue, 5 Feb 2019 13:32:40 -0700 Subject: [PATCH 2/4] Added benchmark tests to WICED wolfcrypt test app. Updated the user_settings.h loc per David. TLS13; SNI; MAX_FRAG Configure for wolfCrypt bench. Update README. --- .cproject | 356 ++++++--- .project | 1 - IDE/WICED-STUDIO/README | 60 +- IDE/WICED-STUDIO/user_settings.h | 720 +++++++++++++++++- IDE/WICED-STUDIO/user_settings_folder/README | 1 - .../user_settings_folder/user_settings.h | 716 ----------------- IDE/WICED-STUDIO/wolfssl_lib.mk | 13 +- wolfcrypt/src/random.c | 2 - wolfcrypt/src/wc_port.c | 3 - wolfcrypt/test/test.c | 1 - wolfssl/wolfcrypt/rsa.h | 4 - wolfssl/wolfcrypt/settings.h | 11 +- 12 files changed, 981 insertions(+), 907 deletions(-) delete mode 100644 IDE/WICED-STUDIO/user_settings_folder/README delete mode 100644 IDE/WICED-STUDIO/user_settings_folder/user_settings.h diff --git a/.cproject b/.cproject index 9e1980344..1db9a198e 100644 --- a/.cproject +++ b/.cproject @@ -1,156 +1,266 @@ - - - + + + + + + + + + + + + - - - + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + <?xml version="1.0" encoding="UTF-8"?> +<TargetConfig> +<Properties property_0="" property_2="LPC18x7_43x7_2x512_BootA.cfx" property_3="NXP" property_4="LPC18S37" property_count="5" version="70200"/> +<infoList vendor="NXP"><info chip="LPC18S37" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC18S37" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC18S37</name> +<family>LPC18xx</family> +<vendor>NXP (formerly Philips)</vendor> +<reset board="None" core="Real" sys="Real"/> +<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/> +<memory can_program="true" id="Flash" is_ro="true" type="Flash"/> +<memory id="RAM" type="RAM"/> +<memory id="Periph" is_volatile="true" type="Peripheral"/> +<memoryInstance derived_from="Flash" id="MFlashA512" location="0x1a000000" size="0x80000"/> +<memoryInstance derived_from="Flash" id="MFlashB512" location="0x1b000000" size="0x80000"/> +<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/> +<memoryInstance derived_from="RAM" id="RamLoc40" location="0x10080000" size="0xa000"/> +<memoryInstance derived_from="RAM" id="RamAHB32" location="0x20000000" size="0x8000"/> +<memoryInstance derived_from="RAM" id="RamAHB16" location="0x20008000" size="0x4000"/> +<memoryInstance derived_from="RAM" id="RamAHB_ETB16" location="0x2000c000" size="0x4000"/> +<prog_flash blocksz="0x2000" location="0x1a000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x10000" location="0x1a010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/> +<prog_flash blocksz="0x2000" location="0x1b000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x10000" location="0x1b010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/> +<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/> +<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/> +<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/> +<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/> +<peripheralInstance derived_from="SCT" id="SCT" location="0x40000000"/> +<peripheralInstance derived_from="GPDMA" id="GPDMA" location="0x40002000"/> +<peripheralInstance derived_from="SPIFI" id="SPIFI" location="0x40003000"/> +<peripheralInstance derived_from="SDMMC" id="SDMMC" location="0x40004000"/> +<peripheralInstance derived_from="EMC" id="EMC" location="0x40005000"/> +<peripheralInstance derived_from="USB0" id="USB0" location="0x40006000"/> +<peripheralInstance derived_from="USB1" id="USB1" location="0x40007000"/> +<peripheralInstance derived_from="EEPROM" id="EEPROM" location="0x4000e000"/> +<peripheralInstance derived_from="ETHERNET" id="ETHERNET" location="0x40010000"/> +<peripheralInstance derived_from="ATIMER" id="ATIMER" location="0x40040000"/> +<peripheralInstance derived_from="REGFILE" id="REGFILE" location="0x40041000"/> +<peripheralInstance derived_from="PMC" id="PMC" location="0x40042000"/> +<peripheralInstance derived_from="CREG" id="CREG" location="0x40043000"/> +<peripheralInstance derived_from="EVENTROUTER" id="EVENTROUTER" location="0x40044000"/> +<peripheralInstance derived_from="RTC" id="RTC" location="0x40046000"/> +<peripheralInstance derived_from="CGU" id="CGU" location="0x40050000"/> +<peripheralInstance derived_from="CCU1" id="CCU1" location="0x40051000"/> +<peripheralInstance derived_from="CCU2" id="CCU2" location="0x40052000"/> +<peripheralInstance derived_from="RGU" id="RGU" location="0x40053000"/> +<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40080000"/> +<peripheralInstance derived_from="USART0" id="USART0" location="0x40081000"/> +<peripheralInstance derived_from="USART2" id="USART2" location="0x400c1000"/> +<peripheralInstance derived_from="USART3" id="USART3" location="0x400c2000"/> +<peripheralInstance derived_from="UART1" id="UART1" location="0x40082000"/> +<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40083000"/> +<peripheralInstance derived_from="SSP1" id="SSP1" location="0x400c5000"/> +<peripheralInstance derived_from="TIMER0" id="TIMER0" location="0x40084000"/> +<peripheralInstance derived_from="TIMER1" id="TIMER1" location="0x40085000"/> +<peripheralInstance derived_from="TIMER2" id="TIMER2" location="0x400c3000"/> +<peripheralInstance derived_from="TIMER3" id="TIMER3" location="0x400c4000"/> +<peripheralInstance derived_from="SCU" id="SCU" location="0x40086000"/> +<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x40087000"/> +<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x40088000"/> +<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40089000"/> +<peripheralInstance derived_from="MCPWM" id="MCPWM" location="0x400a0000"/> +<peripheralInstance derived_from="I2C0" id="I2C0" location="0x400a1000"/> +<peripheralInstance derived_from="I2C1" id="I2C1" location="0x400e0000"/> +<peripheralInstance derived_from="I2S0" id="I2S0" location="0x400a2000"/> +<peripheralInstance derived_from="I2S1" id="I2S1" location="0x400a3000"/> +<peripheralInstance derived_from="C-CAN1" id="C-CAN1" location="0x400a4000"/> +<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x400c0000"/> +<peripheralInstance derived_from="QEI" id="QEI" location="0x400c6000"/> +<peripheralInstance derived_from="GIMA" id="GIMA" location="0x400c7000"/> +<peripheralInstance derived_from="DAC" id="DAC" location="0x400e1000"/> +<peripheralInstance derived_from="C-CAN0" id="C-CAN0" location="0x400e2000"/> +<peripheralInstance derived_from="ADC0" id="ADC0" location="0x400e3000"/> +<peripheralInstance derived_from="ADC1" id="ADC1" location="0x400e4000"/> +<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x400f4000"/> +</chip> +<processor><name gcc_name="cortex-m3">Cortex-M3</name> +<family>Cortex-M</family> +</processor> +<link href="nxp_lpc18xx_peripheral.xme" show="embed" type="simple"/> +</info> +</infoList> +</TargetConfig> + + - + - - - + + + - - - - - - - diff --git a/.project b/.project index 1cbbe3e6c..fc8bc2812 100644 --- a/.project +++ b/.project @@ -24,6 +24,5 @@ org.eclipse.cdt.core.cnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.core.ccnature diff --git a/IDE/WICED-STUDIO/README b/IDE/WICED-STUDIO/README index c93e5b7bb..3d9613be6 100644 --- a/IDE/WICED-STUDIO/README +++ b/IDE/WICED-STUDIO/README @@ -1,60 +1,44 @@ -The wolfSSL examples in the WICED SDK requires a server application. wolfSSL +The wolfSSL examples in the WICED SDK require a server application. wolfSSL provides an easy solution in the /examples/ directory. Run the autogen script and configure the library with necessary functionality, see ./configure -h for a list of configure options. Finally, run make and make check to ensure the -library built successfully. You can install wolfSSL on your system with make -install if you wish. +library build was successfull. You can install wolfSSL on your system with make +install if you wish. See www.wolfssl.com/docs/ for more information. Run ./examples/server/server -h for a list of server options. If you would like to test the server, you may run the client against it using your localhost. An example of how to run the server: ./examples/server/server -b -d -r -p 50007 -Contained within this directory are components that you will need, make sure to -verify that you have access to: - 1. user_settings_folder - 2. wolfssl_lib.mk +Download and install WICED Studio from the Cypress website. -The other directories and files contained within this directory are packaged with -the wolfSSL WICED repository. The directories and files are: - 1. wolfCrypt - a snip that may be used with an existing project or if you - require the ability to add the files to a different version. This snip - runs the wolfCrypt test suite. - 2. wolfSSL_tls_client - a client snip that runs a TLS client over the WICED - TCP application. - 3. WICED.mk and BESL.mk - internal makefiles for the WICED SDK to include and - compile the wolfSSL library. - 4. Create a user_settings.h dummy file in . +The necessary files are located in the /IDE/WICED-STUDIO/ directory. +These files will be described in the following setup proceedure to get you started +with any TLS project. -WICED SDK 6.1 with wolfSSL is available in the wolfSSL repository on github. -You will need to clone both the wolfSSL library and the WICED SDK project from -www.github.com/wolfssl. You will need to download and install the WICED -software from the Cypress website. Once you have installed the WICED SDK software: - 1. Replace the necessary directory, 43xxx_Wi-Fi in the WICED framework with - the cloned wolfSSL WICED project. - 2. Create a directory called 'wolfssl_lib.' The path should be: - 43xxx_Wi-Fi/WICED/security/BESL/wolfssl_lib. +Once you have installed the WICED software: + 1. Create a directory called 'wolfssl_lib.' The path should be: + 43xxx_Wi-Fi/WICED/security/BESL/wolfssl_lib. 3. Drop in or link the wolfSSL library into the wolfssl_lib directory you just created. - 4. The user_settings_folder directory should be placed in wolfSSL's - /wolfssl/. It should be placed at the same level as the openssl - directory. This file provides the configure options for compiling - wolfSSL with your project. + 4. The user_settings.h file in the IDE/WICED-STUDIO/ directory should be place + at . This file provides the configure options for compiling + wolfSSL with your project. The default values will give you a starting point + and you may further configure the library. 5. The wolfssl_lib.mk should be placed at the same level as the wolfSSL library within wolfssl_lib. The directory structure should be WICED/security/BESL/wolfssl_lib/ and WICED/security/BESL/wolfssl_lib/wolfssl_lib.mk. - + 6. Apply the patches: git apply --ignore-space-change + --ignore-whitespace mychanges.patch + You can now build and use the wolfSSL and wolfCrypt snips within the WICED SDK. Cypress includes great documentation and getting started videos to learn how to -build and run the snips as a starting off point for your project. +build and run the snips. -wolfSSL provides a wolfCrypt and TLS Client application in the WICED snips. We -will be adding additional functionality incramentally. - - -wolfSSL acknowledges that TLS v1.3 and DTLS are not functional in the TLS client -application. The development of these features will be done incrementally. A TLS -server application and wolfQTT technology will also be added to WICED in the future. +wolfSSL provides a wolfCrypt test application, a TLS client and server application, +and an HTTPS client application. Future development and additions will be made. +Further instructions and documentation can be found on the wolfSSL website at +www.wolfssl.com or visit us on our forums at www.wolfssl.com/forums/. diff --git a/IDE/WICED-STUDIO/user_settings.h b/IDE/WICED-STUDIO/user_settings.h index 1bccdedda..d7b08e932 100644 --- a/IDE/WICED-STUDIO/user_settings.h +++ b/IDE/WICED-STUDIO/user_settings.h @@ -1,5 +1,717 @@ - -/* - * Dummy file. Place at the root level of wolfSSLl library. - * File is used with the WICED Studio software. + /* Copyright (C) 2006-2018 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 */ + +/* Custom wolfSSL user settings for GCC ARM */ + +#ifndef WOLFSSL_USER_SETTINGS_H +#define WOLFSSL_USER_SETTINGS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------------------------------------------------------------------- */ +/* Platform */ +/* ------------------------------------------------------------------------- */ +#undef WOLFSSL_GENERAL_ALIGNMENT +#define WOLFSSL_GENERAL_ALIGNMENT 4 + +#undef SINGLE_THREADED +#if 0 + #define SINGLE_THREADED +#endif + +#undef WOLFSSL_SMALL_STACK +#if 1 + #define WOLFSSL_SMALL_STACK +#endif + +#undef WOLFSSL_USER_IO +#define WOLFSSL_USER_IO + + +/* ------------------------------------------------------------------------- */ +/* Math Configuration */ +/* ------------------------------------------------------------------------- */ +#undef USE_FAST_MATH +#define USE_FAST_MATH + +#undef SIZEOF_LONG_LONG +#define SIZEOF_LONG_LONG 8 + +#undef USE_FAST_MATH +#if 1 + #define USE_FAST_MATH + + #undef TFM_TIMING_RESISTANT + #define TFM_TIMING_RESISTANT + + /* Optimizations */ + //#define TFM_ARM +#endif + +/* Wolf Single Precision Math */ +#undef WOLFSSL_SP +#if 0 + #define WOLFSSL_SP + #define WOLFSSL_SP_SMALL + #define WOLFSSL_HAVE_SP_RSA + #define WOLFSSL_HAVE_SP_DH + #define WOLFSSL_HAVE_SP_ECC + #define WOLFSSL_SP_CACHE_RESISTANT + //#define WOLFSSL_SP_MATH + + /* 64 or 32 bit version */ + //#define WOLFSSL_SP_ARM32_ASM + //#define WOLFSSL_SP_ARM64_ASM +#endif + +/* ------------------------------------------------------------------------- */ +/* FIPS - Requires eval or license from wolfSSL */ +/* ------------------------------------------------------------------------- */ +#undef HAVE_FIPS +#if 0 + #define HAVE_FIPS + + #undef HAVE_FIPS_VERSION + #define HAVE_FIPS_VERSION 2 + + #ifdef SINGLE_THREADED + #undef NO_THREAD_LS + #define NO_THREAD_LS + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Crypto */ +/* ------------------------------------------------------------------------- */ +/* RSA */ +#undef NO_RSA +#if 1 + #ifdef USE_FAST_MATH + /* Maximum math bits (Max RSA key bits * 2) */ + #undef FP_MAX_BITS + #define FP_MAX_BITS 4096 + #endif + + /* half as much memory but twice as slow */ + #undef RSA_LOW_MEM + //#define RSA_LOW_MEM + + /* Enables blinding mode, to prevent timing attacks */ + #if 1 + #undef WC_RSA_BLINDING + #define WC_RSA_BLINDING + #else + #undef WC_NO_HARDEN + #define WC_NO_HARDEN + #endif + + /* RSA PSS Support */ + #if 1 + #define WC_RSA_PSS + #endif + + #if 0 + #define WC_RSA_NO_PADDING + #endif +#else + #define NO_RSA +#endif + +/* ECC */ +#undef HAVE_ECC +#if 1 + #define HAVE_ECC + + /* Manually define enabled curves */ + #undef ECC_USER_CURVES + #define ECC_USER_CURVES + + #ifdef ECC_USER_CURVES + /* Manual Curve Selection */ + //#define HAVE_ECC192 + //#define HAVE_ECC224 + #undef NO_ECC256 + //#define HAVE_ECC384 + //#define HAVE_ECC521 + #endif + + /* Fixed point cache (speeds repeated operations against same private key) */ + #undef FP_ECC + //#define FP_ECC + #ifdef FP_ECC + /* Bits / Entries */ + #undef FP_ENTRIES + #define FP_ENTRIES 2 + #undef FP_LUT + #define FP_LUT 4 + #endif + + /* Optional ECC calculation method */ + /* Note: doubles heap usage, but slightly faster */ + #undef ECC_SHAMIR + #define ECC_SHAMIR + + #undef TFM_ECC256 + #define TFM_ECC256 + + /* Reduces heap usage, but slower */ + #undef ECC_TIMING_RESISTANT + #define ECC_TIMING_RESISTANT + + /* Enable cofactor support */ + #ifdef HAVE_FIPS + #undef HAVE_ECC_CDH + #define HAVE_ECC_CDH + #endif + + /* Validate import */ + #ifdef HAVE_FIPS + #undef WOLFSSL_VALIDATE_ECC_IMPORT + #define WOLFSSL_VALIDATE_ECC_IMPORT + #endif + + /* Compressed Key Support */ + #undef HAVE_COMP_KEY + //#define HAVE_COMP_KEY + + /* Use alternate ECC size for ECC math */ + #ifdef USE_FAST_MATH + #ifdef NO_RSA + /* Custom fastmath size if not using RSA */ + /* MAX = ROUND32(ECC BITS 256) + SIZE_OF_MP_DIGIT(32) */ + #undef FP_MAX_BITS + #define FP_MAX_BITS (256 + 32) + #else + #undef ALT_ECC_SIZE + #define ALT_ECC_SIZE + #endif + + /* Speedups specific to curve */ + #ifndef NO_ECC256 + #undef TFM_ECC256 + #define TFM_ECC256 + #endif + #endif +#endif + +/* DH */ +#undef NO_DH +#if 1 + /* Use table for DH instead of -lm (math) lib dependency */ + #if 1 + #define WOLFSSL_DH_CONST + #define HAVE_FFDHE_2048 + #define HAVE_FFDHE_4096 + //#define HAVE_FFDHE_6144 + //#define HAVE_FFDHE_8192 + #endif + + #ifdef HAVE_FIPS + #define WOLFSSL_VALIDATE_FFC_IMPORT + #define HAVE_FFDHE_Q + #endif +#else + #define NO_DH +#endif + + +/* AES */ +#undef NO_AES +#if 1 + #undef HAVE_AES_CBC + #define HAVE_AES_CBC + + #undef HAVE_AESGCM + #define HAVE_AESGCM + + /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */ + #define GCM_SMALL + + #undef WOLFSSL_AES_DIRECT + #define WOLFSSL_AES_DIRECT + + #undef HAVE_AES_ECB + //#define HAVE_AES_ECB + + #undef WOLFSSL_AES_COUNTER + #define WOLFSSL_AES_COUNTER + + #undef HAVE_AESCCM + #define HAVE_AESCCM +#else + #define NO_AES +#endif + + +/* DES3 */ +#undef NO_DES3 +#if 1 +#else + #define NO_DES3 +#endif + +/* ChaCha20 / Poly1305 */ +#undef HAVE_CHACHA +#undef HAVE_POLY1305 +#if 1 + #define HAVE_CHACHA + #define HAVE_POLY1305 + + /* Needed for Poly1305 */ + #undef HAVE_ONE_TIME_AUTH + #define HAVE_ONE_TIME_AUTH +#endif + +/* Ed25519 / Curve25519 */ +#undef HAVE_CURVE25519 +#undef HAVE_ED25519 +#if 0 + #define HAVE_CURVE25519 + #define HAVE_ED25519 /* ED25519 Requires SHA512 */ + + /* Optionally use small math (less flash usage, but much slower) */ + #if 1 + #define CURVED25519_SMALL + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Hashing */ +/* ------------------------------------------------------------------------- */ +/* Sha */ +#undef NO_SHA +#if 1 + /* 1k smaller, but 25% slower */ + #define USE_SLOW_SHA +#else + #define NO_SHA +#endif + +/* Sha256 */ +#undef NO_SHA256 +#if 1 + /* not unrolled - ~2k smaller and ~25% slower */ + //#define USE_SLOW_SHA256 + + /* Sha224 */ + #if 1 + #define WOLFSSL_SHA224 + #endif +#else + #define NO_SHA256 +#endif + +/* Sha512 */ +#undef WOLFSSL_SHA512 +#if 1 + #define WOLFSSL_SHA512 + + /* Sha384 */ + #undef WOLFSSL_SHA384 + #if 1 + #define WOLFSSL_SHA384 + #endif + + #undef WOLFSSL_SHA224 + #if 1 + #define WOLFSSL_SHA224 + #endif + + /* over twice as small, but 50% slower */ + //#define USE_SLOW_SHA512 +#endif + +/* Sha3 */ +#undef WOLFSSL_SHA3 +#if 0 + #define WOLFSSL_SHA3 +#endif + +/* MD5 */ +#undef NO_MD5 +#if 1 + +#else + #define NO_MD5 +#endif + +/* HKDF */ +#undef HAVE_HKDF +#if 1 + #define HAVE_HKDF +#endif + +/* CMAC */ +#undef WOLFSSL_CMAC +#if 0 + #define WOLFSSL_CMAC +#endif + + +/* ------------------------------------------------------------------------- */ +/* Benchmark / Test */ +/* ------------------------------------------------------------------------- */ +/* Use reduced benchmark / test sizes */ +#undef BENCH_EMBEDDED +#define BENCH_EMBEDDED + +#undef USE_CERT_BUFFERS_2048 +#define USE_CERT_BUFFERS_2048 + +#undef USE_CERT_BUFFERS_1024 +#define USE_CERT_BUFFERS_1024 + +#undef USE_CERT_BUFFERS_256 +#define USE_CERT_BUFFERS_256 + + +/* ------------------------------------------------------------------------- */ +/* Debugging */ +/* ------------------------------------------------------------------------- */ + +#undef DEBUG_WOLFSSL +#undef NO_ERROR_STRINGS +#if 1 + #define DEBUG_WOLFSSL +#else + #if 0 + #define NO_ERROR_STRINGS + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Memory */ +/* ------------------------------------------------------------------------- */ + +/* Override Memory API's */ +#if 0 + #undef XMALLOC_OVERRIDE + #define XMALLOC_OVERRIDE + + /* prototypes for user heap override functions */ + /* Note: Realloc only required for normal math */ + #include /* for size_t */ + extern void *myMalloc(size_t n, void* heap, int type); + extern void myFree(void *p, void* heap, int type); + extern void *myRealloc(void *p, size_t n, void* heap, int type); + + #define XMALLOC(n, h, t) myMalloc(n, h, t) + #define XFREE(p, h, t) myFree(p, h, t) + #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t) +#endif + +#if 0 + /* Static memory requires fast math */ + #define WOLFSSL_STATIC_MEMORY + + /* Disable fallback malloc/free */ + #define WOLFSSL_NO_MALLOC + #if 1 + #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */ + #endif +#endif + +/* Memory callbacks */ +#if 0 + #undef USE_WOLFSSL_MEMORY + #define USE_WOLFSSL_MEMORY + + /* Use this to measure / print heap usage */ + #if 1 + #undef WOLFSSL_TRACK_MEMORY + #define WOLFSSL_TRACK_MEMORY + + #undef WOLFSSL_DEBUG_MEMORY + #define WOLFSSL_DEBUG_MEMORY + #endif +#else + #ifndef WOLFSSL_STATIC_MEMORY + #define NO_WOLFSSL_MEMORY + /* Otherwise we will use stdlib malloc, free and realloc */ + #endif +#endif + + +/* ------------------------------------------------------------------------- */ +/* Port */ +/* ------------------------------------------------------------------------- */ + +/* Override Current Time */ +/* Allows custom "custom_time()" function to be used for benchmark */ +//#define WOLFSSL_USER_CURRTIME +//#define WOLFSSL_GMTIME +//#define USER_TICKS +extern unsigned long my_time(unsigned long* timer); +#if 0 + #define XTIME my_time +#endif + + +/* ------------------------------------------------------------------------- */ +/* RNG */ +/* ------------------------------------------------------------------------- */ + +/* Seed Source */ +/* Size of returned HW RNG value */ +//#define CUSTOM_RAND_TYPE unsigned int +extern unsigned int my_rng_seed_gen(void); +#undef CUSTOM_RAND_GENERATE +//#define CUSTOM_RAND_GENERATE my_rng_seed_gen + +/* Choose RNG method */ +#if 1 + /* Use built-in P-RNG (SHA256 based) with HW RNG */ + /* P-RNG + HW RNG (P-RNG is ~8K) */ + #undef HAVE_HASHDRBG + #define HAVE_HASHDRBG +#else + #undef WC_NO_HASHDRBG + #define WC_NO_HASHDRBG + + /* Bypass P-RNG and use only HW RNG */ + extern int my_rng_gen_block(unsigned char* output, unsigned int sz); + #undef CUSTOM_RAND_GENERATE_BLOCK + #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block +#endif + + +/* ------------------------------------------------------------------------- */ +/* Custom Standard Lib */ +/* ------------------------------------------------------------------------- */ +/* Allows override of all standard library functions */ +#undef STRING_USER +#if 1 + #define STRING_USER + + #include + + #undef USE_WOLF_STRSEP + #define USE_WOLF_STRSEP + #define XSTRSEP(s1,d) wc_strsep((s1),(d)) + + #undef USE_WOLF_STRTOK + #define USE_WOLF_STRTOK + #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr)) + + #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n)) + + #define XMEMCPY(d,s,l) memcpy((d),(s),(l)) + #define XMEMSET(b,c,l) memset((b),(c),(l)) + #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n)) + #define XMEMMOVE(d,s,l) memmove((d),(s),(l)) + + #define XSTRLEN(s1) strlen((s1)) + #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) + #define XSTRSTR(s1,s2) strstr((s1),(s2)) + + #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n)) + #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n)) + #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n)) + + #define XSNPRINTF snprintf +#endif + + + +/* ------------------------------------------------------------------------- */ +/* Enable Features */ +/* ------------------------------------------------------------------------- */ +#undef WOLFSSL_TLS13 +#if 1 + #define WOLFSSL_TLS13 +#endif + +#undef WOLFSSL_KEY_GEN +#if 0 + #define WOLFSSL_KEY_GEN +#endif + +#if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN) + #define WOLFSSL_OLD_PRIME_CHECK +#endif + +#undef KEEP_PEER_CERT +//#define KEEP_PEER_CERT + +#undef HAVE_COMP_KEY +//#define HAVE_COMP_KEY + +#undef HAVE_TLS_EXTENSIONS +#define HAVE_TLS_EXTENSIONS + +#undef HAVE_SUPPORTED_CURVES +#define HAVE_SUPPORTED_CURVES + +#undef WOLFSSL_BASE64_ENCODE +#define WOLFSSL_BASE64_ENCODE + +/* TLS Session Cache */ +#if 1 + #define SMALL_SESSION_CACHE +#else + #define NO_SESSION_CACHE +#endif + +#undef HAVE_EXTENDED_MASTER +#define HAVE_EXTENDED_MASTER + +#undef HAVE_TRUNCATED_HMAC +#define HAVE_TRUNCATED_HMAC + +#undef WOLFSSL_ALLOW_TLSV10 +#define WOLFSSL_ALLOW_TLSV10 + +#undef HAVE_SNI +#if 1 + #define HAVE_SNI +#endif + +#undef HAVE_MAX_FRAGMENT +#if 1 + /* Set maximum fragment size. */ + #define HAVE_MAX_FRAGMENT +#endif + +#if 1 + #define FP_MAX_BITS_ECC 512 +#endif + +/* ------------------------------------------------------------------------- */ +/* TCP STACK */ +/* ------------------------------------------------------------------------- */ +#undef HAVE_NETX +#if 1 + #define HAVE_NETX +#endif +#undef WOLFSSL_LWIP +#if 0 + #define WOLFSSL_LWIP +#endif + +/* ------------------------------------------------------------------------- */ +/* RTOS */ +/* ------------------------------------------------------------------------- */ +#undef THREADX +#if 1 + #define THREADX + #undef THREADX_NO_DC_PRINTF + #if 1 + #define THREADX_NO_DC_PRINTF + #endif +#endif + +/* ------------------------------------------------------------------------- */ +/* Disable Features */ +/* ------------------------------------------------------------------------- */ +#undef NO_WOLFSSL_SERVER +//#define NO_WOLFSSL_SERVER + +#undef NO_WOLFSSL_CLIENT +//#define NO_WOLFSSL_CLIENT + +#undef NO_CRYPT_TEST +//#define NO_CRYPT_TEST + +#undef NO_CRYPT_BENCHMARK +//#define NO_CRYPT_BENCHMARK + +#undef WOLFCRYPT_ONLY +//#define WOLFCRYPT_ONLY + +/* In-lining of misc.c functions */ +/* If defined, must include wolfcrypt/src/misc.c in build */ +/* Slower, but about 1k smaller */ +#undef NO_INLINE +//#define NO_INLINE + +#undef NO_FILESYSTEM +#define NO_FILESYSTEM + +#undef NO_WRITEV +#define NO_WRITEV + +#undef NO_MAIN_DRIVER +#define NO_MAIN_DRIVER + +#undef NO_DEV_RANDOM +#define NO_DEV_RANDOM + +#undef NO_DSA +//#define NO_DSA + +#undef NO_RC4 +//#define NO_RC4 + +#undef NO_OLD_TLS +//#define NO_OLD_TLS + +#undef NO_HC128 +//#define NO_HC128 + +#undef NO_RABBIT +//#define NO_RABBIT + +#undef NO_PSK +//#define NO_PSK + +#undef NO_MD4 +//#define NO_MD4 + +#undef NO_PWDBASED +#define NO_PWDBASED + +#undef NO_CODING +//#define NO_CODING + +#undef NO_ASN_TIME +//#define NO_ASN_TIME + +#undef NO_CERTS +//#define NO_CERTS + +#undef NO_SIG_WRAPPER +//#define NO_SIG_WRAPPER + +#undef NO_OLD_WC_NAMES +//#define NO_OLD_WC_NAMES + +#undef NO_WOLFSSL_DIR +//#define NO_WOLFSSL_DIR + +/* ------------------------------------------------------------------------- */ +/* WICED SDK */ +/* ------------------------------------------------------------------------- */ +#undef WOLFSSL_WICED +#if 1 + #define WOLFSSL_WICED + #undef WICED_MBEDTLS +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* WOLFSSL_USER_SETTINGS_H */ diff --git a/IDE/WICED-STUDIO/user_settings_folder/README b/IDE/WICED-STUDIO/user_settings_folder/README deleted file mode 100644 index b26054b99..000000000 --- a/IDE/WICED-STUDIO/user_settings_folder/README +++ /dev/null @@ -1 +0,0 @@ -The user settings directory should be placed in wolfssl at the same level as the openssl and wolfcrypt directory. \ No newline at end of file diff --git a/IDE/WICED-STUDIO/user_settings_folder/user_settings.h b/IDE/WICED-STUDIO/user_settings_folder/user_settings.h deleted file mode 100644 index 622560f24..000000000 --- a/IDE/WICED-STUDIO/user_settings_folder/user_settings.h +++ /dev/null @@ -1,716 +0,0 @@ -/* user_settings.h - * - * Copyright (C) 2006-2018 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 - */ - -/* Custom wolfSSL user settings for GCC ARM */ - -#ifndef WOLFSSL_USER_SETTINGS_H -#define WOLFSSL_USER_SETTINGS_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* ------------------------------------------------------------------------- */ -/* Platform */ -/* ------------------------------------------------------------------------- */ -#undef WOLFSSL_GENERAL_ALIGNMENT -#define WOLFSSL_GENERAL_ALIGNMENT 4 - -#undef SINGLE_THREADED -#if 0 - #define SINGLE_THREADED -#endif - -#undef WOLFSSL_SMALL_STACK -#if 1 - #define WOLFSSL_SMALL_STACK -#endif - -#undef WOLFSSL_USER_IO -#define WOLFSSL_USER_IO - - -/* ------------------------------------------------------------------------- */ -/* Math Configuration */ -/* ------------------------------------------------------------------------- */ -#undef USE_FAST_MATH -#define USE_FAST_MATH - -#undef SIZEOF_LONG_LONG -#define SIZEOF_LONG_LONG 8 - -#undef USE_FAST_MATH -#if 1 - #define USE_FAST_MATH - - #undef TFM_TIMING_RESISTANT - #define TFM_TIMING_RESISTANT - - /* Optimizations */ - //#define TFM_ARM -#endif - -/* Wolf Single Precision Math */ -#undef WOLFSSL_SP -#if 0 - #define WOLFSSL_SP - #define WOLFSSL_SP_SMALL - #define WOLFSSL_HAVE_SP_RSA - #define WOLFSSL_HAVE_SP_DH - #define WOLFSSL_HAVE_SP_ECC - #define WOLFSSL_SP_CACHE_RESISTANT - //#define WOLFSSL_SP_MATH - - /* 64 or 32 bit version */ - //#define WOLFSSL_SP_ARM32_ASM - //#define WOLFSSL_SP_ARM64_ASM -#endif - -/* ------------------------------------------------------------------------- */ -/* FIPS - Requires eval or license from wolfSSL */ -/* ------------------------------------------------------------------------- */ -#undef HAVE_FIPS -#if 0 - #define HAVE_FIPS - - #undef HAVE_FIPS_VERSION - #define HAVE_FIPS_VERSION 2 - - #ifdef SINGLE_THREADED - #undef NO_THREAD_LS - #define NO_THREAD_LS - #endif -#endif - - -/* ------------------------------------------------------------------------- */ -/* Crypto */ -/* ------------------------------------------------------------------------- */ -/* RSA */ -#undef NO_RSA -#if 1 - #ifdef USE_FAST_MATH - /* Maximum math bits (Max RSA key bits * 2) */ - #undef FP_MAX_BITS - #define FP_MAX_BITS 4096 - #endif - - /* half as much memory but twice as slow */ - #undef RSA_LOW_MEM - //#define RSA_LOW_MEM - - /* Enables blinding mode, to prevent timing attacks */ - #if 1 - #undef WC_RSA_BLINDING - #define WC_RSA_BLINDING - #else - #undef WC_NO_HARDEN - #define WC_NO_HARDEN - #endif - - /* RSA PSS Support */ - #if 0 - #define WC_RSA_PSS - #endif - - #if 0 - #define WC_RSA_NO_PADDING - #endif -#else - #define NO_RSA -#endif - -/* ECC */ -#undef HAVE_ECC -#if 1 - #define HAVE_ECC - - /* Manually define enabled curves */ - #undef ECC_USER_CURVES - #define ECC_USER_CURVES - - #ifdef ECC_USER_CURVES - /* Manual Curve Selection */ - //#define HAVE_ECC192 - //#define HAVE_ECC224 - #undef NO_ECC256 - //#define HAVE_ECC384 - //#define HAVE_ECC521 - #endif - - /* Fixed point cache (speeds repeated operations against same private key) */ - #undef FP_ECC - //#define FP_ECC - #ifdef FP_ECC - /* Bits / Entries */ - #undef FP_ENTRIES - #define FP_ENTRIES 2 - #undef FP_LUT - #define FP_LUT 4 - #endif - - /* Optional ECC calculation method */ - /* Note: doubles heap usage, but slightly faster */ - #undef ECC_SHAMIR - #define ECC_SHAMIR - - #undef TFM_ECC256 - #define TFM_ECC256 - - /* Reduces heap usage, but slower */ - #undef ECC_TIMING_RESISTANT - #define ECC_TIMING_RESISTANT - - /* Enable cofactor support */ - #ifdef HAVE_FIPS - #undef HAVE_ECC_CDH - #define HAVE_ECC_CDH - #endif - - /* Validate import */ - #ifdef HAVE_FIPS - #undef WOLFSSL_VALIDATE_ECC_IMPORT - #define WOLFSSL_VALIDATE_ECC_IMPORT - #endif - - /* Compressed Key Support */ - #undef HAVE_COMP_KEY - //#define HAVE_COMP_KEY - - /* Use alternate ECC size for ECC math */ - #ifdef USE_FAST_MATH - #ifdef NO_RSA - /* Custom fastmath size if not using RSA */ - /* MAX = ROUND32(ECC BITS 256) + SIZE_OF_MP_DIGIT(32) */ - #undef FP_MAX_BITS - #define FP_MAX_BITS (256 + 32) - #else - #undef ALT_ECC_SIZE - #define ALT_ECC_SIZE - #endif - - /* Speedups specific to curve */ - #ifndef NO_ECC256 - #undef TFM_ECC256 - #define TFM_ECC256 - #endif - #endif -#endif - -/* DH */ -#undef NO_DH -#if 1 - /* Use table for DH instead of -lm (math) lib dependency */ - #if 0 - #define WOLFSSL_DH_CONST - #define HAVE_FFDHE_2048 - #define HAVE_FFDHE_4096 - //#define HAVE_FFDHE_6144 - //#define HAVE_FFDHE_8192 - #endif - - #ifdef HAVE_FIPS - #define WOLFSSL_VALIDATE_FFC_IMPORT - #define HAVE_FFDHE_Q - #endif -#else - #define NO_DH -#endif - - -/* AES */ -#undef NO_AES -#if 1 - #undef HAVE_AES_CBC - #define HAVE_AES_CBC - - #undef HAVE_AESGCM - #define HAVE_AESGCM - - /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */ - #define GCM_SMALL - - #undef WOLFSSL_AES_DIRECT - //#define WOLFSSL_AES_DIRECT - - #undef HAVE_AES_ECB - //#define HAVE_AES_ECB - - #undef WOLFSSL_AES_COUNTER - //#define WOLFSSL_AES_COUNTER - - #undef HAVE_AESCCM - #define HAVE_AESCCM -#else - #define NO_AES -#endif - - -/* DES3 */ -#undef NO_DES3 -#if 1 -#else - #define NO_DES3 -#endif - -/* ChaCha20 / Poly1305 */ -#undef HAVE_CHACHA -#undef HAVE_POLY1305 -#if 1 - #define HAVE_CHACHA - #define HAVE_POLY1305 - - /* Needed for Poly1305 */ - #undef HAVE_ONE_TIME_AUTH - #define HAVE_ONE_TIME_AUTH -#endif - -/* Ed25519 / Curve25519 */ -#undef HAVE_CURVE25519 -#undef HAVE_ED25519 -#if 0 - #define HAVE_CURVE25519 - #define HAVE_ED25519 /* ED25519 Requires SHA512 */ - - /* Optionally use small math (less flash usage, but much slower) */ - #if 1 - #define CURVED25519_SMALL - #endif -#endif - - -/* ------------------------------------------------------------------------- */ -/* Hashing */ -/* ------------------------------------------------------------------------- */ -/* Sha */ -#undef NO_SHA -#if 1 - /* 1k smaller, but 25% slower */ - #define USE_SLOW_SHA -#else - #define NO_SHA -#endif - -/* Sha256 */ -#undef NO_SHA256 -#if 1 - /* not unrolled - ~2k smaller and ~25% slower */ - //#define USE_SLOW_SHA256 - - /* Sha224 */ - #if 1 - #define WOLFSSL_SHA224 - #endif -#else - #define NO_SHA256 -#endif - -/* Sha512 */ -#undef WOLFSSL_SHA512 -#if 1 - #define WOLFSSL_SHA512 - - /* Sha384 */ - #undef WOLFSSL_SHA384 - #if 1 - #define WOLFSSL_SHA384 - #endif - - #undef WOLFSSL_SHA224 - #if 1 - #define WOLFSSL_SHA224 - #endif - - /* over twice as small, but 50% slower */ - //#define USE_SLOW_SHA512 -#endif - -/* Sha3 */ -#undef WOLFSSL_SHA3 -#if 0 - #define WOLFSSL_SHA3 -#endif - -/* MD5 */ -#undef NO_MD5 -#if 1 - -#else - #define NO_MD5 -#endif - -/* HKDF */ -#undef HAVE_HKDF -#if 1 - #define HAVE_HKDF -#endif - -/* CMAC */ -#undef WOLFSSL_CMAC -#if 0 - #define WOLFSSL_CMAC -#endif - - -/* ------------------------------------------------------------------------- */ -/* Benchmark / Test */ -/* ------------------------------------------------------------------------- */ -/* Use reduced benchmark / test sizes */ -#undef BENCH_EMBEDDED -#define BENCH_EMBEDDED - -#undef USE_CERT_BUFFERS_2048 -#define USE_CERT_BUFFERS_2048 - -#undef USE_CERT_BUFFERS_1024 -#define USE_CERT_BUFFERS_1024 - -#undef USE_CERT_BUFFERS_256 -#define USE_CERT_BUFFERS_256 - - -/* ------------------------------------------------------------------------- */ -/* Debugging */ -/* ------------------------------------------------------------------------- */ - -#undef DEBUG_WOLFSSL -#undef NO_ERROR_STRINGS -#if 1 - #define DEBUG_WOLFSSL -#else - #if 0 - #define NO_ERROR_STRINGS - #endif -#endif - - -/* ------------------------------------------------------------------------- */ -/* Memory */ -/* ------------------------------------------------------------------------- */ - -/* Override Memory API's */ -#if 0 - #undef XMALLOC_OVERRIDE - #define XMALLOC_OVERRIDE - - /* prototypes for user heap override functions */ - /* Note: Realloc only required for normal math */ - #include /* for size_t */ - extern void *myMalloc(size_t n, void* heap, int type); - extern void myFree(void *p, void* heap, int type); - extern void *myRealloc(void *p, size_t n, void* heap, int type); - - #define XMALLOC(n, h, t) myMalloc(n, h, t) - #define XFREE(p, h, t) myFree(p, h, t) - #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t) -#endif - -#if 0 - /* Static memory requires fast math */ - #define WOLFSSL_STATIC_MEMORY - - /* Disable fallback malloc/free */ - #define WOLFSSL_NO_MALLOC - #if 1 - #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */ - #endif -#endif - -/* Memory callbacks */ -#if 0 - #undef USE_WOLFSSL_MEMORY - #define USE_WOLFSSL_MEMORY - - /* Use this to measure / print heap usage */ - #if 1 - #undef WOLFSSL_TRACK_MEMORY - #define WOLFSSL_TRACK_MEMORY - - #undef WOLFSSL_DEBUG_MEMORY - #define WOLFSSL_DEBUG_MEMORY - #endif -#else - #ifndef WOLFSSL_STATIC_MEMORY - #define NO_WOLFSSL_MEMORY - /* Otherwise we will use stdlib malloc, free and realloc */ - #endif -#endif - - -/* ------------------------------------------------------------------------- */ -/* Port */ -/* ------------------------------------------------------------------------- */ - -/* Override Current Time */ -/* Allows custom "custom_time()" function to be used for benchmark */ -#define WOLFSSL_USER_CURRTIME -#define WOLFSSL_GMTIME -//#define USER_TICKS -extern unsigned long my_time(unsigned long* timer); -#if 0 - #define XTIME my_time -#endif - - -/* ------------------------------------------------------------------------- */ -/* RNG */ -/* ------------------------------------------------------------------------- */ - -/* Seed Source */ -/* Size of returned HW RNG value */ -//#define CUSTOM_RAND_TYPE unsigned int -extern unsigned int my_rng_seed_gen(void); -#undef CUSTOM_RAND_GENERATE -//#define CUSTOM_RAND_GENERATE my_rng_seed_gen - -/* Choose RNG method */ -#if 1 - /* Use built-in P-RNG (SHA256 based) with HW RNG */ - /* P-RNG + HW RNG (P-RNG is ~8K) */ - #undef HAVE_HASHDRBG - #define HAVE_HASHDRBG -#else - #undef WC_NO_HASHDRBG - #define WC_NO_HASHDRBG - - /* Bypass P-RNG and use only HW RNG */ - extern int my_rng_gen_block(unsigned char* output, unsigned int sz); - #undef CUSTOM_RAND_GENERATE_BLOCK - #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block -#endif - - -/* ------------------------------------------------------------------------- */ -/* Custom Standard Lib */ -/* ------------------------------------------------------------------------- */ -/* Allows override of all standard library functions */ -#undef STRING_USER -#if 1 - #define STRING_USER - - #include - - #undef USE_WOLF_STRSEP - #define USE_WOLF_STRSEP - #define XSTRSEP(s1,d) wc_strsep((s1),(d)) - - #undef USE_WOLF_STRTOK - #define USE_WOLF_STRTOK - #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr)) - - #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n)) - - #define XMEMCPY(d,s,l) memcpy((d),(s),(l)) - #define XMEMSET(b,c,l) memset((b),(c),(l)) - #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n)) - #define XMEMMOVE(d,s,l) memmove((d),(s),(l)) - - #define XSTRLEN(s1) strlen((s1)) - #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) - #define XSTRSTR(s1,s2) strstr((s1),(s2)) - - #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n)) - #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n)) - #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n)) - - #define XSNPRINTF snprintf -#endif - - - -/* ------------------------------------------------------------------------- */ -/* Enable Features */ -/* ------------------------------------------------------------------------- */ -#undef WOLFSSL_TLS13 -#if 0 - #define WOLFSSL_TLS13 -#endif - -#undef WOLFSSL_KEY_GEN -#if 0 - #define WOLFSSL_KEY_GEN -#endif - -#if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN) - #define WOLFSSL_OLD_PRIME_CHECK -#endif - -#undef KEEP_PEER_CERT -//#define KEEP_PEER_CERT - -#undef HAVE_COMP_KEY -//#define HAVE_COMP_KEY - -#undef HAVE_TLS_EXTENSIONS -#define HAVE_TLS_EXTENSIONS - -#undef HAVE_SUPPORTED_CURVES -#define HAVE_SUPPORTED_CURVES - -#undef WOLFSSL_BASE64_ENCODE -#define WOLFSSL_BASE64_ENCODE - -/* TLS Session Cache */ -#if 1 - #define SMALL_SESSION_CACHE -#else - #define NO_SESSION_CACHE -#endif - -#undef HAVE_EXTENDED_MASTER -#define HAVE_EXTENDED_MASTER - -#undef HAVE_TRUNCATED_HMAC -#define HAVE_TRUNCATED_HMAC - -#undef WOLFSSL_ALLOW_TLSV10 -#define WOLFSSL_ALLOW_TLSV10 - - - -#undef HAVE_MAX_FRAGMENT -#if 0 - /* Set maximum fragment size. */ - #define HAVE_MAX_FRAGMENT -#endif - -#if 1 - #define FP_MAX_BITS_ECC 512 -#endif - -/* ------------------------------------------------------------------------- */ -/* TCP STACK */ -/* ------------------------------------------------------------------------- */ -#undef HAVE_NETX -#if 1 - #define HAVE_NETX -#endif -#undef WOLFSSL_LWIP -#if 0 - #define WOLFSSL_LWIP -#endif - -/* ------------------------------------------------------------------------- */ -/* RTOS */ -/* ------------------------------------------------------------------------- */ -#undef THREADX -#if 1 - #define THREADX - #undef THREADX_NO_DC_PRINTF - #if 1 - #define THREADX_NO_DC_PRINTF - #endif -#endif - -/* ------------------------------------------------------------------------- */ -/* Disable Features */ -/* ------------------------------------------------------------------------- */ -#undef NO_WOLFSSL_SERVER -//#define NO_WOLFSSL_SERVER - -#undef NO_WOLFSSL_CLIENT -//#define NO_WOLFSSL_CLIENT - -#undef NO_CRYPT_TEST -//#define NO_CRYPT_TEST - -#undef NO_CRYPT_BENCHMARK -//#define NO_CRYPT_BENCHMARK - -#undef WOLFCRYPT_ONLY -//#define WOLFCRYPT_ONLY - -/* In-lining of misc.c functions */ -/* If defined, must include wolfcrypt/src/misc.c in build */ -/* Slower, but about 1k smaller */ -#undef NO_INLINE -//#define NO_INLINE - -#undef NO_FILESYSTEM -#define NO_FILESYSTEM - -#undef NO_WRITEV -#define NO_WRITEV - -#undef NO_MAIN_DRIVER -#define NO_MAIN_DRIVER - -#undef NO_DEV_RANDOM -#define NO_DEV_RANDOM - -#undef NO_DSA -//#define NO_DSA - -#undef NO_RC4 -//#define NO_RC4 - -#undef NO_OLD_TLS -//#define NO_OLD_TLS - -#undef NO_HC128 -//#define NO_HC128 - -#undef NO_RABBIT -//#define NO_RABBIT - -#undef NO_PSK -#define NO_PSK - -#undef NO_MD4 -//#define NO_MD4 - -#undef NO_PWDBASED -#define NO_PWDBASED - -#undef NO_CODING -//#define NO_CODING - -#undef NO_ASN_TIME -//#define NO_ASN_TIME - -#undef NO_CERTS -//#define NO_CERTS - -#undef NO_SIG_WRAPPER -//#define NO_SIG_WRAPPER - -#undef NO_OLD_WC_NAMES -//#define NO_OLD_WC_NAMES - -#undef NO_WOLFSSL_DIR -//#define NO_WOLFSSL_DIR - -/* ------------------------------------------------------------------------- */ -/* WICED SDK */ -/* ------------------------------------------------------------------------- */ -#undef WOLFSSL_WICED -#if 1 - #define WOLFSSL_WICED - #undef WICED_MBEDTLS -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* WOLFSSL_USER_SETTINGS_H */ diff --git a/IDE/WICED-STUDIO/wolfssl_lib.mk b/IDE/WICED-STUDIO/wolfssl_lib.mk index 8977e8058..37985926f 100644 --- a/IDE/WICED-STUDIO/wolfssl_lib.mk +++ b/IDE/WICED-STUDIO/wolfssl_lib.mk @@ -1,5 +1,3 @@ - # error-ssl.h - # # Copyright (C) 2006-2017 wolfSSL Inc. # # This file is part of wolfSSL. @@ -17,7 +15,7 @@ # 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 - + NAME := wolfSSL @@ -33,6 +31,7 @@ $(NAME)_SOURCES += wolfssl/src/internal.c \ wolfssl/wolfcrypt/src/chacha20_poly1305.c \ wolfssl/wolfcrypt/src/coding.c \ wolfssl/wolfcrypt/src/cpuid.c \ + wolfssl/wolfcrypt/src/cmac.c \ wolfssl/wolfcrypt/src/des3.c \ wolfssl/wolfcrypt/src/dh.c \ wolfssl/wolfcrypt/src/ecc.c \ @@ -61,14 +60,16 @@ $(NAME)_SOURCES += wolfssl/src/internal.c \ wolfssl/wolfcrypt/src/arc4.c \ wolfssl/wolfcrypt/src/rabbit.c \ wolfssl/wolfcrypt/src/curve25519.c \ - wolfssl/wolfcrypt/src/ed25519.c + wolfssl/wolfcrypt/src/ed25519.c \ + wolfssl/wolfcrypt/benchmark/benchmark.c \ + wolfssl/src/tls13.c GLOBAL_INCLUDES += wolfssl \ user_settings_folder \ GLOBAL_DEFINES += WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME=$(shell $(PERL) -e "print time()") \ - WOLFSSL_USER_SETTINGS + WOLFSSL_USER_SETTINGS + - GLOBAL_CFLAGS += -g1 diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 3bb20980d..a99b76326 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -2050,10 +2050,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) } #elif defined(WOLFSSL_WICED) - int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) { - (void)os; if (output == NULL || UINT16_MAX < sz) { return BUFFER_E; diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index ea1b304e2..67265a4b8 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -1864,17 +1864,14 @@ time_t z_time(time_t * timer) time_t wiced_pseudo_unix_epoch_time(time_t * timer) { time_t epoch_time; - /* The time() function return uptime on WICED platform. */ epoch_time = time(NULL) + WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME; if (timer != NULL) { *timer = epoch_time; } - return epoch_time; } - #endif /* WOLFSSL_WICED */ #endif /* !NO_ASN_TIME */ diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 643086cbf..d05f2399d 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -25,7 +25,6 @@ #endif #include -#include #ifdef XMALLOC_USER #include /* we're using malloc / free direct here */ diff --git a/wolfssl/wolfcrypt/rsa.h b/wolfssl/wolfcrypt/rsa.h index 05271ac1d..86d4b93e1 100644 --- a/wolfssl/wolfcrypt/rsa.h +++ b/wolfssl/wolfcrypt/rsa.h @@ -100,10 +100,6 @@ enum { #endif #endif -#if !defined(NO_OLD_WC_NAMES) - #define RSA_PUBLIC WC_RSA_PUBLIC -#endif - enum { RSA_PUBLIC = 0, RSA_PRIVATE = 1, diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 159d4a766..7a0d84e8a 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -172,11 +172,10 @@ /* Uncomment next line if building for using XILINX */ /* #define WOLFSSL_XILINX */ -/* Uncomment the next line when using WICED Studio. */ -/* #ifndef WOLFSSL_WICED +/* Uncomment the next three lines when using WICED Studio. */ + /* #ifndef WOLFSSL_WICED #define WOLFSSL_WICED - #endif -*/ + #endif */ /* Uncomment next line if building for Nucleus 1.2 */ /* #define WOLFSSL_NUCLEUS_1_2 */ @@ -222,10 +221,6 @@ #define SIZEOF_LONG_LONG 8 #endif -#if defined(WOLFSSL_WICED) - #include "wolfssl/user_settings_folder/user_settings.h" -#endif - #ifdef THREADX #define SIZEOF_LONG_LONG 8 #endif From e01723a43537213c71e42e7469c3224108468d83 Mon Sep 17 00:00:00 2001 From: jrblixt Date: Tue, 26 Feb 2019 09:29:39 -0700 Subject: [PATCH 3/4] Code review changes. --- IDE/WICED-STUDIO/README | 44 +++++++++---------- IDE/WICED-STUDIO/wolfssl_lib.mk | 75 --------------------------------- wolfssl/wolfcrypt/settings.h | 7 ++- 3 files changed, 25 insertions(+), 101 deletions(-) delete mode 100644 IDE/WICED-STUDIO/wolfssl_lib.mk diff --git a/IDE/WICED-STUDIO/README b/IDE/WICED-STUDIO/README index 3d9613be6..35c2f5d77 100644 --- a/IDE/WICED-STUDIO/README +++ b/IDE/WICED-STUDIO/README @@ -1,44 +1,44 @@ -The wolfSSL examples in the WICED SDK require a server application. wolfSSL +The wolfSSL examples in the WICED SDK require a server or client application. wolfSSL provides an easy solution in the /examples/ directory. Run the autogen script and configure the library with necessary functionality, see ./configure -h for a list of configure options. Finally, run make and make check to ensure the -library build was successfull. You can install wolfSSL on your system with make +build was successfull. You can install wolfSSL on your system with make install if you wish. See www.wolfssl.com/docs/ for more information. -Run ./examples/server/server -h for a list of server options. If you would like -to test the server, you may run the client against it using your localhost. An -example of how to run the server: - ./examples/server/server -b -d -r -p 50007 +Run ./examples/server/server -h for a list of server options or +./examples/client/client -h for client options. If you would like +to test the server or client, you may run them on localhost. Instructions on +running the client or server can be found in the snip code examles. The snips are +meant to be a starting off point for your applications. Download and install WICED Studio from the Cypress website. -The necessary files are located in the /IDE/WICED-STUDIO/ directory. -These files will be described in the following setup proceedure to get you started -with any TLS project. +In the /IDE/WICED-STUDIO/ directory, you will find the library file +user_settings.h which should be copied to . This is your wolfSSL +configuration file. Please see www.wolfssl.com/docs/ for detailed instructions on +how to use the configure options. Once you have installed the WICED software: 1. Create a directory called 'wolfssl_lib.' The path should be: - 43xxx_Wi-Fi/WICED/security/BESL/wolfssl_lib. - 3. Drop in or link the wolfSSL library into the wolfssl_lib directory you - just created. + 43xxx_Wi-Fi/WICED/security/BESL/wolfssl_lib. + 3. Drop in the wolfssl_lib directory you just created. 4. The user_settings.h file in the IDE/WICED-STUDIO/ directory should be place at . This file provides the configure options for compiling - wolfSSL with your project. The default values will give you a starting point + wolfSSL with your project. The default values will give you a starting point and you may further configure the library. - 5. The wolfssl_lib.mk should be placed at the same level as the wolfSSL - library within wolfssl_lib. The directory structure should be - WICED/security/BESL/wolfssl_lib/ and - WICED/security/BESL/wolfssl_lib/wolfssl_lib.mk. - 6. Apply the patches: git apply --ignore-space-change - --ignore-whitespace mychanges.patch - + 5. Apply the patch: + git apply --ignore-space-change --ignore-whitespace mychanges.patch + You can now build and use the wolfSSL and wolfCrypt snips within the WICED SDK. Cypress includes great documentation and getting started videos to learn how to build and run the snips. -wolfSSL provides a wolfCrypt test application, a TLS client and server application, +wolfSSL provides a wolfCrypt test application, a TLS client and server application, and an HTTPS client application. Future development and additions will be made. +Support for TLS 1.3 is available in the provided snippet and is the most current +TLS version. + Further instructions and documentation can be found on the wolfSSL website at www.wolfssl.com or visit us on our forums at www.wolfssl.com/forums/. - + diff --git a/IDE/WICED-STUDIO/wolfssl_lib.mk b/IDE/WICED-STUDIO/wolfssl_lib.mk deleted file mode 100644 index 37985926f..000000000 --- a/IDE/WICED-STUDIO/wolfssl_lib.mk +++ /dev/null @@ -1,75 +0,0 @@ - # Copyright (C) 2006-2017 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 - - - -NAME := wolfSSL - -$(NAME)_SOURCES += wolfssl/src/internal.c \ - wolfssl/src/keys.c \ - wolfssl/src/ssl.c \ - wolfssl/src/tls.c \ - wolfssl/src/wolfio.c \ - wolfssl/wolfcrypt/src/aes.c \ - wolfssl/wolfcrypt/src/asn.c \ - wolfssl/wolfcrypt/src/chacha.c \ - wolfssl/wolfcrypt/src/chacha20_poly1305.c \ - wolfssl/wolfcrypt/src/coding.c \ - wolfssl/wolfcrypt/src/cpuid.c \ - wolfssl/wolfcrypt/src/cmac.c \ - wolfssl/wolfcrypt/src/des3.c \ - wolfssl/wolfcrypt/src/dh.c \ - wolfssl/wolfcrypt/src/ecc.c \ - wolfssl/wolfcrypt/src/error.c \ - wolfssl/wolfcrypt/src/hash.c \ - wolfssl/wolfcrypt/src/hmac.c \ - wolfssl/wolfcrypt/src/logging.c \ - wolfssl/wolfcrypt/src/md4.c \ - wolfssl/wolfcrypt/src/md5.c \ - wolfssl/wolfcrypt/src/memory.c \ - wolfssl/wolfcrypt/src/poly1305.c \ - wolfssl/wolfcrypt/src/random.c \ - wolfssl/wolfcrypt/src/rsa.c \ - wolfssl/wolfcrypt/src/sha.c \ - wolfssl/wolfcrypt/src/sha256.c \ - wolfssl/wolfcrypt/src/sha3.c \ - wolfssl/wolfcrypt/src/sha512.c \ - wolfssl/wolfcrypt/src/signature.c \ - wolfssl/wolfcrypt/src/tfm.c \ - wolfssl/wolfcrypt/src/wc_encrypt.c \ - wolfssl/wolfcrypt/src/wc_port.c \ - wolfssl/wolfcrypt/src/wolfmath.c \ - wolfssl/wolfcrypt/test/test.c \ - wolfssl/wolfcrypt/src/ripemd.c \ - wolfssl/wolfcrypt/src/dsa.c \ - wolfssl/wolfcrypt/src/arc4.c \ - wolfssl/wolfcrypt/src/rabbit.c \ - wolfssl/wolfcrypt/src/curve25519.c \ - wolfssl/wolfcrypt/src/ed25519.c \ - wolfssl/wolfcrypt/benchmark/benchmark.c \ - wolfssl/src/tls13.c - -GLOBAL_INCLUDES += wolfssl \ - user_settings_folder \ - - -GLOBAL_DEFINES += WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME=$(shell $(PERL) -e "print time()") \ - WOLFSSL_USER_SETTINGS - - -GLOBAL_CFLAGS += -g1 diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 7a0d84e8a..aae18c794 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -172,10 +172,9 @@ /* Uncomment next line if building for using XILINX */ /* #define WOLFSSL_XILINX */ -/* Uncomment the next three lines when using WICED Studio. */ - /* #ifndef WOLFSSL_WICED - #define WOLFSSL_WICED - #endif */ +/* Uncomment next line if building for WICED Studio. */ +/* #define WOLFSSL_WICED */ + /* Uncomment next line if building for Nucleus 1.2 */ /* #define WOLFSSL_NUCLEUS_1_2 */ From 1f7f424075d14d8a001e16e486695c48c8e8841d Mon Sep 17 00:00:00 2001 From: jrblixt Date: Wed, 27 Feb 2019 17:12:36 -0700 Subject: [PATCH 4/4] Code review updates.. --- IDE/WICED-STUDIO/README | 43 +++++++++++++++++++------------- IDE/WICED-STUDIO/user_settings.h | 2 +- wolfcrypt/src/random.c | 9 +++++-- wolfssl/wolfcrypt/settings.h | 2 +- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/IDE/WICED-STUDIO/README b/IDE/WICED-STUDIO/README index 35c2f5d77..00545d8ce 100644 --- a/IDE/WICED-STUDIO/README +++ b/IDE/WICED-STUDIO/README @@ -1,15 +1,18 @@ The wolfSSL examples in the WICED SDK require a server or client application. wolfSSL -provides an easy solution in the /examples/ directory. Run the autogen -script and configure the library with necessary functionality, see ./configure -h for a -list of configure options. Finally, run make and make check to ensure the +provides an easy solution in the /examples/ directory. The wolfSSL +code repository is located on GitHub at https://github.com/wolfSSL/wolfssl. +You can download or clone the repository. Run the autogen script and configure +the library with necessary functionality, see ./configure -h +for a list of configure options. Finally, run make and make check to ensure the build was successfull. You can install wolfSSL on your system with make -install if you wish. See www.wolfssl.com/docs/ for more information. +install if you wish. See www.wolfssl.com/docs/wolfssl-manual/ch2/, 'Building +Wolfssl' for more information. Run ./examples/server/server -h for a list of server options or ./examples/client/client -h for client options. If you would like to test the server or client, you may run them on localhost. Instructions on -running the client or server can be found in the snip code examles. The snips are -meant to be a starting off point for your applications. +running the client or server can be found in the snip code examples in the +WICED SDK. The snips are meant to be a starting off point for your applications. Download and install WICED Studio from the Cypress website. @@ -19,25 +22,31 @@ configuration file. Please see www.wolfssl.com/docs/ for detailed instructions o how to use the configure options. Once you have installed the WICED software: - 1. Create a directory called 'wolfssl_lib.' The path should be: + 1. Create a directory called 'wolfssl_lib' in the BESL directory of WICED + SDK. The path to the new directory should be: 43xxx_Wi-Fi/WICED/security/BESL/wolfssl_lib. - 3. Drop in the wolfssl_lib directory you just created. - 4. The user_settings.h file in the IDE/WICED-STUDIO/ directory should be place - at . This file provides the configure options for compiling - wolfSSL with your project. The default values will give you a starting point - and you may further configure the library. - 5. Apply the patch: - git apply --ignore-space-change --ignore-whitespace mychanges.patch + 2. Drag and drop the wolfssl library directory into the wolfssl_lib folder + you just created. The root wolfSSL directory was created when you either + downloaded or cloned the wolfSSL repository from github. + 3. The user_settings.h file in the IDE/WICED-STUDIO/ directory should be + placed at added to the WICED project in step #2.. This + file provides the configure options for compiling wolfSSL with your project. + The default values will give you a starting point and you may further + configure the library to meet your needs. + 4. Apply the patch to your WICED IDE project's 43xxx_Wi-Fi/ directory. + a. Open a terminal and cd into the project 43xxx_Wi-Fi/ directory.: + b. git apply --ignore-space-change --ignore-whitespace mychanges.patch You can now build and use the wolfSSL and wolfCrypt snips within the WICED SDK. Cypress includes great documentation and getting started videos to learn how to -build and run the snips. +build and run the snips in the Cypress Community section of their website, +https://community.cypress.com/welcome/.. wolfSSL provides a wolfCrypt test application, a TLS client and server application, and an HTTPS client application. Future development and additions will be made. -Support for TLS 1.3 is available in the provided snippet and is the most current -TLS version. +Support for TLS 1.3 is available in the provided snippets and it is the most current +TLS version available. Further instructions and documentation can be found on the wolfSSL website at www.wolfssl.com or visit us on our forums at www.wolfssl.com/forums/. diff --git a/IDE/WICED-STUDIO/user_settings.h b/IDE/WICED-STUDIO/user_settings.h index d7b08e932..b548a55ac 100644 --- a/IDE/WICED-STUDIO/user_settings.h +++ b/IDE/WICED-STUDIO/user_settings.h @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -/* Custom wolfSSL user settings for GCC ARM */ +/* Custom wolfSSL user settings for Cypress WICED Studio. */ #ifndef WOLFSSL_USER_SETTINGS_H #define WOLFSSL_USER_SETTINGS_H diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index a99b76326..7690506e7 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -2052,14 +2052,19 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) #elif defined(WOLFSSL_WICED) int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) { + int ret; (void)os; + if (output == NULL || UINT16_MAX < sz) { return BUFFER_E; } - wiced_crypto_get_random((void*) output, sz); + if ((ret = wiced_crypto_get_random((void*) output, sz) ) + != WICED_SUCCESS) { + return ret; + } - return 0; + return ret; } #elif defined(IDIRECT_DEV_RANDOM) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index aae18c794..f501a4008 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -172,7 +172,7 @@ /* Uncomment next line if building for using XILINX */ /* #define WOLFSSL_XILINX */ -/* Uncomment next line if building for WICED Studio. */ +/* Uncomment next line if building for WICED Studio. */ /* #define WOLFSSL_WICED */ /* Uncomment next line if building for Nucleus 1.2 */