]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/emlib/inc/em_crypto.h
a1d6b19d90a57f588e127d4328794ec15aafc348
[freertos] / FreeRTOS / Demo / CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio / Source / SilLabs_Code / emlib / inc / em_crypto.h
1 /***************************************************************************//**\r
2  * @file em_crypto.h\r
3  * @brief Cryptography accelerator peripheral API\r
4  * @version 4.2.1\r
5  *******************************************************************************\r
6  * @section License\r
7  * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>\r
8  *******************************************************************************\r
9  *\r
10  * Permission is granted to anyone to use this software for any purpose,\r
11  * including commercial applications, and to alter it and redistribute it\r
12  * freely, subject to the following restrictions:\r
13  *\r
14  * 1. The origin of this software must not be misrepresented; you must not\r
15  *    claim that you wrote the original software.\r
16  * 2. Altered source versions must be plainly marked as such, and must not be\r
17  *    misrepresented as being the original software.\r
18  * 3. This notice may not be removed or altered from any source distribution.\r
19  *\r
20  * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no\r
21  * obligation to support this Software. Silicon Labs is providing the\r
22  * Software "AS IS", with no express or implied warranties of any kind,\r
23  * including, but not limited to, any implied warranties of merchantability\r
24  * or fitness for any particular purpose or warranties against infringement\r
25  * of any proprietary rights of a third party.\r
26  *\r
27  * Silicon Labs will not be liable for any consequential, incidental, or\r
28  * special damages, or any other relief, or for any claim by any third party,\r
29  * arising from your use of this Software.\r
30  *\r
31  ******************************************************************************/\r
32 #ifndef __SILICON_LABS_EM_CRYPTO_H__\r
33 #define __SILICON_LABS_EM_CRYPTO_H__\r
34 \r
35 #include "em_device.h"\r
36 \r
37 #if defined(CRYPTO_COUNT) && (CRYPTO_COUNT > 0)\r
38 \r
39 #include "em_bus.h"\r
40 #include <stdbool.h>\r
41 \r
42 #ifdef __cplusplus\r
43 extern "C" {\r
44 #endif\r
45 \r
46 /***************************************************************************//**\r
47  * @addtogroup EM_Library\r
48  * @{\r
49  ******************************************************************************/\r
50 \r
51 /***************************************************************************//**\r
52  * @addtogroup CRYPTO\r
53  * @{\r
54  ******************************************************************************/\r
55 \r
56  /*******************************************************************************\r
57  ******************************   DEFINES    ***********************************\r
58  ******************************************************************************/\r
59 \r
60 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */\r
61 /** Data sizes used by CRYPTO operations. */\r
62 #define CRYPTO_DATA_SIZE_IN_BITS           (128)\r
63 #define CRYPTO_DATA_SIZE_IN_BYTES          (CRYPTO_DATA_SIZE_IN_BITS/8)\r
64 #define CRYPTO_DATA_SIZE_IN_32BIT_WORDS    (CRYPTO_DATA_SIZE_IN_BYTES/sizeof(uint32_t))\r
65 \r
66 #define CRYPTO_KEYBUF_SIZE_IN_BITS         (256)\r
67 #define CRYPTO_KEYBUF_SIZE_IN_BYTES        (CRYPTO_DDATA_SIZE_IN_BITS/8)\r
68 #define CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS  (CRYPTO_DDATA_SIZE_IN_BYTES/sizeof(uint32_t))\r
69 \r
70 #define CRYPTO_DDATA_SIZE_IN_BITS          (256)\r
71 #define CRYPTO_DDATA_SIZE_IN_BYTES         (CRYPTO_DDATA_SIZE_IN_BITS/8)\r
72 #define CRYPTO_DDATA_SIZE_IN_32BIT_WORDS   (CRYPTO_DDATA_SIZE_IN_BYTES/sizeof(uint32_t))\r
73 \r
74 #define CRYPTO_QDATA_SIZE_IN_BITS          (512)\r
75 #define CRYPTO_QDATA_SIZE_IN_BYTES         (CRYPTO_QDATA_SIZE_IN_BITS/8)\r
76 #define CRYPTO_QDATA_SIZE_IN_32BIT_WORDS   (CRYPTO_QDATA_SIZE_IN_BYTES/sizeof(uint32_t))\r
77 \r
78 #define CRYPTO_DATA260_SIZE_IN_32BIT_WORDS (9)\r
79 \r
80 /** SHA-1 digest sizes */\r
81 #define CRYPTO_SHA1_DIGEST_SIZE_IN_BITS    (160)\r
82 #define CRYPTO_SHA1_DIGEST_SIZE_IN_BYTES   (CRYPTO_SHA1_DIGEST_SIZE_IN_BITS/8)\r
83 \r
84 /** SHA-256 digest sizes */\r
85 #define CRYPTO_SHA256_DIGEST_SIZE_IN_BITS  (256)\r
86 #define CRYPTO_SHA256_DIGEST_SIZE_IN_BYTES (CRYPTO_SHA256_DIGEST_SIZE_IN_BITS/8)\r
87 \r
88 /**\r
89  * Read and write all 260 bits of DDATA0 when in 260 bit mode.\r
90  */\r
91 #define CRYPTO_DDATA0_260_BITS_READ(bigint260)  CRYPTO_DData0Read260(bigint260)\r
92 #define CRYPTO_DDATA0_260_BITS_WRITE(bigint260) CRYPTO_DData0Write260(bigint260)\r
93 /** @endcond */\r
94 \r
95 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */\r
96 /**\r
97  * Instruction sequence load macros CRYPTO_SEQ_LOAD_X (where X is in the range\r
98  * 1-20). E.g. @ref CRYPTO_SEQ_LOAD_20.\r
99  * Use these macros in order for faster execution than the function API.\r
100  */\r
101 #define CRYPTO_SEQ_LOAD_1(a1) { \\r
102     CRYPTO->SEQ0 =  a1 |  (CRYPTO_CMD_INSTR_END<<8);}\r
103 #define CRYPTO_SEQ_LOAD_2(a1, a2) { \\r
104     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (CRYPTO_CMD_INSTR_END<<16);}\r
105 #define CRYPTO_SEQ_LOAD_3(a1, a2, a3) { \\r
106     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) | (CRYPTO_CMD_INSTR_END<<24);}\r
107 #define CRYPTO_SEQ_LOAD_4(a1, a2, a3, a4) { \\r
108     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
109     CRYPTO->SEQ1 =  CRYPTO_CMD_INSTR_END;}\r
110 #define CRYPTO_SEQ_LOAD_5(a1, a2, a3, a4, a5) { \\r
111     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
112     CRYPTO->SEQ1 =  a5 |  (CRYPTO_CMD_INSTR_END<<8);}\r
113 #define CRYPTO_SEQ_LOAD_6(a1, a2, a3, a4, a5, a6) { \\r
114     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
115     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (CRYPTO_CMD_INSTR_END<<16);}\r
116 #define CRYPTO_SEQ_LOAD_7(a1, a2, a3, a4, a5, a6, a7) { \\r
117     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
118     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (CRYPTO_CMD_INSTR_END<<24);}\r
119 #define CRYPTO_SEQ_LOAD_8(a1, a2, a3, a4, a5, a6, a7, a8) { \\r
120     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
121     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
122     CRYPTO->SEQ2 =  CRYPTO_CMD_INSTR_END;}\r
123 #define CRYPTO_SEQ_LOAD_9(a1, a2, a3, a4, a5, a6, a7, a8, a9) { \\r
124     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
125     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
126     CRYPTO->SEQ2 =  a9 | (CRYPTO_CMD_INSTR_END<<8);}\r
127 #define CRYPTO_SEQ_LOAD_10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { \\r
128     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
129     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
130     CRYPTO->SEQ2 =  a9 | (a10<<8) | (CRYPTO_CMD_INSTR_END<<16);}\r
131 #define CRYPTO_SEQ_LOAD_11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { \\r
132     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
133     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
134     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (CRYPTO_CMD_INSTR_END<<24);}\r
135 #define CRYPTO_SEQ_LOAD_12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { \\r
136     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
137     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
138     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
139     CRYPTO->SEQ3 = CRYPTO_CMD_INSTR_END;}\r
140 #define CRYPTO_SEQ_LOAD_13(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) { \\r
141     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
142     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
143     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
144     CRYPTO->SEQ3 = a13 | (CRYPTO_CMD_INSTR_END<<8);}\r
145 #define CRYPTO_SEQ_LOAD_14(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) { \\r
146     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
147     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
148     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
149     CRYPTO->SEQ3 = a13 | (a14<<8) | (CRYPTO_CMD_INSTR_END<<16);}\r
150 #define CRYPTO_SEQ_LOAD_15(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) { \\r
151     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
152     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
153     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
154     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (CRYPTO_CMD_INSTR_END<<24);}\r
155 #define CRYPTO_SEQ_LOAD_16(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) { \\r
156     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
157     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
158     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
159     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
160     CRYPTO->SEQ4 = CRYPTO_CMD_INSTR_END;}\r
161 #define CRYPTO_SEQ_LOAD_17(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) { \\r
162     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
163     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
164     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
165     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
166     CRYPTO->SEQ4 = a17 | (CRYPTO_CMD_INSTR_END<<8);}\r
167 #define CRYPTO_SEQ_LOAD_18(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) { \\r
168     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
169     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
170     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
171     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
172     CRYPTO->SEQ4 = a17 | (a18<<8) | (CRYPTO_CMD_INSTR_END<<16);}\r
173 #define CRYPTO_SEQ_LOAD_19(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) { \\r
174     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
175     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
176     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
177     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
178     CRYPTO->SEQ4 = a17 | (a18<<8) | (a19<<16) | (CRYPTO_CMD_INSTR_END<<24);}\r
179 #define CRYPTO_SEQ_LOAD_20(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) { \\r
180     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
181     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
182     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
183     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
184     CRYPTO->SEQ4 = a17 | (a18<<8) | (a19<<16) | (a20<<24);}\r
185 /** @endcond */\r
186 \r
187 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */\r
188 /**\r
189  * Instruction sequence execution macros CRYPTO_EXECUTE_X (where X is in the range\r
190  * 1-20). E.g. @ref CRYPTO_EXECUTE_19.\r
191  * Use these macros in order for faster execution than the function API.\r
192  */\r
193 #define CRYPTO_EXECUTE_1(a1) {                                          \\r
194     CRYPTO->SEQ0 = a1 | (CRYPTO_CMD_INSTR_EXEC<<8);                    }\r
195 #define CRYPTO_EXECUTE_2(a1, a2) {                                      \\r
196     CRYPTO->SEQ0 = a1 | (a2<<8) | (CRYPTO_CMD_INSTR_EXEC<<16);         }\r
197 #define CRYPTO_EXECUTE_3(a1, a2, a3) {                                  \\r
198     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }\r
199 #define CRYPTO_EXECUTE_4(a1, a2, a3, a4) {                              \\r
200     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
201     CRYPTO->SEQ1 = CRYPTO_CMD_INSTR_EXEC;                              }\r
202 #define CRYPTO_EXECUTE_5(a1, a2, a3, a4, a5) {                          \\r
203     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
204     CRYPTO->SEQ1 = a5 | (CRYPTO_CMD_INSTR_EXEC<<8);                    }\r
205 #define CRYPTO_EXECUTE_6(a1, a2, a3, a4, a5, a6) {                      \\r
206     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
207     CRYPTO->SEQ1 = a5 | (a6<<8) | (CRYPTO_CMD_INSTR_EXEC<<16);         }\r
208 #define CRYPTO_EXECUTE_7(a1, a2, a3, a4, a5, a6, a7) {                  \\r
209     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
210     CRYPTO->SEQ1 = a5 | (a6<<8) | (a7<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }\r
211 #define CRYPTO_EXECUTE_8(a1, a2, a3, a4, a5, a6, a7, a8) {              \\r
212     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
213     CRYPTO->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24);                  \\r
214     CRYPTO->SEQ2 = CRYPTO_CMD_INSTR_EXEC;                              }\r
215 #define CRYPTO_EXECUTE_9(a1, a2, a3, a4, a5, a6, a7, a8, a9) {          \\r
216     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
217     CRYPTO->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24);                  \\r
218     CRYPTO->SEQ2 = a9 | (CRYPTO_CMD_INSTR_EXEC<<8);                    }\r
219 #define CRYPTO_EXECUTE_10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {    \\r
220     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
221     CRYPTO->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24);                  \\r
222     CRYPTO->SEQ2 = a9 | (a10<<8) | (CRYPTO_CMD_INSTR_EXEC<<16);        }\r
223 #define CRYPTO_EXECUTE_11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { \\r
224     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
225     CRYPTO->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24);                  \\r
226     CRYPTO->SEQ2 = a9 | (a10<<8) | (a11<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }\r
227 #define CRYPTO_EXECUTE_12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { \\r
228     CRYPTO->SEQ0 = a1 |  (a2<<8) |  (a3<<16) | (a4<<24);                \\r
229     CRYPTO->SEQ1 = a5 |  (a6<<8) |  (a7<<16) | (a8<<24);                \\r
230     CRYPTO->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24);               \\r
231     CRYPTO->SEQ3 = CRYPTO_CMD_INSTR_EXEC;                              }\r
232 #define CRYPTO_EXECUTE_13(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) { \\r
233     CRYPTO->SEQ0 = a1  | (a2<<8)  | (a3<<16)  | (a4<<24);               \\r
234     CRYPTO->SEQ1 = a5  | (a6<<8)  | (a7<<16)  | (a8<<24);               \\r
235     CRYPTO->SEQ2 = a9  | (a10<<8) | (a11<<16) | (a12<<24);              \\r
236     CRYPTO->SEQ3 = a13 | (CRYPTO_CMD_INSTR_EXEC<<8);                   }\r
237 #define CRYPTO_EXECUTE_14(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) { \\r
238     CRYPTO->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24);                  \\r
239     CRYPTO->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24);                  \\r
240     CRYPTO->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24);               \\r
241     CRYPTO->SEQ3 = a13 | (a14<<8) | (CRYPTO_CMD_INSTR_EXEC<<16);       }\r
242 #define CRYPTO_EXECUTE_15(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) { \\r
243     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
244     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
245     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
246     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }\r
247 #define CRYPTO_EXECUTE_16(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) { \\r
248     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
249     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
250     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
251     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
252     CRYPTO->SEQ4 = CRYPTO_CMD_INSTR_EXEC;                              }\r
253 #define CRYPTO_EXECUTE_17(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) { \\r
254     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) | (a4<<24);               \\r
255     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) | (a8<<24);               \\r
256     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
257     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
258     CRYPTO->SEQ4 = a17 | (CRYPTO_CMD_INSTR_EXEC<<8);                   }\r
259 #define CRYPTO_EXECUTE_18(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) { \\r
260     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
261     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
262     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
263     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
264     CRYPTO->SEQ4 = a17 | (a18<<8) | (CRYPTO_CMD_INSTR_EXEC<<16);       }\r
265 #define CRYPTO_EXECUTE_19(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) { \\r
266     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
267     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
268     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
269     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
270     CRYPTO->SEQ4 = a17 | (a18<<8) | (a19<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }\r
271 #define CRYPTO_EXECUTE_20(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) { \\r
272     CRYPTO->SEQ0 =  a1 |  (a2<<8) |  (a3<<16) |  (a4<<24);              \\r
273     CRYPTO->SEQ1 =  a5 |  (a6<<8) |  (a7<<16) |  (a8<<24);              \\r
274     CRYPTO->SEQ2 =  a9 | (a10<<8) | (a11<<16) | (a12<<24);              \\r
275     CRYPTO->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24);              \\r
276     CRYPTO->SEQ4 = a17 | (a18<<8) | (a19<<16) | (a20<<24);              \\r
277     CRYPTO_InstructionSequenceExecute();}\r
278 /** @endcond */\r
279 \r
280 /*******************************************************************************\r
281  ******************************   TYPEDEFS   ***********************************\r
282  ******************************************************************************/\r
283 \r
284 /**\r
285  * CRYPTO data types used for data load functions. This data type is\r
286  * capable of storing a 128 bits value as used in the crypto DATA\r
287  * registers\r
288  */\r
289 typedef uint32_t CRYPTO_Data_TypeDef[CRYPTO_DATA_SIZE_IN_32BIT_WORDS];\r
290 \r
291 /**\r
292  * CRYPTO data type used for data load functions. This data type\r
293  * is capable of storing a 256 bits value as used in the crypto DDATA\r
294  * registers\r
295  */\r
296 typedef uint32_t CRYPTO_DData_TypeDef[CRYPTO_DDATA_SIZE_IN_32BIT_WORDS];\r
297 \r
298 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */\r
299 typedef uint32_t* CRYPTO_DDataPtr_TypeDef;\r
300 /** @endcond */\r
301 \r
302 /**\r
303  * CRYPTO data type used for data load functions. This data type is\r
304  * capable of storing a 512 bits value as used in the crypto QDATA\r
305  * registers\r
306  */\r
307 typedef uint32_t CRYPTO_QData_TypeDef[CRYPTO_QDATA_SIZE_IN_32BIT_WORDS];\r
308 \r
309 /**\r
310  * CRYPTO data type used for data load functions. This data type is\r
311  * capable of storing a 260 bits value as used by the @ref CRYPTO_DData0Write260\r
312  * function.\r
313  *\r
314  * Note that this data type is multiple of 32 bit words, so the\r
315  * actual storage used by this type is 32x9=288 bits.\r
316  */\r
317 typedef uint32_t CRYPTO_Data260_TypeDef[CRYPTO_DATA260_SIZE_IN_32BIT_WORDS];\r
318 \r
319 /**\r
320  * CRYPTO data type used for data load functions. This data type is\r
321  * capable of storing 256 bits as used in the crypto KEYBUF register.\r
322  */\r
323 typedef uint32_t CRYPTO_KeyBuf_TypeDef[CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS];\r
324 \r
325 /**\r
326  * CRYPTO Data registers. These register are used to load 128 bit values as\r
327  * input and output data for cryptographic and big integer arithmetic\r
328  * functions of the CRYPTO module.\r
329  */\r
330 typedef enum\r
331 {\r
332   cryptoRegDATA0    = (uint32_t) &CRYPTO->DATA0,    /**< 128 bit DATA0 register */\r
333   cryptoRegDATA1    = (uint32_t) &CRYPTO->DATA1,    /**< 128 bit DATA1 register */\r
334   cryptoRegDATA2    = (uint32_t) &CRYPTO->DATA2,    /**< 128 bit DATA2 register */\r
335   cryptoRegDATA3    = (uint32_t) &CRYPTO->DATA3,    /**< 128 bit DATA3 register */\r
336   cryptoRegDATA0XOR = (uint32_t) &CRYPTO->DATA0XOR, /**< 128 bit DATA0XOR register */\r
337 } CRYPTO_DataReg_TypeDef;\r
338 \r
339 /**\r
340  * CRYPTO DData (Double Data) registers. These registers are used to load\r
341  * 256 bit values as input and output data for cryptographic and big integer\r
342  * arithmetic functions of the CRYPTO module.\r
343  */\r
344 typedef enum\r
345 {\r
346   cryptoRegDDATA0    = (uint32_t) &CRYPTO->DDATA0,    /**< 256 bit DDATA0 register */\r
347   cryptoRegDDATA1    = (uint32_t) &CRYPTO->DDATA1,    /**< 256 bit DDATA1 register */\r
348   cryptoRegDDATA2    = (uint32_t) &CRYPTO->DDATA2,    /**< 256 bit DDATA2 register */\r
349   cryptoRegDDATA3    = (uint32_t) &CRYPTO->DDATA3,    /**< 256 bit DDATA3 register */\r
350   cryptoRegDDATA4    = (uint32_t) &CRYPTO->DDATA4,    /**< 256 bit DDATA4 register */\r
351   cryptoRegDDATA0BIG = (uint32_t) &CRYPTO->DDATA0BIG, /**< 256 bit DDATA0BIG register, big endian access to DDATA0 */\r
352 } CRYPTO_DDataReg_TypeDef;\r
353 \r
354 /**\r
355  * CRYPTO QData (Quad data) registers. These registers are used to load 512 bit\r
356  * values as input and output data for cryptographic and big integer arithmetic\r
357  * functions of the CRYPTO module.\r
358  */\r
359 typedef enum\r
360 {\r
361   cryptoRegQDATA0    = (uint32_t) &CRYPTO->QDATA0,    /**< 512 bit QDATA0 register */\r
362   cryptoRegQDATA1    = (uint32_t) &CRYPTO->QDATA1,    /**< 512 bit QDATA1 register */\r
363   cryptoRegQDATA1BIG = (uint32_t) &CRYPTO->QDATA1BIG, /**< 512 bit QDATA1BIG register, big-endian access to QDATA1 */\r
364 } CRYPTO_QDataReg_TypeDef;\r
365 \r
366 /** CRYPTO modulus types. */\r
367 typedef enum\r
368 {\r
369   cryptoModulusBin256        = CRYPTO_WAC_MODULUS_BIN256,       /**< Generic 256 bit modulus 2^256 */\r
370   cryptoModulusBin128        = CRYPTO_WAC_MODULUS_BIN128,       /**< Generic 128 bit modulus 2^128 */\r
371   cryptoModulusGcmBin128     = CRYPTO_WAC_MODULUS_GCMBIN128,    /**< GCM 128 bit modulus = 2^128 + 2^7 + 2^2 + 2 + 1 */\r
372   cryptoModulusEccB233       = CRYPTO_WAC_MODULUS_ECCBIN233P,   /**< ECC B233 prime modulus = 2^233 + 2^74 + 1   */\r
373   cryptoModulusEccB163       = CRYPTO_WAC_MODULUS_ECCBIN163P,   /**< ECC B163 prime modulus = 2^163 + 2^7 + 2^6 + 2^3 + 1 */\r
374   cryptoModulusEccP256       = CRYPTO_WAC_MODULUS_ECCPRIME256P, /**< ECC P256 prime modulus = 2^256 - 2^224 + 2^192 + 2^96 - 1 */\r
375   cryptoModulusEccP224       = CRYPTO_WAC_MODULUS_ECCPRIME224P, /**< ECC P224 prime modulus = 2^224 - 2^96 - 1 */\r
376   cryptoModulusEccP192       = CRYPTO_WAC_MODULUS_ECCPRIME192P, /**< ECC P192 prime modulus = 2^192 - 2^64 - 1 */\r
377   cryptoModulusEccB233Order  = CRYPTO_WAC_MODULUS_ECCBIN233N,   /**< ECC B233 order modulus   */\r
378   cryptoModulusEccB233KOrder = CRYPTO_WAC_MODULUS_ECCBIN233KN,  /**< ECC B233K order modulus */\r
379   cryptoModulusEccB163Order  = CRYPTO_WAC_MODULUS_ECCBIN163N,   /**< ECC B163 order modulus */\r
380   cryptoModulusEccB163KOrder = CRYPTO_WAC_MODULUS_ECCBIN163KN,  /**< ECC B163K order modulus */\r
381   cryptoModulusEccP256Order  = CRYPTO_WAC_MODULUS_ECCPRIME256N, /**< ECC P256 order modulus */\r
382   cryptoModulusEccP224Order  = CRYPTO_WAC_MODULUS_ECCPRIME224N, /**< ECC P224 order modulus */\r
383   cryptoModulusEccP192Order  = CRYPTO_WAC_MODULUS_ECCPRIME192N  /**< ECC P192 order modulus */\r
384 } CRYPTO_ModulusType_TypeDef;\r
385 \r
386 /** CRYPTO multiplication widths for wide arithmetic operations. */\r
387 typedef enum\r
388 {\r
389   cryptoMulOperand256Bits     = CRYPTO_WAC_MULWIDTH_MUL256, /**< 256 bits operands */\r
390   cryptoMulOperand128Bits     = CRYPTO_WAC_MULWIDTH_MUL128, /**< 128 bits operands */\r
391   cryptoMulOperandModulusBits = CRYPTO_WAC_MULWIDTH_MULMOD  /**< MUL operand width\r
392                                                                  is specified by the\r
393                                                                  modulus type.*/\r
394 } CRYPTO_MulOperandWidth_TypeDef;\r
395 \r
396 /** CRYPTO result widths for MUL operations. */\r
397 typedef enum\r
398 {\r
399   cryptoResult128Bits = CRYPTO_WAC_RESULTWIDTH_128BIT, /**< Multiplication result width is 128 bits*/\r
400   cryptoResult256Bits = CRYPTO_WAC_RESULTWIDTH_256BIT, /**< Multiplication result width is 256 bits*/\r
401   cryptoResult260Bits = CRYPTO_WAC_RESULTWIDTH_260BIT  /**< Multiplication result width is 260 bits*/\r
402 } CRYPTO_ResultWidth_TypeDef;\r
403 \r
404 /** CRYPTO result widths for MUL operations. */\r
405 typedef enum\r
406 {\r
407   cryptoInc1byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH1, /**< inc width is 1 byte*/\r
408   cryptoInc2byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH2, /**< inc width is 2 byte*/\r
409   cryptoInc3byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH3, /**< inc width is 3 byte*/\r
410   cryptoInc4byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH4  /**< inc width is 4 byte*/\r
411 } CRYPTO_IncWidth_TypeDef;\r
412 \r
413 /** CRYPTO key width. */\r
414 typedef enum\r
415 {\r
416   cryptoKey128Bits = 8,     /**< Key width is 128 bits*/\r
417   cryptoKey256Bits = 16,    /**< Key width is 256 bits*/\r
418 } CRYPTO_KeyWidth_TypeDef;\r
419 \r
420 /**\r
421  * The max number of crypto instructions in an instruction sequence\r
422  */\r
423 #define CRYPTO_MAX_SEQUENCE_INSTRUCTIONS (20)\r
424 \r
425 /**\r
426  * Instruction sequence type.\r
427  * The user should fill in the desired operations from step1, then step2 etc.\r
428  * The CRYPTO_CMD_INSTR_END marks the end of the sequence.\r
429  * Bit fields are used to format the memory layout of the struct equal to the\r
430  * sequence registers in the CRYPTO module.\r
431  */\r
432 typedef uint8_t CRYPTO_InstructionSequence_TypeDef[CRYPTO_MAX_SEQUENCE_INSTRUCTIONS];\r
433 \r
434 /** Default instruction sequence consisting of all ENDs. The user can\r
435     initialize the instruction sequence with this default value set, and fill\r
436     in the desired operations from step 1. The first END instruction marks\r
437     the end of the sequence. */\r
438 #define CRYPTO_INSTRUCTIONSEQUENSE_DEFAULT                             \\r
439   {CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \\r
440    CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \\r
441    CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \\r
442    CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \\r
443    CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \\r
444    CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \\r
445    CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END}\r
446 \r
447 /** SHA-1 Digest type. */\r
448 typedef uint8_t CRYPTO_SHA1_Digest_TypeDef[CRYPTO_SHA1_DIGEST_SIZE_IN_BYTES];\r
449 \r
450 /** SHA-256 Digest type. */\r
451 typedef uint8_t CRYPTO_SHA256_Digest_TypeDef[CRYPTO_SHA256_DIGEST_SIZE_IN_BYTES];\r
452 \r
453 /**\r
454  * @brief\r
455  *   AES counter modification function pointer.\r
456  *\r
457  * @note\r
458  *   This is defined in order for backwards compatibility with EFM32 em_aes.h.\r
459  *   The CRYPTO implementation of Counter mode does not support counter update\r
460  *   callbacks.\r
461  *   \r
462  * @param[in]  ctr   Counter value to be modified.\r
463  */\r
464 typedef void (*CRYPTO_AES_CtrFuncPtr_TypeDef)(uint8_t * ctr);\r
465 \r
466 /*******************************************************************************\r
467  *****************************   PROTOTYPES   **********************************\r
468  ******************************************************************************/\r
469 \r
470 /***************************************************************************//**\r
471  * @brief\r
472  *   Set the modulus type used for wide arithmetic operations.\r
473  *\r
474  * @details\r
475  *   This function sets the modulus type to be used by the Modulus instructions\r
476  *   of the CRYPTO module.\r
477  *\r
478  * @param[in]  modType  Modulus type.\r
479  ******************************************************************************/\r
480 void CRYPTO_ModulusSet(CRYPTO_ModulusType_TypeDef modType);\r
481 \r
482 /***************************************************************************//**\r
483  * @brief\r
484  *   Set the number of bits in the operands of the MUL instruction.\r
485  *\r
486  * @details\r
487  *   This function sets the number of bits to be used in the operands of\r
488  *   the MUL instruction.\r
489  *\r
490  * @param[in]  mulOperandWidth  Multiplication width in bits.\r
491  ******************************************************************************/\r
492 __STATIC_INLINE void CRYPTO_MulOperandWidthSet(CRYPTO_MulOperandWidth_TypeDef mulOperandWidth)\r
493 {\r
494   uint32_t temp = CRYPTO->WAC & (~_CRYPTO_WAC_MULWIDTH_MASK);\r
495   CRYPTO->WAC = temp | mulOperandWidth;\r
496 }\r
497 \r
498 /***************************************************************************//**\r
499  * @brief\r
500  *   Set the width of the results of the non-modulus instructions.\r
501  *\r
502  * @details\r
503  *   This function sets the result width of the non-modulus instructions.\r
504  *\r
505  * @param[in]  resultWidth  Result width of non-modulus instructions.\r
506  ******************************************************************************/\r
507 __STATIC_INLINE void CRYPTO_ResultWidthSet(CRYPTO_ResultWidth_TypeDef resultWidth)\r
508 {\r
509   uint32_t temp = CRYPTO->WAC & (~_CRYPTO_WAC_RESULTWIDTH_MASK);\r
510   CRYPTO->WAC = temp | resultWidth;\r
511 }\r
512 \r
513 /***************************************************************************//**\r
514  * @brief\r
515  *   Set the width of the DATA1 increment instruction DATA1INC.\r
516  *\r
517  * @details\r
518  *   This function sets the width of the DATA1 increment instruction\r
519  *   @ref CRYPTO_CMD_INSTR_DATA1INC.\r
520  *\r
521  * @param[in]  incWidth  incrementation width.\r
522  ******************************************************************************/\r
523 __STATIC_INLINE void CRYPTO_IncWidthSet(CRYPTO_IncWidth_TypeDef incWidth)\r
524 {\r
525   uint32_t temp = CRYPTO->CTRL & (~_CRYPTO_CTRL_INCWIDTH_MASK);\r
526   CRYPTO->CTRL = temp | incWidth;\r
527 }\r
528 \r
529 /***************************************************************************//**\r
530  * @brief\r
531  *   Write a 128 bit value into a crypto register.\r
532  *\r
533  * @note\r
534  *   This function provide a low-level api for writing to the multi-word\r
535  *   registers in the crypto peripheral. Applications should prefer to use\r
536  *   @ref CRYPTO_DataWrite, @ref CRYPTO_DDataWrite or @ref CRYPTO_QDataWrite\r
537  *   for writing to the DATA, DDATA and QDATA registers.\r
538  *\r
539  * @param[in]  reg\r
540  *   Pointer to the crypto register.\r
541  *\r
542  * @param[in]  val\r
543  *   This is a pointer to 4 32 bit integers that contains the 128 bit value\r
544  *   which will be written to the crypto register.\r
545  ******************************************************************************/\r
546 __STATIC_INLINE void CRYPTO_BurstToCrypto(volatile uint32_t * reg, const uint32_t * val)\r
547 {\r
548   /* Load data from memory into local registers. */\r
549   register uint32_t v0 = val[0];\r
550   register uint32_t v1 = val[1];\r
551   register uint32_t v2 = val[2];\r
552   register uint32_t v3 = val[3];\r
553   /* Store data to CRYPTO */\r
554   *reg = v0;\r
555   *reg = v1;\r
556   *reg = v2;\r
557   *reg = v3;\r
558 }\r
559 \r
560 /***************************************************************************//**\r
561  * @brief\r
562  *   Read a 128 bit value from a crypto register.\r
563  *\r
564  * @note\r
565  *   This function provide a low-level api for reading one of the multi-word\r
566  *   registers in the crypto peripheral. Applications should prefer to use\r
567  *   @ref CRYPTO_DataRead, @ref CRYPTO_DDataRead or @ref CRYPTO_QDataRead\r
568  *   for reading the value of the DATA, DDATA and QDATA registers.\r
569  *\r
570  * @param[in]  reg\r
571  *   Pointer to the crypto register.\r
572  *\r
573  * @param[out]  val\r
574  *   This is a pointer to an array that is capable of holding 4 32 bit integers\r
575  *   that will be filled with the 128 bit value from the crypto register.\r
576  ******************************************************************************/\r
577 __STATIC_INLINE void CRYPTO_BurstFromCrypto(volatile uint32_t * reg, uint32_t * val)\r
578 {\r
579   /* Load data from CRYPTO into local registers. */\r
580   register uint32_t v0 = *reg;\r
581   register uint32_t v1 = *reg;\r
582   register uint32_t v2 = *reg;\r
583   register uint32_t v3 = *reg;\r
584   /* Store data to memory */\r
585   val[0] = v0;\r
586   val[1] = v1;\r
587   val[2] = v2;\r
588   val[3] = v3;\r
589 }\r
590 \r
591 /***************************************************************************//**\r
592  * @brief\r
593  *   Write 128 bits of data to a DATAX register in the CRYPTO module.\r
594  *\r
595  * @details\r
596  *   Write 128 bits of data to a DATAX register in the crypto module. The data\r
597  *   value is typically input to a big integer operation (see crypto\r
598  *   instructions).\r
599  *\r
600  * @param[in]  dataReg    The 128 bit DATA register.\r
601  * @param[in]  val        Value of the data to write to the DATA register.\r
602  ******************************************************************************/\r
603 __STATIC_INLINE void CRYPTO_DataWrite(CRYPTO_DataReg_TypeDef dataReg,\r
604                                       const CRYPTO_Data_TypeDef val)\r
605 {\r
606   CRYPTO_BurstToCrypto((volatile uint32_t *)dataReg, val);\r
607 }\r
608 \r
609 /***************************************************************************//**\r
610  * @brief\r
611  *   Read 128 bits of data from a DATAX register in the CRYPTO module.\r
612  *\r
613  * @details\r
614  *   Read 128 bits of data from a DATAX register in the crypto module. The data\r
615  *   value is typically output from a big integer operation (see crypto\r
616  *   instructions)\r
617  *\r
618  * @param[in]  dataReg   The 128 bit DATA register.\r
619  * @param[out] val       Location where to store the value in memory.\r
620  ******************************************************************************/\r
621 __STATIC_INLINE void CRYPTO_DataRead(CRYPTO_DataReg_TypeDef  dataReg,\r
622                                      CRYPTO_Data_TypeDef     val)\r
623 {\r
624   CRYPTO_BurstFromCrypto((volatile uint32_t *)dataReg, val);\r
625 }\r
626 \r
627 /***************************************************************************//**\r
628  * @brief\r
629  *   Write 256 bits of data to a DDATAX register in the CRYPTO module.\r
630  *\r
631  * @details\r
632  *   Write 256 bits of data into a DDATAX (Double Data) register in the crypto\r
633  *   module. The data value is typically input to a big integer operation (see\r
634  *   crypto instructions).\r
635  *\r
636  * @param[in]  ddataReg   The 256 bit DDATA register.\r
637  * @param[in]  val        Value of the data to write to the DDATA register.\r
638  ******************************************************************************/\r
639 __STATIC_INLINE void CRYPTO_DDataWrite(CRYPTO_DDataReg_TypeDef ddataReg,\r
640                                        const CRYPTO_DData_TypeDef val)\r
641 {\r
642   CRYPTO_BurstToCrypto((volatile uint32_t *)ddataReg, &val[0]);\r
643   CRYPTO_BurstToCrypto((volatile uint32_t *)ddataReg, &val[4]);\r
644 }\r
645 \r
646 /***************************************************************************//**\r
647  * @brief\r
648  *   Read 256 bits of data from a DDATAX register in the CRYPTO module.\r
649  *\r
650  * @details\r
651  *   Read 256 bits of data from a DDATAX (Double Data) register in the crypto\r
652  *   module. The data value is typically output from a big integer operation\r
653  *   (see crypto instructions).\r
654  *\r
655  * @param[in]  ddataReg   The 256 bit DDATA register.\r
656  * @param[out] val        Location where to store the value in memory.\r
657  ******************************************************************************/\r
658 __STATIC_INLINE void CRYPTO_DDataRead(CRYPTO_DDataReg_TypeDef ddataReg,\r
659                                       CRYPTO_DData_TypeDef    val)\r
660 {\r
661   CRYPTO_BurstFromCrypto((volatile uint32_t *)ddataReg, &val[0]);\r
662   CRYPTO_BurstFromCrypto((volatile uint32_t *)ddataReg, &val[4]);\r
663 }\r
664 \r
665 /***************************************************************************//**\r
666  * @brief\r
667  *   Write 512 bits of data to a QDATAX register in the CRYPTO module.\r
668  *\r
669  * @details\r
670  *   Write 512 bits of data into a QDATAX (Quad Data) register in the crypto module\r
671  *   The data value is typically input to a big integer operation (see crypto\r
672  *   instructions).\r
673  *\r
674  * @param[in]  qdataReg   The 512 bits QDATA register.\r
675  * @param[in]  val        Value of the data to write to the QDATA register.\r
676  ******************************************************************************/\r
677 __STATIC_INLINE void CRYPTO_QDataWrite(CRYPTO_QDataReg_TypeDef qdataReg,\r
678                                        CRYPTO_QData_TypeDef    val)\r
679 {\r
680   CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[0]);\r
681   CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[4]);\r
682   CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[8]);\r
683   CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[12]);\r
684 }\r
685 \r
686 /***************************************************************************//**\r
687  * @brief\r
688  *   Read 512 bits of data from a QDATAX register in the CRYPTO module.\r
689  *\r
690  * @details\r
691  * Read 512 bits of data from a QDATAX register in the crypto module. The data\r
692  * value is typically input to a big integer operation (see crypto\r
693  * instructions).\r
694  *\r
695  * @param[in]  qdataReg   The 512 bits QDATA register.\r
696  * @param[in]  val        Value of the data to write to the QDATA register.\r
697  ******************************************************************************/\r
698 __STATIC_INLINE void CRYPTO_QDataRead(CRYPTO_QDataReg_TypeDef qdataReg,\r
699                                       CRYPTO_QData_TypeDef    val)\r
700 {\r
701   CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[0]);\r
702   CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[4]);\r
703   CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[8]);\r
704   CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[12]);\r
705 }\r
706 \r
707 /***************************************************************************//**\r
708  * @brief\r
709  *   Set the key value to be used by the CRYPTO module.\r
710  *\r
711  * @details\r
712  *   Write 128 or 256 bit key to the KEYBUF register in the crypto module.\r
713  *\r
714  * @param[in]  val     Value of the data to write to the KEYBUF register.\r
715  * @param[in]  keyWidth Key width - 128 or 256 bits\r
716  ******************************************************************************/\r
717 __STATIC_INLINE void CRYPTO_KeyBufWrite(CRYPTO_KeyBuf_TypeDef    val,\r
718                                         CRYPTO_KeyWidth_TypeDef  keyWidth)\r
719 {\r
720   if (keyWidth == cryptoKey256Bits)\r
721   {\r
722     /* Set AES-256 mode */\r
723     BUS_RegBitWrite(&CRYPTO->CTRL, _CRYPTO_CTRL_AES_SHIFT, _CRYPTO_CTRL_AES_AES256);\r
724     /* Load key in KEYBUF register (= DDATA4) */\r
725     CRYPTO_DDataWrite(cryptoRegDDATA4, (uint32_t *)val);\r
726   }\r
727   else\r
728   {\r
729     /* Set AES-128 mode */\r
730     BUS_RegBitWrite(&CRYPTO->CTRL, _CRYPTO_CTRL_AES_SHIFT, _CRYPTO_CTRL_AES_AES128);\r
731     CRYPTO_BurstToCrypto(&CRYPTO->KEYBUF, &val[0]);\r
732   }\r
733 }\r
734 \r
735 void CRYPTO_KeyRead(CRYPTO_KeyBuf_TypeDef   val,\r
736                     CRYPTO_KeyWidth_TypeDef keyWidth);\r
737 \r
738 /***************************************************************************//**\r
739  * @brief\r
740  *   Quick write 128 bit key to the CRYPTO module.\r
741  *\r
742  * @details\r
743  *   Quick write 128 bit key to the KEYBUF register in the CRYPTO module.\r
744  *\r
745  *  @param[in]  val    Value of the data to write to the KEYBUF register.\r
746  ******************************************************************************/\r
747 __STATIC_INLINE void CRYPTO_KeyBuf128Write(const uint32_t * val)\r
748 {\r
749   CRYPTO_BurstToCrypto(&CRYPTO->KEYBUF, val);\r
750 }\r
751 \r
752 /***************************************************************************//**\r
753  * @brief\r
754  *   Quick read access of the Carry bit from arithmetic operations.\r
755  *\r
756  * @details\r
757  *   This function reads the carry bit of the CRYPTO ALU.\r
758  *\r
759  * @return\r
760  *   Returns 'true' if carry is 1, and 'false' if carry is 0.\r
761  ******************************************************************************/\r
762 __STATIC_INLINE bool CRYPTO_CarryIsSet(void)\r
763 {\r
764   return (CRYPTO->DSTATUS & _CRYPTO_DSTATUS_CARRY_MASK)\r
765     >> _CRYPTO_DSTATUS_CARRY_SHIFT;\r
766 }\r
767 \r
768 /***************************************************************************//**\r
769  * @brief\r
770  *   Quick read access of the 4 LSbits of the DDATA0 register.\r
771  *\r
772  * @details\r
773  *   This function quickly retrieves the 4 least significant bits of the\r
774  *   DDATA0 register via the DDATA0LSBS bit field in the DSTATUS register.\r
775  *\r
776  * @return\r
777  *   Returns the 4 LSbits of DDATA0.\r
778  ******************************************************************************/\r
779 __STATIC_INLINE uint8_t CRYPTO_DData0_4LSBitsRead(void)\r
780 {\r
781   return (CRYPTO->DSTATUS & _CRYPTO_DSTATUS_DDATA0LSBS_MASK)\r
782     >> _CRYPTO_DSTATUS_DDATA0LSBS_SHIFT;\r
783 }\r
784 \r
785 /***************************************************************************//**\r
786  * @brief\r
787  *   Read 260 bits from the DDATA0 register.\r
788  *\r
789  * @details\r
790  *   This functions reads 260 bits from the DDATA0 register in the CRYPTO\r
791  *   module. The data value is typically output from a big integer operation\r
792  *   (see crypto instructions) when the result width is set to 260 bits by\r
793  *   calling @ref CRYPTO_ResultWidthSet(cryptoResult260Bits);\r
794  *\r
795  * @param[out] val        Location where to store the value in memory.\r
796  ******************************************************************************/\r
797 __STATIC_INLINE void CRYPTO_DData0Read260(CRYPTO_Data260_TypeDef val)\r
798 {    \r
799   CRYPTO_DDataRead(cryptoRegDDATA0, val);\r
800   val[8] = (CRYPTO->DSTATUS & _CRYPTO_DSTATUS_DDATA0MSBS_MASK)\r
801         >> _CRYPTO_DSTATUS_DDATA0MSBS_SHIFT;\r
802 }\r
803 \r
804 /***************************************************************************//**\r
805  * @brief\r
806  *   Write 260 bits to the DDATA0 register.\r
807  *\r
808  * @details\r
809  *   This functions writes 260 bits to the DDATA0 register in the CRYPTO\r
810  *   module. The data value is typically input to a big integer operation\r
811  *   (see crypto instructions) when the result width is set to 260 bits by\r
812  *   calling @ref CRYPTO_ResultWidthSet(cryptoResult260Bits);\r
813  *\r
814  * @param[out] val        Location where of the value in memory.\r
815  ******************************************************************************/\r
816 __STATIC_INLINE void CRYPTO_DData0Write260(const CRYPTO_Data260_TypeDef val)\r
817 {\r
818   CRYPTO_DDataWrite(cryptoRegDDATA0, val);\r
819   CRYPTO->DDATA0BYTE32 = val[8] & _CRYPTO_DDATA0BYTE32_DDATA0BYTE32_MASK;\r
820 }\r
821 \r
822 /***************************************************************************//**\r
823  * @brief\r
824  *   Quick read the MSbit of the DDATA1 register.\r
825  *\r
826  * @details\r
827  *   This function reads the most significant bit (bit 255) of the DDATA1\r
828  *   register via the DDATA1MSB bit field in the DSTATUS register. This can\r
829  *   be used to quickly check the signedness of a big integer resident in the\r
830  *   CRYPTO module.\r
831  *\r
832  * @return\r
833  *   Returns 'true' if MSbit is 1, and 'false' if MSbit is 0.\r
834  ******************************************************************************/\r
835 __STATIC_INLINE bool CRYPTO_DData1_MSBitRead(void)\r
836 {\r
837   return (CRYPTO->DSTATUS & _CRYPTO_DSTATUS_DDATA1MSB_MASK)\r
838     >> _CRYPTO_DSTATUS_DDATA1MSB_SHIFT;\r
839 }\r
840 \r
841 /***************************************************************************//**\r
842  * @brief\r
843  *   Load a sequence of instructions to be executed on the current values in\r
844  *   the data registers.\r
845  *\r
846  * @details\r
847  *   This function loads a sequence of instructions to the crypto module. The\r
848  *   instructions will be executed when the CRYPTO_InstructionSequenceExecute\r
849  *   function is called. The first END marks the end of the sequence.\r
850  *\r
851  * @param[in]  instructionSequence  Instruction sequence to load.\r
852  ******************************************************************************/\r
853 __STATIC_INLINE void CRYPTO_InstructionSequenceLoad(const CRYPTO_InstructionSequence_TypeDef instructionSequence)\r
854 {\r
855   const uint32_t * pas = (const uint32_t *) instructionSequence;\r
856 \r
857   CRYPTO->SEQ0 = pas[0];\r
858   CRYPTO->SEQ1 = pas[1];\r
859   CRYPTO->SEQ2 = pas[2];\r
860   CRYPTO->SEQ3 = pas[3];\r
861   CRYPTO->SEQ4 = pas[4];\r
862 }\r
863 \r
864 /***************************************************************************//**\r
865  * @brief\r
866  *   Execute the current programmed instruction sequence.\r
867  *\r
868  * @details\r
869  *   This function starts the execution of the current instruction sequence\r
870  *   in the CRYPTO module.\r
871  ******************************************************************************/\r
872 __STATIC_INLINE void CRYPTO_InstructionSequenceExecute(void)\r
873 {\r
874   /* Start the command sequence. */\r
875   CRYPTO->CMD = CRYPTO_CMD_SEQSTART;\r
876 }\r
877 \r
878 /***************************************************************************//**\r
879  * @brief\r
880  *   Check whether the execution of an instruction sequence has completed.\r
881  *\r
882  * @details\r
883  *   This function checks whether an instruction sequence has completed.\r
884  *\r
885  * @return\r
886  *   Returns 'true' if the instruction sequence is done, and 'false' if not.\r
887  ******************************************************************************/\r
888 __STATIC_INLINE bool CRYPTO_InstructionSequenceDone(void)\r
889 {\r
890   /* Return true if operation has completed. */\r
891   return !(CRYPTO->STATUS\r
892            & (CRYPTO_STATUS_INSTRRUNNING | CRYPTO_STATUS_SEQRUNNING));\r
893 }\r
894 \r
895 /***************************************************************************//**\r
896  * @brief\r
897  *   Wait for completion of the current sequence of instructions.\r
898  *\r
899  * @details\r
900  *   This function "busy"-waits until the execution of the ongoing instruction\r
901  *   sequence has completed.\r
902  ******************************************************************************/\r
903 __STATIC_INLINE void CRYPTO_InstructionSequenceWait(void)\r
904 {\r
905   while (!CRYPTO_InstructionSequenceDone())\r
906     ;\r
907 }\r
908 \r
909 /***************************************************************************//**\r
910  * @brief\r
911  *   Wait for completion of the current command.\r
912  *\r
913  * @details\r
914  *   This function "busy"-waits until the execution of the ongoing instruction\r
915  *   has completed.\r
916  ******************************************************************************/\r
917 __STATIC_INLINE void CRYPTO_InstructionWait(void)\r
918 {\r
919   /* Wait for completion */\r
920   while (!(CRYPTO->IF & CRYPTO_IF_INSTRDONE))\r
921     ;\r
922   CRYPTO->IFC = CRYPTO_IF_INSTRDONE;\r
923 }\r
924 \r
925 void CRYPTO_SHA_1(const uint8_t *              msg,\r
926                   uint64_t                     msgLen,\r
927                   CRYPTO_SHA1_Digest_TypeDef   digest);\r
928 \r
929 void CRYPTO_SHA_256(const uint8_t *              msg,\r
930                     uint64_t                     msgLen,\r
931                     CRYPTO_SHA256_Digest_TypeDef digest);\r
932 \r
933 void CRYPTO_Mul(uint32_t * A, int aSize,\r
934                 uint32_t * B, int bSize,\r
935                 uint32_t * R, int rSize);\r
936 \r
937 void CRYPTO_AES_CBC128(uint8_t * out,\r
938                        const uint8_t * in,\r
939                        unsigned int len,\r
940                        const uint8_t * key,\r
941                        const uint8_t * iv,\r
942                        bool encrypt);\r
943 \r
944 void CRYPTO_AES_CBC256(uint8_t * out,\r
945                        const uint8_t * in,\r
946                        unsigned int len,\r
947                        const uint8_t * key,\r
948                        const uint8_t * iv,\r
949                        bool encrypt);\r
950 \r
951 void CRYPTO_AES_CFB128(uint8_t * out,\r
952                        const uint8_t * in,\r
953                        unsigned int len,\r
954                        const uint8_t * key,\r
955                        const uint8_t * iv,\r
956                        bool encrypt);\r
957 \r
958 void CRYPTO_AES_CFB256(uint8_t * out,\r
959                        const uint8_t * in,\r
960                        unsigned int len,\r
961                        const uint8_t * key,\r
962                        const uint8_t * iv,\r
963                        bool encrypt);\r
964 \r
965 void CRYPTO_AES_CTR128(uint8_t * out,\r
966                        const uint8_t * in,\r
967                        unsigned int len,\r
968                        const uint8_t * key,\r
969                        uint8_t * ctr,\r
970                        CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc);\r
971 \r
972 void CRYPTO_AES_CTR256(uint8_t * out,\r
973                        const uint8_t * in,\r
974                        unsigned int len,\r
975                        const uint8_t * key,\r
976                        uint8_t * ctr,\r
977                        CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc);\r
978 \r
979 void CRYPTO_AES_CTRUpdate32Bit(uint8_t * ctr);\r
980 void CRYPTO_AES_DecryptKey128(uint8_t * out, const uint8_t * in);\r
981 void CRYPTO_AES_DecryptKey256(uint8_t * out, const uint8_t * in);\r
982 \r
983 void CRYPTO_AES_ECB128(uint8_t * out,\r
984                        const uint8_t * in,\r
985                        unsigned int len,\r
986                        const uint8_t * key,\r
987                        bool encrypt);\r
988 \r
989 void CRYPTO_AES_ECB256(uint8_t * out,\r
990                        const uint8_t * in,\r
991                        unsigned int len,\r
992                        const uint8_t * key,\r
993                        bool encrypt);\r
994 \r
995 void CRYPTO_AES_OFB128(uint8_t * out,\r
996                        const uint8_t * in,\r
997                        unsigned int len,\r
998                        const uint8_t * key,\r
999                        const uint8_t * iv);\r
1000 \r
1001 void CRYPTO_AES_OFB256(uint8_t * out,\r
1002                        const uint8_t * in,\r
1003                        unsigned int len,\r
1004                        const uint8_t * key,\r
1005                        const uint8_t * iv);\r
1006 \r
1007 /***************************************************************************//**\r
1008  * @brief\r
1009  *   Clear one or more pending CRYPTO interrupts.\r
1010  *\r
1011  * @param[in] flags\r
1012  *   Pending CRYPTO interrupt source to clear. Use a bitwise logic OR combination of\r
1013  *   valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).\r
1014  ******************************************************************************/\r
1015 __STATIC_INLINE void CRYPTO_IntClear(uint32_t flags)\r
1016 {\r
1017   CRYPTO->IFC = flags;\r
1018 }\r
1019 \r
1020 /***************************************************************************//**\r
1021  * @brief\r
1022  *   Disable one or more CRYPTO interrupts.\r
1023  *\r
1024  * @param[in] flags\r
1025  *   CRYPTO interrupt sources to disable. Use a bitwise logic OR combination of\r
1026  *   valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).\r
1027  ******************************************************************************/\r
1028 __STATIC_INLINE void CRYPTO_IntDisable(uint32_t flags)\r
1029 {\r
1030   CRYPTO->IEN &= ~(flags);\r
1031 }\r
1032 \r
1033 /***************************************************************************//**\r
1034  * @brief\r
1035  *   Enable one or more CRYPTO interrupts.\r
1036  *\r
1037  * @note\r
1038  *   Depending on the use, a pending interrupt may already be set prior to\r
1039  *   enabling the interrupt. Consider using CRYPTO_IntClear() prior to enabling\r
1040  *   if such a pending interrupt should be ignored.\r
1041  *\r
1042  * @param[in] flags\r
1043  *   CRYPTO interrupt sources to enable. Use a bitwise logic OR combination of\r
1044  *   valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).\r
1045  ******************************************************************************/\r
1046 __STATIC_INLINE void CRYPTO_IntEnable(uint32_t flags)\r
1047 {\r
1048   CRYPTO->IEN |= flags;\r
1049 }\r
1050 \r
1051 /***************************************************************************//**\r
1052  * @brief\r
1053  *   Get pending CRYPTO interrupt flags.\r
1054  *\r
1055  * @note\r
1056  *   The event bits are not cleared by the use of this function.\r
1057  *\r
1058  * @return\r
1059  *   CRYPTO interrupt sources pending. A bitwise logic OR combination of valid\r
1060  *   interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).\r
1061  ******************************************************************************/\r
1062 __STATIC_INLINE uint32_t CRYPTO_IntGet(void)\r
1063 {\r
1064   return CRYPTO->IF;\r
1065 }\r
1066 \r
1067 /***************************************************************************//**\r
1068  * @brief\r
1069  *   Get enabled and pending CRYPTO interrupt flags.\r
1070  *   Useful for handling more interrupt sources in the same interrupt handler.\r
1071  *\r
1072  * @note\r
1073  *   Interrupt flags are not cleared by the use of this function.\r
1074  *\r
1075  * @return\r
1076  *   Pending and enabled CRYPTO interrupt sources\r
1077  *   The return value is the bitwise AND of\r
1078  *   - the enabled interrupt sources in CRYPTO_IEN and\r
1079  *   - the pending interrupt flags CRYPTO_IF\r
1080  ******************************************************************************/\r
1081 __STATIC_INLINE uint32_t CRYPTO_IntGetEnabled(void)\r
1082 {\r
1083   return CRYPTO->IF & CRYPTO->IEN;\r
1084 }\r
1085 \r
1086 /***************************************************************************//**\r
1087  * @brief\r
1088  *   Set one or more pending CRYPTO interrupts from SW.\r
1089  *\r
1090  * @param[in] flags\r
1091  *   CRYPTO interrupt sources to set to pending. Use a bitwise logic OR combination\r
1092  *   of valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).\r
1093  ******************************************************************************/\r
1094 __STATIC_INLINE void CRYPTO_IntSet(uint32_t flags)\r
1095 {\r
1096   CRYPTO->IFS = flags;\r
1097 }\r
1098 \r
1099 /*******************************************************************************\r
1100  *****    Static inline wrappers for CRYPTO AES functions in order to      *****\r
1101  *****    preserve backwards compatibility with AES module API functions.  *****\r
1102  ******************************************************************************/\r
1103 \r
1104 /***************************************************************************//**\r
1105  * @brief\r
1106  *   AES Cipher-block chaining (CBC) cipher mode encryption/decryption,\r
1107  *   128 bit key.\r
1108  *\r
1109  * @deprecated\r
1110  *   This function is present to preserve backwards compatibility. Use\r
1111  *   @ref CRYPTO_AES_CBC128 instead.\r
1112  ******************************************************************************/\r
1113 __STATIC_INLINE void AES_CBC128(uint8_t * out,\r
1114                        const uint8_t * in,\r
1115                        unsigned int len,\r
1116                        const uint8_t * key,\r
1117                        const uint8_t * iv,\r
1118                        bool encrypt)\r
1119 {\r
1120   CRYPTO_AES_CBC128(out, in, len, key, iv, encrypt);\r
1121 }\r
1122 \r
1123 /***************************************************************************//**\r
1124  * @brief\r
1125  *   AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 256 bit\r
1126  *   key.\r
1127  *\r
1128  * @deprecated\r
1129  *   This function is present to preserve backwards compatibility. Use\r
1130  *   @ref CRYPTO_AES_CBC256 instead.\r
1131  ******************************************************************************/\r
1132 __STATIC_INLINE void AES_CBC256(uint8_t * out,\r
1133                        const uint8_t * in,\r
1134                        unsigned int len,\r
1135                        const uint8_t * key,\r
1136                        const uint8_t * iv,\r
1137                        bool encrypt)\r
1138 {\r
1139   CRYPTO_AES_CBC256(out, in, len, key, iv, encrypt);\r
1140 }\r
1141 \r
1142 /***************************************************************************//**\r
1143  * @brief\r
1144  *   AES Cipher feedback (CFB) cipher mode encryption/decryption, 128 bit key.\r
1145  *\r
1146  * @deprecated\r
1147  *   This function is present to preserve backwards compatibility. Use\r
1148  *   @ref CRYPTO_AES_CFB128 instead.\r
1149  ******************************************************************************/\r
1150 __STATIC_INLINE void AES_CFB128(uint8_t * out,\r
1151                        const uint8_t * in,\r
1152                        unsigned int len,\r
1153                        const uint8_t * key,\r
1154                        const uint8_t * iv,\r
1155                        bool encrypt)\r
1156 {\r
1157   CRYPTO_AES_CFB128(out, in, len, key, iv, encrypt);\r
1158 }\r
1159 \r
1160 /***************************************************************************//**\r
1161  * @brief\r
1162  *   AES Cipher feedback (CFB) cipher mode encryption/decryption, 256 bit key.\r
1163  *\r
1164  * @deprecated\r
1165  *   This function is present to preserve backwards compatibility. Use\r
1166  *   @ref CRYPTO_AES_CFB256 instead.\r
1167  ******************************************************************************/\r
1168 __STATIC_INLINE void AES_CFB256(uint8_t * out,\r
1169                        const uint8_t * in,\r
1170                        unsigned int len,\r
1171                        const uint8_t * key,\r
1172                        const uint8_t * iv,\r
1173                        bool encrypt)\r
1174 {\r
1175   CRYPTO_AES_CFB256(out, in, len, key, iv, encrypt);\r
1176 }\r
1177 \r
1178 /***************************************************************************//**\r
1179  * @brief\r
1180  *   AES Counter (CTR) cipher mode encryption/decryption, 128 bit key.\r
1181  *\r
1182  * @deprecated\r
1183  *   This function is present to preserve backwards compatibility. Use\r
1184  *   @ref CRYPTO_AES_CTR128 instead.\r
1185  ******************************************************************************/\r
1186 __STATIC_INLINE void AES_CTR128(uint8_t * out,\r
1187                        const uint8_t * in,\r
1188                        unsigned int len,\r
1189                        const uint8_t * key,\r
1190                        uint8_t * ctr,\r
1191                        CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc)\r
1192 {\r
1193   CRYPTO_AES_CTR128(out, in, len, key, ctr, ctrFunc);\r
1194 }\r
1195 \r
1196 /***************************************************************************//**\r
1197  * @brief\r
1198  *   AES Counter (CTR) cipher mode encryption/decryption, 256 bit key.\r
1199  *\r
1200  * @deprecated\r
1201  *   This function is present to preserve backwards compatibility. Use\r
1202  *   @ref CRYPTO_AES_CTR256 instead.\r
1203  ******************************************************************************/\r
1204 __STATIC_INLINE void AES_CTR256(uint8_t * out,\r
1205                        const uint8_t * in,\r
1206                        unsigned int len,\r
1207                        const uint8_t * key,\r
1208                        uint8_t * ctr,\r
1209                        CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc)\r
1210 {\r
1211   CRYPTO_AES_CTR256(out, in, len, key, ctr, ctrFunc);\r
1212 }\r
1213 \r
1214 /***************************************************************************//**\r
1215  * @brief\r
1216  *   Update last 32 bits of 128 bit counter, by incrementing with 1.\r
1217  *\r
1218  * @deprecated\r
1219  *   This function is present to preserve backwards compatibility. Use\r
1220  *   @ref CRYPTO_AES_CTRUpdate32Bit instead.\r
1221  ******************************************************************************/\r
1222 __STATIC_INLINE void AES_CTRUpdate32Bit(uint8_t * ctr)\r
1223 {\r
1224   CRYPTO_AES_CTRUpdate32Bit(ctr);\r
1225 }\r
1226 \r
1227 /***************************************************************************//**\r
1228  * @brief\r
1229  *   Generate 128 bit AES decryption key from 128 bit encryption key. The\r
1230  *   decryption key is used for some cipher modes when decrypting.\r
1231  *\r
1232  * @deprecated\r
1233  *   This function is present to preserve backwards compatibility. Use\r
1234  *   @ref CRYPTO_AES_DecryptKey128 instead.\r
1235  ******************************************************************************/\r
1236 __STATIC_INLINE void AES_DecryptKey128(uint8_t * out, const uint8_t * in)\r
1237 {\r
1238   CRYPTO_AES_DecryptKey128(out, in);\r
1239 }\r
1240 \r
1241 /***************************************************************************//**\r
1242  * @brief\r
1243  *   Generate 256 bit AES decryption key from 256 bit encryption key. The\r
1244  *   decryption key is used for some cipher modes when decrypting.\r
1245  *\r
1246  * @deprecated\r
1247  *   This function is present to preserve backwards compatibility. Use\r
1248  *   @ref CRYPTO_AES_DecryptKey256 instead.\r
1249  ******************************************************************************/\r
1250 __STATIC_INLINE void AES_DecryptKey256(uint8_t * out, const uint8_t * in)\r
1251 {\r
1252   CRYPTO_AES_DecryptKey256(out, in);\r
1253 }\r
1254 \r
1255 /***************************************************************************//**\r
1256  * @brief\r
1257  *   AES Electronic Codebook (ECB) cipher mode encryption/decryption,\r
1258  *   128 bit key.\r
1259  *\r
1260  * @deprecated\r
1261  *   This function is present to preserve backwards compatibility. Use\r
1262  *   @ref CRYPTO_AES_ECB128 instead.\r
1263  ******************************************************************************/\r
1264 __STATIC_INLINE void AES_ECB128(uint8_t * out,\r
1265                                 const uint8_t * in,\r
1266                                 unsigned int len,\r
1267                                 const uint8_t * key,\r
1268                                 bool encrypt)\r
1269 {\r
1270   CRYPTO_AES_ECB128(out, in, len, key, encrypt);\r
1271 }\r
1272 \r
1273 /***************************************************************************//**\r
1274  * @brief\r
1275  *   AES Electronic Codebook (ECB) cipher mode encryption/decryption,\r
1276  *   256 bit key.\r
1277  *\r
1278  * @deprecated\r
1279  *   This function is present to preserve backwards compatibility. Use\r
1280  *   @ref CRYPTO_AES_ECB256 instead.\r
1281  ******************************************************************************/\r
1282 __STATIC_INLINE void AES_ECB256(uint8_t * out,\r
1283                                 const uint8_t * in,\r
1284                                 unsigned int len,\r
1285                                 const uint8_t * key,\r
1286                                 bool encrypt)\r
1287 {\r
1288   CRYPTO_AES_ECB256(out, in, len, key, encrypt);\r
1289 }\r
1290 \r
1291 /***************************************************************************//**\r
1292  * @brief\r
1293  *   AES Output feedback (OFB) cipher mode encryption/decryption, 128 bit key.\r
1294  *\r
1295  * @deprecated\r
1296  *   This function is present to preserve backwards compatibility. Use\r
1297  *   @ref CRYPTO_AES_OFB128 instead.\r
1298  ******************************************************************************/\r
1299 __STATIC_INLINE void AES_OFB128(uint8_t * out,\r
1300                                 const uint8_t * in,\r
1301                                 unsigned int len,\r
1302                                 const uint8_t * key,\r
1303                                 const uint8_t * iv)\r
1304 {\r
1305   CRYPTO_AES_OFB128(out, in, len, key, iv);\r
1306 }\r
1307 \r
1308 /***************************************************************************//**\r
1309  * @brief\r
1310  *   AES Output feedback (OFB) cipher mode encryption/decryption, 256 bit key.\r
1311  *\r
1312  * @deprecated\r
1313  *   This function is present to preserve backwards compatibility. Use\r
1314  *   @ref CRYPTO_AES_OFB256 instead.\r
1315  ******************************************************************************/\r
1316 __STATIC_INLINE void AES_OFB256(uint8_t * out,\r
1317                                 const uint8_t * in,\r
1318                                 unsigned int len,\r
1319                                 const uint8_t * key,\r
1320                                 const uint8_t * iv)\r
1321 {\r
1322   CRYPTO_AES_OFB256(out, in, len, key, iv);\r
1323 }\r
1324 \r
1325 #ifdef __cplusplus\r
1326 }\r
1327 #endif\r
1328 \r
1329 /** @} (end addtogroup CRYPTO) */\r
1330 /** @} (end addtogroup EM_Library) */\r
1331 \r
1332 #endif /* defined(CRYPTO_COUNT) && (CRYPTO_COUNT > 0) */\r
1333 \r
1334 #endif /* __SILICON_LABS_EM_CRYPTO_H__ */\r