ADuCM4x50 Device Drivers API Reference Manual
Release 4.0.0.0
|
Crypto Driver More...
Modules | |
Static Configuration | |
Data Structures | |
struct | ADI_CRYPTO_TRANSACTION |
Macros | |
#define | ADI_CRYPTO_MEMORY_SIZE (92u + ADI_SEM_SIZE) |
#define | ADI_CRYPTO_SHA_HASH_BYTES (256u/8u) |
#define | ADI_CRYPTO_HMAC_HASH_BYTES (256u/8u) |
Typedefs | |
typedef struct __ADI_CRYPTO_DEV_DATA_TYPE * | ADI_CRYPTO_HANDLE |
Functions | |
ADI_CRYPTO_RESULT | adi_crypto_Open (uint32_t const nDeviceNum, void *const pMemory, uint32_t const nMemorySize, ADI_CRYPTO_HANDLE *const phDevice) |
Opens a Crypto device instance. More... | |
ADI_CRYPTO_RESULT | adi_crypto_Close (ADI_CRYPTO_HANDLE const hDevice) |
Close the given device instance. More... | |
ADI_CRYPTO_RESULT | adi_crypto_RegisterCallback (ADI_CRYPTO_HANDLE const hDevice, ADI_CALLBACK const pfCallback, void *const pCBParam) |
Register a user callback function. More... | |
ADI_CRYPTO_RESULT | adi_crypto_Enable (ADI_CRYPTO_HANDLE const hDevice, bool const bEnable) |
Enable/Disable the device. Enabling the device causes the submitted buffer to be processed. More... | |
ADI_CRYPTO_RESULT | adi_crypto_SubmitBuffer (ADI_CRYPTO_HANDLE const hDevice, ADI_CRYPTO_TRANSACTION *const pBuffer) |
Submit a Crypto transaction buffer for processing. More... | |
ADI_CRYPTO_RESULT | adi_crypto_GetBuffer (ADI_CRYPTO_HANDLE const hDevice, ADI_CRYPTO_TRANSACTION **const ppBuffer) |
Get the submitted transaction buffer back from the driver. More... | |
ADI_CRYPTO_RESULT | adi_crypto_IsBufferAvailable (ADI_CRYPTO_HANDLE const hDevice, bool *const pbAvailable) |
Peek function to know whether a submitted transaction is complete. More... | |
Crypto Driver
The Crypto controller provides hardware acceleration of various AES cryptographic cipher modes, including: ECB, CBC, CTR, CMAC, CCM, SHA-256 and Keyed HMAC; as well as Protected Key Storage (PKSTOR) operations for safely storing and using encrypted keys. The Crypto block works most efficiently in DMA mode due to the large about of data I/O which would otherwise incur a lot of PIO-mode interrupt traffic to manually pump data.
Crypto Driver Static Configuration
A number of Crypto cipher modes are able to be configured statically, such that if particular mode(s) are not required, the resulting driver footprint can be reduced internally by blocking out chunks of code that are not needed.
#define ADI_CRYPTO_MEMORY_SIZE (92u + ADI_SEM_SIZE) |
The amount of application supplied memory used by the CRYPTO driver to store internal state. Required user memory size for ADuCM4x50 processor family.
Definition at line 100 of file adi_crypto.h.
#define ADI_CRYPTO_SHA_HASH_BYTES (256u/8u) |
Number of bytes to allocate for SHA256 hash outputs
Definition at line 113 of file adi_crypto.h.
#define ADI_CRYPTO_HMAC_HASH_BYTES (256u/8u) |
Number of bytes to allocate for HMAC hash outputs
Definition at line 117 of file adi_crypto.h.
typedef struct __ADI_CRYPTO_DEV_DATA_TYPE* ADI_CRYPTO_HANDLE |
A device handle used in all API functions to identify the flash device.
Definition at line 109 of file adi_crypto.h.
enum ADI_CRYPTO_RESULT |
Crypto API return codes
Definition at line 38 of file adi_crypto.h.
enum ADI_CRYPTO_EVENT |
Crypto callback events
Definition at line 72 of file adi_crypto.h.
Computation mode(Encryption/Decryption) for given buffers
Enumerator | |
---|---|
ADI_CRYPTO_DECODE | Encoding mode is decryption. |
ADI_CRYPTO_ENCODE | Encoding mode is encryption. |
Definition at line 121 of file adi_crypto.h.
Enum for the AES KEY Length
Enumerator | |
---|---|
ADI_CRYPTO_AES_KEY_LEN_128_BIT | KEY length is 128 bits. |
ADI_CRYPTO_AES_KEY_LEN_256_BIT | KEY length is 256 bits. |
Definition at line 128 of file adi_crypto.h.
Enable byte swapping for KEY writes
Enumerator | |
---|---|
ADI_CRYPTO_KEY_LITTLE_ENDIAN | Do not apply KEY write byte swaps. |
ADI_CRYPTO_KEY_BIG_ENDIAN | Apply KEY write byte swaps. |
Definition at line 136 of file adi_crypto.h.
Byte-swap the SHA/HMAC Input Data
Enumerator | |
---|---|
ADI_CRYPTO_SHA_LITTLE_ENDIAN | Do not apply SHA/HMAC data write byte swaps. |
ADI_CRYPTO_SHA_BIG_ENDIAN | Apply SHA/HMAC data write byte swaps. |
Definition at line 145 of file adi_crypto.h.
Byte-swap the AES Input Data
Enumerator | |
---|---|
ADI_CRYPTO_AES_LITTLE_ENDIAN | Do not apply AES data write byte swaps. |
ADI_CRYPTO_AES_BIG_ENDIAN | Apply AES data write byte swaps. |
Definition at line 153 of file adi_crypto.h.
Enum for the cipher modes.
Definition at line 163 of file adi_crypto.h.
ADI_CRYPTO_RESULT adi_crypto_Open | ( | uint32_t const | nDeviceNum, |
void *const | pMemory, | ||
uint32_t const | nMemorySize, | ||
ADI_CRYPTO_HANDLE *const | phDevice | ||
) |
Opens a Crypto device instance.
[in] | nDeviceNum | Device number to open. |
[in] | pMemory | Pointer to a ADI_CRYPTO_MEMORY_SIZE sized buffer to manage the device instance. |
[in] | nMemorySize | Size of the buffer to which "pMemory" points. |
[out] | phDevice | Pointer to a location where the Crypto device handle is to be written. |
Definition at line 395 of file adi_crypto.c.
ADI_CRYPTO_RESULT adi_crypto_Close | ( | ADI_CRYPTO_HANDLE const | hDevice | ) |
Close the given device instance.
[in] | hDevice | Handle to the device instance. |
Definition at line 480 of file adi_crypto.c.
Referenced by adi_crypto_Open().
ADI_CRYPTO_RESULT adi_crypto_RegisterCallback | ( | ADI_CRYPTO_HANDLE const | hDevice, |
ADI_CALLBACK const | pfCallback, | ||
void *const | pCBParam | ||
) |
Register a user callback function.
[in] | hDevice | Handle to the device instance. |
[in] | pfCallback | Function pointer to user callback function. Passing a NULL pointer will unregister the callback function. |
[in] | pCBParam | Callback function parameter. |
This function registers a user callback function. The registered function will be called when the given computation is over. Registering an active user callback function implies use of the (non-blocking) CALLBACK mode during which any subsequent calls to the (blocking-mode) adi_crypto_GetBuffer() API will be rejected.
Definition at line 532 of file adi_crypto.c.
ADI_CRYPTO_RESULT adi_crypto_Enable | ( | ADI_CRYPTO_HANDLE const | hDevice, |
bool const | bEnable | ||
) |
Enable/Disable the device. Enabling the device causes the submitted buffer to be processed.
[in] | hDevice | Handle to the device instance. |
[in] | bEnable | 'true' to enable and 'false' to disable the device. |
Definition at line 736 of file adi_crypto.c.
Referenced by adi_crypto_Close().
ADI_CRYPTO_RESULT adi_crypto_SubmitBuffer | ( | ADI_CRYPTO_HANDLE const | hDevice, |
ADI_CRYPTO_TRANSACTION *const | pBuffer | ||
) |
Submit a Crypto transaction buffer for processing.
[in] | hDevice | Handle to the device instance. |
[in] | pBuffer | Pointer to the ADI_CRYPTO_TRANSACTION structure which contains details of the cipher-dependent buffer elements required by the driver. |
The buffer submitted is queued for eventual CRYPTO processing. A single buffer may be submitted prior to initiating CRYPTO buffer processing. Buffer processing is initiated with the adi_crypto_Enable() call. As buffer processing is completed, the buffer (and result info) is retrieved with the adi_crypto_GetBuffer() API or through the user callback notification.
Definition at line 585 of file adi_crypto.c.
ADI_CRYPTO_RESULT adi_crypto_GetBuffer | ( | ADI_CRYPTO_HANDLE const | hDevice, |
ADI_CRYPTO_TRANSACTION **const | ppBuffer | ||
) |
Get the submitted transaction buffer back from the driver.
[in] | hDevice | Handle to the device instance. |
[out] | ppBuffer | Pointer to a location to which the address of the buffer structure is written. |
This is a blocking call and will await transaction completion (if not already). This function should not be called if a callback function is registered.
Definition at line 643 of file adi_crypto.c.
ADI_CRYPTO_RESULT adi_crypto_IsBufferAvailable | ( | ADI_CRYPTO_HANDLE const | hDevice, |
bool *const | pbAvailable | ||
) |
Peek function to know whether a submitted transaction is complete.
[in] | hDevice | Handle to the device instance. |
[in] | pbAvailable | Pointer to a Boolean variable. Set to "true" if there is a completed buffer and a call to adi_crypto_GetBuffer is ensured to be successful. Set to "false" if there is no completed buffer. |
Definition at line 697 of file adi_crypto.c.