Merge pull request #585 from NickolasLapp/master

Rename *Mutex Functions with wc_ prefix. Expose these functions for Stunnel.
This commit is contained in:
toddouska
2016-10-12 11:19:32 -07:00
committed by GitHub
23 changed files with 354 additions and 311 deletions

View File

@@ -491,7 +491,7 @@ static void command_invoke(void *args)
func = (void(*)(void *))((func_args *)args)->argv[0] ; func = (void(*)(void *))((func_args *)args)->argv[0] ;
#ifdef HAVE_KEIL_RTX #ifdef HAVE_KEIL_RTX
LockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
#endif #endif
iteration = for_iteration ; iteration = for_iteration ;
for(i=0; i< iteration; i++) { for(i=0; i< iteration; i++) {
@@ -509,7 +509,7 @@ static void command_invoke(void *args)
if(iteration > 1) if(iteration > 1)
for_iteration = 1 ; for_iteration = 1 ;
#ifdef HAVE_KEIL_RTX #ifdef HAVE_KEIL_RTX
UnLockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
os_tsk_delete_self() ; os_tsk_delete_self() ;
#endif #endif
} }
@@ -548,7 +548,7 @@ void shell_main(void) {
#if defined(HAVE_KEIL_RTX) #if defined(HAVE_KEIL_RTX)
InitMutex(&command_mutex) ; wc_InitMutex(&command_mutex) ;
#endif #endif
printf("Starting Shell\n") ; printf("Starting Shell\n") ;
while(1) { while(1) {
@@ -558,14 +558,14 @@ void shell_main(void) {
args.argv[0] = (char *) commandTable[i].func ; args.argv[0] = (char *) commandTable[i].func ;
if(bf_flg == FORGROUND) { if(bf_flg == FORGROUND) {
#ifdef HAVE_KEIL_RTX #ifdef HAVE_KEIL_RTX
UnLockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7, os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7,
command_stack, COMMAND_STACK_SIZE, &args) ; command_stack, COMMAND_STACK_SIZE, &args) ;
#else #else
command_invoke(&args) ; command_invoke(&args) ;
#endif #endif
#ifdef HAVE_KEIL_RTX #ifdef HAVE_KEIL_RTX
LockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
#endif #endif
} else { } else {
#if (!defined(NO_SIMPLE_SERVER) && \ #if (!defined(NO_SIMPLE_SERVER) && \

View File

@@ -562,7 +562,7 @@ static void command_invoke(void const *args)
func = (void(*)(void const *))((func_args *)args)->argv[0] ; func = (void(*)(void const *))((func_args *)args)->argv[0] ;
#if defined(HAVE_KEIL_RTX) #if defined(HAVE_KEIL_RTX)
LockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
#endif #endif
iteration = for_iteration ; iteration = for_iteration ;
for(i=0; i< iteration; i++) { for(i=0; i< iteration; i++) {
@@ -582,7 +582,7 @@ static void command_invoke(void const *args)
for_iteration = 1 ; for_iteration = 1 ;
osDelay(20000) ; osDelay(20000) ;
#ifdef HAVE_KEIL_RTX #ifdef HAVE_KEIL_RTX
UnLockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
#ifdef WOLFSSL_CMSIS_RTOS #ifdef WOLFSSL_CMSIS_RTOS
osThreadTerminate(osThreadGetId()) ; osThreadTerminate(osThreadGetId()) ;
#else #else
@@ -635,7 +635,7 @@ void shell_main(void *arg) {
/* Dummy for avoiding warning: BackGround is defined but not used. */ /* Dummy for avoiding warning: BackGround is defined but not used. */
#if defined(HAVE_KEIL_RTX) #if defined(HAVE_KEIL_RTX)
InitMutex(&command_mutex) ; wc_InitMutex(&command_mutex) ;
#endif #endif
help_comm(NULL) ; help_comm(NULL) ;
@@ -647,13 +647,13 @@ void shell_main(void *arg) {
args.argv[0] = (char *) commandTable[i].func ; args.argv[0] = (char *) commandTable[i].func ;
if(bf_flg == FORGROUND) { if(bf_flg == FORGROUND) {
#if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS) #if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
UnLockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7, os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7,
command_stack, COMMAND_STACK_SIZE, &args) ; command_stack, COMMAND_STACK_SIZE, &args) ;
os_tsk_pass (); os_tsk_pass ();
#else #else
#if defined(WOLFSSL_CMSIS_RTOS) #if defined(WOLFSSL_CMSIS_RTOS)
UnLockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
cmd = osThreadCreate (osThread (command_invoke) , &args); cmd = osThreadCreate (osThread (command_invoke) , &args);
if(cmd == NULL) { if(cmd == NULL) {
printf("Cannon create command thread\n") ; printf("Cannon create command thread\n") ;
@@ -664,7 +664,7 @@ void shell_main(void *arg) {
#endif #endif
#endif #endif
#ifdef HAVE_KEIL_RTX #ifdef HAVE_KEIL_RTX
LockMutex((wolfSSL_Mutex *)&command_mutex) ; wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
#endif #endif
} else { } else {
#if (!defined(NO_SIMPLE_SERVER) && \ #if (!defined(NO_SIMPLE_SERVER) && \

View File

@@ -2284,6 +2284,12 @@ then
AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"]) AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"])
fi fi
# Requires DES3, make sure on
if test "x$ENABLED_DES3" = "xno"
then
ENABLED_DES3="yes"
fi
# Requires tlsx, make sure on # Requires tlsx, make sure on
if test "x$ENABLED_TLSX" = "xno" if test "x$ENABLED_TLSX" = "xno"
then then

View File

@@ -65,7 +65,7 @@ int InitCRL(WOLFSSL_CRL* crl, WOLFSSL_CERT_MANAGER* cm)
return BAD_COND_E; return BAD_COND_E;
} }
#endif #endif
if (InitMutex(&crl->crlLock) != 0) { if (wc_InitMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("Init Mutex failed"); WOLFSSL_MSG("Init Mutex failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -144,7 +144,7 @@ void FreeCRL(WOLFSSL_CRL* crl, int dynamic)
} }
pthread_cond_destroy(&crl->cond); pthread_cond_destroy(&crl->cond);
#endif #endif
FreeMutex(&crl->crlLock); wc_FreeMutex(&crl->crlLock);
if (dynamic) /* free self */ if (dynamic) /* free self */
XFREE(crl, crl->heap, DYNAMIC_TYPE_CRL); XFREE(crl, crl->heap, DYNAMIC_TYPE_CRL);
} }
@@ -159,8 +159,8 @@ int CheckCertCRL(WOLFSSL_CRL* crl, DecodedCert* cert)
WOLFSSL_ENTER("CheckCertCRL"); WOLFSSL_ENTER("CheckCertCRL");
if (LockMutex(&crl->crlLock) != 0) { if (wc_LockMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("LockMutex failed"); WOLFSSL_MSG("wc_LockMutex failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -203,7 +203,7 @@ int CheckCertCRL(WOLFSSL_CRL* crl, DecodedCert* cert)
} }
} }
UnLockMutex(&crl->crlLock); wc_UnLockMutex(&crl->crlLock);
if (foundEntry == 0) { if (foundEntry == 0) {
WOLFSSL_MSG("Couldn't find CRL for status check"); WOLFSSL_MSG("Couldn't find CRL for status check");
@@ -248,15 +248,15 @@ static int AddCRL(WOLFSSL_CRL* crl, DecodedCRL* dcrl)
return -1; return -1;
} }
if (LockMutex(&crl->crlLock) != 0) { if (wc_LockMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("LockMutex failed"); WOLFSSL_MSG("wc_LockMutex failed");
FreeCRL_Entry(crle, crl->heap); FreeCRL_Entry(crle, crl->heap);
XFREE(crle, crl->heap, DYNAMIC_TYPE_CRL_ENTRY); XFREE(crle, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
crle->next = crl->crlList; crle->next = crl->crlList;
crl->crlList = crle; crl->crlList = crle;
UnLockMutex(&crl->crlLock); wc_UnLockMutex(&crl->crlLock);
return 0; return 0;
} }
@@ -337,15 +337,15 @@ static int SignalSetup(WOLFSSL_CRL* crl, int status)
int ret; int ret;
/* signal to calling thread we're setup */ /* signal to calling thread we're setup */
if (LockMutex(&crl->crlLock) != 0) { if (wc_LockMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("LockMutex crlLock failed"); WOLFSSL_MSG("wc_LockMutex crlLock failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
crl->setup = status; crl->setup = status;
ret = pthread_cond_signal(&crl->cond); ret = pthread_cond_signal(&crl->cond);
UnLockMutex(&crl->crlLock); wc_UnLockMutex(&crl->crlLock);
if (ret != 0) if (ret != 0)
return BAD_COND_E; return BAD_COND_E;
@@ -403,8 +403,8 @@ static int SwapLists(WOLFSSL_CRL* crl)
} }
} }
if (LockMutex(&crl->crlLock) != 0) { if (wc_LockMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("LockMutex failed"); WOLFSSL_MSG("wc_LockMutex failed");
FreeCRL(tmp, 0); FreeCRL(tmp, 0);
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
@@ -418,7 +418,7 @@ static int SwapLists(WOLFSSL_CRL* crl)
tmp->crlList = crl->crlList; tmp->crlList = crl->crlList;
crl->crlList = newList; crl->crlList = newList;
UnLockMutex(&crl->crlLock); wc_UnLockMutex(&crl->crlLock);
FreeCRL(tmp, 0); FreeCRL(tmp, 0);
@@ -747,8 +747,8 @@ static int StartMonitorCRL(WOLFSSL_CRL* crl)
} }
/* wait for setup to complete */ /* wait for setup to complete */
if (LockMutex(&crl->crlLock) != 0) { if (wc_LockMutex(&crl->crlLock) != 0) {
WOLFSSL_MSG("LockMutex crlLock error"); WOLFSSL_MSG("wc_LockMutex crlLock error");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -762,7 +762,7 @@ static int StartMonitorCRL(WOLFSSL_CRL* crl)
if (crl->setup < 0) if (crl->setup < 0)
ret = crl->setup; /* store setup error */ ret = crl->setup; /* store setup error */
UnLockMutex(&crl->crlLock); wc_UnLockMutex(&crl->crlLock);
if (ret < 0) { if (ret < 0) {
WOLFSSL_MSG("DoMonitor setup failure"); WOLFSSL_MSG("DoMonitor setup failure");

View File

@@ -313,12 +313,12 @@ static word32 GetEntropy(unsigned char* out, word32 num_bytes)
if ((rngMutex = (wolfSSL_Mutex*)XMALLOC(sizeof(wolfSSL_Mutex), 0, if ((rngMutex = (wolfSSL_Mutex*)XMALLOC(sizeof(wolfSSL_Mutex), 0,
DYNAMIC_TYPE_TLSX)) == NULL) DYNAMIC_TYPE_TLSX)) == NULL)
return DRBG_OUT_OF_MEMORY; return DRBG_OUT_OF_MEMORY;
InitMutex(rngMutex); wc_InitMutex(rngMutex);
} }
ret |= LockMutex(rngMutex); ret |= wc_LockMutex(rngMutex);
ret |= wc_RNG_GenerateBlock(rng, out, num_bytes); ret |= wc_RNG_GenerateBlock(rng, out, num_bytes);
ret |= UnLockMutex(rngMutex); ret |= wc_UnLockMutex(rngMutex);
if (ret != 0) if (ret != 0)
return DRBG_ENTROPY_FAIL; return DRBG_ENTROPY_FAIL;
@@ -1334,7 +1334,7 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
ctx->timeout = WOLFSSL_SESSION_TIMEOUT; ctx->timeout = WOLFSSL_SESSION_TIMEOUT;
ctx->minDowngrade = TLSv1_MINOR; /* current default */ ctx->minDowngrade = TLSv1_MINOR; /* current default */
if (InitMutex(&ctx->countMutex) < 0) { if (wc_InitMutex(&ctx->countMutex) < 0) {
WOLFSSL_MSG("Mutex error on CTX init"); WOLFSSL_MSG("Mutex error on CTX init");
ctx->err = CTX_INIT_MUTEX_E; ctx->err = CTX_INIT_MUTEX_E;
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -1498,7 +1498,7 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
if (ctx->heap != (void*)WOLFSSL_HEAP_TEST) { if (ctx->heap != (void*)WOLFSSL_HEAP_TEST) {
#endif #endif
WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)(ctx->heap); WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)(ctx->heap);
FreeMutex(&((WOLFSSL_HEAP*)(hint->memory))->memory_mutex); wc_FreeMutex(&((WOLFSSL_HEAP*)(hint->memory))->memory_mutex);
#ifdef WOLFSSL_HEAP_TEST #ifdef WOLFSSL_HEAP_TEST
} }
#endif #endif
@@ -1511,7 +1511,7 @@ void FreeSSL_Ctx(WOLFSSL_CTX* ctx)
{ {
int doFree = 0; int doFree = 0;
if (LockMutex(&ctx->countMutex) != 0) { if (wc_LockMutex(&ctx->countMutex) != 0) {
WOLFSSL_MSG("Couldn't lock count mutex"); WOLFSSL_MSG("Couldn't lock count mutex");
/* check error state, if mutex error code then mutex init failed but /* check error state, if mutex error code then mutex init failed but
@@ -1525,12 +1525,12 @@ void FreeSSL_Ctx(WOLFSSL_CTX* ctx)
ctx->refCount--; ctx->refCount--;
if (ctx->refCount == 0) if (ctx->refCount == 0)
doFree = 1; doFree = 1;
UnLockMutex(&ctx->countMutex); wc_UnLockMutex(&ctx->countMutex);
if (doFree) { if (doFree) {
WOLFSSL_MSG("CTX ref count down to 0, doing full free"); WOLFSSL_MSG("CTX ref count down to 0, doing full free");
SSL_CtxResourceFree(ctx); SSL_CtxResourceFree(ctx);
FreeMutex(&ctx->countMutex); wc_FreeMutex(&ctx->countMutex);
XFREE(ctx, ctx->heap, DYNAMIC_TYPE_CTX); XFREE(ctx, ctx->heap, DYNAMIC_TYPE_CTX);
} }
else { else {
@@ -3117,12 +3117,12 @@ int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
} }
/* increment CTX reference count */ /* increment CTX reference count */
if (LockMutex(&ctx->countMutex) != 0) { if (wc_LockMutex(&ctx->countMutex) != 0) {
WOLFSSL_MSG("Couldn't lock CTX count mutex"); WOLFSSL_MSG("Couldn't lock CTX count mutex");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
ctx->refCount++; ctx->refCount++;
UnLockMutex(&ctx->countMutex); wc_UnLockMutex(&ctx->countMutex);
ssl->ctx = ctx; /* only for passing to calls, options could change */ ssl->ctx = ctx; /* only for passing to calls, options could change */
ssl->version = ctx->method->version; ssl->version = ctx->method->version;
@@ -3271,7 +3271,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
ctx_hint = ((WOLFSSL_HEAP_HINT*)(ctx->heap)); ctx_hint = ((WOLFSSL_HEAP_HINT*)(ctx->heap));
/* lock and check IO count / handshake count */ /* lock and check IO count / handshake count */
if (LockMutex(&(ctx_hint->memory->memory_mutex)) != 0) { if (wc_LockMutex(&(ctx_hint->memory->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
XFREE(ssl->heap, ctx->heap, DYNAMIC_TYPE_SSL); XFREE(ssl->heap, ctx->heap, DYNAMIC_TYPE_SSL);
ssl->heap = NULL; /* free and set to NULL for IO counter */ ssl->heap = NULL; /* free and set to NULL for IO counter */
@@ -3280,7 +3280,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
if (ctx_hint->memory->maxHa > 0 && if (ctx_hint->memory->maxHa > 0 &&
ctx_hint->memory->maxHa <= ctx_hint->memory->curHa) { ctx_hint->memory->maxHa <= ctx_hint->memory->curHa) {
WOLFSSL_MSG("At max number of handshakes for static memory"); WOLFSSL_MSG("At max number of handshakes for static memory");
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
XFREE(ssl->heap, ctx->heap, DYNAMIC_TYPE_SSL); XFREE(ssl->heap, ctx->heap, DYNAMIC_TYPE_SSL);
ssl->heap = NULL; /* free and set to NULL for IO counter */ ssl->heap = NULL; /* free and set to NULL for IO counter */
return MEMORY_E; return MEMORY_E;
@@ -3289,7 +3289,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
if (ctx_hint->memory->maxIO > 0 && if (ctx_hint->memory->maxIO > 0 &&
ctx_hint->memory->maxIO <= ctx_hint->memory->curIO) { ctx_hint->memory->maxIO <= ctx_hint->memory->curIO) {
WOLFSSL_MSG("At max number of IO allowed for static memory"); WOLFSSL_MSG("At max number of IO allowed for static memory");
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
XFREE(ssl->heap, ctx->heap, DYNAMIC_TYPE_SSL); XFREE(ssl->heap, ctx->heap, DYNAMIC_TYPE_SSL);
ssl->heap = NULL; /* free and set to NULL for IO counter */ ssl->heap = NULL; /* free and set to NULL for IO counter */
return MEMORY_E; return MEMORY_E;
@@ -3298,7 +3298,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
ctx_hint->memory->curHa++; ctx_hint->memory->curHa++;
ssl_hint->memory = ctx_hint->memory; ssl_hint->memory = ctx_hint->memory;
ssl_hint->haFlag = 1; ssl_hint->haFlag = 1;
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
/* check if tracking stats */ /* check if tracking stats */
if (ctx_hint->memory->flag & WOLFMEM_TRACK_STATS) { if (ctx_hint->memory->flag & WOLFMEM_TRACK_STATS) {
@@ -3312,24 +3312,24 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
/* check if using fixed IO buffers */ /* check if using fixed IO buffers */
if (ctx_hint->memory->flag & WOLFMEM_IO_POOL_FIXED) { if (ctx_hint->memory->flag & WOLFMEM_IO_POOL_FIXED) {
if (LockMutex(&(ctx_hint->memory->memory_mutex)) != 0) { if (wc_LockMutex(&(ctx_hint->memory->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
if (SetFixedIO(ctx_hint->memory, &(ssl_hint->inBuf)) != 1) { if (SetFixedIO(ctx_hint->memory, &(ssl_hint->inBuf)) != 1) {
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
return MEMORY_E; return MEMORY_E;
} }
if (SetFixedIO(ctx_hint->memory, &(ssl_hint->outBuf)) != 1) { if (SetFixedIO(ctx_hint->memory, &(ssl_hint->outBuf)) != 1) {
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
return MEMORY_E; return MEMORY_E;
} }
if (ssl_hint->outBuf == NULL || ssl_hint->inBuf == NULL) { if (ssl_hint->outBuf == NULL || ssl_hint->inBuf == NULL) {
WOLFSSL_MSG("Not enough memory to create fixed IO buffers"); WOLFSSL_MSG("Not enough memory to create fixed IO buffers");
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
return MEMORY_E; return MEMORY_E;
} }
UnLockMutex(&(ctx_hint->memory->memory_mutex)); wc_UnLockMutex(&(ctx_hint->memory->memory_mutex));
} }
#ifdef WOLFSSL_HEAP_TEST #ifdef WOLFSSL_HEAP_TEST
} }
@@ -3724,7 +3724,7 @@ void SSL_ResourceFree(WOLFSSL* ssl)
WOLFSSL_HEAP* ctx_heap; WOLFSSL_HEAP* ctx_heap;
ctx_heap = ssl_hint->memory; ctx_heap = ssl_hint->memory;
if (LockMutex(&(ctx_heap->memory_mutex)) != 0) { if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
} }
ctx_heap->curIO--; ctx_heap->curIO--;
@@ -3737,7 +3737,7 @@ void SSL_ResourceFree(WOLFSSL* ssl)
if (ssl_hint->haFlag) { /* check if handshake count has been decreased*/ if (ssl_hint->haFlag) { /* check if handshake count has been decreased*/
ctx_heap->curHa--; ctx_heap->curHa--;
} }
UnLockMutex(&(ctx_heap->memory_mutex)); wc_UnLockMutex(&(ctx_heap->memory_mutex));
/* check if tracking stats */ /* check if tracking stats */
if (ctx_heap->flag & WOLFMEM_TRACK_STATS) { if (ctx_heap->flag & WOLFMEM_TRACK_STATS) {
@@ -3910,12 +3910,12 @@ void FreeHandshakeResources(WOLFSSL* ssl)
WOLFSSL_HEAP* ctx_heap; WOLFSSL_HEAP* ctx_heap;
ctx_heap = ssl_hint->memory; ctx_heap = ssl_hint->memory;
if (LockMutex(&(ctx_heap->memory_mutex)) != 0) { if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
} }
ctx_heap->curHa--; ctx_heap->curHa--;
ssl_hint->haFlag = 0; /* set to zero since handshake has been dec */ ssl_hint->haFlag = 0; /* set to zero since handshake has been dec */
UnLockMutex(&(ctx_heap->memory_mutex)); wc_UnLockMutex(&(ctx_heap->memory_mutex));
#ifdef WOLFSSL_HEAP_TEST #ifdef WOLFSSL_HEAP_TEST
} }
#endif #endif
@@ -10708,11 +10708,11 @@ int SendCertificateStatus(WOLFSSL* ssl)
if (ret != 0) { if (ret != 0) {
XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
} }
else if (!ssl->buffers.weOwnCert && 0 == LockMutex( else if (!ssl->buffers.weOwnCert && 0 == wc_LockMutex(
&ssl->ctx->cm->ocsp_stapling->ocspLock)) { &ssl->ctx->cm->ocsp_stapling->ocspLock)) {
if (!ssl->ctx->certOcspRequest) if (!ssl->ctx->certOcspRequest)
ssl->ctx->certOcspRequest = request; ssl->ctx->certOcspRequest = request;
UnLockMutex(&ssl->ctx->cm->ocsp_stapling->ocspLock); wc_UnLockMutex(&ssl->ctx->cm->ocsp_stapling->ocspLock);
} }
} }
@@ -10805,12 +10805,12 @@ int SendCertificateStatus(WOLFSSL* ssl)
if (ret != 0) { if (ret != 0) {
XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
} }
else if (!ssl->buffers.weOwnCert && 0 == LockMutex( else if (!ssl->buffers.weOwnCert && 0 == wc_LockMutex(
&ssl->ctx->cm->ocsp_stapling->ocspLock)) { &ssl->ctx->cm->ocsp_stapling->ocspLock)) {
if (!ssl->ctx->certOcspRequest) if (!ssl->ctx->certOcspRequest)
ssl->ctx->certOcspRequest = request; ssl->ctx->certOcspRequest = request;
UnLockMutex(&ssl->ctx->cm->ocsp_stapling->ocspLock); wc_UnLockMutex(&ssl->ctx->cm->ocsp_stapling->ocspLock);
} }
} }
@@ -10885,12 +10885,12 @@ int SendCertificateStatus(WOLFSSL* ssl)
break; break;
} }
else if (!ssl->buffers.weOwnCertChain && 0 == else if (!ssl->buffers.weOwnCertChain && 0 ==
LockMutex( wc_LockMutex(
&ssl->ctx->cm->ocsp_stapling->ocspLock)) { &ssl->ctx->cm->ocsp_stapling->ocspLock)) {
if (!ssl->ctx->chainOcspRequest[i]) if (!ssl->ctx->chainOcspRequest[i])
ssl->ctx->chainOcspRequest[i] = request; ssl->ctx->chainOcspRequest[i] = request;
UnLockMutex( wc_UnLockMutex(
&ssl->ctx->cm->ocsp_stapling->ocspLock); &ssl->ctx->cm->ocsp_stapling->ocspLock);
} }

View File

@@ -49,7 +49,7 @@ int InitOCSP(WOLFSSL_OCSP* ocsp, WOLFSSL_CERT_MANAGER* cm)
ForceZero(ocsp, sizeof(WOLFSSL_OCSP)); ForceZero(ocsp, sizeof(WOLFSSL_OCSP));
if (InitMutex(&ocsp->ocspLock) != 0) if (wc_InitMutex(&ocsp->ocspLock) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
ocsp->cm = cm; ocsp->cm = cm;
@@ -102,7 +102,7 @@ void FreeOCSP(WOLFSSL_OCSP* ocsp, int dynamic)
XFREE(entry, ocsp->cm->heap, DYNAMIC_TYPE_OCSP_ENTRY); XFREE(entry, ocsp->cm->heap, DYNAMIC_TYPE_OCSP_ENTRY);
} }
FreeMutex(&ocsp->ocspLock); wc_FreeMutex(&ocsp->ocspLock);
if (dynamic) if (dynamic)
XFREE(ocsp, ocsp->cm->heap, DYNAMIC_TYPE_OCSP); XFREE(ocsp, ocsp->cm->heap, DYNAMIC_TYPE_OCSP);
@@ -167,7 +167,7 @@ static int GetOcspEntry(WOLFSSL_OCSP* ocsp, OcspRequest* request,
*entry = NULL; *entry = NULL;
if (LockMutex(&ocsp->ocspLock) != 0) { if (wc_LockMutex(&ocsp->ocspLock) != 0) {
WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E); WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E);
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -189,7 +189,7 @@ static int GetOcspEntry(WOLFSSL_OCSP* ocsp, OcspRequest* request,
} }
} }
UnLockMutex(&ocsp->ocspLock); wc_UnLockMutex(&ocsp->ocspLock);
return *entry ? 0 : MEMORY_ERROR; return *entry ? 0 : MEMORY_ERROR;
} }
@@ -204,7 +204,7 @@ static int GetOcspStatus(WOLFSSL_OCSP* ocsp, OcspRequest* request,
*status = NULL; *status = NULL;
if (LockMutex(&ocsp->ocspLock) != 0) { if (wc_LockMutex(&ocsp->ocspLock) != 0) {
WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E); WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E);
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -239,7 +239,7 @@ static int GetOcspStatus(WOLFSSL_OCSP* ocsp, OcspRequest* request,
} }
} }
UnLockMutex(&ocsp->ocspLock); wc_UnLockMutex(&ocsp->ocspLock);
return ret; return ret;
} }
@@ -346,7 +346,7 @@ int CheckOcspRequest(WOLFSSL_OCSP* ocsp, OcspRequest* ocspRequest,
ret = xstat2err(ocspResponse->status->status); ret = xstat2err(ocspResponse->status->status);
if (LockMutex(&ocsp->ocspLock) != 0) if (wc_LockMutex(&ocsp->ocspLock) != 0)
ret = BAD_MUTEX_E; ret = BAD_MUTEX_E;
else { else {
if (status != NULL) { if (status != NULL) {
@@ -383,7 +383,7 @@ int CheckOcspRequest(WOLFSSL_OCSP* ocsp, OcspRequest* ocspRequest,
} }
} }
UnLockMutex(&ocsp->ocspLock); wc_UnLockMutex(&ocsp->ocspLock);
} }
} }
else else

View File

@@ -411,9 +411,9 @@ static word32 MissedDataSessions = 0; /* # of sessions with missed data */
static void UpdateMissedDataSessions(void) static void UpdateMissedDataSessions(void)
{ {
LockMutex(&RecoveryMutex); wc_LockMutex(&RecoveryMutex);
MissedDataSessions += 1; MissedDataSessions += 1;
UnLockMutex(&RecoveryMutex); wc_UnLockMutex(&RecoveryMutex);
} }
@@ -421,9 +421,9 @@ static void UpdateMissedDataSessions(void)
void ssl_InitSniffer(void) void ssl_InitSniffer(void)
{ {
wolfSSL_Init(); wolfSSL_Init();
InitMutex(&ServerListMutex); wc_InitMutex(&ServerListMutex);
InitMutex(&SessionMutex); wc_InitMutex(&SessionMutex);
InitMutex(&RecoveryMutex); wc_InitMutex(&RecoveryMutex);
} }
@@ -461,10 +461,10 @@ static void FreeSnifferServer(SnifferServer* srv)
{ {
if (srv) { if (srv) {
#ifdef HAVE_SNI #ifdef HAVE_SNI
LockMutex(&srv->namedKeysMutex); wc_LockMutex(&srv->namedKeysMutex);
FreeNamedKeyList(srv->namedKeys); FreeNamedKeyList(srv->namedKeys);
UnLockMutex(&srv->namedKeysMutex); wc_UnLockMutex(&srv->namedKeysMutex);
FreeMutex(&srv->namedKeysMutex); wc_FreeMutex(&srv->namedKeysMutex);
#endif #endif
SSL_CTX_free(srv->ctx); SSL_CTX_free(srv->ctx);
} }
@@ -526,8 +526,8 @@ void ssl_FreeSniffer(void)
SnifferSession* removeSession; SnifferSession* removeSession;
int i; int i;
LockMutex(&ServerListMutex); wc_LockMutex(&ServerListMutex);
LockMutex(&SessionMutex); wc_LockMutex(&SessionMutex);
srv = ServerList; srv = ServerList;
while (srv) { while (srv) {
@@ -545,12 +545,12 @@ void ssl_FreeSniffer(void)
} }
} }
UnLockMutex(&SessionMutex); wc_UnLockMutex(&SessionMutex);
UnLockMutex(&ServerListMutex); wc_UnLockMutex(&ServerListMutex);
FreeMutex(&RecoveryMutex); wc_FreeMutex(&RecoveryMutex);
FreeMutex(&SessionMutex); wc_FreeMutex(&SessionMutex);
FreeMutex(&ServerListMutex); wc_FreeMutex(&ServerListMutex);
if (TraceFile) { if (TraceFile) {
TraceOn = 0; TraceOn = 0;
@@ -656,7 +656,7 @@ static void InitSnifferServer(SnifferServer* sniffer)
sniffer->port = 0; sniffer->port = 0;
#ifdef HAVE_SNI #ifdef HAVE_SNI
sniffer->namedKeys = 0; sniffer->namedKeys = 0;
InitMutex(&sniffer->namedKeysMutex); wc_InitMutex(&sniffer->namedKeysMutex);
#endif #endif
sniffer->next = 0; sniffer->next = 0;
} }
@@ -1040,7 +1040,7 @@ static int IsServerRegistered(word32 addr)
int ret = 0; /* false */ int ret = 0; /* false */
SnifferServer* sniffer; SnifferServer* sniffer;
LockMutex(&ServerListMutex); wc_LockMutex(&ServerListMutex);
sniffer = ServerList; sniffer = ServerList;
while (sniffer) { while (sniffer) {
@@ -1051,7 +1051,7 @@ static int IsServerRegistered(word32 addr)
sniffer = sniffer->next; sniffer = sniffer->next;
} }
UnLockMutex(&ServerListMutex); wc_UnLockMutex(&ServerListMutex);
return ret; return ret;
} }
@@ -1064,7 +1064,7 @@ static int IsPortRegistered(word32 port)
int ret = 0; /* false */ int ret = 0; /* false */
SnifferServer* sniffer; SnifferServer* sniffer;
LockMutex(&ServerListMutex); wc_LockMutex(&ServerListMutex);
sniffer = ServerList; sniffer = ServerList;
while (sniffer) { while (sniffer) {
@@ -1075,7 +1075,7 @@ static int IsPortRegistered(word32 port)
sniffer = sniffer->next; sniffer = sniffer->next;
} }
UnLockMutex(&ServerListMutex); wc_UnLockMutex(&ServerListMutex);
return ret; return ret;
} }
@@ -1086,7 +1086,7 @@ static SnifferServer* GetSnifferServer(IpInfo* ipInfo, TcpInfo* tcpInfo)
{ {
SnifferServer* sniffer; SnifferServer* sniffer;
LockMutex(&ServerListMutex); wc_LockMutex(&ServerListMutex);
sniffer = ServerList; sniffer = ServerList;
while (sniffer) { while (sniffer) {
@@ -1097,7 +1097,7 @@ static SnifferServer* GetSnifferServer(IpInfo* ipInfo, TcpInfo* tcpInfo)
sniffer = sniffer->next; sniffer = sniffer->next;
} }
UnLockMutex(&ServerListMutex); wc_UnLockMutex(&ServerListMutex);
return sniffer; return sniffer;
} }
@@ -1122,7 +1122,7 @@ static SnifferSession* GetSnifferSession(IpInfo* ipInfo, TcpInfo* tcpInfo)
assert(row <= HASH_SIZE); assert(row <= HASH_SIZE);
LockMutex(&SessionMutex); wc_LockMutex(&SessionMutex);
session = SessionTable[row]; session = SessionTable[row];
while (session) { while (session) {
@@ -1141,7 +1141,7 @@ static SnifferSession* GetSnifferSession(IpInfo* ipInfo, TcpInfo* tcpInfo)
if (session) if (session)
session->lastUsed= currTime; /* keep session alive, remove stale will */ session->lastUsed= currTime; /* keep session alive, remove stale will */
/* leave alone */ /* leave alone */
UnLockMutex(&SessionMutex); wc_UnLockMutex(&SessionMutex);
/* determine side */ /* determine side */
if (session) { if (session) {
@@ -1315,10 +1315,10 @@ static int SetNamedPrivateKey(const char* name, const char* address, int port,
} }
#ifdef HAVE_SNI #ifdef HAVE_SNI
else { else {
LockMutex(&sniffer->namedKeysMutex); wc_LockMutex(&sniffer->namedKeysMutex);
namedKey->next = sniffer->namedKeys; namedKey->next = sniffer->namedKeys;
sniffer->namedKeys = namedKey; sniffer->namedKeys = namedKey;
UnLockMutex(&sniffer->namedKeysMutex); wc_UnLockMutex(&sniffer->namedKeysMutex);
} }
#endif #endif
@@ -1345,10 +1345,10 @@ int ssl_SetNamedPrivateKey(const char* name,
TraceHeader(); TraceHeader();
TraceSetNamedServer(name, address, port, keyFile); TraceSetNamedServer(name, address, port, keyFile);
LockMutex(&ServerListMutex); wc_LockMutex(&ServerListMutex);
ret = SetNamedPrivateKey(name, address, port, keyFile, ret = SetNamedPrivateKey(name, address, port, keyFile,
typeKey, password, error); typeKey, password, error);
UnLockMutex(&ServerListMutex); wc_UnLockMutex(&ServerListMutex);
if (ret == 0) if (ret == 0)
Trace(NEW_SERVER_STR); Trace(NEW_SERVER_STR);
@@ -1369,10 +1369,10 @@ int ssl_SetPrivateKey(const char* address, int port, const char* keyFile,
TraceHeader(); TraceHeader();
TraceSetServer(address, port, keyFile); TraceSetServer(address, port, keyFile);
LockMutex(&ServerListMutex); wc_LockMutex(&ServerListMutex);
ret = SetNamedPrivateKey(NULL, address, port, keyFile, ret = SetNamedPrivateKey(NULL, address, port, keyFile,
typeKey, password, error); typeKey, password, error);
UnLockMutex(&ServerListMutex); wc_UnLockMutex(&ServerListMutex);
if (ret == 0) if (ret == 0)
Trace(NEW_SERVER_STR); Trace(NEW_SERVER_STR);
@@ -1824,7 +1824,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
if (nameSz >= sizeof(name)) if (nameSz >= sizeof(name))
nameSz = sizeof(name) - 1; nameSz = sizeof(name) - 1;
name[nameSz] = 0; name[nameSz] = 0;
LockMutex(&session->context->namedKeysMutex); wc_LockMutex(&session->context->namedKeysMutex);
namedKey = session->context->namedKeys; namedKey = session->context->namedKeys;
while (namedKey != NULL) { while (namedKey != NULL) {
if (nameSz == namedKey->nameSz && if (nameSz == namedKey->nameSz &&
@@ -1832,7 +1832,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
if (wolfSSL_use_PrivateKey_buffer(session->sslServer, if (wolfSSL_use_PrivateKey_buffer(session->sslServer,
namedKey->key, namedKey->keySz, namedKey->key, namedKey->keySz,
SSL_FILETYPE_ASN1) != SSL_SUCCESS) { SSL_FILETYPE_ASN1) != SSL_SUCCESS) {
UnLockMutex(&session->context->namedKeysMutex); wc_UnLockMutex(&session->context->namedKeysMutex);
SetError(CLIENT_HELLO_LATE_KEY_STR, error, session, SetError(CLIENT_HELLO_LATE_KEY_STR, error, session,
FATAL_ERROR_STATE); FATAL_ERROR_STATE);
return -1; return -1;
@@ -1842,7 +1842,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
else else
namedKey = namedKey->next; namedKey = namedKey->next;
} }
UnLockMutex(&session->context->namedKeysMutex); wc_UnLockMutex(&session->context->namedKeysMutex);
} }
} }
#endif #endif
@@ -2296,7 +2296,7 @@ static void RemoveSession(SnifferSession* session, IpInfo* ipInfo,
Trace(REMOVE_SESSION_STR); Trace(REMOVE_SESSION_STR);
if (!haveLock) if (!haveLock)
LockMutex(&SessionMutex); wc_LockMutex(&SessionMutex);
current = SessionTable[row]; current = SessionTable[row];
@@ -2315,7 +2315,7 @@ static void RemoveSession(SnifferSession* session, IpInfo* ipInfo,
} }
if (!haveLock) if (!haveLock)
UnLockMutex(&SessionMutex); wc_UnLockMutex(&SessionMutex);
} }
@@ -2406,7 +2406,7 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
row = SessionHash(ipInfo, tcpInfo); row = SessionHash(ipInfo, tcpInfo);
/* add it to the session table */ /* add it to the session table */
LockMutex(&SessionMutex); wc_LockMutex(&SessionMutex);
session->next = SessionTable[row]; session->next = SessionTable[row];
SessionTable[row] = session; SessionTable[row] = session;
@@ -2418,7 +2418,7 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
RemoveStaleSessions(); RemoveStaleSessions();
} }
UnLockMutex(&SessionMutex); wc_UnLockMutex(&SessionMutex);
/* determine headed side */ /* determine headed side */
if (ipInfo->dst == session->context->server && if (ipInfo->dst == session->context->server &&
@@ -3562,9 +3562,9 @@ int ssl_GetSessionStats(unsigned int* active, unsigned int* total,
int ret; int ret;
if (missedData) { if (missedData) {
LockMutex(&RecoveryMutex); wc_LockMutex(&RecoveryMutex);
*missedData = MissedDataSessions; *missedData = MissedDataSessions;
UnLockMutex(&RecoveryMutex); wc_UnLockMutex(&RecoveryMutex);
} }
if (reassemblyMem) { if (reassemblyMem) {
@@ -3572,7 +3572,7 @@ int ssl_GetSessionStats(unsigned int* active, unsigned int* total,
int i; int i;
*reassemblyMem = 0; *reassemblyMem = 0;
LockMutex(&SessionMutex); wc_LockMutex(&SessionMutex);
for (i = 0; i < HASH_SIZE; i++) { for (i = 0; i < HASH_SIZE; i++) {
session = SessionTable[i]; session = SessionTable[i];
while (session) { while (session) {
@@ -3581,7 +3581,7 @@ int ssl_GetSessionStats(unsigned int* active, unsigned int* total,
session = session->next; session = session->next;
} }
} }
UnLockMutex(&SessionMutex); wc_UnLockMutex(&SessionMutex);
} }
ret = wolfSSL_get_session_stats(active, total, peak, maxSessions); ret = wolfSSL_get_session_stats(active, total, peak, maxSessions);

138
src/ssl.c
View File

@@ -2270,14 +2270,14 @@ WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew_ex(void* heap)
if (cm) { if (cm) {
XMEMSET(cm, 0, sizeof(WOLFSSL_CERT_MANAGER)); XMEMSET(cm, 0, sizeof(WOLFSSL_CERT_MANAGER));
if (InitMutex(&cm->caLock) != 0) { if (wc_InitMutex(&cm->caLock) != 0) {
WOLFSSL_MSG("Bad mutex init"); WOLFSSL_MSG("Bad mutex init");
wolfSSL_CertManagerFree(cm); wolfSSL_CertManagerFree(cm);
return NULL; return NULL;
} }
#ifdef WOLFSSL_TRUST_PEER_CERT #ifdef WOLFSSL_TRUST_PEER_CERT
if (InitMutex(&cm->tpLock) != 0) { if (wc_InitMutex(&cm->tpLock) != 0) {
WOLFSSL_MSG("Bad mutex init"); WOLFSSL_MSG("Bad mutex init");
wolfSSL_CertManagerFree(cm); wolfSSL_CertManagerFree(cm);
return NULL; return NULL;
@@ -2323,11 +2323,11 @@ void wolfSSL_CertManagerFree(WOLFSSL_CERT_MANAGER* cm)
#endif #endif
#endif #endif
FreeSignerTable(cm->caTable, CA_TABLE_SIZE, cm->heap); FreeSignerTable(cm->caTable, CA_TABLE_SIZE, cm->heap);
FreeMutex(&cm->caLock); wc_FreeMutex(&cm->caLock);
#ifdef WOLFSSL_TRUST_PEER_CERT #ifdef WOLFSSL_TRUST_PEER_CERT
FreeTrustedPeerTable(cm->tpTable, TP_TABLE_SIZE, cm->heap); FreeTrustedPeerTable(cm->tpTable, TP_TABLE_SIZE, cm->heap);
FreeMutex(&cm->tpLock); wc_FreeMutex(&cm->tpLock);
#endif #endif
XFREE(cm, cm->heap, DYNAMIC_TYPE_CERT_MANAGER); XFREE(cm, cm->heap, DYNAMIC_TYPE_CERT_MANAGER);
@@ -2344,12 +2344,12 @@ int wolfSSL_CertManagerUnloadCAs(WOLFSSL_CERT_MANAGER* cm)
if (cm == NULL) if (cm == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
if (LockMutex(&cm->caLock) != 0) if (wc_LockMutex(&cm->caLock) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
FreeSignerTable(cm->caTable, CA_TABLE_SIZE, NULL); FreeSignerTable(cm->caTable, CA_TABLE_SIZE, NULL);
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return SSL_SUCCESS; return SSL_SUCCESS;
@@ -2364,12 +2364,12 @@ int wolfSSL_CertManagerUnload_trust_peers(WOLFSSL_CERT_MANAGER* cm)
if (cm == NULL) if (cm == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
if (LockMutex(&cm->tpLock) != 0) if (wc_LockMutex(&cm->tpLock) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
FreeTrustedPeerTable(cm->tpTable, TP_TABLE_SIZE, NULL); FreeTrustedPeerTable(cm->tpTable, TP_TABLE_SIZE, NULL);
UnLockMutex(&cm->tpLock); wc_UnLockMutex(&cm->tpLock);
return SSL_SUCCESS; return SSL_SUCCESS;
@@ -2777,7 +2777,7 @@ int AlreadySigner(WOLFSSL_CERT_MANAGER* cm, byte* hash)
int ret = 0; int ret = 0;
word32 row = HashSigner(hash); word32 row = HashSigner(hash);
if (LockMutex(&cm->caLock) != 0) if (wc_LockMutex(&cm->caLock) != 0)
return ret; return ret;
signers = cm->caTable[row]; signers = cm->caTable[row];
while (signers) { while (signers) {
@@ -2793,7 +2793,7 @@ int AlreadySigner(WOLFSSL_CERT_MANAGER* cm, byte* hash)
} }
signers = signers->next; signers = signers->next;
} }
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return ret; return ret;
} }
@@ -2813,7 +2813,7 @@ int AlreadyTrustedPeer(WOLFSSL_CERT_MANAGER* cm, byte* hash)
int ret = 0; int ret = 0;
word32 row = TrustedPeerHashSigner(hash); word32 row = TrustedPeerHashSigner(hash);
if (LockMutex(&cm->tpLock) != 0) if (wc_LockMutex(&cm->tpLock) != 0)
return ret; return ret;
tp = cm->tpTable[row]; tp = cm->tpTable[row];
while (tp) { while (tp) {
@@ -2829,7 +2829,7 @@ int AlreadyTrustedPeer(WOLFSSL_CERT_MANAGER* cm, byte* hash)
} }
tp = tp->next; tp = tp->next;
} }
UnLockMutex(&cm->tpLock); wc_UnLockMutex(&cm->tpLock);
return ret; return ret;
} }
@@ -2850,7 +2850,7 @@ TrustedPeerCert* GetTrustedPeer(void* vp, byte* hash, int type)
row = TrustedPeerHashSigner(hash); row = TrustedPeerHashSigner(hash);
if (LockMutex(&cm->tpLock) != 0) if (wc_LockMutex(&cm->tpLock) != 0)
return ret; return ret;
tp = cm->tpTable[row]; tp = cm->tpTable[row];
@@ -2867,7 +2867,7 @@ TrustedPeerCert* GetTrustedPeer(void* vp, byte* hash, int type)
break; break;
default: default:
WOLFSSL_MSG("Unknown search type"); WOLFSSL_MSG("Unknown search type");
UnLockMutex(&cm->tpLock); wc_UnLockMutex(&cm->tpLock);
return NULL; return NULL;
} }
if (XMEMCMP(hash, subjectHash, SIGNER_DIGEST_SIZE) == 0) { if (XMEMCMP(hash, subjectHash, SIGNER_DIGEST_SIZE) == 0) {
@@ -2876,7 +2876,7 @@ TrustedPeerCert* GetTrustedPeer(void* vp, byte* hash, int type)
} }
tp = tp->next; tp = tp->next;
} }
UnLockMutex(&cm->tpLock); wc_UnLockMutex(&cm->tpLock);
return ret; return ret;
} }
@@ -2916,7 +2916,7 @@ Signer* GetCA(void* vp, byte* hash)
if (cm == NULL) if (cm == NULL)
return NULL; return NULL;
if (LockMutex(&cm->caLock) != 0) if (wc_LockMutex(&cm->caLock) != 0)
return ret; return ret;
signers = cm->caTable[row]; signers = cm->caTable[row];
@@ -2933,7 +2933,7 @@ Signer* GetCA(void* vp, byte* hash)
} }
signers = signers->next; signers = signers->next;
} }
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return ret; return ret;
} }
@@ -2951,7 +2951,7 @@ Signer* GetCAByName(void* vp, byte* hash)
if (cm == NULL) if (cm == NULL)
return NULL; return NULL;
if (LockMutex(&cm->caLock) != 0) if (wc_LockMutex(&cm->caLock) != 0)
return ret; return ret;
for (row = 0; row < CA_TABLE_SIZE && ret == NULL; row++) { for (row = 0; row < CA_TABLE_SIZE && ret == NULL; row++) {
@@ -2964,7 +2964,7 @@ Signer* GetCAByName(void* vp, byte* hash)
signers = signers->next; signers = signers->next;
} }
} }
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return ret; return ret;
} }
@@ -3072,10 +3072,10 @@ int AddTrustedPeer(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int verify)
row = TrustedPeerHashSigner(peerCert->subjectNameHash); row = TrustedPeerHashSigner(peerCert->subjectNameHash);
#endif #endif
if (LockMutex(&cm->tpLock) == 0) { if (wc_LockMutex(&cm->tpLock) == 0) {
peerCert->next = cm->tpTable[row]; peerCert->next = cm->tpTable[row];
cm->tpTable[row] = peerCert; /* takes ownership */ cm->tpTable[row] = peerCert; /* takes ownership */
UnLockMutex(&cm->tpLock); wc_UnLockMutex(&cm->tpLock);
} }
else { else {
WOLFSSL_MSG(" Trusted Peer Cert Mutex Lock failed"); WOLFSSL_MSG(" Trusted Peer Cert Mutex Lock failed");
@@ -3218,10 +3218,10 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
row = HashSigner(signer->subjectNameHash); row = HashSigner(signer->subjectNameHash);
#endif #endif
if (LockMutex(&cm->caLock) == 0) { if (wc_LockMutex(&cm->caLock) == 0) {
signer->next = cm->caTable[row]; signer->next = cm->caTable[row];
cm->caTable[row] = signer; /* takes ownership */ cm->caTable[row] = signer; /* takes ownership */
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
if (cm->caCacheCallback) if (cm->caCacheCallback)
cm->caCacheCallback(der->buffer, (int)der->length, type); cm->caCacheCallback(der->buffer, (int)der->length, type);
} }
@@ -3331,24 +3331,24 @@ int wolfSSL_Init(void)
return WC_INIT_E; return WC_INIT_E;
} }
#ifndef NO_SESSION_CACHE #ifndef NO_SESSION_CACHE
if (InitMutex(&session_mutex) != 0) { if (wc_InitMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Bad Init Mutex session"); WOLFSSL_MSG("Bad Init Mutex session");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
#endif #endif
if (InitMutex(&count_mutex) != 0) { if (wc_InitMutex(&count_mutex) != 0) {
WOLFSSL_MSG("Bad Init Mutex count"); WOLFSSL_MSG("Bad Init Mutex count");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
} }
if (LockMutex(&count_mutex) != 0) { if (wc_LockMutex(&count_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex count"); WOLFSSL_MSG("Bad Lock Mutex count");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
initRefCount++; initRefCount++;
UnLockMutex(&count_mutex); wc_UnLockMutex(&count_mutex);
return SSL_SUCCESS; return SSL_SUCCESS;
} }
@@ -5956,7 +5956,7 @@ int wolfSSL_memsave_session_cache(void* mem, int sz)
cache_header.sessionSz = (int)sizeof(WOLFSSL_SESSION); cache_header.sessionSz = (int)sizeof(WOLFSSL_SESSION);
XMEMCPY(mem, &cache_header, sizeof(cache_header)); XMEMCPY(mem, &cache_header, sizeof(cache_header));
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Session cache mutex lock failed"); WOLFSSL_MSG("Session cache mutex lock failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -5970,7 +5970,7 @@ int wolfSSL_memsave_session_cache(void* mem, int sz)
XMEMCPY(clRow++, ClientCache + i, sizeof(ClientRow)); XMEMCPY(clRow++, ClientCache + i, sizeof(ClientRow));
#endif #endif
UnLockMutex(&session_mutex); wc_UnLockMutex(&session_mutex);
WOLFSSL_LEAVE("wolfSSL_memsave_session_cache", SSL_SUCCESS); WOLFSSL_LEAVE("wolfSSL_memsave_session_cache", SSL_SUCCESS);
@@ -6005,7 +6005,7 @@ int wolfSSL_memrestore_session_cache(const void* mem, int sz)
return CACHE_MATCH_ERROR; return CACHE_MATCH_ERROR;
} }
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Session cache mutex lock failed"); WOLFSSL_MSG("Session cache mutex lock failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -6019,7 +6019,7 @@ int wolfSSL_memrestore_session_cache(const void* mem, int sz)
XMEMCPY(ClientCache + i, clRow++, sizeof(ClientRow)); XMEMCPY(ClientCache + i, clRow++, sizeof(ClientRow));
#endif #endif
UnLockMutex(&session_mutex); wc_UnLockMutex(&session_mutex);
WOLFSSL_LEAVE("wolfSSL_memrestore_session_cache", SSL_SUCCESS); WOLFSSL_LEAVE("wolfSSL_memrestore_session_cache", SSL_SUCCESS);
@@ -6058,7 +6058,7 @@ int wolfSSL_save_session_cache(const char *fname)
return FWRITE_ERROR; return FWRITE_ERROR;
} }
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Session cache mutex lock failed"); WOLFSSL_MSG("Session cache mutex lock failed");
XFCLOSE(file); XFCLOSE(file);
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -6086,7 +6086,7 @@ int wolfSSL_save_session_cache(const char *fname)
} }
#endif /* NO_CLIENT_CACHE */ #endif /* NO_CLIENT_CACHE */
UnLockMutex(&session_mutex); wc_UnLockMutex(&session_mutex);
XFCLOSE(file); XFCLOSE(file);
WOLFSSL_LEAVE("wolfSSL_save_session_cache", rc); WOLFSSL_LEAVE("wolfSSL_save_session_cache", rc);
@@ -6129,7 +6129,7 @@ int wolfSSL_restore_session_cache(const char *fname)
return CACHE_MATCH_ERROR; return CACHE_MATCH_ERROR;
} }
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Session cache mutex lock failed"); WOLFSSL_MSG("Session cache mutex lock failed");
XFCLOSE(file); XFCLOSE(file);
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -6160,7 +6160,7 @@ int wolfSSL_restore_session_cache(const char *fname)
#endif /* NO_CLIENT_CACHE */ #endif /* NO_CLIENT_CACHE */
UnLockMutex(&session_mutex); wc_UnLockMutex(&session_mutex);
XFCLOSE(file); XFCLOSE(file);
WOLFSSL_LEAVE("wolfSSL_restore_session_cache", rc); WOLFSSL_LEAVE("wolfSSL_restore_session_cache", rc);
@@ -6497,8 +6497,8 @@ int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
return SSL_BAD_FILE; return SSL_BAD_FILE;
} }
if (LockMutex(&cm->caLock) != 0) { if (wc_LockMutex(&cm->caLock) != 0) {
WOLFSSL_MSG("LockMutex on caLock failed"); WOLFSSL_MSG("wc_LockMutex on caLock failed");
XFCLOSE(file); XFCLOSE(file);
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -6520,7 +6520,7 @@ int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
} }
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
XFCLOSE(file); XFCLOSE(file);
return rc; return rc;
@@ -6588,8 +6588,8 @@ int CM_MemSaveCertCache(WOLFSSL_CERT_MANAGER* cm, void* mem, int sz, int* used)
WOLFSSL_ENTER("CM_MemSaveCertCache"); WOLFSSL_ENTER("CM_MemSaveCertCache");
if (LockMutex(&cm->caLock) != 0) { if (wc_LockMutex(&cm->caLock) != 0) {
WOLFSSL_MSG("LockMutex on caLock failed"); WOLFSSL_MSG("wc_LockMutex on caLock failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -6597,7 +6597,7 @@ int CM_MemSaveCertCache(WOLFSSL_CERT_MANAGER* cm, void* mem, int sz, int* used)
if (ret == SSL_SUCCESS) if (ret == SSL_SUCCESS)
*used = GetCertCacheMemSize(cm); *used = GetCertCacheMemSize(cm);
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return ret; return ret;
} }
@@ -6627,8 +6627,8 @@ int CM_MemRestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const void* mem, int sz)
return CACHE_MATCH_ERROR; return CACHE_MATCH_ERROR;
} }
if (LockMutex(&cm->caLock) != 0) { if (wc_LockMutex(&cm->caLock) != 0) {
WOLFSSL_MSG("LockMutex on caLock failed"); WOLFSSL_MSG("wc_LockMutex on caLock failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -6644,7 +6644,7 @@ int CM_MemRestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const void* mem, int sz)
current += added; current += added;
} }
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return ret; return ret;
} }
@@ -6657,14 +6657,14 @@ int CM_GetCertCacheMemSize(WOLFSSL_CERT_MANAGER* cm)
WOLFSSL_ENTER("CM_GetCertCacheMemSize"); WOLFSSL_ENTER("CM_GetCertCacheMemSize");
if (LockMutex(&cm->caLock) != 0) { if (wc_LockMutex(&cm->caLock) != 0) {
WOLFSSL_MSG("LockMutex on caLock failed"); WOLFSSL_MSG("wc_LockMutex on caLock failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
sz = GetCertCacheMemSize(cm); sz = GetCertCacheMemSize(cm);
UnLockMutex(&cm->caLock); wc_UnLockMutex(&cm->caLock);
return sz; return sz;
} }
@@ -7514,7 +7514,7 @@ int wolfSSL_Cleanup(void)
if (initRefCount == 0) if (initRefCount == 0)
return ret; /* possibly no init yet, but not failure either way */ return ret; /* possibly no init yet, but not failure either way */
if (LockMutex(&count_mutex) != 0) { if (wc_LockMutex(&count_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex count"); WOLFSSL_MSG("Bad Lock Mutex count");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -7523,16 +7523,16 @@ int wolfSSL_Cleanup(void)
if (initRefCount < 0) if (initRefCount < 0)
initRefCount = 0; initRefCount = 0;
UnLockMutex(&count_mutex); wc_UnLockMutex(&count_mutex);
if (!release) if (!release)
return ret; return ret;
#ifndef NO_SESSION_CACHE #ifndef NO_SESSION_CACHE
if (FreeMutex(&session_mutex) != 0) if (wc_FreeMutex(&session_mutex) != 0)
ret = BAD_MUTEX_E; ret = BAD_MUTEX_E;
#endif #endif
if (FreeMutex(&count_mutex) != 0) if (wc_FreeMutex(&count_mutex) != 0)
ret = BAD_MUTEX_E; ret = BAD_MUTEX_E;
#if defined(HAVE_ECC) && defined(FP_ECC) #if defined(HAVE_ECC) && defined(FP_ECC)
@@ -7620,7 +7620,7 @@ WOLFSSL_SESSION* GetSessionClient(WOLFSSL* ssl, const byte* id, int len)
return NULL; return NULL;
} }
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Lock session mutex failed"); WOLFSSL_MSG("Lock session mutex failed");
return NULL; return NULL;
} }
@@ -7657,7 +7657,7 @@ WOLFSSL_SESSION* GetSessionClient(WOLFSSL* ssl, const byte* id, int len)
} }
} }
UnLockMutex(&session_mutex); wc_UnLockMutex(&session_mutex);
return ret; return ret;
} }
@@ -7699,7 +7699,7 @@ WOLFSSL_SESSION* GetSession(WOLFSSL* ssl, byte* masterSecret,
return NULL; return NULL;
} }
if (LockMutex(&session_mutex) != 0) if (wc_LockMutex(&session_mutex) != 0)
return 0; return 0;
/* start from most recently used */ /* start from most recently used */
@@ -7744,7 +7744,7 @@ WOLFSSL_SESSION* GetSession(WOLFSSL* ssl, byte* masterSecret,
} }
} }
UnLockMutex(&session_mutex); wc_UnLockMutex(&session_mutex);
return ret; return ret;
} }
@@ -7774,7 +7774,7 @@ static int GetDeepCopySession(WOLFSSL* ssl, WOLFSSL_SESSION* copyFrom)
} }
#endif #endif
if (LockMutex(&session_mutex) != 0) if (wc_LockMutex(&session_mutex) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
@@ -7791,7 +7791,7 @@ static int GetDeepCopySession(WOLFSSL* ssl, WOLFSSL_SESSION* copyFrom)
copyInto->isDynamic = 0; copyInto->isDynamic = 0;
#endif #endif
if (UnLockMutex(&session_mutex) != 0) { if (wc_UnLockMutex(&session_mutex) != 0) {
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -7803,7 +7803,7 @@ static int GetDeepCopySession(WOLFSSL* ssl, WOLFSSL_SESSION* copyFrom)
if (!tmpBuff) if (!tmpBuff)
return MEMORY_ERROR; return MEMORY_ERROR;
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
XFREE(tmpBuff, ssl->heap, DYNAMIC_TYPE_SESSION_TICK); XFREE(tmpBuff, ssl->heap, DYNAMIC_TYPE_SESSION_TICK);
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -7825,7 +7825,7 @@ static int GetDeepCopySession(WOLFSSL* ssl, WOLFSSL_SESSION* copyFrom)
copyInto->ticket = copyInto->staticTicket; copyInto->ticket = copyInto->staticTicket;
} }
if (UnLockMutex(&session_mutex) != 0) { if (wc_UnLockMutex(&session_mutex) != 0) {
if (ret == SSL_SUCCESS) if (ret == SSL_SUCCESS)
ret = BAD_MUTEX_E; ret = BAD_MUTEX_E;
} }
@@ -7907,7 +7907,7 @@ int AddSession(WOLFSSL* ssl)
} }
#endif #endif
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
XFREE(tmpBuff, ssl->heap, DYNAMIC_TYPE_SESSION_TICK); XFREE(tmpBuff, ssl->heap, DYNAMIC_TYPE_SESSION_TICK);
#endif #endif
@@ -8033,7 +8033,7 @@ int AddSession(WOLFSSL* ssl)
} }
#endif /* defined(WOLFSSL_SESSION_STATS) && defined(WOLFSSL_PEAK_SESSIONS) */ #endif /* defined(WOLFSSL_SESSION_STATS) && defined(WOLFSSL_PEAK_SESSIONS) */
if (UnLockMutex(&session_mutex) != 0) if (wc_UnLockMutex(&session_mutex) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
return error; return error;
@@ -8059,7 +8059,7 @@ int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session)
row = idx >> SESSIDX_ROW_SHIFT; row = idx >> SESSIDX_ROW_SHIFT;
col = idx & SESSIDX_IDX_MASK; col = idx & SESSIDX_IDX_MASK;
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -8070,7 +8070,7 @@ int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session)
result = SSL_SUCCESS; result = SSL_SUCCESS;
} }
if (UnLockMutex(&session_mutex) != 0) if (wc_UnLockMutex(&session_mutex) != 0)
result = BAD_MUTEX_E; result = BAD_MUTEX_E;
WOLFSSL_LEAVE("wolfSSL_GetSessionAtIndex", result); WOLFSSL_LEAVE("wolfSSL_GetSessionAtIndex", result);
@@ -8174,13 +8174,13 @@ int wolfSSL_get_session_stats(word32* active, word32* total, word32* peak,
if (active == NULL && total == NULL && peak == NULL) if (active == NULL && total == NULL && peak == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
if (LockMutex(&session_mutex) != 0) { if (wc_LockMutex(&session_mutex) != 0) {
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
result = get_locked_session_stats(active, total, peak); result = get_locked_session_stats(active, total, peak);
if (UnLockMutex(&session_mutex) != 0) if (wc_UnLockMutex(&session_mutex) != 0)
result = BAD_MUTEX_E; result = BAD_MUTEX_E;
WOLFSSL_LEAVE("wolfSSL_get_session_stats", result); WOLFSSL_LEAVE("wolfSSL_get_session_stats", result);
@@ -13964,6 +13964,7 @@ static void InitwolfSSL_DH(WOLFSSL_DH* dh)
if (dh) { if (dh) {
dh->p = NULL; dh->p = NULL;
dh->g = NULL; dh->g = NULL;
dh->q = NULL;
dh->pub_key = NULL; dh->pub_key = NULL;
dh->priv_key = NULL; dh->priv_key = NULL;
dh->internal = NULL; dh->internal = NULL;
@@ -14016,6 +14017,7 @@ void wolfSSL_DH_free(WOLFSSL_DH* dh)
wolfSSL_BN_free(dh->pub_key); wolfSSL_BN_free(dh->pub_key);
wolfSSL_BN_free(dh->g); wolfSSL_BN_free(dh->g);
wolfSSL_BN_free(dh->p); wolfSSL_BN_free(dh->p);
wolfSSL_BN_free(dh->q);
InitwolfSSL_DH(dh); /* set back to NULLs for safety */ InitwolfSSL_DH(dh); /* set back to NULLs for safety */
XFREE(dh, NULL, DYNAMIC_TYPE_DH); XFREE(dh, NULL, DYNAMIC_TYPE_DH);
@@ -17959,7 +17961,7 @@ void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl)
#ifdef OPENSSL_EXTRA /*Lighttp compatibility*/ #ifdef OPENSSL_EXTRA /*Lighttp compatibility*/
#if defined(HAVE_LIGHTY) || defined(WOLFSSL_MYSQL_COMPATIBLE) #if defined(HAVE_LIGHTY) || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(HAVE_STUNNEL)
unsigned char *wolfSSL_SHA1(const unsigned char *d, size_t n, unsigned char *md) unsigned char *wolfSSL_SHA1(const unsigned char *d, size_t n, unsigned char *md)
{ {
@@ -18149,7 +18151,7 @@ void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl)
return NULL; return NULL;
} }
#endif /* HAVE_LIGHTY || WOLFSSL_MYSQL_COMPATIBLE */ #endif /* HAVE_LIGHTY || WOLFSSL_MYSQL_COMPATIBLE || HAVE_STUNNEL */
#endif #endif
@@ -18556,7 +18558,7 @@ int wolfSSL_get_state(const WOLFSSL* ssl)
} }
void* wolfSSL_sk_X509_NAME_value(STACK_OF(WOLFSSL_X509_NAME)* sk, int i) void* wolfSSL_sk_X509_NAME_value(const STACK_OF(WOLFSSL_X509_NAME)* sk, int i)
{ {
(void)sk; (void)sk;
(void)i; (void)i;

View File

@@ -4234,12 +4234,12 @@ static word32 GetEntropy(unsigned char* out, word32 num_bytes)
if ((rngMutex = (wolfSSL_Mutex*)XMALLOC(sizeof(wolfSSL_Mutex), NULL, if ((rngMutex = (wolfSSL_Mutex*)XMALLOC(sizeof(wolfSSL_Mutex), NULL,
DYNAMIC_TYPE_TLSX)) == NULL) DYNAMIC_TYPE_TLSX)) == NULL)
return DRBG_OUT_OF_MEMORY; return DRBG_OUT_OF_MEMORY;
InitMutex(rngMutex); wc_InitMutex(rngMutex);
} }
ret |= LockMutex(rngMutex); ret |= wc_LockMutex(rngMutex);
ret |= wc_RNG_GenerateBlock(rng, out, num_bytes); ret |= wc_RNG_GenerateBlock(rng, out, num_bytes);
ret |= UnLockMutex(rngMutex); ret |= wc_UnLockMutex(rngMutex);
if (ret != 0) if (ret != 0)
return DRBG_ENTROPY_FAIL; return DRBG_ENTROPY_FAIL;

View File

@@ -1574,7 +1574,7 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
#warning "Allocate non-Cache buffers" #warning "Allocate non-Cache buffers"
#endif #endif
InitMutex(&Mutex_AesSEC); wc_InitMutex(&Mutex_AesSEC);
} }
if (!((keylen == 16) || (keylen == 24) || (keylen == 32))) if (!((keylen == 16) || (keylen == 24) || (keylen == 32)))
@@ -2165,7 +2165,7 @@ int wc_InitAes_h(Aes* aes, void* h)
if ((pi == NULL) || (po == NULL)) if ((pi == NULL) || (po == NULL))
return BAD_FUNC_ARG; /*wrong pointer*/ return BAD_FUNC_ARG; /*wrong pointer*/
LockMutex(&Mutex_AesSEC); wc_LockMutex(&Mutex_AesSEC);
/* Set descriptor for SEC */ /* Set descriptor for SEC */
secDesc->length1 = 0x0; secDesc->length1 = 0x0;
@@ -2241,7 +2241,7 @@ int wc_InitAes_h(Aes* aes, void* h)
po += size; po += size;
} }
UnLockMutex(&Mutex_AesSEC); wc_UnLockMutex(&Mutex_AesSEC);
return 0; return 0;
} }

