4.3.2.3 Crypto_Mac_AesCmac_Final
crypto_Mac_Status_E Crypto_Mac_AesCmac_Final(
st_Crypto_Mac_Aes_ctx *ptr_aesCmacCtx_st,
uint8_t *ptr_outMac,
uint32_t macLen
);
Description
This API calculates the MAC using AES-CMAC. To use it, first initialize the context by calling the Crypto_Mac_AesCmac_Init function. Then, call Crypto_Mac_AesCmac_Cipher to calculate the MAC. Once this is done, the API can be called. 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 | st_Crypto_Mac_Aes_ctx* | ptr_aesCmacCtx_st | Input | AES-CMAC algorithm context |
2 | uint8_t* | ptr_outMac | Output | Pointer for MAC |
3 | uint8_t* | macLen | Input | MAC length in bytes, 16 bytes |
Returns
Return Type | Description |
---|---|
crypto_Mac_Status_E | Function returns the status of the API. |
Example
#define sessionID 1
crypto_Mac_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_HW_INTERNAL;
st_Crypto_Mac_Aes_ctx Mac_Ctx;
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 = sizeof(outData);
status = Crypto_Mac_AesCmac_Init(
&Mac_Ctx,
handlerType_en,
key,
keyLen,
sessionID
);
status = Crypto_Mac_AesCmac_Cipher(
&Mac_Ctx,
inputData,
dataLen
);
status = Crypto_Mac_AesCmac_Final(
&Mac_Ctx,
mac,
macLen
);