Zephyr port of crypto

pull/2075/head
Sean Parkinson 2019-02-07 16:11:17 +10:00
parent 25dd5882f8
commit 3366acc9ce
14 changed files with 579 additions and 185 deletions

View File

@ -6436,6 +6436,13 @@ ProtocolVersion MakeDTLSv1_2(void)
return now;
}
#elif defined(WOLFSSL_ZEPHYR)
word32 LowResTimer(void)
{
return k_uptime_get() / 1000;
}
#else
/* Posix style time */
#ifndef USER_TIME

View File

@ -69,6 +69,29 @@
void BSP_Ser_Printf (CPU_CHAR* format, ...);
#undef printf
#define printf BSP_Ser_Printf
#elif defined(WOLFSSL_ZEPHYR)
#include <stdio.h>
#define BENCH_EMBEDDED
#define printf printfk
static int printfk(const char *fmt, ...)
{
int ret;
char line[150];
va_list ap;
va_start(ap, fmt);
ret = vsnprintf(line, sizeof(line), fmt, ap);
line[sizeof(line)-1] = '\0';
printk("%s", line);
va_end(ap);
return ret;
}
#else
#include <stdio.h>
#endif
@ -228,6 +251,7 @@ typedef struct bench_alg {
int val;
} bench_alg;
#ifndef MAIN_NO_ARGS
/* All recognized cipher algorithm choosing command line options. */
static const bench_alg bench_cipher_opt[] = {
{ "-cipher", -1 },
@ -410,6 +434,7 @@ static const bench_alg bench_other_opt[] = {
#endif
{ NULL, 0}
};
#endif /* MAIN_NO_ARGS */
#endif /* !WOLFSSL_BENCHMARK_ALL && !NO_MAIN_DRIVER */
@ -424,7 +449,9 @@ static const bench_alg bench_other_opt[] = {
#endif
static int lng_index = 0;
#ifndef NO_MAIN_DRIVER
#ifndef MAIN_NO_ARGS
static const char* bench_Usage_msg1[][10] = {
/* 0 English */
{ "-? <num> Help, print this usage\n 0: English, 1: Japanese\n",
@ -453,6 +480,7 @@ static const char* bench_Usage_msg1[][10] = {
},
#endif
};
#endif /* MAIN_NO_ARGS */
#endif
static const char* bench_result_words1[][4] = {
@ -1707,6 +1735,8 @@ int benchmark_test(void *args)
benchmarks_do(NULL);
#endif
printf("Benchmark complete\n");
ret = benchmark_free();
EXIT_TEST(ret);
@ -5252,6 +5282,21 @@ exit_ed_verify:
(void)reset;
return (double) CPU_TS_Get32()/CPU_TS_TmrFreqGet(&err);
}
#elif defined(WOLFSSL_ZEPHYR)
#include <time.h>
double current_time(int reset)
{
(void)reset;
#if defined(CONFIG_ARCH_POSIX)
k_cpu_idle();
#endif
return (double)k_uptime_get() / 1000;
}
#else
#include <sys/time.h>
@ -5297,6 +5342,8 @@ void benchmark_configure(int block_size)
#ifndef NO_MAIN_DRIVER
#ifndef MAIN_NO_ARGS
#ifndef WOLFSSL_BENCHMARK_ALL
/* Display the algorithm string and keep to 80 characters per line.
*
@ -5378,13 +5425,18 @@ static int string_matches(const char* arg, const char* str)
int len = (int)XSTRLEN(str) + 1;
return XSTRNCMP(arg, str, len) == 0;
}
#endif /* MAIN_NO_ARGS */
#ifdef WOLFSSL_ESPIDF
int wolf_benchmark_task( )
#elif defined(MAIN_NO_ARGS)
int main()
#else
int main(int argc, char** argv)
#endif
{
int ret = 0;
#ifndef MAIN_NO_ARGS
int optMatched;
#ifdef WOLFSSL_ESPIDF
int argc = construct_argv();
@ -5393,7 +5445,9 @@ int main(int argc, char** argv)
#ifndef WOLFSSL_BENCHMARK_ALL
int i;
#endif
#endif
#ifndef MAIN_NO_ARGS
while (argc > 1) {
if (string_matches(argv[1], "-?")) {
if(--argc>1){
@ -5499,6 +5553,7 @@ int main(int argc, char** argv)
argc--;
argv++;
}
#endif /* MAIN_NO_ARGS */
#ifdef HAVE_STACK_SIZE
ret = StackSizeCheck(NULL, benchmark_test);

View File

@ -259,6 +259,8 @@ static void wolfssl_log(const int logLevel, const char *const logMessage)
LOG_DEBUG(&mynewt_log, LOG_MODULE_DEFAULT, "%s\n", logMessage);
#elif defined(WOLFSSL_ESPIDF)
ESP_LOGI("wolfssl", "%s", logMessage);
#elif defined(WOLFSSL_ZEPHYR)
printk("%s\n", logMessage);
#else
fprintf(stderr, "%s\n", logMessage);
#endif

View File

@ -53,6 +53,19 @@ Possible memory options:
* WOLFSSL_HEAP_TEST: Used for internal testing of heap hint
*/
#ifdef WOLFSSL_ZEPHYR
#undef realloc
void *z_realloc(void *ptr, size_t size)
{
if (ptr == NULL)
ptr = malloc(size);
else
ptr = realloc(ptr, size);
return ptr;
}
#define realloc z_realloc
#endif
#ifdef USE_WOLFSSL_MEMORY

View File

@ -148,6 +148,7 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
#elif defined(MICRIUM)
#elif defined(WOLFSSL_NUCLEUS)
#elif defined(WOLFSSL_PB)
#elif defined(WOLFSSL_ZEPHYR)
#else
/* include headers that may be needed to get good seed */
#include <fcntl.h>
@ -2157,6 +2158,41 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
#define USE_TEST_GENSEED
#elif defined(WOLFSSL_ZEPHYR)
#include <entropy.h>
#ifndef _POSIX_C_SOURCE
#include <posix/time.h>
#else
#include <sys/time.h>
#endif
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int ret = 0;
struct device* dev;
dev = device_get_binding(CONFIG_ENTROPY_NAME);
if (dev != NULL) {
if (entropy_get_entropy(dev, output, sz) != 0)
ret = READ_RAN_E;
}
else {
word32 now;
while (sz > 0) {
word32 len = sizeof(now);
if (sz < len)
len = sz;
now = k_cycle_get_32();
XMEMCPY(output, &now, sz);
output += len;
sz -= len;
}
}
return ret;
}
#elif defined(NO_DEV_RANDOM)
#error "you need to write an os specific wc_GenerateSeed() here"

View File

@ -298,6 +298,37 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
return 0;
}
} while (FindNextFileA(ctx->hFind, &ctx->FindFileData));
#elif defined(WOLFSSL_ZEPHYR)
if (fs_opendir(&ctx->dir, path) != 0) {
WOLFSSL_MSG("opendir path verify locations failed");
return BAD_PATH_ERROR;
}
ctx->dirp = &ctx->dir;
while ((fs_readdir(&ctx->dir, &ctx->entry)) != 0) {
dnameLen = (int)XSTRLEN(ctx->entry.name);
if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
ret = BAD_PATH_ERROR;
break;
}
XSTRNCPY(ctx->name, path, pathLen + 1);
ctx->name[pathLen] = '/';
/* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
* of earlier check it is known that dnameLen is less than
* MAX_FILENAME_SZ - (pathLen + 2) so dnameLen +1 will fit */
XSTRNCPY(ctx->name + pathLen + 1, ctx->entry.name, dnameLen + 1);
if (fs_stat(ctx->name, &ctx->s) != 0) {
WOLFSSL_MSG("stat on name failed");
ret = BAD_PATH_ERROR;
break;
} else if (ctx->s.type == FS_DIR_ENTRY_FILE) {
if (name)
*name = ctx->name;
return 0;
}
}
#else
ctx->dir = opendir(path);
if (ctx->dir == NULL) {
@ -370,6 +401,31 @@ int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name)
return 0;
}
}
#elif defined(WOLFSSL_ZEPHYR)
while ((fs_readdir(&ctx->dir, &ctx->entry)) != 0) {
dnameLen = (int)XSTRLEN(ctx->entry.name);
if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
ret = BAD_PATH_ERROR;
break;
}
XSTRNCPY(ctx->name, path, pathLen + 1);
ctx->name[pathLen] = '/';
/* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
* of earlier check it is known that dnameLen is less than
* MAX_FILENAME_SZ - (pathLen + 2) so that dnameLen +1 will fit */
XSTRNCPY(ctx->name + pathLen + 1, ctx->entry.name, dnameLen + 1);
if (fs_stat(ctx->name, &ctx->s) != 0) {
WOLFSSL_MSG("stat on name failed");
ret = BAD_PATH_ERROR;
break;
} else if (ctx->s.type == FS_DIR_ENTRY_FILE) {
if (name)
*name = ctx->name;
return 0;
}
}
#else
while ((ctx->entry = readdir(ctx->dir)) != NULL) {
dnameLen = (int)XSTRLEN(ctx->entry->d_name);
@ -413,6 +469,11 @@ void wc_ReadDirClose(ReadDirCtx* ctx)
FindClose(ctx->hFind);
ctx->hFind = INVALID_HANDLE_VALUE;
}
#elif defined(WOLFSSL_ZEPHYR)
if (ctx->dirp) {
fs_closedir(ctx->dirp);
ctx->dirp = NULL;
}
#else
if (ctx->dir) {
closedir(ctx->dir);
@ -423,6 +484,33 @@ void wc_ReadDirClose(ReadDirCtx* ctx)
#endif /* !NO_FILESYSTEM && !NO_WOLFSSL_DIR */
#if !defined(NO_FILESYSTEM) && defined(WOLFSSL_ZEPHYR)
XFILE z_fs_open(const char* filename, const char* perm)
{
XFILE file;
file = XMALLOC(sizeof(file), NULL, DYNAMIC_TYPE_FILE);
if (file != NULL)
fs_open(file, filename);
return file;
}
int z_fs_close(XFILE file)
{
int ret;
if (file == NULL)
return -1;
ret = (fs_close(file) == 0) ? 0 : -1;
XFREE(file, NULL, DYNAMIC_TYPE_FILE);
return ret;
}
#endif /* !NO_FILESYSTEM && !NO_WOLFSSL_DIR */
wolfSSL_Mutex* wc_InitAndAllocMutex(void)
{
@ -1468,6 +1556,37 @@ int wolfSSL_CryptHwMutexUnLock(void) {
return BAD_MUTEX_E;
}
#elif defined(WOLFSSL_ZEPHYR)
int wc_InitMutex(wolfSSL_Mutex* m)
{
k_mutex_init(m);
return 0;
}
int wc_FreeMutex(wolfSSL_Mutex* m)
{
return 0;
}
int wc_LockMutex(wolfSSL_Mutex* m)
{
int ret = 0;
if (k_mutex_lock(m, K_FOREVER) != 0)
ret = BAD_MUTEX_E;
return ret;
}
int wc_UnLockMutex(wolfSSL_Mutex* m)
{
k_mutex_unlock(m);
return 0;
}
#else
#warning No mutex handling defined
@ -1639,7 +1758,6 @@ time_t deos_time(time_t* timer)
}
#endif /* WOLFSSL_DEOS */
#if defined(MICRIUM)
time_t micrium_time(time_t* timer)
@ -1717,6 +1835,22 @@ time_t XTIME(time_t * timer)
}
#endif /* WOLFSSL_XILINX */
#if defined(WOLFSSL_ZEPHYR)
time_t z_time(time_t * timer)
{
struct timespec ts;
if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
if (timer != NULL)
*timer = ts.tv_sec;
return ts.tv_sec;
}
#endif /* WOLFSSL_ZEPHYR */
#endif /* !NO_ASN_TIME */
#ifndef WOLFSSL_LEANPSK

