EE445M RTOS
Taken at the University of Texas Spring 2015
Aes_api

Functions

void AESReset (uint32_t ui32Base)
 
void AESConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void AESKey1Set (uint32_t ui32Base, uint32_t *pui32Key, uint32_t ui32Keysize)
 
void AESKey2Set (uint32_t ui32Base, uint32_t *pui32Key, uint32_t ui32Keysize)
 
void AESKey3Set (uint32_t ui32Base, uint32_t *pui32Key)
 
void AESIVSet (uint32_t ui32Base, uint32_t *pui32IVdata)
 
void AESIVRead (uint32_t ui32Base, uint32_t *pui32IVData)
 
void AESTagRead (uint32_t ui32Base, uint32_t *pui32TagData)
 
void AESLengthSet (uint32_t ui32Base, uint64_t ui64Length)
 
void AESAuthLengthSet (uint32_t ui32Base, uint32_t ui32Length)
 
bool AESDataReadNonBlocking (uint32_t ui32Base, uint32_t *pui32Dest)
 
void AESDataRead (uint32_t ui32Base, uint32_t *pui32Dest)
 
bool AESDataWriteNonBlocking (uint32_t ui32Base, uint32_t *pui32Src)
 
void AESDataWrite (uint32_t ui32Base, uint32_t *pui32Src)
 
bool AESDataProcess (uint32_t ui32Base, uint32_t *pui32Src, uint32_t *pui32Dest, uint32_t ui32Length)
 
bool AESDataAuth (uint32_t ui32Base, uint32_t *pui32Src, uint32_t ui32Length, uint32_t *pui32Tag)
 
bool AESDataProcessAuth (uint32_t ui32Base, uint32_t *pui32Src, uint32_t *pui32Dest, uint32_t ui32Length, uint32_t *pui32AuthSrc, uint32_t ui32AuthLength, uint32_t *pui32Tag)
 
uint32_t AESIntStatus (uint32_t ui32Base, bool bMasked)
 
void AESIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void AESIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void AESIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void AESIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void AESIntUnregister (uint32_t ui32Base)
 
void AESDMAEnable (uint32_t ui32Base, uint32_t ui32Flags)
 
void AESDMADisable (uint32_t ui32Base, uint32_t ui32Flags)
 

Detailed Description

Function Documentation

void AESAuthLengthSet ( uint32_t  ui32Base,
uint32_t  ui32Length 
)

Sets the authentication data length in the AES module.

Parameters
ui32Baseis the base address of the AES module.
ui32Lengthis the length in bytes.

This function is only used to write the authentication data length in the combined modes (GCM or CCM) and XTS mode. Supported AAD lengths for CCM are from 0 to (2^16 - 28) bytes. For GCM, any value up to (2^32 - 1) can be used. For XTS mode, this register is used to load j. Loading of j is only required if j != 0. j represents the sequential number of the 128-bit blocks inside the data unit. Consequently, j must be multiplied by 16 when passed to this function, thereby placing the block number in bits [31:4] of the register.

When this function is called, the engine is triggered to start using this context for GCM and CCM.

Returns
None

Definition at line 561 of file aes.c.

References AES_BASE, AES_O_AUTH_LENGTH, ASSERT, and HWREG.

Referenced by AESDataProcessAuth().

562 {
563  //
564  // Check the arguments.
565  //
566  ASSERT(ui32Base == AES_BASE);
567 
568  //
569  // Write the length into the register.
570  //
571  HWREG(ui32Base + AES_O_AUTH_LENGTH) = ui32Length;
572 }
#define AES_O_AUTH_LENGTH
Definition: hw_aes.h:75
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_BASE
Definition: hw_memmap.h:140

Here is the caller graph for this function:

void AESConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the AES module.

Parameters
ui32Baseis the base address of the AES module.
ui32Configis the configuration of the AES module.

This function configures the AES module based on the specified parameters. It does not change any DMA- or interrupt-related parameters.

The ui32Config parameter is a bit-wise OR of a number of configuration flags. The valid flags are grouped based on their function.

The direction of the operation is specified with only of following flags:

  • AES_CFG_DIR_ENCRYPT - Encryption mode
  • AES_CFG_DIR_DECRYPT - Decryption mode

The key size is specified with only one of the following flags:

  • AES_CFG_KEY_SIZE_128BIT - Key size of 128 bits
  • AES_CFG_KEY_SIZE_192BIT - Key size of 192 bits
  • AES_CFG_KEY_SIZE_256BIT - Key size of 256 bits

The mode of operation is specified with only one of the following flags.

  • AES_CFG_MODE_ECB - Electronic codebook mode
  • AES_CFG_MODE_CBC - Cipher-block chaining mode
  • AES_CFG_MODE_CFB - Cipher feedback mode
  • AES_CFG_MODE_CTR - Counter mode
  • AES_CFG_MODE_ICM - Integer counter mode
  • AES_CFG_MODE_XTS - Ciphertext stealing mode
  • AES_CFG_MODE_XTS_TWEAKJL - XEX-based tweaked-codebook mode with ciphertext stealing with previous/intermediate tweak value and j loaded
  • AES_CFG_MODE_XTS_K2IJL - XEX-based tweaked-codebook mode with ciphertext stealing with key2, i and j loaded
  • AES_CFG_MODE_XTS_K2ILJ0 - XEX-based tweaked-codebook mode with ciphertext stealing with key2 and i loaded, j = 0
  • AES_CFG_MODE_F8 - F8 mode
  • AES_CFG_MODE_F9 - F9 mode
  • AES_CFG_MODE_CBCMAC - Cipher block chaining message authentication code mode
  • AES_CFG_MODE_GCM_HLY0ZERO - Galois/counter mode with GHASH with H loaded, Y0-encrypted forced to zero and counter is not enabled.
  • AES_CFG_MODE_GCM_HLY0CALC - Galois/counter mode with GHASH with H loaded, Y0-encrypted calculated internally and counter is enabled.
  • AES_CFG_MODE_GCM_HY0CALC - Galois/Counter mode with autonomous GHASH (both H and Y0-encrypted calculated internally) and counter is enabled.
  • AES_CFG_MODE_CCM - Counter with CBC-MAC mode

The following defines are used to specify the counter width. It is only required to be defined when using CTR, CCM, or GCM modes, only one of the following defines must be used to specify the counter width length:

  • AES_CFG_CTR_WIDTH_32 - Counter is 32 bits
  • AES_CFG_CTR_WIDTH_64 - Counter is 64 bits
  • AES_CFG_CTR_WIDTH_96 - Counter is 96 bits
  • AES_CFG_CTR_WIDTH_128 - Counter is 128 bits

Only one of the following defines must be used to specify the length field for CCM operations (L):

  • AES_CFG_CCM_L_1 - 1 byte
  • AES_CFG_CCM_L_2 - 2 bytes
  • AES_CFG_CCM_L_3 - 3 bytes
  • AES_CFG_CCM_L_4 - 4 bytes
  • AES_CFG_CCM_L_5 - 5 bytes
  • AES_CFG_CCM_L_6 - 6 bytes
  • AES_CFG_CCM_L_7 - 7 bytes
  • AES_CFG_CCM_L_8 - 8 bytes

Only one of the following defines must be used to specify the length of the authentication field for CCM operations (M) through the ui32Config argument in the AESConfigSet() function:

  • AES_CFG_CCM_M_4 - 4 bytes
  • AES_CFG_CCM_M_6 - 6 bytes
  • AES_CFG_CCM_M_8 - 8 bytes
  • AES_CFG_CCM_M_10 - 10 bytes
  • AES_CFG_CCM_M_12 - 12 bytes
  • AES_CFG_CCM_M_14 - 14 bytes
  • AES_CFG_CCM_M_16 - 16 bytes
Note
When performing a basic GHASH operation for used with GCM mode, use the AES_CFG_MODE_GCM_HLY0ZERO and do not specify a direction.
Returns
None.

Definition at line 183 of file aes.c.