View File

@@ -396,7 +396,7 @@ static void wc_Des_Cbc(byte* out, const byte* in, word32 sz,
int size ; int size ;
volatile int v ; volatile int v ;
LockMutex(&Mutex_DesSEC) ; wc_LockMutex(&Mutex_DesSEC) ;
secDesc->length1 = 0x0; secDesc->length1 = 0x0;
secDesc->pointer1 = NULL; secDesc->pointer1 = NULL;
@@ -464,7 +464,7 @@ static void wc_Des_Cbc(byte* out, const byte* in, word32 sz,
out += size ; out += size ;
} }
UnLockMutex(&Mutex_DesSEC) ; wc_UnLockMutex(&Mutex_DesSEC) ;
} }
@@ -532,7 +532,7 @@ int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
#warning "Allocate non-Cache buffers" #warning "Allocate non-Cache buffers"
#endif #endif
InitMutex(&Mutex_DesSEC) ; wc_InitMutex(&Mutex_DesSEC) ;
} }
XMEMCPY(des->key, key, DES_KEYLEN); XMEMCPY(des->key, key, DES_KEYLEN);
@@ -562,7 +562,7 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
#warning "Allocate non-Cache buffers" #warning "Allocate non-Cache buffers"
#endif #endif
InitMutex(&Mutex_DesSEC) ; wc_InitMutex(&Mutex_DesSEC) ;
} }
XMEMCPY(des3->key[0], key, DES3_KEYLEN); XMEMCPY(des3->key[0], key, DES3_KEYLEN);

