5.5.2.5 Crypto_Aead_AesGcm_EncryptAuthDirect

crypto_Aead_Status_E Crypto_Aead_AesGcm_EncryptAuthDirect(
    crypto_HandlerType_E handlerType_en, 
    uint8_t *ptr_inputData, 
    uint32_t dataLen, 
    uint8_t *ptr_outData, 
    uint8_t *ptr_key, 
    uint32_t keyLen, 
    uint8_t *ptr_initVect, 
    uint32_t initVectLen, 
    uint8_t *ptr_aad, 
    uint32_t aadLen, 
    uint8_t *ptr_authTag, 
    uint32_t authTagLen, 
    uint32_t sessionID);

Description

This API performs AES_GCM encryption and generates an authentication tag in a single step without initializing.

Parameters

No.Argument TypeArgument NameTypeDescription
1crypto_HandlerType_EhandlerType_enInputEnum for crypto operation handler i.e., SW, HW.
2uint8_t*ptr_inputDataInputInput data to encrypt.
3uint32_tdataLenInputInput length of plain data in bytes.
4uint8_t*ptr_outDataOutputPointer to store cipher text as output.
5uint8_t*ptr_keyInputKey for the AES-GCM cipher operation.
6uint32_tkeyLenInputKey length in bytes for the AES-GCM algorithm.
7uint8_t*ptr_initVectInputPointer for the IV Value
8uint32_tinitVectLenInputLength of IV in bytes
9uint8_t*ptr_aadInputPointer for additional authentication data. It is optional to use, so it can be NULL also.
10uint32_taadLenInputLength of additional authentication data in bytes, as it is optional so it can be 0 also.
11uint8_t*ptr_authTagOutputPointer for authentication tag.
12uint8_t*authTagLenInputAuthentication tag length in bytes, range 12-16 bytes.
13uint32_tsessionIDInputIt defines the session ID, must be more than zero.

Returns

Return TypeDescription
crypto_Aead_Status_EFunction returns the status of the API.

Example

#define sessionID 1
crypto_Aead_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 outData[64];
uint8_t initVect[32] = {/*data*/};
uint32_t initVectLen = sizeof(initVect);
uint8_t authTag[32] = {/*data*/};
uint32_t authTagLen = 16; // auth tag length can be 12-16 bytes
uint8_t aad[32] = {/*data*/};
uint32_t aadLen = sizeof(aad);

status = Crypto_Aead_AesGcm_EncryptAuthDirect(
    handlerType_en,
    inputData,
    dataLen,
    outData,
    key,
    keyLen,
    initVect,
    initVectLen,
    aad,    
    aadLen,
    authTag,
    authTagLen,
    sessionID
);