KM_GenerateKeyPair

Generate a key pair.

NOTE   This function uses the following callback:

>UICB_ShowMsg_t

Synopsis

#include <kmlib.h>

CK_RV KM_GenerateKeyPair ( 
   CK_SESSION_HANDLE   hSession,
   CK_KEY_TYPE         keyType,
   CK_SIZE             keySizeInBits, 
   CK_ATTRIBUTE *      pPublicKeyTpl, 
   CK_COUNT            publicKeyTplSize, 
   CK_ATTRIBUTE *      pPrivateKeyTpl, 
   CK_COUNT            privateKeyTplSize, 
   CK_OBJECT_HANDLE *  phPublicKey, 
   CK_OBJECT_HANDLE *  phPrivateKey
);
Parameter Description
hSession Handle to an open session.
keyType

The type of key pair to generate. Options are:

>CKK_RSA

>CKK_DSA

>CKK_DH

keySizeInBits

Size, in bits, of the key pair to generate. The size ranges for the supported key types are:

>CKK_RSA - 512 to 4096 bits in 256 bit increments

>CKK_DSA - 512 to 1024 bits in 64 bit increments

>CKK_DH - 512 to 2048 bits in 256 bit increments

pPublicKeyTpl The attribute template the public key will have.
publicKeyTplSize The number of attributes in pPublicKeyTpl.
pPrivateKeyTpl The attribute template the public key will have.
privateKeyTplSize

The number of attributes in pPrivateKeyTpl.

phPublicKey Location to store the handle of the new public key.
phPrivateKey

Location to store the handle of the new private key.

Returns

CKR_ARGUMENTS_BAD
CKR_ATTRIBUTE_READ_ONLY
CKR_ATTRIBUTE_TYPE_INVALID
CKR_ATTRIBUTE_VALUE_INVALID
CKR_CRYPTOKI_NOT_INITIALIZED
CKR_DEVICE_ERROR
CKR_DEVICE_MEMORY
CKR_DEVICE_REMOVED
CKR_FUNCTION_CANCELED
CKR_FUNCTION_FAILED
CKR_GENERAL_ERROR
CKR_HOST_MEMORY
CKR_MECHANISM_INVALID
CKR_MECHANISM_PARAM_INVALID
CKR_OK
CKR_OPERATION_ACTIVE
CKR_SESSION_CLOSED
CKR_SESSION_HANDLE_INVALID
CKR_SESSION_READ_ONLY
CKR_TEMPLATE_INCOMPLETE
CKR_TEMPLATE_INCONSISTENT
CKR_TOKEN_WRITE_PROTECTED
CKR_USER_NOT_LOGGED_IN