fsl_ltc_edma.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2018 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_LTC_EDMA_H_
  35. #define _FSL_LTC_EDMA_H_
  36. #include "fsl_common.h"
  37. #include "fsl_edma.h"
  38. #include "fsl_ltc.h"
  39. /*!
  40. * @addtogroup ltc_edma_driver
  41. * @{
  42. */
  43. /*******************************************************************************
  44. * Definitions
  45. ******************************************************************************/
  46. /*! @name Driver version */
  47. /*@{*/
  48. /*! @brief LTC EDMA driver version. Version 2.0.5. */
  49. #define FSL_LTC_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 5))
  50. /*@}*/
  51. /* @brief The LTC eDMA handle type. */
  52. typedef struct _ltc_edma_handle ltc_edma_handle_t;
  53. /*! @brief LTC eDMA callback function. */
  54. typedef void (*ltc_edma_callback_t)(LTC_Type *base, ltc_edma_handle_t *handle, status_t status, void *userData);
  55. /*! @brief LTC eDMA state machine function. It is defined only for private usage inside LTC eDMA driver. */
  56. typedef status_t (*ltc_edma_state_machine_t)(LTC_Type *base, ltc_edma_handle_t *handle);
  57. /*!
  58. * @brief LTC eDMA handle. It is defined only for private usage inside LTC eDMA driver.
  59. */
  60. struct _ltc_edma_handle
  61. {
  62. ltc_edma_callback_t callback; /*!< Callback function. */
  63. void *userData; /*!< LTC callback function parameter.*/
  64. edma_handle_t *inputFifoEdmaHandle; /*!< The eDMA TX channel used. */
  65. edma_handle_t *outputFifoEdmaHandle; /*!< The eDMA RX channel used. */
  66. ltc_edma_state_machine_t state_machine; /*!< State machine. */
  67. uint32_t state; /*!< Internal state. */
  68. const uint8_t *inData; /*!< Input data. */
  69. uint8_t *outData; /*!< Output data. */
  70. uint32_t size; /*!< Size of input and output data in bytes.*/
  71. uint32_t modeReg; /*!< LTC mode register.*/
  72. /* Used by AES CTR*/
  73. uint8_t *counter; /*!< Input counter (updates on return)*/
  74. const uint8_t *key; /*!< Input key to use for forward AES cipher*/
  75. uint32_t keySize; /*!< Size of the input key, in bytes. Must be 16, 24, or 32.*/
  76. uint8_t
  77. *counterlast; /*!< Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are
  78. not used.*/
  79. uint32_t *szLeft; /*!< Output number of bytes in left unused in counterlast block. NULL can be passed if chained
  80. calls are not used.*/
  81. uint32_t lastSize; /*!< Last size.*/
  82. };
  83. /*******************************************************************************
  84. * API
  85. ******************************************************************************/
  86. #if defined(__cplusplus)
  87. extern "C" {
  88. #endif
  89. /*!
  90. * @brief Init the LTC eDMA handle which is used in transcational functions
  91. * @param base LTC module base address
  92. * @param handle Pointer to ltc_edma_handle_t structure
  93. * @param callback Callback function, NULL means no callback.
  94. * @param userData Callback function parameter.
  95. * @param inputFifoEdmaHandle User requested eDMA handle for Input FIFO eDMA.
  96. * @param outputFifoEdmaHandle User requested eDMA handle for Output FIFO eDMA.
  97. */
  98. void LTC_CreateHandleEDMA(LTC_Type *base,
  99. ltc_edma_handle_t *handle,
  100. ltc_edma_callback_t callback,
  101. void *userData,
  102. edma_handle_t *inputFifoEdmaHandle,
  103. edma_handle_t *outputFifoEdmaHandle);
  104. /*! @}*/
  105. /*******************************************************************************
  106. * AES API
  107. ******************************************************************************/
  108. /*!
  109. * @addtogroup ltc_edma_driver_aes
  110. * @{
  111. */
  112. /*!
  113. * @brief Encrypts AES using the ECB block mode.
  114. *
  115. * Encrypts AES using the ECB block mode.
  116. *
  117. * @param base LTC peripheral base address
  118. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  119. * @param plaintext Input plain text to encrypt
  120. * @param[out] ciphertext Output cipher text
  121. * @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
  122. * @param key Input key to use for encryption
  123. * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
  124. * @return Status from encrypt operation
  125. */
  126. status_t LTC_AES_EncryptEcbEDMA(LTC_Type *base,
  127. ltc_edma_handle_t *handle,
  128. const uint8_t *plaintext,
  129. uint8_t *ciphertext,
  130. uint32_t size,
  131. const uint8_t *key,
  132. uint32_t keySize);
  133. /*!
  134. * @brief Decrypts AES using ECB block mode.
  135. *
  136. * Decrypts AES using ECB block mode.
  137. *
  138. * @param base LTC peripheral base address
  139. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  140. * @param ciphertext Input cipher text to decrypt
  141. * @param[out] plaintext Output plain text
  142. * @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
  143. * @param key Input key.
  144. * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
  145. * @param keyType Input type of the key (allows to directly load decrypt key for AES ECB decrypt operation.)
  146. * @return Status from decrypt operation
  147. */
  148. status_t LTC_AES_DecryptEcbEDMA(LTC_Type *base,
  149. ltc_edma_handle_t *handle,
  150. const uint8_t *ciphertext,
  151. uint8_t *plaintext,
  152. uint32_t size,
  153. const uint8_t *key,
  154. uint32_t keySize,
  155. ltc_aes_key_t keyType);
  156. /*!
  157. * @brief Encrypts AES using CBC block mode.
  158. *
  159. * @param base LTC peripheral base address
  160. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  161. * @param plaintext Input plain text to encrypt
  162. * @param[out] ciphertext Output cipher text
  163. * @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
  164. * @param iv Input initial vector to combine with the first input block.
  165. * @param key Input key to use for encryption
  166. * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
  167. * @return Status from encrypt operation
  168. */
  169. status_t LTC_AES_EncryptCbcEDMA(LTC_Type *base,
  170. ltc_edma_handle_t *handle,
  171. const uint8_t *plaintext,
  172. uint8_t *ciphertext,
  173. uint32_t size,
  174. const uint8_t iv[LTC_AES_IV_SIZE],
  175. const uint8_t *key,
  176. uint32_t keySize);
  177. /*!
  178. * @brief Decrypts AES using CBC block mode.
  179. *
  180. * @param base LTC peripheral base address
  181. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  182. * @param ciphertext Input cipher text to decrypt
  183. * @param[out] plaintext Output plain text
  184. * @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
  185. * @param iv Input initial vector to combine with the first input block.
  186. * @param key Input key to use for decryption
  187. * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
  188. * @param keyType Input type of the key (allows to directly load decrypt key for AES CBC decrypt operation.)
  189. * @return Status from decrypt operation
  190. */
  191. status_t LTC_AES_DecryptCbcEDMA(LTC_Type *base,
  192. ltc_edma_handle_t *handle,
  193. const uint8_t *ciphertext,
  194. uint8_t *plaintext,
  195. uint32_t size,
  196. const uint8_t iv[LTC_AES_IV_SIZE],
  197. const uint8_t *key,
  198. uint32_t keySize,
  199. ltc_aes_key_t keyType);
  200. /*!
  201. * @brief Encrypts or decrypts AES using CTR block mode.
  202. *
  203. * Encrypts or decrypts AES using CTR block mode.
  204. * AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption.
  205. * The only difference between encryption and decryption is that, for encryption, the input argument
  206. * is plain text and the output argument is cipher text. For decryption, the input argument is cipher text
  207. * and the output argument is plain text.
  208. *
  209. * @param base LTC peripheral base address
  210. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  211. * @param input Input data for CTR block mode
  212. * @param[out] output Output data for CTR block mode
  213. * @param size Size of input and output data in bytes
  214. * @param[in,out] counter Input counter (updates on return)
  215. * @param key Input key to use for forward AES cipher
  216. * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
  217. * @param[out] counterlast Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are
  218. * not used.
  219. * @param[out] szLeft Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls
  220. * are not used.
  221. * @return Status from encrypt operation
  222. */
  223. status_t LTC_AES_CryptCtrEDMA(LTC_Type *base,
  224. ltc_edma_handle_t *handle,
  225. const uint8_t *input,
  226. uint8_t *output,
  227. uint32_t size,
  228. uint8_t counter[LTC_AES_BLOCK_SIZE],
  229. const uint8_t *key,
  230. uint32_t keySize,
  231. uint8_t counterlast[LTC_AES_BLOCK_SIZE],
  232. uint32_t *szLeft);
  233. /*! AES CTR decrypt is mapped to the AES CTR generic operation */
  234. #define LTC_AES_DecryptCtrEDMA(base, handle, input, output, size, counter, key, keySize, counterlast, szLeft) \
  235. LTC_AES_CryptCtrEDMA(base, handle, input, output, size, counter, key, keySize, counterlast, szLeft)
  236. /*! AES CTR encrypt is mapped to the AES CTR generic operation */
  237. #define LTC_AES_EncryptCtrEDMA(base, handle, input, output, size, counter, key, keySize, counterlast, szLeft) \
  238. LTC_AES_CryptCtrEDMA(base, handle, input, output, size, counter, key, keySize, counterlast, szLeft)
  239. /*!
  240. *@}
  241. */
  242. /*******************************************************************************
  243. * DES API
  244. ******************************************************************************/
  245. /*!
  246. * @addtogroup ltc_edma_driver_des
  247. * @{
  248. */
  249. /*!
  250. * @brief Encrypts DES using ECB block mode.
  251. *
  252. * Encrypts DES using ECB block mode.
  253. *
  254. * @param base LTC peripheral base address
  255. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  256. * @param plaintext Input plaintext to encrypt
  257. * @param[out] ciphertext Output ciphertext
  258. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  259. * @param key Input key to use for encryption
  260. * @return Status from encrypt/decrypt operation
  261. */
  262. status_t LTC_DES_EncryptEcbEDMA(LTC_Type *base,
  263. ltc_edma_handle_t *handle,
  264. const uint8_t *plaintext,
  265. uint8_t *ciphertext,
  266. uint32_t size,
  267. const uint8_t key[LTC_DES_KEY_SIZE]);
  268. /*!
  269. * @brief Decrypts DES using ECB block mode.
  270. *
  271. * Decrypts DES using ECB block mode.
  272. *
  273. * @param base LTC peripheral base address
  274. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  275. * @param ciphertext Input ciphertext to decrypt
  276. * @param[out] plaintext Output plaintext
  277. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  278. * @param key Input key to use for decryption
  279. * @return Status from encrypt/decrypt operation
  280. */
  281. status_t LTC_DES_DecryptEcbEDMA(LTC_Type *base,
  282. ltc_edma_handle_t *handle,
  283. const uint8_t *ciphertext,
  284. uint8_t *plaintext,
  285. uint32_t size,
  286. const uint8_t key[LTC_DES_KEY_SIZE]);
  287. /*!
  288. * @brief Encrypts DES using CBC block mode.
  289. *
  290. * Encrypts DES using CBC block mode.
  291. *
  292. * @param base LTC peripheral base address
  293. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  294. * @param plaintext Input plaintext to encrypt
  295. * @param[out] ciphertext Ouput ciphertext
  296. * @param size Size of input and output data in bytes
  297. * @param iv Input initial vector to combine with the first plaintext block.
  298. * The iv does not need to be secret, but it must be unpredictable.
  299. * @param key Input key to use for encryption
  300. * @return Status from encrypt/decrypt operation
  301. */
  302. status_t LTC_DES_EncryptCbcEDMA(LTC_Type *base,
  303. ltc_edma_handle_t *handle,
  304. const uint8_t *plaintext,
  305. uint8_t *ciphertext,
  306. uint32_t size,
  307. const uint8_t iv[LTC_DES_IV_SIZE],
  308. const uint8_t key[LTC_DES_KEY_SIZE]);
  309. /*!
  310. * @brief Decrypts DES using CBC block mode.
  311. *
  312. * Decrypts DES using CBC block mode.
  313. *
  314. * @param base LTC peripheral base address
  315. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  316. * @param ciphertext Input ciphertext to decrypt
  317. * @param[out] plaintext Output plaintext
  318. * @param size Size of input data in bytes
  319. * @param iv Input initial vector to combine with the first plaintext block.
  320. * The iv does not need to be secret, but it must be unpredictable.
  321. * @param key Input key to use for decryption
  322. * @return Status from encrypt/decrypt operation
  323. */
  324. status_t LTC_DES_DecryptCbcEDMA(LTC_Type *base,
  325. ltc_edma_handle_t *handle,
  326. const uint8_t *ciphertext,
  327. uint8_t *plaintext,
  328. uint32_t size,
  329. const uint8_t iv[LTC_DES_IV_SIZE],
  330. const uint8_t key[LTC_DES_KEY_SIZE]);
  331. /*!
  332. * @brief Encrypts DES using CFB block mode.
  333. *
  334. * Encrypts DES using CFB block mode.
  335. *
  336. * @param base LTC peripheral base address
  337. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  338. * @param plaintext Input plaintext to encrypt
  339. * @param size Size of input data in bytes
  340. * @param iv Input initial block.
  341. * @param key Input key to use for encryption
  342. * @param[out] ciphertext Output ciphertext
  343. * @return Status from encrypt/decrypt operation
  344. */
  345. status_t LTC_DES_EncryptCfbEDMA(LTC_Type *base,
  346. ltc_edma_handle_t *handle,
  347. const uint8_t *plaintext,
  348. uint8_t *ciphertext,
  349. uint32_t size,
  350. const uint8_t iv[LTC_DES_IV_SIZE],
  351. const uint8_t key[LTC_DES_KEY_SIZE]);
  352. /*!
  353. * @brief Decrypts DES using CFB block mode.
  354. *
  355. * Decrypts DES using CFB block mode.
  356. *
  357. * @param base LTC peripheral base address
  358. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  359. * @param ciphertext Input ciphertext to decrypt
  360. * @param[out] plaintext Output plaintext
  361. * @param size Size of input and output data in bytes
  362. * @param iv Input initial block.
  363. * @param key Input key to use for decryption
  364. * @return Status from encrypt/decrypt operation
  365. */
  366. status_t LTC_DES_DecryptCfbEDMA(LTC_Type *base,
  367. ltc_edma_handle_t *handle,
  368. const uint8_t *ciphertext,
  369. uint8_t *plaintext,
  370. uint32_t size,
  371. const uint8_t iv[LTC_DES_IV_SIZE],
  372. const uint8_t key[LTC_DES_KEY_SIZE]);
  373. /*!
  374. * @brief Encrypts DES using OFB block mode.
  375. *
  376. * Encrypts DES using OFB block mode.
  377. *
  378. * @param base LTC peripheral base address
  379. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  380. * @param plaintext Input plaintext to encrypt
  381. * @param[out] ciphertext Output ciphertext
  382. * @param size Size of input and output data in bytes
  383. * @param iv Input unique input vector. The OFB mode requires that the IV be unique
  384. * for each execution of the mode under the given key.
  385. * @param key Input key to use for encryption
  386. * @return Status from encrypt/decrypt operation
  387. */
  388. status_t LTC_DES_EncryptOfbEDMA(LTC_Type *base,
  389. ltc_edma_handle_t *handle,
  390. const uint8_t *plaintext,
  391. uint8_t *ciphertext,
  392. uint32_t size,
  393. const uint8_t iv[LTC_DES_IV_SIZE],
  394. const uint8_t key[LTC_DES_KEY_SIZE]);
  395. /*!
  396. * @brief Decrypts DES using OFB block mode.
  397. *
  398. * Decrypts DES using OFB block mode.
  399. *
  400. * @param base LTC peripheral base address
  401. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  402. * @param ciphertext Input ciphertext to decrypt
  403. * @param[out] plaintext Output plaintext
  404. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  405. * @param iv Input unique input vector. The OFB mode requires that the IV be unique
  406. * for each execution of the mode under the given key.
  407. * @param key Input key to use for decryption
  408. * @return Status from encrypt/decrypt operation
  409. */
  410. status_t LTC_DES_DecryptOfbEDMA(LTC_Type *base,
  411. ltc_edma_handle_t *handle,
  412. const uint8_t *ciphertext,
  413. uint8_t *plaintext,
  414. uint32_t size,
  415. const uint8_t iv[LTC_DES_IV_SIZE],
  416. const uint8_t key[LTC_DES_KEY_SIZE]);
  417. /*!
  418. * @brief Encrypts triple DES using ECB block mode with two keys.
  419. *
  420. * Encrypts triple DES using ECB block mode with two keys.
  421. *
  422. * @param base LTC peripheral base address
  423. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  424. * @param plaintext Input plaintext to encrypt
  425. * @param[out] ciphertext Output ciphertext
  426. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  427. * @param key1 First input key for key bundle
  428. * @param key2 Second input key for key bundle
  429. * @return Status from encrypt/decrypt operation
  430. */
  431. status_t LTC_DES2_EncryptEcbEDMA(LTC_Type *base,
  432. ltc_edma_handle_t *handle,
  433. const uint8_t *plaintext,
  434. uint8_t *ciphertext,
  435. uint32_t size,
  436. const uint8_t key1[LTC_DES_KEY_SIZE],
  437. const uint8_t key2[LTC_DES_KEY_SIZE]);
  438. /*!
  439. * @brief Decrypts triple DES using ECB block mode with two keys.
  440. *
  441. * Decrypts triple DES using ECB block mode with two keys.
  442. *
  443. * @param base LTC peripheral base address
  444. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  445. * @param ciphertext Input ciphertext to decrypt
  446. * @param[out] plaintext Output plaintext
  447. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  448. * @param key1 First input key for key bundle
  449. * @param key2 Second input key for key bundle
  450. * @return Status from encrypt/decrypt operation
  451. */
  452. status_t LTC_DES2_DecryptEcbEDMA(LTC_Type *base,
  453. ltc_edma_handle_t *handle,
  454. const uint8_t *ciphertext,
  455. uint8_t *plaintext,
  456. uint32_t size,
  457. const uint8_t key1[LTC_DES_KEY_SIZE],
  458. const uint8_t key2[LTC_DES_KEY_SIZE]);
  459. /*!
  460. * @brief Encrypts triple DES using CBC block mode with two keys.
  461. *
  462. * Encrypts triple DES using CBC block mode with two keys.
  463. *
  464. * @param base LTC peripheral base address
  465. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  466. * @param plaintext Input plaintext to encrypt
  467. * @param[out] ciphertext Output ciphertext
  468. * @param size Size of input and output data in bytes
  469. * @param iv Input initial vector to combine with the first plaintext block.
  470. * The iv does not need to be secret, but it must be unpredictable.
  471. * @param key1 First input key for key bundle
  472. * @param key2 Second input key for key bundle
  473. * @return Status from encrypt/decrypt operation
  474. */
  475. status_t LTC_DES2_EncryptCbcEDMA(LTC_Type *base,
  476. ltc_edma_handle_t *handle,
  477. const uint8_t *plaintext,
  478. uint8_t *ciphertext,
  479. uint32_t size,
  480. const uint8_t iv[LTC_DES_IV_SIZE],
  481. const uint8_t key1[LTC_DES_KEY_SIZE],
  482. const uint8_t key2[LTC_DES_KEY_SIZE]);
  483. /*!
  484. * @brief Decrypts triple DES using CBC block mode with two keys.
  485. *
  486. * Decrypts triple DES using CBC block mode with two keys.
  487. *
  488. * @param base LTC peripheral base address
  489. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  490. * @param ciphertext Input ciphertext to decrypt
  491. * @param[out] plaintext Output plaintext
  492. * @param size Size of input and output data in bytes
  493. * @param iv Input initial vector to combine with the first plaintext block.
  494. * The iv does not need to be secret, but it must be unpredictable.
  495. * @param key1 First input key for key bundle
  496. * @param key2 Second input key for key bundle
  497. * @return Status from encrypt/decrypt operation
  498. */
  499. status_t LTC_DES2_DecryptCbcEDMA(LTC_Type *base,
  500. ltc_edma_handle_t *handle,
  501. const uint8_t *ciphertext,
  502. uint8_t *plaintext,
  503. uint32_t size,
  504. const uint8_t iv[LTC_DES_IV_SIZE],
  505. const uint8_t key1[LTC_DES_KEY_SIZE],
  506. const uint8_t key2[LTC_DES_KEY_SIZE]);
  507. /*!
  508. * @brief Encrypts triple DES using CFB block mode with two keys.
  509. *
  510. * Encrypts triple DES using CFB block mode with two keys.
  511. *
  512. * @param base LTC peripheral base address
  513. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  514. * @param plaintext Input plaintext to encrypt
  515. * @param[out] ciphertext Output ciphertext
  516. * @param size Size of input and output data in bytes
  517. * @param iv Input initial block.
  518. * @param key1 First input key for key bundle
  519. * @param key2 Second input key for key bundle
  520. * @return Status from encrypt/decrypt operation
  521. */
  522. status_t LTC_DES2_EncryptCfbEDMA(LTC_Type *base,
  523. ltc_edma_handle_t *handle,
  524. const uint8_t *plaintext,
  525. uint8_t *ciphertext,
  526. uint32_t size,
  527. const uint8_t iv[LTC_DES_IV_SIZE],
  528. const uint8_t key1[LTC_DES_KEY_SIZE],
  529. const uint8_t key2[LTC_DES_KEY_SIZE]);
  530. /*!
  531. * @brief Decrypts triple DES using CFB block mode with two keys.
  532. *
  533. * Decrypts triple DES using CFB block mode with two keys.
  534. *
  535. * @param base LTC peripheral base address
  536. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  537. * @param ciphertext Input ciphertext to decrypt
  538. * @param[out] plaintext Output plaintext
  539. * @param size Size of input and output data in bytes
  540. * @param iv Input initial block.
  541. * @param key1 First input key for key bundle
  542. * @param key2 Second input key for key bundle
  543. * @return Status from encrypt/decrypt operation
  544. */
  545. status_t LTC_DES2_DecryptCfbEDMA(LTC_Type *base,
  546. ltc_edma_handle_t *handle,
  547. const uint8_t *ciphertext,
  548. uint8_t *plaintext,
  549. uint32_t size,
  550. const uint8_t iv[LTC_DES_IV_SIZE],
  551. const uint8_t key1[LTC_DES_KEY_SIZE],
  552. const uint8_t key2[LTC_DES_KEY_SIZE]);
  553. /*!
  554. * @brief Encrypts triple DES using OFB block mode with two keys.
  555. *
  556. * Encrypts triple DES using OFB block mode with two keys.
  557. *
  558. * @param base LTC peripheral base address
  559. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  560. * @param plaintext Input plaintext to encrypt
  561. * @param[out] ciphertext Output ciphertext
  562. * @param size Size of input and output data in bytes
  563. * @param iv Input unique input vector. The OFB mode requires that the IV be unique
  564. * for each execution of the mode under the given key.
  565. * @param key1 First input key for key bundle
  566. * @param key2 Second input key for key bundle
  567. * @return Status from encrypt/decrypt operation
  568. */
  569. status_t LTC_DES2_EncryptOfbEDMA(LTC_Type *base,
  570. ltc_edma_handle_t *handle,
  571. const uint8_t *plaintext,
  572. uint8_t *ciphertext,
  573. uint32_t size,
  574. const uint8_t iv[LTC_DES_IV_SIZE],
  575. const uint8_t key1[LTC_DES_KEY_SIZE],
  576. const uint8_t key2[LTC_DES_KEY_SIZE]);
  577. /*!
  578. * @brief Decrypts triple DES using OFB block mode with two keys.
  579. *
  580. * Decrypts triple DES using OFB block mode with two keys.
  581. *
  582. * @param base LTC peripheral base address
  583. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  584. * @param ciphertext Input ciphertext to decrypt
  585. * @param[out] plaintext Output plaintext
  586. * @param size Size of input and output data in bytes
  587. * @param iv Input unique input vector. The OFB mode requires that the IV be unique
  588. * for each execution of the mode under the given key.
  589. * @param key1 First input key for key bundle
  590. * @param key2 Second input key for key bundle
  591. * @return Status from encrypt/decrypt operation
  592. */
  593. status_t LTC_DES2_DecryptOfbEDMA(LTC_Type *base,
  594. ltc_edma_handle_t *handle,
  595. const uint8_t *ciphertext,
  596. uint8_t *plaintext,
  597. uint32_t size,
  598. const uint8_t iv[LTC_DES_IV_SIZE],
  599. const uint8_t key1[LTC_DES_KEY_SIZE],
  600. const uint8_t key2[LTC_DES_KEY_SIZE]);
  601. /*!
  602. * @brief Encrypts triple DES using ECB block mode with three keys.
  603. *
  604. * Encrypts triple DES using ECB block mode with three keys.
  605. *
  606. * @param base LTC peripheral base address
  607. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  608. * @param plaintext Input plaintext to encrypt
  609. * @param[out] ciphertext Output ciphertext
  610. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  611. * @param key1 First input key for key bundle
  612. * @param key2 Second input key for key bundle
  613. * @param key3 Third input key for key bundle
  614. * @return Status from encrypt/decrypt operation
  615. */
  616. status_t LTC_DES3_EncryptEcbEDMA(LTC_Type *base,
  617. ltc_edma_handle_t *handle,
  618. const uint8_t *plaintext,
  619. uint8_t *ciphertext,
  620. uint32_t size,
  621. const uint8_t key1[LTC_DES_KEY_SIZE],
  622. const uint8_t key2[LTC_DES_KEY_SIZE],
  623. const uint8_t key3[LTC_DES_KEY_SIZE]);
  624. /*!
  625. * @brief Decrypts triple DES using ECB block mode with three keys.
  626. *
  627. * Decrypts triple DES using ECB block mode with three keys.
  628. *
  629. * @param base LTC peripheral base address
  630. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  631. * @param ciphertext Input ciphertext to decrypt
  632. * @param[out] plaintext Output plaintext
  633. * @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
  634. * @param key1 First input key for key bundle
  635. * @param key2 Second input key for key bundle
  636. * @param key3 Third input key for key bundle
  637. * @return Status from encrypt/decrypt operation
  638. */
  639. status_t LTC_DES3_DecryptEcbEDMA(LTC_Type *base,
  640. ltc_edma_handle_t *handle,
  641. const uint8_t *ciphertext,
  642. uint8_t *plaintext,
  643. uint32_t size,
  644. const uint8_t key1[LTC_DES_KEY_SIZE],
  645. const uint8_t key2[LTC_DES_KEY_SIZE],
  646. const uint8_t key3[LTC_DES_KEY_SIZE]);
  647. /*!
  648. * @brief Encrypts triple DES using CBC block mode with three keys.
  649. *
  650. * Encrypts triple DES using CBC block mode with three keys.
  651. *
  652. * @param base LTC peripheral base address
  653. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  654. * @param plaintext Input plaintext to encrypt
  655. * @param[out] ciphertext Output ciphertext
  656. * @param size Size of input data in bytes
  657. * @param iv Input initial vector to combine with the first plaintext block.
  658. * The iv does not need to be secret, but it must be unpredictable.
  659. * @param key1 First input key for key bundle
  660. * @param key2 Second input key for key bundle
  661. * @param key3 Third input key for key bundle
  662. * @return Status from encrypt/decrypt operation
  663. */
  664. status_t LTC_DES3_EncryptCbcEDMA(LTC_Type *base,
  665. ltc_edma_handle_t *handle,
  666. const uint8_t *plaintext,
  667. uint8_t *ciphertext,
  668. uint32_t size,
  669. const uint8_t iv[LTC_DES_IV_SIZE],
  670. const uint8_t key1[LTC_DES_KEY_SIZE],
  671. const uint8_t key2[LTC_DES_KEY_SIZE],
  672. const uint8_t key3[LTC_DES_KEY_SIZE]);
  673. /*!
  674. * @brief Decrypts triple DES using CBC block mode with three keys.
  675. *
  676. * Decrypts triple DES using CBC block mode with three keys.
  677. *
  678. * @param base LTC peripheral base address
  679. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  680. * @param ciphertext Input ciphertext to decrypt
  681. * @param[out] plaintext Output plaintext
  682. * @param size Size of input and output data in bytes
  683. * @param iv Input initial vector to combine with the first plaintext block.
  684. * The iv does not need to be secret, but it must be unpredictable.
  685. * @param key1 First input key for key bundle
  686. * @param key2 Second input key for key bundle
  687. * @param key3 Third input key for key bundle
  688. * @return Status from encrypt/decrypt operation
  689. */
  690. status_t LTC_DES3_DecryptCbcEDMA(LTC_Type *base,
  691. ltc_edma_handle_t *handle,
  692. const uint8_t *ciphertext,
  693. uint8_t *plaintext,
  694. uint32_t size,
  695. const uint8_t iv[LTC_DES_IV_SIZE],
  696. const uint8_t key1[LTC_DES_KEY_SIZE],
  697. const uint8_t key2[LTC_DES_KEY_SIZE],
  698. const uint8_t key3[LTC_DES_KEY_SIZE]);
  699. /*!
  700. * @brief Encrypts triple DES using CFB block mode with three keys.
  701. *
  702. * Encrypts triple DES using CFB block mode with three keys.
  703. *
  704. * @param base LTC peripheral base address
  705. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  706. * @param plaintext Input plaintext to encrypt
  707. * @param[out] ciphertext Output ciphertext
  708. * @param size Size of input and ouput data in bytes
  709. * @param iv Input initial block.
  710. * @param key1 First input key for key bundle
  711. * @param key2 Second input key for key bundle
  712. * @param key3 Third input key for key bundle
  713. * @return Status from encrypt/decrypt operation
  714. */
  715. status_t LTC_DES3_EncryptCfbEDMA(LTC_Type *base,
  716. ltc_edma_handle_t *handle,
  717. const uint8_t *plaintext,
  718. uint8_t *ciphertext,
  719. uint32_t size,
  720. const uint8_t iv[LTC_DES_IV_SIZE],
  721. const uint8_t key1[LTC_DES_KEY_SIZE],
  722. const uint8_t key2[LTC_DES_KEY_SIZE],
  723. const uint8_t key3[LTC_DES_KEY_SIZE]);
  724. /*!
  725. * @brief Decrypts triple DES using CFB block mode with three keys.
  726. *
  727. * Decrypts triple DES using CFB block mode with three keys.
  728. *
  729. * @param base LTC peripheral base address
  730. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  731. * @param ciphertext Input ciphertext to decrypt
  732. * @param[out] plaintext Output plaintext
  733. * @param size Size of input data in bytes
  734. * @param iv Input initial block.
  735. * @param key1 First input key for key bundle
  736. * @param key2 Second input key for key bundle
  737. * @param key3 Third input key for key bundle
  738. * @return Status from encrypt/decrypt operation
  739. */
  740. status_t LTC_DES3_DecryptCfbEDMA(LTC_Type *base,
  741. ltc_edma_handle_t *handle,
  742. const uint8_t *ciphertext,
  743. uint8_t *plaintext,
  744. uint32_t size,
  745. const uint8_t iv[LTC_DES_IV_SIZE],
  746. const uint8_t key1[LTC_DES_KEY_SIZE],
  747. const uint8_t key2[LTC_DES_KEY_SIZE],
  748. const uint8_t key3[LTC_DES_KEY_SIZE]);
  749. /*!
  750. * @brief Encrypts triple DES using OFB block mode with three keys.
  751. *
  752. * Encrypts triple DES using OFB block mode with three keys.
  753. *
  754. * @param base LTC peripheral base address
  755. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  756. * @param plaintext Input plaintext to encrypt
  757. * @param[out] ciphertext Output ciphertext
  758. * @param size Size of input and output data in bytes
  759. * @param iv Input unique input vector. The OFB mode requires that the IV be unique
  760. * for each execution of the mode under the given key.
  761. * @param key1 First input key for key bundle
  762. * @param key2 Second input key for key bundle
  763. * @param key3 Third input key for key bundle
  764. * @return Status from encrypt/decrypt operation
  765. */
  766. status_t LTC_DES3_EncryptOfbEDMA(LTC_Type *base,
  767. ltc_edma_handle_t *handle,
  768. const uint8_t *plaintext,
  769. uint8_t *ciphertext,
  770. uint32_t size,
  771. const uint8_t iv[LTC_DES_IV_SIZE],
  772. const uint8_t key1[LTC_DES_KEY_SIZE],
  773. const uint8_t key2[LTC_DES_KEY_SIZE],
  774. const uint8_t key3[LTC_DES_KEY_SIZE]);
  775. /*!
  776. * @brief Decrypts triple DES using OFB block mode with three keys.
  777. *
  778. * Decrypts triple DES using OFB block mode with three keys.
  779. *
  780. * @param base LTC peripheral base address
  781. * @param handle pointer to ltc_edma_handle_t structure which stores the transaction state.
  782. * @param ciphertext Input ciphertext to decrypt
  783. * @param[out] plaintext Output plaintext
  784. * @param size Size of input and output data in bytes
  785. * @param iv Input unique input vector. The OFB mode requires that the IV be unique
  786. * for each execution of the mode under the given key.
  787. * @param key1 First input key for key bundle
  788. * @param key2 Second input key for key bundle
  789. * @param key3 Third input key for key bundle
  790. * @return Status from encrypt/decrypt operation
  791. */
  792. status_t LTC_DES3_DecryptOfbEDMA(LTC_Type *base,
  793. ltc_edma_handle_t *handle,
  794. const uint8_t *ciphertext,
  795. uint8_t *plaintext,
  796. uint32_t size,
  797. const uint8_t iv[LTC_DES_IV_SIZE],
  798. const uint8_t key1[LTC_DES_KEY_SIZE],
  799. const uint8_t key2[LTC_DES_KEY_SIZE],
  800. const uint8_t key3[LTC_DES_KEY_SIZE]);
  801. /*!
  802. *@}
  803. */
  804. #if defined(__cplusplus)
  805. }
  806. #endif
  807. #endif /* _FSL_LTC_EDMA_H_ */