AES_DecryptAndVerify

Syntax

#include <twl/aes.h>

#define AES_ENCRYPT_HEADER_SIZE 16

AESResult AES_DecryptAndVerify(
            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. It must be larger than 0, and less than or equal to AES_PDATA_SIZE_MAX.
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_SIGN_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 and verifies the signature of data that was encrypted using AES_EncryptAndSign().

This uses the key that was selected with AES_SetKey() to decrypt and verify the signature of the srcSize bytes starting from src. The decrypted result is written to a region starting at dst whose size is srcSize - AES_SIGN_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_EncryptAndSign

Revision History

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


CONFIDENTIAL