mirror of https://github.com/wolfSSL/wolfssl.git
Merge branch 'master' of github.com:cyassl/cyassl
commit
c20eb88d3d
|
@ -64,16 +64,6 @@ enum {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
|
|
||||||
static INLINE word32 min(word32 a, word32 b)
|
|
||||||
{
|
|
||||||
return a > b ? b : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* min */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef THREADX
|
#ifdef THREADX
|
||||||
/* uses parital <time.h> structures */
|
/* uses parital <time.h> structures */
|
||||||
#define XTIME(tl) (0)
|
#define XTIME(tl) (0)
|
||||||
|
@ -1351,7 +1341,6 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||||
int oidSz;
|
int oidSz;
|
||||||
|
|
||||||
if (GetSet(cert->source, &cert->srcIdx, &dummy, cert->maxIdx) < 0) {
|
if (GetSet(cert->source, &cert->srcIdx, &dummy, cert->maxIdx) < 0) {
|
||||||
(void)b; /* empty body warning w/o messages enabled */
|
|
||||||
CYASSL_MSG("Cert name lacks set header, trying sequence");
|
CYASSL_MSG("Cert name lacks set header, trying sequence");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2958,6 +2947,17 @@ int RsaKeyToDer(RsaKey* key, byte* output, word32 inLen)
|
||||||
|
|
||||||
#ifdef CYASSL_CERT_GEN
|
#ifdef CYASSL_CERT_GEN
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef min
|
||||||
|
|
||||||
|
static INLINE word32 min(word32 a, word32 b)
|
||||||
|
{
|
||||||
|
return a > b ? b : a;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* min */
|
||||||
|
|
||||||
|
|
||||||
/* Initialize and Set Certficate defaults:
|
/* Initialize and Set Certficate defaults:
|
||||||
version = 3 (0x2)
|
version = 3 (0x2)
|
||||||
serial = 0
|
serial = 0
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
/* Uncomment next line if building CyaSSL for a game console */
|
/* Uncomment next line if building CyaSSL for a game console */
|
||||||
/* #define CYASSL_GAME_BUILD */
|
/* #define CYASSL_GAME_BUILD */
|
||||||
|
|
||||||
|
/* Uncomment next line if building CyaSSL for LSR */
|
||||||
|
/* #define CYASSL_LSR */
|
||||||
|
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/visibility.h>
|
#include <cyassl/ctaocrypt/visibility.h>
|
||||||
|
|
||||||
|
@ -146,6 +149,29 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CYASSL_LSR
|
||||||
|
#define NO_WRITEV
|
||||||
|
#define NO_SHA512
|
||||||
|
#define NO_DH
|
||||||
|
#define NO_DSA
|
||||||
|
#define NO_HC128
|
||||||
|
#define NO_DEV_RANDOM
|
||||||
|
#define NO_CYASSL_DIR
|
||||||
|
#define NO_RABBIT
|
||||||
|
#ifndef NO_FILESYSTEM
|
||||||
|
#define LSR_FS
|
||||||
|
#include "fs.h"
|
||||||
|
#endif
|
||||||
|
#define CYASSL_LWIP
|
||||||
|
#define CYASSL_SAFERTOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CYASSL_SAFERTOS
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
|
#include "SafeRTOS/semphr.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MICRIUM
|
#ifdef MICRIUM
|
||||||
|
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
#endif
|
#endif
|
||||||
#elif defined(MICRIUM)
|
#elif defined(MICRIUM)
|
||||||
/* do nothing, just don't pick Unix */
|
/* do nothing, just don't pick Unix */
|
||||||
#elif defined(FREERTOS)
|
#elif defined(FREERTOS) || defined(CYASSL_SAFERTOS)
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
#elif defined(EBSNET)
|
#elif defined(EBSNET)
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
|
@ -674,6 +674,11 @@ struct CYASSL_CIPHER {
|
||||||
/* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
|
/* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
|
||||||
#ifdef FREERTOS
|
#ifdef FREERTOS
|
||||||
typedef xSemaphoreHandle CyaSSL_Mutex;
|
typedef xSemaphoreHandle CyaSSL_Mutex;
|
||||||
|
#elif defined(CYASSL_SAFERTOS)
|
||||||
|
typedef struct CyaSSL_Mutex {
|
||||||
|
signed char mutexBuffer[portQUEUE_OVERHEAD_BYTES];
|
||||||
|
xSemaphoreHandle mutex;
|
||||||
|
} CyaSSL_Mutex;
|
||||||
#elif defined(USE_WINDOWS_API)
|
#elif defined(USE_WINDOWS_API)
|
||||||
typedef CRITICAL_SECTION CyaSSL_Mutex;
|
typedef CRITICAL_SECTION CyaSSL_Mutex;
|
||||||
#elif defined(CYASSL_PTHREADS)
|
#elif defined(CYASSL_PTHREADS)
|
||||||
|
|
|
@ -630,10 +630,14 @@ static INLINE int myVerify(int preverify, CYASSL_X509_STORE_CTX* store)
|
||||||
{
|
{
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
|
|
||||||
|
#ifdef OPENSSL_EXTRA
|
||||||
|
CYASSL_X509* peer;
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("In verification callback, error = %d, %s\n", store->error,
|
printf("In verification callback, error = %d, %s\n", store->error,
|
||||||
CyaSSL_ERR_error_string(store->error, buffer));
|
CyaSSL_ERR_error_string(store->error, buffer));
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
CYASSL_X509* peer = store->current_cert;
|
peer = store->current_cert;
|
||||||
if (peer) {
|
if (peer) {
|
||||||
char* issuer = CyaSSL_X509_NAME_oneline(
|
char* issuer = CyaSSL_X509_NAME_oneline(
|
||||||
CyaSSL_X509_get_issuer_name(peer), 0, 0);
|
CyaSSL_X509_get_issuer_name(peer), 0, 0);
|
||||||
|
|
|
@ -392,7 +392,8 @@ void client_test(void* args)
|
||||||
sslResume = CyaSSL_new(ctx);
|
sslResume = CyaSSL_new(ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CyaSSL_shutdown(ssl);
|
if (doDTLS == 0) /* don't send alert after "break" command */
|
||||||
|
CyaSSL_shutdown(ssl); /* echoserver will interpret as new conn */
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
CloseSocket(sockfd);
|
CloseSocket(sockfd);
|
||||||
|
|
||||||
|
@ -404,7 +405,7 @@ void client_test(void* args)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
tcp_connect(&sockfd, host, port);
|
tcp_connect(&sockfd, host, port, doDTLS);
|
||||||
CyaSSL_set_fd(sslResume, sockfd);
|
CyaSSL_set_fd(sslResume, sockfd);
|
||||||
CyaSSL_set_session(sslResume, session);
|
CyaSSL_set_session(sslResume, session);
|
||||||
|
|
||||||
|
|
|
@ -449,6 +449,7 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveDH, byte havePSK,
|
||||||
(void)havePSK;
|
(void)havePSK;
|
||||||
(void)haveNTRU;
|
(void)haveNTRU;
|
||||||
(void)haveStaticECC;
|
(void)haveStaticECC;
|
||||||
|
(void)haveRSAsig;
|
||||||
|
|
||||||
if (suites->setSuites)
|
if (suites->setSuites)
|
||||||
return; /* trust user settings, don't override */
|
return; /* trust user settings, don't override */
|
||||||
|
@ -7076,6 +7077,37 @@ int UnLockMutex(CyaSSL_Mutex* m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(CYASSL_SAFERTOS)
|
||||||
|
|
||||||
|
int InitMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
vSemaphoreCreateBinary(m->mutexBuffer, m->mutex);
|
||||||
|
if (m->mutex == NULL)
|
||||||
|
return BAD_MUTEX_ERROR;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FreeMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
(void)m;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LockMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
/* Assume an infinite block */
|
||||||
|
xSemaphoreTake(m->mutex, portMAX_DELAY);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UnLockMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
xSemaphoreGive(m->mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#elif defined(USE_WINDOWS_API)
|
#elif defined(USE_WINDOWS_API)
|
||||||
|
|
||||||
int InitMutex(CyaSSL_Mutex* m)
|
int InitMutex(CyaSSL_Mutex* m)
|
||||||
|
@ -7257,7 +7289,7 @@ int UnLockMutex(CyaSSL_Mutex* m)
|
||||||
return BAD_MUTEX_ERROR;
|
return BAD_MUTEX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UnlockMutex(CyaSSL_Mutex* m)
|
int UnLockMutex(CyaSSL_Mutex* m)
|
||||||
{
|
{
|
||||||
rtp_sig_mutex_release(*m);
|
rtp_sig_mutex_release(*m);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
15
src/io.c
15
src/io.c
|
@ -43,9 +43,11 @@
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef USE_WINDOWS_API
|
||||||
#ifdef CYASSL_LWIP
|
#ifdef CYASSL_LWIP
|
||||||
/* lwIP needs to be configured to use sockets API in this mode */
|
/* lwIP needs to be configured to use sockets API in this mode */
|
||||||
/* LWIP_SOCKET 1 && LWIP_COMPAT_SOCKETS 1 in lwip/opt.h or in build */
|
/* LWIP_SOCKET 1 in lwip/opt.h or in build */
|
||||||
#define LWIP_PROVIDE_ERRNO 1
|
#include "lwip/sockets.h"
|
||||||
#include "sockets.h"
|
#ifndef LWIP_PROVIDE_ERRNO
|
||||||
|
#define LWIP_PROVIDE_ERRNO 1
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -53,7 +55,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if !(defined(DEVKITPRO) || defined(THREADX)) || defined(EBSNET)
|
#if !(defined(DEVKITPRO) || defined(THREADX) || defined(EBSNET))
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -109,6 +111,9 @@
|
||||||
int net_recv(int, void*, int, unsigned int);
|
int net_recv(int, void*, int, unsigned int);
|
||||||
#define SEND_FUNCTION net_send
|
#define SEND_FUNCTION net_send
|
||||||
#define RECV_FUNCTION net_recv
|
#define RECV_FUNCTION net_recv
|
||||||
|
#elif defined(CYASSL_LWIP)
|
||||||
|
#define SEND_FUNCTION lwip_send
|
||||||
|
#define RECV_FUNCTION lwip_recv
|
||||||
#else
|
#else
|
||||||
#define SEND_FUNCTION send
|
#define SEND_FUNCTION send
|
||||||
#define RECV_FUNCTION recv
|
#define RECV_FUNCTION recv
|
||||||
|
@ -120,7 +125,7 @@ static INLINE int LastError(void)
|
||||||
#ifdef USE_WINDOWS_API
|
#ifdef USE_WINDOWS_API
|
||||||
return WSAGetLastError();
|
return WSAGetLastError();
|
||||||
#elif defined(EBSNET)
|
#elif defined(EBSNET)
|
||||||
return un_getlasterror();
|
return xn_getlasterror();
|
||||||
#else
|
#else
|
||||||
return errno;
|
return errno;
|
||||||
#endif
|
#endif
|
||||||
|
|
37
src/ssl.c
37
src/ssl.c
|
@ -1139,13 +1139,12 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
|
||||||
#endif /* HAVE_ECC */
|
#endif /* HAVE_ECC */
|
||||||
}
|
}
|
||||||
else if (type == CERT_TYPE) {
|
else if (type == CERT_TYPE) {
|
||||||
int ret;
|
|
||||||
DecodedCert cert;
|
DecodedCert cert;
|
||||||
|
|
||||||
CYASSL_MSG("Checking cert signature type");
|
CYASSL_MSG("Checking cert signature type");
|
||||||
InitDecodedCert(&cert, der.buffer, der.length, ctx->heap);
|
InitDecodedCert(&cert, der.buffer, der.length, ctx->heap);
|
||||||
|
|
||||||
if ((ret = DecodeToKey(&cert, 0)) < 0) {
|
if (DecodeToKey(&cert, 0) < 0) {
|
||||||
CYASSL_MSG("Decode to key failed");
|
CYASSL_MSG("Decode to key failed");
|
||||||
return SSL_BAD_FILE;
|
return SSL_BAD_FILE;
|
||||||
}
|
}
|
||||||
|
@ -1215,17 +1214,18 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||||
#define XFCLOSE vf_close
|
#define XFCLOSE vf_close
|
||||||
#define XSEEK_END VSEEK_END
|
#define XSEEK_END VSEEK_END
|
||||||
#define XBADFILE -1
|
#define XBADFILE -1
|
||||||
#elif !defined(MICRIUM)
|
#elif defined(LSR_FS)
|
||||||
#define XFILE FILE*
|
#include <fs.h>
|
||||||
#define XFOPEN fopen
|
#define XFILE struct fs_file*
|
||||||
#define XFSEEK fseek
|
#define XFOPEN(NAME, MODE) fs_open(NAME);
|
||||||
#define XFTELL ftell
|
#define XFSEEK
|
||||||
#define XREWIND rewind
|
#define XFTELL(F) (F)->len
|
||||||
#define XFREAD fread
|
#define XREWIND
|
||||||
#define XFCLOSE fclose
|
#define XFREAD(BUF, SZ, AMT, F) fs_read(F, BUF, SZ*AMT)
|
||||||
#define XSEEK_END SEEK_END
|
#define XFCLOSE fs_close
|
||||||
#define XBADFILE NULL
|
#define XSEEK_END 0
|
||||||
#else
|
#define XBADFILE NULL
|
||||||
|
#elif defined(MICRIUM)
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
#define XFILE FS_FILE*
|
#define XFILE FS_FILE*
|
||||||
#define XFOPEN fs_fopen
|
#define XFOPEN fs_fopen
|
||||||
|
@ -1236,6 +1236,17 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||||
#define XFCLOSE fs_fclose
|
#define XFCLOSE fs_fclose
|
||||||
#define XSEEK_END FS_SEEK_END
|
#define XSEEK_END FS_SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
|
#else
|
||||||
|
/* stdio, default case */
|
||||||
|
#define XFILE FILE*
|
||||||
|
#define XFOPEN fopen
|
||||||
|
#define XFSEEK fseek
|
||||||
|
#define XFTELL ftell
|
||||||
|
#define XREWIND rewind
|
||||||
|
#define XFREAD fread
|
||||||
|
#define XFCLOSE fclose
|
||||||
|
#define XSEEK_END SEEK_END
|
||||||
|
#define XBADFILE NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue