Fix va_copy error for Win32 build and AES-NI segfault

This commit is contained in:
Ludovic FLAMENT
2016-05-24 18:17:26 +02:00
parent ab1d6c91bf
commit 1d675ed1e6
2 changed files with 19 additions and 5 deletions

View File

@ -45,7 +45,13 @@
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#define SHUT_RDWR SD_BOTH #define SHUT_RDWR SD_BOTH
#else #ifdef _MSC_VER
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
#pragma warning(disable: 4996)
/* 4127 warning to use check on size of component of an union */
#pragma warning(disable: 4127)
#endif
#else /* USE_WINDOWS_API */
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/time.h> #include <sys/time.h>
@ -800,6 +806,10 @@ unsigned long wc_BioNumberWritten(WOLFCRYPT_BIO *bio)
#ifndef NO_STDIO_FILESYSTEM #ifndef NO_STDIO_FILESYSTEM
#ifndef va_copy
#define va_copy(dest, src) ((dest) = (src))
#endif
#ifndef USE_WINDOWS_API #ifndef USE_WINDOWS_API
__attribute__((format(printf, 2, 3))) __attribute__((format(printf, 2, 3)))
#endif #endif
@ -1731,7 +1741,9 @@ static int wc_BioBuffer_read(WOLFCRYPT_BIO *bio, char *data, int size)
ctx->inLen = i; ctx->inLen = i;
} }
#ifndef USE_WINDOWS_API
return 1; return 1;
#endif
} }
static int wc_BioBuffer_write(WOLFCRYPT_BIO *bio, static int wc_BioBuffer_write(WOLFCRYPT_BIO *bio,
@ -1809,7 +1821,9 @@ static int wc_BioBuffer_write(WOLFCRYPT_BIO *bio,
} }
} }
#ifndef USE_WINDOWS_API
return 1; return 1;
#endif
} }
static long wc_BioBuffer_ctrl(WOLFCRYPT_BIO *bio, int cmd, long num, void *ptr) static long wc_BioBuffer_ctrl(WOLFCRYPT_BIO *bio, int cmd, long num, void *ptr)
@ -3506,7 +3520,7 @@ again:
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
closesocket(s); closesocket(s);
#else #else
close(s); close(s);
#endif #endif
break; break;

View File

@ -980,7 +980,7 @@ int wc_EVP_CipherInit(WOLFCRYPT_EVP_CIPHER_CTX* ctx,
if (enc == 0 || enc == 1) if (enc == 0 || enc == 1)
ctx->enc = enc ? 1 : 0; ctx->enc = enc ? 1 : 0;
if (key) { if (key) {
ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, ret = wc_AesSetKeyDirect(&ctx->cipher.aes, key, ctx->keyLen, iv,
AES_ENCRYPTION); AES_ENCRYPTION);
if (ret != 0) if (ret != 0)
return ret; return ret;
@ -1004,7 +1004,7 @@ int wc_EVP_CipherInit(WOLFCRYPT_EVP_CIPHER_CTX* ctx,
if (enc == 0 || enc == 1) if (enc == 0 || enc == 1)
ctx->enc = enc ? 1 : 0; ctx->enc = enc ? 1 : 0;
if (key) { if (key) {
ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, ret = wc_AesSetKeyDirect(&ctx->cipher.aes, key, ctx->keyLen, iv,
AES_ENCRYPTION); AES_ENCRYPTION);
if (ret != 0) if (ret != 0)
return ret; return ret;
@ -1028,7 +1028,7 @@ int wc_EVP_CipherInit(WOLFCRYPT_EVP_CIPHER_CTX* ctx,
if (enc == 0 || enc == 1) if (enc == 0 || enc == 1)
ctx->enc = enc ? 1 : 0; ctx->enc = enc ? 1 : 0;
if (key) { if (key) {
ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, ret = wc_AesSetKeyDirect(&ctx->cipher.aes, key, ctx->keyLen, iv,
AES_ENCRYPTION); AES_ENCRYPTION);
if (ret != 0) if (ret != 0)
return ret; return ret;