corePKCS11 v3.5.0
PKCS #11 Cryptoki Library
C_Finalize

Clean up miscellaneous Cryptoki-associated resources.

CK_DECLARE_FUNCTION( CK_RV, C_Finalize )( CK_VOID_PTR pReserved )
{
CK_RV xResult = CKR_OK;
if( pReserved != NULL )
{
xResult = CKR_ARGUMENTS_BAD;
LogError( ( "Failed to un-initialize PKCS #11. Received bad arguments. "
"Parameters must be NULL, but were not." ) );
}
if( xResult == CKR_OK )
{
/* MISRA Ref 10.5.1 [Essential type casting] */
/* More details at: https://github.com/FreeRTOS/corePKCS11/blob/main/MISRA.md#rule-105 */
/* coverity[misra_c_2012_rule_10_5_violation] */
if( xP11Context.xIsInitialized == ( CK_BBOOL ) CK_FALSE )
{
xResult = CKR_CRYPTOKI_NOT_INITIALIZED;
LogWarn( ( "PKCS #11 was already uninitialized." ) );
}
}
if( xResult == CKR_OK )
{
mbedtls_entropy_free( &xP11Context.xMbedEntropyContext );
mbedtls_ctr_drbg_free( &xP11Context.xMbedDrbgCtx );
mbedtls_mutex_free( &xP11Context.xObjectList.xMutex );
mbedtls_mutex_free( &xP11Context.xSessionMutex );
/* MISRA Ref 10.5.1 [Essential type casting] */
/* More details at: https://github.com/FreeRTOS/corePKCS11/blob/main/MISRA.md#rule-105 */
/* coverity[misra_c_2012_rule_10_5_violation] */
xP11Context.xIsInitialized = ( CK_BBOOL ) CK_FALSE;
LogInfo( ( "PKCS #11 was successfully uninitialized." ) );
}
return xResult;
}
#define CK_DECLARE_FUNCTION(returnType, name)
Macro for defining a PKCS #11 functions.
Definition: core_pkcs11.h:77
#define LogInfo(message)
Macro that is called in the corePKCS11 library for logging "Info" level messages.
Definition: core_pkcs11_config_defaults.h:357
#define LogWarn(message)
Macro that is called in the corePKCS11 library for logging "Warning" level messages.
Definition: core_pkcs11_config_defaults.h:337
#define LogError(message)
Macro that is called in the corePKCS11 library for logging "Error" level messages.
Definition: core_pkcs11_config_defaults.h:317
static P11Struct_t xP11Context
The global PKCS #11 module object. Entropy/randomness and object lists are shared across PKCS #11 ses...
Definition: core_pkcs11_mbedtls.c:326
CK_RV C_Finalize(CK_VOID_PTR pReserved)
Clean up miscellaneous Cryptoki-associated resources.
Definition: core_pkcs11_mbedtls.c:1463
mbedtls_threading_mutex_t xMutex
Mutex that protects write operations to the xObjects array.
Definition: core_pkcs11_mbedtls.c:275
P11ObjectList_t xObjectList
List of PKCS #11 objects that have been found/created since module initialization....
Definition: core_pkcs11_mbedtls.c:289
mbedtls_entropy_context xMbedEntropyContext
Entropy context for PKCS #11 module - used to collect entropy for RNG.
Definition: core_pkcs11_mbedtls.c:287
CK_BBOOL xIsInitialized
Indicates whether PKCS #11 module has been initialized with a call to C_Initialize.
Definition: core_pkcs11_mbedtls.c:285
mbedtls_threading_mutex_t xSessionMutex
Mutex that protects write operations to the pxSession array.
Definition: core_pkcs11_mbedtls.c:288
mbedtls_ctr_drbg_context xMbedDrbgCtx
CTR-DRBG context for PKCS #11 module - used to generate pseudo-random numbers.
Definition: core_pkcs11_mbedtls.c:286