MG32F157 Standard Peripherals Firmware Library
mg32f157_aes.h
Go to the documentation of this file.
1 
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32F157_AES_H
12 #define __MG32F157_AES_H
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32f157.h"
20 
29 /* Exported types ------------------------------------------------------------*/
30 
34 typedef enum
35 {
36  AES_CHMOD_ECB,
37  AES_CHMOD_CBC,
38  AES_CHMOD_CTR
40 
41 #define IS_AES_CHMOD(MODE) (((MODE) == AES_CHMOD_ECB) || ((MODE) == AES_CHMOD_CBC) || \
42  ((MODE) == AES_CHMOD_CTR))
43 
47 typedef enum
48 {
49  AES_MODE_Encryption,
50  AES_MODE_Decryption,
51  AES_MODE_Derivation,
52  AES_MODE_Derivation_Decryption
54 
55 #define IS_AES_MODE(MODE) (((MODE) == AES_MODE_Encryption) || ((MODE) == AES_MODE_Decryption) || \
56  ((MODE) == AES_MODE_Derivation) || ((MODE) == AES_MODE_Derivation_Decryption))
57 
58 
62 typedef enum
63 {
64  AES_DATATYPE_32Bits,
65  AES_DATATYPE_16Bits,
66  AES_DATATYPE_8Bits,
67  AES_DATATYPE_1Bit
69 
70 #define IS_AES_DATATYPE(DATA) (((DATA) == AES_DATATYPE_32Bits) || ((DATA) == AES_DATATYPE_16Bits) || \
71  ((DATA) == AES_DATATYPE_8Bits) || ((DATA) == AES_DATATYPE_1Bit))
72 
76 typedef struct
77 {
87 
88 /* Exported constants --------------------------------------------------------*/
89 
97 #define AES_DMA_IN ((uint16_t)0x0800)
98 #define AES_DMA_OUT ((uint16_t)0x1000)
99 
100 #define IS_AES_DMA(AES_DMA) (((AES_DMA) == AES_DMA_IN) || ((AES_DMA) == AES_DMA_OUT))
101 
108 #define AES_IT_ERR ((uint32_t)0x04000006)
109 #define AES_IT_CCF ((uint32_t)0x02000001)
110 
111 #define IS_AES_IT(AES_IT) (((uint16_t)(AES_IT >> 16) & 0x0600) != 0x0000)
112 
113 #define IS_AES_GET_IT(AES_IT) (((AES_IT) == AES_IT_ERR) || ((AES_IT) == AES_IT_CCF))
114 
121 #define AES_FLAG_WRERR ((uint8_t)0x04)
122 #define AES_FLAG_RDERR ((uint8_t)0x02)
123 #define AES_FLAG_CCF ((uint8_t)0x01)
124 
125 #define IS_AES_GET_FLAG(AES_FLAG) (((AES_FLAG) == AES_FLAG_WRERR) || ((AES_FLAG) == AES_FLAG_RDERR) || ((AES_FLAG) == AES_FLAG_CCF))
126 #define IS_AES_CLEAR_FLAG(AES_FLAG) (((AES_FLAG) == AES_FLAG_WRERR) || ((AES_FLAG) == AES_FLAG_RDERR) || ((AES_FLAG) == AES_FLAG_CCF))
127 
135 /* Exported macro ------------------------------------------------------------*/
136 /* Exported functions --------------------------------------------------------*/
137 
138 void AES_DeInit(void);
139 void AES_Cmd(FunctionalState NewState);
140 void AES_IT_Config(uint32_t AES_IT, FunctionalState NewState);
141 void AES_Init( AES_InitTypeDef* AES_InitStruct);
142 void AES_SetKey(uint8_t *Key);
143 void AES_SetInitVector(uint8_t *InitVector);
144 void AES_DataInput(uint32_t *inputaddr);
145 void AES_DataOutput(uint32_t *outputaddr);
146 void AES_DMA_Cmd(uint16_t AES_DMA, FunctionalState NewState);
147 FlagStatus AES_GetFlagStatus(uint8_t AES_FLAG);
148 void AES_ClearFlag(uint8_t AES_FLAG);
149 ITStatus AES_GetITStatus(uint32_t AES_IT);
150 void AES_ClearITPendingBit(uint32_t AES_IT);
151 
160 #ifdef __cplusplus
161 }
162 #endif
163 
164 #endif /* __MG32F157_AES_H */
void AES_Init(AES_InitTypeDef *AES_InitStruct)
Initializes the AES peripheral according to the specified parameters in the AES_InitStruct.
Definition: mg32f157_aes.c:129
void AES_SetInitVector(uint8_t *InitVector)
Writes the InitVector/InitCounter in IV registers.
Definition: mg32f157_aes.c:382
AESMode_TypeDef
AES working mode definition.
Definition: mg32f157_aes.h:47
ITStatus AES_GetITStatus(uint32_t AES_IT)
Checks whether the specified AES interrupt has occurred or not.
Definition: mg32f157_aes.c:294
void AES_SetKey(uint8_t *Key)
Writes the Key in Key registers.
Definition: mg32f157_aes.c:360
void AES_ClearITPendingBit(uint32_t AES_IT)
Clears the AES's interrupt pending bits.
Definition: mg32f157_aes.c:330
AESData_TypeDef AES_DATATYPE
Definition: mg32f157_aes.h:84
FlagStatus AES_GetFlagStatus(uint8_t AES_FLAG)
Checks whether the specified AES flag is set or not.
Definition: mg32f157_aes.c:236
void AES_ClearFlag(uint8_t AES_FLAG)
Clears the AES's pending flags.
Definition: mg32f157_aes.c:268
void AES_DataInput(uint32_t *inputaddr)
Writes the origin data into AES DINR register.
Definition: mg32f157_aes.c:400
AESData_TypeDef
AES datatype definition.
Definition: mg32f157_aes.h:62
void AES_Cmd(FunctionalState NewState)
Enables or disables the AES.
Definition: mg32f157_aes.c:70
AESMode_TypeDef AES_MODE
Definition: mg32f157_aes.h:81
void AES_DeInit(void)
Deinitializes the AES peripheral registers to their default reset values.
Definition: mg32f157_aes.c:89
void AES_DMA_Cmd(uint16_t AES_DMA, FunctionalState NewState)
Enables or disables the specified AES DMA request.
Definition: mg32f157_aes.c:433
void AES_DataOutput(uint32_t *outputaddr)
Gets the output data from AES DOUTR register.
Definition: mg32f157_aes.c:416
void AES_IT_Config(uint32_t AES_IT, FunctionalState NewState)
Enables or disables the specified AES interrupts.
Definition: mg32f157_aes.c:200
AES Init structure definition.
Definition: mg32f157_aes.h:76
AESChMod_TypeDef
AES chaining mode definition.
Definition: mg32f157_aes.h:34
AESChMod_TypeDef AES_CHMOD
Definition: mg32f157_aes.h:78