30 #ifndef __STM32F4xx_CRYP_H 31 #define __STM32F4xx_CRYP_H 113 uint32_t CRYP_CSGCMCCMR[8];
114 uint32_t CRYP_CSGCMR[8];
127 #define CRYP_AlgoDir_Encrypt ((uint16_t)0x0000) 128 #define CRYP_AlgoDir_Decrypt ((uint16_t)0x0004) 129 #define IS_CRYP_ALGODIR(ALGODIR) (((ALGODIR) == CRYP_AlgoDir_Encrypt) || \ 130 ((ALGODIR) == CRYP_AlgoDir_Decrypt)) 141 #define CRYP_AlgoMode_TDES_ECB ((uint32_t)0x00000000) 142 #define CRYP_AlgoMode_TDES_CBC ((uint32_t)0x00000008) 145 #define CRYP_AlgoMode_DES_ECB ((uint32_t)0x00000010) 146 #define CRYP_AlgoMode_DES_CBC ((uint32_t)0x00000018) 149 #define CRYP_AlgoMode_AES_ECB ((uint32_t)0x00000020) 150 #define CRYP_AlgoMode_AES_CBC ((uint32_t)0x00000028) 151 #define CRYP_AlgoMode_AES_CTR ((uint32_t)0x00000030) 152 #define CRYP_AlgoMode_AES_Key ((uint32_t)0x00000038) 153 #define CRYP_AlgoMode_AES_GCM ((uint32_t)0x00080000) 154 #define CRYP_AlgoMode_AES_CCM ((uint32_t)0x00080008) 156 #define IS_CRYP_ALGOMODE(ALGOMODE) (((ALGOMODE) == CRYP_AlgoMode_TDES_ECB) || \ 157 ((ALGOMODE) == CRYP_AlgoMode_TDES_CBC)|| \ 158 ((ALGOMODE) == CRYP_AlgoMode_DES_ECB) || \ 159 ((ALGOMODE) == CRYP_AlgoMode_DES_CBC) || \ 160 ((ALGOMODE) == CRYP_AlgoMode_AES_ECB) || \ 161 ((ALGOMODE) == CRYP_AlgoMode_AES_CBC) || \ 162 ((ALGOMODE) == CRYP_AlgoMode_AES_CTR) || \ 163 ((ALGOMODE) == CRYP_AlgoMode_AES_Key) || \ 164 ((ALGOMODE) == CRYP_AlgoMode_AES_GCM) || \ 165 ((ALGOMODE) == CRYP_AlgoMode_AES_CCM)) 175 #define CRYP_Phase_Init ((uint32_t)0x00000000) 176 #define CRYP_Phase_Header CRYP_CR_GCM_CCMPH_0 177 #define CRYP_Phase_Payload CRYP_CR_GCM_CCMPH_1 178 #define CRYP_Phase_Final CRYP_CR_GCM_CCMPH 180 #define IS_CRYP_PHASE(PHASE) (((PHASE) == CRYP_Phase_Init) || \ 181 ((PHASE) == CRYP_Phase_Header) || \ 182 ((PHASE) == CRYP_Phase_Payload) || \ 183 ((PHASE) == CRYP_Phase_Final)) 192 #define CRYP_DataType_32b ((uint16_t)0x0000) 193 #define CRYP_DataType_16b ((uint16_t)0x0040) 194 #define CRYP_DataType_8b ((uint16_t)0x0080) 195 #define CRYP_DataType_1b ((uint16_t)0x00C0) 196 #define IS_CRYP_DATATYPE(DATATYPE) (((DATATYPE) == CRYP_DataType_32b) || \ 197 ((DATATYPE) == CRYP_DataType_16b)|| \ 198 ((DATATYPE) == CRYP_DataType_8b)|| \ 199 ((DATATYPE) == CRYP_DataType_1b)) 207 #define CRYP_KeySize_128b ((uint16_t)0x0000) 208 #define CRYP_KeySize_192b ((uint16_t)0x0100) 209 #define CRYP_KeySize_256b ((uint16_t)0x0200) 210 #define IS_CRYP_KEYSIZE(KEYSIZE) (((KEYSIZE) == CRYP_KeySize_128b)|| \ 211 ((KEYSIZE) == CRYP_KeySize_192b)|| \ 212 ((KEYSIZE) == CRYP_KeySize_256b)) 220 #define CRYP_FLAG_BUSY ((uint8_t)0x10) 224 #define CRYP_FLAG_IFEM ((uint8_t)0x01) 225 #define CRYP_FLAG_IFNF ((uint8_t)0x02) 226 #define CRYP_FLAG_INRIS ((uint8_t)0x22) 227 #define CRYP_FLAG_OFNE ((uint8_t)0x04) 229 #define CRYP_FLAG_OFFU ((uint8_t)0x08) 230 #define CRYP_FLAG_OUTRIS ((uint8_t)0x21) 233 #define IS_CRYP_GET_FLAG(FLAG) (((FLAG) == CRYP_FLAG_IFEM) || \ 234 ((FLAG) == CRYP_FLAG_IFNF) || \ 235 ((FLAG) == CRYP_FLAG_OFNE) || \ 236 ((FLAG) == CRYP_FLAG_OFFU) || \ 237 ((FLAG) == CRYP_FLAG_BUSY) || \ 238 ((FLAG) == CRYP_FLAG_OUTRIS)|| \ 239 ((FLAG) == CRYP_FLAG_INRIS)) 247 #define CRYP_IT_INI ((uint8_t)0x01) 248 #define CRYP_IT_OUTI ((uint8_t)0x02) 249 #define IS_CRYP_CONFIG_IT(IT) ((((IT) & (uint8_t)0xFC) == 0x00) && ((IT) != 0x00)) 250 #define IS_CRYP_GET_IT(IT) (((IT) == CRYP_IT_INI) || ((IT) == CRYP_IT_OUTI)) 259 #define MODE_ENCRYPT ((uint8_t)0x01) 260 #define MODE_DECRYPT ((uint8_t)0x00) 269 #define CRYP_DMAReq_DataIN ((uint8_t)0x01) 270 #define CRYP_DMAReq_DataOUT ((uint8_t)0x02) 271 #define IS_CRYP_DMAREQ(DMAREQ) ((((DMAREQ) & (uint8_t)0xFC) == 0x00) && ((DMAREQ) != 0x00)) 316 uint8_t *Key, uint16_t Keysize,
317 uint8_t *Input, uint32_t Ilength,
321 uint8_t InitVectors[16],
322 uint8_t *Key, uint16_t Keysize,
323 uint8_t *Input, uint32_t Ilength,
327 uint8_t InitVectors[16],
328 uint8_t *Key, uint16_t Keysize,
329 uint8_t *Input, uint32_t Ilength,
333 uint8_t *Key, uint16_t Keysize,
334 uint8_t *Input, uint32_t ILength,
335 uint8_t *
Header, uint32_t HLength,
336 uint8_t *Output, uint8_t *AuthTAG);
339 uint8_t* Nonce, uint32_t NonceSize,
340 uint8_t* Key, uint16_t Keysize,
341 uint8_t* Input, uint32_t ILength,
342 uint8_t*
Header, uint32_t HLength, uint8_t *HBuffer,
344 uint8_t* AuthTAG, uint32_t TAGSize);
349 uint8_t *Input, uint32_t Ilength,
354 uint8_t InitVectors[8],
355 uint8_t *Input, uint32_t Ilength,
361 uint8_t *Input, uint32_t Ilength,
366 uint8_t InitVectors[8],
367 uint8_t *Input,uint32_t Ilength,
ITStatus CRYP_GetITStatus(uint8_t CRYP_IT)
Checks whether the specified CRYP interrupt has occurred or not.
ErrorStatus CRYP_DES_ECB(uint8_t Mode, uint8_t Key[8], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using DES in ECB Mode.
void CRYP_DMACmd(uint8_t CRYP_DMAReq, FunctionalState NewState)
Enables or disables the CRYP DMA interface.
void CRYP_ITConfig(uint8_t CRYP_IT, FunctionalState NewState)
Enables or disables the specified CRYP interrupts.
uint32_t CR_CurrentConfig
void CRYP_Init(CRYP_InitTypeDef *CRYP_InitStruct)
Initializes the CRYP peripheral according to the specified parameters in the CRYP_InitStruct.
ErrorStatus CRYP_AES_CBC(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using AES in CBC Mode.
void CRYP_StructInit(CRYP_InitTypeDef *CRYP_InitStruct)
Fills each CRYP_InitStruct member with its default value.
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
CRYP context swapping structure definition.
void CRYP_FIFOFlush(void)
Flushes the IN and OUT FIFOs (that is read and write pointers of the FIFOs are reset) ...
void CRYP_PhaseConfig(uint32_t CRYP_Phase)
Configures the AES-CCM and AES-GCM phases.
uint32_t CRYP_DataOut(void)
Returns the last data entered into the output FIFO.
ErrorStatus CRYP_TDES_CBC(uint8_t Mode, uint8_t Key[24], uint8_t InitVectors[8], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using TDES in CBC Mode.
ErrorStatus CRYP_TDES_ECB(uint8_t Mode, uint8_t Key[24], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using TDES in ECB Mode.
FlagStatus CRYP_GetFlagStatus(uint8_t CRYP_FLAG)
Checks whether the specified CRYP flag is set or not.
void CRYP_DataIn(uint32_t Data)
Writes data in the Data Input register (DIN).
FunctionalState CRYP_GetCmdStatus(void)
Returns whether CRYP peripheral is enabled or disabled.
ErrorStatus CRYP_AES_GCM(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t ILength, uint8_t *Header, uint32_t HLength, uint8_t *Output, uint8_t *AuthTAG)
Encrypt and decrypt using AES in GCM Mode. The GCM and CCM modes are available only on STM32F437x Dev...
ErrorStatus CRYP_AES_CTR(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using AES in CTR Mode.
void CRYP_RestoreContext(CRYP_Context *CRYP_ContextRestore)
Restores the CRYP peripheral Context.
ErrorStatus CRYP_DES_CBC(uint8_t Mode, uint8_t Key[8], uint8_t InitVectors[8], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using DES in CBC Mode.
void CRYP_IVStructInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
Fills each CRYP_IVInitStruct member with its default value.
CRYP Key(s) structure definition.
void CRYP_Cmd(FunctionalState NewState)
Enables or disables the CRYP peripheral.
void CRYP_KeyInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Initializes the CRYP Keys according to the specified parameters in the CRYP_KeyInitStruct.
ErrorStatus CRYP_AES_ECB(uint8_t Mode, uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using AES in ECB Mode.
ErrorStatus CRYP_AES_CCM(uint8_t Mode, uint8_t *Nonce, uint32_t NonceSize, uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t ILength, uint8_t *Header, uint32_t HLength, uint8_t *HBuffer, uint8_t *Output, uint8_t *AuthTAG, uint32_t TAGSize)
Encrypt and decrypt using AES in CCM Mode. The GCM and CCM modes are available only on STM32F437x Dev...
ErrorStatus CRYP_SaveContext(CRYP_Context *CRYP_ContextSave, CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Saves the CRYP peripheral Context.
CRYP Initialization Vectors (IV) structure definition.
void CRYP_KeyStructInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Fills each CRYP_KeyInitStruct member with its default value.
void CRYP_IVInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
Initializes the CRYP Initialization Vectors(IV) according to the specified parameters in the CRYP_IVI...
void CRYP_DeInit(void)
Deinitializes the CRYP peripheral registers to their default reset values.
CRYP Init structure definition.