crypto_Mac_Status_E Crypto_Mac_AesCmac_Direct(
crypto_HandlerType_E macHandlerType_en,
uint8_t *ptr_inputData,
uint32_t dataLen,
uint8_t * ptr_outMac,
uint32_t macLen,
uint8_t *ptr_key,
uint8_t *ptr_key,
uint32_t keyLen,
uint32_t sessionID
);
Description
This API generates the MAC using AES-CMAC in a single step, without needing any prior
initialization. To verify the MAC, users can compare the generated MAC with the one
received from the sender along with the message.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|
1 | crypto_HandlerType_E | handlerType_en | Input | Enum for
crypto operation handler i.e., SW, HW |
2 | uint8_t* | ptr_inputData | Input | Input data to
calculate the MAC |
3 | uint32_t | dataLen | Input | Input length
of plain data in bytes |
4 | uint8_t* | ptr_outMac | Output | Pointer for
MAC |
5 | uint8_t* | macLen | Input | MAC length,
min 4 bytes max 16 bytes |
6 | uint8_t* | ptr_key | Input | Key for the
AES-CMAC cipher operation |
7 | uint32_t | keyLen | Input | Key length in
bytes for the AES-CMAC algorithm |
8 | uint32_t | sessionID | Input | It defines the
session ID, must be more than zero |
Returns
Return Type | Description |
---|
crypto_Mac_Status_E | Function
returns the status of the API. |
Prerequisites
- To use the HW handler, the
algorithm must be enabled in Crypto v4 in MPLAB® Code Configurator.
- To use the SW handler, the
algorithm must be enabled in wolfCrypt, and linked to Crypto V4 in MPLAB® Code
Configurator.
Example
#define sessionID 1
crypto_Mac_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_SW_WOLFCRYPT;
uint8_t inputData[32] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t key[32] = {/*data*/};
uint32_t keyLen = sizeof(key);
uint8_t mac[64];
uint32_t macLen = 16;
status = Crypto_Mac_AesCmac_Direct(
handlerType_en,
inputData,
dataLen,
mac,
macLen,
key,
keyLen,
sessionID
);