AES_Decrypt

Syntax

#include <twl/aes.h>

#define AES_ENCRYPT_HEADER_SIZE 16

AESResult AES_Decrypt(
            const void* src,
            u32         srcSize,
            void*       dst,
            AESCallback callback,
            void*       arg );

Arguments

src Pointer to ciphertext. Must be 4-byte aligned. In addition, it must point to a location in main memory.
srcSize Ciphertext size. Must be greater than zero.
dst Pointer to the buffer that will store the plaintext. Must be 4-byte aligned. In addition, it must point to a location in main memory. An area of size srcSize - AES_ENCRYPT_HEADER_SIZE bytes is required.
callback Pointer to the callback function to call when decryption completes. It is possible to specify NULL.
arg User-defined parameter that is passed to the above callback function. Can be any value, including NULL.

Return Values

Returns AES_RESULT_SUCCESS if the AES operation was started successfully. Any other return values indicate an error.

Description

Decrypts data that was encrypted using AES_Encrypt().

This function uses the key set with AES_SetKey() to decrypt srcSize bytes starting from src. The decrypted result is written to a region starting at dst whose size is srcSize - AES_ENCRYPT_HEADER_SIZE bytes. When the decryption process completes, callback is called, using the decrypted result and arg as arguments. callback is called from the interrupt handler, so it might be called even when interrupts are disabled. Conversely, callback will not be called when interrupts are disabled.

This function returns control immediately once it has started the processing. If processing starts without a problem, this function will return AES_RESULT_SUCCESS, but if an error occurs during subsequent processing, it will call callback with the error value and arg as arguments. Note: Error notification using this callback is started from the interrupt handler, so depending on the situation, it is possible that the callback can deliver error notification before control returns from the function.

The decryption key must be set beforehand using AES_SetKey().

See Also

AES_Encrypt

Revision History

2008/07/11 Added AES_ENCRYPT_HEADER_SIZE.
2007/12/25 Initial version.


CONFIDENTIAL