KM_GenerateSecretKey
Generate a secret key.
Synopsis
#include <kmlib.h>
CK_RV KM_GenerateSecretKey ( CK_SESSION_HANDLE hSession, CK_KEY_TYPE keyType, CK_SIZE keySizeInBits, CK_ATTRIBUTE * pTpl, CK_COUNT tplSize, CK_COUNT numComps, CK_OBJECT_HANDLE * phKey );
Parameter | Description |
---|---|
hSession | Handle to an open session. |
keyType |
The type of PKCS #11 key to generate. Examples are: >CKK_AES >CKK_CAST128 >CKK_DES >CKK_DES2 >CKK_DES3 >CKK_IDEA >CKK_RC2 >CKK_RC4 >CKK_GENERIC_SECRET |
keySizeInBits |
Size, in bits, of the key to generate. This is not needed for fixed length key types. The size ranges for the supported PKCS #11 key types are: >CKK_AES - 128, 192 or 256 bits >CKK_CAST128 - 8, 64 or 128 bits >CKK_DES - 64 bits >CKK_DES2 - 128 bits >CKK_DES3 - 192 bits >CKK_IDEA - 128 bits >CKK_RC2 - 8 to 1024 bits in 8 bit increments >CKK_RC4 - 8 to 2048 bits in 8 bit increments >CKK_GENERIC_SECRET - 8 to "Effectively Infinite" bits |
pTpl | The attribute template of the new key. |
tplSize | Number of attributes in pTpl. |
numComps | The number of components to generate if XORable key components are required. This parameter should be set to 0 or 1 if component generation is not required. |
phKey |
Location to store the handle of the generated 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_OBJECT_HANDLE_INVALID CKR_OK CKR_OPERATION_ACTIVE CKR_RANDOM_NO_RNG 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