View File

@@ -5494,10 +5494,10 @@ int ecc_mul2add(ecc_point* A, mp_int* kA,
#ifndef HAVE_THREAD_LS #ifndef HAVE_THREAD_LS
if (initMutex == 0) { if (initMutex == 0) {
InitMutex(&ecc_fp_lock); wc_InitMutex(&ecc_fp_lock);
initMutex = 1; initMutex = 1;
} }
if (LockMutex(&ecc_fp_lock) != 0) if (wc_LockMutex(&ecc_fp_lock) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
#endif /* HAVE_THREAD_LS */ #endif /* HAVE_THREAD_LS */
@@ -5585,7 +5585,7 @@ int ecc_mul2add(ecc_point* A, mp_int* kA,
} }
#ifndef HAVE_THREAD_LS #ifndef HAVE_THREAD_LS
UnLockMutex(&ecc_fp_lock); wc_UnLockMutex(&ecc_fp_lock);
#endif /* HAVE_THREAD_LS */ #endif /* HAVE_THREAD_LS */
#ifndef USE_FAST_MATH #ifndef USE_FAST_MATH
mp_clear(&mu); mp_clear(&mu);
@@ -5634,11 +5634,11 @@ int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
#ifndef HAVE_THREAD_LS #ifndef HAVE_THREAD_LS
if (initMutex == 0) { if (initMutex == 0) {
InitMutex(&ecc_fp_lock); wc_InitMutex(&ecc_fp_lock);
initMutex = 1; initMutex = 1;
} }
if (LockMutex(&ecc_fp_lock) != 0) if (wc_LockMutex(&ecc_fp_lock) != 0)
return BAD_MUTEX_E; return BAD_MUTEX_E;
#endif /* HAVE_THREAD_LS */ #endif /* HAVE_THREAD_LS */
@@ -5691,7 +5691,7 @@ int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
} }
#ifndef HAVE_THREAD_LS #ifndef HAVE_THREAD_LS
UnLockMutex(&ecc_fp_lock); wc_UnLockMutex(&ecc_fp_lock);
#endif /* HAVE_THREAD_LS */ #endif /* HAVE_THREAD_LS */
#ifndef USE_FAST_MATH #ifndef USE_FAST_MATH
mp_clear(&mu); mp_clear(&mu);
@@ -5725,18 +5725,18 @@ void wc_ecc_fp_free(void)
{ {
#ifndef HAVE_THREAD_LS #ifndef HAVE_THREAD_LS
if (initMutex == 0) { if (initMutex == 0) {
InitMutex(&ecc_fp_lock); wc_InitMutex(&ecc_fp_lock);
initMutex = 1; initMutex = 1;
} }
if (LockMutex(&ecc_fp_lock) == 0) { if (wc_LockMutex(&ecc_fp_lock) == 0) {
#endif /* HAVE_THREAD_LS */ #endif /* HAVE_THREAD_LS */
wc_ecc_fp_free_cache(); wc_ecc_fp_free_cache();
#ifndef HAVE_THREAD_LS #ifndef HAVE_THREAD_LS
UnLockMutex(&ecc_fp_lock); wc_UnLockMutex(&ecc_fp_lock);
FreeMutex(&ecc_fp_lock); wc_FreeMutex(&ecc_fp_lock);
initMutex = 0; initMutex = 0;
} }
#endif /* HAVE_THREAD_LS */ #endif /* HAVE_THREAD_LS */

View File

@@ -210,7 +210,7 @@ int wolfSSL_init_memory_heap(WOLFSSL_HEAP* heap)
XMEMCPY(heap->sizeList, wc_MemSz, sizeof(wc_MemSz)); XMEMCPY(heap->sizeList, wc_MemSz, sizeof(wc_MemSz));
XMEMCPY(heap->distList, wc_Dist, sizeof(wc_Dist)); XMEMCPY(heap->distList, wc_Dist, sizeof(wc_Dist));
if (InitMutex(&(heap->memory_mutex)) != 0) { if (wc_InitMutex(&(heap->memory_mutex)) != 0) {
WOLFSSL_MSG("Error creating heap memory mutex"); WOLFSSL_MSG("Error creating heap memory mutex");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -524,7 +524,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)heap; WOLFSSL_HEAP_HINT* hint = (WOLFSSL_HEAP_HINT*)heap;
WOLFSSL_HEAP* mem = hint->memory; WOLFSSL_HEAP* mem = hint->memory;
if (LockMutex(&(mem->memory_mutex)) != 0) { if (wc_LockMutex(&(mem->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
return NULL; return NULL;
} }
@@ -591,7 +591,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
WOLFSSL_MSG("ERROR ran out of static memory"); WOLFSSL_MSG("ERROR ran out of static memory");
} }
UnLockMutex(&(mem->memory_mutex)); wc_UnLockMutex(&(mem->memory_mutex));
} }
#ifdef WOLFSSL_MALLOC_CHECK #ifdef WOLFSSL_MALLOC_CHECK
@@ -651,7 +651,7 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
/* get memory struct and add it to available list */ /* get memory struct and add it to available list */
pt = (wc_Memory*)((byte*)ptr - sizeof(wc_Memory) - padSz); pt = (wc_Memory*)((byte*)ptr - sizeof(wc_Memory) - padSz);
if (LockMutex(&(mem->memory_mutex)) != 0) { if (wc_LockMutex(&(mem->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
return; return;
} }
@@ -703,7 +703,7 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
stats->totalFr++; stats->totalFr++;
} }
} }
UnLockMutex(&(mem->memory_mutex)); wc_UnLockMutex(&(mem->memory_mutex));
} }
} }
@@ -745,7 +745,7 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
WOLFSSL_HEAP* mem = hint->memory; WOLFSSL_HEAP* mem = hint->memory;
word32 padSz = -(int)sizeof(wc_Memory) & (WOLFSSL_STATIC_ALIGN - 1); word32 padSz = -(int)sizeof(wc_Memory) & (WOLFSSL_STATIC_ALIGN - 1);
if (LockMutex(&(mem->memory_mutex)) != 0) { if (wc_LockMutex(&(mem->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
return NULL; return NULL;
} }
@@ -786,19 +786,19 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
mem->alloc += 1; mem->alloc += 1;
/* free memory that was previously being used */ /* free memory that was previously being used */
UnLockMutex(&(mem->memory_mutex)); wc_UnLockMutex(&(mem->memory_mutex));
wolfSSL_Free(ptr, heap, type wolfSSL_Free(ptr, heap, type
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
, func, line , func, line
#endif #endif
); );
if (LockMutex(&(mem->memory_mutex)) != 0) { if (wc_LockMutex(&(mem->memory_mutex)) != 0) {
WOLFSSL_MSG("Bad memory_mutex lock"); WOLFSSL_MSG("Bad memory_mutex lock");
return NULL; return NULL;
} }
} }
} }
UnLockMutex(&(mem->memory_mutex)); wc_UnLockMutex(&(mem->memory_mutex));
} }
#ifdef WOLFSSL_MALLOC_CHECK #ifdef WOLFSSL_MALLOC_CHECK

