30 #ifndef __STM32F4xx_CRYP_H
31 #define __STM32F4xx_CRYP_H
38 #include "stm32f4xx.h"
55 uint16_t CRYP_AlgoDir;
57 uint16_t CRYP_AlgoMode;
60 uint16_t CRYP_DataType;
62 uint16_t CRYP_KeySize;
125 #define CRYP_AlgoDir_Encrypt ((uint16_t)0x0000)
126 #define CRYP_AlgoDir_Decrypt ((uint16_t)0x0004)
127 #define IS_CRYP_ALGODIR(ALGODIR) (((ALGODIR) == CRYP_AlgoDir_Encrypt) || \
128 ((ALGODIR) == CRYP_AlgoDir_Decrypt))
139 #define CRYP_AlgoMode_TDES_ECB ((uint16_t)0x0000)
140 #define CRYP_AlgoMode_TDES_CBC ((uint16_t)0x0008)
143 #define CRYP_AlgoMode_DES_ECB ((uint16_t)0x0010)
144 #define CRYP_AlgoMode_DES_CBC ((uint16_t)0x0018)
147 #define CRYP_AlgoMode_AES_ECB ((uint16_t)0x0020)
148 #define CRYP_AlgoMode_AES_CBC ((uint16_t)0x0028)
149 #define CRYP_AlgoMode_AES_CTR ((uint16_t)0x0030)
150 #define CRYP_AlgoMode_AES_Key ((uint16_t)0x0038)
152 #define IS_CRYP_ALGOMODE(ALGOMODE) (((ALGOMODE) == CRYP_AlgoMode_TDES_ECB) || \
153 ((ALGOMODE) == CRYP_AlgoMode_TDES_CBC)|| \
154 ((ALGOMODE) == CRYP_AlgoMode_DES_ECB)|| \
155 ((ALGOMODE) == CRYP_AlgoMode_DES_CBC) || \
156 ((ALGOMODE) == CRYP_AlgoMode_AES_ECB) || \
157 ((ALGOMODE) == CRYP_AlgoMode_AES_CBC) || \
158 ((ALGOMODE) == CRYP_AlgoMode_AES_CTR) || \
159 ((ALGOMODE) == CRYP_AlgoMode_AES_Key))
167 #define CRYP_DataType_32b ((uint16_t)0x0000)
168 #define CRYP_DataType_16b ((uint16_t)0x0040)
169 #define CRYP_DataType_8b ((uint16_t)0x0080)
170 #define CRYP_DataType_1b ((uint16_t)0x00C0)
171 #define IS_CRYP_DATATYPE(DATATYPE) (((DATATYPE) == CRYP_DataType_32b) || \
172 ((DATATYPE) == CRYP_DataType_16b)|| \
173 ((DATATYPE) == CRYP_DataType_8b)|| \
174 ((DATATYPE) == CRYP_DataType_1b))
182 #define CRYP_KeySize_128b ((uint16_t)0x0000)
183 #define CRYP_KeySize_192b ((uint16_t)0x0100)
184 #define CRYP_KeySize_256b ((uint16_t)0x0200)
185 #define IS_CRYP_KEYSIZE(KEYSIZE) (((KEYSIZE) == CRYP_KeySize_128b)|| \
186 ((KEYSIZE) == CRYP_KeySize_192b)|| \
187 ((KEYSIZE) == CRYP_KeySize_256b))
195 #define CRYP_FLAG_BUSY ((uint8_t)0x10)
199 #define CRYP_FLAG_IFEM ((uint8_t)0x01)
200 #define CRYP_FLAG_IFNF ((uint8_t)0x02)
201 #define CRYP_FLAG_INRIS ((uint8_t)0x22)
202 #define CRYP_FLAG_OFNE ((uint8_t)0x04)
204 #define CRYP_FLAG_OFFU ((uint8_t)0x08)
205 #define CRYP_FLAG_OUTRIS ((uint8_t)0x21)
208 #define IS_CRYP_GET_FLAG(FLAG) (((FLAG) == CRYP_FLAG_IFEM) || \
209 ((FLAG) == CRYP_FLAG_IFNF) || \
210 ((FLAG) == CRYP_FLAG_OFNE) || \
211 ((FLAG) == CRYP_FLAG_OFFU) || \
212 ((FLAG) == CRYP_FLAG_BUSY) || \
213 ((FLAG) == CRYP_FLAG_OUTRIS)|| \
214 ((FLAG) == CRYP_FLAG_INRIS))
222 #define CRYP_IT_INI ((uint8_t)0x01)
223 #define CRYP_IT_OUTI ((uint8_t)0x02)
224 #define IS_CRYP_CONFIG_IT(IT) ((((IT) & (uint8_t)0xFC) == 0x00) && ((IT) != 0x00))
225 #define IS_CRYP_GET_IT(IT) (((IT) == CRYP_IT_INI) || ((IT) == CRYP_IT_OUTI))
234 #define MODE_ENCRYPT ((uint8_t)0x01)
235 #define MODE_DECRYPT ((uint8_t)0x00)
244 #define CRYP_DMAReq_DataIN ((uint8_t)0x01)
245 #define CRYP_DMAReq_DataOUT ((uint8_t)0x02)
246 #define IS_CRYP_DMAREQ(DMAREQ) ((((DMAREQ) & (uint8_t)0xFC) == 0x00) && ((DMAREQ) != 0x00))
268 void CRYP_Cmd(FunctionalState NewState);
281 void CRYP_DMACmd(uint8_t CRYP_DMAReq, FunctionalState NewState);
284 void CRYP_ITConfig(uint8_t CRYP_IT, FunctionalState NewState);
290 uint8_t *Key, uint16_t Keysize,
291 uint8_t *Input, uint32_t Ilength,
295 uint8_t InitVectors[16],
296 uint8_t *Key, uint16_t Keysize,
297 uint8_t *Input, uint32_t Ilength,
301 uint8_t InitVectors[16],
302 uint8_t *Key, uint16_t Keysize,
303 uint8_t *Input, uint32_t Ilength,
309 uint8_t *Input, uint32_t Ilength,
314 uint8_t InitVectors[8],
315 uint8_t *Input, uint32_t Ilength,
321 uint8_t *Input, uint32_t Ilength,
326 uint8_t InitVectors[8],
327 uint8_t *Input,uint32_t Ilength,