References AES_BASE, AES_CFG_CCM_L_1, AES_CFG_CCM_L_2, AES_CFG_CCM_L_3, AES_CFG_CCM_L_4, AES_CFG_CCM_L_5, AES_CFG_CCM_L_6, AES_CFG_CCM_L_7, AES_CFG_CCM_L_8, AES_CFG_CCM_M_10, AES_CFG_CCM_M_12, AES_CFG_CCM_M_14, AES_CFG_CCM_M_16, AES_CFG_CCM_M_4, AES_CFG_CCM_M_6, AES_CFG_CCM_M_8, AES_CFG_CTR_WIDTH_128, AES_CFG_CTR_WIDTH_32, AES_CFG_CTR_WIDTH_64, AES_CFG_CTR_WIDTH_96, AES_CFG_DIR_DECRYPT, AES_CFG_DIR_ENCRYPT, AES_CFG_KEY_SIZE_128BIT, AES_CFG_KEY_SIZE_192BIT, AES_CFG_KEY_SIZE_256BIT, AES_CFG_MODE_CBC, AES_CFG_MODE_CBCMAC, AES_CFG_MODE_CCM, AES_CFG_MODE_CFB, AES_CFG_MODE_CTR, AES_CFG_MODE_ECB, AES_CFG_MODE_F8, AES_CFG_MODE_F9, AES_CFG_MODE_GCM_HLY0CALC, AES_CFG_MODE_GCM_HLY0ZERO, AES_CFG_MODE_GCM_HY0CALC, AES_CFG_MODE_ICM, AES_CFG_MODE_XTS_K2IJL, AES_CFG_MODE_XTS_K2ILJ0, AES_CFG_MODE_XTS_TWEAKJL, AES_CTRL_SAVE_CONTEXT, AES_O_CTRL, ASSERT, and HWREG.

184 {
185  //
186  // Check the arguments.
187  //
188  ASSERT(ui32Base == AES_BASE);
189  ASSERT((ui32Config & AES_CFG_DIR_ENCRYPT) ||
190  (ui32Config & AES_CFG_DIR_DECRYPT));
191  ASSERT((ui32Config & AES_CFG_KEY_SIZE_128BIT) ||
192  (ui32Config & AES_CFG_KEY_SIZE_192BIT) ||
193  (ui32Config & AES_CFG_KEY_SIZE_256BIT));
194  ASSERT((ui32Config & AES_CFG_MODE_ECB) ||
195  (ui32Config & AES_CFG_MODE_CBC) ||
196  (ui32Config & AES_CFG_MODE_CTR) ||
197  (ui32Config & AES_CFG_MODE_ICM) ||
198  (ui32Config & AES_CFG_MODE_CFB) ||
199  (ui32Config & AES_CFG_MODE_XTS_TWEAKJL) ||
200  (ui32Config & AES_CFG_MODE_XTS_K2IJL) ||
201  (ui32Config & AES_CFG_MODE_XTS_K2ILJ0) ||
202  (ui32Config & AES_CFG_MODE_F8) ||
203  (ui32Config & AES_CFG_MODE_F9) ||
204  (ui32Config & AES_CFG_MODE_CTR) ||
205  (ui32Config & AES_CFG_MODE_CBCMAC) ||
206  (ui32Config & AES_CFG_MODE_GCM_HLY0ZERO) ||
207  (ui32Config & AES_CFG_MODE_GCM_HLY0CALC) ||
208  (ui32Config & AES_CFG_MODE_GCM_HY0CALC) ||
209  (ui32Config & AES_CFG_MODE_CCM));
210  ASSERT(((ui32Config & AES_CFG_MODE_CTR) ||
211  (ui32Config & AES_CFG_MODE_GCM_HLY0ZERO) ||
212  (ui32Config & AES_CFG_MODE_GCM_HLY0CALC) ||
213  (ui32Config & AES_CFG_MODE_GCM_HY0CALC) ||
214  (ui32Config & AES_CFG_MODE_CCM)) &&
215  ((ui32Config & AES_CFG_CTR_WIDTH_32) ||
216  (ui32Config & AES_CFG_CTR_WIDTH_64) ||
217  (ui32Config & AES_CFG_CTR_WIDTH_96) ||
218  (ui32Config & AES_CFG_CTR_WIDTH_128)));
219  ASSERT((ui32Config & AES_CFG_MODE_CCM) &&
220  ((ui32Config & AES_CFG_CCM_L_1) ||
221  (ui32Config & AES_CFG_CCM_L_2) ||
222  (ui32Config & AES_CFG_CCM_L_3) ||
223  (ui32Config & AES_CFG_CCM_L_4) ||
224  (ui32Config & AES_CFG_CCM_L_5) ||
225  (ui32Config & AES_CFG_CCM_L_6) ||
226  (ui32Config & AES_CFG_CCM_L_7) ||
227  (ui32Config & AES_CFG_CCM_L_8)) &&
228  ((ui32Config & AES_CFG_CCM_M_4) ||
229  (ui32Config & AES_CFG_CCM_M_6) ||
230  (ui32Config & AES_CFG_CCM_M_8) ||
231  (ui32Config & AES_CFG_CCM_M_10) ||
232  (ui32Config & AES_CFG_CCM_M_12) ||
233  (ui32Config & AES_CFG_CCM_M_14) ||
234  (ui32Config & AES_CFG_CCM_M_16)));
235 
236  //
237  // Backup the save context field before updating the register.
238  //
239  if(HWREG(ui32Base + AES_O_CTRL) & AES_CTRL_SAVE_CONTEXT)
240  {
241  ui32Config |= AES_CTRL_SAVE_CONTEXT;
242  }
243 
244  //
245  // Write the CTRL register with the new value
246  //
247  HWREG(ui32Base + AES_O_CTRL) = ui32Config;
248 }
#define AES_CFG_CCM_M_10
Definition: aes.h:140
#define AES_CFG_MODE_CTR
Definition: aes.h:82
#define AES_CFG_KEY_SIZE_128BIT
Definition: aes.h:69
#define AES_CFG_MODE_ECB
Definition: aes.h:80
#define AES_CFG_MODE_CFB
Definition: aes.h:84
#define AES_CFG_MODE_F9
Definition: aes.h:92
#define HWREG(x)
Definition: hw_types.h:48
#define AES_CFG_MODE_XTS_K2ILJ0
Definition: aes.h:89
#define AES_CFG_MODE_CBC
Definition: aes.h:81
#define AES_CFG_MODE_XTS_K2IJL
Definition: aes.h:87
#define AES_CFG_MODE_CBCMAC
Definition: aes.h:93
#define AES_CFG_MODE_GCM_HY0CALC
Definition: aes.h:98
#define AES_CFG_CCM_L_4
Definition: aes.h:124
#define AES_CFG_CCM_M_12
Definition: aes.h:141
#define AES_CFG_MODE_ICM
Definition: aes.h:83
#define ASSERT(expr)
Definition: debug.h:67
#define AES_CFG_CCM_L_8
Definition: aes.h:128
#define AES_CFG_MODE_CCM
Definition: aes.h:100
#define AES_CFG_CCM_L_1
Definition: aes.h:121
#define AES_CFG_CTR_WIDTH_32
Definition: aes.h:109
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_CFG_CCM_M_4
Definition: aes.h:137
#define AES_CTRL_SAVE_CONTEXT
Definition: hw_aes.h:266
#define AES_CFG_CTR_WIDTH_128
Definition: aes.h:112
#define AES_CFG_CCM_L_5
Definition: aes.h:125
#define AES_CFG_CCM_M_16
Definition: aes.h:143
#define AES_CFG_KEY_SIZE_256BIT
Definition: aes.h:71
#define AES_CFG_CCM_L_7
Definition: aes.h:127
#define AES_CFG_CCM_L_6
Definition: aes.h:126
#define AES_CFG_CCM_L_2
Definition: aes.h:122
#define AES_CFG_CCM_M_14
Definition: aes.h:142
#define AES_CFG_MODE_GCM_HLY0ZERO
Definition: aes.h:94
#define AES_CFG_CTR_WIDTH_64
Definition: aes.h:110
#define AES_CFG_MODE_F8
Definition: aes.h:91
#define AES_CFG_CCM_L_3
Definition: aes.h:123
#define AES_CFG_KEY_SIZE_192BIT
Definition: aes.h:70
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_CFG_CCM_M_6
Definition: aes.h:138
#define AES_CFG_CTR_WIDTH_96
Definition: aes.h:111
#define AES_CFG_DIR_DECRYPT
Definition: aes.h:61
#define AES_CFG_MODE_XTS_TWEAKJL
Definition: aes.h:85
#define AES_CFG_CCM_M_8
Definition: aes.h:139
#define AES_CFG_DIR_ENCRYPT
Definition: aes.h:60
#define AES_CFG_MODE_GCM_HLY0CALC
Definition: aes.h:96
bool AESDataAuth ( uint32_t  ui32Base,
uint32_t *  pui32Src,
uint32_t  ui32Length,
uint32_t *  pui32Tag 
)

