Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.15 KB

GUID-40FBBE9E-0D8E-426B-A2F1-BD98986910D8.md

File metadata and controls

57 lines (37 loc) · 1.15 KB

CRYPT_AES_KeySet Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_AES_KeySet(
    CRYPT_AES_CTX* aes, 
    const unsigned char* key, 
    unsigned int keyLen, 
    const unsigned char* iv, 
    int dir
);

Description

This function sets the key, IV, and direction (encryption or decryption) that AES will later perform.

Preconditions

None.

Parameters

Parameters Description
aes Pointer to context which saves state between calls.
key Pointer to buffer holding the key itself.
keyLen Length of key in bytes.
iv Pointer to buffer holding the initialization vector.
dir Which operation (CRYPT_AES_ENCRYPTION or CRYPT_AES_DECRYPTION).

Returns

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

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

Remarks

None.

Example

CRYPT_AES_CTX mcAes;
int           ret;

strncpy((char*)key, "1234567890abcdefghijklmnopqrstuv", 32);
strncpy((char*)iv,  "1234567890abcdef", 16);

ret = CRYPT_AES_KeySet(&mcAes, key, 16, iv, CRYPT_AES_ENCRYPTION);