adjust pointer cast, ssl rng with fips and unused param

This commit is contained in:
Jacob Barthelmeh
2016-06-06 14:32:49 -06:00
parent 2feee8856e
commit db90594909
7 changed files with 36 additions and 20 deletions

View File

@@ -3340,10 +3340,18 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
return MEMORY_E;
}
/* FIPS RNG API does not accept a heap hint */
#ifndef HAVE_FIPS
if ( (ret = wc_InitRng_ex(ssl->rng, ssl->heap)) != 0) {
WOLFSSL_MSG("RNG Init error");
return ret;
}
#else
if ( (ret = wc_InitRng(ssl->rng)) != 0) {
WOLFSSL_MSG("RNG Init error");
return ret;
}
#endif
#if defined(WOLFSSL_DTLS) && !defined(NO_WOLFSSL_SERVER)
if (ssl->options.dtls && ssl->options.side == WOLFSSL_SERVER_END) {

View File

@@ -640,10 +640,10 @@ int wolfSSL_init_memory_heap(WOLFSSL_HEAP* heap)
XMEMSET(heap, 0, sizeof(WOLFSSL_HEAP));
/* default pool sizes and distribution, else leave a 0's for now */
if (WOLFMEM_DEF_BUCKETS == WOLFMEM_MAX_BUCKETS) {
#if WOLFMEM_DEF_BUCKETS == WOLFMEM_MAX_BUCKETS
XMEMCPY(heap->sizeList, wc_defaultMemSz, sizeof(wc_defaultMemSz));
XMEMCPY(heap->distList, wc_defaultDist, sizeof(wc_defaultMemSz));
}
#endif
if (InitMutex(&(heap->memory_mutex)) != 0) {
WOLFSSL_MSG("Error creating heap memory mutex");
@@ -17437,7 +17437,7 @@ WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx)
WOLFSSL_MSG("Failed alloc X509");
}
else {
InitX509(x509, 1);
InitX509(x509, 1, NULL);
if ((ret = CopyDecodedToX509(x509, cert)) != 0) {
WOLFSSL_MSG("Failed to copy decoded");
@@ -17848,7 +17848,7 @@ void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl)
#ifndef NO_CERTS
void wolfSSL_X509_NAME_free(WOLFSSL_X509_NAME *name){
FreeX509Name(name);
FreeX509Name(name, NULL);
WOLFSSL_ENTER("wolfSSL_X509_NAME_free");
WOLFSSL_STUB("wolfSSL_X509_NAME_free");
}

View File

@@ -1955,6 +1955,8 @@ static INLINE void FreeTmpDsas(byte** tmps, void* heap)
for (i = 0; i < DSA_INTS; i++)
XFREE(tmps[i], heap, DYNAMIC_TYPE_DSA);
(void)heap;
}
/* Convert DsaKey key to DER format, write to output (inLen), return bytes

View File

@@ -831,9 +831,9 @@ int ecc_map(ecc_point* P, mp_int* modulus, mp_digit* mp)
*/
#ifdef FP_ECC
static int normal_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
mp_int* modulus, int map)
mp_int* modulus, int map, void* heap)
#else
static int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
mp_int* modulus, int map, void* heap)
#endif
{
@@ -1055,7 +1055,7 @@ int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
static int normal_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
mp_int* modulus, int map, void* heap)
#else
static int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
mp_int* modulus, int map, void* heap)
#endif
{
@@ -4501,7 +4501,7 @@ int ecc_mul2add(ecc_point* A, mp_int* kA,
int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
int map)
{
return wc_ecc_mulmod_h(k, G, R, modulus, map, NULL);
return wc_ecc_mulmod_ex(k, G, R, modulus, map, NULL);
}
@@ -4514,7 +4514,7 @@ int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
otherwise it's left in jacobian-montgomery form
return MP_OKAY if successful
*/
int wc_ecc_mulmod_h(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R, mp_int* modulus,
int map, void* heap)
{
int idx, err = MP_OKAY;

View File

@@ -218,7 +218,7 @@ int wolfSSL_load_static_memory(byte* buffer, word32 sz, int flag,
}
/* align pt */
while ((word64)pt % WOLFSSL_STATIC_ALIGN && pt < (buffer + sz)) {
while ((long)pt % WOLFSSL_STATIC_ALIGN && pt < (buffer + sz)) {
*pt = 0x00;
pt++;
}
@@ -379,8 +379,12 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
res = NULL;
}
#else
#ifndef WOLFSSL_NO_MALLOC
res = malloc(size);
#endif
#else
WOLFSSL_MSG("No heap hint found to use and no malloc");
#endif /* WOLFSSL_NO_MALLOC */
#endif /* WOLFSSL_HEAP_TEST */
}
else {
WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)heap;
@@ -489,7 +493,11 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
WOLFSSL_MSG("ERROR null heap hint passed into XFREE\n");
}
#endif
#ifndef WOLFSSL_NO_MALLOC
free(ptr);
#else
WOLFSSL_MSG("Error trying to call free when turned off");
#endif /* WOLFSSL_NO_MALLOC */
}
else {
WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)heap;
@@ -571,7 +579,11 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
#ifdef WOLFSSL_HEAP_TEST
WOLFSSL_MSG("ERROR null heap hint passed in to XREALLOC\n");
#endif
res = realloc(ptr, size);
#ifndef WOLFSSL_NO_MALLOC
res = realloc(ptr, size);
#else
WOLFSSL_MSG("NO heap found to use for realloc");
#endif /* WOLFSSL_NO_MALLOC */
}
else {
WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)heap;

View File

@@ -235,8 +235,8 @@ WOLFSSL_API
int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
mp_int* modulus, int map);
WOLFSSL_API
int wc_ecc_mulmod_h(mp_int* k, ecc_point *G, ecc_point *R,
WOLFSSL_LOCAL
int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
mp_int* modulus, int map, void* heap);
#ifdef HAVE_ECC_KEY_EXPORT
/* ASN key helpers */

View File

@@ -211,12 +211,6 @@
#endif
/* sleep function for static memory */
#ifdef WOLFSSL_STATIC_MEMORY
#include <unistd.h>
#define XSLEEP(t) sleep((t))
#endif /* WOLFSSL_STATIC_MEMORY */
#ifndef STRING_USER
#include <string.h>
char* mystrnstr(const char* s1, const char* s2, unsigned int n);