File diff suppressed because it is too large Load Diff

View File

@ -169,6 +169,10 @@
void mynewt_ctx_clear(void *ctx);
void* mynewt_ctx_new();
#endif
#elif defined(WOLFSSL_ZEPHYR)
#ifndef SINGLE_THREADED
#include <kernel.h>
#endif
#else
#ifndef SINGLE_THREADED
#define WOLFSSL_PTHREADS

View File

@ -1707,7 +1707,8 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL*, void* key, unsigned int len,
#elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && \
!defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM) && \
!defined(WOLFSSL_EMBOS) && !defined(WOLFSSL_FROSTED) && \
!defined(WOLFSSL_CHIBIOS) && !defined(WOLFSSL_CONTIKI)
!defined(WOLFSSL_CHIBIOS) && !defined(WOLFSSL_CONTIKI) && \
!defined(WOLFSSL_ZEPHYR)
#include <sys/uio.h>
#endif
/* allow writev style writing */

View File

@ -93,6 +93,30 @@
#include <netdb.h>
#include <pthread.h>
#define SOCKET_T int
#elif defined(WOLFSSL_ZEPHYR)
#include <string.h>
#include <sys/types.h>
#include <net/socket.h>
#define SOCKET_T int
#define SOL_SOCKET 1
#define SO_REUSEADDR 201
#define WOLFSSL_USE_GETADDRINFO
static unsigned long inet_addr(const char *cp)
{
unsigned int a[4]; unsigned long ret;
int i, j;
for (i=0, j=0; i<4; i++) {
a[i] = 0;
while (cp[j] != '.' && cp[j] != '\0') {
a[i] *= 10;
a[i] += cp[j] - '0';
j++;
}
}
ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ;
return(ret) ;
}
#else
#include <string.h>
#include <sys/types.h>
@ -203,6 +227,10 @@
typedef void THREAD_RETURN;
typedef Task_Handle THREAD_TYPE;
#define WOLFSSL_THREAD
#elif defined(WOLFSSL_ZEPHYR)
typedef unsigned int THREAD_RETURN;
typedef k_tid_t THREAD_TYPE;
#define WOLFSSL_THREAD
#else
typedef unsigned int THREAD_RETURN;
typedef intptr_t THREAD_TYPE;
@ -394,7 +422,10 @@ static const word16 wolfSSLPort = 11111;
#define EXIT_FAILURE 1
#endif
#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
#if defined(WOLFSSL_FORCE_MALLOC_FAIL_TEST) || defined(WOLFSSL_ZEPHYR)
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#define XEXIT(rc) return rc
#define XEXIT_T(rc) return (THREAD_RETURN)rc
#else
@ -404,7 +435,7 @@ static const word16 wolfSSLPort = 11111;
static WC_INLINE
#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
#if defined(WOLFSSL_FORCE_MALLOC_FAIL_TEST) || defined(WOLFSSL_ZEPHYR)
THREAD_RETURN
#else
WC_NORETURN void
@ -751,6 +782,7 @@ static WC_INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
#ifndef TEST_IPV6
/* peer could be in human readable form */
if ( ((size_t)peer != INADDR_ANY) && isalpha((int)peer[0])) {
#ifndef WOLFSSL_USE_GETADDRINFO
#if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
int err;
struct hostent* entry = gethostbyname(peer, &err);
@ -767,6 +799,19 @@ static WC_INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
entry->h_length);
useLookup = 1;
}
#else
struct zsock_addrinfo hints, *addrInfo;
char portStr[6];
XSNPRINTF(portStr, sizeof(portStr), "%d", port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM;
hints.ai_protocol = udp ? IPPROTO_UDP : IPPROTO_TCP;
if (getaddrinfo((char*)peer, portStr, &hints, &addrInfo) == 0) {
XMEMCPY(addr, addrInfo->ai_addr, sizeof(*addr));
useLookup = 1;
}
#endif
else
err_sys("no entry for host");
}
@ -862,7 +907,7 @@ static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
err_sys("setsockopt SO_NOSIGPIPE failed\n");
}
#elif defined(WOLFSSL_MDK_ARM) || defined (WOLFSSL_TIRTOS) ||\
defined(WOLFSSL_KEIL_TCP_NET)
defined(WOLFSSL_KEIL_TCP_NET) || defined(WOLFSSL_ZEPHYR)
/* nothing to define */
#else /* no S_NOSIGPIPE */
signal(SIGPIPE, SIG_IGN);
@ -993,7 +1038,7 @@ static WC_INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr,
tcp_socket(sockfd, udp, sctp);
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)\
&& !defined(WOLFSSL_KEIL_TCP_NET)
&& !defined(WOLFSSL_KEIL_TCP_NET) && !defined(WOLFSSL_ZEPHYR)
{
int res, on = 1;
socklen_t len = sizeof(on);
@ -1014,7 +1059,8 @@ static WC_INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr,
if (listen(*sockfd, SOCK_LISTEN_MAX_QUEUE) != 0)
err_sys("tcp listen failed");
}
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS) \
&& !defined(WOLFSSL_ZEPHYR)
if (*port == 0) {
socklen_t len = sizeof(addr);
if (getsockname(*sockfd, (struct sockaddr*)&addr, &len) == 0) {
@ -1062,7 +1108,7 @@ static WC_INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM) \
&& !defined(WOLFSSL_KEIL_TCP_NET)
&& !defined(WOLFSSL_KEIL_TCP_NET) && !defined(WOLFSSL_ZEPHYR)
{
int res, on = 1;
socklen_t len = sizeof(on);
@ -1186,7 +1232,8 @@ static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
if (ret == SOCKET_ERROR)
err_sys("ioctlsocket failed");
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) \
|| defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS)
|| defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS) \
|| defined(WOLFSSL_ZEPHYR)
/* non blocking not supported, for now */
#else
int flags = fcntl(*sockfd, F_GETFL, 0);
@ -1357,6 +1404,8 @@ static WC_INLINE unsigned int my_psk_server_tls13_cb(WOLFSSL* ssl,
#elif defined(WOLFSSL_TIRTOS)
extern double current_time();
#elif defined(WOLFSSL_ZEPHYR)
extern double current_time();
#else
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_TCP_NET) && !defined(WOLFSSL_CHIBIOS)

