em_aes.h

Go to the documentation of this file.
00001 /***************************************************************************/
00035 #ifndef __EM_AES_H
00036 #define __EM_AES_H
00037 
00038 #include "em_device.h"
00039 #if defined(AES_COUNT) && (AES_COUNT > 0)
00040 
00041 #include <stdbool.h>
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 /***************************************************************************/
00052 /***************************************************************************/
00057 /*******************************************************************************
00058  ******************************   TYPEDEFS   ***********************************
00059  ******************************************************************************/
00060 
00068 typedef void (*AES_CtrFuncPtr_TypeDef)(uint8_t *ctr);
00069 
00070 /*******************************************************************************
00071  *****************************   PROTOTYPES   **********************************
00072  ******************************************************************************/
00073 
00074 void AES_CBC128(uint8_t *out,
00075                 const uint8_t *in,
00076                 unsigned int len,
00077                 const uint8_t *key,
00078                 const uint8_t *iv,
00079                 bool encrypt);
00080 
00081 #if defined( AES_CTRL_AES256 )
00082 void AES_CBC256(uint8_t *out,
00083                 const uint8_t *in,
00084                 unsigned int len,
00085                 const uint8_t *key,
00086                 const uint8_t *iv,
00087                 bool encrypt);
00088 #endif
00089 
00090 void AES_CFB128(uint8_t *out,
00091                 const uint8_t *in,
00092                 unsigned int len,
00093                 const uint8_t *key,
00094                 const uint8_t *iv,
00095                 bool encrypt);
00096 
00097 #if defined( AES_CTRL_AES256 )
00098 void AES_CFB256(uint8_t *out,
00099                 const uint8_t *in,
00100                 unsigned int len,
00101                 const uint8_t *key,
00102                 const uint8_t *iv,
00103                 bool encrypt);
00104 #endif
00105 
00106 void AES_CTR128(uint8_t *out,
00107                 const uint8_t *in,
00108                 unsigned int len,
00109                 const uint8_t *key,
00110                 uint8_t *ctr,
00111                 AES_CtrFuncPtr_TypeDef ctrFunc);
00112 
00113 #if defined( AES_CTRL_AES256 )
00114 void AES_CTR256(uint8_t *out,
00115                 const uint8_t *in,
00116                 unsigned int len,
00117                 const uint8_t *key,
00118                 uint8_t *ctr,
00119                 AES_CtrFuncPtr_TypeDef ctrFunc);
00120 #endif
00121 
00122 void AES_CTRUpdate32Bit(uint8_t *ctr);
00123 
00124 void AES_DecryptKey128(uint8_t *out, const uint8_t *in);
00125 
00126 #if defined( AES_CTRL_AES256 )
00127 void AES_DecryptKey256(uint8_t *out, const uint8_t *in);
00128 #endif
00129 
00130 void AES_ECB128(uint8_t *out,
00131                 const uint8_t *in,
00132                 unsigned int len,
00133                 const uint8_t *key,
00134                 bool encrypt);
00135 
00136 #if defined( AES_CTRL_AES256 )
00137 void AES_ECB256(uint8_t *out,
00138                 const uint8_t *in,
00139                 unsigned int len,
00140                 const uint8_t *key,
00141                 bool encrypt);
00142 #endif
00143 
00144 /***************************************************************************/
00152 __STATIC_INLINE void AES_IntClear(uint32_t flags)
00153 {
00154   AES->IFC = flags;
00155 }
00156 
00157 
00158 /***************************************************************************/
00166 __STATIC_INLINE void AES_IntDisable(uint32_t flags)
00167 {
00168   AES->IEN &= ~(flags);
00169 }
00170 
00171 
00172 /***************************************************************************/
00185 __STATIC_INLINE void AES_IntEnable(uint32_t flags)
00186 {
00187   AES->IEN |= flags;
00188 }
00189 
00190 
00191 /***************************************************************************/
00202 __STATIC_INLINE uint32_t AES_IntGet(void)
00203 {
00204   return(AES->IF);
00205 }
00206 
00207 
00208 /***************************************************************************/
00216 __STATIC_INLINE void AES_IntSet(uint32_t flags)
00217 {
00218   AES->IFS = flags;
00219 }
00220 
00221 
00222 void AES_OFB128(uint8_t *out,
00223                 const uint8_t *in,
00224                 unsigned int len,
00225                 const uint8_t *key,
00226                 const uint8_t *iv);
00227 
00228 #if defined( AES_CTRL_AES256 )
00229 void AES_OFB256(uint8_t *out,
00230                 const uint8_t *in,
00231                 unsigned int len,
00232                 const uint8_t *key,
00233                 const uint8_t *iv);
00234 #endif
00235 
00236 
00240 #ifdef __cplusplus
00241 }
00242 #endif
00243 
00244 #endif /* __EM_AES_H */
00245 
00246 #endif /* defined(AES_COUNT) && (AES_COUNT > 0) */