2.6.1.2 Crypto_Sym_Tdes_Cipher

crypto_Sym_Status_E Crypto_Sym_Tdes_Cipher(
    st_Crypto_Sym_BlockCtx *ptr_tdesCtx_st, 
    uint8_t *ptr_inputData, 
    uint32_t dataLen, 
    uint8_t *ptr_outData
    );

Description

This API performs TDES/3DES encryption or decryption for different operation modes. Initialize context by calling Crypto_Sym_Tdes_Init function before calling this API.

Parameters

No.Argument TypeArgument NameTypeDescription
1st_Crypto_Sym_BlockCtx*ptr_tdesCtx_stInputTDES/3DES algorithm context
2uint8_t*ptr_inputDataInputInput data to encrypt or decrypt
3uint32_tdataLenInputInput length of plain data or cipher data in bytes
4uint8_t*ptr_outDataOutputPointer to store cipher text/plain text as output

Returns

Return TypeDescription
crypto_Sym_Status_EFunction returns the status of the API.

Example

crypto_Sym_Status_E status;
#define sessionID 1
crypto_Sym_Status_E status;
st_Crypto_Sym_BlockCtx  tdesCtx_st;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_HW_INTERNAL;
crypto_CipherOper_E cipherOpType_en = CRYPTO_CIOP_ENCRYPT;
crypto_Sym_OpModes_E opMode_en = CRYPTO_SYM_OPMODE_ECB;
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];

status = Crypto_Sym_Tdes_Init(
    &tdesCtx_st, 
    handlerType_en, 
    cipherOpType_en, 
    opMode_en, 
    key, 
    ptr_initVect, 
    sessionID
    );

status =  Crypto_Sym_Tdes_Cipher(
    &tdesCtx_st, 
    inputData, 
    dataLen, 
    outData
    );