View File

@ -1378,6 +1378,29 @@ extern void uITRON4_free(void *p) ;
#endif /*(WOLFSSL_APACHE_MYNEWT)*/
#ifdef WOLFSSL_ZEPHYR
#include <zephyr.h>
#include <misc/printk.h>
#include <misc/util.h>
#include <stdlib.h>
#define WOLFSSL_DH_CONST
#define WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MAX
#define NO_WRITEV
#define USE_FLAT_BENCHMARK_H
#define USE_FLAT_TEST_H
#define EXIT_FAILURE 1
#define MAIN_NO_ARGS
void *z_realloc(void *ptr, size_t size);
#define realloc z_realloc
#define CONFIG_NET_BUF_USER_DATA_SIZE 10
#define CONFIG_NET_SOCKETS_POSIX_NAMES
#endif
#ifdef WOLFSSL_IMX6
#ifndef SIZEOF_LONG_LONG
#define SIZEOF_LONG_LONG 8

View File

@ -175,7 +175,8 @@
#if defined(_MSC_VER)
#define THREAD_LS_T __declspec(thread)
/* Thread local storage only in FreeRTOS v8.2.1 and higher */
#elif defined(FREERTOS) || defined(FREERTOS_TCP)
#elif defined(FREERTOS) || defined(FREERTOS_TCP) || \
defined(WOLFSSL_ZEPHYR)
#define THREAD_LS_T
#else
#define THREAD_LS_T __thread
@ -360,7 +361,8 @@
#endif
#ifndef XSTRNCASECMP
#if defined(MICROCHIP_PIC32) || defined(WOLFSSL_TIRTOS)
#if defined(MICROCHIP_PIC32) || defined(WOLFSSL_TIRTOS) || \
defined(WOLFSSL_ZEPHYR)
/* XC32 does not support strncasecmp, so use case sensitive one */
#define XSTRNCASECMP(s1,s2,n) strncmp((s1),(s2),(n))
#elif defined(USE_WINDOWS_API) || defined(FREERTOS_TCP_WINSIM)

