CSSM_EncryptData

Purpose

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. When working with U.S. exportable versions of the OCSF, the caller may be required to possess specific exemptions or privileges in order to allow this call to complete successfully.

Format

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)

Parameters

Input
CCHandle
The handle that describes the context of this cryptographic operation used to link to the CSP-managed information.
ClearBufs
A pointer to a vector of CSSM_DATA structures that contain the data to be operated on.
ClearBufCount
The number of ClearBufs.
CipherBufCount
The number of CipherBufs.
Output
CipherBufs
A pointer to a vector of CSSM_DATA structures that contain the results of the operation on the data.
bytesEncrypted
The size of the encrypted data in bytes.
RemData
A pointer to the CSSM_DATA structure for the last encrypted block containing padded data.

Return Value

CSSM_OK if the function was successful. CSSM_FAIL if an error occurred. Use CSSM_GetError to determine the exact error.

Notes

The output can be obtained either by filling the caller-supplied buffer or using the application's memory allocation functions to allocate space, which the application must later free. If the output buffer pointer is NULL, an error code CSSM_CSP_INVALID_DATA_POINTER is returned. In-place encryption can be done by supplying the same input and output buffers.

Related Information

CSSM_QuerySize
CSSM_DecryptData
CSSM_EncryptDataInit
CSSM_EncryptDataUpdate
CSSM_EncryptDataFinal
CSSM_RequestCssmExemption