aes.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //*****************************************************************************
  2. //
  3. // aes.h - Defines and Macros for the AES module.
  4. //
  5. // Copyright (c) 2012-2014 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its contributors may be used to endorse or promote products derived
  22. // from this software without specific prior written permission.
  23. //
  24. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
  37. //
  38. //*****************************************************************************
  39. #ifndef __DRIVERLIB_AES_H__
  40. #define __DRIVERLIB_AES_H__
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. // The following defines are used to specify the operation direction in the
  54. // ui32Config argument in the AESConfig function. Only one is permitted.
  55. //
  56. //*****************************************************************************
  57. #define AES_CFG_DIR_ENCRYPT 0x00000004
  58. #define AES_CFG_DIR_DECRYPT 0x00000000
  59. //*****************************************************************************
  60. //
  61. // The following defines are used to specify the key size in the ui32Config
  62. // argument in the AESConfig function. Only one is permitted.
  63. //
  64. //*****************************************************************************
  65. #define AES_CFG_KEY_SIZE_128BIT 0x00000008
  66. #define AES_CFG_KEY_SIZE_192BIT 0x00000010
  67. #define AES_CFG_KEY_SIZE_256BIT 0x00000018
  68. //*****************************************************************************
  69. //
  70. // The following defines are used to specify the mode of operation in the
  71. // ui32Config argument in the AESConfig function. Only one is permitted.
  72. //
  73. //*****************************************************************************
  74. #define AES_CFG_MODE_M 0x2007fe60
  75. #define AES_CFG_MODE_ECB 0x00000000
  76. #define AES_CFG_MODE_CBC 0x00000020
  77. #define AES_CFG_MODE_CTR 0x00000040
  78. #define AES_CFG_MODE_ICM 0x00000200
  79. #define AES_CFG_MODE_CFB 0x00000400
  80. #define AES_CFG_MODE_XTS_TWEAKJL \
  81. 0x00000800
  82. #define AES_CFG_MODE_XTS_K2IJL \
  83. 0x00001000
  84. #define AES_CFG_MODE_XTS_K2ILJ0 \
  85. 0x00001800
  86. #define AES_CFG_MODE_F8 0x00002000
  87. #define AES_CFG_MODE_F9 0x20004000
  88. #define AES_CFG_MODE_CBCMAC 0x20008000
  89. #define AES_CFG_MODE_GCM_HLY0ZERO \
  90. 0x20010000
  91. #define AES_CFG_MODE_GCM_HLY0CALC \
  92. 0x20020040
  93. #define AES_CFG_MODE_GCM_HY0CALC \
  94. 0x20030040
  95. #define AES_CFG_MODE_CCM 0x20040040
  96. //*****************************************************************************
  97. //
  98. // The following defines are used to specify the counter width in the
  99. // ui32Config argument in the AESConfig function. It is only required to
  100. // be defined when using CTR, CCM, or GCM modes. Only one length is permitted.
  101. //
  102. //*****************************************************************************
  103. #define AES_CFG_CTR_WIDTH_32 0x00000000
  104. #define AES_CFG_CTR_WIDTH_64 0x00000080
  105. #define AES_CFG_CTR_WIDTH_96 0x00000100
  106. #define AES_CFG_CTR_WIDTH_128 0x00000180
  107. //*****************************************************************************
  108. //
  109. // The following defines are used to define the width of the length field for
  110. // CCM operation through the ui32Config argument in the AESConfig function.
  111. // This value is also known as L. Only one is permitted.
  112. //
  113. //*****************************************************************************
  114. #define AES_CFG_CCM_L_1 0x00000000
  115. #define AES_CFG_CCM_L_2 0x00080000
  116. #define AES_CFG_CCM_L_3 0x00100000
  117. #define AES_CFG_CCM_L_4 0x00180000
  118. #define AES_CFG_CCM_L_5 0x00200000
  119. #define AES_CFG_CCM_L_6 0x00280000
  120. #define AES_CFG_CCM_L_7 0x00300000
  121. #define AES_CFG_CCM_L_8 0x00380000
  122. //*****************************************************************************
  123. //
  124. // The following defines are used to define the length of the authentication
  125. // field for CCM operations through the ui32Config argument in the AESConfig
  126. // function. This value is also known as M. Only one is permitted.
  127. //
  128. //*****************************************************************************
  129. #define AES_CFG_CCM_M_4 0x00400000
  130. #define AES_CFG_CCM_M_6 0x00800000
  131. #define AES_CFG_CCM_M_8 0x00c00000
  132. #define AES_CFG_CCM_M_10 0x01000000
  133. #define AES_CFG_CCM_M_12 0x01400000
  134. #define AES_CFG_CCM_M_14 0x01800000
  135. #define AES_CFG_CCM_M_16 0x01c00000
  136. //*****************************************************************************
  137. //
  138. // Interrupt flags for use with the AESIntEnable, AESIntDisable, and
  139. // AESIntStatus functions.
  140. //
  141. //*****************************************************************************
  142. #define AES_INT_CONTEXT_IN 0x00000001
  143. #define AES_INT_CONTEXT_OUT 0x00000008
  144. #define AES_INT_DATA_IN 0x00000002
  145. #define AES_INT_DATA_OUT 0x00000004
  146. #define AES_INT_DMA_CONTEXT_IN 0x00010000
  147. #define AES_INT_DMA_CONTEXT_OUT 0x00080000
  148. #define AES_INT_DMA_DATA_IN 0x00020000
  149. #define AES_INT_DMA_DATA_OUT 0x00040000
  150. //*****************************************************************************
  151. //
  152. // Defines used when enabling and disabling DMA requests in the
  153. // AESEnableDMA and AESDisableDMA functions.
  154. //
  155. //*****************************************************************************
  156. #define AES_DMA_DATA_IN 0x00000020
  157. #define AES_DMA_DATA_OUT 0x00000040
  158. #define AES_DMA_CONTEXT_IN 0x00000080
  159. #define AES_DMA_CONTEXT_OUT 0x00000100
  160. //*****************************************************************************
  161. //
  162. // Function prototypes.
  163. //
  164. //*****************************************************************************
  165. extern void AESAuthLengthSet(uint32_t ui32Base, uint32_t ui32Length);
  166. extern void AESConfigSet(uint32_t ui32Base, uint32_t ui32Config);
  167. extern void AESDataRead(uint32_t ui32Base, uint32_t *pui32Dest);
  168. extern bool AESDataReadNonBlocking(uint32_t ui32Base, uint32_t *pui32Dest);
  169. extern bool AESDataProcess(uint32_t ui32Base, uint32_t *pui32Src,
  170. uint32_t *pui32Dest, uint32_t ui32Length);
  171. extern bool AESDataAuth(uint32_t ui32Base, uint32_t *pui32Src,
  172. uint32_t ui32Length, uint32_t *pui32Tag);
  173. extern bool AESDataProcessAuth(uint32_t ui32Base, uint32_t *pui32Src,
  174. uint32_t *pui32Dest, uint32_t ui32Length,
  175. uint32_t *pui32AuthSrc,
  176. uint32_t ui32AuthLength, uint32_t *pui32Tag);
  177. extern void AESDataWrite(uint32_t ui32Base, uint32_t *pui32Src);
  178. extern bool AESDataWriteNonBlocking(uint32_t ui32Base, uint32_t *pui32Src);
  179. extern void AESDMADisable(uint32_t ui32Base, uint32_t ui32Flags);
  180. extern void AESDMAEnable(uint32_t ui32Base, uint32_t ui32Flags);
  181. extern void AESIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
  182. extern void AESIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
  183. extern void AESIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
  184. extern void AESIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
  185. extern uint32_t AESIntStatus(uint32_t ui32Base, bool bMasked);
  186. extern void AESIntUnregister(uint32_t ui32Base);
  187. extern void AESIVSet(uint32_t ui32Base, uint32_t *pui32IVdata);
  188. extern void AESIVRead(uint32_t ui32Base, uint32_t *pui32IVdata);
  189. extern void AESKey1Set(uint32_t ui32Base, uint32_t *pui32Key,
  190. uint32_t ui32Keysize);
  191. extern void AESKey2Set(uint32_t ui32Base, uint32_t *pui32Key,
  192. uint32_t ui32Keysize);
  193. extern void AESKey3Set(uint32_t ui32Base, uint32_t *pui32Key);
  194. extern void AESLengthSet(uint32_t ui32Base, uint64_t ui64Length);
  195. extern void AESReset(uint32_t ui32Base);
  196. extern void AESTagRead(uint32_t ui32Base, uint32_t *pui32TagData);
  197. //*****************************************************************************
  198. //
  199. // Mark the end of the C bindings section for C++ compilers.
  200. //
  201. //*****************************************************************************
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205. #endif // __DRIVERLIB_AES_H__