6.4.2.2 Crypto_Mac_AesGmac_Direct

crypto_Mac_Status_E Crypto_Mac_AesGmac_Direct(
    crypto_HandlerType_E macHandlerType_en, 
    uint8_t *ptr_initVect, 
    uint32_t initVectLen, 
    uint8_t *ptr_outMac, 
    uint32_t macLen, 
    uint8_t *ptr_key, 
    uint32_t keyLen,
    uint8_t *ptr_aad,
    uint32_t aadLen,
    uint32_t sessionID
    );

Description

This API generates the MAC using AES-GMAC 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_initVectInputInput data to calculate the MAC
3uint32_tinitVectLenInputInput 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-GMAC cipher operation
7uint32_tkeyLenInputKey length in bytes for the AES-GMAC algorithm
8uint32_tptr_aadInputKey length in bytes for the AES-GMAC algorithm
9uint32_taadLenInputaad length in bytes for the AES-GMAC algorithm
10uint32_tsessionIDInputIt defines the session ID, must be more than zero

Returns

Return TypeDescription
crypto_Mac_Status_EFunction 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_AesGmac_Direct(
    handlerType_en, 
    inputData, 
    dataLen, 
    mac, 
    macLen, 
    key, 
    keyLen, 
    sessionID
    );