forked from wolfSSL/wolfssl
fix some bugs, add Windows support
This commit is contained in:
@@ -263,11 +263,12 @@ WOLFSSL* wolfSSL_dup(WOLFSSL* s)
|
|||||||
CHACHA20_IMP_IV_SZ);
|
CHACHA20_IMP_IV_SZ);
|
||||||
XMEMCPY(ret->keys.client_write_IV, s->keys.client_write_IV,
|
XMEMCPY(ret->keys.client_write_IV, s->keys.client_write_IV,
|
||||||
CHACHA20_IMP_IV_SZ);
|
CHACHA20_IMP_IV_SZ);
|
||||||
|
#ifdef HAVE_AEAD
|
||||||
XMEMCPY(ret->keys.aead_enc_imp_IV, ret->keys.server_write_IV,
|
XMEMCPY(ret->keys.aead_enc_imp_IV, ret->keys.server_write_IV,
|
||||||
CHACHA20_IMP_IV_SZ);
|
CHACHA20_IMP_IV_SZ);
|
||||||
XMEMCPY(ret->keys.aead_dec_imp_IV, ret->keys.client_write_IV,
|
XMEMCPY(ret->keys.aead_dec_imp_IV, ret->keys.client_write_IV,
|
||||||
CHACHA20_IMP_IV_SZ);
|
CHACHA20_IMP_IV_SZ);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* setup biord, and biowr */
|
/* setup biord, and biowr */
|
||||||
if (s->biord != NULL) {
|
if (s->biord != NULL) {
|
||||||
@@ -16673,7 +16674,7 @@ WOLFCRYPT_BIO *wolfSSL_BioNewSSLConnect(WOLFSSL_CTX *ctx)
|
|||||||
if (con == NULL)
|
if (con == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ssl = wolfSSL_BioNewSSL(ctx, 1);
|
ssl = wolfSSL_BioNewSSL(ctx, BIO_CLOSE);
|
||||||
if (ssl == NULL)
|
if (ssl == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@@ -30,16 +30,18 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
#ifdef USE_WINDOWS_API
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#define SHUT_RDWR SD_BOTH
|
||||||
#else
|
#else
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
@@ -753,7 +755,9 @@ unsigned long wc_BioNumberWritten(WOLFCRYPT_BIO *bio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USE_WINDOWS_API
|
||||||
__attribute__((format(printf, 2, 3)))
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
int wc_BioPrintf(WOLFCRYPT_BIO *bio, const char *format, ...)
|
int wc_BioPrintf(WOLFCRYPT_BIO *bio, const char *format, ...)
|
||||||
{
|
{
|
||||||
int size, ret;
|
int size, ret;
|
||||||
@@ -1954,7 +1958,6 @@ static int wc_BioBuffer_gets(WOLFCRYPT_BIO *bio, char *buf, int size)
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (ctx->inLen > 0) {
|
if (ctx->inLen > 0) {
|
||||||
// p = &(ctx->in[ctx->inIdx]);
|
|
||||||
flag = 0;
|
flag = 0;
|
||||||
|
|
||||||
for (i = 0; (i < ctx->inLen) && (i < size); i++) {
|
for (i = 0; (i < ctx->inLen) && (i < size); i++) {
|
||||||
@@ -3071,6 +3074,9 @@ int wc_BioSetTcpNsigpipe(int s, int on)
|
|||||||
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif /* S_NOSIGPIPE */
|
#endif /* S_NOSIGPIPE */
|
||||||
|
#else /* USE_WINDOWS_API */
|
||||||
|
(void) s;
|
||||||
|
(void) on;
|
||||||
#endif /* USE_WINDOWS_API */
|
#endif /* USE_WINDOWS_API */
|
||||||
|
|
||||||
return (ret == 0);
|
return (ret == 0);
|
||||||
@@ -5462,7 +5468,7 @@ static int wolfCrypt_BufMem_grow(WOLFCRYPT_BUF_MEM *buf, size_t len)
|
|||||||
static int wolfCrypt_BufMem_grow_clean(WOLFCRYPT_BUF_MEM *buf, size_t len)
|
static int wolfCrypt_BufMem_grow_clean(WOLFCRYPT_BUF_MEM *buf, size_t len)
|
||||||
{
|
{
|
||||||
int ret, idx = -1;
|
int ret, idx = -1;
|
||||||
size_t size;
|
size_t size = 0;
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
WOLFSSL_ERROR(BAD_FUNC_ARG);
|
WOLFSSL_ERROR(BAD_FUNC_ARG);
|
||||||
|
@@ -6736,7 +6736,11 @@ int bio_connect_ssl_test(void)
|
|||||||
i = wc_BioWrite(out, request+idx, len);
|
i = wc_BioWrite(out, request+idx, len);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
if (wc_BioShouldRetry(out)) {
|
if (wc_BioShouldRetry(out)) {
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
Sleep(1000);
|
||||||
|
#else
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
ret = -3005;
|
ret = -3005;
|
||||||
@@ -6755,7 +6759,11 @@ int bio_connect_ssl_test(void)
|
|||||||
break;
|
break;
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
if (wc_BioShouldRetry(out)) {
|
if (wc_BioShouldRetry(out)) {
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
Sleep(1000);
|
||||||
|
#else
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = -3006;
|
ret = -3006;
|
||||||
@@ -6817,7 +6825,7 @@ int bio_accept_ssl_test(void)
|
|||||||
#define KEY_F "./certs/ecc-key.pem"
|
#define KEY_F "./certs/ecc-key.pem"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssl_ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());
|
ssl_ctx = wolfSSL_CTX_new(wolfTLSv1_server_method());
|
||||||
if (ssl_ctx == NULL)
|
if (ssl_ctx == NULL)
|
||||||
return -3000;
|
return -3000;
|
||||||
|
|
||||||
@@ -6844,7 +6852,7 @@ int bio_accept_ssl_test(void)
|
|||||||
#endif /* NO_DH */
|
#endif /* NO_DH */
|
||||||
|
|
||||||
/* Setup server side SSL bio */
|
/* Setup server side SSL bio */
|
||||||
ssl_bio = wolfSSL_BioNewSSL(ssl_ctx, 0);
|
ssl_bio = wolfSSL_BioNewSSL(ssl_ctx, BIO_NOCLOSE);
|
||||||
if (ssl_bio == NULL) {
|
if (ssl_bio == NULL) {
|
||||||
ret = -3005;
|
ret = -3005;
|
||||||
goto end;
|
goto end;
|
||||||
@@ -6882,7 +6890,7 @@ int bio_accept_ssl_test(void)
|
|||||||
* will be freed when the accept BIO is freed.
|
* will be freed when the accept BIO is freed.
|
||||||
*/
|
*/
|
||||||
if (wc_BioSetAcceptBios(in, ssl_bio) <= 0) {
|
if (wc_BioSetAcceptBios(in, ssl_bio) <= 0) {
|
||||||
ret = -3006;
|
ret = -3009;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6904,7 +6912,8 @@ int bio_accept_ssl_test(void)
|
|||||||
b_rw = wc_BioPop(in);
|
b_rw = wc_BioPop(in);
|
||||||
if (b_rw == NULL) {
|
if (b_rw == NULL) {
|
||||||
printf("BIO error -> close\n");
|
printf("BIO error -> close\n");
|
||||||
break;
|
ret = -3012;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
@@ -6922,6 +6931,8 @@ int bio_accept_ssl_test(void)
|
|||||||
if (wc_BioShouldRetry(b_rw))
|
if (wc_BioShouldRetry(b_rw))
|
||||||
continue;
|
continue;
|
||||||
printf("Read error -> close\n");
|
printf("Read error -> close\n");
|
||||||
|
ret = -3014;
|
||||||
|
goto end;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7004,8 +7015,13 @@ int bio_test(void)
|
|||||||
return -1006;
|
return -1006;
|
||||||
|
|
||||||
ret = wc_BioTell(bio);
|
ret = wc_BioTell(bio);
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
if (ret != 0)
|
||||||
|
return -1007;
|
||||||
|
#else
|
||||||
if (ret != (int)strlen(buf)+1)
|
if (ret != (int)strlen(buf)+1)
|
||||||
return -1007;
|
return -1007;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* write */
|
/* write */
|
||||||
ret = wc_BioPrintf(bio, "%s\n", buf);
|
ret = wc_BioPrintf(bio, "%s\n", buf);
|
||||||
|
@@ -165,7 +165,11 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\asn.c"
|
RelativePath=".\wolfcrypt\src\asn.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\wolfcrypt\src\bio.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\blake2b.c"
|
RelativePath=".\wolfcrypt\src\blake2b.c"
|
||||||
>
|
>
|
||||||
@@ -176,7 +180,12 @@
|
|||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\coding.c"
|
RelativePath=".\wolfcrypt\src\coding.c"
|
||||||
>
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\wolfcrypt\src\compat-wolfssl.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\chacha.c"
|
RelativePath=".\wolfcrypt\src\chacha.c"
|
||||||
>
|
>
|
||||||
|
@@ -162,6 +162,10 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\asn.c"
|
RelativePath=".\wolfcrypt\src\asn.c"
|
||||||
>
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\wolfcrypt\src\bio.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\blake2b.c"
|
RelativePath=".\wolfcrypt\src\blake2b.c"
|
||||||
@@ -174,6 +178,10 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\coding.c"
|
RelativePath=".\wolfcrypt\src\coding.c"
|
||||||
>
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\wolfcrypt\src\compat-wolfssl.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\wolfcrypt\src\chacha.c"
|
RelativePath=".\wolfcrypt\src\chacha.c"
|
||||||
|
@@ -286,11 +286,13 @@
|
|||||||
<ClCompile Include="wolfcrypt\src\aes.c" />
|
<ClCompile Include="wolfcrypt\src\aes.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\arc4.c" />
|
<ClCompile Include="wolfcrypt\src\arc4.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\asn.c" />
|
<ClCompile Include="wolfcrypt\src\asn.c" />
|
||||||
|
<ClCompile Include="wolfcrypt\src\bio.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\blake2b.c" />
|
<ClCompile Include="wolfcrypt\src\blake2b.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\camellia.c" />
|
<ClCompile Include="wolfcrypt\src\camellia.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\chacha.c" />
|
<ClCompile Include="wolfcrypt\src\chacha.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\chacha20_poly1305.c" />
|
<ClCompile Include="wolfcrypt\src\chacha20_poly1305.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\coding.c" />
|
<ClCompile Include="wolfcrypt\src\coding.c" />
|
||||||
|
<ClCompile Include="wolfcrypt\src\compat-wolfssl.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\des3.c" />
|
<ClCompile Include="wolfcrypt\src\des3.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\dh.c" />
|
<ClCompile Include="wolfcrypt\src\dh.c" />
|
||||||
<ClCompile Include="wolfcrypt\src\dsa.c" />
|
<ClCompile Include="wolfcrypt\src\dsa.c" />
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#ifdef WOLFSSL_RIPEMD
|
#ifdef WOLFSSL_RIPEMD
|
||||||
|
|
||||||
typedef WOLCRYPT_RIPEMD_CTX RIPEMD_CTX;
|
typedef WOLFCRYPT_RIPEMD_CTX RIPEMD_CTX;
|
||||||
|
|
||||||
#define RIPEMD_Init wc_RIPEMD_Init
|
#define RIPEMD_Init wc_RIPEMD_Init
|
||||||
#define RIPEMD_Update wc_RIPEMD_Update
|
#define RIPEMD_Update wc_RIPEMD_Update
|
||||||
|
@@ -50,10 +50,8 @@ enum WS_BIO_TYPE {
|
|||||||
* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
|
* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
|
||||||
* BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
* BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||||
*/
|
*/
|
||||||
#if !defined(BIO_CLOSE) || !defined(BIO_NOCLOSE)
|
|
||||||
#define BIO_CLOSE 1
|
#define BIO_CLOSE 1
|
||||||
#define BIO_NOCLOSE 0
|
#define BIO_NOCLOSE 0
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are used in the following macros and are passed to BIO_ctrl()
|
* These are used in the following macros and are passed to BIO_ctrl()
|
||||||
|
Reference in New Issue
Block a user