hw_aes.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. //*****************************************************************************
  2. //
  3. // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
  4. //
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions
  8. // are met:
  9. //
  10. // Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. //
  13. // Redistributions in binary form must reproduce the above copyright
  14. // notice, this list of conditions and the following disclaimer in the
  15. // documentation and/or other materials provided with the
  16. // distribution.
  17. //
  18. // Neither the name of Texas Instruments Incorporated nor the names of
  19. // its contributors may be used to endorse or promote products derived
  20. // from this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. //
  34. //*****************************************************************************
  35. #ifndef __HW_AES_H__
  36. #define __HW_AES_H__
  37. //*****************************************************************************
  38. //
  39. // The following are defines for the AES_P register offsets.
  40. //
  41. //*****************************************************************************
  42. #define AES_O_KEY2_6 0x00000000 // XTS second key / CBC-MAC third
  43. // key
  44. #define AES_O_KEY2_7 0x00000004 // XTS second key (MSW for 256-bit
  45. // key) / CBC-MAC third key (MSW)
  46. #define AES_O_KEY2_4 0x00000008 // XTS / CCM second key / CBC-MAC
  47. // third key (LSW)
  48. #define AES_O_KEY2_5 0x0000000C // XTS second key (MSW for 192-bit
  49. // key) / CBC-MAC third key
  50. #define AES_O_KEY2_2 0x00000010 // XTS / CCM / CBC-MAC second key /
  51. // Hash Key input
  52. #define AES_O_KEY2_3 0x00000014 // XTS second key (MSW for 128-bit
  53. // key) + CCM/CBC-MAC second key
  54. // (MSW) / Hash Key input (MSW)
  55. #define AES_O_KEY2_0 0x00000018 // XTS / CCM / CBC-MAC second key
  56. // (LSW) / Hash Key input (LSW)
  57. #define AES_O_KEY2_1 0x0000001C // XTS / CCM / CBC-MAC second key /
  58. // Hash Key input
  59. #define AES_O_KEY1_6 0x00000020 // Key (LSW for 256-bit key)
  60. #define AES_O_KEY1_7 0x00000024 // Key (MSW for 256-bit key)
  61. #define AES_O_KEY1_4 0x00000028 // Key (LSW for 192-bit key)
  62. #define AES_O_KEY1_5 0x0000002C // Key (MSW for 192-bit key)
  63. #define AES_O_KEY1_2 0x00000030 // Key
  64. #define AES_O_KEY1_3 0x00000034 // Key (MSW for 128-bit key)
  65. #define AES_O_KEY1_0 0x00000038 // Key (LSW for 128-bit key)
  66. #define AES_O_KEY1_1 0x0000003C // Key
  67. #define AES_O_IV_IN_0 0x00000040 // Initialization Vector input
  68. // (LSW)
  69. #define AES_O_IV_IN_1 0x00000044 // Initialization vector input
  70. #define AES_O_IV_IN_2 0x00000048 // Initialization vector input
  71. #define AES_O_IV_IN_3 0x0000004C // Initialization Vector input
  72. // (MSW)
  73. #define AES_O_CTRL 0x00000050 // register determines the mode of
  74. // operation of the AES Engine
  75. #define AES_O_C_LENGTH_0 0x00000054 // Crypto data length registers
  76. // (LSW and MSW) store the
  77. // cryptographic data length in
  78. // bytes for all modes. Once
  79. // processing with this context is
  80. // started@@ this length decrements
  81. // to zero. Data lengths up to (2^61
  82. // – 1) bytes are allowed. For GCM@@
  83. // any value up to 2^36 - 32 bytes
  84. // can be used. This is because a
  85. // 32-bit counter mode is used; the
  86. // maximum number of 128-bit blocks
  87. // is 2^32 – 2@@ resulting in a
  88. // maximum number of bytes of 2^36 -
  89. // 32. A write to this register
  90. // triggers the engine to start
  91. // using this context. This is valid
  92. // for all modes except GCM and CCM.
  93. // Note that for the combined
  94. // modes@@ this length does not
  95. // include the authentication only
  96. // data; the authentication length
  97. // is specified in the
  98. // AES_AUTH_LENGTH register below.
  99. // All modes must have a length > 0.
  100. // For the combined modes@@ it is
  101. // allowed to have one of the
  102. // lengths equal to zero. For the
  103. // basic encryption modes
  104. // (ECB/CBC/CTR/ICM/CFB128) it is
  105. // allowed to program zero to the
  106. // length field; in that case the
  107. // length is assumed infinite. All
  108. // data must be byte (8-bit)
  109. // aligned; bit aligned data streams
  110. // are not supported by the AES
  111. // Engine. For a Host read
  112. // operation@@ these registers
  113. // return all-zeroes.
  114. #define AES_O_C_LENGTH_1 0x00000058 // Crypto data length registers
  115. // (LSW and MSW) store the
  116. // cryptographic data length in
  117. // bytes for all modes. Once
  118. // processing with this context is
  119. // started@@ this length decrements
  120. // to zero. Data lengths up to (2^61
  121. // – 1) bytes are allowed. For GCM@@
  122. // any value up to 2^36 - 32 bytes
  123. // can be used. This is because a
  124. // 32-bit counter mode is used; the
  125. // maximum number of 128-bit blocks
  126. // is 2^32 – 2@@ resulting in a
  127. // maximum number of bytes of 2^36 -
  128. // 32. A write to this register
  129. // triggers the engine to start
  130. // using this context. This is valid
  131. // for all modes except GCM and CCM.
  132. // Note that for the combined
  133. // modes@@ this length does not
  134. // include the authentication only
  135. // data; the authentication length
  136. // is specified in the
  137. // AES_AUTH_LENGTH register below.
  138. // All modes must have a length > 0.
  139. // For the combined modes@@ it is
  140. // allowed to have one of the
  141. // lengths equal to zero. For the
  142. // basic encryption modes
  143. // (ECB/CBC/CTR/ICM/CFB128) it is
  144. // allowed to program zero to the
  145. // length field; in that case the
  146. // length is assumed infinite. All
  147. // data must be byte (8-bit)
  148. // aligned; bit aligned data streams
  149. // are not supported by the AES
  150. // Engine. For a Host read
  151. // operation@@ these registers
  152. // return all-zeroes.
  153. #define AES_O_AUTH_LENGTH 0x0000005C // AAD data length. The
  154. // authentication length register
  155. // store the authentication data
  156. // length in bytes for combined
  157. // modes only (GCM or CCM) Supported
  158. // AAD-lengths for CCM are from 0 to
  159. // (2^16 - 2^8) bytes. For GCM any
  160. // value up to (2^32 - 1) bytes can
  161. // be used. Once processing with
  162. // this context is started@@ this
  163. // length decrements to zero. A
  164. // write to this register triggers
  165. // the engine to start using this
  166. // context for GCM and CCM. For XTS
  167. // this register is optionally used
  168. // to load ‘j’. Loading of ‘j’ is
  169. // only required if ‘j’ != 0. ‘j’ is
  170. // a 28-bit value and must be
  171. // written to bits [31-4] of this
  172. // register. ‘j’ represents the
  173. // sequential number of the 128-bit
  174. // block inside the data unit. For
  175. // the first block in a unit@@ this
  176. // value is zero. It is not required
  177. // to provide a ‘j’ for each new
  178. // data block within a unit. Note
  179. // that it is possible to start with
  180. // a ‘j’ unequal to zero; refer to
  181. // Table 4 for more details. For a
  182. // Host read operation@@ these
  183. // registers return all-zeroes.
  184. #define AES_O_DATA_IN_0 0x00000060 // Data register to read and write
  185. // plaintext/ciphertext (MSW)
  186. #define AES_O_DATA_IN_1 0x00000064 // Data register to read and write
  187. // plaintext/ciphertext
  188. #define AES_O_DATA_IN_2 0x00000068 // Data register to read and write
  189. // plaintext/ciphertext
  190. #define AES_O_DATA_IN_3 0x0000006C // Data register to read and write
  191. // plaintext/ciphertext (LSW)
  192. #define AES_O_TAG_OUT_0 0x00000070
  193. #define AES_O_TAG_OUT_1 0x00000074
  194. #define AES_O_TAG_OUT_2 0x00000078
  195. #define AES_O_TAG_OUT_3 0x0000007C
  196. #define AES_O_REVISION 0x00000080 // Register AES_REVISION
  197. #define AES_O_SYSCONFIG 0x00000084 // Register AES_SYSCONFIG.This
  198. // register configures the DMA
  199. // signals and controls the IDLE and
  200. // reset logic
  201. #define AES_O_SYSSTATUS 0x00000088
  202. #define AES_O_IRQSTATUS 0x0000008C // This register indicates the
  203. // interrupt status. If one of the
  204. // interrupt bits is set the
  205. // interrupt output will be asserted
  206. #define AES_O_IRQENABLE 0x00000090 // This register contains an enable
  207. // bit for each unique interrupt
  208. // generated by the module. It
  209. // matches the layout of
  210. // AES_IRQSTATUS register. An
  211. // interrupt is enabled when the bit
  212. // in this register is set to ‘1’.
  213. // An interrupt that is enabled is
  214. // propagated to the SINTREQUEST_x
  215. // output. All interrupts need to be
  216. // enabled explicitly by writing
  217. // this register.
  218. //******************************************************************************
  219. //
  220. // The following are defines for the bit fields in the AES_O_KEY2_6 register.
  221. //
  222. //******************************************************************************
  223. #define AES_KEY2_6_KEY_M 0xFFFFFFFF // key data
  224. #define AES_KEY2_6_KEY_S 0
  225. //******************************************************************************
  226. //
  227. // The following are defines for the bit fields in the AES_O_KEY2_7 register.
  228. //
  229. //******************************************************************************
  230. #define AES_KEY2_7_KEY_M 0xFFFFFFFF // key data
  231. #define AES_KEY2_7_KEY_S 0
  232. //******************************************************************************
  233. //
  234. // The following are defines for the bit fields in the AES_O_KEY2_4 register.
  235. //
  236. //******************************************************************************
  237. #define AES_KEY2_4_KEY_M 0xFFFFFFFF // key data
  238. #define AES_KEY2_4_KEY_S 0
  239. //******************************************************************************
  240. //
  241. // The following are defines for the bit fields in the AES_O_KEY2_5 register.
  242. //
  243. //******************************************************************************
  244. #define AES_KEY2_5_KEY_M 0xFFFFFFFF // key data
  245. #define AES_KEY2_5_KEY_S 0
  246. //******************************************************************************
  247. //
  248. // The following are defines for the bit fields in the AES_O_KEY2_2 register.
  249. //
  250. //******************************************************************************
  251. #define AES_KEY2_2_KEY_M 0xFFFFFFFF // key data
  252. #define AES_KEY2_2_KEY_S 0
  253. //******************************************************************************
  254. //
  255. // The following are defines for the bit fields in the AES_O_KEY2_3 register.
  256. //
  257. //******************************************************************************
  258. #define AES_KEY2_3_KEY_M 0xFFFFFFFF // key data
  259. #define AES_KEY2_3_KEY_S 0
  260. //******************************************************************************
  261. //
  262. // The following are defines for the bit fields in the AES_O_KEY2_0 register.
  263. //
  264. //******************************************************************************
  265. #define AES_KEY2_0_KEY_M 0xFFFFFFFF // key data
  266. #define AES_KEY2_0_KEY_S 0
  267. //******************************************************************************
  268. //
  269. // The following are defines for the bit fields in the AES_O_KEY2_1 register.
  270. //
  271. //******************************************************************************
  272. #define AES_KEY2_1_KEY_M 0xFFFFFFFF // key data
  273. #define AES_KEY2_1_KEY_S 0
  274. //******************************************************************************
  275. //
  276. // The following are defines for the bit fields in the AES_O_KEY1_6 register.
  277. //
  278. //******************************************************************************
  279. #define AES_KEY1_6_KEY_M 0xFFFFFFFF // key data
  280. #define AES_KEY1_6_KEY_S 0
  281. //******************************************************************************
  282. //
  283. // The following are defines for the bit fields in the AES_O_KEY1_7 register.
  284. //
  285. //******************************************************************************
  286. #define AES_KEY1_7_KEY_M 0xFFFFFFFF // key data
  287. #define AES_KEY1_7_KEY_S 0
  288. //******************************************************************************
  289. //
  290. // The following are defines for the bit fields in the AES_O_KEY1_4 register.
  291. //
  292. //******************************************************************************
  293. #define AES_KEY1_4_KEY_M 0xFFFFFFFF // key data
  294. #define AES_KEY1_4_KEY_S 0
  295. //******************************************************************************
  296. //
  297. // The following are defines for the bit fields in the AES_O_KEY1_5 register.
  298. //
  299. //******************************************************************************
  300. #define AES_KEY1_5_KEY_M 0xFFFFFFFF // key data
  301. #define AES_KEY1_5_KEY_S 0
  302. //******************************************************************************
  303. //
  304. // The following are defines for the bit fields in the AES_O_KEY1_2 register.
  305. //
  306. //******************************************************************************
  307. #define AES_KEY1_2_KEY_M 0xFFFFFFFF // key data
  308. #define AES_KEY1_2_KEY_S 0
  309. //******************************************************************************
  310. //
  311. // The following are defines for the bit fields in the AES_O_KEY1_3 register.
  312. //
  313. //******************************************************************************
  314. #define AES_KEY1_3_KEY_M 0xFFFFFFFF // key data
  315. #define AES_KEY1_3_KEY_S 0
  316. //******************************************************************************
  317. //
  318. // The following are defines for the bit fields in the AES_O_KEY1_0 register.
  319. //
  320. //******************************************************************************
  321. #define AES_KEY1_0_KEY_M 0xFFFFFFFF // key data
  322. #define AES_KEY1_0_KEY_S 0
  323. //******************************************************************************
  324. //
  325. // The following are defines for the bit fields in the AES_O_KEY1_1 register.
  326. //
  327. //******************************************************************************
  328. #define AES_KEY1_1_KEY_M 0xFFFFFFFF // key data
  329. #define AES_KEY1_1_KEY_S 0
  330. //******************************************************************************
  331. //
  332. // The following are defines for the bit fields in the AES_O_IV_IN_0 register.
  333. //
  334. //******************************************************************************
  335. #define AES_IV_IN_0_DATA_M 0xFFFFFFFF // IV data
  336. #define AES_IV_IN_0_DATA_S 0
  337. //******************************************************************************
  338. //
  339. // The following are defines for the bit fields in the AES_O_IV_IN_1 register.
  340. //
  341. //******************************************************************************
  342. #define AES_IV_IN_1_DATA_M 0xFFFFFFFF // IV data
  343. #define AES_IV_IN_1_DATA_S 0
  344. //******************************************************************************
  345. //
  346. // The following are defines for the bit fields in the AES_O_IV_IN_2 register.
  347. //
  348. //******************************************************************************
  349. #define AES_IV_IN_2_DATA_M 0xFFFFFFFF // IV data
  350. #define AES_IV_IN_2_DATA_S 0
  351. //******************************************************************************
  352. //
  353. // The following are defines for the bit fields in the AES_O_IV_IN_3 register.
  354. //
  355. //******************************************************************************
  356. #define AES_IV_IN_3_DATA_M 0xFFFFFFFF // IV data
  357. #define AES_IV_IN_3_DATA_S 0
  358. //******************************************************************************
  359. //
  360. // The following are defines for the bit fields in the AES_O_CTRL register.
  361. //
  362. //******************************************************************************
  363. #define AES_CTRL_CONTEXT_READY \
  364. 0x80000000 // If ‘1’@@ this read-only status
  365. // bit indicates that the context
  366. // data registers can be overwritten
  367. // and the host is permitted to
  368. // write the next context.
  369. #define AES_CTRL_SVCTXTRDY \
  370. 0x40000000 // If ‘1’@@ this read-only status
  371. // bit indicates that an AES
  372. // authentication TAG and/or IV
  373. // block(s) is/are available for the
  374. // host to retrieve. This bit is
  375. // only asserted if the
  376. // ‘save_context’ bit is set to ‘1’.
  377. // The bit is mutual exclusive with
  378. // the ‘context_ready’ bit.
  379. #define AES_CTRL_SAVE_CONTEXT 0x20000000 // This bit is used to indicate
  380. // that an authentication TAG or
  381. // result IV needs to be stored as a
  382. // result context. If this bit is
  383. // set@@ context output DMA and/or
  384. // interrupt will be asserted if the
  385. // operation is finished and related
  386. // signals are enabled.
  387. #define AES_CTRL_CCM_M 0x01C00000 // Defines “M” that indicated the
  388. // length of the authentication
  389. // field for CCM operations; the
  390. // authentication field length
  391. // equals two times (the value of
  392. // CCM-M plus one). Note that the
  393. // AES Engine always returns a
  394. // 128-bit authentication field@@ of
  395. // which the M least significant
  396. // bytes are valid. All values are
  397. // supported.
  398. #define AES_CTRL_CCM_S 22
  399. #define AES_CTRL_CCM_L_M 0x00380000 // Defines “L” that indicated the
  400. // width of the length field for CCM
  401. // operations; the length field in
  402. // bytes equals the value of CMM-L
  403. // plus one. Supported values for L
  404. // are (programmed value): 2 (1)@@ 4
  405. // (3) and 8 (7).
  406. #define AES_CTRL_CCM_L_S 19
  407. #define AES_CTRL_CCM 0x00040000 // AES-CCM is selected@@ this is a
  408. // combined mode@@ using AES for
  409. // both authentication and
  410. // encryption. No additional mode
  411. // selection is required. 0 Other
  412. // mode selected 1 ccm mode selected
  413. #define AES_CTRL_GCM_M 0x00030000 // AES-GCM mode is selected.this is
  414. // a combined mode@@ using the
  415. // Galois field multiplier GF(2^128)
  416. // for authentication and AES-CTR
  417. // mode for encryption@@ the bits
  418. // specify the GCM mode. 0x0 No
  419. // operation 0x1 GHASH with H loaded
  420. // and Y0-encrypted forced to zero
  421. // 0x2 GHASH with H loaded and
  422. // Y0-encrypted calculated
  423. // internally 0x3 Autonomous GHASH
  424. // (both H and Y0-encrypted
  425. // calculated internally)
  426. #define AES_CTRL_GCM_S 16
  427. #define AES_CTRL_CBCMAC 0x00008000 // AES-CBC MAC is selected@@ the
  428. // Direction bit must be set to ‘1’
  429. // for this mode. 0 Other mode
  430. // selected 1 cbcmac mode selected
  431. #define AES_CTRL_F9 0x00004000 // AES f9 mode is selected@@ the
  432. // AES key size must be set to
  433. // 128-bit for this mode. 0 Other
  434. // mode selected 1 f9 selected
  435. #define AES_CTRL_F8 0x00002000 // AES f8 mode is selected@@ the
  436. // AES key size must be set to
  437. // 128-bit for this mode. 0 Other
  438. // mode selected 1 f8 selected
  439. #define AES_CTRL_XTS_M 0x00001800 // AES-XTS operation is selected;
  440. // the bits specify the XTS mode.01
  441. // = Previous/intermediate tweak
  442. // value and ‘j’ loaded (value is
  443. // loaded via IV@@ j is loaded via
  444. // the AAD length register) 0x0 No
  445. // operation 0x1
  446. // Previous/intermediate tweak value
  447. // and ‘j’ loaded (value is loaded
  448. // via IV@@ j is loaded via the AAD
  449. // length register) 0x2 Key2@@ i and
  450. // j loaded (i is loaded via IV@@ j
  451. // is loaded via the AAD length
  452. // register) 0x3 Key2 and i loaded@@
  453. // j=0 (i is loaded via IV)
  454. #define AES_CTRL_XTS_S 11
  455. #define AES_CTRL_CFB 0x00000400 // full block AES cipher feedback
  456. // mode (CFB128) is selected. 0
  457. // other mode selected 1 cfb
  458. // selected
  459. #define AES_CTRL_ICM 0x00000200 // AES integer counter mode (ICM)
  460. // is selected@@ this is a counter
  461. // mode with a 16-bit wide counter.
  462. // 0 Other mode selected. 1 ICM mode
  463. // selected
  464. #define AES_CTRL_CTR_WIDTH_M 0x00000180 // Specifies the counter width for
  465. // AES-CTR mode 0x0 Counter is 32
  466. // bits 0x1 Counter is 64 bits 0x2
  467. // Counter is 128 bits 0x3 Counter
  468. // is 192 bits
  469. #define AES_CTRL_CTR_WIDTH_S 7
  470. #define AES_CTRL_CTR 0x00000040 // Tthis bit must also be set for
  471. // GCM and CCM@@ when
  472. // encryption/decryption is
  473. // required. 0 Other mode selected 1
  474. // Counter mode
  475. #define AES_CTRL_MODE 0x00000020 // ecb/cbc mode 0 ecb mode 1 cbc
  476. // mode
  477. #define AES_CTRL_KEY_SIZE_M 0x00000018 // key size 0x0 reserved 0x1 Key is
  478. // 128 bits. 0x2 Key is 192 bits 0x3
  479. // Key is 256
  480. #define AES_CTRL_KEY_SIZE_S 3
  481. #define AES_CTRL_DIRECTION 0x00000004 // If set to ‘1’ an encrypt
  482. // operation is performed. If set to
  483. // ‘0’ a decrypt operation is
  484. // performed. Read 0 decryption is
  485. // selected Read 1 Encryption is
  486. // selected
  487. #define AES_CTRL_INPUT_READY 0x00000002 // If ‘1’@@ this read-only status
  488. // bit indicates that the 16-byte
  489. // input buffer is empty@@ and the
  490. // host is permitted to write the
  491. // next block of data.
  492. #define AES_CTRL_OUTPUT_READY 0x00000001 // If ‘1’@@ this read-only status
  493. // bit indicates that an AES output
  494. // block is available for the host
  495. // to retrieve.
  496. //******************************************************************************
  497. //
  498. // The following are defines for the bit fields in the
  499. // AES_O_C_LENGTH_0 register.
  500. //
  501. //******************************************************************************
  502. //******************************************************************************
  503. //
  504. // The following are defines for the bit fields in the
  505. // AES_O_C_LENGTH_1 register.
  506. //
  507. //******************************************************************************
  508. #define AES_C_LENGTH_1_LENGTH_M \
  509. 0x1FFFFFFF // Data length (MSW) length
  510. // registers (LSW and MSW) store the
  511. // cryptographic data length in
  512. // bytes for all modes. Once
  513. // processing with this context is
  514. // started@@ this length decrements
  515. // to zero. Data lengths up to (2^61
  516. // – 1) bytes are allowed. For GCM@@
  517. // any value up to 2^36 - 32 bytes
  518. // can be used. This is because a
  519. // 32-bit counter mode is used; the
  520. // maximum number of 128-bit blocks
  521. // is 2^32 – 2@@ resulting in a
  522. // maximum number of bytes of 2^36 -
  523. // 32. A write to this register
  524. // triggers the engine to start
  525. // using this context. This is valid
  526. // for all modes except GCM and CCM.
  527. // Note that for the combined
  528. // modes@@ this length does not
  529. // include the authentication only
  530. // data; the authentication length
  531. // is specified in the
  532. // AES_AUTH_LENGTH register below.
  533. // All modes must have a length > 0.
  534. // For the combined modes@@ it is
  535. // allowed to have one of the
  536. // lengths equal to zero. For the
  537. // basic encryption modes
  538. // (ECB/CBC/CTR/ICM/CFB128) it is
  539. // allowed to program zero to the
  540. // length field; in that case the
  541. // length is assumed infinite. All
  542. // data must be byte (8-bit)
  543. // aligned; bit aligned data streams
  544. // are not supported by the AES
  545. // Engine. For a Host read
  546. // operation@@ these registers
  547. // return all-zeroes.
  548. #define AES_C_LENGTH_1_LENGTH_S 0
  549. //******************************************************************************
  550. //
  551. // The following are defines for the bit fields in the
  552. // AES_O_AUTH_LENGTH register.
  553. //
  554. //******************************************************************************
  555. #define AES_AUTH_LENGTH_AUTH_M \
  556. 0xFFFFFFFF // data
  557. #define AES_AUTH_LENGTH_AUTH_S 0
  558. //******************************************************************************
  559. //
  560. // The following are defines for the bit fields in the AES_O_DATA_IN_0 register.
  561. //
  562. //******************************************************************************
  563. #define AES_DATA_IN_0_DATA_M 0xFFFFFFFF // Data to encrypt/decrypt
  564. #define AES_DATA_IN_0_DATA_S 0
  565. //******************************************************************************
  566. //
  567. // The following are defines for the bit fields in the AES_O_DATA_IN_1 register.
  568. //
  569. //******************************************************************************
  570. #define AES_DATA_IN_1_DATA_M 0xFFFFFFFF // Data to encrypt/decrypt
  571. #define AES_DATA_IN_1_DATA_S 0
  572. //******************************************************************************
  573. //
  574. // The following are defines for the bit fields in the AES_O_DATA_IN_2 register.
  575. //
  576. //******************************************************************************
  577. #define AES_DATA_IN_2_DATA_M 0xFFFFFFFF // Data to encrypt/decrypt
  578. #define AES_DATA_IN_2_DATA_S 0
  579. //******************************************************************************
  580. //
  581. // The following are defines for the bit fields in the AES_O_DATA_IN_3 register.
  582. //
  583. //******************************************************************************
  584. #define AES_DATA_IN_3_DATA_M 0xFFFFFFFF // Data to encrypt/decrypt
  585. #define AES_DATA_IN_3_DATA_S 0
  586. //******************************************************************************
  587. //
  588. // The following are defines for the bit fields in the AES_O_TAG_OUT_0 register.
  589. //
  590. //******************************************************************************
  591. #define AES_TAG_OUT_0_HASH_M 0xFFFFFFFF // Hash result (MSW)
  592. #define AES_TAG_OUT_0_HASH_S 0
  593. //******************************************************************************
  594. //
  595. // The following are defines for the bit fields in the AES_O_TAG_OUT_1 register.
  596. //
  597. //******************************************************************************
  598. #define AES_TAG_OUT_1_HASH_M 0xFFFFFFFF // Hash result (MSW)
  599. #define AES_TAG_OUT_1_HASH_S 0
  600. //******************************************************************************
  601. //
  602. // The following are defines for the bit fields in the AES_O_TAG_OUT_2 register.
  603. //
  604. //******************************************************************************
  605. #define AES_TAG_OUT_2_HASH_M 0xFFFFFFFF // Hash result (MSW)
  606. #define AES_TAG_OUT_2_HASH_S 0
  607. //******************************************************************************
  608. //
  609. // The following are defines for the bit fields in the AES_O_TAG_OUT_3 register.
  610. //
  611. //******************************************************************************
  612. #define AES_TAG_OUT_3_HASH_M 0xFFFFFFFF // Hash result (LSW)
  613. #define AES_TAG_OUT_3_HASH_S 0
  614. //******************************************************************************
  615. //
  616. // The following are defines for the bit fields in the AES_O_REVISION register.
  617. //
  618. //******************************************************************************
  619. #define AES_REVISION_SCHEME_M 0xC0000000
  620. #define AES_REVISION_SCHEME_S 30
  621. #define AES_REVISION_FUNC_M 0x0FFF0000 // Function indicates a software
  622. // compatible module family. If
  623. // there is no level of software
  624. // compatibility a new Func number
  625. // (and hence REVISION) should be
  626. // assigned.
  627. #define AES_REVISION_FUNC_S 16
  628. #define AES_REVISION_R_RTL_M 0x0000F800 // RTL Version (R)@@ maintained by
  629. // IP design owner. RTL follows a
  630. // numbering such as X.Y.R.Z which
  631. // are explained in this table. R
  632. // changes ONLY when: (1) PDS
  633. // uploads occur which may have been
  634. // due to spec changes (2) Bug fixes
  635. // occur (3) Resets to '0' when X or
  636. // Y changes. Design team has an
  637. // internal 'Z' (customer invisible)
  638. // number which increments on every
  639. // drop that happens due to DV and
  640. // RTL updates. Z resets to 0 when R
  641. // increments.
  642. #define AES_REVISION_R_RTL_S 11
  643. #define AES_REVISION_X_MAJOR_M \
  644. 0x00000700 // Major Revision (X)@@ maintained
  645. // by IP specification owner. X
  646. // changes ONLY when: (1) There is a
  647. // major feature addition. An
  648. // example would be adding Master
  649. // Mode to Utopia Level2. The Func
  650. // field (or Class/Type in old PID
  651. // format) will remain the same. X
  652. // does NOT change due to: (1) Bug
  653. // fixes (2) Change in feature
  654. // parameters.
  655. #define AES_REVISION_X_MAJOR_S 8
  656. #define AES_REVISION_CUSTOM_M 0x000000C0
  657. #define AES_REVISION_CUSTOM_S 6
  658. #define AES_REVISION_Y_MINOR_M \
  659. 0x0000003F // Minor Revision (Y)@@ maintained
  660. // by IP specification owner. Y
  661. // changes ONLY when: (1) Features
  662. // are scaled (up or down).
  663. // Flexibility exists in that this
  664. // feature scalability may either be
  665. // represented in the Y change or a
  666. // specific register in the IP that
  667. // indicates which features are
  668. // exactly available. (2) When
  669. // feature creeps from Is-Not list
  670. // to Is list. But this may not be
  671. // the case once it sees silicon; in
  672. // which case X will change. Y does
  673. // NOT change due to: (1) Bug fixes
  674. // (2) Typos or clarifications (3)
  675. // major functional/feature
  676. // change/addition/deletion. Instead
  677. // these changes may be reflected
  678. // via R@@ S@@ X as applicable. Spec
  679. // owner maintains a
  680. // customer-invisible number 'S'
  681. // which changes due to: (1)
  682. // Typos/clarifications (2) Bug
  683. // documentation. Note that this bug
  684. // is not due to a spec change but
  685. // due to implementation.
  686. // Nevertheless@@ the spec tracks
  687. // the IP bugs. An RTL release (say
  688. // for silicon PG1.1) that occurs
  689. // due to bug fix should document
  690. // the corresponding spec number
  691. // (X.Y.S) in its release notes.
  692. #define AES_REVISION_Y_MINOR_S 0
  693. //******************************************************************************
  694. //
  695. // The following are defines for the bit fields in the AES_O_SYSCONFIG register.
  696. //
  697. //******************************************************************************
  698. #define AES_SYSCONFIG_MACONTEXT_OUT_ON_DATA_OUT \
  699. 0x00000200 // If set to '1' the two context
  700. // out requests
  701. // (dma_req_context_out_en@@ Bit [8]
  702. // above@@ and context_out interrupt
  703. // enable@@ Bit [3] of AES_IRQENABLE
  704. // register) are mapped on the
  705. // corresponding data output request
  706. // bit. In this case@@ the original
  707. // ‘context out’ bit values are
  708. // ignored.
  709. #define AES_SYSCONFIG_DMA_REQ_CONTEXT_OUT_EN \
  710. 0x00000100 // If set to ‘1’@@ the DMA context
  711. // output request is enabled (for
  712. // context data out@@ e.g. TAG for
  713. // authentication modes). 0 Dma
  714. // disabled 1 Dma enabled
  715. #define AES_SYSCONFIG_DMA_REQ_CONTEXT_IN_EN \
  716. 0x00000080 // If set to ‘1’@@ the DMA context
  717. // request is enabled. 0 Dma
  718. // disabled 1 Dma enabled
  719. #define AES_SYSCONFIG_DMA_REQ_DATA_OUT_EN \
  720. 0x00000040 // If set to ‘1’@@ the DMA output
  721. // request is enabled. 0 Dma
  722. // disabled 1 Dma enabled
  723. #define AES_SYSCONFIG_DMA_REQ_DATA_IN_EN \
  724. 0x00000020 // If set to ‘1’@@ the DMA input
  725. // request is enabled. 0 Dma
  726. // disabled 1 Dma enabled
  727. //******************************************************************************
  728. //
  729. // The following are defines for the bit fields in the AES_O_SYSSTATUS register.
  730. //
  731. //******************************************************************************
  732. #define AES_SYSSTATUS_RESETDONE \
  733. 0x00000001
  734. //******************************************************************************
  735. //
  736. // The following are defines for the bit fields in the AES_O_IRQSTATUS register.
  737. //
  738. //******************************************************************************
  739. #define AES_IRQSTATUS_CONTEXT_OUT \
  740. 0x00000008 // This bit indicates
  741. // authentication tag (and IV)
  742. // interrupt(s) is/are active and
  743. // triggers the interrupt output.
  744. #define AES_IRQSTATUS_DATA_OUT \
  745. 0x00000004 // This bit indicates data output
  746. // interrupt is active and triggers
  747. // the interrupt output.
  748. #define AES_IRQSTATUS_DATA_IN 0x00000002 // This bit indicates data input
  749. // interrupt is active and triggers
  750. // the interrupt output.
  751. #define AES_IRQSTATUS_CONTEX_IN \
  752. 0x00000001 // This bit indicates context
  753. // interrupt is active and triggers
  754. // the interrupt output.
  755. //******************************************************************************
  756. //
  757. // The following are defines for the bit fields in the AES_O_IRQENABLE register.
  758. //
  759. //******************************************************************************
  760. #define AES_IRQENABLE_CONTEXT_OUT \
  761. 0x00000008 // This bit indicates
  762. // authentication tag (and IV)
  763. // interrupt(s) is/are active and
  764. // triggers the interrupt output.
  765. #define AES_IRQENABLE_DATA_OUT \
  766. 0x00000004 // This bit indicates data output
  767. // interrupt is active and triggers
  768. // the interrupt output.
  769. #define AES_IRQENABLE_DATA_IN 0x00000002 // This bit indicates data input
  770. // interrupt is active and triggers
  771. // the interrupt output.
  772. #define AES_IRQENABLE_CONTEX_IN \
  773. 0x00000001 // This bit indicates context
  774. // interrupt is active and triggers
  775. // the interrupt output.
  776. #endif // __HW_AES_H__