#include <twl/aes.h>
#define AES_ENCRYPT_HEADER_SIZE 16
AESResult AES_Encrypt(
const void* src,
u32 srcSize,
void* dst,
AESCallback callback,
void* arg );
| src | Pointer to the plaintext. Must be 4-byte aligned. In addition, it must point to a location in main memory. |
|---|---|
| srcSize | Plaintext size. Must be greater than zero. |
| dst | Pointer to the buffer that will store the ciphertext. 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 encryption 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. |
Returns AES_RESULT_SUCCESS if the AES operation was started successfully. Any other return values indicate an error.
Uses the AES algorithm to encrypt data. AES_Decrypt() is used to decrypt data.
This uses the key set with AES_SetKey() to encrypt srcSize bytes starting from src. The encrypted result will be written to a region starting at dst whose size is srcSize + AES_ENCRYPT_HEADER_SIZE bytes. When the encryption process completes, callback will be called, using the encrypted result and arg as arguments. callback is called from the interrupt handler, so note that it may be called even when interrupts are disabled. Conversely, also note that callback is not 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 that error notification done using this callback will be started from the interrupt handler, so depending on the situation, it's possible that the callback could deliver an error notification before control returns from the function.
The encryption key must be set beforehand using AES_SetKey().
2008/09/06 Revised in line with the removal of AES_InitRand.
2007/12/25 Initial version.
CONFIDENTIAL