Merge branch 'master' of github.com:cyassl/cyassl
This commit is contained in:
commit
c08debf236
@ -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)
|
||||
|
||||
@ -25,7 +25,7 @@ AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
|
||||
|
||||
|
||||
#shared library versioning
|
||||
CYASSL_LIBRARY_VERSION=3:1:0
|
||||
CYASSL_LIBRARY_VERSION=3:2:0
|
||||
# | | |
|
||||
# +------+ | +---+
|
||||
# | | |
|
||||
|
31
src/io.c
31
src/io.c
@ -204,6 +204,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
|
||||
*/
|
||||
@ -211,15 +218,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);
|
||||
@ -227,17 +234,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;
|
||||
|
26
src/ssl.c
26
src/ssl.c
@ -1201,7 +1201,7 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||
#ifndef NO_FILESYSTEM
|
||||
|
||||
#ifndef MICRIUM
|
||||
#define XFILE FILE
|
||||
#define XFILE FILE*
|
||||
#define XFOPEN fopen
|
||||
#define XFSEEK fseek
|
||||
#define XFTELL ftell
|
||||
@ -1209,9 +1209,10 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||
#define XFREAD fread
|
||||
#define XFCLOSE fclose
|
||||
#define XSEEK_END SEEK_END
|
||||
#define XBADFILE NULL
|
||||
#else
|
||||
#include <fs.h>
|
||||
#define XFILE FS_FILE
|
||||
#define XFILE FS_FILE*
|
||||
#define XFOPEN fs_fopen
|
||||
#define XFSEEK fs_fseek
|
||||
#define XFTELL fs_ftell
|
||||
@ -1219,6 +1220,7 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||
#define XFREAD fs_fread
|
||||
#define XFCLOSE fs_fclose
|
||||
#define XSEEK_END FS_SEEK_END
|
||||
#define XBADFILE NULL
|
||||
#endif
|
||||
|
||||
|
||||
@ -1232,11 +1234,11 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
||||
int dynamic = 0;
|
||||
int ret;
|
||||
long sz = 0;
|
||||
XFILE* file = XFOPEN(fname, "rb");
|
||||
XFILE file = XFOPEN(fname, "rb");
|
||||
|
||||
(void)crl;
|
||||
|
||||
if (!file) return SSL_BAD_FILE;
|
||||
if (file == XBADFILE) return SSL_BAD_FILE;
|
||||
XFSEEK(file, 0, XSEEK_END);
|
||||
sz = XFTELL(file);
|
||||
XREWIND(file);
|
||||
@ -1394,11 +1396,11 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname,
|
||||
byte* myBuffer = staticBuffer;
|
||||
int dynamic = 0;
|
||||
long sz = 0;
|
||||
XFILE* file = XFOPEN(fname, "rb");
|
||||
XFILE file = XFOPEN(fname, "rb");
|
||||
|
||||
CYASSL_ENTER("CyaSSL_CertManagerVerify");
|
||||
|
||||
if (!file) return SSL_BAD_FILE;
|
||||
if (file == XBADFILE) return SSL_BAD_FILE;
|
||||
XFSEEK(file, 0, XSEEK_END);
|
||||
sz = XFTELL(file);
|
||||
XREWIND(file);
|
||||
@ -1702,14 +1704,14 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz)
|
||||
int ret;
|
||||
int ecc = 0;
|
||||
long sz = 0;
|
||||
XFILE* file = XFOPEN(fileName, "rb");
|
||||
XFILE file = XFOPEN(fileName, "rb");
|
||||
EncryptedInfo info;
|
||||
buffer converted;
|
||||
|
||||
CYASSL_ENTER("CyaSSL_PemCertToDer");
|
||||
converted.buffer = 0;
|
||||
|
||||
if (!file) return SSL_BAD_FILE;
|
||||
if (file == XBADFILE) return SSL_BAD_FILE;
|
||||
XFSEEK(file, 0, XSEEK_END);
|
||||
sz = XFTELL(file);
|
||||
XREWIND(file);
|
||||
@ -1917,9 +1919,9 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl,
|
||||
int dynamic = 0;
|
||||
int ret;
|
||||
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);
|
||||
sz = XFTELL(file);
|
||||
XREWIND(file);
|
||||
@ -5935,7 +5937,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
||||
CYASSL_ENTER("CyaSSL_cmp_peer_cert_to_file");
|
||||
if (ssl != NULL && fname != NULL)
|
||||
{
|
||||
XFILE* file = NULL;
|
||||
XFILE file = XBADFILE;
|
||||
int sz = 0;
|
||||
byte staticBuffer[FILE_BUFFER_SIZE];
|
||||
byte* myBuffer = staticBuffer;
|
||||
@ -5951,7 +5953,7 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
||||
fileDer.buffer = 0;
|
||||
|
||||
file = XFOPEN(fname, "rb");
|
||||
if (!file) return SSL_BAD_FILE;
|
||||
if (file == XBADFILE) return SSL_BAD_FILE;
|
||||
XFSEEK(file, 0, XSEEK_END);
|
||||
sz = XFTELL(file);
|
||||
XREWIND(file);
|
||||
|
Loading…
Reference in New Issue
Block a user