30 #ifndef __STM32F4xx_HASH_H
31 #define __STM32F4xx_HASH_H
38 #include "stm32f4xx.h"
55 uint32_t HASH_AlgoSelection;
57 uint32_t HASH_AlgoMode;
59 uint32_t HASH_DataType;
62 uint32_t HASH_HMACKeyType;
83 uint32_t HASH_CSR[51];
95 #define HASH_AlgoSelection_SHA1 ((uint16_t)0x0000)
96 #define HASH_AlgoSelection_MD5 ((uint16_t)0x0080)
98 #define IS_HASH_ALGOSELECTION(ALGOSELECTION) (((ALGOSELECTION) == HASH_AlgoSelection_SHA1) || \
99 ((ALGOSELECTION) == HASH_AlgoSelection_MD5))
107 #define HASH_AlgoMode_HASH ((uint16_t)0x0000)
108 #define HASH_AlgoMode_HMAC ((uint16_t)0x0040)
110 #define IS_HASH_ALGOMODE(ALGOMODE) (((ALGOMODE) == HASH_AlgoMode_HASH) || \
111 ((ALGOMODE) == HASH_AlgoMode_HMAC))
119 #define HASH_DataType_32b ((uint16_t)0x0000)
120 #define HASH_DataType_16b ((uint16_t)0x0010)
121 #define HASH_DataType_8b ((uint16_t)0x0020)
122 #define HASH_DataType_1b ((uint16_t)0x0030)
124 #define IS_HASH_DATATYPE(DATATYPE) (((DATATYPE) == HASH_DataType_32b)|| \
125 ((DATATYPE) == HASH_DataType_16b)|| \
126 ((DATATYPE) == HASH_DataType_8b)|| \
127 ((DATATYPE) == HASH_DataType_1b))
135 #define HASH_HMACKeyType_ShortKey ((uint32_t)0x00000000)
136 #define HASH_HMACKeyType_LongKey ((uint32_t)0x00010000)
138 #define IS_HASH_HMAC_KEYTYPE(KEYTYPE) (((KEYTYPE) == HASH_HMACKeyType_ShortKey) || \
139 ((KEYTYPE) == HASH_HMACKeyType_LongKey))
147 #define IS_HASH_VALIDBITSNUMBER(VALIDBITS) ((VALIDBITS) <= 0x1F)
156 #define HASH_IT_DINI ((uint8_t)0x01)
157 #define HASH_IT_DCI ((uint8_t)0x02)
159 #define IS_HASH_IT(IT) ((((IT) & (uint8_t)0xFC) == 0x00) && ((IT) != 0x00))
160 #define IS_HASH_GET_IT(IT) (((IT) == HASH_IT_DINI) || ((IT) == HASH_IT_DCI))
169 #define HASH_FLAG_DINIS ((uint16_t)0x0001)
170 #define HASH_FLAG_DCIS ((uint16_t)0x0002)
171 #define HASH_FLAG_DMAS ((uint16_t)0x0004)
172 #define HASH_FLAG_BUSY ((uint16_t)0x0008)
173 #define HASH_FLAG_DINNE ((uint16_t)0x1000)
175 #define IS_HASH_GET_FLAG(FLAG) (((FLAG) == HASH_FLAG_DINIS) || \
176 ((FLAG) == HASH_FLAG_DCIS) || \
177 ((FLAG) == HASH_FLAG_DMAS) || \
178 ((FLAG) == HASH_FLAG_BUSY) || \
179 ((FLAG) == HASH_FLAG_DINNE))
181 #define IS_HASH_CLEAR_FLAG(FLAG)(((FLAG) == HASH_FLAG_DINIS) || \
182 ((FLAG) == HASH_FLAG_DCIS))
218 void HASH_ITConfig(uint8_t HASH_IT, FunctionalState NewState);
225 ErrorStatus
HASH_SHA1(uint8_t *Input, uint32_t Ilen, uint8_t Output[20]);
226 ErrorStatus
HMAC_SHA1(uint8_t *Key, uint32_t Keylen,
227 uint8_t *Input, uint32_t Ilen,
231 ErrorStatus
HASH_MD5(uint8_t *Input, uint32_t Ilen, uint8_t Output[16]);
232 ErrorStatus
HMAC_MD5(uint8_t *Key, uint32_t Keylen,
233 uint8_t *Input, uint32_t Ilen,