@@ -77,7 +77,6 @@ typedef struct
7777
7878} CRYP_ConfigTypeDef ;
7979
80-
8180/**
8281 * @brief CRYP State Structure definition
8382 */
@@ -92,6 +91,31 @@ typedef enum
9291#endif /* USE_HAL_CRYP_SUSPEND_RESUME */
9392} HAL_CRYP_STATETypeDef ;
9493
94+ /**
95+ * @brief CRYP Context Structure definition
96+ */
97+
98+ typedef struct
99+ {
100+ uint32_t DataType ; /*!< This parameter can be a value of @ref CRYP_Data_Type */
101+ uint32_t KeySize ; /*!< This parameter can be a value of @ref CRYP_Key_Size */
102+ uint32_t * pKey ; /*!< The key used for encryption/decryption */
103+ uint32_t * pInitVect ; /*!< The initialization vector, counter with CBC and CTR Algorithm */
104+ uint32_t Algorithm ; /*!< This parameter can be a value of @ref CRYP_Algorithm_Mode */
105+ uint32_t DataWidthUnit ; /*!< This parameter can be value of @ref CRYP_Data_Width_Unit */
106+ uint32_t KeyIVConfigSkip ; /*!< This parameter can be a value of @ref CRYP_Configuration_Skip */
107+ uint32_t KeyMode ; /*!< This parameter can be value of @ref CRYP_Key_Mode */
108+ uint32_t Phase ; /*!< CRYP peripheral phase */
109+ uint32_t KeyIVConfig ; /*!< CRYP peripheral Key and IV configuration flag */
110+ uint32_t CR_Reg ; /*!< CRYP CR register */
111+ uint32_t IER_Reg ; /*!< CRYP IER register */
112+ uint32_t IVR0_Reg ; /*!< CRYP IVR0 register */
113+ uint32_t IVR1_Reg ; /*!< CRYP IVR1 register */
114+ uint32_t IVR2_Reg ; /*!< CRYP IVR2 register */
115+ uint32_t IVR3_Reg ; /*!< CRYP IVR3 register */
116+
117+ } CRYP_ContextTypeDef ;
118+
95119#if (USE_HAL_CRYP_SUSPEND_RESUME == 1U )
96120/**
97121 * @brief HAL CRYP mode suspend definitions
@@ -238,6 +262,7 @@ typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< point
238262#define HAL_CRYP_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U) /*!< Invalid Callback error */
239263#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
240264#define HAL_CRYP_ERROR_KEY 0x00000100U /*!< Key error */
265+ #define HAL_CRYP_ERROR_RNG 0x00000200U /*!< Rng error */
241266/**
242267 * @}
243268 */
@@ -339,10 +364,15 @@ typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< point
339364 * @{
340365 */
341366
342- #define CRYP_NO_SWAP 0x00000000U /*!< 32-bit data type (no swapping) */
343- #define CRYP_HALFWORD_SWAP AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */
344- #define CRYP_BYTE_SWAP AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */
345- #define CRYP_BIT_SWAP AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */
367+ #define CRYP_DATATYPE_32B 0x00000000U
368+ #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0
369+ #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1
370+ #define CRYP_DATATYPE_1B AES_CR_DATATYPE
371+
372+ #define CRYP_NO_SWAP CRYP_DATATYPE_32B /*!< 32-bit data type (no swapping) */
373+ #define CRYP_HALFWORD_SWAP CRYP_DATATYPE_16B /*!< 16-bit data type (half-word swapping) */
374+ #define CRYP_BYTE_SWAP CRYP_DATATYPE_8B /*!< 8-bit data type (byte swapping) */
375+ #define CRYP_BIT_SWAP CRYP_DATATYPE_1B /*!< 1-bit data type (bit swapping) */
346376
347377/**
348378 * @}
@@ -351,9 +381,10 @@ typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< point
351381/** @defgroup CRYP_Interrupt CRYP Interrupt
352382 * @{
353383 */
354- #define CRYP_IT_CCFIE AES_IER_CCFIE /*!< Computation Complete interrupt enable */
355- #define CRYP_IT_RWEIE AES_IER_RWEIE /*!< Read or write Error interrupt enable */
356- #define CRYP_IT_KEIE AES_IER_KEIE /*!< Key error interrupt enable */
384+ #define CRYP_IT_CCFIE AES_IER_CCFIE /*!< Computation Complete interrupt enable */
385+ #define CRYP_IT_RWEIE AES_IER_RWEIE /*!< Read or write Error interrupt enable */
386+ #define CRYP_IT_KEIE AES_IER_KEIE /*!< Key error interrupt enable */
387+ #define CRYP_IT_RNGEIE AES_IER_RNGEIE /*!< Rng error interrupt enable */
357388
358389/**
359390 * @}
@@ -363,14 +394,15 @@ typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< point
363394 * @{
364395 */
365396
366- #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden
367- also set when transferring a shared key from SAES peripheral */
368- #define CRYP_FLAG_WRERR (AES_SR_WRERR | 0x80000000U) /*!< Write Error flag */
369- #define CRYP_FLAG_RDERR (AES_SR_RDERR | 0x80000000U) /*!< Read error flag */
370- #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed flag as AES_ISR_CCF */
371- #define CRYP_FLAG_KEYVALID AES_SR_KEYVALID /*!< Key Valid flag */
372- #define CRYP_FLAG_KEIF AES_ISR_KEIF /*Key error interrupt flag */
373- #define CRYP_FLAG_RWEIF AES_ISR_RWEIF /*Read or write error Interrupt flag */
397+ #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden also set when
398+ transferring a shared key from SAES peripheral */
399+ #define CRYP_FLAG_WRERR (AES_SR_WRERR | 0x80000000U) /*!< Write Error flag */
400+ #define CRYP_FLAG_RDERR (AES_SR_RDERR | 0x80000000U) /*!< Read error flag */
401+ #define CRYP_FLAG_CCF AES_ISR_CCF /*!< Computation completed flag as AES_ISR_CCF */
402+ #define CRYP_FLAG_KEYVALID AES_SR_KEYVALID /*!< Key Valid flag */
403+ #define CRYP_FLAG_KEIF AES_ISR_KEIF /*!<Key error interrupt flag */
404+ #define CRYP_FLAG_RWEIF AES_ISR_RWEIF /*!<Read or write error Interrupt flag */
405+ #define CRYP_FLAG_RNGEIF AES_ISR_RNGEIF /*!<RNG error interrupt flag */
374406
375407
376408/**
@@ -381,10 +413,12 @@ typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< point
381413 * @{
382414 */
383415
384- #define CRYP_CLEAR_CCF AES_ICR_CCF /* Computation Complete Flag Clear */
385- #define CRYP_CLEAR_RWEIF AES_ICR_RWEIF /* Clear Error Flag : RWEIF in AES_ISR and
416+ #define CRYP_CLEAR_CCF AES_ICR_CCF /*!< Computation Complete Flag Clear */
417+ #define CRYP_CLEAR_RWEIF AES_ICR_RWEIF /*!< Clear Error Flag : RWEIF in AES_ISR and
386418 both RDERR and WRERR flags in AES_SR */
387- #define CRYP_CLEAR_KEIF AES_ICR_KEIF /* Clear Key Error Flag: KEIF in AES_ISR */
419+ #define CRYP_CLEAR_KEIF AES_ICR_KEIF /*!< Clear Key Error Flag: KEIF in AES_ISR */
420+ #define CRYP_CLEAR_RNGEIF AES_ICR_RNGEIF /*!< Clear rng Error Flag: RNGEIF in AES_ISR */
421+
388422
389423/**
390424 * @}
@@ -394,9 +428,10 @@ typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< point
394428 * @{
395429 */
396430
397- #define CRYP_KEYIVCONFIG_ALWAYS 0x00000000U /*!< Peripheral Key and IV configuration to do systematically */
398- #define CRYP_KEYIVCONFIG_ONCE 0x00000001U /*!< Peripheral Key and IV configuration to do only once */
399- #define CRYP_KEYNOCONFIG 0x00000002U /*!< Peripheral Key configuration to not do */
431+ #define CRYP_KEYIVCONFIG_ALWAYS 0x00000000U /*!< Peripheral Key and IV configuration to do systematically */
432+ #define CRYP_KEYIVCONFIG_ONCE 0x00000001U /*!< Peripheral Key and IV configuration to do only once */
433+ #define CRYP_KEYNOCONFIG 0x00000002U /*!< Peripheral Key configuration to not do */
434+ #define CRYP_IVCONFIG_ONCE 0x00000004U /*!< Peripheral IV configuration do once for interleave mode */
400435
401436/**
402437 * @}
@@ -552,6 +587,9 @@ void HAL_CRYP_ProcessSuspend(CRYP_HandleTypeDef *hcryp);
552587HAL_StatusTypeDef HAL_CRYP_Suspend (CRYP_HandleTypeDef * hcryp );
553588HAL_StatusTypeDef HAL_CRYP_Resume (CRYP_HandleTypeDef * hcryp );
554589#endif /* defined (USE_HAL_CRYP_SUSPEND_RESUME) */
590+ HAL_StatusTypeDef HAL_CRYP_SaveContext (CRYP_HandleTypeDef * hcryp , CRYP_ContextTypeDef * pcont );
591+ HAL_StatusTypeDef HAL_CRYP_RestoreContext (CRYP_HandleTypeDef * hcryp , CRYP_ContextTypeDef * pcont );
592+
555593/**
556594 * @}
557595 */
@@ -580,11 +618,11 @@ HAL_StatusTypeDef HAL_CRYP_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *pInp
580618 */
581619/* Interrupt Handler functions **********************************************/
582620void HAL_CRYP_IRQHandler (CRYP_HandleTypeDef * hcryp );
583- HAL_CRYP_STATETypeDef HAL_CRYP_GetState (CRYP_HandleTypeDef * hcryp );
621+ HAL_CRYP_STATETypeDef HAL_CRYP_GetState (const CRYP_HandleTypeDef * hcryp );
584622void HAL_CRYP_InCpltCallback (CRYP_HandleTypeDef * hcryp );
585623void HAL_CRYP_OutCpltCallback (CRYP_HandleTypeDef * hcryp );
586624void HAL_CRYP_ErrorCallback (CRYP_HandleTypeDef * hcryp );
587- uint32_t HAL_CRYP_GetError (CRYP_HandleTypeDef * hcryp );
625+ uint32_t HAL_CRYP_GetError (const CRYP_HandleTypeDef * hcryp );
588626
589627/**
590628 * @}
@@ -618,6 +656,8 @@ uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
618656 ((DATATYPE) == CRYP_BIT_SWAP))
619657
620658#define IS_CRYP_INIT (CONFIG )(((CONFIG) == CRYP_KEYIVCONFIG_ALWAYS) || \
659+ ((CONFIG) == CRYP_KEYNOCONFIG) || \
660+ ((CONFIG) == CRYP_IVCONFIG_ONCE) || \
621661 ((CONFIG) == CRYP_KEYIVCONFIG_ONCE))
622662
623663#define IS_CRYP_BUFFERSIZE (ALGO , DATAWIDTH , SIZE ) \
@@ -634,6 +674,13 @@ uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
634674
635675
636676/* Private constants ---------------------------------------------------------*/
677+ /** @defgroup CRYP_Private_Constants CRYP Private Constants
678+ * @{
679+ */
680+
681+ /**
682+ * @}
683+ */
637684/* Private defines -----------------------------------------------------------*/
638685/** @defgroup CRYP_Private_Defines CRYP Private Defines
639686 * @{
@@ -644,6 +691,14 @@ uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
644691 */
645692
646693/* Private variables ---------------------------------------------------------*/
694+ /** @defgroup CRYP_Private_Variables CRYP Private Variables
695+ * @{
696+ */
697+
698+ /**
699+ * @}
700+ */
701+
647702/* Private functions ---------------------------------------------------------*/
648703/** @defgroup CRYP_Private_Functions CRYP Private Functions
649704 * @{
0 commit comments