crypto_Aead_Status_E Crypto_Aead_AesEax_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_nonce,
uint32_t nonceLen,
uint8_t *ptr_aad,
uint32_t aadLen,
uint8_t *ptr_authTag,
uint32_t authTagLen,
uint32_t sessionID);
Description
This API performs AES-EAX 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-EAX cipher operation. |
6 | uint32_t | keyLen | Input | Key length in
bytes for the AES-EAX algorithm. |
7 | uint8_t* | ptr_nonce | Input | Pointer for
the Nonce value. |
8 | uint32_t | nonceLen | Input | Length of
Nonce 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, max 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. |
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_Aead_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 outData[32];
uint8_t nonce[32] = {/*data*/};
uint32_t nonceLen = sizeof(nonce);
uint8_t authTag[32];
uint32_t authTagLen = 16; ////auth tag length can be 4-16
uint8_t aad[32] = {/*data*/};
uint32_t aadLen = sizeof(aad);
status = Crypto_Aead_AesEax_EncryptAuthDirect(
handlerType_en,
inputData,
dataLen,
outData,
key,
keyLen,
nonce,
nonceLen,
aad,
aadLen,
authTag,
authTagLen,
sessionID
);