20#ifndef STM32H7xx_HAL_CRYP_H
21#define STM32H7xx_HAL_CRYP_H
66 uint32_t DataWidthUnit;
67 uint32_t HeaderWidthUnit;
68 uint32_t KeyIVConfigSkip;
81 HAL_CRYP_STATE_RESET = 0x00U,
82 HAL_CRYP_STATE_READY = 0x01U,
83 HAL_CRYP_STATE_BUSY = 0x02U
84} HAL_CRYP_STATETypeDef;
91#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
92typedef struct __CRYP_HandleTypeDef
100 CRYP_ConfigTypeDef Init;
102 uint32_t *pCrypInBuffPtr;
104 uint32_t *pCrypOutBuffPtr;
106 __IO uint16_t CrypHeaderCount;
108 __IO uint16_t CrypInCount;
110 __IO uint16_t CrypOutCount;
122 __IO HAL_CRYP_STATETypeDef State;
124 __IO uint32_t ErrorCode;
128 uint32_t KeyIVConfig;
135#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
136 void (*InCpltCallback)(
struct __CRYP_HandleTypeDef *hcryp);
137 void (*OutCpltCallback)(
struct __CRYP_HandleTypeDef *hcryp);
138 void (*ErrorCallback)(
struct __CRYP_HandleTypeDef *hcryp);
140 void (* MspInitCallback)(
struct __CRYP_HandleTypeDef *hcryp);
141 void (* MspDeInitCallback)(
struct __CRYP_HandleTypeDef *hcryp);
152#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
160 HAL_CRYP_INPUT_COMPLETE_CB_ID = 0x01U,
161 HAL_CRYP_OUTPUT_COMPLETE_CB_ID = 0x02U,
162 HAL_CRYP_ERROR_CB_ID = 0x03U,
164 HAL_CRYP_MSPINIT_CB_ID = 0x04U,
165 HAL_CRYP_MSPDEINIT_CB_ID = 0x05U
167} HAL_CRYP_CallbackIDTypeDef;
178typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp);
196#define HAL_CRYP_ERROR_NONE 0x00000000U
197#define HAL_CRYP_ERROR_WRITE 0x00000001U
198#define HAL_CRYP_ERROR_READ 0x00000002U
199#define HAL_CRYP_ERROR_DMA 0x00000004U
200#define HAL_CRYP_ERROR_BUSY 0x00000008U
201#define HAL_CRYP_ERROR_TIMEOUT 0x00000010U
202#define HAL_CRYP_ERROR_NOT_SUPPORTED 0x00000020U
203#define HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE 0x00000040U
204#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
205#define HAL_CRYP_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U)
218#define CRYP_DATAWIDTHUNIT_WORD 0x00000000U
219#define CRYP_DATAWIDTHUNIT_BYTE 0x00000001U
230#define CRYP_HEADERWIDTHUNIT_WORD 0x00000000U
231#define CRYP_HEADERWIDTHUNIT_BYTE 0x00000001U
242#define CRYP_DES_ECB CRYP_CR_ALGOMODE_DES_ECB
243#define CRYP_DES_CBC CRYP_CR_ALGOMODE_DES_CBC
244#define CRYP_TDES_ECB CRYP_CR_ALGOMODE_TDES_ECB
245#define CRYP_TDES_CBC CRYP_CR_ALGOMODE_TDES_CBC
246#define CRYP_AES_ECB CRYP_CR_ALGOMODE_AES_ECB
247#define CRYP_AES_CBC CRYP_CR_ALGOMODE_AES_CBC
248#define CRYP_AES_CTR CRYP_CR_ALGOMODE_AES_CTR
249#define CRYP_AES_GCM CRYP_CR_ALGOMODE_AES_GCM
250#define CRYP_AES_CCM CRYP_CR_ALGOMODE_AES_CCM
261#define CRYP_KEYSIZE_128B 0x00000000U
262#define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0
263#define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1
274#define CRYP_NO_SWAP 0x00000000U
275#define CRYP_HALFWORD_SWAP CRYP_CR_DATATYPE_0
276#define CRYP_BYTE_SWAP CRYP_CR_DATATYPE_1
277#define CRYP_BIT_SWAP CRYP_CR_DATATYPE
288#define CRYP_IT_INI CRYP_IMSCR_INIM
289#define CRYP_IT_OUTI CRYP_IMSCR_OUTIM
301#define CRYP_FLAG_IFEM CRYP_SR_IFEM
302#define CRYP_FLAG_IFNF CRYP_SR_IFNF
303#define CRYP_FLAG_OFNE CRYP_SR_OFNE
304#define CRYP_FLAG_OFFU CRYP_SR_OFFU
305#define CRYP_FLAG_BUSY CRYP_SR_BUSY
308#define CRYP_FLAG_OUTRIS 0x01000002U
309#define CRYP_FLAG_INRIS 0x01000001U
320#define CRYP_KEYIVCONFIG_ALWAYS 0x00000000U
321#define CRYP_KEYIVCONFIG_ONCE 0x00000001U
341#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
342#define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) do{\
343 (__HANDLE__)->State = HAL_CRYP_STATE_RESET;\
344 (__HANDLE__)->MspInitCallback = NULL;\
345 (__HANDLE__)->MspDeInitCallback = NULL;\
348#define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ( (__HANDLE__)->State = HAL_CRYP_STATE_RESET)
357#define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRYP_CR_CRYPEN)
358#define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~CRYP_CR_CRYPEN)
373#define CRYP_FLAG_MASK 0x0000001FU
375#define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__)\
376 ((((uint8_t)((__FLAG__) >> 24)) == 0x01U)?((((__HANDLE__)->Instance->RISR) &\
377 ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)): \
378 ((((__HANDLE__)->Instance->RISR) &\
379 ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)))
390#define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->MISR &\
391 (__INTERRUPT__)) == (__INTERRUPT__))
403#define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) |= (__INTERRUPT__))
415#define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) &= ~(__INTERRUPT__))
435void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp);
436void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp);
437HAL_StatusTypeDef HAL_CRYP_SetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf);
438HAL_StatusTypeDef HAL_CRYP_GetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf);
439#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
440HAL_StatusTypeDef HAL_CRYP_RegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID,
441 pCRYP_CallbackTypeDef pCallback);
442HAL_StatusTypeDef HAL_CRYP_UnRegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID);
453HAL_StatusTypeDef HAL_CRYP_Encrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output,
455HAL_StatusTypeDef HAL_CRYP_Decrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output,
457HAL_StatusTypeDef HAL_CRYP_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
458HAL_StatusTypeDef HAL_CRYP_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
459HAL_StatusTypeDef HAL_CRYP_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
460HAL_StatusTypeDef HAL_CRYP_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
471void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp);
472HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp);
473void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp);
474void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp);
475void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp);
476uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
497#define IS_CRYP_ALGORITHM(ALGORITHM) (((ALGORITHM) == CRYP_DES_ECB) || \
498 ((ALGORITHM) == CRYP_DES_CBC) || \
499 ((ALGORITHM) == CRYP_TDES_ECB) || \
500 ((ALGORITHM) == CRYP_TDES_CBC) || \
501 ((ALGORITHM) == CRYP_AES_ECB) || \
502 ((ALGORITHM) == CRYP_AES_CBC) || \
503 ((ALGORITHM) == CRYP_AES_CTR) || \
504 ((ALGORITHM) == CRYP_AES_GCM) || \
505 ((ALGORITHM) == CRYP_AES_CCM))
507#define IS_CRYP_KEYSIZE(KEYSIZE)(((KEYSIZE) == CRYP_KEYSIZE_128B) || \
508 ((KEYSIZE) == CRYP_KEYSIZE_192B) || \
509 ((KEYSIZE) == CRYP_KEYSIZE_256B))
511#define IS_CRYP_DATATYPE(DATATYPE)(((DATATYPE) == CRYP_NO_SWAP) || \
512 ((DATATYPE) == CRYP_HALFWORD_SWAP) || \
513 ((DATATYPE) == CRYP_BYTE_SWAP) || \
514 ((DATATYPE) == CRYP_BIT_SWAP))
516#define IS_CRYP_INIT(CONFIG)(((CONFIG) == CRYP_KEYIVCONFIG_ALWAYS) || \
517 ((CONFIG) == CRYP_KEYIVCONFIG_ONCE))
#define __IO
Definition: core_cm4.h:239
Header file of CRYP HAL Extension module.
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Crypto Processor.
Definition: stm32h730xx.h:1670
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138