Previous section.

Common Security: CDSA and CSSM
Copyright © 1997 The Open Group

NAME

CSP_GenerateKey

SYNOPSIS

CSSM_RETURN CSSMSPI CSP_GenerateKey
    (CSSM_CSP_HANDLE CSPHandle,
    CSSM_CC_HANDLE CCHandle,
    const CSSM_CONTEXT_PTR Context,
    uint32 KeyUsage,
    uint32 KeyAttr,
    const CSSM_DATA_PTR KeyLabel,
    CSSM_KEY_PTR Key)

DESCRIPTION

This function generates a symmetric key. The CSP may cache keying material associated with the new symmetric key. When the symmetric key is no longer in active use, the application can invoke the CSSM_FreeKey interface to allow cached keying material associated with the symmetric key to be removed.

PARAMETERS

CSPHandle (input)

The handle that describes the add-in cryptographic service provider module used to perform up-calls to CSSM for the memory functions managed by CSSM.

CCHandle (input)

The handle that describes the context of this cryptographic operation used to link to the CSP-managed information.

Context (input)

Pointer to CSSM_CONTEXT structure that describes the attributes with this context.

KeyUsage (input/optional)

A bit mask specifying how the new key can be used.

KeyAttr (input/optional)

A bit mask specifying other attributes to be associated with the new key.

KeyLabel (input)

Pointer to a byte string that will be used as the label for the key.

Key (output)

Pointer to CSSM_KEY structure used to obtain the key. Upon function invocation, any values in the CSSM_Key structure should be ignored. All input values should be supplied in the cryptographic context, KeyUsage, KeyAttr, and KeyLabel input parameters.

RETURN VALUE

A CSSM return value. This function returns CSSM_OK if successful and returns an error code if an error has occurred.

ERRORS

CSSM_CSP_INVALID_CSP_HANDLE

Invalid CSP handle.

CSSM_CSP_INVALID_CONTEXT_HANDLE

Invalid context handle.

CSSM_CSP_INVALID_CONTEXT_POINTER

Invalid CSSM_CONTEXT pointer.

CSSM_CSP_INVALID_CONTEXT

Context type and operation do not match.

CSSM_CSP_INVALID_DATA_POINTER

Invalid CSSM_DATA pointer for KeyLabel.

CSSM_CSP_INVALID_DATA

Invalid CSSM_DATA buffer for KeyLabel.

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 service not supported.

CSSM_CSP_OPERATION_FAILED

Cryptographic operation 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_SEED

Invalid seed attribute in the context if caller provides the seed crypto data structure.

CSSM_CSP_CALLBACK_FAILED

Seed callback function failed if caller provides a seed callback function.

CSSM_CSP_INVALID_ATTR_SALT

Invalid salt attribute if caller provides one.

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 if caller provides one.

Comments

The output can be obtained either by filling the caller-supplied buffer or using the application's memory allocation functions to allocate space; application has to free the memory in this case. If the output buffer pointer is NULL, an error code CSSM_CSP_INVALID_DATA_POINTER is returned.

SEE ALSO

CSP_GenerateRandom, CSP_GenerateKeyPair

Why not acquire a nicely bound hard copy?
Click here to return to the publication details or order a copy of this publication.
You should also read the legal notice explaining the terms and conditions relating to the CDSA documentation.

Contents Next section Index