forked from wolfSSL/wolfssl
Merge pull request #887 from dgarske/minor_cleanups
Added return code checking for `wolfCrypt_Init()`
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
This port is for the tenAsys INtime RTOS available [here](http://www.tenasys.com/tenasys-products/intime-rtos-family/overview-rtos).
|
This port is for the tenAsys INtime RTOS available [here](http://www.tenasys.com/intime).
|
||||||
|
|
||||||
To enable use the define `INTIME_RTOS`.
|
To enable use the define `INTIME_RTOS`.
|
||||||
|
|
||||||
|
@@ -74,17 +74,31 @@ int wolfCrypt_Init(void)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (initRefCount == 0) {
|
if (initRefCount == 0) {
|
||||||
|
WOLFSSL_ENTER("wolfCrypt_Init");
|
||||||
|
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
wolfAsync_HardwareStart();
|
ret = wolfAsync_HardwareStart();
|
||||||
|
if (ret != 0) {
|
||||||
|
WOLFSSL_MSG("Async hardware start failed");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
|
#if defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
|
||||||
InitMemoryTracker();
|
ret = InitMemoryTracker();
|
||||||
|
if (ret != 0) {
|
||||||
|
WOLFSSL_MSG("InitMemoryTracker failed");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WOLFSSL_CRYPT_HW_MUTEX
|
#if WOLFSSL_CRYPT_HW_MUTEX
|
||||||
/* If crypto hardware mutex protection is enabled, then initialize it */
|
/* If crypto hardware mutex protection is enabled, then initialize it */
|
||||||
wolfSSL_CryptHwMutexInit();
|
ret = wolfSSL_CryptHwMutexInit();
|
||||||
|
if (ret != 0) {
|
||||||
|
WOLFSSL_MSG("Hw crypt mutex init failed");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* if defined have fast RSA then initialize Intel IPP */
|
/* if defined have fast RSA then initialize Intel IPP */
|
||||||
@@ -102,7 +116,11 @@ int wolfCrypt_Init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FREESCALE_LTC_TFM) || defined(FREESCALE_LTC_ECC)
|
#if defined(FREESCALE_LTC_TFM) || defined(FREESCALE_LTC_ECC)
|
||||||
ksdk_port_init();
|
ret = ksdk_port_init();
|
||||||
|
if (ret != 0) {
|
||||||
|
WOLFSSL_MSG("KSDK port init failed");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_ATMEL
|
#ifdef WOLFSSL_ATMEL
|
||||||
@@ -145,6 +163,7 @@ int wolfCrypt_Cleanup(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (initRefCount == 1) {
|
||||||
WOLFSSL_ENTER("wolfCrypt_Cleanup");
|
WOLFSSL_ENTER("wolfCrypt_Cleanup");
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
@@ -154,7 +173,7 @@ int wolfCrypt_Cleanup(void)
|
|||||||
#ifdef ECC_CACHE_CURVE
|
#ifdef ECC_CACHE_CURVE
|
||||||
wc_ecc_curve_cache_free();
|
wc_ecc_curve_cache_free();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* HAVE_ECC */
|
||||||
|
|
||||||
#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
|
#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
|
||||||
ret = wc_LoggingCleanup();
|
ret = wc_LoggingCleanup();
|
||||||
@@ -169,6 +188,7 @@ int wolfCrypt_Cleanup(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
initRefCount = 0; /* allow re-init */
|
initRefCount = 0; /* allow re-init */
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user