Used to authenticate blocks of data by generating a hash tag.

Parameters
ui32Baseis the base address of the AES module.
pui32Srcis a pointer to the memory location where the input data is stored. The data must be padded to the 16-byte boundary.
ui32Lengthis the length of the cryptographic data in bytes.
pui32Tagis a pointer to a 4-word array where the hash tag is written.

This function processes data to produce a hash tag that can be used tor authentication. Before calling this function, ensure that the AES module is properly configured the key, data size, mode, etc. Only CBC-MAC and F9 modes should be used.

Returns
Returns true if data was processed successfully. Returns false if data processing failed.

Definition at line 825 of file aes.c.

References AES_BASE, AESDataWrite(), AESLengthSet(), AESTagRead(), and ASSERT.

827 {
828  uint32_t ui32Count;
829 
830  //
831  // Check the arguments.
832  //
833  ASSERT(ui32Base == AES_BASE);
834 
835  //
836  // Write the length register first, which triggers the engine to start
837  // using this context.
838  //
839  AESLengthSet(ui32Base, (uint64_t)ui32Length);
840 
841  //
842  // Now loop until the blocks are written.
843  //
844  for(ui32Count = 0; ui32Count < ui32Length; ui32Count += 16)
845  {
846  //
847  // Write the data registers.
848  //
849  AESDataWrite(ui32Base, pui32Src + (ui32Count / 4));
850  }
851 
852  //
853  // Read the hash tag value.
854  //
855  AESTagRead(ui32Base, pui32Tag);
856 
857  //
858  // Return true to indicate successful completion of the function.
859  //
860  return(true);
861 }
void AESLengthSet(uint32_t ui32Base, uint64_t ui64Length)
Definition: aes.c:524
#define ASSERT(expr)
Definition: debug.h:67
void AESTagRead(uint32_t ui32Base, uint32_t *pui32TagData)
Definition: aes.c:477
void AESDataWrite(uint32_t ui32Base, uint32_t *pui32Src)
Definition: aes.c:718
#define AES_BASE
Definition: hw_memmap.h:140

Here is the call graph for this function:

bool AESDataProcess ( uint32_t  ui32Base,
uint32_t *  pui32Src,
uint32_t *  pui32Dest,
uint32_t  ui32Length 
)

Used to process(transform) blocks of data, either encrypt or decrypt it.

Parameters
ui32Baseis the base address of the AES module.
pui32Srcis a pointer to the memory location where the input data is stored. The data must be padded to the 16-byte boundary.
pui32Destis a pointer to the memory location output is written. The space for written data must be rounded up to the 16-byte boundary.
ui32Lengthis the length of the cryptographic data in bytes.

This function iterates the encryption or decryption mechanism number over the data length. Before calling this function, ensure that the AES module is properly configured the key, data size, mode, etc. Only ECB, CBC, CTR, ICM, CFB, XTS and F8 operating modes should be used. The data is processed in 4-word (16-byte) blocks.

Note
This function only supports values of ui32Length less than 2^32, because the memory size is restricted to between 0 to 2^32 bytes.
Returns
Returns true if data was processed successfully. Returns false if data processing failed.

Definition at line 766 of file aes.c.

References AES_BASE, AESDataRead(), AESDataWrite(), AESLengthSet(), and ASSERT.

768 {
769  uint32_t ui32Count;
770 
771  //
772  // Check the arguments.
773  //
774  ASSERT(ui32Base == AES_BASE);
775 
776  //
777  // Write the length register first, which triggers the engine to start
778  // using this context.
779  //
780  AESLengthSet(AES_BASE, (uint64_t)ui32Length);
781 
782  //
783  // Now loop until the blocks are written.
784  //
785  for(ui32Count = 0; ui32Count < ui32Length; ui32Count += 16)
786  {
787  //
788  // Write the data registers.
789  //
790  AESDataWrite(ui32Base, pui32Src + (ui32Count / 4));
791 
792  //
793  // Read the data registers.
794  //
795  AESDataRead(ui32Base, pui32Dest + (ui32Count / 4));
796  }
797 
798  //
799  // Return true to indicate successful completion of the function.
800  //
801  return(true);
802 }
void AESLengthSet(uint32_t ui32Base, uint64_t ui64Length)
Definition: aes.c:524
#define ASSERT(expr)
Definition: debug.h:67
void AESDataRead(uint32_t ui32Base, uint32_t *pui32Dest)
Definition: aes.c:635
void AESDataWrite(uint32_t ui32Base, uint32_t *pui32Src)
Definition: aes.c:718
#define AES_BASE
Definition: hw_memmap.h:140

Here is the call graph for this function:

bool AESDataProcessAuth ( uint32_t  ui32Base,
uint32_t *  pui32Src,
uint32_t *  pui32Dest,
uint32_t  ui32Length,
uint32_t *  pui32AuthSrc,
uint32_t  ui32AuthLength,
uint32_t *  pui32Tag 
)

Processes and authenticates blocks of data, either encrypt it or decrypts it.

Parameters
ui32Baseis the base address of the AES module.
pui32Srcis a pointer to the memory location where the input data is stored. The data must be padded to the 16-byte boundary.
pui32Destis a pointer to the memory location output is written. The space for written data must be rounded up to the 16-byte boundary.
ui32Lengthis the length of the cryptographic data in bytes.
pui32AuthSrcis a pointer to the memory location where the additional authentication data is stored. The data must be padded to the 16-byte boundary.
ui32AuthLengthis the length of the additional authentication data in bytes.
pui32Tagis a pointer to a 4-word array where the hash tag is written.

This function encrypts or decrypts blocks of data in addition to authentication data. A hash tag is also produced. Before calling this function, ensure that the AES module is properly configured the key, data size, mode, etc. Only CCM and GCM modes should be used.

Returns
Returns true if data was processed successfully. Returns false if data processing failed.

Definition at line 892 of file aes.c.

References AES_BASE, AESAuthLengthSet(), AESDataRead(), AESDataWrite(), AESLengthSet(), AESTagRead(), and ASSERT.

896 {
897  uint32_t ui32Count;
898 
899  //
900  // Check the arguments.
901  //
902  ASSERT(ui32Base == AES_BASE);
903 
904  //
905  // Set the data length.
906  //
907  AESLengthSet(ui32Base, (uint64_t)ui32Length);
908 
909  //
910  // Set the additional authentication data length.
911  //
912  AESAuthLengthSet(ui32Base, ui32AuthLength);
913 
914  //
915  // Now loop until the authentication data blocks are written.
916  //
917  for(ui32Count = 0; ui32Count < ui32AuthLength; ui32Count += 16)
918  {
919  //
920  // Write the data registers.
921  //
922  AESDataWrite(ui32Base, pui32AuthSrc + (ui32Count / 4));
923  }
924 
925  //
926  // Now loop until the data blocks are written.
927  //
928  for(ui32Count = 0; ui32Count < ui32Length; ui32Count += 16)
929  {
930  //
931  // Write the data registers.
932  //
933  AESDataWrite(ui32Base, pui32Src + (ui32Count / 4));
934 
935  //
936  //
937  // Read the data registers.
938  //
939  AESDataRead(ui32Base, pui32Dest + (ui32Count / 4));
940  }
941 
942  //
943  // Read the hash tag value.
944  //
945  AESTagRead(ui32Base, pui32Tag);
946 
947  //
948  // Return true to indicate successful completion of the function.
949  //
950  return(true);
951 }
void AESLengthSet(uint32_t ui32Base, uint64_t ui64Length)
Definition: aes.c:524
void AESAuthLengthSet(uint32_t ui32Base, uint32_t ui32Length)
Definition: aes.c:561
#define ASSERT(expr)
Definition: debug.h:67
void AESDataRead(uint32_t ui32Base, uint32_t *pui32Dest)
Definition: aes.c:635
void AESTagRead(uint32_t ui32Base, uint32_t *pui32TagData)
Definition: aes.c:477
void AESDataWrite(uint32_t ui32Base, uint32_t *pui32Src)
Definition: aes.c:718
#define AES_BASE
Definition: hw_memmap.h:140

