Closed AnthonyDeroche closed 7 years ago
Hi Anthony,
Thanks for your question! I'm currently looking into your case and will get back to as soon as I have an update.
Hi Anthony,
I have created a pull request here that addresses some of your concerns: https://github.com/wolfSSL/wolfssl/pull/551
Implement GenerateSeed in random.c (line 1652) (I basically uncommented the commented function)
This is necessary as we do not provide a source of entropy with our libraries. We use /dev/urandom when available and many embedded systems have their own hardware entropy source which can be setup and accessed through the GenerateSeed API.
I did not find it necessary to define NO_INLINE when building for Intel® Galileo board (the only platform we currently have ported to in ARDUINO)
By defining INTEL_GALILEO there is no need to remove references to XTIME/GMTIME, I've added this to the README and a commented define under WOLFSSL_ARDUINO in wolfssl/wolfcrypt/settings.h to make this more intuitive.
I updated the /bin/sh script as you mentioned.
Let us know if there is anything further.
Kind Regards, Kaleb
Thanks for your fast reply.
I will try it out as soon as possible. I will keep you posted.
Regards, Anthony
Hi Anthony,
Just checking in on this issue. Were Kaleb's comments above helpful?
Thanks, Chris
I didn't try again to compile the library in my environment. I will keep you posted as soon as I work again in this project.
Thanks, Anthony
Hi Anthony,
Did you ever get a chance to get back to this? Should we close this issue?
Regards,
Kaleb
I had a follow-up on this issue, although maybe I should open another issue for it:
I am building for a more plain Arduino platform, not a Yun or Galileo or any of the linux-backed platforms, just a simple microcontroller embedded context where a WifiClient that conforms to the expected interface is provided (ESP8266 derivative).
When building, I get the errors:
/var/folders/dy/nsmz0p8s06b0z0_rrfvqtqz40000gn/T/arduino_build_70070/libraries/wolfssl/asn.c.o: In function `CheckCurve':
/Users/xyz/Documents/Arduino/libraries/wolfssl/asn.c:4036: undefined reference to `__ctype_ptr__'
/var/folders/dy/nsmz0p8s06b0z0_rrfvqtqz40000gn/T/arduino_build_70070/libraries/wolfssl/asn.c.o: In function `ExtractDate':
/Users/xyz/Documents/Arduino/libraries/wolfssl/asn.c:4036: undefined reference to `XTIME'
/Users/xyz/Documents/Arduino/libraries/wolfssl/asn.c:4036: undefined reference to `XGMTIME'
/var/folders/dy/nsmz0p8s06b0z0_rrfvqtqz40000gn/T/arduino_build_70070/libraries/wolfssl/asn.c.o: In function `ValidateDate':
/Users/xyz/Documents/Arduino/libraries/wolfssl/asn.c:4036: undefined reference to `XTIME'
/Users/xyz/Documents/Arduino/libraries/wolfssl/asn.c:4036: undefined reference to `XGMTIME'
collect2: error: ld returned 1 exit status
When I try to define even a placeholder function like below in the .ino file to get the link error to resolve (not expecting it to work properly), the problem remains.
extern time_t XTIME(time_t * timer){
time_t temp;
return temp;
}
Am I overlooking something for the correct procedure for how to provide XTIME and XGMTIME to the settings and configuration?
tagging the pros so they'll see by above comment, before I open a separate issue, @kaleb-himes @cconlon
Hi,
I know this is closed, but I'm having similar problems as @AnthonyDeroche
After doing what he posted, I'm having these compilation problems:
arduino-1.8.5\libraries\wolfssl/wolfssl/wolfcrypt/wc_port.h:469:31: error: expected unqualified-id before 'const'
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
^
E:\arduino-1.8.5\libraries\wolfssl/wolfssl/wolfcrypt/wc_port.h:469:31: error: expected ')' before 'const'
E:\arduino-1.8.5\libraries\wolfssl/wolfssl/wolfcrypt/wc_port.h:469:31: error: expected initializer before 'const'
exit status 1 Error compilando para la tarjeta Arduino Leonardo.
Files I think are involved are pasted below.
My file settings.h ` / settings.h
/ Place OS specific preprocessor flags, defines, includes here, will be included into every file because types.h includes it /
extern "C" {
/ Uncomment next line if using IPHONE / / #define IPHONE /
/ Uncomment next line if using ThreadX / / #define THREADX /
/ Uncomment next line if using Micrium uC/OS-III / / #define MICRIUM /
/ Uncomment next line if using Mbed / / #define MBED /
/ Uncomment next line if using Microchip PIC32 ethernet starter kit / / #define MICROCHIP_PIC32 /
/ Uncomment next line if using Microchip TCP/IP stack, version 5 / / #define MICROCHIP_TCPIP_V5 /
/ Uncomment next line if using Microchip TCP/IP stack, version 6 or later / / #define MICROCHIP_TCPIP /
/ Uncomment next line if using PIC32MZ Crypto Engine / / #define WOLFSSL_MICROCHIP_PIC32MZ /
/ Uncomment next line if using FreeRTOS / / #define FREERTOS /
/ Uncomment next line if using FreeRTOS+ TCP / / #define FREERTOS_TCP /
/ Uncomment next line if using FreeRTOS Windows Simulator / / #define FREERTOS_WINSIM /
/ Uncomment next line if using RTIP / / #define EBSNET /
/ Uncomment next line if using lwip / / #define WOLFSSL_LWIP /
/ Uncomment next line if building wolfSSL for a game console / / #define WOLFSSL_GAME_BUILD /
/ Uncomment next line if building wolfSSL for LSR / / #define WOLFSSL_LSR /
/ Uncomment next line if building for Freescale Classic MQX/RTCS/MFS / / #define FREESCALE_MQX /
/ Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS / / #define FREESCALE_KSDK_MQX /
/ Uncomment next line if building for Freescale KSDK Bare Metal / / #define FREESCALE_KSDK_BM /
/ Uncomment next line if building for Freescale KSDK FreeRTOS (old name FREESCALE_FREE_RTOS) / / #define FREESCALE_KSDK_FREERTOS /
/ Uncomment next line if using STM32F2 / / #define WOLFSSL_STM32F2 /
/ Uncomment next line if using STM32F4 / / #define WOLFSSL_STM32F4 /
/ Uncomment next line if using STM32F7 / / #define WOLFSSL_STM32F7 /
/ Uncomment next line if using QL SEP settings / / #define WOLFSSL_QL /
/ Uncomment next line if building for EROAD / / #define WOLFSSL_EROAD /
/ Uncomment next line if building for IAR EWARM / / #define WOLFSSL_IAR_ARM /
/ Uncomment next line if building for Rowley CrossWorks ARM / / #define WOLFSSL_ROWLEY_ARM /
/ Uncomment next line if using TI-RTOS settings / / #define WOLFSSL_TIRTOS /
/ Uncomment next line if building with PicoTCP / / #define WOLFSSL_PICOTCP /
/ Uncomment next line if building for PicoTCP demo bundle / / #define WOLFSSL_PICOTCP_DEMO /
/ Uncomment next line if building for uITRON4 / / #define WOLFSSL_uITRON4 /
/ Uncomment next line if building for uT-Kernel / / #define WOLFSSL_uTKERNEL2 /
/ Uncomment next line if using Max Strength build / / #define WOLFSSL_MAX_STRENGTH /
/ Uncomment next line if building for VxWorks / / #define WOLFSSL_VXWORKS /
/ Uncomment next line if building for Nordic nRF5x platofrm / / #define WOLFSSL_NRF5x /
/ Uncomment next line to enable deprecated less secure static DH suites / / #define WOLFSSL_STATIC_DH /
/ Uncomment next line to enable deprecated less secure static RSA suites / / #define WOLFSSL_STATIC_RSA /
/ Uncomment next line if building for ARDUINO / / Uncomment both lines if building for ARDUINO on INTEL_GALILEO /
//#define NO_INLINE // Don't know if this is mandatory for Leonardo / #define INTEL_GALILEO /
/ Uncomment next line to enable asynchronous crypto WC_PENDING_E / / #define WOLFSSL_ASYNC_CRYPT /
/ Uncomment next line if building for uTasker / / #define WOLFSSL_UTASKER /
/ Uncomment next line if building for embOS / / #define WOLFSSL_EMBOS /
/ Uncomment next line if building for RIOT-OS / / #define WOLFSSL_RIOT_OS /
/ Uncomment next line if building for using XILINX hardened crypto / / #define WOLFSSL_XILINX_CRYPT /
/ Uncomment next line if building for using XILINX / / #define WOLFSSL_XILINX /
#include "user_settings.h"
/ make sure old RNG name is used with CTaoCrypt FIPS /
#define WC_RNG RNG
/* blinding adds API not available yet in FIPS mode */
#undef WC_RSA_BLINDING
defined(HAVE_AESGCM) && defined(WOLFSSL_AESNI)
/* The _M_X64 macro is what's used in the headers for MSC to tell if it
unrolling. */
#define SIZEOF_LONG_LONG 8
#define SIZEOF_LONG_LONG 8
#ifdef NEED_THREADX_TYPES
#include <types.h>
#endif
#include <nx_api.h>
#define WOLFSSL_LWIP
#define NO_WRITEV
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#define NO_MAIN_DRIVER
#define SINGLE_THREADED
#if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
#define USE_CERT_BUFFERS_1024
#endif
#define BENCH_EMBEDDED
#define NO_FILESYSTEM
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define BENCH_EMBEDDED
/* #define WOLFSSL_MICROCHIP_PIC32MZ */
#define SIZEOF_LONG_LONG 8
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MAX
#define NO_BIG_INT
#define WOLFSSL_PIC32MZ_CRYPT
#define WOLFSSL_PIC32MZ_RNG
#define WOLFSSL_PIC32MZ_HASH
/* include timer functions */
#include "TCPIP Stack/TCPIP.h"
/* include timer, NTP functions */
#ifdef MICROCHIP_MPLAB_HARMONY
#include "tcpip/tcpip.h"
#else
#include "system/system_services.h"
#include "tcpip/sntp.h"
#endif
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#define NO_CERT
#if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
#define USE_CERT_BUFFERS_1024
#endif
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_SHA512
#define NO_DH
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_DSA
#define NO_HC128
#define HAVE_ECC
#define NO_SESSION_CACHE
#define WOLFSSL_CMSIS_RTOS
#define FREESCALE_MQX
#define FREESCALE_MMCAU
#define SINGLE_THREADED
#define NO_STDIO_FILESYSTEM
#define WOLFSSL_LEANPSK
#define HAVE_NULL_CIPHER
#define NO_OLD_TLS
#define NO_ASN
#define NO_BIG_INT
#define NO_RSA
#define NO_DSA
#define NO_DH
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_CERTS
#define NO_PWDBASED
#define NO_DES3
#define NO_MD4
#define NO_RC4
#define NO_MD5
#define NO_SESSION_CACHE
#define NO_MAIN_DRIVER
#ifndef errno
#define errno pico_err
#endif
#include "pico_defines.h"
#include "pico_stack.h"
#include "pico_constants.h"
#include "pico_protocol.h"
#define CUSTOM_RAND_GENERATE pico_rand
#define WOLFSSL_STM32
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define XMALLOC(s, h, type) PICO_ZALLOC((s))
#define XFREE(p, h, type) PICO_FREE((p))
#define SINGLE_THREADED
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define FREERTOS
#define USE_WINDOWS_API
/* VxWorks simulator incorrectly detects building for i386 */
#ifdef VXWORKS_SIM
#define TFM_NO_ASM
#endif
#define WOLFSSL_PTHREADS
#define WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MAX
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_MAIN_DRIVER
#define NO_DEV_RANDOM
#define NO_WRITEV
#define NO_WRITEV
#define NO_WOLFSSL_DIR
#define SINGLE_THREADED
#define NO_DEV_RANDOM
#ifndef INTEL_GALILEO /* Galileo has time.h compatibility */
#define TIME_OVERRIDES /* must define XTIME and XGMTIME externally */
#endif
#define WOLFSSL_USER_IO
#define HAVE_ECC
#define NO_DH
#define NO_SESSION_CACHE
#define USE_SLOW_SHA
#define NO_WOLFSSL_SERVER
#define NO_ERROR_STRINGS
/* uTasker configuration - used for fnRandom() */
#include "config.h"
#define SINGLE_THREADED
#define NO_WOLFSSL_DIR
#define WOLFSSL_HAVE_MIN
#define NO_WRITEV
#define HAVE_ECC
#define ALT_ECC_SIZE
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
/* used in wolfCrypt test */
#define NO_MAIN_DRIVER
#define USE_CERT_BUFFERS_2048
/* uTasker port uses RAW sockets, use I/O callbacks
* See wolfSSL uTasker example for sample callbacks */
#define WOLFSSL_USER_IO
/* uTasker filesystem not ported */
#define NO_FILESYSTEM
/* uTasker RNG is abstracted, calls HW RNG when available */
#define CUSTOM_RAND_GENERATE fnRandom
#define CUSTOM_RAND_TYPE unsigned short
/* user needs to define XTIME to function that provides
* seconds since Unix epoch */
#ifndef XTIME
//#error XTIME must be defined in wolfSSL settings.h
//#define XTIME fnSecondsSinceEpoch
#endif
/* use uTasker std library replacements where available */
#define STRING_USER
#define XMEMCPY(d,s,l) uMemcpy((d),(s),(l))
#define XMEMSET(b,c,l) uMemset((b),(c),(l))
#define XMEMCMP(s1,s2,n) uMemcmp((s1),(s2),(n))
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
#define XSTRLEN(s1) uStrlen((s1))
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
#define XSTRSTR(s1,s2) strstr((s1),(s2))
#define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
#define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
#if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
#define XSTRTOK strtok_r
#endif
#define NO_FILESYSTEM /* Not ported at this time */
#define USE_CERT_BUFFERS_2048 /* use when NO_FILESYSTEM */
#define NO_MAIN_DRIVER
#define NO_RC4
#define SINGLE_THREADED /* Not ported at this time */
#define NO_WRITEV
#define TFM_NO_ASM
#define USE_FAST_MATH
#define NO_FILESYSTEM
#define USE_CERT_BUFFERS_2048
/* ChibiOS definitions. This file is distributed with chibiOS. */
#include "wolfssl_chibios.h"
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define NO_ASN_TIME
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define NO_MAIN_DRIVER
#define NO_WRITEV
#define SINGLE_THREADED
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define USE_WOLFSSL_MEMORY
#define WOLFSSL_NRF51
#define WOLFSSL_USER_IO
#define NO_SESSION_CACHE
/ Micrium will use Visual Studio for compilation but not the Win32 API /
!defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_EROAD) && \
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
#define USE_WINDOWS_API
extern int uITRON4_minit(size_t poolsz) ; extern void uITRON4_malloc(size_t sz) ; extern void uITRON4_realloc(void p, size_t sz) ; extern void uITRON4_free(void p) ;
#define XMALLOC_OVERRIDE
int uTKernel_init_mpool(unsigned int sz); /* initializing malloc pool */
void* uTKernel_malloc(unsigned int sz);
void* uTKernel_realloc(void *p, unsigned int sz);
void uTKernel_free(void *p);
#define XMALLOC(s, h, type) uTKernel_malloc((s))
#define XREALLOC(p, n, h, t) uTKernel_realloc((p), (n))
#define XFREE(p, h, type) uTKernel_free((p))
#include <stdio.h>
#include "tm/tmonitor.h"
/* static char* gets(char *buff); */
static char* fgets(char *buff, int sz, FILE *fp) {
char * p = buff;
*p = '\0';
while (1) {
*p = tm_getchar(-1);
tm_putchar(*p);
if (*p == '\r') {
tm_putchar('\n');
*p = '\0';
break;
}
p++;
}
return buff;
}
#include <stdlib.h>
#define XMALLOC(s, h, type) malloc((s))
#define XFREE(p, h, type) free((p))
#define XREALLOC(p, n, h, t) realloc((p), (n))
#undef XMALLOC
#define XMALLOC yaXMALLOC
#undef XFREE
#define XFREE yaXFREE
#undef XREALLOC
#define XREALLOC yaXREALLOC
#include "FreeRTOS.h"
/* FreeRTOS pvPortRealloc() only in AVR32_UC3 port */
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#endif
#ifndef NO_WRITEV
#define NO_WRITEV
#endif
#ifndef HAVE_SHA512
#ifndef NO_SHA512
#define NO_SHA512
#endif
#endif
#ifndef HAVE_DH
#ifndef NO_DH
#define NO_DH
#endif
#endif
#ifndef NO_DSA
#define NO_DSA
#endif
#ifndef NO_HC128
#define NO_HC128
#endif
#ifndef SINGLE_THREADED
#include "semphr.h"
#endif
#if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#endif
#define WOLFSSL_GENSEED_FORTEST
#define NO_WOLFSSL_DIR
#define NO_WRITEV
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_MAIN_DRIVER
#define SIZEOF_LONG_LONG 8
#define NO_WRITEV
#define NO_WOLFSSL_DIR
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define WC_RSA_BLINDING
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_CERT_BUFFERS_2048
#define NO_ERROR_STRINGS
#define USER_TIME
#define HAVE_ECC
#define HAVE_ALPN
#define USE_WOLF_STRTOK /* use with HAVE_ALPN */
#define HAVE_TLS_EXTENSIONS
#define HAVE_AESGCM
#define HAVE_SUPPORTED_CURVES
#define ALT_ECC_SIZE
#ifdef __IAR_SYSTEMS_ICC__
#pragma diag_suppress=Pa089
#elif !defined(__GNUC__)
/* Suppress the sslpro warning */
#pragma diag_suppress=11
#endif
#include <ti/sysbios/hal/Seconds.h>
#include "rtip.h"
/* #define DEBUG_WOLFSSL */
#define NO_WOLFSSL_DIR /* tbd */
#if (POLLOS)
#define SINGLE_THREADED
#endif
#if (RTPLATFORM)
#if (!RTP_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
#else
#if (!KS_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
#endif
#if (WINMSP3)
#undef SIZEOF_LONG
#define SIZEOF_LONG_LONG 8
#else
#sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
#endif
#define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
#define XFREE(p, h, type) (rtp_free(p))
#define XREALLOC(p, n, h, t) realloc((p), (n))
#define SIZEOF_LONG_LONG 8
#if defined(__PPU) || defined(__XENON)
#define BIG_ENDIAN_ORDER
#endif
#define HAVE_WEBSERVER
#define SIZEOF_LONG_LONG 8
#define WOLFSSL_LOW_MEMORY
#define NO_WRITEV
#define NO_SHA512
#define NO_DH
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_DSA
#define NO_HC128
#define NO_DEV_RANDOM
#define NO_WOLFSSL_DIR
#define NO_RABBIT
#ifndef NO_FILESYSTEM
#define LSR_FS
#include "inc/hw_types.h"
#include "fs.h"
#endif
#define WOLFSSL_LWIP
#include <errno.h> /* for tcp errno */
#define WOLFSSL_SAFERTOS
#if defined(__IAR_SYSTEMS_ICC__)
/* enum uses enum */
#pragma diag_suppress=Pa089
#endif
#ifndef SINGLE_THREADED
#include "SafeRTOS/semphr.h"
#endif
#include "SafeRTOS/heap.h"
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
#undef RSA_LOW_MEM
#define RSA_LOW_MEM
#undef WOLFSSL_SMALL_STACK
#define WOLFSSL_SMALL_STACK
#undef TFM_TIMING_RESISTANT
#define TFM_TIMING_RESISTANT
#define FREESCALE_COMMON
#include "mqx.h"
#ifndef NO_FILESYSTEM
#include "mfs.h"
#if MQX_USE_IO_OLD
#include "fio.h"
#define NO_STDIO_FILESYSTEM
#else
#include "nio.h"
#endif
#endif
#ifndef SINGLE_THREADED
#include "mutex.h"
#endif
#define XMALLOC_OVERRIDE
#define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
#define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
/* Note: MQX has no realloc, using fastmath above */
#define FREESCALE_COMMON
#include <mqx.h>
#ifndef NO_FILESYSTEM
#if MQX_USE_IO_OLD
#include <fio.h>
#else
#include <stdio.h>
#include <nio.h>
#endif
#endif
#ifndef SINGLE_THREADED
#include <mutex.h>
#endif
#define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
#define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
#define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */
#define MQX_FILE_PTR FILE *
#define IO_SEEK_SET SEEK_SET
#define IO_SEEK_END SEEK_END
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_FILESYSTEM
#define WOLFSSL_CRYPT_HW_MUTEX 1
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#endif
//#define USER_TICKS
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define WOLFSSL_LWIP
#define FREERTOS_TCP
#define FREESCALE_FREE_RTOS
#define FREERTOS_SOCKET_ERROR ( -1 )
#define FREERTOS_EWOULDBLOCK ( -2 )
#define FREERTOS_EINVAL ( -4 )
#define FREERTOS_EADDRNOTAVAIL ( -5 )
#define FREERTOS_EADDRINUSE ( -6 )
#define FREERTOS_ENOBUFS ( -7 )
#define FREERTOS_ENOPROTOOPT ( -8 )
#define FREESCALE_COMMON
#define WOLFSSL_USER_IO
#define SINGLE_THREADED
#define NO_FILESYSTEM
#ifndef TIME_OVERRIDES
#define USER_TICKS
#endif
#define SIZEOF_LONG_LONG 8
/* disable features */
#undef NO_WRITEV
#define NO_WRITEV
#undef NO_DEV_RANDOM
#define NO_DEV_RANDOM
#undef NO_RABBIT
#define NO_RABBIT
#undef NO_WOLFSSL_DIR
#define NO_WOLFSSL_DIR
#undef NO_RC4
#define NO_RC4
/* enable features */
#undef USE_FAST_MATH
#define USE_FAST_MATH
#define USE_CERT_BUFFERS_2048
#define BENCH_EMBEDDED
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#undef HAVE_ECC
#define HAVE_ECC
#ifndef NO_AES
#undef HAVE_AESCCM
#define HAVE_AESCCM
#undef HAVE_AESGCM
#define HAVE_AESGCM
#undef WOLFSSL_AES_COUNTER
#define WOLFSSL_AES_COUNTER
#undef WOLFSSL_AES_DIRECT
#define WOLFSSL_AES_DIRECT
#endif
#ifdef FREESCALE_KSDK_1_3
#include "fsl_device_registers.h"
#elif !defined(FREESCALE_MQX)
/* Classic MQX does not have fsl_common.h */
#include "fsl_common.h"
#endif
/* random seed */
#define NO_OLD_RNGNAME
#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0)
#define FREESCALE_KSDK_2_0_TRNG
#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0)
#ifdef FREESCALE_KSDK_1_3
#include "fsl_rnga_driver.h"
#define FREESCALE_RNGA
#define RNGA_INSTANCE (0)
#else
#define FREESCALE_KSDK_2_0_RNGA
#endif
#elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) && !defined(FREESCALE_KSDK_FREERTOS)
#define FREESCALE_RNGA
#define RNGA_INSTANCE (0)
/* defaulting to K70 RNGA, user should change if different */
/* #define FREESCALE_K53_RNGB */
#define FREESCALE_K70_RNGA
#endif
/* HW crypto */
/* automatic enable based on Kinetis feature */
/* if case manual selection is required, for example for benchmarking purposes,
* just define FREESCALE_USE_MMCAU or FREESCALE_USE_LTC or none of these two macros (for software only)
* both can be enabled simultaneously as LTC has priority over MMCAU in source code.
*/
/* #define FSL_HW_CRYPTO_MANUAL_SELECTION */
#ifndef FSL_HW_CRYPTO_MANUAL_SELECTION
#if defined(FSL_FEATURE_SOC_MMCAU_COUNT) && FSL_FEATURE_SOC_MMCAU_COUNT
#define FREESCALE_USE_MMCAU
#endif
#if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
#define FREESCALE_USE_LTC
#endif
#else
/* #define FREESCALE_USE_MMCAU */
/* #define FREESCALE_USE_LTC */
#endif
/ Classic pre-KSDK mmCAU library /
#define FREESCALE_USE_MMCAU
#define FREESCALE_MMCAU_CLASSIC
#define FREESCALE_MMCAU_CLASSIC_SHA
/ KSDK mmCAU library /
/* AES and DES */
#define FREESCALE_MMCAU
/* MD5, SHA-1 and SHA-256 */
#define FREESCALE_MMCAU_SHA
#if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
#define FREESCALE_LTC
#define LTC_BASE LTC0
#if defined(FSL_FEATURE_LTC_HAS_DES) && FSL_FEATURE_LTC_HAS_DES
#define FREESCALE_LTC_DES
#endif
#if defined(FSL_FEATURE_LTC_HAS_GCM) && FSL_FEATURE_LTC_HAS_GCM
#define FREESCALE_LTC_AES_GCM
#endif
#if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA
#define FREESCALE_LTC_SHA
#endif
#if defined(FSL_FEATURE_LTC_HAS_PKHA) && FSL_FEATURE_LTC_HAS_PKHA
#define FREESCALE_LTC_ECC
#define FREESCALE_LTC_TFM
/* the LTC PKHA hardware limit is 2048 bits (256 bytes) for integer arithmetic.
the LTC_MAX_INT_BYTES defines the size of local variables that hold big integers. */
#ifndef LTC_MAX_INT_BYTES
#define LTC_MAX_INT_BYTES (256)
#endif
/* This FREESCALE_LTC_TFM_RSA_4096_ENABLE macro can be defined.
* In such a case both software and hardware algorithm
* for TFM is linked in. The decision for which algorithm is used is determined at runtime
* from size of inputs. If inputs and result can fit into LTC (see LTC_MAX_INT_BYTES)
* then we call hardware algorithm, otherwise we call software algorithm.
*
* Chinese reminder theorem is used to break RSA 4096 exponentiations (both public and private key)
* into several computations with 2048-bit modulus and exponents.
*/
/* #define FREESCALE_LTC_TFM_RSA_4096_ENABLE */
/* ECC-384, ECC-256, ECC-224 and ECC-192 have been enabled with LTC PKHA acceleration */
#ifdef HAVE_ECC
#undef ECC_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
/* the LTC PKHA hardware limit is 512 bits (64 bytes) for ECC.
the LTC_MAX_ECC_BITS defines the size of local variables that hold ECC parameters
and point coordinates */
#ifndef LTC_MAX_ECC_BITS
#define LTC_MAX_ECC_BITS (384)
#endif
/* Enable curves up to 384 bits */
#if !defined(ECC_USER_CURVES) && !defined(HAVE_ALL_CURVES)
#define ECC_USER_CURVES
#define HAVE_ECC192
#define HAVE_ECC224
#undef NO_ECC256
#define HAVE_ECC384
#endif
/* enable features */
#undef HAVE_CURVE25519
#define HAVE_CURVE25519
#undef HAVE_ED25519
#define HAVE_ED25519
#undef WOLFSSL_SHA512
#define WOLFSSL_SHA512
#endif
#endif
#endif
#undef USE_CERT_BUFFERS_4096
#define USE_CERT_BUFFERS_4096
#undef FP_MAX_BITS
#define FP_MAX_BITS (8192)
#undef NO_DH
#define NO_DH
#undef NO_DSA
#define NO_DSA
/ if LTC has AES engine but doesn't have GCM, use software with LTC AES ECB mode /
#define GCM_TABLE
defined(WOLFSSL_STM32F7) || defined(WOLFSSL_STM32F1)
#define SIZEOF_LONG_LONG 8
#define NO_DEV_RANDOM
#define NO_WOLFSSL_DIR
#undef NO_RABBIT
#define NO_RABBIT
#ifndef NO_STM32_RNG
#undef STM32_RNG
#define STM32_RNG
#endif
#ifndef NO_STM32_CRYPTO
#undef STM32_CRYPTO
#define STM32_CRYPTO
#endif
#ifndef NO_STM32_HASH
#undef STM32_HASH
#define STM32_HASH
#endif
#if !defined(__GNUC__) && !defined(__ICCARM__)
#define KEIL_INTRINSICS
#endif
#define NO_OLD_RNGNAME
#ifdef WOLFSSL_STM32_CUBEMX
#if defined(WOLFSSL_STM32F2)
#include "stm32f2xx_hal.h"
#elif defined(WOLFSSL_STM32F4)
#include "stm32f4xx_hal.h"
#elif defined(WOLFSSL_STM32F7)
#include "stm32f7xx_hal.h"
#elif defined(WOLFSSL_STM32F1)
#include "stm32f1xx_hal.h"
#endif
#ifndef STM32_HAL_TIMEOUT
#define STM32_HAL_TIMEOUT 0xFF
#endif
#else
#if defined(WOLFSSL_STM32F2)
#include "stm32f2xx.h"
#ifdef STM32_CRYPTO
#include "stm32f2xx_cryp.h"
#endif
#ifdef STM32_HASH
#include "stm32f2xx_hash.h"
#endif
#elif defined(WOLFSSL_STM32F4)
#include "stm32f4xx.h"
#ifdef STM32_CRYPTO
#include "stm32f4xx_cryp.h"
#endif
#ifdef STM32_HASH
#include "stm32f4xx_hash.h"
#endif
#elif defined(WOLFSSL_STM32F7)
#include "stm32f7xx.h"
#elif defined(WOLFSSL_STM32F1)
#include "stm32f1xx.h"
#endif
#endif /* WOLFSSL_STM32_CUBEMX */
#include <stdlib.h>
#include <os.h>
#include <net_cfg.h>
#include <net_sock.h>
#include <net_err.h>
#include <lib_mem.h>
#include <lib_math.h>
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define WC_RSA_BLINDING
#define HAVE_HASHDRBG
#define HAVE_ECC
#define ALT_ECC_SIZE
#define TFM_ECC192
#define TFM_ECC224
#define TFM_ECC256
#define TFM_ECC384
#define TFM_ECC521
#define NO_RC4
#define HAVE_TLS_EXTENSIONS
#define HAVE_SUPPORTED_CURVES
#define HAVE_EXTENDED_MASTER
#define NO_WOLFSSL_DIR
#define NO_WRITEV
#ifndef CUSTOM_RAND_GENERATE
#define CUSTOM_RAND_TYPE RAND_NBR
#define CUSTOM_RAND_GENERATE Math_Rand
#endif
#define WOLFSSL_TYPES
typedef CPU_INT08U byte;
typedef CPU_INT16U word16;
typedef CPU_INT32U word32;
#define STRING_USER
#define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
#define XSTRNCPY(pstr_dest, pstr_src, len_max) \
((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
(CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
#define XSTRNCMP(pstr_1, pstr_2, len_max) \
((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
(CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
#define XSTRNCASECMP(pstr_1, pstr_2, len_max) \
((CPU_INT16S)Str_CmpIgnoreCase_N((CPU_CHAR *)(pstr_1), \
(CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
#define XSTRSTR(pstr, pstr_srch) \
((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
(CPU_CHAR *)(pstr_srch)))
#define XSTRNSTR(pstr, pstr_srch, len_max) \
((CPU_CHAR *)Str_Str_N((CPU_CHAR *)(pstr), \
(CPU_CHAR *)(pstr_srch),(CPU_SIZE_T)(len_max)))
#define XSTRNCAT(pstr_dest, pstr_cat, len_max) \
((CPU_CHAR *)Str_Cat_N((CPU_CHAR *)(pstr_dest), \
(const CPU_CHAR *)(pstr_cat),(CPU_SIZE_T)(len_max)))
#define XMEMSET(pmem, data_val, size) \
((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
(CPU_SIZE_T)(size)))
#define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
(void *)(psrc), (CPU_SIZE_T)(size)))
#define XMEMCMP(pmem_1, pmem_2, size) \
(((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
(CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
#define XMEMMOVE XMEMCPY
#if (OS_CFG_MUTEX_EN == DEF_DISABLED)
#define SINGLE_THREADED
#endif
#if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
#define BIG_ENDIAN_ORDER
#else
#undef BIG_ENDIAN_ORDER
#define LITTLE_ENDIAN_ORDER
#endif
#ifndef WOLFSSL_SEP
#define WOLFSSL_SEP
#endif
#ifndef OPENSSL_EXTRA
#define OPENSSL_EXTRA
#endif
#ifndef SESSION_CERTS
#define SESSION_CERTS
#endif
#ifndef HAVE_AESCCM
#define HAVE_AESCCM
#endif
#ifndef ATOMIC_USER
#define ATOMIC_USER
#endif
#ifndef WOLFSSL_DER_LOAD
#define WOLFSSL_DER_LOAD
#endif
#ifndef KEEP_PEER_CERT
#define KEEP_PEER_CERT
#endif
#ifndef HAVE_ECC
#define HAVE_ECC
#endif
#ifndef SESSION_INDEX
#define SESSION_INDEX
#endif
#define USER_TIME /* XTIME in asn.c */
#define NO_WOLFSSL_DIR
#define NO_DEV_RANDOM
#define HAVE_AESGCM
#if defined(WOLFSSL_ARMASM)
#error can not use both ARMv8 instructions and XILINX hardened crypto
#endif
#if defined(WOLFSSL_SHA3)
/* only SHA3-384 is supported */
#undef WOLFSSL_NOSHA3_224
#undef WOLFSSL_NOSHA3_256
#undef WOLFSSL_NOSHA3_512
#define WOLFSSL_NOSHA3_224
#define WOLFSSL_NOSHA3_256
#define WOLFSSL_NOSHA3_512
#endif
#ifndef SIZEOF_LONG_LONG
#define SIZEOF_LONG_LONG 8
#endif
/ if defined turn on all CAAM support /
#undef WOLFSSL_IMX6_CAAM_RNG
#define WOLFSSL_IMX6_CAAM_RNG
#undef WOLFSSL_IMX6_CAAM_BLOB
#define WOLFSSL_IMX6_CAAM_BLOB
/* large performance gain with HAVE_AES_ECB defined */
#undef HAVE_AES_ECB
#define HAVE_AES_ECB
!defined(WOLFSSL_LEANPSK) && !defined(NO_WOLFSSL_MEMORY) && \
!defined(XMALLOC_OVERRIDE)
#define USE_WOLFSSL_MEMORY
#undef KEEP_PEER_CERT
#define KEEP_PEER_CERT
/ stream ciphers except arc4 need 32bit alignment, intel ok without /
#if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
#define NO_XSTREAM_ALIGN
#else
#define XSTREAM_ALIGN
#endif
/* write dup cannot be used with secure renegotiation because write dup
#ifdef _MSC_VER
#define NO_RC4
#ifndef HAVE_FIPS
#define WOLFCRYPT_ONLY
#define NO_DES3
#define NO_SHA
#define NO_MD5
#else
#define TFM_TIMING_RESISTANT
#define NO_WOLFSSL_DIR
#define NO_FILESYSTEM
#define NO_WRITEV
#define NO_MAIN_DRIVER
#define WOLFSSL_LOG_PRINTF
#define WOLFSSL_DH_CONST
#endif
#else
#define HAVE_ECC
#define ECC_TIMING_RESISTANT
#define TFM_TIMING_RESISTANT
#define NO_FILESYSTEM
#define NO_WRITEV
#define NO_MAIN_DRIVER
#define USER_TICKS
#define WOLFSSL_LOG_PRINTF
#define WOLFSSL_DH_CONST
#endif /* _MSC_VER */
#if !defined(HAVE_FIPS) && !defined(NO_RSA)
#define WC_RSA_BLINDING
#endif
#define SINGLE_THREADED
#define NO_ASN_TIME /* can not use headers such as windows.h */
#define HAVE_AESGCM
#define USE_CERT_BUFFERS_2048
#define USE_FAST_MATH
/ FreeScale MMCAU hardware crypto has 4 byte alignment. However, KSDK fsl_mmcau.h gives API with no alignment requirements (4 byte alignment is managed internally by fsl_mmcau.c) /
#ifdef FREESCALE_MMCAU_CLASSIC
#define WOLFSSL_MMCAU_ALIGNMENT 4
#else
#define WOLFSSL_MMCAU_ALIGNMENT 0
#endif
/ if using hardware crypto and have alignment requirements, specify the requirement here. The record header of SSL/TLS will prevent easy alignment. This hint tries to help as much as possible. /
#ifdef WOLFSSL_AESNI
#define WOLFSSL_GENERAL_ALIGNMENT 16
#elif defined(XSTREAM_ALIGN)
#define WOLFSSL_GENERAL_ALIGNMENT 4
#elif defined(FREESCALE_MMCAU) || defined(FREESCALE_MMCAU_CLASSIC)
#define WOLFSSL_GENERAL_ALIGNMENT WOLFSSL_MMCAU_ALIGNMENT
#else
#define WOLFSSL_GENERAL_ALIGNMENT 0
#endif
#if defined(_MSC_VER)
#define XGEN_ALIGN __declspec(align(WOLFSSL_GENERAL_ALIGNMENT))
#elif defined(__GNUC__)
#define XGEN_ALIGN __attribute__((aligned(WOLFSSL_GENERAL_ALIGNMENT)))
#else
#define XGEN_ALIGN
#endif
#define XGEN_ALIGN
/* not widely supported yet */
#undef NO_SKID
#define NO_SKID
#pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
/* user can specify what curves they want with ECC_USER_CURVES otherwise
#define HAVE_ALL_CURVES
/ ECC Configs /
/* By default enable Sign, Verify, DHE, Key Import and Key Export unless explicitly disabled */
#ifndef NO_ECC_SIGN
#undef HAVE_ECC_SIGN
#define HAVE_ECC_SIGN
#endif
#ifndef NO_ECC_VERIFY
#undef HAVE_ECC_VERIFY
#define HAVE_ECC_VERIFY
#endif
#ifndef NO_ECC_CHECK_KEY
#undef HAVE_ECC_CHECK_KEY
#define HAVE_ECC_CHECK_KEY
#endif
#ifndef NO_ECC_DHE
#undef HAVE_ECC_DHE
#define HAVE_ECC_DHE
#endif
#ifndef NO_ECC_KEY_IMPORT
#undef HAVE_ECC_KEY_IMPORT
#define HAVE_ECC_KEY_IMPORT
#endif
#ifndef NO_ECC_KEY_EXPORT
#undef HAVE_ECC_KEY_EXPORT
#define HAVE_ECC_KEY_EXPORT
#endif
/ Curve255519 Configs /
/* By default enable shared secret, key export and import */
#ifndef NO_CURVE25519_SHARED_SECRET
#undef HAVE_CURVE25519_SHARED_SECRET
#define HAVE_CURVE25519_SHARED_SECRET
#endif
#ifndef NO_CURVE25519_KEY_EXPORT
#undef HAVE_CURVE25519_KEY_EXPORT
#define HAVE_CURVE25519_KEY_EXPORT
#endif
#ifndef NO_CURVE25519_KEY_IMPORT
#undef HAVE_CURVE25519_KEY_IMPORT
#define HAVE_CURVE25519_KEY_IMPORT
#endif
/ Ed255519 Configs /
/* By default enable sign, verify, key export and import */
#ifndef NO_ED25519_SIGN
#undef HAVE_ED25519_SIGN
#define HAVE_ED25519_SIGN
#endif
#ifndef NO_ED25519_VERIFY
#undef HAVE_ED25519_VERIFY
#define HAVE_ED25519_VERIFY
#endif
#ifndef NO_ED25519_KEY_EXPORT
#undef HAVE_ED25519_KEY_EXPORT
#define HAVE_ED25519_KEY_EXPORT
#endif
#ifndef NO_ED25519_KEY_IMPORT
#undef HAVE_ED25519_KEY_IMPORT
#define HAVE_ED25519_KEY_IMPORT
#endif
/ AES Config /
/* By default enable all AES key sizes, decryption and CBC */
#ifndef AES_MAX_KEY_SIZE
#undef AES_MAX_KEY_SIZE
#define AES_MAX_KEY_SIZE 256
#endif
#ifndef NO_AES_128
#undef WOLFSSL_AES_128
#define WOLFSSL_AES_128
#endif
#if !defined(NO_AES_192) && AES_MAX_KEY_SIZE >= 192
#undef WOLFSSL_AES_192
#define WOLFSSL_AES_192
#endif
#if !defined(NO_AES_256) && AES_MAX_KEY_SIZE >= 256
#undef WOLFSSL_AES_256
#define WOLFSSL_AES_256
#endif
#if !defined(WOLFSSL_AES_128) && defined(HAVE_ECC_ENCRYPT)
#warning HAVE_ECC_ENCRYPT uses AES 128 bit keys
#endif
#ifndef NO_AES_DECRYPT
#undef HAVE_AES_DECRYPT
#define HAVE_AES_DECRYPT
#endif
#ifndef NO_AES_CBC
#undef HAVE_AES_CBC
#define HAVE_AES_CBC
#else
#ifndef WOLFCRYPT_ONLY
#error "AES CBC is required for TLS and can only be disabled for WOLFCRYPT_ONLY builds"
#endif
#endif
#ifdef WOLFSSL_AES_XTS
/* AES-XTS makes calls to AES direct functions */
#ifndef WOLFSSL_AES_DIRECT
#define WOLFSSL_AES_DIRECT
#endif
#endif
#ifdef WOLFSSL_AES_CFB
/* AES-CFB makes calls to AES direct functions */
#ifndef WOLFSSL_AES_DIRECT
#define WOLFSSL_AES_DIRECT
#endif
#endif
/ if desktop type system and fastmath increase default max bits /
#ifdef USE_FAST_MATH
#ifndef FP_MAX_BITS
#define FP_MAX_BITS 8192
#endif
#endif
/ If using the max strength build, ensure OLD TLS is disabled. /
#undef NO_OLD_TLS
#define NO_OLD_TLS
/ Default AES minimum auth tag sz, allow user to override /
#define WOLFSSL_MIN_AUTH_TAG_SZ 12
/* sniffer requires:
#define WOLFSSL_STATIC_RSA
#define WOLFSSL_SESSION_STATS
#define WOLFSSL_PEAK_SESSIONS
/* Decode Public Key extras on by default, user can turn off with
#define RSA_DECODE_EXTRA
#define ECC_DECODE_EXTRA
/ C Sharp wrapper defines /
#ifndef WOLFSSL_DTLS
#define WOLFSSL_DTLS
#endif
#undef NO_PSK
#undef NO_SHA256
#undef NO_DH
/ Asynchronous Crypto /
/* Make sure wolf events are enabled */
#undef HAVE_WOLF_EVENT
#define HAVE_WOLF_EVENT
#ifdef WOLFSSL_ASYNC_CRYPT_TEST
#define WC_ASYNC_DEV_SIZE 320+24
#else
#define WC_ASYNC_DEV_SIZE 320
#endif
#if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \
!defined(WOLFSSL_ASYNC_CRYPT_TEST)
#error No async hardware defined with WOLFSSL_ASYNC_CRYPT!
#endif
/* Enable ECC_CACHE_CURVE for ASYNC */
#if !defined(ECC_CACHE_CURVE)
#define ECC_CACHE_CURVE
#endif
#define WC_ASYNC_DEV_SIZE 0
/ leantls checks /
#ifndef HAVE_ECC
#error leantls build needs ECC
#endif
/ restriction with static memory /
#if defined(HAVE_IO_POOL) || defined(XMALLOC_USER) || defined(NO_WOLFSSL_MEMORY)
#error static memory cannot be used with HAVE_IO_POOL, XMALLOC_USER or NO_WOLFSSL_MEMORY
#endif
#if !defined(USE_FAST_MATH) && !defined(NO_BIG_INT)
#error static memory requires fast math please define USE_FAST_MATH
#endif
#ifdef WOLFSSL_SMALL_STACK
#error static memory does not support small stack please undefine
#endif
#ifndef WOLFSSL_AES_DIRECT
#error AES key wrap requires AES direct please define WOLFSSL_AES_DIRECT
#endif
#if defined(NO_AES) && defined(NO_DES3)
#error PKCS7 needs either AES or 3DES enabled, please enable one
#endif
#ifndef HAVE_AES_KEYWRAP
#error PKCS7 requires AES key wrap please define HAVE_AES_KEYWRAP
#endif
#if defined(HAVE_ECC) && !defined(HAVE_X963_KDF)
#error PKCS7 requires X963 KDF please define HAVE_X963_KDF
#endif
(defined(NO_SHA) || defined(NO_MD5))
#error old TLS requires MD5 and SHA
/ for backwards compatibility /
#define WOLFSSL_IPV6
/ Place any other flags or defines here /
&& defined(HAVE_GMTIME_R)
#undef HAVE_GMTIME_R /* don't trust macro with windows */
#define SSL_OP_NO_COMPRESSION SSL_OP_NO_COMPRESSION
#define OPENSSL_NO_ENGINE
#define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
#ifndef OPENSSL_EXTRA
#define OPENSSL_EXTRA
#endif
#ifndef HAVE_SESSION_TICKET
#define HAVE_SESSION_TICKET
#endif
#ifndef HAVE_OCSP
#define HAVE_OCSP
#endif
#ifndef KEEP_OUR_CERT
#define KEEP_OUR_CERT
#endif
#ifndef HAVE_SNI
#define HAVE_SNI
#endif
#define SSL_CTRL_SET_TLSEXT_HOSTNAME
/ both CURVE and ED small math should be enabled /
#define CURVE25519_SMALL
#define ED25519_SMALL
#define WOLFSSL_ALERT_COUNT_MAX 5
/ warning for not using harden build options (default with ./configure) /
#if (defined(USE_FAST_MATH) && !defined(TFM_TIMING_RESISTANT)) || \
(defined(HAVE_ECC) && !defined(ECC_TIMING_RESISTANT)) || \
(!defined(NO_RSA) && !defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS))
#ifndef _MSC_VER
#warning "For timing resistance / side-channel attack prevention consider using harden options"
#else
#pragma message("Warning: For timing resistance / side-channel attack prevention consider using harden options")
#endif
#endif
/* added to have compatibility with SHA256() */
#if !defined(NO_OLD_SHA256_NAMES) && !defined(HAVE_FIPS)
#define NO_OLD_SHA256_NAMES
#endif
/* switch for compatibility layer functionality. Has subparts i.e. BIO/X509
} /* extern "C" */
_My file wcport.h ` / wc_port.h
/! \file wolfssl/wolfcrypt/wc_port.h /
extern "C" {
#ifdef WOLFSSL_GAME_BUILD
#include "system/xtl.h"
#else
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef WOLFSSL_SGX
#if defined(_WIN32_WCE) || defined(WIN32_LEAN_AND_MEAN)
/* On WinCE winsock2.h must be included before windows.h */
#include <winsock2.h>
#endif
#include <windows.h>
#endif /* WOLFSSL_SGX */
#endif
#ifndef SINGLE_THREADED
#ifdef NEED_THREADX_TYPES
#include <types.h>
#endif
#include <tx_api.h>
#endif
/* do nothing, just don't pick Unix */
/* do nothing */
/* do nothing */
/* do nothing */
#include "fsl_os_abstraction.h"
#include "stddef.h"
#include "kernel.h"
#include "tk/tkernel.h"
#include "cmsis_os.h"
#if defined(WOLFSSL_MDK5)
#include "cmsis_os.h"
#else
#include <rtl.h>
#endif
#include "cmsis_os.h"
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <semaphore.h>
#include <rt.h>
#include <io.h>
#ifndef SINGLE_THREADED
#define WOLFSSL_PTHREADS
#include <pthread.h>
#endif
#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
#include <unistd.h> /* for close of BIO */
#endif
/ For FIPS keep the function names the same /
typedef int wolfSSL_Mutex;
/* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
#if defined(FREERTOS)
typedef xSemaphoreHandle wolfSSL_Mutex;
#elif defined(FREERTOS_TCP)
#include "FreeRTOS.h"
#include "semphr.h"
typedef SemaphoreHandle_t wolfSSL_Mutex;
#elif defined(WOLFSSL_SAFERTOS)
typedef struct wolfSSL_Mutex {
signed char mutexBuffer[portQUEUE_OVERHEAD_BYTES];
xSemaphoreHandle mutex;
} wolfSSL_Mutex;
#elif defined(USE_WINDOWS_API)
typedef CRITICAL_SECTION wolfSSL_Mutex;
#elif defined(WOLFSSL_PTHREADS)
typedef pthread_mutex_t wolfSSL_Mutex;
#elif defined(THREADX)
typedef TX_MUTEX wolfSSL_Mutex;
#elif defined(MICRIUM)
typedef OS_MUTEX wolfSSL_Mutex;
#elif defined(EBSNET)
typedef RTP_MUTEX wolfSSL_Mutex;
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
typedef MUTEX_STRUCT wolfSSL_Mutex;
#elif defined(FREESCALE_FREE_RTOS)
typedef mutex_t wolfSSL_Mutex;
#elif defined(WOLFSSL_uITRON4)
typedef struct wolfSSL_Mutex {
T_CSEM sem ;
ID id ;
} wolfSSL_Mutex;
#elif defined(WOLFSSL_uTKERNEL2)
typedef struct wolfSSL_Mutex {
T_CSEM sem ;
ID id ;
} wolfSSL_Mutex;
#elif defined(WOLFSSL_MDK_ARM)
#if defined(WOLFSSL_CMSIS_RTOS)
typedef osMutexId wolfSSL_Mutex;
#else
typedef OS_MUT wolfSSL_Mutex;
#endif
#elif defined(WOLFSSL_CMSIS_RTOS)
typedef osMutexId wolfSSL_Mutex;
#elif defined(WOLFSSL_TIRTOS)
typedef ti_sysbios_knl_Semaphore_Handle wolfSSL_Mutex;
#elif defined(WOLFSSL_FROSTED)
typedef mutex_t * wolfSSL_Mutex;
#elif defined(INTIME_RTOS)
typedef RTHANDLE wolfSSL_Mutex;
#else
#error Need a mutex type in multithreaded mode
#endif /* USE_WINDOWS_API */
/ Enable crypt HW mutex for Freescale MMCAU or PIC32MZ /
#ifndef WOLFSSL_CRYPT_HW_MUTEX
#define WOLFSSL_CRYPT_HW_MUTEX 1
#endif
#define WOLFSSL_CRYPT_HW_MUTEX 0
/* wolfSSL_CryptHwMutexInit is called on first wolfSSL_CryptHwMutexLock,
however it's recommended to call this directly on Hw init to avoid possible
race condition where two calls to wolfSSL_CryptHwMutexLock are made at
the same time. */
int wolfSSL_CryptHwMutexInit(void);
int wolfSSL_CryptHwMutexLock(void);
int wolfSSL_CryptHwMutexUnLock(void);
/* Define stubs, since HW mutex is disabled */
#define wolfSSL_CryptHwMutexInit() 0 /* Success */
#define wolfSSL_CryptHwMutexLock() 0 /* Success */
#define wolfSSL_CryptHwMutexUnLock() (void)0 /* Success */
/ Mutex functions / WOLFSSL_API int wc_InitMutex(wolfSSL_Mutex); WOLFSSL_API wolfSSL_Mutex wc_InitAndAllocMutex(void); WOLFSSL_API int wc_FreeMutex(wolfSSL_Mutex); WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex); WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex*);
/ dynamiclly set which mutex to use. unlock / lock is controlled by flag / typedef void (mutex_cb)(int flag, int type, const char* file, int line);
WOLFSSL_API int wc_LockMutex_ex(int flag, int type, const char file, int line); WOLFSSL_API int wc_SetMutexCb(mutex_cb cb);
/ main crypto initialization function / WOLFSSL_API int wolfCrypt_Init(void); WOLFSSL_API int wolfCrypt_Cleanup(void);
/ filesystem abstraction layer, used by ssl.c /
#include "vfapi.h"
#include "vfile.h"
#define XFILE int
#define XFOPEN(NAME, MODE) vf_open((const char *)NAME, VO_RDONLY, 0);
#define XFSEEK vf_lseek
#define XFTELL vf_tell
#define XREWIND vf_rewind
#define XFREAD(BUF, SZ, AMT, FD) vf_read(FD, BUF, SZ*AMT)
#define XFWRITE(BUF, SZ, AMT, FD) vf_write(FD, BUF, SZ*AMT)
#define XFCLOSE vf_close
#define XSEEK_END VSEEK_END
#define XBADFILE -1
#define XFGETS(b,s,f) -2 /* Not ported yet */
#include <fs.h>
#define XFILE struct fs_file*
#define XFOPEN(NAME, MODE) fs_open((char*)NAME);
#define XFSEEK(F, O, W) (void)F
#define XFTELL(F) (F)->len
#define XREWIND(F) (void)F
#define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT)
#define XFWRITE(BUF, SZ, AMT, F) fs_write(F, (char*)BUF, SZ*AMT)
#define XFCLOSE fs_close
#define XSEEK_END 0
#define XBADFILE NULL
#define XFGETS(b,s,f) -2 /* Not ported yet */
#define XFILE MQX_FILE_PTR
#define XFOPEN fopen
#define XFSEEK fseek
#define XFTELL ftell
#define XREWIND(F) fseek(F, 0, IO_SEEK_SET)
#define XFREAD fread
#define XFWRITE fwrite
#define XFCLOSE fclose
#define XSEEK_END IO_SEEK_END
#define XBADFILE NULL
#define XFGETS fgets
#include <fs_api.h>
#define XFILE FS_FILE*
#define XFOPEN fs_fopen
#define XFSEEK fs_fseek
#define XFTELL fs_ftell
#define XREWIND fs_rewind
#define XFREAD fs_fread
#define XFWRITE fs_fwrite
#define XFCLOSE fs_fclose
#define XSEEK_END FS_SEEK_END
#define XBADFILE NULL
#define XFGETS(b,s,f) -2 /* Not ported yet */
/* stdio, default case */
#include <stdio.h>
#define XFILE FILE*
#if defined(WOLFSSL_MDK_ARM)
extern FILE * wolfSSL_fopen(const char *name, const char *mode) ;
#define XFOPEN wolfSSL_fopen
#else
#define XFOPEN fopen
#endif
#define XFSEEK fseek
#define XFTELL ftell
#define XREWIND rewind
#define XFREAD fread
#define XFWRITE fwrite
#define XFCLOSE fclose
#define XSEEK_END SEEK_END
#define XBADFILE NULL
#define XFGETS fgets
#if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR)
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#endif
#ifndef MAX_FILENAME_SZ
#define MAX_FILENAME_SZ 256 /* max file name length */
#endif
#ifndef MAX_PATH
#define MAX_PATH 256
#endif
typedef struct ReadDirCtx {
#ifdef USE_WINDOWS_API
WIN32_FIND_DATAA FindFileData;
HANDLE hFind;
#else
struct dirent* entry;
DIR* dir;
struct stat s;
#endif
char name[MAX_FILENAME_SZ];
} ReadDirCtx;
WOLFSSL_API int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name);
WOLFSSL_API int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name);
WOLFSSL_API void wc_ReadDirClose(ReadDirCtx* ctx);
/ Windows API defines its own min() macro. /
#if defined(min) || defined(WOLFSSL_MYSQL_COMPATIBLE)
#define WOLFSSL_HAVE_MIN
#endif /* min */
#if defined(max) || defined(WOLFSSL_MYSQL_COMPATIBLE)
#define WOLFSSL_HAVE_MAX
#endif /* max */
/ Time functions /
/* Use our gmtime and time_t/struct tm types.
Only needs seconds since EPOCH using XTIME function.
time_t XTIME(time_t * timer) {}
*/
#define WOLFSSL_GMTIME
#define USE_WOLF_TM
#define USE_WOLF_TIME_T
/* Override XTIME() and XGMTIME() functionality.
Requires user to provide these functions:
time_t XTIME(time_t * timer) {}
struct tm* XGMTIME(const time_t* timer, struct tm* tmp) {}
*/
#ifndef HAVE_TIME_T_TYPE
#define USE_WOLF_TIME_T
#endif
#ifndef HAVE_TM_TYPE
#define USE_WOLF_TM
#endif
#define NEED_TMP_TIME
#include "os.h" /* dc_rtc_api needs */
#include "dc_rtc_api.h" /* to get current time */
/* uses parital <time.h> structures */
#define XTIME(tl) (0)
#define XGMTIME(c, t) rtpsys_gmtime((c))
#include <clk.h>
#include <time.h>
#define XTIME(t1) micrium_time((t1))
#define WOLFSSL_GMTIME
#include <time.h>
#define XTIME(t1) pic32_time((t1))
#define XGMTIME(c, t) gmtime((c))
#define XTIME(t1) mqx_time((t1))
#define HAVE_GMTIME_R
#include <time.h>
#ifndef XTIME
/*extern time_t ksdk_time(time_t* timer);*/
#define XTIME(t1) ksdk_time((t1))
#endif
#define XGMTIME(c, t) gmtime((c))
#define XTIME(t1) atmel_get_curr_time_and_date((t1))
#define WOLFSSL_GMTIME
#define USE_WOLF_TM
#define USE_WOLF_TIME_T
/*Gets the timestamp from cloak software owned by VT iDirect
in place of time() from <time.h> */
#include <time.h>
#define XTIME(t1) idirect_time((t1))
#define XGMTIME(c, t) gmtime((c))
#include <windows.h>
#define XTIME(t1) windows_time((t1))
#define WOLFSSL_GMTIME
/* default */
/* uses complete <time.h> facility */
#include <time.h>
/* PowerPC time_t is int */
#ifdef __PPC__
#define TIME_T_NOT_LONG
#endif
/ Map default time functions /
#define XTIME(tl) time((tl))
#if defined(WOLFSSL_GMTIME) || !defined(HAVE_GMTIME_R)
#define XGMTIME(c, t) gmtime((c))
#else
#define XGMTIME(c, t) gmtime_r((c), (t))
#define NEED_TMP_TIME
#endif
#define USE_WOLF_VALIDDATE
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
/ wolf struct tm and time_t /
struct tm {
int tm_sec; /* seconds after the minute [0-60] */
int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
int tm_mon; /* months since January [0-11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
int tm_isdst; /* Daylight Savings Time flag */
long tm_gmtoff; /* offset from CUT in seconds */
char *tm_zone; /* timezone abbreviation */
};
typedef long time_t;
/ forward declarations /
struct tm* gmtime(const time_t* timer);
extern time_t XTIME(time_t * timer);
#ifdef STACK_TRAP
/* for stack trap tracking, don't call os gmtime on OS X/linux,
uses a lot of stack spce */
extern time_t time(time_t * timer);
#define XTIME(tl) time((tl))
#endif /* STACK_TRAP */
extern time_t XTIME(time_t * timer);
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
struct tm* gmtime(const time_t* timer);
} /* extern "C" */
Hello,
I'm trying to compile the lib under Arduino IDE 1.6.11 / Ubuntu 16.04.1.
Compilation performed without error once I have carried few steps out:
I have also undefined reference to XTIME/GMTTIME because TIME_OVERRIDES is defined in Arduino section.
I'm wondering whether or not I have really to do all of this in order to pass compilation under Arduino IDE ?
Thanks, Anthony