Merge branch 'master' of github.com:cyassl/cyassl

This commit is contained in:
John Safranek
2012-08-22 16:16:49 -07:00
6 changed files with 70 additions and 13 deletions

View File

@@ -5,7 +5,7 @@
# make sure current config is ok # make sure current config is ok
echo -e "\n\nTesting current config...\n\n" echo -e "\n\nTesting current config...\n\n"
make test; make -j 8 test;
RESULT=$? RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nCurrent config make test failed" && exit 1 [ $RESULT -ne 0 ] && echo -e "\n\nCurrent config make test failed" && exit 1

View File

@@ -146,6 +146,19 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
return 0; return 0;
} }
#elif defined(CYASSL_SAFERTOS)
#warning "write a real random seed!!!!, just for testing now"
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
for (i = 0; i < sz; i++ )
output[i] = i;
return 0;
}
#elif defined(NO_DEV_RANDOM) #elif defined(NO_DEV_RANDOM)
#error "you need to write an os specific GenerateSeed() here" #error "you need to write an os specific GenerateSeed() here"

View File

@@ -150,6 +150,8 @@
#endif #endif
#ifdef CYASSL_LSR #ifdef CYASSL_LSR
#define SIZEOF_LONG_LONG 8
#define CYASSL_LOW_MEMORY
#define NO_WRITEV #define NO_WRITEV
#define NO_SHA512 #define NO_SHA512
#define NO_DH #define NO_DH
@@ -160,16 +162,32 @@
#define NO_RABBIT #define NO_RABBIT
#ifndef NO_FILESYSTEM #ifndef NO_FILESYSTEM
#define LSR_FS #define LSR_FS
#include "inc/hw_types.h"
#include "fs.h" #include "fs.h"
#endif #endif
#define CYASSL_LWIP #define CYASSL_LWIP
#define CYASSL_SAFERTOS #define CYASSL_SAFERTOS
#if defined(__IAR_SYSTEMS_ICC__)
/* enum uses enum */
#pragma diag_suppress=Pa089
#endif
#endif #endif
#ifdef CYASSL_SAFERTOS #ifdef CYASSL_SAFERTOS
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
#include "SafeRTOS/semphr.h" #include "SafeRTOS/semphr.h"
#endif #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))
#endif
#ifdef CYASSL_LOW_MEMORY
#define RSA_LOW_MEM
#define CYASSL_SMALL_STACK
#define TFM_TIMING_RESISTANT
#endif #endif
#ifdef MICRIUM #ifdef MICRIUM

View File

