Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.25 KB

GUID-0939BA24-824A-48DC-831C-5FEFCA8BE5B2.md

File metadata and controls

57 lines (37 loc) · 1.25 KB

CRYPT_TDES_IvSet Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_TDES_IvSet(
    CRYPT_TDES_CTX* tdes, 
    const unsigned char* iv
);

Description

This function changes the initialization vector (IV) of a TDES context, but leaves the key alone.

Preconditions

None.

Parameters

Parameters Description
tdes Pointer to context which saves state between calls.
iv Pointer to buffer holding the initialization vector. Must be 8 bytes in size.

Returns

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

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

Remarks

The IV must be 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_IvSet(&mcDes3, iv);
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);