View File

@@ -64,7 +64,7 @@ int wolfSSL_TI_CCMInit(void)
WAIT(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0)) ; WAIT(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0)) ;
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
if(InitMutex(&TI_CCM_Mutex))return false ; if(wc_InitMutex(&TI_CCM_Mutex))return false ;
#endif #endif
return true ; return true ;
@@ -72,11 +72,11 @@ int wolfSSL_TI_CCMInit(void)
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
void wolfSSL_TI_lockCCM(void) { void wolfSSL_TI_lockCCM(void) {
LockMutex(&TI_CCM_Mutex) ; wc_LockMutex(&TI_CCM_Mutex) ;
} }
void wolfSSL_TI_unlockCCM(void) { void wolfSSL_TI_unlockCCM(void) {
UnLockMutex(&TI_CCM_Mutex) ; wc_UnLockMutex(&TI_CCM_Mutex) ;
} }
#endif #endif

View File

@@ -896,13 +896,13 @@ int wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout)
return 0; return 0;
} }
if (InitMutex(&wnr_mutex) != 0) { if (wc_InitMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Init Mutex wnr_mutex"); WOLFSSL_MSG("Bad Init Mutex wnr_mutex");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
wnr_mutex_init = 1; wnr_mutex_init = 1;
if (LockMutex(&wnr_mutex) != 0) { if (wc_LockMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex wnr_mutex"); WOLFSSL_MSG("Bad Lock Mutex wnr_mutex");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -942,7 +942,7 @@ int wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout)
return RNG_FAILURE_E; return RNG_FAILURE_E;
} }
UnLockMutex(&wnr_mutex); wc_UnLockMutex(&wnr_mutex);
return 0; return 0;
} }
@@ -955,7 +955,7 @@ int wc_FreeNetRandom(void)
{ {
if (wnr_mutex_init > 0) { if (wnr_mutex_init > 0) {
if (LockMutex(&wnr_mutex) != 0) { if (wc_LockMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex wnr_mutex"); WOLFSSL_MSG("Bad Lock Mutex wnr_mutex");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -966,9 +966,9 @@ int wc_FreeNetRandom(void)
} }
wnr_poll_destroy(); wnr_poll_destroy();
UnLockMutex(&wnr_mutex); wc_UnLockMutex(&wnr_mutex);
FreeMutex(&wnr_mutex); wc_FreeMutex(&wnr_mutex);
wnr_mutex_init = 0; wnr_mutex_init = 0;
} }
@@ -1539,7 +1539,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
return RNG_FAILURE_E; return RNG_FAILURE_E;
} }
if (LockMutex(&wnr_mutex) != 0) { if (wc_LockMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex wnr_mutex\n"); WOLFSSL_MSG("Bad Lock Mutex wnr_mutex\n");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@@ -1548,7 +1548,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
WNR_ERROR_NONE) WNR_ERROR_NONE)
return RNG_FAILURE_E; return RNG_FAILURE_E;
UnLockMutex(&wnr_mutex); wc_UnLockMutex(&wnr_mutex);
return 0; return 0;
} }

