RTEMS 6.1-rc5
Loading...
Searching...
No Matches
stm32h7xx_hal_cryp.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_CRYP_H
21#define STM32H7xx_HAL_CRYP_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28/* Includes ------------------------------------------------------------------*/
29#include "stm32h7xx_hal_def.h"
30
34#if defined (CRYP)
39/* Exported types ------------------------------------------------------------*/
49typedef struct
50{
51 uint32_t DataType;
53 uint32_t KeySize;
55 uint32_t *pKey;
56 uint32_t *pInitVect;
58 uint32_t Algorithm;
61 uint32_t *Header;
64 uint32_t HeaderSize;
65 uint32_t *B0;
66 uint32_t DataWidthUnit;
67 uint32_t HeaderWidthUnit;
68 uint32_t KeyIVConfigSkip;
72} CRYP_ConfigTypeDef;
73
74
79typedef enum
80{
81 HAL_CRYP_STATE_RESET = 0x00U,
82 HAL_CRYP_STATE_READY = 0x01U,
83 HAL_CRYP_STATE_BUSY = 0x02U
84} HAL_CRYP_STATETypeDef;
85
86
91#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
92typedef struct __CRYP_HandleTypeDef
93#else
94typedef struct
95#endif /* (USE_HAL_CRYP_REGISTER_CALLBACKS) */
96{
97
98 CRYP_TypeDef *Instance;
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;
112 uint16_t Size;
114 uint32_t Phase;
116 DMA_HandleTypeDef *hdmain;
118 DMA_HandleTypeDef *hdmaout;
120 HAL_LockTypeDef Lock;
122 __IO HAL_CRYP_STATETypeDef State;
124 __IO uint32_t ErrorCode;
126 uint32_t Version;
128 uint32_t KeyIVConfig;
131 uint32_t SizesSum;
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);
143#endif /* (USE_HAL_CRYP_REGISTER_CALLBACKS) */
144
145} CRYP_HandleTypeDef;
146
147
152#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
158typedef enum
159{
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);
184#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
185
186/* Exported constants --------------------------------------------------------*/
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)
206#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
207
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
251
261#define CRYP_KEYSIZE_128B 0x00000000U
262#define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0
263#define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1
264
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
278
288#define CRYP_IT_INI CRYP_IMSCR_INIM
289#define CRYP_IT_OUTI CRYP_IMSCR_OUTIM
300/* Flags in the SR register */
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
307/* Flags in the RISR register */
308#define CRYP_FLAG_OUTRIS 0x01000002U
309#define CRYP_FLAG_INRIS 0x01000001U
320#define CRYP_KEYIVCONFIG_ALWAYS 0x00000000U
321#define CRYP_KEYIVCONFIG_ONCE 0x00000001U
331/* Exported macros -----------------------------------------------------------*/
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;\
346 }while(0)
347#else
348#define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ( (__HANDLE__)->State = HAL_CRYP_STATE_RESET)
349#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
350
357#define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRYP_CR_CRYPEN)
358#define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~CRYP_CR_CRYPEN)
359
373#define CRYP_FLAG_MASK 0x0000001FU
374
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)))
380
390#define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->MISR &\
391 (__INTERRUPT__)) == (__INTERRUPT__))
392
403#define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) |= (__INTERRUPT__))
404
415#define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) &= ~(__INTERRUPT__))
416
421/* Include CRYP HAL Extended module */
423
424/* Exported functions --------------------------------------------------------*/
433HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp);
434HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp);
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);
443#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
452/* encryption/decryption ***********************************/
453HAL_StatusTypeDef HAL_CRYP_Encrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output,
454 uint32_t Timeout);
455HAL_StatusTypeDef HAL_CRYP_Decrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output,
456 uint32_t Timeout);
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);
461
470/* Interrupt Handler functions **********************************************/
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);
477
486/* Private macros --------------------------------------------------------*/
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))
506
507#define IS_CRYP_KEYSIZE(KEYSIZE)(((KEYSIZE) == CRYP_KEYSIZE_128B) || \
508 ((KEYSIZE) == CRYP_KEYSIZE_192B) || \
509 ((KEYSIZE) == CRYP_KEYSIZE_256B))
510
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))
515
516#define IS_CRYP_INIT(CONFIG)(((CONFIG) == CRYP_KEYIVCONFIG_ALWAYS) || \
517 ((CONFIG) == CRYP_KEYIVCONFIG_ONCE))
518
528/* Private constants ---------------------------------------------------------*/
537/* Private defines -----------------------------------------------------------*/
547/* Private variables ---------------------------------------------------------*/
556/* Private functions prototypes ----------------------------------------------*/
566/* Private functions ---------------------------------------------------------*/
582#endif /* CRYP */
587#ifdef __cplusplus
588}
589#endif
590
591#endif /* STM32H7xx_HAL_CRYP_H */
592
#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