EFM32 Gecko Software Documentation  efm32g-doc-5.1.2
em_crypto.h
Go to the documentation of this file.
1 /***************************************************************************/
32 #ifndef EM_CRYPTO_H
33 #define EM_CRYPTO_H
34 
35 #include "em_device.h"
36 
37 #if defined(CRYPTO_COUNT) && (CRYPTO_COUNT > 0)
38 
39 #include "em_bus.h"
40 #include <stdbool.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /***************************************************************************/
51 /***************************************************************************/
190  /*******************************************************************************
191  ****************************** DEFINES ***********************************
192  ******************************************************************************/
193 
196 #define CRYPTO_DATA_SIZE_IN_BITS (128)
197 #define CRYPTO_DATA_SIZE_IN_BYTES (CRYPTO_DATA_SIZE_IN_BITS/8)
198 #define CRYPTO_DATA_SIZE_IN_32BIT_WORDS (CRYPTO_DATA_SIZE_IN_BYTES/sizeof(uint32_t))
199 
200 #define CRYPTO_KEYBUF_SIZE_IN_BITS (256)
201 #define CRYPTO_KEYBUF_SIZE_IN_BYTES (CRYPTO_DDATA_SIZE_IN_BITS/8)
202 #define CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS (CRYPTO_DDATA_SIZE_IN_BYTES/sizeof(uint32_t))
203 
204 #define CRYPTO_DDATA_SIZE_IN_BITS (256)
205 #define CRYPTO_DDATA_SIZE_IN_BYTES (CRYPTO_DDATA_SIZE_IN_BITS/8)
206 #define CRYPTO_DDATA_SIZE_IN_32BIT_WORDS (CRYPTO_DDATA_SIZE_IN_BYTES/sizeof(uint32_t))
207 
208 #define CRYPTO_QDATA_SIZE_IN_BITS (512)
209 #define CRYPTO_QDATA_SIZE_IN_BYTES (CRYPTO_QDATA_SIZE_IN_BITS/8)
210 #define CRYPTO_QDATA_SIZE_IN_32BIT_WORDS (CRYPTO_QDATA_SIZE_IN_BYTES/sizeof(uint32_t))
211 
212 #define CRYPTO_DATA260_SIZE_IN_32BIT_WORDS (9)
213 
215 #define CRYPTO_SHA1_DIGEST_SIZE_IN_BITS (160)
216 #define CRYPTO_SHA1_DIGEST_SIZE_IN_BYTES (CRYPTO_SHA1_DIGEST_SIZE_IN_BITS/8)
217 
219 #define CRYPTO_SHA256_DIGEST_SIZE_IN_BITS (256)
220 #define CRYPTO_SHA256_DIGEST_SIZE_IN_BYTES (CRYPTO_SHA256_DIGEST_SIZE_IN_BITS/8)
221 
225 #define CRYPTO_DDATA0_260_BITS_READ(crypto, bigint260) CRYPTO_DData0Read260(crypto, bigint260)
226 #define CRYPTO_DDATA0_260_BITS_WRITE(crypto, bigint260) CRYPTO_DData0Write260(crypto, bigint260)
227 
235 #define CRYPTO_SEQ_LOAD_1(crypto, a1) { \
236  crypto->SEQ0 = a1 | (CRYPTO_CMD_INSTR_END<<8);}
237 #define CRYPTO_SEQ_LOAD_2(crypto, a1, a2) { \
238  crypto->SEQ0 = a1 | (a2<<8) | (CRYPTO_CMD_INSTR_END<<16);}
239 #define CRYPTO_SEQ_LOAD_3(crypto, a1, a2, a3) { \
240  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (CRYPTO_CMD_INSTR_END<<24);}
241 #define CRYPTO_SEQ_LOAD_4(crypto, a1, a2, a3, a4) { \
242  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
243  crypto->SEQ1 = CRYPTO_CMD_INSTR_END;}
244 #define CRYPTO_SEQ_LOAD_5(crypto, a1, a2, a3, a4, a5) { \
245  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
246  crypto->SEQ1 = a5 | (CRYPTO_CMD_INSTR_END<<8);}
247 #define CRYPTO_SEQ_LOAD_6(crypto, a1, a2, a3, a4, a5, a6) { \
248  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
249  crypto->SEQ1 = a5 | (a6<<8) | (CRYPTO_CMD_INSTR_END<<16);}
250 #define CRYPTO_SEQ_LOAD_7(crypto, a1, a2, a3, a4, a5, a6, a7) { \
251  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
252  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (CRYPTO_CMD_INSTR_END<<24);}
253 #define CRYPTO_SEQ_LOAD_8(crypto, a1, a2, a3, a4, a5, a6, a7, a8) { \
254  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
255  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
256  crypto->SEQ2 = CRYPTO_CMD_INSTR_END;}
257 #define CRYPTO_SEQ_LOAD_9(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9) { \
258  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
259  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
260  crypto->SEQ2 = a9 | (CRYPTO_CMD_INSTR_END<<8);}
261 #define CRYPTO_SEQ_LOAD_10(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { \
262  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
263  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
264  crypto->SEQ2 = a9 | (a10<<8) | (CRYPTO_CMD_INSTR_END<<16);}
265 #define CRYPTO_SEQ_LOAD_11(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { \
266  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
267  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
268  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (CRYPTO_CMD_INSTR_END<<24);}
269 #define CRYPTO_SEQ_LOAD_12(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { \
270  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
271  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
272  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
273  crypto->SEQ3 = CRYPTO_CMD_INSTR_END;}
274 #define CRYPTO_SEQ_LOAD_13(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) { \
275  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
276  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
277  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
278  crypto->SEQ3 = a13 | (CRYPTO_CMD_INSTR_END<<8);}
279 #define CRYPTO_SEQ_LOAD_14(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) { \
280  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
281  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
282  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
283  crypto->SEQ3 = a13 | (a14<<8) | (CRYPTO_CMD_INSTR_END<<16);}
284 #define CRYPTO_SEQ_LOAD_15(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) { \
285  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
286  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
287  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
288  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (CRYPTO_CMD_INSTR_END<<24);}
289 #define CRYPTO_SEQ_LOAD_16(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) { \
290  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
291  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
292  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
293  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
294  crypto->SEQ4 = CRYPTO_CMD_INSTR_END;}
295 #define CRYPTO_SEQ_LOAD_17(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) { \
296  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
297  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
298  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
299  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
300  crypto->SEQ4 = a17 | (CRYPTO_CMD_INSTR_END<<8);}
301 #define CRYPTO_SEQ_LOAD_18(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) { \
302  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
303  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
304  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
305  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
306  crypto->SEQ4 = a17 | (a18<<8) | (CRYPTO_CMD_INSTR_END<<16);}
307 #define CRYPTO_SEQ_LOAD_19(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) { \
308  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
309  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
310  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
311  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
312  crypto->SEQ4 = a17 | (a18<<8) | (a19<<16) | (CRYPTO_CMD_INSTR_END<<24);}
313 #define CRYPTO_SEQ_LOAD_20(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) { \
314  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
315  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
316  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
317  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
318  crypto->SEQ4 = a17 | (a18<<8) | (a19<<16) | (a20<<24);}
319 
327 #define CRYPTO_EXECUTE_1(crypto, a1) { \
328  crypto->SEQ0 = a1 | (CRYPTO_CMD_INSTR_EXEC<<8); }
329 #define CRYPTO_EXECUTE_2(crypto, a1, a2) { \
330  crypto->SEQ0 = a1 | (a2<<8) | (CRYPTO_CMD_INSTR_EXEC<<16); }
331 #define CRYPTO_EXECUTE_3(crypto, a1, a2, a3) { \
332  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }
333 #define CRYPTO_EXECUTE_4(crypto, a1, a2, a3, a4) { \
334  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
335  crypto->SEQ1 = CRYPTO_CMD_INSTR_EXEC; }
336 #define CRYPTO_EXECUTE_5(crypto, a1, a2, a3, a4, a5) { \
337  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
338  crypto->SEQ1 = a5 | (CRYPTO_CMD_INSTR_EXEC<<8); }
339 #define CRYPTO_EXECUTE_6(crypto, a1, a2, a3, a4, a5, a6) { \
340  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
341  crypto->SEQ1 = a5 | (a6<<8) | (CRYPTO_CMD_INSTR_EXEC<<16); }
342 #define CRYPTO_EXECUTE_7(crypto, a1, a2, a3, a4, a5, a6, a7) { \
343  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
344  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }
345 #define CRYPTO_EXECUTE_8(crypto, a1, a2, a3, a4, a5, a6, a7, a8) { \
346  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
347  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
348  crypto->SEQ2 = CRYPTO_CMD_INSTR_EXEC; }
349 #define CRYPTO_EXECUTE_9(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9) { \
350  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
351  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
352  crypto->SEQ2 = a9 | (CRYPTO_CMD_INSTR_EXEC<<8); }
353 #define CRYPTO_EXECUTE_10(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { \
354  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
355  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
356  crypto->SEQ2 = a9 | (a10<<8) | (CRYPTO_CMD_INSTR_EXEC<<16); }
357 #define CRYPTO_EXECUTE_11(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { \
358  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
359  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
360  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }
361 #define CRYPTO_EXECUTE_12(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { \
362  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
363  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
364  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
365  crypto->SEQ3 = CRYPTO_CMD_INSTR_EXEC; }
366 #define CRYPTO_EXECUTE_13(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) { \
367  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
368  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
369  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
370  crypto->SEQ3 = a13 | (CRYPTO_CMD_INSTR_EXEC<<8); }
371 #define CRYPTO_EXECUTE_14(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) { \
372  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
373  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
374  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
375  crypto->SEQ3 = a13 | (a14<<8) | (CRYPTO_CMD_INSTR_EXEC<<16); }
376 #define CRYPTO_EXECUTE_15(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) { \
377  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
378  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
379  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
380  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }
381 #define CRYPTO_EXECUTE_16(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) { \
382  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
383  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
384  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
385  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
386  crypto->SEQ4 = CRYPTO_CMD_INSTR_EXEC; }
387 #define CRYPTO_EXECUTE_17(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) { \
388  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
389  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
390  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
391  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
392  crypto->SEQ4 = a17 | (CRYPTO_CMD_INSTR_EXEC<<8); }
393 #define CRYPTO_EXECUTE_18(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) { \
394  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
395  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
396  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
397  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
398  crypto->SEQ4 = a17 | (a18<<8) | (CRYPTO_CMD_INSTR_EXEC<<16); }
399 #define CRYPTO_EXECUTE_19(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) { \
400  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
401  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
402  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
403  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
404  crypto->SEQ4 = a17 | (a18<<8) | (a19<<16) | (CRYPTO_CMD_INSTR_EXEC<<24); }
405 #define CRYPTO_EXECUTE_20(crypto, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) { \
406  crypto->SEQ0 = a1 | (a2<<8) | (a3<<16) | (a4<<24); \
407  crypto->SEQ1 = a5 | (a6<<8) | (a7<<16) | (a8<<24); \
408  crypto->SEQ2 = a9 | (a10<<8) | (a11<<16) | (a12<<24); \
409  crypto->SEQ3 = a13 | (a14<<8) | (a15<<16) | (a16<<24); \
410  crypto->SEQ4 = a17 | (a18<<8) | (a19<<16) | (a20<<24); \
411  CRYPTO_InstructionSequenceExecute();}
412 
414 /*******************************************************************************
415  ****************************** TYPEDEFS ***********************************
416  ******************************************************************************/
417 
423 typedef uint32_t CRYPTO_Data_TypeDef[CRYPTO_DATA_SIZE_IN_32BIT_WORDS];
424 
430 typedef uint32_t CRYPTO_DData_TypeDef[CRYPTO_DDATA_SIZE_IN_32BIT_WORDS];
431 
433 typedef uint32_t* CRYPTO_DDataPtr_TypeDef;
441 typedef uint32_t CRYPTO_QData_TypeDef[CRYPTO_QDATA_SIZE_IN_32BIT_WORDS];
442 
451 typedef uint32_t CRYPTO_Data260_TypeDef[CRYPTO_DATA260_SIZE_IN_32BIT_WORDS];
452 
457 typedef uint32_t CRYPTO_KeyBuf_TypeDef[CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS];
458 
464 typedef volatile uint32_t* CRYPTO_DataReg_TypeDef;
465 
471 typedef volatile uint32_t* CRYPTO_DDataReg_TypeDef;
472 
478 typedef volatile uint32_t* CRYPTO_QDataReg_TypeDef;
479 
481 typedef enum
482 {
483  cryptoModulusBin256 = CRYPTO_WAC_MODULUS_BIN256,
484  cryptoModulusBin128 = CRYPTO_WAC_MODULUS_BIN128,
485  cryptoModulusGcmBin128 = CRYPTO_WAC_MODULUS_GCMBIN128,
486  cryptoModulusEccB233 = CRYPTO_WAC_MODULUS_ECCBIN233P,
487  cryptoModulusEccB163 = CRYPTO_WAC_MODULUS_ECCBIN163P,
488  cryptoModulusEccP256 = CRYPTO_WAC_MODULUS_ECCPRIME256P,
489  cryptoModulusEccP224 = CRYPTO_WAC_MODULUS_ECCPRIME224P,
490  cryptoModulusEccP192 = CRYPTO_WAC_MODULUS_ECCPRIME192P,
491  cryptoModulusEccB233Order = CRYPTO_WAC_MODULUS_ECCBIN233N,
492  cryptoModulusEccB233KOrder = CRYPTO_WAC_MODULUS_ECCBIN233KN,
493  cryptoModulusEccB163Order = CRYPTO_WAC_MODULUS_ECCBIN163N,
494  cryptoModulusEccB163KOrder = CRYPTO_WAC_MODULUS_ECCBIN163KN,
495  cryptoModulusEccP256Order = CRYPTO_WAC_MODULUS_ECCPRIME256N,
496  cryptoModulusEccP224Order = CRYPTO_WAC_MODULUS_ECCPRIME224N,
497  cryptoModulusEccP192Order = CRYPTO_WAC_MODULUS_ECCPRIME192N
498 } CRYPTO_ModulusId_TypeDef;
499 
501 typedef enum
502 {
503  cryptoMulOperand256Bits = CRYPTO_WAC_MULWIDTH_MUL256,
504  cryptoMulOperand128Bits = CRYPTO_WAC_MULWIDTH_MUL128,
505  cryptoMulOperandModulusBits = CRYPTO_WAC_MULWIDTH_MULMOD
508 } CRYPTO_MulOperandWidth_TypeDef;
509 
511 typedef enum
512 {
513  cryptoResult128Bits = CRYPTO_WAC_RESULTWIDTH_128BIT,
514  cryptoResult256Bits = CRYPTO_WAC_RESULTWIDTH_256BIT,
515  cryptoResult260Bits = CRYPTO_WAC_RESULTWIDTH_260BIT
516 } CRYPTO_ResultWidth_TypeDef;
517 
519 typedef enum
520 {
521  cryptoInc1byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH1,
522  cryptoInc2byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH2,
523  cryptoInc3byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH3,
524  cryptoInc4byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH4
525 } CRYPTO_IncWidth_TypeDef;
526 
528 typedef enum
529 {
530  cryptoKey128Bits = 8,
531  cryptoKey256Bits = 16,
532 } CRYPTO_KeyWidth_TypeDef;
533 
537 #define CRYPTO_MAX_SEQUENCE_INSTRUCTIONS (20)
538 
546 typedef uint8_t CRYPTO_InstructionSequence_TypeDef[CRYPTO_MAX_SEQUENCE_INSTRUCTIONS];
547 
552 #define CRYPTO_INSTRUCTIONSEQUENSE_DEFAULT \
553  {CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \
554  CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \
555  CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \
556  CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \
557  CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \
558  CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END, \
559  CRYPTO_CMD_INSTR_END, CRYPTO_CMD_INSTR_END}
560 
562 typedef uint8_t CRYPTO_SHA1_Digest_TypeDef[CRYPTO_SHA1_DIGEST_SIZE_IN_BYTES];
563 
565 typedef uint8_t CRYPTO_SHA256_Digest_TypeDef[CRYPTO_SHA256_DIGEST_SIZE_IN_BYTES];
566 
578 typedef void (*CRYPTO_AES_CtrFuncPtr_TypeDef)(uint8_t * ctr);
579 
580 /*******************************************************************************
581  ***************************** PROTOTYPES **********************************
582  ******************************************************************************/
583 
584 /***************************************************************************/
598 void CRYPTO_ModulusSet(CRYPTO_TypeDef * crypto,
599  CRYPTO_ModulusId_TypeDef modType);
600 
601 /***************************************************************************/
615 __STATIC_INLINE
616 void CRYPTO_MulOperandWidthSet(CRYPTO_TypeDef *crypto,
617  CRYPTO_MulOperandWidth_TypeDef mulOperandWidth)
618 {
619  uint32_t temp = crypto->WAC & (~_CRYPTO_WAC_MULWIDTH_MASK);
620  crypto->WAC = temp | mulOperandWidth;
621 }
622 
623 /***************************************************************************/
636 __STATIC_INLINE
637 void CRYPTO_ResultWidthSet(CRYPTO_TypeDef *crypto,
638  CRYPTO_ResultWidth_TypeDef resultWidth)
639 {
640  uint32_t temp = crypto->WAC & (~_CRYPTO_WAC_RESULTWIDTH_MASK);
641  crypto->WAC = temp | resultWidth;
642 }
643 
644 /***************************************************************************/
658 __STATIC_INLINE void CRYPTO_IncWidthSet(CRYPTO_TypeDef *crypto,
659  CRYPTO_IncWidth_TypeDef incWidth)
660 {
661  uint32_t temp = crypto->CTRL & (~_CRYPTO_CTRL_INCWIDTH_MASK);
662  crypto->CTRL = temp | incWidth;
663 }
664 
665 /***************************************************************************/
682 __STATIC_INLINE void CRYPTO_BurstToCrypto(volatile uint32_t * reg,
683  const uint32_t * val)
684 {
685  /* Load data from memory into local registers. */
686  register uint32_t v0 = val[0];
687  register uint32_t v1 = val[1];
688  register uint32_t v2 = val[2];
689  register uint32_t v3 = val[3];
690  /* Store data to CRYPTO */
691  *reg = v0;
692  *reg = v1;
693  *reg = v2;
694  *reg = v3;
695 }
696 
697 /***************************************************************************/
714 __STATIC_INLINE void CRYPTO_BurstFromCrypto(volatile uint32_t * reg, uint32_t * val)
715 {
716  /* Load data from CRYPTO into local registers. */
717  register uint32_t v0 = *reg;
718  register uint32_t v1 = *reg;
719  register uint32_t v2 = *reg;
720  register uint32_t v3 = *reg;
721  /* Store data to memory */
722  val[0] = v0;
723  val[1] = v1;
724  val[2] = v2;
725  val[3] = v3;
726 }
727 
728 /***************************************************************************/
740 __STATIC_INLINE void CRYPTO_DataWrite(CRYPTO_DataReg_TypeDef dataReg,
741  const CRYPTO_Data_TypeDef val)
742 {
743  CRYPTO_BurstToCrypto((volatile uint32_t *)dataReg, val);
744 }
745 
746 /***************************************************************************/
758 __STATIC_INLINE void CRYPTO_DataRead(CRYPTO_DataReg_TypeDef dataReg,
759  CRYPTO_Data_TypeDef val)
760 {
761  CRYPTO_BurstFromCrypto((volatile uint32_t *)dataReg, val);
762 }
763 
764 /***************************************************************************/
776 __STATIC_INLINE void CRYPTO_DDataWrite(CRYPTO_DDataReg_TypeDef ddataReg,
777  const CRYPTO_DData_TypeDef val)
778 {
779  CRYPTO_BurstToCrypto((volatile uint32_t *)ddataReg, &val[0]);
780  CRYPTO_BurstToCrypto((volatile uint32_t *)ddataReg, &val[4]);
781 }
782 
783 /***************************************************************************/
795 __STATIC_INLINE void CRYPTO_DDataRead(CRYPTO_DDataReg_TypeDef ddataReg,
796  CRYPTO_DData_TypeDef val)
797 {
798  CRYPTO_BurstFromCrypto((volatile uint32_t *)ddataReg, &val[0]);
799  CRYPTO_BurstFromCrypto((volatile uint32_t *)ddataReg, &val[4]);
800 }
801 
802 /***************************************************************************/
814 __STATIC_INLINE void CRYPTO_QDataWrite(CRYPTO_QDataReg_TypeDef qdataReg,
815  CRYPTO_QData_TypeDef val)
816 {
817  CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[0]);
818  CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[4]);
819  CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[8]);
820  CRYPTO_BurstToCrypto((volatile uint32_t *)qdataReg, &val[12]);
821 }
822 
823 /***************************************************************************/
835 __STATIC_INLINE void CRYPTO_QDataRead(CRYPTO_QDataReg_TypeDef qdataReg,
836  CRYPTO_QData_TypeDef val)
837 {
838  CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[0]);
839  CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[4]);
840  CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[8]);
841  CRYPTO_BurstFromCrypto((volatile uint32_t *)qdataReg, &val[12]);
842 }
843 
844 /***************************************************************************/
860 __STATIC_INLINE void CRYPTO_KeyBufWrite(CRYPTO_TypeDef *crypto,
861  CRYPTO_KeyBuf_TypeDef val,
862  CRYPTO_KeyWidth_TypeDef keyWidth)
863 {
864  if (keyWidth == cryptoKey256Bits)
865  {
866  /* Set AES-256 mode */
867  BUS_RegBitWrite(&crypto->CTRL, _CRYPTO_CTRL_AES_SHIFT, _CRYPTO_CTRL_AES_AES256);
868  /* Load key in KEYBUF register (= DDATA4) */
869  CRYPTO_DDataWrite(&crypto->DDATA4, (uint32_t *)val);
870  }
871  else
872  {
873  /* Set AES-128 mode */
874  BUS_RegBitWrite(&crypto->CTRL, _CRYPTO_CTRL_AES_SHIFT, _CRYPTO_CTRL_AES_AES128);
875  CRYPTO_BurstToCrypto(&crypto->KEYBUF, &val[0]);
876  }
877 }
878 
879 void CRYPTO_KeyRead(CRYPTO_TypeDef *crypto,
880  CRYPTO_KeyBuf_TypeDef val,
881  CRYPTO_KeyWidth_TypeDef keyWidth);
882 
883 /***************************************************************************/
896 __STATIC_INLINE void CRYPTO_KeyBuf128Write(CRYPTO_TypeDef *crypto,
897  const uint32_t * val)
898 {
899  CRYPTO_BurstToCrypto(&crypto->KEYBUF, val);
900 }
901 
902 /***************************************************************************/
915 __STATIC_INLINE bool CRYPTO_CarryIsSet(CRYPTO_TypeDef *crypto)
916 {
917  return (crypto->DSTATUS & _CRYPTO_DSTATUS_CARRY_MASK)
918  >> _CRYPTO_DSTATUS_CARRY_SHIFT;
919 }
920 
921 /***************************************************************************/
935 __STATIC_INLINE uint8_t CRYPTO_DData0_4LSBitsRead(CRYPTO_TypeDef *crypto)
936 {
937  return (crypto->DSTATUS & _CRYPTO_DSTATUS_DDATA0LSBS_MASK)
938  >> _CRYPTO_DSTATUS_DDATA0LSBS_SHIFT;
939 }
940 
941 /***************************************************************************/
957 __STATIC_INLINE void CRYPTO_DData0Read260(CRYPTO_TypeDef *crypto,
958  CRYPTO_Data260_TypeDef val)
959 {
960  CRYPTO_DDataRead(&crypto->DDATA0, val);
961  val[8] = (crypto->DSTATUS & _CRYPTO_DSTATUS_DDATA0MSBS_MASK)
962  >> _CRYPTO_DSTATUS_DDATA0MSBS_SHIFT;
963 }
964 
965 /***************************************************************************/
981 __STATIC_INLINE void CRYPTO_DData0Write260(CRYPTO_TypeDef *crypto,
982  const CRYPTO_Data260_TypeDef val)
983 {
984  CRYPTO_DDataWrite(&crypto->DDATA0, val);
985  crypto->DDATA0BYTE32 = val[8] & _CRYPTO_DDATA0BYTE32_DDATA0BYTE32_MASK;
986 }
987 
988 /***************************************************************************/
1004 __STATIC_INLINE bool CRYPTO_DData1_MSBitRead(CRYPTO_TypeDef *crypto)
1005 {
1006  return (crypto->DSTATUS & _CRYPTO_DSTATUS_DDATA1MSB_MASK)
1007  >> _CRYPTO_DSTATUS_DDATA1MSB_SHIFT;
1008 }
1009 
1010 /***************************************************************************/
1026 __STATIC_INLINE
1027 void CRYPTO_InstructionSequenceLoad(CRYPTO_TypeDef *crypto,
1028  const CRYPTO_InstructionSequence_TypeDef instructionSequence)
1029 {
1030  const uint32_t * pas = (const uint32_t *) instructionSequence;
1031 
1032  crypto->SEQ0 = pas[0];
1033  crypto->SEQ1 = pas[1];
1034  crypto->SEQ2 = pas[2];
1035  crypto->SEQ3 = pas[3];
1036  crypto->SEQ4 = pas[4];
1037 }
1038 
1039 /***************************************************************************/
1050 __STATIC_INLINE void CRYPTO_InstructionSequenceExecute(CRYPTO_TypeDef *crypto)
1051 {
1052  /* Start the command sequence. */
1053  crypto->CMD = CRYPTO_CMD_SEQSTART;
1054 }
1055 
1056 /***************************************************************************/
1069 __STATIC_INLINE bool CRYPTO_InstructionSequenceDone(CRYPTO_TypeDef *crypto)
1070 {
1071  /* Return true if operation has completed. */
1072  return !(crypto->STATUS
1073  & (CRYPTO_STATUS_INSTRRUNNING | CRYPTO_STATUS_SEQRUNNING));
1074 }
1075 
1076 /***************************************************************************/
1087 __STATIC_INLINE void CRYPTO_InstructionSequenceWait(CRYPTO_TypeDef *crypto)
1088 {
1089  while (!CRYPTO_InstructionSequenceDone(crypto))
1090  ;
1091 }
1092 
1093 /***************************************************************************/
1104 __STATIC_INLINE void CRYPTO_InstructionWait(CRYPTO_TypeDef *crypto)
1105 {
1106  /* Wait for completion */
1107  while (!(crypto->IF & CRYPTO_IF_INSTRDONE))
1108  ;
1109  crypto->IFC = CRYPTO_IF_INSTRDONE;
1110 }
1111 
1112 void CRYPTO_SHA_1(CRYPTO_TypeDef *crypto,
1113  const uint8_t *msg,
1114  uint64_t msgLen,
1115  CRYPTO_SHA1_Digest_TypeDef digest);
1116 
1117 void CRYPTO_SHA_256(CRYPTO_TypeDef *crypto,
1118  const uint8_t *msg,
1119  uint64_t msgLen,
1120  CRYPTO_SHA256_Digest_TypeDef digest);
1121 
1122 void CRYPTO_Mul(CRYPTO_TypeDef *crypto,
1123  uint32_t * A, int aSize,
1124  uint32_t * B, int bSize,
1125  uint32_t * R, int rSize);
1126 
1127 void CRYPTO_AES_CBC128(CRYPTO_TypeDef *crypto,
1128  uint8_t * out,
1129  const uint8_t * in,
1130  unsigned int len,
1131  const uint8_t * key,
1132  const uint8_t * iv,
1133  bool encrypt);
1134 
1135 void CRYPTO_AES_CBC256(CRYPTO_TypeDef *crypto,
1136  uint8_t * out,
1137  const uint8_t * in,
1138  unsigned int len,
1139  const uint8_t * key,
1140  const uint8_t * iv,
1141  bool encrypt);
1142 
1143 void CRYPTO_AES_CFB128(CRYPTO_TypeDef *crypto,
1144  uint8_t * out,
1145  const uint8_t * in,
1146  unsigned int len,
1147  const uint8_t * key,
1148  const uint8_t * iv,
1149  bool encrypt);
1150 
1151 void CRYPTO_AES_CFB256(CRYPTO_TypeDef *crypto,
1152  uint8_t * out,
1153  const uint8_t * in,
1154  unsigned int len,
1155  const uint8_t * key,
1156  const uint8_t * iv,
1157  bool encrypt);
1158 
1159 void CRYPTO_AES_CTR128(CRYPTO_TypeDef *crypto,
1160  uint8_t * out,
1161  const uint8_t * in,
1162  unsigned int len,
1163  const uint8_t * key,
1164  uint8_t * ctr,
1165  CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc);
1166 
1167 void CRYPTO_AES_CTR256(CRYPTO_TypeDef *crypto,
1168  uint8_t * out,
1169  const uint8_t * in,
1170  unsigned int len,
1171  const uint8_t * key,
1172  uint8_t * ctr,
1173  CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc);
1174 
1175 void CRYPTO_AES_CTRUpdate32Bit(uint8_t * ctr);
1176 void CRYPTO_AES_DecryptKey128(CRYPTO_TypeDef *crypto, uint8_t * out, const uint8_t * in);
1177 void CRYPTO_AES_DecryptKey256(CRYPTO_TypeDef *crypto, uint8_t * out, const uint8_t * in);
1178 
1179 void CRYPTO_AES_ECB128(CRYPTO_TypeDef *crypto,
1180  uint8_t * out,
1181  const uint8_t * in,
1182  unsigned int len,
1183  const uint8_t * key,
1184  bool encrypt);
1185 
1186 void CRYPTO_AES_ECB256(CRYPTO_TypeDef *crypto,
1187  uint8_t * out,
1188  const uint8_t * in,
1189  unsigned int len,
1190  const uint8_t * key,
1191  bool encrypt);
1192 
1193 void CRYPTO_AES_OFB128(CRYPTO_TypeDef *crypto,
1194  uint8_t * out,
1195  const uint8_t * in,
1196  unsigned int len,
1197  const uint8_t * key,
1198  const uint8_t * iv);
1199 
1200 void CRYPTO_AES_OFB256(CRYPTO_TypeDef *crypto,
1201  uint8_t * out,
1202  const uint8_t * in,
1203  unsigned int len,
1204  const uint8_t * key,
1205  const uint8_t * iv);
1206 
1207 /***************************************************************************/
1218 __STATIC_INLINE void CRYPTO_IntClear(CRYPTO_TypeDef *crypto, uint32_t flags)
1219 {
1220  crypto->IFC = flags;
1221 }
1222 
1223 /***************************************************************************/
1234 __STATIC_INLINE void CRYPTO_IntDisable(CRYPTO_TypeDef *crypto, uint32_t flags)
1235 {
1236  crypto->IEN &= ~(flags);
1237 }
1238 
1239 /***************************************************************************/
1255 __STATIC_INLINE void CRYPTO_IntEnable(CRYPTO_TypeDef *crypto, uint32_t flags)
1256 {
1257  crypto->IEN |= flags;
1258 }
1259 
1260 /***************************************************************************/
1274 __STATIC_INLINE uint32_t CRYPTO_IntGet(CRYPTO_TypeDef *crypto)
1275 {
1276  return crypto->IF;
1277 }
1278 
1279 /***************************************************************************/
1296 __STATIC_INLINE uint32_t CRYPTO_IntGetEnabled(CRYPTO_TypeDef *crypto)
1297 {
1298  uint32_t tmp;
1299 
1300  /* Store IEN in temporary variable in order to define explicit order
1301  * of volatile accesses. */
1302  tmp = crypto->IEN;
1303 
1304  /* Bitwise AND of pending and enabled interrupts */
1305  return crypto->IF & tmp;
1306 }
1307 
1308 /***************************************************************************/
1319 __STATIC_INLINE void CRYPTO_IntSet(CRYPTO_TypeDef *crypto, uint32_t flags)
1320 {
1321  crypto->IFS = flags;
1322 }
1323 
1324 /*******************************************************************************
1325  ***** Static inline wrappers for CRYPTO AES functions in order to *****
1326  ***** preserve backwards compatibility with AES module API functions. *****
1327  ******************************************************************************/
1328 
1329 /***************************************************************************/
1338 __STATIC_INLINE void AES_CBC128(uint8_t * out,
1339  const uint8_t * in,
1340  unsigned int len,
1341  const uint8_t * key,
1342  const uint8_t * iv,
1343  bool encrypt)
1344 {
1345  CRYPTO_AES_CBC128(CRYPTO, out, in, len, key, iv, encrypt);
1346 }
1347 
1348 /***************************************************************************/
1357 __STATIC_INLINE void AES_CBC256(uint8_t * out,
1358  const uint8_t * in,
1359  unsigned int len,
1360  const uint8_t * key,
1361  const uint8_t * iv,
1362  bool encrypt)
1363 {
1364  CRYPTO_AES_CBC256(CRYPTO, out, in, len, key, iv, encrypt);
1365 }
1366 
1367 /***************************************************************************/
1375 __STATIC_INLINE void AES_CFB128(uint8_t * out,
1376  const uint8_t * in,
1377  unsigned int len,
1378  const uint8_t * key,
1379  const uint8_t * iv,
1380  bool encrypt)
1381 {
1382  CRYPTO_AES_CFB128(CRYPTO, out, in, len, key, iv, encrypt);
1383 }
1384 
1385 /***************************************************************************/
1393 __STATIC_INLINE void AES_CFB256(uint8_t * out,
1394  const uint8_t * in,
1395  unsigned int len,
1396  const uint8_t * key,
1397  const uint8_t * iv,
1398  bool encrypt)
1399 {
1400  CRYPTO_AES_CFB256(CRYPTO, out, in, len, key, iv, encrypt);
1401 }
1402 
1403 /***************************************************************************/
1411 __STATIC_INLINE void AES_CTR128(uint8_t * out,
1412  const uint8_t * in,
1413  unsigned int len,
1414  const uint8_t * key,
1415  uint8_t * ctr,
1416  CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc)
1417 {
1418  CRYPTO_AES_CTR128(CRYPTO, out, in, len, key, ctr, ctrFunc);
1419 }
1420 
1421 /***************************************************************************/
1429 __STATIC_INLINE void AES_CTR256(uint8_t * out,
1430  const uint8_t * in,
1431  unsigned int len,
1432  const uint8_t * key,
1433  uint8_t * ctr,
1434  CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc)
1435 {
1436  CRYPTO_AES_CTR256(CRYPTO, out, in, len, key, ctr, ctrFunc);
1437 }
1438 
1439 /***************************************************************************/
1447 __STATIC_INLINE void AES_CTRUpdate32Bit(uint8_t * ctr)
1448 {
1449  CRYPTO_AES_CTRUpdate32Bit(ctr);
1450 }
1451 
1452 /***************************************************************************/
1461 __STATIC_INLINE void AES_DecryptKey128(uint8_t * out, const uint8_t * in)
1462 {
1463  CRYPTO_AES_DecryptKey128(CRYPTO, out, in);
1464 }
1465 
1466 /***************************************************************************/
1475 __STATIC_INLINE void AES_DecryptKey256(uint8_t * out, const uint8_t * in)
1476 {
1477  CRYPTO_AES_DecryptKey256(CRYPTO, out, in);
1478 }
1479 
1480 /***************************************************************************/
1489 __STATIC_INLINE void AES_ECB128(uint8_t * out,
1490  const uint8_t * in,
1491  unsigned int len,
1492  const uint8_t * key,
1493  bool encrypt)
1494 {
1495  CRYPTO_AES_ECB128(CRYPTO, out, in, len, key, encrypt);
1496 }
1497 
1498 /***************************************************************************/
1507 __STATIC_INLINE void AES_ECB256(uint8_t * out,
1508  const uint8_t * in,
1509  unsigned int len,
1510  const uint8_t * key,
1511  bool encrypt)
1512 {
1513  CRYPTO_AES_ECB256(CRYPTO, out, in, len, key, encrypt);
1514 }
1515 
1516 /***************************************************************************/
1524 __STATIC_INLINE void AES_OFB128(uint8_t * out,
1525  const uint8_t * in,
1526  unsigned int len,
1527  const uint8_t * key,
1528  const uint8_t * iv)
1529 {
1530  CRYPTO_AES_OFB128(CRYPTO, out, in, len, key, iv);
1531 }
1532 
1533 /***************************************************************************/
1541 __STATIC_INLINE void AES_OFB256(uint8_t * out,
1542  const uint8_t * in,
1543  unsigned int len,
1544  const uint8_t * key,
1545  const uint8_t * iv)
1546 {
1547  CRYPTO_AES_OFB256(CRYPTO, out, in, len, key, iv);
1548 }
1549 
1550 #ifdef __cplusplus
1551 }
1552 #endif
1553 
1557 #endif /* defined(CRYPTO_COUNT) && (CRYPTO_COUNT > 0) */
1558 
1559 #endif /* EM_CRYPTO_H */
void AES_CTRUpdate32Bit(uint8_t *ctr)
Update last 32 bits of 128 bit counter, by incrementing with 1.
Definition: em_aes.c:850
void AES_DecryptKey128(uint8_t *out, const uint8_t *in)
Generate 128 bit decryption key from 128 bit encryption key. The decryption key is used for some ciph...
Definition: em_aes.c:873
RAM and peripheral bit-field set and clear API.
void AES_CFB256(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt)
Cipher feedback (CFB) cipher mode encryption/decryption, 256 bit key.
Definition: em_aes.c:562
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
void AES_CTR128(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, AES_CtrFuncPtr_TypeDef ctrFunc)
Counter (CTR) cipher mode encryption/decryption, 128 bit key.
Definition: em_aes.c:687
void AES_OFB256(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv)
Output feedback (OFB) cipher mode encryption/decryption, 256 bit key.
Definition: em_aes.c:1299
void AES_CTR256(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, AES_CtrFuncPtr_TypeDef ctrFunc)
Counter (CTR) cipher mode encryption/decryption, 256 bit key.
Definition: em_aes.c:785
void AES_OFB128(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv)
Output feedback (OFB) cipher mode encryption/decryption, 128 bit key.
Definition: em_aes.c:1213
void AES_CBC128(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt)
Cipher-block chaining (CBC) cipher mode encryption/decryption, 128 bit key.
Definition: em_aes.c:124
void AES_CBC256(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt)
Cipher-block chaining (CBC) cipher mode encryption/decryption, 256 bit key.
Definition: em_aes.c:289
void AES_DecryptKey256(uint8_t *out, const uint8_t *in)
Generate 256 bit decryption key from 256 bit encryption key. The decryption key is used for some ciph...
Definition: em_aes.c:918
__STATIC_INLINE void BUS_RegBitWrite(volatile uint32_t *addr, unsigned int bit, unsigned int val)
Perform a single-bit write operation on a peripheral register.
Definition: em_bus.h:148
void AES_ECB256(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt)
Electronic Codebook (ECB) cipher mode encryption/decryption, 256 bit key.
Definition: em_aes.c:1102
void AES_ECB128(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt)
Electronic Codebook (ECB) cipher mode encryption/decryption, 128 bit key.
Definition: em_aes.c:1001
void AES_CFB128(uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt)
Cipher feedback (CFB) cipher mode encryption/decryption, 128 bit key.
Definition: em_aes.c:453