AES_EncryptAndSign

Syntax

#include <twl/aes.h>

#define AES_SIGN_HEADER_SIZE    32

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

Arguments

src Pointer to the plaintext. Must be 4-byte aligned. In addition, it must point to a location in main memory.
srcSize Plaintext 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 ciphertext. 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 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.

Return Values

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

Description

Uses the AES algorithm to encrypt and sign data. AES_DecryptAndVerify() is used to decrypt data and verify signatures.

This function uses the key set with AES_SetKey() to encrypt and sign srcSize bytes, starting from src. The encrypted result and signature will be written to a region starting at dst whose size is srcSize + AES_SIGN_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().

See Also

AES_DecryptAndVerify

Revision History

2008/09/06 Revised in line with the removal of AES_InitRand.
2007/12/25 Initial version.


CONFIDENTIAL