corePKCS11  v3.2.0
PKCS #11 Cryptoki Library
C_Initialize

Initializes Cryptoki.

CK_DECLARE_FUNCTION( CK_RV, C_Initialize )( CK_VOID_PTR pInitArgs )
{
CK_RV xResult = CKR_OK;
( void ) ( pInitArgs );
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
if( xP11Context.xIsInitialized != ( CK_BBOOL ) CK_TRUE )
{
xResult = PKCS11_PAL_Initialize();
if( xResult == CKR_OK )
{
xResult = prvMbedTLS_Initialize();
}
else
{
LogError( ( "Failed to initialize PKCS #11. PAL failed with error code: 0x%0lX", ( unsigned long int ) xResult ) );
}
}
else
{
xResult = CKR_CRYPTOKI_ALREADY_INITIALIZED;
LogWarn( ( "Failed to initialize PKCS #11. PKCS #11 was already initialized." ) );
}
if( xResult == CKR_OK )
{
LogInfo( ( "PKCS #11 successfully initialized." ) );
}
return xResult;
}
Note
C_Initialize is not thread-safe.

C_Initialize should be called (and allowed to return) before any additional PKCS #11 operations are invoked.

In this implementation, all arguments are ignored. Thread protection for the rest of PKCS #11 functions default to FreeRTOS primitives.

Parameters
[in]pInitArgsThis parameter is ignored.
Returns
CKR_OK if successful. CKR_CRYPTOKI_ALREADY_INITIALIZED if C_Initialize was previously called. All other errors indicate that the PKCS #11 module is not ready to be used.
PKCS11_PAL_Initialize
CK_RV PKCS11_PAL_Initialize(void)
Initializes the PKCS #11 PAL.
P11Struct_t::xIsInitialized
CK_BBOOL xIsInitialized
Indicates whether PKCS #11 module has been initialized with a call to C_Initialize.
Definition: core_pkcs11_mbedtls.c:272
C_Initialize
CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
Initializes Cryptoki.
Definition: core_pkcs11_mbedtls.c:1374
xP11Context
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:313
LogInfo
#define LogInfo(message)
Macro that is called in the corePKCS11 library for logging "Info" level messages.
Definition: core_pkcs11_config_defaults.h:355
LogWarn
#define LogWarn(message)
Macro that is called in the corePKCS11 library for logging "Warning" level messages.
Definition: core_pkcs11_config_defaults.h:335
CK_DECLARE_FUNCTION
#define CK_DECLARE_FUNCTION(returnType, name)
Macro for defining a PKCS #11 functions.
Definition: core_pkcs11.h:75
prvMbedTLS_Initialize
static CK_RV prvMbedTLS_Initialize(void)
Initialize mbedTLS.
Definition: core_pkcs11_mbedtls.c:426
LogError
#define LogError(message)
Macro that is called in the corePKCS11 library for logging "Error" level messages.
Definition: core_pkcs11_config_defaults.h:315