1 /***************************************************************************//**
\r
3 * @brief Advanced encryption standard (AES) accelerator peripheral API for
\r
6 *******************************************************************************
\r
8 * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
\r
9 *******************************************************************************
\r
11 * Permission is granted to anyone to use this software for any purpose,
\r
12 * including commercial applications, and to alter it and redistribute it
\r
13 * freely, subject to the following restrictions:
\r
15 * 1. The origin of this software must not be misrepresented; you must not
\r
16 * claim that you wrote the original software.
\r
17 * 2. Altered source versions must be plainly marked as such, and must not be
\r
18 * misrepresented as being the original software.
\r
19 * 3. This notice may not be removed or altered from any source distribution.
\r
21 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
\r
22 * obligation to support this Software. Silicon Labs is providing the
\r
23 * Software "AS IS", with no express or implied warranties of any kind,
\r
24 * including, but not limited to, any implied warranties of merchantability
\r
25 * or fitness for any particular purpose or warranties against infringement
\r
26 * of any proprietary rights of a third party.
\r
28 * Silicon Labs will not be liable for any consequential, incidental, or
\r
29 * special damages, or any other relief, or for any claim by any third party,
\r
30 * arising from your use of this Software.
\r
32 ******************************************************************************/
\r
35 #ifndef __SILICON_LABS_EM_AES_H_
\r
36 #define __SILICON_LABS_EM_AES_H_
\r
38 #include "em_device.h"
\r
39 #if defined(AES_COUNT) && (AES_COUNT > 0)
\r
41 #include <stdbool.h>
\r
47 /***************************************************************************//**
\r
48 * @addtogroup EM_Library
\r
50 ******************************************************************************/
\r
52 /***************************************************************************//**
\r
55 ******************************************************************************/
\r
57 /*******************************************************************************
\r
58 ****************************** TYPEDEFS ***********************************
\r
59 ******************************************************************************/
\r
63 * AES counter modification function pointer.
\r
66 * @li ctr - Ptr to byte array (16 bytes) holding counter to be modified.
\r
68 typedef void (*AES_CtrFuncPtr_TypeDef)(uint8_t *ctr);
\r
70 /*******************************************************************************
\r
71 ***************************** PROTOTYPES **********************************
\r
72 ******************************************************************************/
\r
74 void AES_CBC128(uint8_t *out,
\r
81 #if defined( AES_CTRL_AES256 )
\r
82 void AES_CBC256(uint8_t *out,
\r
90 void AES_CFB128(uint8_t *out,
\r
97 #if defined( AES_CTRL_AES256 )
\r
98 void AES_CFB256(uint8_t *out,
\r
101 const uint8_t *key,
\r
106 void AES_CTR128(uint8_t *out,
\r
109 const uint8_t *key,
\r
111 AES_CtrFuncPtr_TypeDef ctrFunc);
\r
113 #if defined( AES_CTRL_AES256 )
\r
114 void AES_CTR256(uint8_t *out,
\r
117 const uint8_t *key,
\r
119 AES_CtrFuncPtr_TypeDef ctrFunc);
\r
122 void AES_CTRUpdate32Bit(uint8_t *ctr);
\r
124 void AES_DecryptKey128(uint8_t *out, const uint8_t *in);
\r
126 #if defined( AES_CTRL_AES256 )
\r
127 void AES_DecryptKey256(uint8_t *out, const uint8_t *in);
\r
130 void AES_ECB128(uint8_t *out,
\r
133 const uint8_t *key,
\r
136 #if defined( AES_CTRL_AES256 )
\r
137 void AES_ECB256(uint8_t *out,
\r
140 const uint8_t *key,
\r
144 /***************************************************************************//**
\r
146 * Clear one or more pending AES interrupts.
\r
149 * Pending AES interrupt source to clear. Use a bitwise logic OR combination of
\r
150 * valid interrupt flags for the AES module (AES_IF_nnn).
\r
151 ******************************************************************************/
\r
152 __STATIC_INLINE void AES_IntClear(uint32_t flags)
\r
158 /***************************************************************************//**
\r
160 * Disable one or more AES interrupts.
\r
163 * AES interrupt sources to disable. Use a bitwise logic OR combination of
\r
164 * valid interrupt flags for the AES module (AES_IF_nnn).
\r
165 ******************************************************************************/
\r
166 __STATIC_INLINE void AES_IntDisable(uint32_t flags)
\r
168 AES->IEN &= ~(flags);
\r
172 /***************************************************************************//**
\r
174 * Enable one or more AES interrupts.
\r
177 * Depending on the use, a pending interrupt may already be set prior to
\r
178 * enabling the interrupt. Consider using AES_IntClear() prior to enabling
\r
179 * if such a pending interrupt should be ignored.
\r
182 * AES interrupt sources to enable. Use a bitwise logic OR combination of
\r
183 * valid interrupt flags for the AES module (AES_IF_nnn).
\r
184 ******************************************************************************/
\r
185 __STATIC_INLINE void AES_IntEnable(uint32_t flags)
\r
191 /***************************************************************************//**
\r
193 * Get pending AES interrupt flags.
\r
196 * The event bits are not cleared by the use of this function.
\r
199 * AES interrupt sources pending. A bitwise logic OR combination of valid
\r
200 * interrupt flags for the AES module (AES_IF_nnn).
\r
201 ******************************************************************************/
\r
202 __STATIC_INLINE uint32_t AES_IntGet(void)
\r
208 /***************************************************************************//**
\r
210 * Set one or more pending AES interrupts from SW.
\r
213 * AES interrupt sources to set to pending. Use a bitwise logic OR combination
\r
214 * of valid interrupt flags for the AES module (AES_IF_nnn).
\r
215 ******************************************************************************/
\r
216 __STATIC_INLINE void AES_IntSet(uint32_t flags)
\r
222 void AES_OFB128(uint8_t *out,
\r
225 const uint8_t *key,
\r
226 const uint8_t *iv);
\r
228 #if defined( AES_CTRL_AES256 )
\r
229 void AES_OFB256(uint8_t *out,
\r
232 const uint8_t *key,
\r
233 const uint8_t *iv);
\r
237 /** @} (end addtogroup AES) */
\r
238 /** @} (end addtogroup EM_Library) */
\r
244 #endif /* defined(AES_COUNT) && (AES_COUNT > 0) */
\r
245 #endif /* __SILICON_LABS_EM_AES_H_ */
\r