CSSM_GenerateKeyPair
CSSM_RETURN CSSMAPI CSSM_GenerateKeyPair
(CSSM_CC_HANDLE CCHandle,
uint32 PublicKeyUsage,
uint32 PublicKeyAttr,
const CSSM_DATA_PTR PublicKeyLabel,
CSSM_KEY_PTR PublicKey,
uint32 PrivateKeyUsage,
uint32 PrivateKeyAttr,
const CSSM_DATA_PTR PrivateKeyLabel,
CSSM_KEY_PTR PrivateKey)
This function generates an asymmetric key pair. The CSP may cache keying material associated with the new asymmetric keypair. When one or both of the keys are no longer in active use, the application can invoke the CSSM_FreeKey interface to allow cached keying material associated with the key to be removed.
- CCHandle (input)
The handle that describes the context of this cryptographic operation used to link to the CSP-managed information.
- PublicKeyUsage (input)
A bit mask indicating all permitted uses for the new public key.
- PublicKeyAttr (input)
A bit mask defining attribute values for the new public key.
- PublicKeyLabel (input)
A key label value to be associated with the new public key.
- PublicKey (output)
Pointer to CSSM_KEY structure used to hold the new public key. The CSSM_KEY structure should be empty upon input to this function. The CSP will ignore any values residing in this structure at function invocation. Input values should be supplied in the cryptographic context, PublicKeyUsage, PublicKeyAttr, and PublicKeyLabel input parameters.
- PrivateKeyUsage (input)
A bit mask indicating all permitted uses for the new private key. The CSSM_KEY structure should be empty upon input to this function. The CSP will ignore any values residing in this structure at function invocation. Input values should be supplied in the cryptographic context, PublicKeyUsage, PublicKeyAttr, and PublicKeyLabel input parameters.
- PrivateKeyAttr (input)
A bit mask defining attribute values for the new private key.
- PrivateKeyLabel (input)
A key label value to be associated with the new private key.
- PrivateKey (output)
Pointer to CSSM_KEY structure used to hold the new private key.
A CSSM return value. This function returns CSSM_OK if successful, and returns an error code if an error has occurred.
- CSSM_MANIFEST_ATTRIBUTES_NOT_FOUND
No capability attribute found in the manifest.
- CSSM_CONTEXT_FILTER_FAILED
Requested context was not in the manifest capability attribute.
- CSSM_CSP_INVALID_CONTEXT_HANDLE
Invalid context handle.
- CSSM_CSP_INVALID_CONTEXT
Context type and operation do not match.
- CSSM_CSP_INVALID_DATA_POINTER
Invalid CSSM_DATA pointer for PublicKeyLabel or PrivateKeyLabel.
- CSSM_CSP_INVALID_DATA
Invalid CSSM_DATA buffer for PublicKeyLabel or PrivateKeyLabel.
- CSSM_CSP_INVALID_KEY_POINTER
Invalid or missing CSSM_KEY pointer.
- CSSM_CSP_INVALID_KEY
Invalid CSSM_KEY buffer.
- CSSM_CSP_NOT_ENOUGH_BUFFER
The output key buffer is not big enough.
- CSSM_CSP_INVALID_ALGORITHM
Unknown algorithm.
- CSSM_CSP_MEMORY_ERROR
Not enough memory to allocate.
- CSSM_CSP_OPERATION_UNSUPPORTED
Generate key pair service not supported.
- CSSM_CSP_OPERATION_FAILED
Cryptographic operation failed.
- CSSM_CSP_INVALID_ATTR_PASSPHRASE
Invalid or missing passphrase attribute in the context.
- CSSM_CSP_CALLBACK_FAILED
Passphrase callback function failed.
- CSSM_CSP_INVALID_KEYUSAGE_MASK
Specified key usage mask is invalid.
- CSSM_CSP_KEYUSAGE_MASK_UNSUPPORTED
Requested key usage mask unsupported.
- CSSM_CSP_INVALID_KEYATTR_MASK
Specified key attribute mask is invalid.
- CSSM_CSP_KEYATTR_MASK_UNSUPPORTED
Requested key attribute mask unsupported.
- CSSM_CSP_INVALID_KEY_SIZE_IN_BITS
Key size in bits unsupported.
- CSSM_CSP_INVALID_ATTR_ALG_PARAMS
Invalid param attribute if caller provides one.
- CSSM_CSP_INVALID_ATTR_START_DATE
Invalid start date attribute if caller provides one.
- CSSM_CSP_INVALID_ATTR_END_DATE
Invalid end date attribute if caller provides one.
Comments
The KeyData field of the CSSM_KEY structures are not required to be allocated. In this case the memory required to represent the key is allocated by the CSP. The application is required to free this memory. The CSP will only allocate memory if the Data field of KeyData is NULL and the Length field is zero.
CSSM_GenerateRandom
Contents | Next section | Index |