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 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 encrypt. |
3 | uint32_t | dataLen | Input | Input length of plain data in bytes. |
4 | uint8_t* | ptr_outData | Output | Pointer to store cipher text as output. |
5 | uint8_t* | ptr_key | Input | Key for the AES-GCM cipher operation. |
6 | uint32_t | keyLen | Input | Key length in bytes for the AES-GCM algorithm. |
7 | uint8_t* | ptr_initVect | Input | Pointer for the IV Value |
8 | uint32_t | initVectLen | Input | Length of IV in bytes |
9 | uint8_t* | ptr_aad | Input | Pointer for additional authentication data. It is optional to use, so it can be NULL also. |
10 | uint32_t | aadLen | Input | Length of additional authentication data in bytes, as it is optional so it can be 0 also. |
11 | uint8_t* | ptr_authTag | Output | Pointer for authentication tag. |
12 | uint8_t* | authTagLen | Input | Authentication tag length in bytes, range 12-16 bytes. |
13 | uint32_t | sessionID | Input | It defines the session ID, must be more than zero. |
Returns
Return Type | Description |
---|---|
crypto_Aead_Status_E | Function 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
);