Check-in Nucleus Plus 2.3 port work

This commit is contained in:
kaleb-himes
2024-07-09 15:53:00 -06:00
parent 00e42151ca
commit c333fdf545
6 changed files with 151 additions and 1 deletions

View File

@ -41,6 +41,11 @@
#include <wolfssl/error-ssl.h> #include <wolfssl/error-ssl.h>
#include <wolfssl/wolfio.h> #include <wolfssl/wolfio.h>
#ifdef NUCLEUS_PLUS_2_3
/* Holds last Nucleus networking error number */
int Nucleus_Net_Errno;
#endif
#if defined(USE_WOLFSSL_IO) || defined(HAVE_HTTP_CLIENT) #if defined(USE_WOLFSSL_IO) || defined(HAVE_HTTP_CLIENT)
#ifndef USE_WINDOWS_API #ifndef USE_WINDOWS_API
#if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT) #if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
@ -176,6 +181,8 @@ static WC_INLINE int wolfSSL_LastError(int err)
#elif defined(FUSION_RTOS) #elif defined(FUSION_RTOS)
#include <fclerrno.h> #include <fclerrno.h>
return FCL_GET_ERRNO; return FCL_GET_ERRNO;
#elif defined(NUCLEUS_PLUS_2_3)
return Nucleus_Net_Errno;
#else #else
return errno; return errno;
#endif #endif
@ -411,6 +418,110 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx)
#include <wolfssl/wolfcrypt/sha.h> #include <wolfssl/wolfcrypt/sha.h>
#if defined(NUCLEUS_PLUS_2_3)
STATIC INT32 nucyassl_recv(INT sd, CHAR *buf, UINT16 sz, INT16 flags)
{
int recvd;
/* Read data from socket */
recvd = NU_Recv(sd, buf, sz, flags);
if (recvd < 0) {
if (recvd == NU_NOT_CONNECTED) {
recvd = 0;
} else {
Nucleus_Net_Errno = recvd;
recvd = WOLFSSL_FATAL_ERROR;
}
} else {
Nucleus_Net_Errno = 0;
}
return (recvd);
}
STATIC int nucyassl_send(INT sd, CHAR *buf, UINT16 sz, INT16 flags)
{
int sent;
/* Write data to socket */
sent = NU_Send(sd, buf, sz, flags);
if (sent < 0) {
Nucleus_Net_Errno = sent;
sent = WOLFSSL_FATAL_ERROR;
} else {
Nucleus_Net_Errno = 0;
}
return sent;
}
#define SELECT_FUNCTION nucyassl_select
int nucyassl_select(INT sd, UINT32 timeout)
{
FD_SET readfs;
STATUS status;
/* Init fs data for socket */
NU_FD_Init(&readfs);
NU_FD_Set(sd, &readfs);
/* Wait for data to arrive */
status = NU_Select((sd + 1), &readfs, NU_NULL, NU_NULL,
(timeout * NU_TICKS_PER_SECOND));
if (status < 0) {
Nucleus_Net_Errno = status;
status = WOLFSSL_FATAL_ERROR;
}
return status;
}
#define sockaddr_storage addr_struct
#define sockaddr addr_struct
STATIC INT32 nucyassl_recvfrom(INT sd, CHAR *buf, UINT16 sz, INT16 flags,
SOCKADDR *peer, XSOCKLENT *peersz)
{
int recvd;
memset(peer, 0, sizeof(struct addr_struct));
recvd = NU_Recv_From(sd, buf, sz, flags, (struct addr_struct *) peer,
(INT16*) peersz);
if (recvd < 0) {
Nucleus_Net_Errno = recvd;
recvd = WOLFSSL_FATAL_ERROR;
} else {
Nucleus_Net_Errno = 0;
}
return recvd;
}
STATIC int nucyassl_sendto(INT sd, CHAR *buf, UINT16 sz, INT16 flags,
const SOCKADDR *peer, INT16 peersz)
{
int sent;
sent = NU_Send_To(sd, buf, sz, flags, (const struct addr_struct *) peer,
peersz);
if (sent < 0) {
Nucleus_Net_Errno = sent;
sent = WOLFSSL_FATAL_ERROR;
} else {
Nucleus_Net_Errno = 0;
}
return sent;
}
#endif /* NUCLEUS_PLUS_2_3 */
#ifndef DTLS_SENDTO_FUNCTION #ifndef DTLS_SENDTO_FUNCTION
#define DTLS_SENDTO_FUNCTION sendto #define DTLS_SENDTO_FUNCTION sendto
#endif #endif

