1 /***************************************************************************//**
\r
3 * @brief Advanced encryption standard (AES) accelerator peripheral API.
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
\r
8 *******************************************************************************
\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
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
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
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
31 ******************************************************************************/
\r
33 #ifndef __SILICON_LABS_EM_AES_H__
\r
34 #define __SILICON_LABS_EM_AES_H__
\r
36 #include "em_device.h"
\r
37 #if defined(AES_COUNT) && (AES_COUNT > 0)
\r
39 #include <stdbool.h>
\r
45 /***************************************************************************//**
\r
46 * @addtogroup EM_Library
\r
48 ******************************************************************************/
\r
50 /***************************************************************************//**
\r
53 ******************************************************************************/
\r
55 /*******************************************************************************
\r
56 ****************************** TYPEDEFS ***********************************
\r
57 ******************************************************************************/
\r
61 * AES counter modification function pointer.
\r
64 * @li ctr - Ptr to byte array (16 bytes) holding counter to be modified.
\r
66 typedef void (*AES_CtrFuncPtr_TypeDef)(uint8_t *ctr);
\r
68 /*******************************************************************************
\r
69 ***************************** PROTOTYPES **********************************
\r
70 ******************************************************************************/
\r
72 void AES_CBC128(uint8_t *out,
\r
79 #if defined( AES_CTRL_AES256 )
\r
80 void AES_CBC256(uint8_t *out,
\r
88 void AES_CFB128(uint8_t *out,
\r
95 #if defined( AES_CTRL_AES256 )
\r
96 void AES_CFB256(uint8_t *out,
\r
104 void AES_CTR128(uint8_t *out,
\r
107 const uint8_t *key,
\r
109 AES_CtrFuncPtr_TypeDef ctrFunc);
\r
111 #if defined( AES_CTRL_AES256 )
\r
112 void AES_CTR256(uint8_t *out,
\r
115 const uint8_t *key,
\r
117 AES_CtrFuncPtr_TypeDef ctrFunc);
\r
120 void AES_CTRUpdate32Bit(uint8_t *ctr);
\r
122 void AES_DecryptKey128(uint8_t *out, const uint8_t *in);
\r
124 #if defined( AES_CTRL_AES256 )
\r
125 void AES_DecryptKey256(uint8_t *out, const uint8_t *in);
\r
128 void AES_ECB128(uint8_t *out,
\r
131 const uint8_t *key,
\r
134 #if defined( AES_CTRL_AES256 )
\r
135 void AES_ECB256(uint8_t *out,
\r
138 const uint8_t *key,
\r
142 /***************************************************************************//**
\r
144 * Clear one or more pending AES interrupts.
\r
147 * Pending AES interrupt source to clear. Use a bitwise logic OR combination of
\r
148 * valid interrupt flags for the AES module (AES_IF_nnn).
\r
149 ******************************************************************************/
\r
150 __STATIC_INLINE void AES_IntClear(uint32_t flags)
\r
156 /***************************************************************************//**
\r
158 * Disable one or more AES interrupts.
\r
161 * AES interrupt sources to disable. Use a bitwise logic OR combination of
\r
162 * valid interrupt flags for the AES module (AES_IF_nnn).
\r
163 ******************************************************************************/
\r
164 __STATIC_INLINE void AES_IntDisable(uint32_t flags)
\r
166 AES->IEN &= ~(flags);
\r
170 /***************************************************************************//**
\r
172 * Enable one or more AES interrupts.
\r
175 * Depending on the use, a pending interrupt may already be set prior to
\r
176 * enabling the interrupt. Consider using AES_IntClear() prior to enabling
\r
177 * if such a pending interrupt should be ignored.
\r
180 * AES interrupt sources to enable. Use a bitwise logic OR combination of
\r
181 * valid interrupt flags for the AES module (AES_IF_nnn).
\r
182 ******************************************************************************/
\r
183 __STATIC_INLINE void AES_IntEnable(uint32_t flags)
\r
189 /***************************************************************************//**
\r
191 * Get pending AES interrupt flags.
\r
194 * The event bits are not cleared by the use of this function.
\r
197 * AES interrupt sources pending. A bitwise logic OR combination of valid
\r
198 * interrupt flags for the AES module (AES_IF_nnn).
\r
199 ******************************************************************************/
\r
200 __STATIC_INLINE uint32_t AES_IntGet(void)
\r
206 /***************************************************************************//**
\r
208 * Get enabled and pending AES interrupt flags.
\r
209 * Useful for handling more interrupt sources in the same interrupt handler.
\r
212 * Interrupt flags are not cleared by the use of this function.
\r
215 * Pending and enabled AES interrupt sources
\r
216 * The return value is the bitwise AND of
\r
217 * - the enabled interrupt sources in AES_IEN and
\r
218 * - the pending interrupt flags AES_IF
\r
219 ******************************************************************************/
\r
220 __STATIC_INLINE uint32_t AES_IntGetEnabled(void)
\r
225 return AES->IF & ien;
\r
229 /***************************************************************************//**
\r
231 * Set one or more pending AES interrupts from SW.
\r
234 * AES interrupt sources to set to pending. Use a bitwise logic OR combination
\r
235 * of valid interrupt flags for the AES module (AES_IF_nnn).
\r
236 ******************************************************************************/
\r
237 __STATIC_INLINE void AES_IntSet(uint32_t flags)
\r
243 void AES_OFB128(uint8_t *out,
\r
246 const uint8_t *key,
\r
247 const uint8_t *iv);
\r
249 #if defined( AES_CTRL_AES256 )
\r
250 void AES_OFB256(uint8_t *out,
\r
253 const uint8_t *key,
\r
254 const uint8_t *iv);
\r
258 /** @} (end addtogroup AES) */
\r
259 /** @} (end addtogroup EM_Library) */
\r
265 #endif /* defined(AES_COUNT) && (AES_COUNT > 0) */
\r
266 #endif /* __SILICON_LABS_EM_AES_H__ */
\r