The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_EFM32PG_STK3401/TOOLCHAIN_ARM_MICRO/em_aes.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_EFM32ZG_STK3200/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_aes.h@160:5571c4ff569f
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 156:ff21514d8981 | 1 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 2 | * @file em_aes.h |
AnnaBridge | 156:ff21514d8981 | 3 | * @brief Advanced encryption standard (AES) accelerator peripheral API. |
Anna Bridge |
160:5571c4ff569f | 4 | * @version 5.3.3 |
AnnaBridge | 156:ff21514d8981 | 5 | ******************************************************************************* |
Anna Bridge |
160:5571c4ff569f | 6 | * # License |
AnnaBridge | 156:ff21514d8981 | 7 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
AnnaBridge | 156:ff21514d8981 | 8 | ******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 9 | * |
AnnaBridge | 156:ff21514d8981 | 10 | * Permission is granted to anyone to use this software for any purpose, |
AnnaBridge | 156:ff21514d8981 | 11 | * including commercial applications, and to alter it and redistribute it |
AnnaBridge | 156:ff21514d8981 | 12 | * freely, subject to the following restrictions: |
AnnaBridge | 156:ff21514d8981 | 13 | * |
AnnaBridge | 156:ff21514d8981 | 14 | * 1. The origin of this software must not be misrepresented; you must not |
AnnaBridge | 156:ff21514d8981 | 15 | * claim that you wrote the original software. |
AnnaBridge | 156:ff21514d8981 | 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
AnnaBridge | 156:ff21514d8981 | 17 | * misrepresented as being the original software. |
AnnaBridge | 156:ff21514d8981 | 18 | * 3. This notice may not be removed or altered from any source distribution. |
AnnaBridge | 156:ff21514d8981 | 19 | * |
AnnaBridge | 156:ff21514d8981 | 20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
AnnaBridge | 156:ff21514d8981 | 21 | * obligation to support this Software. Silicon Labs is providing the |
AnnaBridge | 156:ff21514d8981 | 22 | * Software "AS IS", with no express or implied warranties of any kind, |
AnnaBridge | 156:ff21514d8981 | 23 | * including, but not limited to, any implied warranties of merchantability |
AnnaBridge | 156:ff21514d8981 | 24 | * or fitness for any particular purpose or warranties against infringement |
AnnaBridge | 156:ff21514d8981 | 25 | * of any proprietary rights of a third party. |
AnnaBridge | 156:ff21514d8981 | 26 | * |
AnnaBridge | 156:ff21514d8981 | 27 | * Silicon Labs will not be liable for any consequential, incidental, or |
AnnaBridge | 156:ff21514d8981 | 28 | * special damages, or any other relief, or for any claim by any third party, |
AnnaBridge | 156:ff21514d8981 | 29 | * arising from your use of this Software. |
AnnaBridge | 156:ff21514d8981 | 30 | * |
AnnaBridge | 156:ff21514d8981 | 31 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 32 | |
AnnaBridge | 156:ff21514d8981 | 33 | #ifndef EM_AES_H |
AnnaBridge | 156:ff21514d8981 | 34 | #define EM_AES_H |
AnnaBridge | 156:ff21514d8981 | 35 | |
AnnaBridge | 156:ff21514d8981 | 36 | #include "em_device.h" |
AnnaBridge | 156:ff21514d8981 | 37 | #if defined(AES_COUNT) && (AES_COUNT > 0) |
AnnaBridge | 156:ff21514d8981 | 38 | |
AnnaBridge | 156:ff21514d8981 | 39 | #include <stdbool.h> |
AnnaBridge | 156:ff21514d8981 | 40 | |
AnnaBridge | 156:ff21514d8981 | 41 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 42 | extern "C" { |
AnnaBridge | 156:ff21514d8981 | 43 | #endif |
AnnaBridge | 156:ff21514d8981 | 44 | |
AnnaBridge | 156:ff21514d8981 | 45 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 46 | * @addtogroup emlib |
AnnaBridge | 156:ff21514d8981 | 47 | * @{ |
AnnaBridge | 156:ff21514d8981 | 48 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 49 | |
AnnaBridge | 156:ff21514d8981 | 50 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 51 | * @addtogroup AES |
AnnaBridge | 156:ff21514d8981 | 52 | * @brief Advanced Encryption Standard Accelerator (AES) Peripheral API. |
AnnaBridge | 156:ff21514d8981 | 53 | * |
AnnaBridge | 156:ff21514d8981 | 54 | * @details |
AnnaBridge | 156:ff21514d8981 | 55 | * The AES peripheral supports AES block cipher encryption and decryption with |
AnnaBridge | 156:ff21514d8981 | 56 | * 128 bit and 256 bit keys. The following block cipher modes are supported: |
AnnaBridge | 156:ff21514d8981 | 57 | * @li CBC - Cipher Block Chaining mode |
AnnaBridge | 156:ff21514d8981 | 58 | * @li CFB - Cipher Feedback mode |
AnnaBridge | 156:ff21514d8981 | 59 | * @li CTR - Counter mode |
AnnaBridge | 156:ff21514d8981 | 60 | * @li ECB - Electronic Code Book mode |
AnnaBridge | 156:ff21514d8981 | 61 | * @li OFB - Output Feedback mode |
AnnaBridge | 156:ff21514d8981 | 62 | * |
AnnaBridge | 156:ff21514d8981 | 63 | * The following input/output notations should be noted: |
AnnaBridge | 156:ff21514d8981 | 64 | * |
AnnaBridge | 156:ff21514d8981 | 65 | * @li Input/output data (plaintext, ciphertext, key etc) are treated as |
AnnaBridge | 156:ff21514d8981 | 66 | * byte arrays, starting with most significant byte. Ie, 32 bytes of |
AnnaBridge | 156:ff21514d8981 | 67 | * plaintext (B0...B31) is located in memory in the same order, with B0 at |
AnnaBridge | 156:ff21514d8981 | 68 | * the lower address and B31 at the higher address. |
AnnaBridge | 156:ff21514d8981 | 69 | * |
AnnaBridge | 156:ff21514d8981 | 70 | * @li Byte arrays must always be a multiple of AES block size, ie a multiple |
AnnaBridge | 156:ff21514d8981 | 71 | * of 16. Padding, if required, is done at the end of the byte array. |
AnnaBridge | 156:ff21514d8981 | 72 | * |
AnnaBridge | 156:ff21514d8981 | 73 | * @li Byte arrays should be word (32 bit) aligned for performance |
AnnaBridge | 156:ff21514d8981 | 74 | * considerations, since the array is accessed with 32 bit access type. |
AnnaBridge | 156:ff21514d8981 | 75 | * The Cortex-M supports unaligned accesses, but with a performance penalty. |
AnnaBridge | 156:ff21514d8981 | 76 | * |
AnnaBridge | 156:ff21514d8981 | 77 | * @li It is possible to specify the same output buffer as input buffer |
AnnaBridge | 156:ff21514d8981 | 78 | * as long as they point to the same address. In that case the provided input |
AnnaBridge | 156:ff21514d8981 | 79 | * buffer is replaced with the encrypted/decrypted output. Notice that the |
AnnaBridge | 156:ff21514d8981 | 80 | * buffers must be exactly overlapping. If partly overlapping, the |
AnnaBridge | 156:ff21514d8981 | 81 | * behaviour is undefined. |
AnnaBridge | 156:ff21514d8981 | 82 | * |
AnnaBridge | 156:ff21514d8981 | 83 | * It is up to the user to use a cipher mode according to its requirements |
AnnaBridge | 156:ff21514d8981 | 84 | * in order to not break security. Please refer to specific cipher mode |
AnnaBridge | 156:ff21514d8981 | 85 | * theory for details. |
AnnaBridge | 156:ff21514d8981 | 86 | * |
AnnaBridge | 156:ff21514d8981 | 87 | * References: |
AnnaBridge | 156:ff21514d8981 | 88 | * @li Wikipedia - Cipher modes, http://en.wikipedia.org/wiki/Cipher_modes |
AnnaBridge | 156:ff21514d8981 | 89 | * |
AnnaBridge | 156:ff21514d8981 | 90 | * @li Recommendation for Block Cipher Modes of Operation, |
AnnaBridge | 156:ff21514d8981 | 91 | * NIST Special Publication 800-38A, 2001 Edition, |
AnnaBridge | 156:ff21514d8981 | 92 | * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf |
AnnaBridge | 156:ff21514d8981 | 93 | * |
AnnaBridge | 156:ff21514d8981 | 94 | * E.g. the following example shows how to perform an AES-128 CBC encryption: |
AnnaBridge | 156:ff21514d8981 | 95 | * |
AnnaBridge | 156:ff21514d8981 | 96 | * Enable clocks: |
AnnaBridge | 156:ff21514d8981 | 97 | * @include em_aes_clock_enable.c |
AnnaBridge | 156:ff21514d8981 | 98 | * |
AnnaBridge | 156:ff21514d8981 | 99 | * Execute AES-128 CBC encryption: |
AnnaBridge | 156:ff21514d8981 | 100 | * @include em_aes_basic_usage.c |
AnnaBridge | 156:ff21514d8981 | 101 | * |
AnnaBridge | 156:ff21514d8981 | 102 | * @{ |
AnnaBridge | 156:ff21514d8981 | 103 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 104 | |
AnnaBridge | 156:ff21514d8981 | 105 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 106 | ****************************** TYPEDEFS *********************************** |
AnnaBridge | 156:ff21514d8981 | 107 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 108 | |
AnnaBridge | 156:ff21514d8981 | 109 | /** |
AnnaBridge | 156:ff21514d8981 | 110 | * @brief |
AnnaBridge | 156:ff21514d8981 | 111 | * AES counter modification function pointer. |
AnnaBridge | 156:ff21514d8981 | 112 | * @details |
AnnaBridge | 156:ff21514d8981 | 113 | * Parameters: |
AnnaBridge | 156:ff21514d8981 | 114 | * @li ctr - Ptr to byte array (16 bytes) holding counter to be modified. |
AnnaBridge | 156:ff21514d8981 | 115 | */ |
AnnaBridge | 156:ff21514d8981 | 116 | typedef void (*AES_CtrFuncPtr_TypeDef)(uint8_t *ctr); |
AnnaBridge | 156:ff21514d8981 | 117 | |
AnnaBridge | 156:ff21514d8981 | 118 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 119 | ***************************** PROTOTYPES ********************************** |
AnnaBridge | 156:ff21514d8981 | 120 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 121 | |
AnnaBridge | 156:ff21514d8981 | 122 | void AES_CBC128(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 123 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 124 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 125 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 126 | const uint8_t *iv, |
AnnaBridge | 156:ff21514d8981 | 127 | bool encrypt); |
AnnaBridge | 156:ff21514d8981 | 128 | |
Anna Bridge |
160:5571c4ff569f | 129 | #if defined(AES_CTRL_AES256) |
AnnaBridge | 156:ff21514d8981 | 130 | void AES_CBC256(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 131 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 132 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 133 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 134 | const uint8_t *iv, |
AnnaBridge | 156:ff21514d8981 | 135 | bool encrypt); |
AnnaBridge | 156:ff21514d8981 | 136 | #endif |
AnnaBridge | 156:ff21514d8981 | 137 | |
AnnaBridge | 156:ff21514d8981 | 138 | void AES_CFB128(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 139 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 140 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 141 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 142 | const uint8_t *iv, |
AnnaBridge | 156:ff21514d8981 | 143 | bool encrypt); |
AnnaBridge | 156:ff21514d8981 | 144 | |
Anna Bridge |
160:5571c4ff569f | 145 | #if defined(AES_CTRL_AES256) |
AnnaBridge | 156:ff21514d8981 | 146 | void AES_CFB256(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 147 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 148 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 149 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 150 | const uint8_t *iv, |
AnnaBridge | 156:ff21514d8981 | 151 | bool encrypt); |
AnnaBridge | 156:ff21514d8981 | 152 | #endif |
AnnaBridge | 156:ff21514d8981 | 153 | |
AnnaBridge | 156:ff21514d8981 | 154 | void AES_CTR128(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 155 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 156 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 157 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 158 | uint8_t *ctr, |
AnnaBridge | 156:ff21514d8981 | 159 | AES_CtrFuncPtr_TypeDef ctrFunc); |
AnnaBridge | 156:ff21514d8981 | 160 | |
Anna Bridge |
160:5571c4ff569f | 161 | #if defined(AES_CTRL_AES256) |
AnnaBridge | 156:ff21514d8981 | 162 | void AES_CTR256(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 163 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 164 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 165 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 166 | uint8_t *ctr, |
AnnaBridge | 156:ff21514d8981 | 167 | AES_CtrFuncPtr_TypeDef ctrFunc); |
AnnaBridge | 156:ff21514d8981 | 168 | #endif |
AnnaBridge | 156:ff21514d8981 | 169 | |
AnnaBridge | 156:ff21514d8981 | 170 | void AES_CTRUpdate32Bit(uint8_t *ctr); |
AnnaBridge | 156:ff21514d8981 | 171 | |
AnnaBridge | 156:ff21514d8981 | 172 | void AES_DecryptKey128(uint8_t *out, const uint8_t *in); |
AnnaBridge | 156:ff21514d8981 | 173 | |
Anna Bridge |
160:5571c4ff569f | 174 | #if defined(AES_CTRL_AES256) |
AnnaBridge | 156:ff21514d8981 | 175 | void AES_DecryptKey256(uint8_t *out, const uint8_t *in); |
AnnaBridge | 156:ff21514d8981 | 176 | #endif |
AnnaBridge | 156:ff21514d8981 | 177 | |
AnnaBridge | 156:ff21514d8981 | 178 | void AES_ECB128(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 179 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 180 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 181 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 182 | bool encrypt); |
AnnaBridge | 156:ff21514d8981 | 183 | |
Anna Bridge |
160:5571c4ff569f | 184 | #if defined(AES_CTRL_AES256) |
AnnaBridge | 156:ff21514d8981 | 185 | void AES_ECB256(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 186 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 187 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 188 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 189 | bool encrypt); |
AnnaBridge | 156:ff21514d8981 | 190 | #endif |
AnnaBridge | 156:ff21514d8981 | 191 | |
AnnaBridge | 156:ff21514d8981 | 192 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 193 | * @brief |
AnnaBridge | 156:ff21514d8981 | 194 | * Clear one or more pending AES interrupts. |
AnnaBridge | 156:ff21514d8981 | 195 | * |
AnnaBridge | 156:ff21514d8981 | 196 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 197 | * Pending AES interrupt source to clear. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 198 | * valid interrupt flags for the AES module (AES_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 199 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 200 | __STATIC_INLINE void AES_IntClear(uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 201 | { |
AnnaBridge | 156:ff21514d8981 | 202 | AES->IFC = flags; |
AnnaBridge | 156:ff21514d8981 | 203 | } |
AnnaBridge | 156:ff21514d8981 | 204 | |
AnnaBridge | 156:ff21514d8981 | 205 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 206 | * @brief |
AnnaBridge | 156:ff21514d8981 | 207 | * Disable one or more AES interrupts. |
AnnaBridge | 156:ff21514d8981 | 208 | * |
AnnaBridge | 156:ff21514d8981 | 209 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 210 | * AES interrupt sources to disable. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 211 | * valid interrupt flags for the AES module (AES_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 212 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 213 | __STATIC_INLINE void AES_IntDisable(uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 214 | { |
AnnaBridge | 156:ff21514d8981 | 215 | AES->IEN &= ~(flags); |
AnnaBridge | 156:ff21514d8981 | 216 | } |
AnnaBridge | 156:ff21514d8981 | 217 | |
AnnaBridge | 156:ff21514d8981 | 218 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 219 | * @brief |
AnnaBridge | 156:ff21514d8981 | 220 | * Enable one or more AES interrupts. |
AnnaBridge | 156:ff21514d8981 | 221 | * |
AnnaBridge | 156:ff21514d8981 | 222 | * @note |
AnnaBridge | 156:ff21514d8981 | 223 | * Depending on the use, a pending interrupt may already be set prior to |
AnnaBridge | 156:ff21514d8981 | 224 | * enabling the interrupt. Consider using AES_IntClear() prior to enabling |
AnnaBridge | 156:ff21514d8981 | 225 | * if such a pending interrupt should be ignored. |
AnnaBridge | 156:ff21514d8981 | 226 | * |
AnnaBridge | 156:ff21514d8981 | 227 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 228 | * AES interrupt sources to enable. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 229 | * valid interrupt flags for the AES module (AES_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 230 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 231 | __STATIC_INLINE void AES_IntEnable(uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 232 | { |
AnnaBridge | 156:ff21514d8981 | 233 | AES->IEN |= flags; |
AnnaBridge | 156:ff21514d8981 | 234 | } |
AnnaBridge | 156:ff21514d8981 | 235 | |
AnnaBridge | 156:ff21514d8981 | 236 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 237 | * @brief |
AnnaBridge | 156:ff21514d8981 | 238 | * Get pending AES interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 239 | * |
AnnaBridge | 156:ff21514d8981 | 240 | * @note |
AnnaBridge | 156:ff21514d8981 | 241 | * The event bits are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 242 | * |
AnnaBridge | 156:ff21514d8981 | 243 | * @return |
AnnaBridge | 156:ff21514d8981 | 244 | * AES interrupt sources pending. A bitwise logic OR combination of valid |
AnnaBridge | 156:ff21514d8981 | 245 | * interrupt flags for the AES module (AES_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 246 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 247 | __STATIC_INLINE uint32_t AES_IntGet(void) |
AnnaBridge | 156:ff21514d8981 | 248 | { |
AnnaBridge | 156:ff21514d8981 | 249 | return AES->IF; |
AnnaBridge | 156:ff21514d8981 | 250 | } |
AnnaBridge | 156:ff21514d8981 | 251 | |
AnnaBridge | 156:ff21514d8981 | 252 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 253 | * @brief |
AnnaBridge | 156:ff21514d8981 | 254 | * Get enabled and pending AES interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 255 | * Useful for handling more interrupt sources in the same interrupt handler. |
AnnaBridge | 156:ff21514d8981 | 256 | * |
AnnaBridge | 156:ff21514d8981 | 257 | * @note |
AnnaBridge | 156:ff21514d8981 | 258 | * Interrupt flags are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 259 | * |
AnnaBridge | 156:ff21514d8981 | 260 | * @return |
AnnaBridge | 156:ff21514d8981 | 261 | * Pending and enabled AES interrupt sources |
AnnaBridge | 156:ff21514d8981 | 262 | * The return value is the bitwise AND of |
AnnaBridge | 156:ff21514d8981 | 263 | * - the enabled interrupt sources in AES_IEN and |
AnnaBridge | 156:ff21514d8981 | 264 | * - the pending interrupt flags AES_IF |
AnnaBridge | 156:ff21514d8981 | 265 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 266 | __STATIC_INLINE uint32_t AES_IntGetEnabled(void) |
AnnaBridge | 156:ff21514d8981 | 267 | { |
AnnaBridge | 156:ff21514d8981 | 268 | uint32_t ien; |
AnnaBridge | 156:ff21514d8981 | 269 | |
AnnaBridge | 156:ff21514d8981 | 270 | ien = AES->IEN; |
AnnaBridge | 156:ff21514d8981 | 271 | return AES->IF & ien; |
AnnaBridge | 156:ff21514d8981 | 272 | } |
AnnaBridge | 156:ff21514d8981 | 273 | |
AnnaBridge | 156:ff21514d8981 | 274 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 275 | * @brief |
AnnaBridge | 156:ff21514d8981 | 276 | * Set one or more pending AES interrupts from SW. |
AnnaBridge | 156:ff21514d8981 | 277 | * |
AnnaBridge | 156:ff21514d8981 | 278 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 279 | * AES interrupt sources to set to pending. Use a bitwise logic OR combination |
AnnaBridge | 156:ff21514d8981 | 280 | * of valid interrupt flags for the AES module (AES_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 281 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 282 | __STATIC_INLINE void AES_IntSet(uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 283 | { |
AnnaBridge | 156:ff21514d8981 | 284 | AES->IFS = flags; |
AnnaBridge | 156:ff21514d8981 | 285 | } |
AnnaBridge | 156:ff21514d8981 | 286 | |
AnnaBridge | 156:ff21514d8981 | 287 | void AES_OFB128(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 288 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 289 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 290 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 291 | const uint8_t *iv); |
AnnaBridge | 156:ff21514d8981 | 292 | |
Anna Bridge |
160:5571c4ff569f | 293 | #if defined(AES_CTRL_AES256) |
AnnaBridge | 156:ff21514d8981 | 294 | void AES_OFB256(uint8_t *out, |
AnnaBridge | 156:ff21514d8981 | 295 | const uint8_t *in, |
AnnaBridge | 156:ff21514d8981 | 296 | unsigned int len, |
AnnaBridge | 156:ff21514d8981 | 297 | const uint8_t *key, |
AnnaBridge | 156:ff21514d8981 | 298 | const uint8_t *iv); |
AnnaBridge | 156:ff21514d8981 | 299 | #endif |
AnnaBridge | 156:ff21514d8981 | 300 | |
AnnaBridge | 156:ff21514d8981 | 301 | /** @} (end addtogroup AES) */ |
AnnaBridge | 156:ff21514d8981 | 302 | /** @} (end addtogroup emlib) */ |
AnnaBridge | 156:ff21514d8981 | 303 | |
AnnaBridge | 156:ff21514d8981 | 304 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 305 | } |
AnnaBridge | 156:ff21514d8981 | 306 | #endif |
AnnaBridge | 156:ff21514d8981 | 307 | |
AnnaBridge | 156:ff21514d8981 | 308 | #endif /* defined(AES_COUNT) && (AES_COUNT > 0) */ |
AnnaBridge | 156:ff21514d8981 | 309 | #endif /* EM_AES_H */ |