4.3.2.4 Crypto_Mac_AesCmac_Direct

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 TypeArgument NameTypeDescription
1crypto_HandlerType_EhandlerType_enInputEnum for crypto operation handler i.e., SW, HW
2uint8_t*ptr_inputDataInputInput data to calculate the MAC
3uint32_tdataLenInputInput length of plain data in bytes
4uint8_t*ptr_outMacOutputPointer for MAC
5uint8_t*macLenInputMAC length, min 4 bytes max 16 bytes
6uint8_t*ptr_keyInputKey for the AES-CMAC cipher operation
7uint32_tkeyLenInputKey length in bytes for the AES-CMAC algorithm
8uint32_tsessionIDInputIt defines the session ID, must be more than zero

Returns

Return TypeDescription
crypto_Mac_Status_EFunction returns the status of the API.

Example

#define sessionID 1
crypto_Mac_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_HW_INTERNAL;
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_Direct(
    handlerType_en, 
    inputData, 
    dataLen, 
    mac, 
    macLen, 
    key, 
    keyLen, 
    sessionID
    );