View File

@ -108,6 +108,14 @@
#include "nucleus.h"
#elif defined(WOLFSSL_APACHE_MYNEWT)
/* do nothing */
#elif defined(WOLFSSL_ZEPHYR)
#ifndef SINGLE_THREADED
#include <kernel.h>
#define WOLFSSL_PTHREADS
#define HAVE_PTHREAD
#include <posix/pthread.h>
#endif
#else
#ifndef SINGLE_THREADED
#define WOLFSSL_PTHREADS
@ -185,6 +193,8 @@
typedef RTHANDLE wolfSSL_Mutex;
#elif defined(WOLFSSL_NUCLEUS_1_2)
typedef NU_SEMAPHORE wolfSSL_Mutex;
#elif defined(WOLFSSL_ZEPHYR)
typedef struct k_mutex wolfSSL_Mutex;
#else
#error Need a mutex type in multithreaded mode
#endif /* USE_WINDOWS_API */
@ -321,6 +331,27 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
#define XSEEK_END 2
#define XBADFILE NULL
#define XFGETS(b,s,f) -2 /* Not ported yet */
#elif defined(WOLFSSL_ZEPHYR)
#include <fs.h>
#define XFILE struct fs_file_t*
#define STAT struct fs_dirent
XFILE z_fs_open(const char* filename, const char* perm);
int z_fs_close(XFILE file);
#define XFOPEN z_fs_open
#define XFCLOSE z_fs_close
#define XFSEEK fs_seek
#define XFTELL fs_tell
#define XFREWIND fs_rewind
#define XREWIND(F) fs_seek(F, 0, FS_SEEK_SET)
#define XFREAD(P,S,N,F) fs_read(F, P, S*N)
#define XFWRITE(P,S,N,F) fs_write(F, P, S*N)
#define XSEEK_END FS_SEEK_END
#define XBADFILE NULL
#define XFGETS(b,s,f) -2 /* Not ported yet */
#elif defined(WOLFSSL_USER_FILESYSTEM)
/* To be defined in user_settings.h */
#else
@ -364,6 +395,11 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
#ifdef USE_WINDOWS_API
WIN32_FIND_DATAA FindFileData;
HANDLE hFind;
#elif defined(WOLFSSL_ZEPHYR)
struct fs_dirent entry;
struct fs_dir_t dir;
struct fs_dirent s;
struct fs_dir_t* dirp;
#else
struct dirent* entry;
DIR* dir;
@ -486,6 +522,24 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
#define WOLFSSL_GMTIME
#define USE_WOLF_TM
#define USE_WOLF_TIME_T
#elif defined(WOLFSSL_ZEPHYR)
#ifndef _POSIX_C_SOURCE
#include <posix/time.h>
#else
#include <sys/time.h>
#endif
typedef signed int time_t;
time_t z_time(time_t *timer);
#define XTIME(tl) z_time((tl))
#define XGMTIME(c, t) gmtime((c))
#define WOLFSSL_GMTIME
#define USE_WOLF_TM
#else
/* default */
/* uses complete <time.h> facility */

View File

@ -116,6 +116,8 @@
#include <socketapi.h>
#include <lwip-socket.h>
#include <errno.h>
#elif defined(WOLFSSL_ZEPHYR)
#include <net/socket.h>
#elif !defined(WOLFSSL_NO_SOCK)
#include <sys/types.h>
#include <errno.h>
@ -257,6 +259,9 @@
#elif defined(WOLFSSL_NUCLEUS_1_2)
#define SEND_FUNCTION NU_Send
#define RECV_FUNCTION NU_Recv
#elif defined(WOLFSSL_ZEPHYR)
#define SEND_FUNCTION zsock_send
#define RECV_FUNCTION zsock_recv
#else
#define SEND_FUNCTION send
#define RECV_FUNCTION recv