1 /*
2  *  Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *
8  *    Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  *    Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the
14  *    distribution.
15  *
16  *    Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 //*****************************************************************************
34 //
35 //  des.h
36 //
37 //  Defines and Macros for the DES module.
38 //
39 //*****************************************************************************
40 
41 #ifndef __DRIVERLIB_DES_H__
42 #define __DRIVERLIB_DES_H__
43 
44 //*****************************************************************************
45 //
46 // If building with a C++ compiler, make all of the definitions in this header
47 // have a C binding.
48 //
49 //*****************************************************************************
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 //*****************************************************************************
56 //
57 // The following defines are used to specify the direction with the
58 // ui32Config argument in the DESConfig() function.  Only one is permitted.
59 //
60 //*****************************************************************************
61 #define DES_CFG_DIR_DECRYPT     0x00000000
62 #define DES_CFG_DIR_ENCRYPT     0x00000004
63 
64 //*****************************************************************************
65 //
66 // The following defines are used to specify the operational with the
67 // ui32Config argument in the DESConfig() function.  Only one is permitted.
68 //
69 //*****************************************************************************
70 #define DES_CFG_MODE_ECB        0x00000000
71 #define DES_CFG_MODE_CBC        0x00000010
72 #define DES_CFG_MODE_CFB        0x00000020
73 
74 //*****************************************************************************
75 //
76 // The following defines are used to select between single DES and triple DES
77 // with the ui32Config argument in the DESConfig() function.  Only one is
78 // permitted.
79 //
80 //*****************************************************************************
81 #define DES_CFG_SINGLE          0x00000000
82 #define DES_CFG_TRIPLE          0x00000008
83 
84 //*****************************************************************************
85 //
86 // The following defines are used with the DESIntEnable(), DESIntDisable() and
87 // DESIntStatus() functions.
88 //
89 //*****************************************************************************
90 #define DES_INT_CONTEXT_IN      0x00000001
91 #define DES_INT_DATA_IN         0x00000002
92 #define DES_INT_DATA_OUT        0x00000004
93 #define DES_INT_DMA_CONTEXT_IN  0x00010000
94 #define DES_INT_DMA_DATA_IN     0x00020000
95 #define DES_INT_DMA_DATA_OUT    0x00040000
96 
97 //*****************************************************************************
98 //
99 // The following defines are used with the DESEnableDMA() and DESDisableDMA()
100 // functions.
101 //
102 //*****************************************************************************
103 #define DES_DMA_CONTEXT_IN      0x00000080
104 #define DES_DMA_DATA_OUT        0x00000040
105 #define DES_DMA_DATA_IN         0x00000020
106 
107 //*****************************************************************************
108 //
109 // API Function prototypes
110 //
111 //*****************************************************************************
112 extern void DESConfigSet(uint32_t ui32Base, uint32_t ui32Config);
113 extern void DESDataRead(uint32_t ui32Base, uint8_t *pui8Dest,
114                         uint8_t ui8Length);
115 extern bool DESDataReadNonBlocking(uint32_t ui32Base, uint8_t *pui8Dest,
116                                    uint8_t ui8Length);
117 extern bool DESDataProcess(uint32_t ui32Base, uint8_t *pui8Src,
118                            uint8_t *pui8Dest, uint32_t ui32Length);
119 extern void DESDataWrite(uint32_t ui32Base, uint8_t *pui8Src,
120                          uint8_t ui8Length);
121 extern bool DESDataWriteNonBlocking(uint32_t ui32Base, uint8_t *pui8Src,
122                                     uint8_t ui8Length);
123 extern void DESDMADisable(uint32_t ui32Base, uint32_t ui32Flags);
124 extern void DESDMAEnable(uint32_t ui32Base, uint32_t ui32Flags);
125 extern void DESIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
126 extern void DESIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
127 extern void DESIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
128 extern void DESIntRegister(uint32_t ui32Base, void(*pfnHandler)(void));
129 extern uint32_t DESIntStatus(uint32_t ui32Base, bool bMasked);
130 extern void DESIntUnregister(uint32_t ui32Base);
131 extern bool DESIVSet(uint32_t ui32Base, uint8_t *pui8IVdata);
132 extern void DESKeySet(uint32_t ui32Base, uint8_t *pui8Key);
133 extern void DESDataLengthSet(uint32_t ui32Base, uint32_t ui32Length);
134 
135 //*****************************************************************************
136 //
137 // Mark the end of the C bindings section for C++ compilers.
138 //
139 //*****************************************************************************
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif //  __DRIVERLIB_DES_H__
145