2.5.2.3 Crypto_Aead_AesGcm_AddAadData
crypto_Aead_Status_E Crypto_Aead_AesGcm_AddAadData(
st_Crypto_Aead_AesGcm_ctx *ptr_aesGcmCtx_st,
uint8_t *ptr_aad,
uint32_t aadLen);
Description
This API is used to incorporate additional authentication data into an AES-GCM encrypted stream. It should be called when the user requires authentication assurance of the additional associated data (AAD). To use it, initialize the context by calling the Crypto_Aead_AesGcm_Init function, then call this API. Afterward, proceed with encrypting the data using Crypto_Aead_AesGcm_Cipher. Finally, obtain the authentication tag by calling Crypto_Aead_AesGcm_Final. If authentication assurance of AAD is not needed, you can skip calling this API.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|---|---|---|---|
1 | st_Crypto_Aead_AesGcm_ctx* | ptr_aesGcmCtx_st | Input | AES-GCM Algorithm context. |
2 | uint8_t* | ptr_aad | Input | Pointer for additional authentication data. It is optional to use, so it can be NULL also. |
3 | uint32_t | aadLen | Input | Length of additional authentication data in bytes, as it is optional so it can be 0 also. |
Returns
Return Type | Description |
---|---|
crypto_Aead_Status_E | Function 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.
- Crypto_Aead_AesGcm_Init and Crypto_Aead_AesGcm_Cipher must be called prior to calling Crypto_Aead_AesGcm_AddAadData.
Example
Example provided in Crypto_Aead_AesGcm_Final.