FreeRTOS: PKCS11
PKCS11 Cryptoki Library
Return to main page ↑
C_Initialize

Initializes Cryptoki.

CK_DECLARE_FUNCTION( CK_RV, C_Initialize )( CK_VOID_PTR pInitArgs )
{
( void ) ( pInitArgs );
CK_RV xResult = CKR_OK;
/* 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
{
xResult = CKR_CRYPTOKI_ALREADY_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. See PKCS #11 specification for more information.
CK_DECLARE_FUNCTION
#define CK_DECLARE_FUNCTION(returnType, name)
Macro for defining a PKCS #11 functions.
Definition: iot_pkcs11.h:66
P11Struct_t::xIsInitialized
CK_BBOOL xIsInitialized
Indicates whether PKCS #11 module has been initialized with a call to C_Initialize.
Definition: iot_pkcs11_mbedtls.c:202
prvMbedTLS_Initialize
static CK_RV prvMbedTLS_Initialize(void)
Initialize mbedTLS.
Definition: iot_pkcs11_mbedtls.c:464
C_Initialize
CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
Initializes Cryptoki.
Definition: iot_pkcs11_mbedtls.c:1328
PKCS11_PAL_Initialize
CK_RV PKCS11_PAL_Initialize(void)
Initializes the PKCS #11 PAL.
xP11Context
static P11Struct_t xP11Context
The global PKCS #11 module object. Entropy/randomness and object lists are shared across PKCS #11 ses...
Definition: iot_pkcs11_mbedtls.c:238