@@ -108,6 +108,8 @@ enum {
#define INLINE inline #define INLINE inline
#elif defined(THREADX) #elif defined(THREADX)
#define INLINE _Inline #define INLINE _Inline
#elif defined(__IAR_SYSTEMS_ICC__)
#define INLINE inline
#else #else
#define INLINE #define INLINE
#endif #endif
@@ -148,7 +150,7 @@ enum {
extern void *XMALLOC(size_t n, void* heap, int type); extern void *XMALLOC(size_t n, void* heap, int type);
extern void *XREALLOC(void *p, 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); extern void XFREE(void *p, void* heap, int type);
#elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) && !defined(CYASSL_SAFERTOS)
/* default C runtime, can install different routines at runtime */ /* default C runtime, can install different routines at runtime */
#include <cyassl/ctaocrypt/memory.h> #include <cyassl/ctaocrypt/memory.h>
#define XMALLOC(s, h, t) CyaSSL_Malloc((s)) #define XMALLOC(s, h, t) CyaSSL_Malloc((s))

View File

@@ -410,7 +410,19 @@ void client_test(void* args)
CyaSSL_set_session(sslResume, session); CyaSSL_set_session(sslResume, session);
showPeer(sslResume); showPeer(sslResume);
if (CyaSSL_connect(sslResume) != SSL_SUCCESS) err_sys("SSL resume failed"); #ifdef NON_BLOCKING
tcp_set_nonblocking(&sockfd);
NonBlockingSSL_Connect(sslResume);
#else
#ifndef CYASSL_CALLBACKS
if (CyaSSL_connect(sslResume) != SSL_SUCCESS)
err_sys("SSL resume failed");
#else
timeout.tv_sec = 2;
timeout.tv_usec = 0;
NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */
#endif
#endif
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
if (CyaSSL_session_reused(sslResume)) if (CyaSSL_session_reused(sslResume))
@@ -422,6 +434,15 @@ void client_test(void* args)
if (CyaSSL_write(sslResume, resumeMsg, resumeSz) != resumeSz) if (CyaSSL_write(sslResume, resumeMsg, resumeSz) != resumeSz)
err_sys("SSL_write failed"); err_sys("SSL_write failed");
#ifdef NON_BLOCKING
/* need to give server a chance to bounce a message back to client */
#ifdef USE_WINDOWS_API
Sleep(500);
#else
sleep(1);
#endif
#endif
input = CyaSSL_read(sslResume, reply, sizeof(reply)); input = CyaSSL_read(sslResume, reply, sizeof(reply));
if (input > 0) { if (input > 0) {
reply[input] = 0; reply[input] = 0;

View File

@@ -1217,11 +1217,11 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
#elif defined(LSR_FS) #elif defined(LSR_FS)
#include <fs.h> #include <fs.h>
#define XFILE struct fs_file* #define XFILE struct fs_file*
#define XFOPEN(NAME, MODE) fs_open(NAME); #define XFOPEN(NAME, MODE) fs_open((char*)NAME);
#define XFSEEK #define XFSEEK(F, O, W) (void)F
#define XFTELL(F) (F)->len #define XFTELL(F) (F)->len
#define XREWIND #define XREWIND(F) (void)F
#define XFREAD(BUF, SZ, AMT, F) fs_read(F, BUF, SZ*AMT) #define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT)
#define XFCLOSE fs_close #define XFCLOSE fs_close
#define XSEEK_END 0 #define XSEEK_END 0
#define XBADFILE NULL #define XBADFILE NULL
@@ -2254,7 +2254,10 @@ int CyaSSL_set_cipher_list(CYASSL* ssl, const char* list)
neededState = ssl->options.resuming ? SERVER_FINISHED_COMPLETE : neededState = ssl->options.resuming ? SERVER_FINISHED_COMPLETE :
SERVER_HELLODONE_COMPLETE; SERVER_HELLODONE_COMPLETE;
#ifdef CYASSL_DTLS #ifdef CYASSL_DTLS
if (ssl->options.dtls && !ssl->options.resuming) /* In DTLS, when resuming, we can go straight to FINISHED,
* or do a cookie exchange and then skip to FINISHED, assume
* we need the cookie exchange first. */
if (ssl->options.dtls)
neededState = SERVER_HELLOVERIFYREQUEST_COMPLETE; neededState = SERVER_HELLOVERIFYREQUEST_COMPLETE;
#endif #endif
/* get response */ /* get response */
@@ -2281,7 +2284,7 @@ int CyaSSL_set_cipher_list(CYASSL* ssl, const char* list)
return SSL_SUCCESS; return SSL_SUCCESS;
#ifdef CYASSL_DTLS #ifdef CYASSL_DTLS
if (ssl->options.dtls && !ssl->options.resuming) { if (ssl->options.dtls) {
/* re-init hashes, exclude first hello and verify request */ /* re-init hashes, exclude first hello and verify request */
InitMd5(&ssl->hashMd5); InitMd5(&ssl->hashMd5);
InitSha(&ssl->hashSha); InitSha(&ssl->hashSha);
@@ -2501,7 +2504,7 @@ int CyaSSL_set_cipher_list(CYASSL* ssl, const char* list)
case ACCEPT_CLIENT_HELLO_DONE : case ACCEPT_CLIENT_HELLO_DONE :
#ifdef CYASSL_DTLS #ifdef CYASSL_DTLS
if (ssl->options.dtls && !ssl->options.resuming) if (ssl->options.dtls)
if ( (ssl->error = SendHelloVerifyRequest(ssl)) != 0) { if ( (ssl->error = SendHelloVerifyRequest(ssl)) != 0) {
CYASSL_ERROR(ssl->error); CYASSL_ERROR(ssl->error);
return SSL_FATAL_ERROR; return SSL_FATAL_ERROR;
@@ -2512,7 +2515,7 @@ int CyaSSL_set_cipher_list(CYASSL* ssl, const char* list)
case HELLO_VERIFY_SENT: case HELLO_VERIFY_SENT:
#ifdef CYASSL_DTLS #ifdef CYASSL_DTLS
if (ssl->options.dtls && !ssl->options.resuming) { if (ssl->options.dtls) {
ssl->options.clientState = NULL_STATE; /* get again */ ssl->options.clientState = NULL_STATE; /* get again */
/* re-init hashes, exclude first hello and verify request */ /* re-init hashes, exclude first hello and verify request */
InitMd5(&ssl->hashMd5); InitMd5(&ssl->hashMd5);