View File

@ -441,7 +441,7 @@ static WC_INLINE void AddLength(wc_Sha* sha, word32 len)
#define f3(x,y,z) (((x)&(y))|((z)&((x)|(y)))) #define f3(x,y,z) (((x)&(y))|((z)&((x)|(y))))
#define f4(x,y,z) ((x)^(y)^(z)) #define f4(x,y,z) ((x)^(y)^(z))
#ifdef WOLFSSL_NUCLEUS_1_2 #if defined(WOLFSSL_NUCLEUS_1_2) || defined(NUCLEUS_PLUS_2_3)
/* nucleus.h also defines R1-R4 */ /* nucleus.h also defines R1-R4 */
#undef R1 #undef R1
#undef R2 #undef R2

View File

@ -3089,6 +3089,8 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
#include <sys/socket.h> #include <sys/socket.h>
#elif defined(ARDUINO) #elif defined(ARDUINO)
/* TODO board specific */ /* TODO board specific */
#elif defined(NUCLEUS_PLUS_2_3)
#include "services/sys/uio.h"
#elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && \ #elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && \
!defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM) && \ !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM) && \
!defined(WOLFSSL_EMBOS) && !defined(WOLFSSL_FROSTED) && \ !defined(WOLFSSL_EMBOS) && !defined(WOLFSSL_FROSTED) && \

View File

