ica_aes_cmac
Purpose
Authenticate data or verify the authenticity of data with an AES key using the Block Cipher Based Message Authentication Code (CMAC) mode, as described in NIST Special Publication 800-38B. ica_aes_cmac can be used to authenticate or verify the authenticity of a complete message.
Format
unsigned int ica_aes_cmac(const unsigned char *message,
unsigned long message_length,
unsigned char *mac,
unsigned int mac_length,
const unsigned char *key,
unsigned int key_length,
unsigned int direction);
Required hardware support
- KMAC-AES-128, KMAC-AES-192 or KMAC-AES-256
- PCC-Compute-Last_block-CMAC-Using-AES-128, PCC-Compute-Last_block-CMAC-Using-AES-192, or PCC-Compute-Last_block-CMAC-Using-AES-256
Parameters
- const unsigned char *message
- Pointer to a readable buffer of size greater than or equal to message_length bytes. This buffer contains a message to be authenticated, or of which the authenticity is to be verified.
- unsigned long message_length
- Length in bytes of the message to be authenticated or verified.
- unsigned char *mac
- Pointer to a buffer of size greater than or equal to mac_length bytes. If direction is equal to 1, the buffer must be writable and a message authentication code for the message in message of size mac_length bytes is written to this buffer. If direction is equal to 0, this buffer must be readable and contain a message authentication code to be verified against the message in message.
- unsigned int mac_length
- Length in bytes of the message authentication code mac in bytes, which is less than or equal to the cipher block size (16 bytes for AES). It is recommended to use values greater than or equal to 8.
- const unsigned char *key
- Pointer to a valid AES key.
- unsigned int key_length
- Length in bytes of the AES key. Supported sizes are 16, 24, and 32 for AES-128, AES-192, and AES-256 respectively. Therefore, you can use the definitions: AES_KEY_LEN128, AES_KEY_LEN192, and AES_KEY_LEN256.
- unsigned int direction
-
- 0
- Verify message authentication code.
- 1
- Compute message authentication code for the message.
Return codes
- 0
- Success
- EFAULT
- If direction is equal to 0 and the verification of the message authentication code fails.
For return codes indicating exceptions, see Return codes.