diff --git a/src/internal.c b/src/internal.c index 3435b8776..56c834a60 100755 --- a/src/internal.c +++ b/src/internal.c @@ -3626,16 +3626,17 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup) /* arrays */ ssl->arrays = (Arrays*)XMALLOC(sizeof(Arrays), ssl->heap, DYNAMIC_TYPE_ARRAYS); - if (ssl->arrays == NULL) { - WOLFSSL_MSG("Arrays Memory error"); - return MEMORY_E; - } - XMEMSET(ssl->arrays, 0, sizeof(Arrays)); - ssl->arrays->preMasterSecret = (byte*)XMALLOC(ENCRYPT_LEN, ssl->heap, - DYNAMIC_TYPE_TMP_BUFFER); - if (ssl->arrays->preMasterSecret == NULL) { - return MEMORY_E; - } + if (ssl->arrays == NULL) { + WOLFSSL_MSG("Arrays Memory error"); + return MEMORY_E; + } + XMEMSET(ssl->arrays, 0, sizeof(Arrays)); + ssl->arrays->preMasterSecret = (byte*)XMALLOC(ENCRYPT_LEN, ssl->heap, + DYNAMIC_TYPE_TMP_BUFFER); + if (ssl->arrays->preMasterSecret == NULL) { + return MEMORY_E; + } + XMEMSET(ssl->arrays->preMasterSecret, 0, ENCRYPT_LEN); /* suites */ ssl->suites = (Suites*)XMALLOC(sizeof(Suites), ssl->heap, diff --git a/wolfssl/wolfcrypt/des3.h b/wolfssl/wolfcrypt/des3.h index 6662501e5..5eb94a1c8 100644 --- a/wolfssl/wolfcrypt/des3.h +++ b/wolfssl/wolfcrypt/des3.h @@ -113,6 +113,8 @@ WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out, WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz); +/* These are only required when using either: + static memory (WOLFSSL_STATIC_MEMORY) or asynchronous (WOLFSSL_ASYNC_CRYPT) */ WOLFSSL_API int wc_Des3Init(Des3*, void*, int); WOLFSSL_API void wc_Des3Free(Des3*); diff --git a/wolfssl/wolfcrypt/sha.h b/wolfssl/wolfcrypt/sha.h index 5d5d0908f..db72e9118 100644 --- a/wolfssl/wolfcrypt/sha.h +++ b/wolfssl/wolfcrypt/sha.h @@ -56,11 +56,7 @@ enum { #endif SHA = 1, /* hash type unique */ SHA_BLOCK_SIZE = 64, -#ifdef WOLFSSL_PIC32MZ_HASH - SHA_DIGEST_SIZE = PIC32_HASH_SIZE, -#else SHA_DIGEST_SIZE = 20, -#endif SHA_PAD_SIZE = 56 }; @@ -75,7 +71,11 @@ typedef struct Sha { word32 loLen; /* length in bytes */ word32 hiLen; /* length in bytes */ word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)]; + #ifndef WOLFSSL_PIC32MZ_HASH word32 digest[SHA_DIGEST_SIZE / sizeof(word32)]; + #else + word32 digest[PIC32_HASH_SIZE / sizeof(word32)]; + #endif void* heap; #ifdef WOLFSSL_PIC32MZ_HASH pic32mz_desc desc; /* Crypt Engine descriptor */