Here is the call graph for this function:

void AESDataRead ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads plaintext/ciphertext from data registers with blocking.

Parameters
ui32Baseis the base address of the AES module.
pui32Destis a pointer to an array of words.

This function reads a block of either plaintext or ciphertext out of the AES module. If the output is not ready, the function waits until it is ready. A block is 16 bytes or 4 words.

Returns
None.

Definition at line 635 of file aes.c.

References AES_BASE, AES_CTRL_OUTPUT_READY, AES_O_CTRL, AES_O_DATA_IN_0, AES_O_DATA_IN_1, AES_O_DATA_IN_2, AES_O_DATA_IN_3, ASSERT, and HWREG.

Referenced by AESDataProcess(), and AESDataProcessAuth().

636 {
637  //
638  // Check the arguments.
639  //
640  ASSERT(ui32Base == AES_BASE);
641 
642  //
643  // Wait for the output to be ready before reading the data.
644  //
645  while((AES_CTRL_OUTPUT_READY & (HWREG(ui32Base + AES_O_CTRL))) == 0)
646  {
647  }
648 
649  //
650  // Read a block of data from the data registers
651  //
652  pui32Dest[0] = HWREG(ui32Base + AES_O_DATA_IN_3);
653  pui32Dest[1] = HWREG(ui32Base + AES_O_DATA_IN_2);
654  pui32Dest[2] = HWREG(ui32Base + AES_O_DATA_IN_1);
655  pui32Dest[3] = HWREG(ui32Base + AES_O_DATA_IN_0);
656 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_DATA_IN_0
Definition: hw_aes.h:76
#define AES_CTRL_OUTPUT_READY
Definition: hw_aes.h:314
#define AES_O_DATA_IN_2
Definition: hw_aes.h:80
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_O_DATA_IN_1
Definition: hw_aes.h:78
#define AES_O_DATA_IN_3
Definition: hw_aes.h:82
#define AES_BASE
Definition: hw_memmap.h:140

Here is the caller graph for this function:

bool AESDataReadNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads plaintext/ciphertext from data registers without blocking.

Parameters
ui32Baseis the base address of the AES module.
pui32Destis a pointer to an array of words of data.

This function reads a block of either plaintext or ciphertext out of the AES module. If the output data is not ready, the function returns false. If the read completed successfully, the function returns true. A block is 16 bytes or 4 words.

Returns
true or false.

Definition at line 590 of file aes.c.

References AES_BASE, AES_CTRL_OUTPUT_READY, AES_O_CTRL, AES_O_DATA_IN_0, AES_O_DATA_IN_1, AES_O_DATA_IN_2, AES_O_DATA_IN_3, ASSERT, and HWREG.

591 {
592  //
593  // Check the arguments.
594  //
595  ASSERT(ui32Base == AES_BASE);
596 
597  //
598  // Check if the output is ready before reading the data. If it not ready,
599  // return false.
600  //
601  if((AES_CTRL_OUTPUT_READY & (HWREG(ui32Base + AES_O_CTRL))) == 0)
602  {
603  return(false);
604  }
605 
606  //
607  // Read a block of data from the data registers
608  //
609  pui32Dest[0] = HWREG(ui32Base + AES_O_DATA_IN_3);
610  pui32Dest[1] = HWREG(ui32Base + AES_O_DATA_IN_2);
611  pui32Dest[2] = HWREG(ui32Base + AES_O_DATA_IN_1);
612  pui32Dest[3] = HWREG(ui32Base + AES_O_DATA_IN_0);
613 
614  //
615  // Read successful, return true.
616  //
617  return(true);
618 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_DATA_IN_0
Definition: hw_aes.h:76
#define AES_CTRL_OUTPUT_READY
Definition: hw_aes.h:314
#define AES_O_DATA_IN_2
Definition: hw_aes.h:80
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_O_DATA_IN_1
Definition: hw_aes.h:78
#define AES_O_DATA_IN_3
Definition: hw_aes.h:82
#define AES_BASE
Definition: hw_memmap.h:140
void AESDataWrite ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes plaintext/ciphertext to data registers with blocking.

Parameters
ui32Baseis the base address of the AES module.
pui32Srcis a pointer to an array of bytes.

This function writes a block of either plaintext or ciphertext into the AES module. If the input is not ready, the function waits until it is ready before performing the write. A block is 16 bytes or 4 words.

Returns
None.

Definition at line 718 of file aes.c.

References AES_BASE, AES_CTRL_INPUT_READY, AES_O_CTRL, AES_O_DATA_IN_0, AES_O_DATA_IN_1, AES_O_DATA_IN_2, AES_O_DATA_IN_3, ASSERT, and HWREG.

Referenced by AESDataAuth(), AESDataProcess(), and AESDataProcessAuth().

719 {
720  //
721  // Check the arguments.
722  //
723  ASSERT(ui32Base == AES_BASE);
724 
725  //
726  // Wait for input ready.
727  //
728  while((AES_CTRL_INPUT_READY & (HWREG(ui32Base + AES_O_CTRL))) == 0)
729  {
730  }
731 
732  //
733  // Write a block of data into the data registers.
734  //
735  HWREG(ui32Base + AES_O_DATA_IN_3) = pui32Src[0];
736  HWREG(ui32Base + AES_O_DATA_IN_2) = pui32Src[1];
737  HWREG(ui32Base + AES_O_DATA_IN_1) = pui32Src[2];
738  HWREG(ui32Base + AES_O_DATA_IN_0) = pui32Src[3];
739 }
#define HWREG(x)
Definition: hw_types.h:48
#define AES_CTRL_INPUT_READY
Definition: hw_aes.h:313
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_DATA_IN_0
Definition: hw_aes.h:76
#define AES_O_DATA_IN_2
Definition: hw_aes.h:80
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_O_DATA_IN_1
Definition: hw_aes.h:78
#define AES_O_DATA_IN_3
Definition: hw_aes.h:82
#define AES_BASE
Definition: hw_memmap.h:140

Here is the caller graph for this function:

bool AESDataWriteNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes plaintext/ciphertext to data registers without blocking.

Parameters
ui32Baseis the base address of the AES module.
pui32Srcis a pointer to an array of words of data.

This function writes a block of either plaintext or ciphertext into the AES module. If the input is not ready, the function returns false. If the write completed successfully, the function returns true. A block is 16 bytes or 4 words.

Returns
True or false.

Definition at line 674 of file aes.c.

References AES_BASE, AES_CTRL_INPUT_READY, AES_O_CTRL, AES_O_DATA_IN_0, AES_O_DATA_IN_1, AES_O_DATA_IN_2, AES_O_DATA_IN_3, ASSERT, and HWREG.

675 {
676  //
677  // Check the arguments.
678  //
679  ASSERT(ui32Base == AES_BASE);
680 
681  //
682  // Check if the input is ready. If not, then return false.
683  //
684  if(!(AES_CTRL_INPUT_READY & (HWREG(ui32Base + AES_O_CTRL))))
685  {
686  return(false);
687  }
688 
689  //
690  // Write a block of data into the data registers.
691  //
692  HWREG(ui32Base + AES_O_DATA_IN_3) = pui32Src[0];
693  HWREG(ui32Base + AES_O_DATA_IN_2) = pui32Src[1];
694  HWREG(ui32Base + AES_O_DATA_IN_1) = pui32Src[2];
695  HWREG(ui32Base + AES_O_DATA_IN_0) = pui32Src[3];
696 
697  //
698  // Write successful, return true.
699  //
700  return(true);
701 }
#define HWREG(x)
Definition: hw_types.h:48
#define AES_CTRL_INPUT_READY
Definition: hw_aes.h:313
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_DATA_IN_0
Definition: hw_aes.h:76
#define AES_O_DATA_IN_2
Definition: hw_aes.h:80
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_O_DATA_IN_1
Definition: hw_aes.h:78
#define AES_O_DATA_IN_3
Definition: hw_aes.h:82
#define AES_BASE
Definition: hw_memmap.h:140
void AESDMADisable ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Disables uDMA requests for the AES module.

Parameters
ui32Baseis the base address of the AES module.
ui32Flagsis a bit mask of the uDMA requests to be disabled.

This function disables the uDMA request sources in the AES module. The ui32Flags parameter is the logical OR of any of the following:

  • AES_DMA_DATA_IN
  • AES_DMA_DATA_OUT
  • AES_DMA_CONTEXT_IN
  • AES_DMA_CONTEXT_OUT
Returns
None.

Definition at line 1283 of file aes.c.

References AES_BASE, AES_DMA_CONTEXT_IN, AES_DMA_CONTEXT_OUT, AES_DMA_DATA_IN, AES_DMA_DATA_OUT, AES_O_SYSCONFIG, ASSERT, and HWREG.

1284 {
1285  //
1286  // Check the arguments.
1287  //
1288  ASSERT(ui32Base == AES_BASE);
1289  ASSERT((ui32Flags == AES_DMA_DATA_IN) ||
1290  (ui32Flags == AES_DMA_DATA_OUT) ||
1291  (ui32Flags == AES_DMA_CONTEXT_IN) ||
1292  (ui32Flags == AES_DMA_CONTEXT_OUT));
1293 
1294  //
1295  // Clear the flags in the current register value.
1296  //
1297  HWREG(ui32Base + AES_O_SYSCONFIG) &= ~ui32Flags;
1298 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_DMA_DATA_OUT
Definition: aes.h:167
#define AES_DMA_CONTEXT_IN
Definition: aes.h:168
#define AES_DMA_DATA_IN
Definition: aes.h:166
#define AES_O_SYSCONFIG
Definition: hw_aes.h:89
#define AES_DMA_CONTEXT_OUT
Definition: aes.h:169
#define AES_BASE
Definition: hw_memmap.h:140
void AESDMAEnable ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Enables uDMA requests for the AES module.

Parameters
ui32Baseis the base address of the AES module.
ui32Flagsis a bit mask of the uDMA requests to be enabled.

This function enables the uDMA request sources in the AES module. The ui32Flags parameter is the logical OR of any of the following:

  • AES_DMA_DATA_IN
  • AES_DMA_DATA_OUT
  • AES_DMA_CONTEXT_IN
  • AES_DMA_CONTEXT_OUT
Returns
None.

Definition at line 1246 of file aes.c.

References AES_BASE, AES_DMA_CONTEXT_IN, AES_DMA_CONTEXT_OUT, AES_DMA_DATA_IN, AES_DMA_DATA_OUT, AES_O_SYSCONFIG, ASSERT, and HWREG.

1247 {
1248  //
1249  // Check the arguments.
1250  //
1251  ASSERT(ui32Base == AES_BASE);
1252  ASSERT((ui32Flags == AES_DMA_DATA_IN) ||
1253  (ui32Flags == AES_DMA_DATA_OUT) ||
1254  (ui32Flags == AES_DMA_CONTEXT_IN) ||
1255  (ui32Flags == AES_DMA_CONTEXT_OUT));
1256 
1257  //
1258  // Set the flags in the current register value.
1259  //
1260  HWREG(ui32Base + AES_O_SYSCONFIG) |= ui32Flags;
1261 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_DMA_DATA_OUT
Definition: aes.h:167
#define AES_DMA_CONTEXT_IN
Definition: aes.h:168
#define AES_DMA_DATA_IN
Definition: aes.h:166
#define AES_O_SYSCONFIG
Definition: hw_aes.h:89
#define AES_DMA_CONTEXT_OUT
Definition: aes.h:169
#define AES_BASE
Definition: hw_memmap.h:140
void AESIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears AES module interrupts.

Parameters
ui32Baseis the base address of the AES module.
ui32IntFlagsis a bit mask of the interrupt sources to disable.

This function clears the interrupt sources in the AES module. The ui32IntFlags parameter is the logical OR of any of the following:

  • AES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • AES_INT_DMA_CONTEXT_OUT - Authentication tag (and IV) DMA done interrupt
  • AES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • AES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Note
Only the DMA done interrupts can be cleared. The remaining interrupts should be disabled with AESIntDisable().
Returns
None.

Definition at line 1133 of file aes.c.

References AES_BASE, AES_INT_DMA_CONTEXT_IN, AES_INT_DMA_CONTEXT_OUT, AES_INT_DMA_DATA_IN, AES_INT_DMA_DATA_OUT, AES_O_DMAIC, ASSERT, and HWREG.

1134 {
1135  //
1136  // Check the arguments.
1137  //
1138  ASSERT(ui32Base == AES_BASE);
1139  ASSERT((ui32IntFlags == AES_INT_DMA_CONTEXT_IN) ||
1140  (ui32IntFlags == AES_INT_DMA_CONTEXT_OUT) ||
1141  (ui32IntFlags == AES_INT_DMA_DATA_IN) ||
1142  (ui32IntFlags == AES_INT_DMA_DATA_OUT));
1143 
1144  HWREG(ui32Base + AES_O_DMAIC) = (((ui32IntFlags & 0x00010000) >> 16) |
1145  ((ui32IntFlags & 0x00060000) >> 15) |
1146  ((ui32IntFlags & 0x00080000) >> 18));
1147 }
#define HWREG(x)
Definition: hw_types.h:48
#define AES_INT_DMA_DATA_OUT
Definition: aes.h:158
#define AES_INT_DMA_CONTEXT_IN
Definition: aes.h:155
#define ASSERT(expr)
Definition: debug.h:67
#define AES_INT_DMA_CONTEXT_OUT
Definition: aes.h:156
#define AES_O_DMAIC
Definition: hw_aes.h:97
#define AES_INT_DMA_DATA_IN
Definition: aes.h:157
#define AES_BASE
Definition: hw_memmap.h:140
void AESIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables AES module interrupts.

Parameters
ui32Baseis the base address of the AES module.
ui32IntFlagsis a bit mask of the interrupt sources to disable.

This function disables the interrupt sources in the AES module. The ui32IntFlags parameter is the logical OR of any of the following:

  • AES_INT_CONTEXT_IN - Context interrupt
  • AES_INT_CONTEXT_OUT - Authentication tag (and IV) interrupt
  • AES_INT_DATA_IN - Data input interrupt
  • AES_INT_DATA_OUT - Data output interrupt
  • AES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • AES_INT_DMA_CONTEXT_OUT - Authentication tag (and IV) DMA done interrupt
  • AES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • AES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Note
The DMA done interrupts are the only interrupts that can be cleared. The remaining interrupts can be disabled instead using AESIntDisable().
Returns
None.

Definition at line 1086 of file aes.c.

References AES_BASE, AES_INT_CONTEXT_IN, AES_INT_CONTEXT_OUT, AES_INT_DATA_IN, AES_INT_DATA_OUT, AES_INT_DMA_CONTEXT_IN, AES_INT_DMA_CONTEXT_OUT, AES_INT_DMA_DATA_IN, AES_INT_DMA_DATA_OUT, AES_O_DMAIM, AES_O_IRQENABLE, ASSERT, and HWREG.

1087 {
1088  //
1089  // Check the arguments.
1090  //
1091  ASSERT(ui32Base == AES_BASE);
1092  ASSERT((ui32IntFlags == AES_INT_CONTEXT_IN) ||
1093  (ui32IntFlags == AES_INT_CONTEXT_OUT) ||
1094  (ui32IntFlags == AES_INT_DATA_IN) ||
1095  (ui32IntFlags == AES_INT_DATA_OUT) ||
1096  (ui32IntFlags == AES_INT_DMA_CONTEXT_IN) ||
1097  (ui32IntFlags == AES_INT_DMA_CONTEXT_OUT) ||
1098  (ui32IntFlags == AES_INT_DMA_DATA_IN) ||
1099  (ui32IntFlags == AES_INT_DMA_DATA_OUT));
1100 
1101  //
1102  // Clear the flags.
1103  //
1104  HWREG(ui32Base + AES_O_DMAIM) &= ~(((ui32IntFlags & 0x00010000) >> 16) |
1105  ((ui32IntFlags & 0x00060000) >> 15) |
1106  ((ui32IntFlags & 0x00080000) >> 18));
1107  HWREG(ui32Base + AES_O_IRQENABLE) &= ~(ui32IntFlags & 0x0000ffff);
1108 }
#define AES_INT_DATA_OUT
Definition: aes.h:154
#define HWREG(x)
Definition: hw_types.h:48
#define AES_INT_DMA_DATA_OUT
Definition: aes.h:158
#define AES_INT_DMA_CONTEXT_IN
Definition: aes.h:155
#define ASSERT(expr)
Definition: debug.h:67
#define AES_INT_CONTEXT_IN
Definition: aes.h:151
#define AES_INT_DMA_CONTEXT_OUT
Definition: aes.h:156
#define AES_O_DMAIM
Definition: hw_aes.h:94
#define AES_INT_DATA_IN
Definition: aes.h:153
#define AES_INT_CONTEXT_OUT
Definition: aes.h:152
#define AES_INT_DMA_DATA_IN
Definition: aes.h:157
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_IRQENABLE
Definition: hw_aes.h:92
void AESIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables AES module interrupts.

Parameters
ui32Baseis the base address of the AES module.
ui32IntFlagsis a bit mask of the interrupt sources to enable.

This function enables the interrupts in the AES module. The ui32IntFlags parameter is the logical OR of any of the following:

  • AES_INT_CONTEXT_IN - Context interrupt
  • AES_INT_CONTEXT_OUT - Authentication tag (and IV) interrupt
  • AES_INT_DATA_IN - Data input interrupt
  • AES_INT_DATA_OUT - Data output interrupt
  • AES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • AES_INT_DMA_CONTEXT_OUT - Authentication tag (and IV) DMA done interrupt
  • AES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • AES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Note
Interrupts that have been previously been enabled are not disabled when this function is called.
Returns
None.

Definition at line 1035 of file aes.c.

References AES_BASE, AES_INT_CONTEXT_IN, AES_INT_CONTEXT_OUT, AES_INT_DATA_IN, AES_INT_DATA_OUT, AES_INT_DMA_CONTEXT_IN, AES_INT_DMA_CONTEXT_OUT, AES_INT_DMA_DATA_IN, AES_INT_DMA_DATA_OUT, AES_O_DMAIM, AES_O_IRQENABLE, ASSERT, and HWREG.

1036 {
1037  //
1038  // Check the arguments.
1039  //
1040  ASSERT(ui32Base == AES_BASE);
1041  ASSERT((ui32IntFlags == AES_INT_CONTEXT_IN) ||
1042  (ui32IntFlags == AES_INT_CONTEXT_OUT) ||
1043  (ui32IntFlags == AES_INT_DATA_IN) ||
1044  (ui32IntFlags == AES_INT_DATA_OUT) ||
1045  (ui32IntFlags == AES_INT_DMA_CONTEXT_IN) ||
1046  (ui32IntFlags == AES_INT_DMA_CONTEXT_OUT) ||
1047  (ui32IntFlags == AES_INT_DMA_DATA_IN) ||
1048  (ui32IntFlags == AES_INT_DMA_DATA_OUT));
1049 
1050  //
1051  // Set the flags.
1052  //
1053  HWREG(ui32Base + AES_O_DMAIM) |= (((ui32IntFlags & 0x00010000) >> 16) |
1054  ((ui32IntFlags & 0x00060000) >> 15) |
1055  ((ui32IntFlags & 0x00080000) >> 18));
1056  HWREG(ui32Base + AES_O_IRQENABLE) |= ui32IntFlags & 0x0000ffff;
1057 }
#define AES_INT_DATA_OUT
Definition: aes.h:154
#define HWREG(x)
Definition: hw_types.h:48
#define AES_INT_DMA_DATA_OUT
Definition: aes.h:158
#define AES_INT_DMA_CONTEXT_IN
Definition: aes.h:155
#define ASSERT(expr)
Definition: debug.h:67
#define AES_INT_CONTEXT_IN
Definition: aes.h:151
#define AES_INT_DMA_CONTEXT_OUT
Definition: aes.h:156
#define AES_O_DMAIM
Definition: hw_aes.h:94
#define AES_INT_DATA_IN
Definition: aes.h:153
#define AES_INT_CONTEXT_OUT
Definition: aes.h:152
#define AES_INT_DMA_DATA_IN
Definition: aes.h:157
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_IRQENABLE
Definition: hw_aes.h:92
void AESIntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the AES module.

Parameters
ui32Baseis the base address of the AES module.
pfnHandleris a pointer to the function to be called when the enabled AES interrupts occur.

This function registers the interrupt handler in the interrupt vector table, and enables AES interrupts on the interrupt controller; specific AES interrupt sources must be enabled using AESIntEnable(). The interrupt handler being registered must clear the source of the interrupt using AESIntClear().

If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() is used to enable AES interrupts on the interrupt controller.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 1175 of file aes.c.

References AES_BASE, ASSERT, INT_AES0_TM4C129, IntEnable(), and IntRegister().

1176 {
1177  //
1178  // Check the arguments.
1179  //
1180  ASSERT(ui32Base == AES_BASE);
1181 
1182  //
1183  // Register the interrupt handler.
1184  //
1185  IntRegister(INT_AES0_TM4C129, pfnHandler);
1186 
1187  //
1188  // Enable the interrupt
1189  //
1191 }
#define ASSERT(expr)
Definition: debug.h:67
#define INT_AES0_TM4C129
Definition: hw_ints.h:269
#define AES_BASE
Definition: hw_memmap.h:140
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

uint32_t AESIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Returns the current AES module interrupt status.

Parameters
ui32Baseis the base address of the AES module.
bMaskedis false if the raw interrupt status is required and true if the masked interrupt status is required.
Returns
Returns a bit mask of the interrupt sources, which is a logical OR of any of the following:
  • AES_INT_CONTEXT_IN - Context interrupt
  • AES_INT_CONTEXT_OUT - Authentication tag (and IV) interrupt.
  • AES_INT_DATA_IN - Data input interrupt
  • AES_INT_DATA_OUT - Data output interrupt
  • AES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • AES_INT_DMA_CONTEXT_OUT - Authentication tag (and IV) DMA done interrupt
  • AES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • AES_INT_DMA_DATA_OUT - Data output DMA done interrupt

Definition at line 976 of file aes.c.

References AES_BASE, AES_O_DMAMIS, AES_O_DMARIS, AES_O_IRQENABLE, AES_O_IRQSTATUS, ASSERT, and HWREG.

977 {
978  uint32_t ui32Status, ui32Enable, ui32Temp;
979 
980  //
981  // Check the arguments.
982  //
983  ASSERT(ui32Base == AES_BASE);
984 
985  //
986  // Read the IRQ status register and return the value.
987  //
988  ui32Status = HWREG(ui32Base + AES_O_IRQSTATUS);
989  if(bMasked)
990  {
991  ui32Enable = HWREG(ui32Base + AES_O_IRQENABLE);
992  ui32Temp = HWREG(ui32Base + AES_O_DMAMIS);
993  return((ui32Status & ui32Enable) |
994  (((ui32Temp & 0x00000001) << 16) |
995  ((ui32Temp & 0x00000002) << 18) |
996  ((ui32Temp & 0x0000000c) << 15)));
997  }
998  else
999  {
1000  ui32Temp = HWREG(ui32Base + AES_O_DMARIS);
1001  return(ui32Status |
1002  (((ui32Temp & 0x00000001) << 16) |
1003  ((ui32Temp & 0x00000002) << 18) |
1004  ((ui32Temp & 0x0000000c) << 15)));
1005  }
1006 }
#define AES_O_IRQSTATUS
Definition: hw_aes.h:91
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_DMAMIS
Definition: hw_aes.h:96
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_DMARIS
Definition: hw_aes.h:95
#define AES_O_IRQENABLE
Definition: hw_aes.h:92
void AESIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the AES module.

Parameters
ui32Baseis the base address of the AES module.

This function unregisters the previously registered interrupt handler and disables the interrupt in the interrupt controller.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 1209 of file aes.c.

References AES_BASE, ASSERT, INT_AES0_TM4C129, IntDisable(), and IntUnregister().

1210 {
1211  //
1212  // Check the arguments.
1213  //
1214  ASSERT(ui32Base == AES_BASE);
1215 
1216  //
1217  // Disable the interrupt.
1218  //
1220 
1221  //
1222  // Unregister the interrupt handler.
1223  //
1225 }
#define ASSERT(expr)
Definition: debug.h:67
#define INT_AES0_TM4C129
Definition: hw_ints.h:269
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
#define AES_BASE
Definition: hw_memmap.h:140
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684

Here is the call graph for this function:

void AESIVRead ( uint32_t  ui32Base,
uint32_t *  pui32IVData 
)

Saves the Initial Vector (IV) registers to a user-defined location.

Parameters
ui32Baseis the base address of the AES module.
pui32IVDatais pointer to the location that stores the IV data.

This function stores the IV for use with authenticated encryption and decryption operations. It is assumed that the AES_CTRL_SAVE_CONTEXT bit is set in the AES_CTRL register.

Returns
None.

Definition at line 439 of file aes.c.

References AES_BASE, AES_CTRL_SVCTXTRDY, AES_O_CTRL, AES_O_IV_IN_0, AES_O_IV_IN_1, AES_O_IV_IN_2, AES_O_IV_IN_3, ASSERT, and HWREG.

440 {
441  //
442  // Check the arguments.
443  //
444  ASSERT(ui32Base == AES_BASE);
445 
446  //
447  // Wait for the output context to be ready.
448  //
449  while((AES_CTRL_SVCTXTRDY & (HWREG(ui32Base + AES_O_CTRL))) == 0)
450  {
451  }
452 
453  //
454  // Read the tag data.
455  //
456  pui32IVData[0] = HWREG((ui32Base + AES_O_IV_IN_0));
457  pui32IVData[1] = HWREG((ui32Base + AES_O_IV_IN_1));
458  pui32IVData[2] = HWREG((ui32Base + AES_O_IV_IN_2));
459  pui32IVData[3] = HWREG((ui32Base + AES_O_IV_IN_3));
460 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_CTRL_SVCTXTRDY
Definition: hw_aes.h:265
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_O_IV_IN_1
Definition: hw_aes.h:66
#define AES_O_IV_IN_2
Definition: hw_aes.h:68
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_IV_IN_0
Definition: hw_aes.h:64
#define AES_O_IV_IN_3
Definition: hw_aes.h:70
void AESIVSet ( uint32_t  ui32Base,
uint32_t *  pui32IVdata 
)

Writes the Initial Vector (IV) register, needed in some of the AES Modes.

Parameters
ui32Baseis the base address of the AES module.
pui32IVdatais an array of 4 words (128 bits), containing the IV value to be configured. The least significant word is in the 0th index.

This functions writes the initial vector registers in the AES module.

Returns
None.

Definition at line 408 of file aes.c.

References AES_BASE, AES_O_IV_IN_0, AES_O_IV_IN_1, AES_O_IV_IN_2, AES_O_IV_IN_3, ASSERT, and HWREG.

409 {
410  //
411  // Check the arguments.
412  //
413  ASSERT(ui32Base == AES_BASE);
414 
415  //
416  // Write the initial vector registers.
417  //
418  HWREG(ui32Base + AES_O_IV_IN_0) = pui32IVdata[0];
419  HWREG(ui32Base + AES_O_IV_IN_1) = pui32IVdata[1];
420  HWREG(ui32Base + AES_O_IV_IN_2) = pui32IVdata[2];
421  HWREG(ui32Base + AES_O_IV_IN_3) = pui32IVdata[3];
422 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_IV_IN_1
Definition: hw_aes.h:66
#define AES_O_IV_IN_2
Definition: hw_aes.h:68
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_IV_IN_0
Definition: hw_aes.h:64
#define AES_O_IV_IN_3
Definition: hw_aes.h:70
void AESKey1Set ( uint32_t  ui32Base,
uint32_t *  pui32Key,
uint32_t  ui32Keysize 
)

Writes the key 1 configuration registers, which are used for encryption or decryption.

Parameters
ui32Baseis the base address for the AES module.
pui32Keyis an array of 32-bit words, containing the key to be configured. The least significant word in the 0th index.
ui32Keysizeis the size of the key, which must be one of the following values: AES_CFG_KEY_SIZE_128, AES_CFG_KEY_SIZE_192, or AES_CFG_KEY_SIZE_256.

This function writes key 1 configuration registers based on the key size. This function is used in all modes.

Returns
None.

Definition at line 269 of file aes.c.

References AES_BASE, AES_CFG_KEY_SIZE_128BIT, AES_CFG_KEY_SIZE_192BIT, AES_CFG_KEY_SIZE_256BIT, AES_O_KEY1_0, AES_O_KEY1_1, AES_O_KEY1_2, AES_O_KEY1_3, AES_O_KEY1_4, AES_O_KEY1_5, AES_O_KEY1_6, AES_O_KEY1_7, ASSERT, and HWREG.

270 {
271  //
272  // Check the arguments.
273  //
274  ASSERT(ui32Base == AES_BASE);
275  ASSERT((ui32Keysize == AES_CFG_KEY_SIZE_128BIT) ||
276  (ui32Keysize == AES_CFG_KEY_SIZE_192BIT) ||
277  (ui32Keysize == AES_CFG_KEY_SIZE_256BIT));
278 
279  //
280  // With all key sizes, the first 4 words are written.
281  //
282  HWREG(ui32Base + AES_O_KEY1_0) = pui32Key[0];
283  HWREG(ui32Base + AES_O_KEY1_1) = pui32Key[1];
284  HWREG(ui32Base + AES_O_KEY1_2) = pui32Key[2];
285  HWREG(ui32Base + AES_O_KEY1_3) = pui32Key[3];
286 
287  //
288  // The key is 192 or 256 bits. Write the next 2 words.
289  //
290  if(ui32Keysize != AES_CFG_KEY_SIZE_128BIT)
291  {
292  HWREG(ui32Base + AES_O_KEY1_4) = pui32Key[4];
293  HWREG(ui32Base + AES_O_KEY1_5) = pui32Key[5];
294  }
295 
296  //
297  // The key is 256 bits. Write the last 2 words.
298  //
299  if(ui32Keysize == AES_CFG_KEY_SIZE_256BIT)
300  {
301  HWREG(ui32Base + AES_O_KEY1_6) = pui32Key[6];
302  HWREG(ui32Base + AES_O_KEY1_7) = pui32Key[7];
303  }
304 }
#define AES_CFG_KEY_SIZE_128BIT
Definition: aes.h:69
#define HWREG(x)
Definition: hw_types.h:48
#define AES_O_KEY1_7
Definition: hw_aes.h:57
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_KEY1_5
Definition: hw_aes.h:59
#define AES_O_KEY1_1
Definition: hw_aes.h:63
#define AES_CFG_KEY_SIZE_256BIT
Definition: aes.h:71
#define AES_O_KEY1_3
Definition: hw_aes.h:61
#define AES_O_KEY1_4
Definition: hw_aes.h:58
#define AES_O_KEY1_0
Definition: hw_aes.h:62
#define AES_CFG_KEY_SIZE_192BIT
Definition: aes.h:70
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_KEY1_6
Definition: hw_aes.h:56
#define AES_O_KEY1_2
Definition: hw_aes.h:60
void AESKey2Set ( uint32_t  ui32Base,
uint32_t *  pui32Key,
uint32_t  ui32Keysize 
)

Writes the key 2 configuration registers, which are used for encryption or decryption.

Parameters
ui32Baseis the base address for the AES module.
pui32Keyis an array of 32-bit words, containing the key to be configured. The least significant word in the 0th index.
ui32Keysizeis the size of the key, which must be one of the following values: AES_CFG_KEY_SIZE_128, AES_CFG_KEY_SIZE_192, or AES_CFG_KEY_SIZE_256.

This function writes the key 2 configuration registers based on the key size. This function is used in the F8, F9, XTS, CCM, and CBC-MAC modes.

Returns
None.

Definition at line 325 of file aes.c.

References AES_BASE, AES_CFG_KEY_SIZE_128BIT, AES_CFG_KEY_SIZE_192BIT, AES_CFG_KEY_SIZE_256BIT, AES_O_KEY2_0, AES_O_KEY2_1, AES_O_KEY2_2, AES_O_KEY2_3, AES_O_KEY2_4, AES_O_KEY2_5, AES_O_KEY2_6, AES_O_KEY2_7, ASSERT, and HWREG.

326 {
327  //
328  // Check the arguments.
329  //
330  ASSERT(ui32Base == AES_BASE);
331  ASSERT((ui32Keysize == AES_CFG_KEY_SIZE_128BIT) ||
332  (ui32Keysize == AES_CFG_KEY_SIZE_192BIT) ||
333  (ui32Keysize == AES_CFG_KEY_SIZE_256BIT));
334 
335  //
336  // With all key sizes, the first 4 words are written.
337  //
338  HWREG(ui32Base + AES_O_KEY2_0) = pui32Key[0];
339  HWREG(ui32Base + AES_O_KEY2_1) = pui32Key[1];
340  HWREG(ui32Base + AES_O_KEY2_2) = pui32Key[2];
341  HWREG(ui32Base + AES_O_KEY2_3) = pui32Key[3];
342 
343  //
344  // The key is 192 or 256 bits. Write the next 2 words.
345  //
346  if(ui32Keysize != AES_CFG_KEY_SIZE_128BIT)
347  {
348  HWREG(ui32Base + AES_O_KEY2_4) = pui32Key[4];
349  HWREG(ui32Base + AES_O_KEY2_5) = pui32Key[5];
350  }
351 
352  //
353  // The key is 256 bits. Write the last 2 words.
354  //
355  if(ui32Keysize == AES_CFG_KEY_SIZE_256BIT)
356  {
357  HWREG(ui32Base + AES_O_KEY2_6) = pui32Key[6];
358  HWREG(ui32Base + AES_O_KEY2_7) = pui32Key[7];
359  }
360 }
#define AES_CFG_KEY_SIZE_128BIT
Definition: aes.h:69
#define AES_O_KEY2_2
Definition: hw_aes.h:52
#define HWREG(x)
Definition: hw_types.h:48
#define AES_O_KEY2_7
Definition: hw_aes.h:49
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_KEY2_0
Definition: hw_aes.h:54
#define AES_O_KEY2_5
Definition: hw_aes.h:51
#define AES_O_KEY2_3
Definition: hw_aes.h:53
#define AES_CFG_KEY_SIZE_256BIT
Definition: aes.h:71
#define AES_O_KEY2_4
Definition: hw_aes.h:50
#define AES_O_KEY2_1
Definition: hw_aes.h:55
#define AES_CFG_KEY_SIZE_192BIT
Definition: aes.h:70
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_KEY2_6
Definition: hw_aes.h:48
void AESKey3Set ( uint32_t  ui32Base,
uint32_t *  pui32Key 
)

Writes key 3 configuration registers, which are used for encryption or decryption.

Parameters
ui32Baseis the base address for the AES module.
pui32Keyis a pointer to an array of 4 words (128 bits), containing the key to be configured. The least significant word is in the 0th index.

This function writes the key 2 configuration registers with key 3 data used in CBC-MAC and F8 modes. This key is always 128 bits.

Returns
None.

Definition at line 378 of file aes.c.

References AES_BASE, AES_O_KEY2_4, AES_O_KEY2_5, AES_O_KEY2_6, AES_O_KEY2_7, ASSERT, and HWREG.

379 {
380  //
381  // Check the arguments.
382  //
383  ASSERT(ui32Base == AES_BASE);
384 
385  //
386  // Write the key into the upper 4 key registers
387  //
388  HWREG(ui32Base + AES_O_KEY2_4) = pui32Key[0];
389  HWREG(ui32Base + AES_O_KEY2_5) = pui32Key[1];
390  HWREG(ui32Base + AES_O_KEY2_6) = pui32Key[2];
391  HWREG(ui32Base + AES_O_KEY2_7) = pui32Key[3];
392 }
#define HWREG(x)
Definition: hw_types.h:48
#define AES_O_KEY2_7
Definition: hw_aes.h:49
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_KEY2_5
Definition: hw_aes.h:51
#define AES_O_KEY2_4
Definition: hw_aes.h:50
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_KEY2_6
Definition: hw_aes.h:48
void AESLengthSet ( uint32_t  ui32Base,
uint64_t  ui64Length 
)

Used to set the write crypto data length in the AES module.

Parameters
ui32Baseis the base address of the AES module.
ui64Lengthis the crypto data length in bytes.

This function stores the cryptographic data length in blocks for all modes. Data lengths up to (2^61 - 1) bytes are allowed. For GCM, any value up to (2^36 - 2) bytes are allowed because a 32-bit block counter is used. For basic modes (ECB/CBC/CTR/ICM/CFB128), zero can be programmed into the length field, indicating that the length is infinite.

When this function is called, the engine is triggered to start using this context.

Note
This length does not include the authentication-only data used in some modes. Use the AESAuthLengthSet() function to specify the authentication data length.
Returns
None

Definition at line 524 of file aes.c.

References AES_BASE, AES_O_C_LENGTH_0, AES_O_C_LENGTH_1, ASSERT, and HWREG.

Referenced by AESDataAuth(), AESDataProcess(), and AESDataProcessAuth().

525 {
526  //
527  // Check the arguments.
528  //
529  ASSERT(ui32Base == AES_BASE);
530 
531  //
532  // Write the length register by shifting the 64-bit ui64Length.
533  //
534  HWREG(ui32Base + AES_O_C_LENGTH_0) = (uint32_t)(ui64Length);
535  HWREG(ui32Base + AES_O_C_LENGTH_1) = (uint32_t)(ui64Length >> 32);
536 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_O_C_LENGTH_1
Definition: hw_aes.h:74
#define AES_O_C_LENGTH_0
Definition: hw_aes.h:73
#define AES_BASE
Definition: hw_memmap.h:140

Here is the caller graph for this function:

void AESReset ( uint32_t  ui32Base)

Resets the AES module.

Parameters
ui32Baseis the base address of the AES module.

This function performs a softreset the AES module.

Returns
None.

Definition at line 72 of file aes.c.

References AES_BASE, AES_O_SYSCONFIG, AES_O_SYSSTATUS, AES_SYSCONFIG_SOFTRESET, AES_SYSSTATUS_RESETDONE, ASSERT, and HWREG.

73 {
74  //
75  // Check the arguments.
76  //
77  ASSERT(ui32Base == AES_BASE);
78 
79  //
80  // Trigger the reset.
81  //
83 
84  //
85  // Wait for the reset to finish.
86  //
87  while((HWREG(ui32Base + AES_O_SYSSTATUS) &
89  {
90  }
91 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define AES_SYSCONFIG_SOFTRESET
Definition: hw_aes.h:447
#define AES_O_SYSCONFIG
Definition: hw_aes.h:89
#define AES_SYSSTATUS_RESETDONE
Definition: hw_aes.h:455
#define AES_BASE
Definition: hw_memmap.h:140
#define AES_O_SYSSTATUS
Definition: hw_aes.h:90
void AESTagRead ( uint32_t  ui32Base,
uint32_t *  pui32TagData 
)

Saves the tag registers to a user-defined location.

Parameters
ui32Baseis the base address of the AES module.
pui32TagDatais pointer to the location that stores the tag data.

This function stores the tag data for use authenticated encryption and decryption operations. It is assumed that the AES_CTRL_SAVE_CONTEXT bit is set in the AES_CTRL register.

Returns
None.

Definition at line 477 of file aes.c.

References AES_BASE, AES_CTRL_SVCTXTRDY, AES_O_CTRL, AES_O_TAG_OUT_0, AES_O_TAG_OUT_1, AES_O_TAG_OUT_2, AES_O_TAG_OUT_3, ASSERT, and HWREG.

Referenced by AESDataAuth(), and AESDataProcessAuth().

478 {
479  //
480  // Check the arguments.
481  //
482  ASSERT(ui32Base == AES_BASE);
483 
484  //
485  // Wait for the output context to be ready.
486  //
487  while((AES_CTRL_SVCTXTRDY & (HWREG(ui32Base + AES_O_CTRL))) == 0)
488  {
489  }
490 
491  //
492  // Read the tag data.
493  //
494  pui32TagData[0] = HWREG((ui32Base + AES_O_TAG_OUT_0));
495  pui32TagData[1] = HWREG((ui32Base + AES_O_TAG_OUT_1));
496  pui32TagData[2] = HWREG((ui32Base + AES_O_TAG_OUT_2));
497  pui32TagData[3] = HWREG((ui32Base + AES_O_TAG_OUT_3));
498 }
#define AES_O_TAG_OUT_2
Definition: hw_aes.h:86
#define HWREG(x)
Definition: hw_types.h:48
#define AES_O_TAG_OUT_3
Definition: hw_aes.h:87
#define AES_O_TAG_OUT_1
Definition: hw_aes.h:85
#define ASSERT(expr)
Definition: debug.h:67
#define AES_CTRL_SVCTXTRDY
Definition: hw_aes.h:265
#define AES_O_TAG_OUT_0
Definition: hw_aes.h:84
#define AES_O_CTRL
Definition: hw_aes.h:72
#define AES_BASE
Definition: hw_memmap.h:140

Here is the caller graph for this function: