corePKCS11  V3.0.0
PKCS #11 Cryptoki Library
C_GetSlotList
CK_DECLARE_FUNCTION( CK_RV, C_GetSlotList )( CK_BBOOL tokenPresent,
CK_SLOT_ID_PTR pSlotList,
CK_ULONG_PTR pulCount )
{
CK_RV xResult = CKR_OK;
/* Since the mbedTLS implementation of PKCS#11 does not depend
* on a physical token, this parameter is ignored. */
( void ) ( tokenPresent );
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
if( xP11Context.xIsInitialized != ( CK_BBOOL ) CK_TRUE )
{
xResult = CKR_CRYPTOKI_NOT_INITIALIZED;
LogError( ( "Failed to get slot list. PKCS #11 must be initialized "
"before any operations." ) );
}
if( NULL == pulCount )
{
xResult = CKR_ARGUMENTS_BAD;
LogError( ( "Failed to get slot list. Count pointer was NULL." ) );
}
if( xResult == CKR_OK )
{
if( NULL == pSlotList )
{
*pulCount = 1;
}
else
{
if( 0u == *pulCount )
{
xResult = CKR_BUFFER_TOO_SMALL;
LogWarn( ( "The buffer is too small to contain the slot list." ) );
}
else
{
pSlotList[ 0 ] = pkcs11SLOT_ID;
*pulCount = 1;
LogDebug( ( "Successfully Returned a PKCS #11 slot with ID "
"%lu with a count of %lu.", ( unsigned long int ) pkcs11SLOT_ID, ( unsigned long int ) *pulCount ) );
}
}
}
return xResult;
}
CK_DECLARE_FUNCTION
#define CK_DECLARE_FUNCTION(returnType, name)
Macro for defining a PKCS #11 functions.
Definition: core_pkcs11.h:72