forked from wolfSSL/wolfssl
Merge branch 'master' of github.com:cyassl/cyassl
This commit is contained in:
@ -41,7 +41,9 @@
|
||||
#else
|
||||
#ifndef NO_DEV_RANDOM
|
||||
#include <fcntl.h>
|
||||
#ifndef EBSNET
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#else
|
||||
/* include headers that may be needed to get good seed */
|
||||
#endif
|
||||
@ -101,7 +103,7 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
}
|
||||
|
||||
|
||||
#elif defined(THREADX)
|
||||
#elif defined(THREADX) || defined(EBSNET)
|
||||
|
||||
#include "rtprand.h" /* rtp_rand () */
|
||||
#include "rtptime.h" /* rtp_get_system_msec() */
|
||||
|
@ -51,6 +51,9 @@
|
||||
/* 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 CYASSL_LWIP */
|
||||
|
||||
@ -106,6 +109,39 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef EBSNET
|
||||
#include "rtip.h"
|
||||
|
||||
/* #define DEBUG_CYASSL */
|
||||
#define NO_CYASSL_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))
|
||||
|
||||
#endif /* EBSNET */
|
||||
|
||||
#ifdef CYASSL_GAME_BUILD
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#if defined(__PPU) || defined(__XENON)
|
||||
|
@ -132,7 +132,8 @@ enum {
|
||||
|
||||
|
||||
/* Micrium will use Visual Studio for compilation but not the Win32 API */
|
||||
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS)
|
||||
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
|
||||
&& !defined(EBSNET)
|
||||
#define USE_WINDOWS_API
|
||||
#endif
|
||||
|
||||
@ -147,7 +148,7 @@ enum {
|
||||
extern void *XMALLOC(size_t n, void* heap, int type);
|
||||
extern void *XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
extern void XFREE(void *p, void* heap, int type);
|
||||
#elif !defined(MICRIUM_MALLOC)
|
||||
#elif !defined(MICRIUM_MALLOC) && !defined(EBSNET)
|
||||
/* default C runtime, can install different routines at runtime */
|
||||
#include <cyassl/ctaocrypt/memory.h>
|
||||
#define XMALLOC(s, h, t) CyaSSL_Malloc((s))
|
||||
|
@ -71,6 +71,8 @@
|
||||
/* do nothing, just don't pick Unix */
|
||||
#elif defined(FREERTOS) || defined(CYASSL_SAFERTOS)
|
||||
/* do nothing */
|
||||
#elif defined(EBSNET)
|
||||
/* do nothing */
|
||||
#else
|
||||
#ifndef SINGLE_THREADED
|
||||
#define CYASSL_PTHREADS
|
||||
@ -683,6 +685,8 @@ struct CYASSL_CIPHER {
|
||||
typedef TX_MUTEX CyaSSL_Mutex;
|
||||
#elif defined(MICRIUM)
|
||||
typedef OS_MUTEX CyaSSL_Mutex;
|
||||
#elif defined(EBSNET)
|
||||
typedef RTP_MUTEX CyaSSL_Mutex;
|
||||
#else
|
||||
#error Need a mutex type in multithreaded mode
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
@ -7130,5 +7130,35 @@ int UnLockMutex(CyaSSL_Mutex* m)
|
||||
|
||||
}
|
||||
|
||||
#elif defined(EBSNET)
|
||||
|
||||
int InitMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
if (rtp_sig_mutex_alloc(m, "CyaSSL Mutex") == -1)
|
||||
return BAD_MUTEX_ERROR;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FreeMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
rtp_sig_mutex_free(*m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LockMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
if (rtp_sig_mutex_claim_timed(*m, RTIP_INF) == 0)
|
||||
return 0;
|
||||
else
|
||||
return BAD_MUTEX_ERROR;
|
||||
}
|
||||
|
||||
int UnLockMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
rtp_sig_mutex_release(*m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* USE_WINDOWS_API */
|
||||
#endif /* SINGLE_THREADED */
|
||||
|
41
src/io.c
41
src/io.c
@ -51,9 +51,11 @@
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#ifndef EBSNET
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#if !(defined(DEVKITPRO) || defined(THREADX))
|
||||
#if !(defined(DEVKITPRO) || defined(THREADX) || defined(EBSNET))
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
@ -67,6 +69,10 @@
|
||||
#ifdef THREADX
|
||||
#include <socket.h>
|
||||
#endif
|
||||
#ifdef EBSNET
|
||||
#include "rtipapi.h" /* errno */
|
||||
#include "socket.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
@ -118,6 +124,8 @@ static INLINE int LastError(void)
|
||||
{
|
||||
#ifdef USE_WINDOWS_API
|
||||
return WSAGetLastError();
|
||||
#elif defined(EBSNET)
|
||||
return xn_getlasterror();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
@ -209,6 +217,13 @@ int EmbedSend(char *buf, int sz, void *ctx)
|
||||
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define XSOCKLENT int
|
||||
#else
|
||||
#define XSOCKLENT socklen_t
|
||||
#endif
|
||||
|
||||
|
||||
/* The DTLS Generate Cookie callback
|
||||
* return : number of bytes copied into buf, or error
|
||||
*/
|
||||
@ -216,15 +231,15 @@ int EmbedGenerateCookie(byte *buf, int sz, void *ctx)
|
||||
{
|
||||
CYASSL* ssl = (CYASSL*)ctx;
|
||||
int sd = ssl->wfd;
|
||||
struct sockaddr_storage peer;
|
||||
socklen_t peerSz = sizeof(peer);
|
||||
byte cookieSrc[sizeof(struct in6_addr) + sizeof(int)];
|
||||
struct sockaddr_in peer;
|
||||
XSOCKLENT peerSz = sizeof(peer);
|
||||
byte cookieSrc[sizeof(struct in_addr) + sizeof(int)];
|
||||
int cookieSrcSz = 0;
|
||||
Sha sha;
|
||||
|
||||
getpeername(sd, (struct sockaddr*)&peer, &peerSz);
|
||||
|
||||
if (peer.ss_family == AF_INET) {
|
||||
if (peer.sin_family == AF_INET) {
|
||||
struct sockaddr_in *s = (struct sockaddr_in*)&peer;
|
||||
|
||||
cookieSrcSz = sizeof(struct in_addr) + sizeof(s->sin_port);
|
||||
@ -232,17 +247,17 @@ int EmbedGenerateCookie(byte *buf, int sz, void *ctx)
|
||||
XMEMCPY(cookieSrc + sizeof(s->sin_port),
|
||||
&s->sin_addr, sizeof(struct in_addr));
|
||||
}
|
||||
else if (peer.ss_family == AF_INET6) {
|
||||
struct sockaddr_in6 *s = (struct sockaddr_in6*)&peer;
|
||||
|
||||
cookieSrcSz = sizeof(struct in6_addr) + sizeof(s->sin6_port);
|
||||
XMEMCPY(cookieSrc, &s->sin6_port, sizeof(s->sin6_port));
|
||||
XMEMCPY(cookieSrc + sizeof(s->sin6_port),
|
||||
&s->sin6_addr, sizeof(struct in6_addr));
|
||||
}
|
||||
|
||||
InitSha(&sha);
|
||||
ShaUpdate(&sha, cookieSrc, cookieSrcSz);
|
||||
|
||||
if (sz < SHA_DIGEST_SIZE) {
|
||||
byte digest[SHA_DIGEST_SIZE];
|
||||
ShaFinal(&sha, digest);
|
||||
XMEMCPY(buf, digest, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
ShaFinal(&sha, buf);
|
||||
|
||||
return SHA_DIGEST_SIZE;
|
||||
|
@ -25,12 +25,19 @@
|
||||
|
||||
#ifdef HAVE_OCSP
|
||||
|
||||
#ifdef EBSNET
|
||||
#include "rtip.h"
|
||||
#include "socket.h"
|
||||
#endif
|
||||
|
||||
#include <cyassl/error.h>
|
||||
#include <cyassl/ocsp.h>
|
||||
#include <cyassl/internal.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifndef EBSNET
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
@ -40,6 +47,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_API int ocsp_test(unsigned char* buf, int sz);
|
||||
|
19
src/ssl.c
19
src/ssl.c
@ -61,9 +61,14 @@
|
||||
#endif
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
#if !defined(USE_WINDOWS_API) && !defined(NO_CYASSL_DIR)
|
||||
#if !defined(USE_WINDOWS_API) && !defined(NO_CYASSL_DIR) \
|
||||
&& !defined(EBSNET)
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#ifdef EBSNET
|
||||
#include "vfapi.h"
|
||||
#include "vfile.h"
|
||||
#endif
|
||||
#endif /* NO_FILESYSTEM */
|
||||
|
||||
|
||||
@ -1199,7 +1204,17 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
|
||||
#ifndef MICRIUM
|
||||
#if defined(EBSNET)
|
||||
#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 XFCLOSE vf_close
|
||||
#define XSEEK_END VSEEK_END
|
||||
#define XBADFILE -1
|
||||
#elif !defined(MICRIUM)
|
||||
#define XFILE FILE*
|
||||
#define XFOPEN fopen
|
||||
#define XFSEEK fseek
|
||||
|
Reference in New Issue
Block a user