View File

@@ -79,6 +79,16 @@ int wolfCrypt_Init()
return ret; return ret;
} }
wolfSSL_Mutex* wc_InitAndAllocMutex()
{
wolfSSL_Mutex* m = (wolfSSL_Mutex*) XMALLOC(sizeof(wolfSSL_Mutex), NULL,
DYNAMIC_TYPE_MUTEX);
if(m && wc_InitMutex(m))
return m;
XFREE(m, NULL, DYNAMIC_TYPE_MUTEX);
m = NULL;
return m;
}
#if WOLFSSL_CRYPT_HW_MUTEX #if WOLFSSL_CRYPT_HW_MUTEX
/* Mutex for protection of cryptography hardware */ /* Mutex for protection of cryptography hardware */
@@ -88,7 +98,7 @@ static int wcCryptHwMutexInit = 0;
int wolfSSL_CryptHwMutexInit(void) { int wolfSSL_CryptHwMutexInit(void) {
int ret = 0; int ret = 0;
if(wcCryptHwMutexInit == 0) { if(wcCryptHwMutexInit == 0) {
ret = InitMutex(&wcCryptHwMutex); ret = wc_InitMutex(&wcCryptHwMutex);
if(ret == 0) { if(ret == 0) {
wcCryptHwMutexInit = 1; wcCryptHwMutexInit = 1;
} }
@@ -103,16 +113,16 @@ int wolfSSL_CryptHwMutexLock(void) {
wolfSSL_CryptHwMutexInit(); wolfSSL_CryptHwMutexInit();
if(wcCryptHwMutexInit) { if(wcCryptHwMutexInit) {
ret = LockMutex(&wcCryptHwMutex); ret = wc_LockMutex(&wcCryptHwMutex);
} }
return ret; return ret;
} }
int wolfSSL_CryptHwMutexUnLock(void) { int wolfSSL_CryptHwMutexUnLock(void) {
int ret = BAD_MUTEX_E; int ret = BAD_MUTEX_E;
if(wcCryptHwMutexInit) { if(wcCryptHwMutexInit) {
ret = UnLockMutex(&wcCryptHwMutex); ret = wc_UnLockMutex(&wcCryptHwMutex);
} }
return ret; return ret;
} }
@@ -121,28 +131,27 @@ int wolfSSL_CryptHwMutexUnLock(void) {
#ifdef SINGLE_THREADED #ifdef SINGLE_THREADED
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{
(void)m;
return 0;
}
int wc_FreeMutex(wolfSSL_Mutex *m)
{ {
(void)m; (void)m;
return 0; return 0;
} }
int FreeMutex(wolfSSL_Mutex *m) int wc_LockMutex(wolfSSL_Mutex *m)
{ {
(void)m; (void)m;
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex *m) int wc_UnLockMutex(wolfSSL_Mutex *m)
{
(void)m;
return 0;
}
int UnLockMutex(wolfSSL_Mutex *m)
{ {
(void)m; (void)m;
return 0; return 0;
@@ -153,7 +162,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#if defined(FREERTOS) || defined(FREERTOS_TCP) || \ #if defined(FREERTOS) || defined(FREERTOS_TCP) || \
defined(FREESCALE_FREE_RTOS) defined(FREESCALE_FREE_RTOS)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
int iReturn; int iReturn;
@@ -166,20 +175,21 @@ int UnLockMutex(wolfSSL_Mutex *m)
return iReturn; return iReturn;
} }
int FreeMutex(wolfSSL_Mutex* m)
int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
vSemaphoreDelete( *m ); vSemaphoreDelete( *m );
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
/* Assume an infinite block, or should there be zero block? */ /* Assume an infinite block, or should there be zero block? */
xSemaphoreTake( *m, portMAX_DELAY ); xSemaphoreTake( *m, portMAX_DELAY );
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
xSemaphoreGive( *m ); xSemaphoreGive( *m );
return 0; return 0;
@@ -187,7 +197,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(WOLFSSL_SAFERTOS) #elif defined(WOLFSSL_SAFERTOS)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
vSemaphoreCreateBinary(m->mutexBuffer, m->mutex); vSemaphoreCreateBinary(m->mutexBuffer, m->mutex);
if (m->mutex == NULL) if (m->mutex == NULL)
@@ -196,20 +206,20 @@ int UnLockMutex(wolfSSL_Mutex *m)
return 0; return 0;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
(void)m; (void)m;
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
/* Assume an infinite block */ /* Assume an infinite block */
xSemaphoreTake(m->mutex, portMAX_DELAY); xSemaphoreTake(m->mutex, portMAX_DELAY);
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
xSemaphoreGive(m->mutex); xSemaphoreGive(m->mutex);
return 0; return 0;
@@ -218,28 +228,28 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(USE_WINDOWS_API) #elif defined(USE_WINDOWS_API)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
InitializeCriticalSection(m); InitializeCriticalSection(m);
return 0; return 0;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
DeleteCriticalSection(m); DeleteCriticalSection(m);
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
EnterCriticalSection(m); EnterCriticalSection(m);
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
LeaveCriticalSection(m); LeaveCriticalSection(m);
return 0; return 0;
@@ -247,7 +257,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(WOLFSSL_PTHREADS) #elif defined(WOLFSSL_PTHREADS)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
if (pthread_mutex_init(m, 0) == 0) if (pthread_mutex_init(m, 0) == 0)
return 0; return 0;
@@ -256,7 +266,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
if (pthread_mutex_destroy(m) == 0) if (pthread_mutex_destroy(m) == 0)
return 0; return 0;
@@ -265,7 +275,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
if (pthread_mutex_lock(m) == 0) if (pthread_mutex_lock(m) == 0)
return 0; return 0;
@@ -274,7 +284,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
if (pthread_mutex_unlock(m) == 0) if (pthread_mutex_unlock(m) == 0)
return 0; return 0;
@@ -284,7 +294,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(THREADX) #elif defined(THREADX)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
if (tx_mutex_create(m, "wolfSSL Mutex", TX_NO_INHERIT) == 0) if (tx_mutex_create(m, "wolfSSL Mutex", TX_NO_INHERIT) == 0)
return 0; return 0;
@@ -293,7 +303,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
if (tx_mutex_delete(m) == 0) if (tx_mutex_delete(m) == 0)
return 0; return 0;
@@ -302,7 +312,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
if (tx_mutex_get(m, TX_WAIT_FOREVER) == 0) if (tx_mutex_get(m, TX_WAIT_FOREVER) == 0)
return 0; return 0;
@@ -311,7 +321,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
if (tx_mutex_put(m) == 0) if (tx_mutex_put(m) == 0)
return 0; return 0;
@@ -321,7 +331,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(MICRIUM) #elif defined(MICRIUM)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED) #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
if (NetSecure_OS_MutexCreate(m) == 0) if (NetSecure_OS_MutexCreate(m) == 0)
@@ -334,10 +344,10 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED) #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
if (NetSecure_OS_FreeMutex(m) == 0) if (NetSecure_OS_wc_FreeMutex(m) == 0)
return 0; return 0;
else else
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -347,10 +357,10 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED) #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
if (NetSecure_OS_LockMutex(m) == 0) if (NetSecure_OS_wc_LockMutex(m) == 0)
return 0; return 0;
else else
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -360,10 +370,10 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED) #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
if (NetSecure_OS_UnLockMutex(m) == 0) if (NetSecure_OS_wc_UnLockMutex(m) == 0)
return 0; return 0;
else else
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -375,7 +385,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(EBSNET) #elif defined(EBSNET)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
if (rtp_sig_mutex_alloc(m, "wolfSSL Mutex") == -1) if (rtp_sig_mutex_alloc(m, "wolfSSL Mutex") == -1)
return BAD_MUTEX_E; return BAD_MUTEX_E;
@@ -383,13 +393,13 @@ int UnLockMutex(wolfSSL_Mutex *m)
return 0; return 0;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
rtp_sig_mutex_free(*m); rtp_sig_mutex_free(*m);
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
if (rtp_sig_mutex_claim_timed(*m, RTIP_INF) == 0) if (rtp_sig_mutex_claim_timed(*m, RTIP_INF) == 0)
return 0; return 0;
@@ -397,7 +407,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
rtp_sig_mutex_release(*m); rtp_sig_mutex_release(*m);
return 0; return 0;
@@ -405,7 +415,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
if (_mutex_init(m, NULL) == MQX_EOK) if (_mutex_init(m, NULL) == MQX_EOK)
return 0; return 0;
@@ -413,7 +423,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
if (_mutex_destroy(m) == MQX_EOK) if (_mutex_destroy(m) == MQX_EOK)
return 0; return 0;
@@ -421,7 +431,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
if (_mutex_lock(m) == MQX_EOK) if (_mutex_lock(m) == MQX_EOK)
return 0; return 0;
@@ -429,7 +439,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
if (_mutex_unlock(m) == MQX_EOK) if (_mutex_unlock(m) == MQX_EOK)
return 0; return 0;
@@ -439,7 +449,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined (WOLFSSL_TIRTOS) #elif defined (WOLFSSL_TIRTOS)
#include <xdc/runtime/Error.h> #include <xdc/runtime/Error.h>
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
Semaphore_Params params; Semaphore_Params params;
Error_Block eb; Error_Block eb;
@@ -454,21 +464,21 @@ int UnLockMutex(wolfSSL_Mutex *m)
} else return 0; } else return 0;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
Semaphore_delete(m); Semaphore_delete(m);
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
Semaphore_pend(*m, BIOS_WAIT_FOREVER); Semaphore_pend(*m, BIOS_WAIT_FOREVER);
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
Semaphore_post(*m); Semaphore_post(*m);
@@ -478,7 +488,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(WOLFSSL_uITRON4) #elif defined(WOLFSSL_uITRON4)
#include "stddef.h" #include "stddef.h"
#include "kernel.h" #include "kernel.h"
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
int iReturn; int iReturn;
m->sem.sematr = TA_TFIFO ; m->sem.sematr = TA_TFIFO ;
@@ -495,19 +505,19 @@ int UnLockMutex(wolfSSL_Mutex *m)
return iReturn; return iReturn;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
del_sem( m->id ); del_sem( m->id );
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
wai_sem(m->id); wai_sem(m->id);
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
sig_sem(m->id); sig_sem(m->id);
return 0; return 0;
@@ -568,7 +578,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
#elif defined(WOLFSSL_uTKERNEL2) #elif defined(WOLFSSL_uTKERNEL2)
#include "tk/tkernel.h" #include "tk/tkernel.h"
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
int iReturn; int iReturn;
m->sem.sematr = TA_TFIFO ; m->sem.sematr = TA_TFIFO ;
@@ -584,19 +594,19 @@ int UnLockMutex(wolfSSL_Mutex *m)
return iReturn; return iReturn;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
tk_del_sem( m->id ); tk_del_sem( m->id );
return 0; return 0;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
tk_wai_sem(m->id, 1, TMO_FEVR); tk_wai_sem(m->id, 1, TMO_FEVR);
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
tk_sig_sem(m->id, 1); tk_sig_sem(m->id, 1);
return 0; return 0;
@@ -657,7 +667,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
} }
#elif defined (WOLFSSL_FROSTED) #elif defined (WOLFSSL_FROSTED)
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
*m = mutex_init(); *m = mutex_init();
if (*m) if (*m)
@@ -666,19 +676,19 @@ int UnLockMutex(wolfSSL_Mutex *m)
return -1; return -1;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
mutex_destroy(*m); mutex_destroy(*m);
return(0) ; return(0) ;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
mutex_lock(*m); mutex_lock(*m);
return 0; return 0;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
mutex_unlock(*m); mutex_unlock(*m);
return 0; return 0;
@@ -700,7 +710,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0} ; static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0} ;
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
int i ; int i ;
for (i=0; i<CMSIS_NMUTEX; i++) { for (i=0; i<CMSIS_NMUTEX; i++) {
@@ -713,7 +723,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
return -1 ; return -1 ;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
int i ; int i ;
osMutexDelete (*m) ; osMutexDelete (*m) ;
@@ -725,37 +735,37 @@ int UnLockMutex(wolfSSL_Mutex *m)
} }
return(-1) ; return(-1) ;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
osMutexWait(*m, osWaitForever) ; osMutexWait(*m, osWaitForever) ;
return(0) ; return(0) ;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
osMutexRelease (*m); osMutexRelease (*m);
return 0; return 0;
} }
#else #else
int InitMutex(wolfSSL_Mutex* m) int wc_InitMutex(wolfSSL_Mutex* m)
{ {
os_mut_init (m); os_mut_init (m);
return 0; return 0;
} }
int FreeMutex(wolfSSL_Mutex* m) int wc_FreeMutex(wolfSSL_Mutex* m)
{ {
return(0) ; return(0) ;
} }
int LockMutex(wolfSSL_Mutex* m) int wc_LockMutex(wolfSSL_Mutex* m)
{ {
os_mut_wait (m, 0xffff); os_mut_wait (m, 0xffff);
return(0) ; return(0) ;
} }
int UnLockMutex(wolfSSL_Mutex* m) int wc_UnLockMutex(wolfSSL_Mutex* m)
{ {
os_mut_release (m); os_mut_release (m);
return 0; return 0;

View File

@@ -79,7 +79,7 @@ int wolfEventQueue_Init(WOLF_EVENT_QUEUE* queue)
XMEMSET(queue, 0, sizeof(WOLF_EVENT_QUEUE)); XMEMSET(queue, 0, sizeof(WOLF_EVENT_QUEUE));
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
ret = InitMutex(&queue->lock); ret = wc_InitMutex(&queue->lock);
#endif #endif
return ret; return ret;
} }
@@ -94,7 +94,7 @@ int wolfEventQueue_Push(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event)
} }
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
if ((ret = LockMutex(&queue->lock)) != 0) { if ((ret = wc_LockMutex(&queue->lock)) != 0) {
return ret; return ret;
} }
#endif #endif
@@ -115,7 +115,7 @@ int wolfEventQueue_Push(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event)
ret = 0; ret = 0;
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
UnLockMutex(&queue->lock); wc_UnLockMutex(&queue->lock);
#endif #endif
return ret; return ret;
@@ -131,7 +131,7 @@ int wolfEventQueue_Pop(WOLF_EVENT_QUEUE* queue, WOLF_EVENT** event)
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
/* In single threaded mode "event_queue.lock" doesn't exist */ /* In single threaded mode "event_queue.lock" doesn't exist */
if ((ret = LockMutex(&queue->lock)) != 0) { if ((ret = wc_LockMutex(&queue->lock)) != 0) {
return ret; return ret;
} }
#endif #endif
@@ -141,7 +141,7 @@ int wolfEventQueue_Pop(WOLF_EVENT_QUEUE* queue, WOLF_EVENT** event)
ret = wolfEventQueue_Remove(queue, *event); ret = wolfEventQueue_Remove(queue, *event);
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
UnLockMutex(&queue->lock); wc_UnLockMutex(&queue->lock);
#endif #endif
return ret; return ret;
@@ -191,7 +191,7 @@ int wolfEventQueue_Poll(WOLF_EVENT_QUEUE* queue, void* context_filter,
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
/* In single threaded mode "event_queue.lock" doesn't exist */ /* In single threaded mode "event_queue.lock" doesn't exist */
if ((ret = LockMutex(&queue->lock)) != 0) { if ((ret = wc_LockMutex(&queue->lock)) != 0) {
return ret; return ret;
} }
#endif #endif
@@ -227,7 +227,7 @@ int wolfEventQueue_Poll(WOLF_EVENT_QUEUE* queue, void* context_filter,
} }
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
UnLockMutex(&queue->lock); wc_UnLockMutex(&queue->lock);
#endif #endif
/* return number of properly populated events */ /* return number of properly populated events */
@@ -248,7 +248,7 @@ int wolfEventQueue_Count(WOLF_EVENT_QUEUE* queue)
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
/* In single threaded mode "event_queue.lock" doesn't exist */ /* In single threaded mode "event_queue.lock" doesn't exist */
if ((ret = LockMutex(&queue->lock)) != 0) { if ((ret = wc_LockMutex(&queue->lock)) != 0) {
return ret; return ret;
} }
#endif #endif
@@ -256,7 +256,7 @@ int wolfEventQueue_Count(WOLF_EVENT_QUEUE* queue)
ret = queue->count; ret = queue->count;
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
UnLockMutex(&queue->lock); wc_UnLockMutex(&queue->lock);
#endif #endif
return ret; return ret;
@@ -266,7 +266,7 @@ void wolfEventQueue_Free(WOLF_EVENT_QUEUE* queue)
{ {
if (queue) { if (queue) {
#ifndef SINGLE_THREADED #ifndef SINGLE_THREADED
FreeMutex(&queue->lock); wc_FreeMutex(&queue->lock);
#endif #endif
} }
} }

