From 6a825ea0ce0d699cbd9f2493de1c02aedc8f71fc Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Thu, 9 Nov 2017 17:30:59 +1000 Subject: [PATCH] Fix warnings and g++ casting error --- src/ssl.c | 24 ++++++++++++------------ wolfcrypt/src/aes.c | 13 ++----------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index b1e625458..67ffe6fb0 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -288,16 +288,17 @@ WOLFSSL_CTX* wolfSSL_CTX_new_ex(WOLFSSL_METHOD* method, void* heap) wolfSSL_CTX_free(ctx); ctx = NULL; } - #if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \ - && !defined(NO_SHA256) && !defined(WC_NO_RNG) - ctx->srp = (Srp*) XMALLOC(sizeof(Srp), heap, DYNAMIC_TYPE_SRP); - if (ctx->srp == NULL){ - WOLFSSL_MSG("Init CTX failed"); - wolfSSL_CTX_free(ctx); - return NULL; + && !defined(NO_SHA256) && !defined(WC_NO_RNG) + else { + ctx->srp = (Srp*) XMALLOC(sizeof(Srp), heap, DYNAMIC_TYPE_SRP); + if (ctx->srp == NULL){ + WOLFSSL_MSG("Init CTX failed"); + wolfSSL_CTX_free(ctx); + return NULL; + } + XMEMSET(ctx->srp, 0, sizeof(Srp)); } - XMEMSET(ctx->srp, 0, sizeof(Srp)); #endif } else { @@ -11177,7 +11178,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) int wolfSSL_CTX_set_srp_username(WOLFSSL_CTX* ctx, char* username) { int r = 0; - int srp_side = 0; + SrpSide srp_side = SRP_CLIENT_SIDE; WC_RNG rng; byte salt[SRP_SALT_SIZE]; @@ -11290,9 +11291,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (ctx->srp_password != NULL) XFREE(ctx->srp_password,ctx->heap, DYNAMIC_TYPE_SRP); - ctx->srp_password = XMALLOC(XSTRLEN(password) + 1, - ctx->heap, - DYNAMIC_TYPE_SRP); + ctx->srp_password = (byte*)XMALLOC(XSTRLEN(password) + 1, ctx->heap, + DYNAMIC_TYPE_SRP); if (ctx->srp_password == NULL){ WOLFSSL_MSG("memory allocation error"); return SSL_FAILURE; diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 2684d8a8d..85b957a07 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -7855,7 +7855,7 @@ int wc_AesXtsEncrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz, word32 blocks = (sz / AES_BLOCK_SIZE); Aes *aes, *tweak; - if (xaes == NULL || out == NULL) { + if (xaes == NULL || out == NULL || in == NULL) { return BAD_FUNC_ARG; } @@ -7866,10 +7866,6 @@ int wc_AesXtsEncrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz, return BAD_FUNC_ARG; } - if (in == NULL && sz > 0) { - return BAD_FUNC_ARG; - } - if (blocks > 0) { byte tmp[AES_BLOCK_SIZE]; @@ -7896,7 +7892,6 @@ int wc_AesXtsEncrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz, if (carry) { tmp[0] ^= GF_XTS; } - carry = 0; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; @@ -7948,7 +7943,7 @@ int wc_AesXtsDecrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz, word32 blocks = (sz / AES_BLOCK_SIZE); Aes *aes, *tweak; - if (xaes == NULL || out == NULL) { + if (xaes == NULL || out == NULL || in == NULL) { return BAD_FUNC_ARG; } @@ -7959,10 +7954,6 @@ int wc_AesXtsDecrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz, return BAD_FUNC_ARG; } - if (in == NULL && sz > 0) { - return BAD_FUNC_ARG; - } - if (blocks > 0) { word32 j; byte carry = 0;