2.4.1.4 Crypto_Sym_Aes_EncryptDirect

crypto_Sym_Status_E Crypto_Sym_Aes_EncryptDirect(
    crypto_HandlerType_E handlerType_en,
    crypto_Sym_OpModes_E opMode_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 sessionID
    );

Description

This API performs AES encryption for different operation modes in a single step without initializing.

Parameters

No.Argument TypeArgument NameTypeDescription
1crypto_HandlerType_EhandlerType_enInputEnum for crypto operation handler i.e., SW, HW.
2crypto_Sym_OpModes_EopMode_enInputSelect operation mode. i.e., ECB, CBC, or others.
3uint8_t*ptr_inputDataInputInput data to encrypt.
4uint32_tdataLenInputInput length of plain data in bytes.
5uint8_t*ptr_outDataOutputPointer to store cipher text as output.
6uint8_t*ptr_keyInputKey for the Symmetric operation.
7uint32_tkeyLenInputKey length for the Symmetric algorithm in bytes.
8uint8_t*ptr_initVectInputInitialization vector (known as “Nonce” for CTR). Use NULL when ECB mode or XTS Mode.
9uint32_tsessionIDInputIt defines the session ID, must be more than zero.

Returns

Return TypeDescription
crypto_Sym_Status_EFunction returns the status of the API.

Example

#define sessionID 1
crypto_Sym_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_HW_INTERNAL;
crypto_Sym_OpModes_E opMode_en = CRYPTO_SYM_OPMODE_CBC;
uint8_t key[16] = {/*data*/};
uint32_t keyLen = sizeof(key);
uint8_t *ptr_initVect = NULL;
uint8_t inputData[64] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t outData[64];
uint8_t* ptr_tweak = {/*data*/};

status = Crypto_Sym_Aes_EncryptDirect(
    handlerType_en,
    opMode_en,
    inputData,
    dataLen,
    outData,
    key,
    keyLen,
    ptr_initVect,
    sessionID
);