corePKCS11  V3.0.0
PKCS #11 Cryptoki Library
C_CreateObject
CK_DECLARE_FUNCTION( CK_RV, C_CreateObject )( CK_SESSION_HANDLE hSession,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR phObject )
{
CK_OBJECT_CLASS xClass = 0;
const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( ( NULL == pTemplate ) ||
( NULL == phObject ) )
{
LogError( ( "Failed to create object. Received a NULL template or "
"object pointer." ) );
xResult = CKR_ARGUMENTS_BAD;
}
if( xResult == CKR_OK )
{
xResult = prvGetObjectClass( pTemplate, ulCount, &xClass );
}
if( xResult == CKR_OK )
{
LogInfo( ( "Creating a 0x%0lX type object.", ( unsigned long int ) xClass ) );
switch( xClass )
{
case CKO_CERTIFICATE:
xResult = prvCreateCertificate( pTemplate, ulCount, phObject );
break;
case CKO_PRIVATE_KEY:
xResult = prvCreatePrivateKey( pTemplate, ulCount, phObject );
break;
case CKO_PUBLIC_KEY:
xResult = prvCreatePublicKey( pTemplate, ulCount, phObject );
break;
default:
xResult = CKR_ATTRIBUTE_VALUE_INVALID;
break;
}
}
return xResult;
}
CK_DECLARE_FUNCTION
#define CK_DECLARE_FUNCTION(returnType, name)
Macro for defining a PKCS #11 functions.
Definition: core_pkcs11.h:72