1.41 CRYPT_TDES_CBC_Decrypt Function

C

int CRYPT_TDES_CBC_Decrypt(
    CRYPT_TDES_CTX* tdes, 
    unsigned char* out, 
    const unsigned char* in, 
    unsigned int inSz
);

Description

This function decrypts a block of data using a Triple DES algorithm.

Preconditions

The context tdes must be set earlier using CRYPT_TDES_KeySet. The input block must be a multiple of 8 bytes long.

Parameters

ParametersDescription
tdesPointer to context which saves state between calls.
outPointer to output buffer to store the results.
inPointer to input buffer for the source of the data.
inSzSize of the input data buffer.

Returns

  • BAD_FUNC_ARG - An invalid pointer was passed to the function.

  • 0 - An invalid pointer was not passed to the function.

Remarks

Input data must have a length that is a multiple of 8 bytes. Output data will be zero-padded at the end if the original data was not a multiple of 8 bytes long.

Example

CRYPT_TDES_CTX mcDes3;
int            ret;
byte           out1[TDES_SIZE];
byte           out2[TDES_SIZE];

strncpy((char*)key, "1234567890abcdefghijklmn", 24);
strncpy((char*)iv,  "12345678", 8);

ret = CRYPT_TDES_KeySet(&mcDes3, key, iv, CRYPT_TDES_ENCRYPTION);
ret = CRYPT_TDES_CBC_Encrypt(&mcDes3, out1, ourData, TDES_SIZE);
ret = CRYPT_TDES_KeySet(&mcDes3, key, iv, CRYPT_TDES_DECRYPTION);
ret = CRYPT_TDES_CBC_Decrypt(&mcDes3, out2, out1, TDES_TEST_SIZE);