View File

@@ -32,6 +32,15 @@ typedef void (CRYPTO_free_func)(void*parent, void*ptr, CRYPTO_EX_DATA *ad, int i
long argl, void* argp); long argl, void* argp);
#define CRYPTO_THREADID_set_callback wolfSSL_THREADID_set_callback #define CRYPTO_THREADID_set_callback wolfSSL_THREADID_set_callback
#define CRYPTO_THREADID_set_numeric wolfSSL_THREADID_set_numeric #define CRYPTO_THREADID_set_numeric wolfSSL_THREADID_set_numeric
#define CRYPTO_lock wc_LockMutex
#define CRYPTO_r_lock wc_LockMutex
#define CRYPTO_unlock wc_UnLockMutex
#define CRYPTO_THREAD_lock wc_LockMutex
#define CRYPTO_THREAD_r_lock wc_LockMutex
#define CRYPTO_THREAD_unlock wc_UnLockMutex
#endif /* HAVE_STUNNEL */ #endif /* HAVE_STUNNEL */
#endif /* header */ #endif /* header */

View File

@@ -14,12 +14,13 @@
struct WOLFSSL_DH { struct WOLFSSL_DH {
WOLFSSL_BIGNUM* p; WOLFSSL_BIGNUM* p;
WOLFSSL_BIGNUM* g; WOLFSSL_BIGNUM* g;
WOLFSSL_BIGNUM* q;
WOLFSSL_BIGNUM* pub_key; /* openssh deference g^x */ WOLFSSL_BIGNUM* pub_key; /* openssh deference g^x */
WOLFSSL_BIGNUM* priv_key; /* openssh deference x */ WOLFSSL_BIGNUM* priv_key; /* openssh deference x */
void* internal; /* our DH */ void* internal; /* our DH */
char inSet; /* internal set from external ? */ char inSet; /* internal set from external ? */
char exSet; /* external set from internal ? */ char exSet; /* external set from internal ? */
/*added for lighttpd openssl compatibility, go back and add a getter in /*added for lighttpd openssl compatibility, go back and add a getter in
* lighttpd src code. * lighttpd src code.
*/ */
int length; int length;
@@ -36,7 +37,7 @@ WOLFSSL_API int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* pub,
typedef WOLFSSL_DH DH; typedef WOLFSSL_DH DH;
#define DH_new wolfSSL_DH_new #define DH_new wolfSSL_DH_new
#define DH_free wolfSSL_DH_free #define DH_free wolfSSL_DH_free
#define DH_size wolfSSL_DH_size #define DH_size wolfSSL_DH_size
@@ -45,7 +46,7 @@ typedef WOLFSSL_DH DH;
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
#ifdef HAVE_STUNNEL #ifdef HAVE_STUNNEL

View File

@@ -259,6 +259,12 @@ typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX;
#define CRYPTO_set_dynlock_destroy_callback wolfSSL_set_dynlock_destroy_callback #define CRYPTO_set_dynlock_destroy_callback wolfSSL_set_dynlock_destroy_callback
#define CRYPTO_num_locks wolfSSL_num_locks #define CRYPTO_num_locks wolfSSL_num_locks
# define CRYPTO_LOCK 1
# define CRYPTO_UNLOCK 2
# define CRYPTO_READ 4
# define CRYPTO_WRITE 8
#define X509_STORE_CTX_get_current_cert wolfSSL_X509_STORE_CTX_get_current_cert #define X509_STORE_CTX_get_current_cert wolfSSL_X509_STORE_CTX_get_current_cert
#define X509_STORE_CTX_get_error wolfSSL_X509_STORE_CTX_get_error #define X509_STORE_CTX_get_error wolfSSL_X509_STORE_CTX_get_error
#define X509_STORE_CTX_get_error_depth wolfSSL_X509_STORE_CTX_get_error_depth #define X509_STORE_CTX_get_error_depth wolfSSL_X509_STORE_CTX_get_error_depth
@@ -411,7 +417,7 @@ typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX;
/* Lighthttp compatibility */ /* Lighthttp compatibility */
#if defined(HAVE_LIGHTY) || defined(WOLFSSL_MYSQL_COMPATIBLE) #if defined(HAVE_LIGHTY) || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(HAVE_STUNNEL)
typedef WOLFSSL_X509_NAME_ENTRY X509_NAME_ENTRY; typedef WOLFSSL_X509_NAME_ENTRY X509_NAME_ENTRY;
#define SSL_CB_HANDSHAKE_START 0x10 #define SSL_CB_HANDSHAKE_START 0x10

View File

@@ -1789,7 +1789,7 @@ struct WOLFSSL_X509_NAME_ENTRY {
int size; int size;
}; };
#if defined(HAVE_LIGHTY) || defined(WOLFSSL_MYSQL_COMPATIBLE) #if defined(HAVE_LIGHTY) || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(HAVE_STUNNEL)
WOLFSSL_API void wolfSSL_X509_NAME_free(WOLFSSL_X509_NAME *name); WOLFSSL_API void wolfSSL_X509_NAME_free(WOLFSSL_X509_NAME *name);
WOLFSSL_API char wolfSSL_CTX_use_certificate(WOLFSSL_CTX *ctx, WOLFSSL_X509 *x); WOLFSSL_API char wolfSSL_CTX_use_certificate(WOLFSSL_CTX *ctx, WOLFSSL_X509 *x);
WOLFSSL_API int wolfSSL_CTX_use_PrivateKey(WOLFSSL_CTX *ctx, WOLFSSL_EVP_PKEY *pkey); WOLFSSL_API int wolfSSL_CTX_use_PrivateKey(WOLFSSL_CTX *ctx, WOLFSSL_EVP_PKEY *pkey);
@@ -1810,7 +1810,7 @@ WOLFSSL_API unsigned char *wolfSSL_SHA1(const unsigned char *d, size_t n, unsign
WOLFSSL_API int wolfSSL_X509_check_private_key(WOLFSSL_X509*, WOLFSSL_EVP_PKEY*); WOLFSSL_API int wolfSSL_X509_check_private_key(WOLFSSL_X509*, WOLFSSL_EVP_PKEY*);
WOLFSSL_API STACK_OF(WOLFSSL_X509_NAME) *wolfSSL_dup_CA_list( STACK_OF(WOLFSSL_X509_NAME) *sk ); WOLFSSL_API STACK_OF(WOLFSSL_X509_NAME) *wolfSSL_dup_CA_list( STACK_OF(WOLFSSL_X509_NAME) *sk );
/* end lighttpd*/ /* end lighttpd, mysql, have_stunnel*/
#endif #endif
#endif #endif
@@ -1875,7 +1875,7 @@ WOLFSSL_API int wolfSSL_version(WOLFSSL*);
WOLFSSL_API int wolfSSL_get_state(const WOLFSSL*); WOLFSSL_API int wolfSSL_get_state(const WOLFSSL*);
WOLFSSL_API void* wolfSSL_sk_X509_NAME_value(STACK_OF(WOLFSSL_X509_NAME)*, int); WOLFSSL_API void* wolfSSL_sk_X509_NAME_value(const STACK_OF(WOLFSSL_X509_NAME)*, int);
WOLFSSL_API void* wolfSSL_sk_X509_value(STACK_OF(WOLFSSL_X509)*, int); WOLFSSL_API void* wolfSSL_sk_X509_value(STACK_OF(WOLFSSL_X509)*, int);

View File

@@ -337,7 +337,8 @@
DYNAMIC_TYPE_DTLS_FRAG = 55, DYNAMIC_TYPE_DTLS_FRAG = 55,
DYNAMIC_TYPE_DTLS_BUFFER = 56, DYNAMIC_TYPE_DTLS_BUFFER = 56,
DYNAMIC_TYPE_SESSION_TICK = 57, DYNAMIC_TYPE_SESSION_TICK = 57,
DYNAMIC_TYPE_PKCS = 58 DYNAMIC_TYPE_PKCS = 58,
DYNAMIC_TYPE_MUTEX = 59
}; };
/* max error buffer string size */ /* max error buffer string size */

