5.4.2.4 Crypto_Aead_AesEax_Final
crypto_Aead_Status_E Crypto_Aead_AesEax_Final(
st_crypto_Aead_AesEax_Ctx *ptr_aesEaxCtx_st,
uint8_t *ptr_authTag,
uint32_t authTagLen
);
Description
This API is used to obtain the authentication tag for AES-EAX encryption. To use it, first initialize the context by calling the Crypto_Aead_AesEax_Init function. Then, calculate the authentication tag by calling Crypto_Aead_AesEax_Cipher. Finally, only after completing these steps, call this API.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|---|---|---|---|
1 | st_Crypto_Aead_AesEax_ctx* | ptr_aesEaxCtx_st | Input | AES-EAX Algorithm context |
2 | uint8_t* | ptr_authTag | Output/Input | Pointer to store authentication tag value |
3 | uint8_t* | authTagLen | Input | Authentication tag length in bytes, max 16 bytes |
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;
crypto_CipherOper_E cipherOper_en = CRYPTO_CIOP_ENCRYPT;
st_Crypto_Aead_AesEax_ctx AesEax_ctx ;
uint8_t inputData[32] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t key[32] = {/*data*/};
uint32_t keyLen = sizeof(key);
uint8_t outData[64];
uint32_t digestLen = sizeof(outData);
uint8_t nonce[32] = {/*data*/};
uint32_t nonceLen = sizeof(nonce);
uint8_t authTag[32] = {/*data*/};
uint32_t authTagLen = 16; // auth tag can be 4-16
uint8_t aad[32] = {/*data*/};
uint32_t aadLen = sizeof(aad);
crypto_Aead_Status_E status;
status = Crypto_Aead_AesEax_Init(
&AesEax_ctx,
handlerType_en,
cipherOper_en,
key,
keyLen,
nonce,
nonceLen,
ptr_aad,
aad,
sessionID
);
status = Crypto_Aead_AesEax_Cipher(
&AesEax_ctx,
inputData,
dataLen,
outData,
aad,
aadLen
);
status = Crypto_Aead_AesEax_AddAadData(
&AesEax_ctx,
aad,
aadLen
);
status = Crypto_Aead_AesEax_Final(
&AesEax_ctx,
authTag,
authTagLen
);