EZR32 Wonder Gecko Software Documentation  ezr32wg-doc-4.2.1
em_aes.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __SILICON_LABS_EM_AES_H__
34 #define __SILICON_LABS_EM_AES_H__
35 
36 #include "em_device.h"
37 #if defined(AES_COUNT) && (AES_COUNT > 0)
38 
39 #include <stdbool.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /***************************************************************************/
50 /***************************************************************************/
55 /*******************************************************************************
56  ****************************** TYPEDEFS ***********************************
57  ******************************************************************************/
58 
66 typedef void (*AES_CtrFuncPtr_TypeDef)(uint8_t *ctr);
67 
68 /*******************************************************************************
69  ***************************** PROTOTYPES **********************************
70  ******************************************************************************/
71 
72 void AES_CBC128(uint8_t *out,
73  const uint8_t *in,
74  unsigned int len,
75  const uint8_t *key,
76  const uint8_t *iv,
77  bool encrypt);
78 
79 #if defined( AES_CTRL_AES256 )
80 void AES_CBC256(uint8_t *out,
81  const uint8_t *in,
82  unsigned int len,
83  const uint8_t *key,
84  const uint8_t *iv,
85  bool encrypt);
86 #endif
87 
88 void AES_CFB128(uint8_t *out,
89  const uint8_t *in,
90  unsigned int len,
91  const uint8_t *key,
92  const uint8_t *iv,
93  bool encrypt);
94 
95 #if defined( AES_CTRL_AES256 )
96 void AES_CFB256(uint8_t *out,
97  const uint8_t *in,
98  unsigned int len,
99  const uint8_t *key,
100  const uint8_t *iv,
101  bool encrypt);
102 #endif
103 
104 void AES_CTR128(uint8_t *out,
105  const uint8_t *in,
106  unsigned int len,
107  const uint8_t *key,
108  uint8_t *ctr,
109  AES_CtrFuncPtr_TypeDef ctrFunc);
110 
111 #if defined( AES_CTRL_AES256 )
112 void AES_CTR256(uint8_t *out,
113  const uint8_t *in,
114  unsigned int len,
115  const uint8_t *key,
116  uint8_t *ctr,
117  AES_CtrFuncPtr_TypeDef ctrFunc);
118 #endif
119 
120 void AES_CTRUpdate32Bit(uint8_t *ctr);
121 
122 void AES_DecryptKey128(uint8_t *out, const uint8_t *in);
123 
124 #if defined( AES_CTRL_AES256 )
125 void AES_DecryptKey256(uint8_t *out, const uint8_t *in);
126 #endif
127 
128 void AES_ECB128(uint8_t *out,
129  const uint8_t *in,
130  unsigned int len,
131  const uint8_t *key,
132  bool encrypt);
133 
134 #if defined( AES_CTRL_AES256 )
135 void AES_ECB256(uint8_t *out,
136  const uint8_t *in,
137  unsigned int len,
138  const uint8_t *key,
139  bool encrypt);
140 #endif
141 
142 /***************************************************************************/
150 __STATIC_INLINE void AES_IntClear(uint32_t flags)
151 {
152  AES->IFC = flags;
153 }
154 
155 
156 /***************************************************************************/
164 __STATIC_INLINE void AES_IntDisable(uint32_t flags)
165 {
166  AES->IEN &= ~(flags);
167 }
168 
169 
170 /***************************************************************************/
183 __STATIC_INLINE void AES_IntEnable(uint32_t flags)
184 {
185  AES->IEN |= flags;
186 }
187 
188 
189 /***************************************************************************/
200 __STATIC_INLINE uint32_t AES_IntGet(void)
201 {
202  return AES->IF;
203 }
204 
205 
206 /***************************************************************************/
220 __STATIC_INLINE uint32_t AES_IntGetEnabled(void)
221 {
222  uint32_t ien;
223 
224  ien = AES->IEN;
225  return AES->IF & ien;
226 }
227 
228 
229 /***************************************************************************/
237 __STATIC_INLINE void AES_IntSet(uint32_t flags)
238 {
239  AES->IFS = flags;
240 }
241 
242 
243 void AES_OFB128(uint8_t *out,
244  const uint8_t *in,
245  unsigned int len,
246  const uint8_t *key,
247  const uint8_t *iv);
248 
249 #if defined( AES_CTRL_AES256 )
250 void AES_OFB256(uint8_t *out,
251  const uint8_t *in,
252  unsigned int len,
253  const uint8_t *key,
254  const uint8_t *iv);
255 #endif
256 
257 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif /* defined(AES_COUNT) && (AES_COUNT > 0) */
266 #endif /* __SILICON_LABS_EM_AES_H__ */
267 
268 
__STATIC_INLINE uint32_t AES_IntGet(void)
Get pending AES interrupt flags.
Definition: em_aes.h:200
void AES_CTRUpdate32Bit(uint8_t *ctr)
Update last 32 bits of 128 bit counter, by incrementing with 1.
Definition: em_aes.c:883
__STATIC_INLINE void AES_IntDisable(uint32_t flags)
Disable one or more AES interrupts.
Definition: em_aes.h:164
#define AES
__STATIC_INLINE uint32_t AES_IntGetEnabled(void)
Get enabled and pending AES interrupt flags. Useful for handling more interrupt sources in the same i...
Definition: em_aes.h:220
__STATIC_INLINE void AES_IntEnable(uint32_t flags)
Enable one or more AES interrupts.
Definition: em_aes.h:183
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:906
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:595
__STATIC_INLINE void AES_IntClear(uint32_t flags)
Clear one or more pending AES interrupts.
Definition: em_aes.h:150
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:720
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:1332
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:818
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:1246
__STATIC_INLINE void AES_IntSet(uint32_t flags)
Set one or more pending AES interrupts from SW.
Definition: em_aes.h:237
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:157
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:322
void(* AES_CtrFuncPtr_TypeDef)(uint8_t *ctr)
AES counter modification function pointer.
Definition: em_aes.h:66
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:951
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:1135
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:1034
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:486