View File

@@ -85,12 +85,19 @@
#endif #endif
#endif #endif
/* For FIPS keep the function names the same */
#ifdef HAVE_FIPS
#define wc_InitMutex InitMutex
#define wc_FreeMutex FreeMutex
#define wc_LockMutex LockMutex
#define wc_UnLockMutex UnLockMutex
#endif /* HAVE_FIPS */
#ifdef SINGLE_THREADED #ifdef SINGLE_THREADED
typedef int wolfSSL_Mutex; typedef int wolfSSL_Mutex;
#else /* MULTI_THREADED */ #else /* MULTI_THREADED */
/* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */ /* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
#if defined(FREERTOS) #if defined(FREERTOS)
typedef xSemaphoreHandle wolfSSL_Mutex; typedef xSemaphoreHandle wolfSSL_Mutex;
#elif defined(FREERTOS_TCP) #elif defined(FREERTOS_TCP)
#include "FreeRTOS.h" #include "FreeRTOS.h"
@@ -169,10 +176,11 @@
#endif /* WOLFSSL_CRYPT_HW_MUTEX */ #endif /* WOLFSSL_CRYPT_HW_MUTEX */
/* Mutex functions */ /* Mutex functions */
WOLFSSL_LOCAL int InitMutex(wolfSSL_Mutex*); WOLFSSL_API int wc_InitMutex(wolfSSL_Mutex*);
WOLFSSL_LOCAL int FreeMutex(wolfSSL_Mutex*); WOLFSSL_API wolfSSL_Mutex* wc_InitAndAllocMutex(void);
WOLFSSL_LOCAL int LockMutex(wolfSSL_Mutex*); WOLFSSL_API int wc_FreeMutex(wolfSSL_Mutex*);
WOLFSSL_LOCAL int UnLockMutex(wolfSSL_Mutex*); WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex*);
WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex*);
/* main crypto initialization function */ /* main crypto initialization function */
WOLFSSL_API int wolfCrypt_Init(void); WOLFSSL_API int wolfCrypt_Init(void);