crypto_Sym_Status_E Crypto_Sym_AesKeyWrap_Cipher(
st_Crypto_Sym_BlockCtx *ptr_aesCtx_st,
uint8_t *ptr_inputData,
uint32_t dataLen,
uint8_t *ptr_outData
);
Description
This API is used to wrap or unwrap the data using AES-KW. Initialize context by
calling Crypto_Sym_AesKeyWrap_Init before calling this API.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|
1 | st_Crypto_Sym_BlockCtx* | ptr_aesCtx_st | Input | AES KW
algorithm context |
2 | uint8_t* | ptr_inputData | Input | Input data to
wrap or unwrap |
3 | uint32_t | dataLen | Input | Input length
of plain data or cipher data in bytes |
4 | uint8_t* | ptr_outData | Output | Pointer to
store cipher text/plain text as output |
Returns
Return Type | Description |
---|
crypto_Sym_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_Sym_AesKeyWrap_Init must be called prior to calling
Crypto_Sym_AesKeyWrap_Cipher.
Example
crypto_Sym_Status_E status;
#define sessionID 1
crypto_Sym_Status_E status;
st_Crypto_Sym_BlockCtx aesCtx_st;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_SW_WOLFCRYPT;
crypto_CipherOper_E cipherOpType_en = CRYPTO_CIOP_ENCRYPT;
uint8_t key[16] = {/*data*/};
uint32_t keyLen = sizeof(key);
uint8_t *ptr_initVect = {/*data*/};
uint8_t inputData[64] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t outData[64];
status = Crypto_Sym_AesKeyWrap_Init(
&aesCtx_st,
handlerType_en,
cipherOpType_en
key,
keyLen
ptr_initVect,
sessionID
);
status = Crypto_Sym_AesKeyWrap_Cipher(
&aesCtx_st,
inputData,
dataLen,
outData
);