@ -114,6 +114,13 @@ WOLFSSL_API int wc_RunCast_fips(int type);
WOLFSSL_API int wc_GetCastStatus_fips(int type); WOLFSSL_API int wc_GetCastStatus_fips(int type);
WOLFSSL_API int wc_RunAllCast_fips(void); WOLFSSL_API int wc_RunAllCast_fips(void);
#ifdef NO_ATTRIBUTE_CONSTRUCTOR
/* NOTE: Must be called in OS initialization section outside user control
* and must prove during operational testing/code review with the lab that
* this is outside user-control if called by the OS */
void fipsEntry(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif

View File

@ -212,6 +212,9 @@
/* Uncomment next line if building for Nucleus 1.2 */ /* Uncomment next line if building for Nucleus 1.2 */
/* #define WOLFSSL_NUCLEUS_1_2 */ /* #define WOLFSSL_NUCLEUS_1_2 */
/* Uncomment next line if building for Nucleus Plus 2.3 */
/* #define NUCLEUS_PLUS_2_3 */
/* Uncomment next line if building for using Apache mynewt */ /* Uncomment next line if building for using Apache mynewt */
/* #define WOLFSSL_APACHE_MYNEWT */ /* #define WOLFSSL_APACHE_MYNEWT */
@ -319,6 +322,10 @@
#elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H) #elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H)
/* STM Configuration File (generated by CubeMX) */ /* STM Configuration File (generated by CubeMX) */
#include "wolfSSL.I-CUBE-wolfSSL_conf.h" #include "wolfSSL.I-CUBE-wolfSSL_conf.h"
#elif defined(NUCLEUS_PLUS_2_3)
/* NOTE: cyassl_nucleus_defs.h is akin to user_settings.h */
#include "nucleus.h"
#include "os/networking/ssl/lite/cyassl_nucleus_defs.h"
#endif #endif
#include <wolfssl/wolfcrypt/visibility.h> #include <wolfssl/wolfcrypt/visibility.h>

View File

@ -168,6 +168,9 @@
#include "socket.h" #include "socket.h"
#elif defined(NETOS) #elif defined(NETOS)
#include <sockapi.h> #include <sockapi.h>
#elif defined(NUCLEUS_PLUS_2_3)
#define SO_TYPE 17 /* Socket type */
#define SO_RCVTIMEO 13 /* Recv Timeout */
#elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) \ #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) \
&& !defined(WOLFSSL_CONTIKI) && !defined(WOLFSSL_WICED) \ && !defined(WOLFSSL_CONTIKI) && !defined(WOLFSSL_WICED) \
&& !defined(WOLFSSL_GNRC) && !defined(WOLFSSL_RIOT_OS) && !defined(WOLFSSL_GNRC) && !defined(WOLFSSL_RIOT_OS)
@ -270,6 +273,14 @@
#define SOCKET_EPIPE NU_NOT_CONNECTED #define SOCKET_EPIPE NU_NOT_CONNECTED
#define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED #define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED
#define SOCKET_ECONNABORTED NU_NOT_CONNECTED #define SOCKET_ECONNABORTED NU_NOT_CONNECTED
#elif defined(NUCLEUS_PLUS_2_3)
#define SOCKET_EWOULDBLOCK NU_WOULD_BLOCK
#define SOCKET_EAGAIN NU_NO_DATA
#define SOCKET_ECONNRESET NU_RESET
#define SOCKET_EINTR 0
#define SOCKET_EPIPE 0
#define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED
#define SOCKET_ECONNABORTED NU_CONNECTION_REFUSED
#elif defined(WOLFSSL_DEOS) #elif defined(WOLFSSL_DEOS)
/* `sockaddr_storage` is not defined in DEOS. This workaround will /* `sockaddr_storage` is not defined in DEOS. This workaround will
* work for IPV4, but not IPV6 * work for IPV4, but not IPV6
@ -354,6 +365,11 @@
#elif defined(WOLFSSL_NUCLEUS_1_2) #elif defined(WOLFSSL_NUCLEUS_1_2)
#define SEND_FUNCTION NU_Send #define SEND_FUNCTION NU_Send
#define RECV_FUNCTION NU_Recv #define RECV_FUNCTION NU_Recv
#elif defined(NUCLEUS_PLUS_2_3)
#define SEND_FUNCTION nucyassl_send
#define RECV_FUNCTION nucyassl_recv
#define DTLS_RECVFROM_FUNCTION nucyassl_recvfrom
#define DTLS_SENDTO_FUNCTION nucyassl_sendto
#elif defined(FUSION_RTOS) #elif defined(FUSION_RTOS)
#define SEND_FUNCTION FNS_SEND #define SEND_FUNCTION FNS_SEND
#define RECV_FUNCTION FNS_RECV #define RECV_FUNCTION FNS_RECV
@ -398,6 +414,9 @@
#ifndef XSOCKLENT #ifndef XSOCKLENT
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
#define XSOCKLENT int #define XSOCKLENT int
#elif defined(NUCLEUS_PLUS_2_3)
typedef int socklen_t;
#define XSOCKLENT socklen_t
#else #else
#define XSOCKLENT socklen_t #define XSOCKLENT socklen_t
#endif #endif
@ -485,6 +504,10 @@ WOLFSSL_API int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx); WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
#ifdef WOLFSSL_DTLS #ifdef WOLFSSL_DTLS
#ifdef NUCLEUS_PLUS_2_3
#define SELECT_FUNCTION nucyassl_select
WOLFSSL_LOCAL int nucyassl_select(INT sd, UINT32 timeout);
#endif
WOLFSSL_API int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, WOLFSSL_API int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz,
void *ctx); void *ctx);
WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx); WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx);