Fixes to a few things based on peer review.

This commit is contained in:
David Garske 2017-04-07 16:07:48 -07:00
parent c1640e8a3d
commit 56a1618ba0
3 changed files with 17 additions and 14 deletions

View File

@ -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,

View File

@ -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*);

View File

@ -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 */