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

This commit is contained in:
John Safranek
2012-08-13 16:04:41 -07:00
3 changed files with 35 additions and 26 deletions

View File

@ -6,7 +6,7 @@
# #
# #
AC_INIT([cyassl],[2.3.0],[http://www.yassl.com]) AC_INIT([cyassl],[2.3.1],[http://www.yassl.com])
AC_CONFIG_AUX_DIR(config) AC_CONFIG_AUX_DIR(config)
@ -25,7 +25,7 @@ AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
#shared library versioning #shared library versioning
CYASSL_LIBRARY_VERSION=3:1:0 CYASSL_LIBRARY_VERSION=3:2:0
# | | | # | | |
# +------+ | +---+ # +------+ | +---+
# | | | # | | |

View File

@ -204,6 +204,13 @@ int EmbedSend(char *buf, int sz, void *ctx)
#include <cyassl/ctaocrypt/sha.h> #include <cyassl/ctaocrypt/sha.h>
#ifdef USE_WINDOWS_API
#define XSOCKLENT int
#else
#define XSOCKLENT socklen_t
#endif
/* The DTLS Generate Cookie callback /* The DTLS Generate Cookie callback
* return : number of bytes copied into buf, or error * return : number of bytes copied into buf, or error
*/ */
@ -211,15 +218,15 @@ int EmbedGenerateCookie(byte *buf, int sz, void *ctx)
{ {
CYASSL* ssl = (CYASSL*)ctx; CYASSL* ssl = (CYASSL*)ctx;
int sd = ssl->wfd; int sd = ssl->wfd;
struct sockaddr_storage peer; struct sockaddr_in peer;
socklen_t peerSz = sizeof(peer); XSOCKLENT peerSz = sizeof(peer);
byte cookieSrc[sizeof(struct in6_addr) + sizeof(int)]; byte cookieSrc[sizeof(struct in_addr) + sizeof(int)];
int cookieSrcSz = 0; int cookieSrcSz = 0;
Sha sha; Sha sha;
getpeername(sd, (struct sockaddr*)&peer, &peerSz); 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; struct sockaddr_in *s = (struct sockaddr_in*)&peer;
cookieSrcSz = sizeof(struct in_addr) + sizeof(s->sin_port); cookieSrcSz = sizeof(struct in_addr) + sizeof(s->sin_port);
@ -227,17 +234,17 @@ int EmbedGenerateCookie(byte *buf, int sz, void *ctx)
XMEMCPY(cookieSrc + sizeof(s->sin_port), XMEMCPY(cookieSrc + sizeof(s->sin_port),
&s->sin_addr, sizeof(struct in_addr)); &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); InitSha(&sha);
ShaUpdate(&sha, cookieSrc, cookieSrcSz); 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); ShaFinal(&sha, buf);
return SHA_DIGEST_SIZE; return SHA_DIGEST_SIZE;

View File

@ -1201,7 +1201,7 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
#ifndef NO_FILESYSTEM #ifndef NO_FILESYSTEM
#ifndef MICRIUM #ifndef MICRIUM
#define XFILE FILE #define XFILE FILE*
#define XFOPEN fopen #define XFOPEN fopen
#define XFSEEK fseek #define XFSEEK fseek
#define XFTELL ftell #define XFTELL ftell
@ -1209,9 +1209,10 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
#define XFREAD fread #define XFREAD fread
#define XFCLOSE fclose #define XFCLOSE fclose
#define XSEEK_END SEEK_END #define XSEEK_END SEEK_END
#define XBADFILE NULL
#else #else
#include <fs.h> #include <fs.h>
#define XFILE FS_FILE #define XFILE FS_FILE*
#define XFOPEN fs_fopen #define XFOPEN fs_fopen
#define XFSEEK fs_fseek #define XFSEEK fs_fseek
#define XFTELL fs_ftell #define XFTELL fs_ftell
@ -1219,6 +1220,7 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
#define XFREAD fs_fread #define XFREAD fs_fread
#define XFCLOSE fs_fclose #define XFCLOSE fs_fclose
#define XSEEK_END FS_SEEK_END #define XSEEK_END FS_SEEK_END
#define XBADFILE NULL
#endif #endif
@ -1232,11 +1234,11 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
int dynamic = 0; int dynamic = 0;
int ret; int ret;
long sz = 0; long sz = 0;
XFILE* file = XFOPEN(fname, "rb"); XFILE file = XFOPEN(fname, "rb");
(void)crl; (void)crl;
if (!file) return SSL_BAD_FILE; if (file == XBADFILE) return SSL_BAD_FILE;
XFSEEK(file, 0, XSEEK_END); XFSEEK(file, 0, XSEEK_END);
sz = XFTELL(file); sz = XFTELL(file);
XREWIND(file); XREWIND(file);
@ -1394,11 +1396,11 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname,
byte* myBuffer = staticBuffer; byte* myBuffer = staticBuffer;
int dynamic = 0; int dynamic = 0;
long sz = 0; long sz = 0;
XFILE* file = XFOPEN(fname, "rb"); XFILE file = XFOPEN(fname, "rb");
CYASSL_ENTER("CyaSSL_CertManagerVerify"); CYASSL_ENTER("CyaSSL_CertManagerVerify");
if (!file) return SSL_BAD_FILE; if (file == XBADFILE) return SSL_BAD_FILE;
XFSEEK(file, 0, XSEEK_END); XFSEEK(file, 0, XSEEK_END);
sz = XFTELL(file); sz = XFTELL(file);
XREWIND(file); XREWIND(file);
@ -1702,14 +1704,14 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz)
int ret; int ret;
int ecc = 0; int ecc = 0;
long sz = 0; long sz = 0;
XFILE* file = XFOPEN(fileName, "rb"); XFILE file = XFOPEN(fileName, "rb");
EncryptedInfo info; EncryptedInfo info;
buffer converted; buffer converted;
CYASSL_ENTER("CyaSSL_PemCertToDer"); CYASSL_ENTER("CyaSSL_PemCertToDer");
converted.buffer = 0; converted.buffer = 0;
if (!file) return SSL_BAD_FILE; if (file == XBADFILE) return SSL_BAD_FILE;
XFSEEK(file, 0, XSEEK_END); XFSEEK(file, 0, XSEEK_END);
sz = XFTELL(file); sz = XFTELL(file);
XREWIND(file); XREWIND(file);
@ -1917,9 +1919,9 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl,
int dynamic = 0; int dynamic = 0;
int ret; int ret;
long sz = 0; long sz = 0;
XFILE* file = XFOPEN(fname, "rb"); XFILE file = XFOPEN(fname, "rb");
if (!file) return SSL_BAD_FILE; if (file == XBADFILE) return SSL_BAD_FILE;
XFSEEK(file, 0, XSEEK_END); XFSEEK(file, 0, XSEEK_END);
sz = XFTELL(file); sz = XFTELL(file);
XREWIND(file); XREWIND(file);
@ -5935,7 +5937,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
CYASSL_ENTER("CyaSSL_cmp_peer_cert_to_file"); CYASSL_ENTER("CyaSSL_cmp_peer_cert_to_file");
if (ssl != NULL && fname != NULL) if (ssl != NULL && fname != NULL)
{ {
XFILE* file = NULL; XFILE file = XBADFILE;
int sz = 0; int sz = 0;
byte staticBuffer[FILE_BUFFER_SIZE]; byte staticBuffer[FILE_BUFFER_SIZE];
byte* myBuffer = staticBuffer; byte* myBuffer = staticBuffer;
@ -5951,7 +5953,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
fileDer.buffer = 0; fileDer.buffer = 0;
file = XFOPEN(fname, "rb"); file = XFOPEN(fname, "rb");
if (!file) return SSL_BAD_FILE; if (file == XBADFILE) return SSL_BAD_FILE;
XFSEEK(file, 0, XSEEK_END); XFSEEK(file, 0, XSEEK_END);
sz = XFTELL(file); sz = XFTELL(file);
XREWIND(file); XREWIND(file);