Previous section.

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

NAME

CSSM_EncryptData

SYNOPSIS

CSSM_RETURN CSSMAPI CSSM_EncryptData
    (CSSM_CC_HANDLE CCHandle,
    const CSSM_DATA_PTR ClearBufs,
    uint32 ClearBufCount,
    CSSM_DATA_PTR CipherBufs,
    uint32 CipherBufCount,
    uint32 *bytesEncrypted,
    CSSM_DATA_PTR RemData)

DESCRIPTION

This function encrypts the supplied data using information in the context. The CSSM_QuerySize function can be used to estimate the output buffer size required.

PARAMETERS

CCHandle (input)

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

ClearBufs (input)

A pointer to a vector of CSSM_DATA structures that contain the data to be operated on.

ClearBufCount (input)

The number of ClearBufs.

CipherBufs (output)

A pointer to a vector of CSSM_DATA structures that contain the results of the operation on the data.

CipherBufCount (input)

The number of CipherBufs.

bytesEncrypted (output)

A pointer to uint32 for the size of the encrypted data in bytes.

RemData (output)

A pointer to the CSSM_DATA structure for the last encrypted block containing padded data.

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__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 input or output CSSM_DATA pointer.

CSSM__CSP_INVALID_DATA_COUNT

Invalid data count; data count cannot be 0.

CSSM__CSP_INVALID_DATA

Invalid input or output CSSM_DATA buffer.

CSSM__CSP_NOT_ENOUGH_BUFFER

The output buffer is not big enough.

CSSM__CSP_INVALID_ALGORITHM

Unknown algorithm.

CSSM__CSP_MEMORY_ERROR

Not enough memory to allocate.

CSSM__CSP_OPERATION_UNSUPPORTED

Encrypt data service not supported.

CSSM__CSP_OPERATION_FAILED

Cryptographic operation failed.

CSSM__CSP_VECTOROFBUFS_UNSUPPORTED

Supports only a single buffer of input.

CSSM__CSP_INVALID_ATTR_KEY

Invalid or missing key attribute in the context.

CSSM__CSP_INVALID_KEY

Invalid or missing key data in the context attribute.

CSSM__CSP_INVALID_KEYCLASS

Key class is not private or public key class for asymmetric context or is not session class for symmetric context.

CSSM__CSP_KEY_USAGE_INCORRECT

Key usage does not allow encryption.

CSSM__CSP_KEY_ALGID_MISMATCH

The supplied key does not match the operation.

CSSM__CSP_KEY_KEYHEADER_INCONSISTENT

Key header and key data is inconsistent.

CSSM__CSP_KEY_FORMAT_INCORRECT

Unknown key format.

CSSM__CSP_INVALID_KEY_SIZE_IN_BITS

Key size in bits unsupported.

CSSM__CSP_INVALID_PADDING

Unknown padding.

CSSM__CSP_INVALID_MODE

Unknown algorithm mode for symmetric context.

CSSM__CSP_INVALID_ATTR_PASSPHRASE

Invalid or missing passphrase attribute in the asymmetric context.

CSSM__CSP_PRIKEY_NOT_FOUND

Cannot find the corresponding private key.

CSSM__CSP_PASSPHRASE_INVALID

Passphrase length error or passphrase badly formed for asymmetric context.

CSSM__CSP_PASSPHRASE_INCORRECT

Passphrase incorrect for asymmetric context.

CSSM__CSP_PRIKEY_ERROR

Error in getting the raw private key or private key storage error for asymmetric context.

CSSM__CSP_INVALID_ATTR_INIT_VECTOR

Init vector attribute data or length error for symmetric context.

Comments

The output is returned to the caller either by filling the caller-specified buffer or by using the application's declared memory allocation functions to allocate buffer space. To specify a specific, pre-allocated output buffer, the caller must provide an array of one or more CSSM_DATA structures each one containing a Length field value greater than zero and a non-NULL Data pointer field value. To specify automatic output buffer allocation by the CSP, the caller must provide an array of one or more CSSM_DATA structures each containing a Length field value equal to zero and a NULL Data pointer field value. The application is always responsible for de-allocating the memory when it is no longer needed. If the CSSM_DATA_PTR parameter is NULL (that is, does not point to an array of CSSM__DATA structures) or the number of CSSM_DATA structures is specified as zero, the error code CSSM__CSP_INVALID_DATA_POINTER is returned. In-place encryption can be done by supplying the same input and output buffers.

SEE ALSO

CSSM_QuerySize, CSSM_DecryptData,
CSSM_EncryptDataInit, CSSM_EncryptDataUpdate,
CSSM_EncryptDataFinal

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