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