1.20 CRYPT_AES_KeySet Function

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

ParametersDescription
aesPointer to context which saves state between calls.
keyPointer to buffer holding the key itself.
keyLenLength of key in bytes.
ivPointer to buffer holding the initialization vector.
dirWhich 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);