gr55xx_hal_hmac.h
Go to the documentation of this file.
1 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_HMAC_H__
53 #define __GR55xx_HAL_HMAC_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_hmac.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
76 typedef enum
77 {
86 
102 typedef struct _hmac_init
103 {
104  uint32_t mode;
106  uint32_t *p_key;
108  uint32_t *p_user_hash;
110  uint32_t key_fetch_type;
115  uint32_t dpa_mode;
127 typedef struct _hmac_handle
128 {
129  hmac_regs_t *p_instance;
133  uint32_t *p_message;
135  uint32_t *p_digest;
137  uint32_t block_size;
139  uint32_t block_count;
141  uint32_t is_last_trans;
147  __IO uint32_t error_code;
149  uint32_t timeout;
151  uint32_t retention[17];
154 
171 typedef struct _hal_hmac_callback
172 {
173  void (*hmac_msp_init)(hmac_handle_t *p_hmac);
174  void (*hmac_msp_deinit)(hmac_handle_t *p_hmac);
178 
188 /* Exported constants --------------------------------------------------------*/
196 #define HAL_HMAC_ERROR_NONE ((uint32_t)0x00000000)
197 #define HAL_HMAC_ERROR_TIMEOUT ((uint32_t)0x00000001)
198 #define HAL_HMAC_ERROR_TRANSFER ((uint32_t)0x00000002)
199 #define HAL_HMAC_ERROR_INVALID_PARAM ((uint32_t)0x00000004)
205 #define HMAC_MODE_SHA LL_HMAC_CALCULATETYPE_SHA
206 #define HMAC_MODE_HMAC LL_HMAC_CALCULATETYPE_HMAC
212 #define HMAC_BLOCK_MAX (512)
213 #define HMAC_BLOCKSIZE_BITS (512)
214 #define HMAC_BLOCKSIZE_BYTES (HMAC_BLOCKSIZE_BITS >> 3)
215 #define HMAC_BLOCKSIZE_WORDS (HMAC_BLOCKSIZE_BYTES >> 2)
216 #define HMAC_DIGESTSIZE_BITS (256)
217 #define HMAC_DIGESTSIZE_BYTES (HMAC_DIGESTSIZE_BITS >> 3)
218 #define HMAC_DIGESTSIZE_WORDS (HMAC_DIGESTSIZE_BYTES >> 2)
219 #define HMAC_DMA_BLOCK_MAX (512)
225 #define HMAC_FLAG_DATAREADY_SHA LL_HMAC_FLAG_DATAREADY_SHA
226 #define HMAC_FLAG_DATAREADY_HMAC LL_HMAC_FLAG_DATAREADY_HMAC
227 #define HMAC_FLAG_DMA_MESSAGEDONE LL_HMAC_FLAG_DMA_MESSAGEDONE
228 #define HMAC_FLAG_DMA_DONE LL_HMAC_FLAG_DMA_DONE
229 #define HMAC_FLAG_DMA_ERR LL_HMAC_FLAG_DMA_ERR
230 #define HMAC_FLAG_KEY_VALID LL_HMAC_FLAG_KEY_VALID
236 #define HAL_HMAC_KEYTYPE_MCU LL_HMAC_KEYTYPE_MCU
237 /* { Start_private */
238 #define HAL_HMAC_KEYTYPE_AHB LL_HMAC_KEYTYPE_AHB
239 /* } End_private */
240 #define HAL_HMAC_KEYTYPE_KRAM LL_HMAC_KEYTYPE_KRAM
246 #define HMAC_IT_DONE ((uint32_t)0x00000001)
252 #define HAL_HMAC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
257 /* Exported macro ------------------------------------------------------------*/
258 
266 #define __HAL_HMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_HMAC_STATE_RESET)
267 
272 #define __HAL_HMAC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_ENABLE)
273 
278 #define __HAL_HMAC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_ENABLE)
279 
284 #define __HAL_HMAC_ENABLE_IT(__HANDLE__) ll_hmac_enable_it_done((__HANDLE__)->p_instance)
285 
290 #define __HAL_HMAC_DISABLE_IT(__HANDLE__) ll_hmac_disable_it_done((__HANDLE__)->p_instance)
291 
299 #define __HAL_HMAC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__)) == (__FLAG__))
300 
308 #define __HAL_HMAC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__))
309 
321 #define __HAL_HMAC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STATUS, (__FLAG__)) != 0) ? SET : RESET)
322 
327 /* Exported functions --------------------------------------------------------*/
371 
383 
393 
403 
459 hal_status_t hal_hmac_sha256_digest(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest, uint32_t timeout);
460 
474 hal_status_t hal_hmac_sha256_digest_it(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
475 
489 hal_status_t hal_hmac_sha256_digest_dma(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
490 
505 
513 
521 
553 
562 
570 void hal_hmac_set_timeout(hmac_handle_t *p_hmac, uint32_t timeout);
571 
572 
585 
599 
600 
605 #ifdef __cplusplus
606 }
607 #endif
608 
609 #endif /* __GR55xx_HAL_HMAC_H__ */
610 
_hmac_init::key_fetch_type
uint32_t key_fetch_type
Definition: gr55xx_hal_hmac.h:110
_hmac_init::p_user_hash
uint32_t * p_user_hash
Definition: gr55xx_hal_hmac.h:108
hal_hmac_get_error
uint32_t hal_hmac_get_error(hmac_handle_t *p_hmac)
Return the HMAC error code.
hal_hmac_resume_reg
hal_status_t hal_hmac_resume_reg(hmac_handle_t *p_hmac)
Restore some registers related to HMAC configuration after sleep. This function must be used in conju...
hal_hmac_irq_handler
void hal_hmac_irq_handler(hmac_handle_t *p_hmac)
Handle HMAC interrupt request.
_hmac_init
HMAC init Structure definition.
Definition: gr55xx_hal_hmac.h:103
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_hal_hmac_callback::hmac_msp_init
void(* hmac_msp_init)(hmac_handle_t *p_hmac)
Definition: gr55xx_hal_hmac.h:173
_hmac_handle::p_message
uint32_t * p_message
Definition: gr55xx_hal_hmac.h:133
hmac_handle_t
struct _hmac_handle hmac_handle_t
HMAC handle Structure definition.
hal_hmac_suspend_reg
hal_status_t hal_hmac_suspend_reg(hmac_handle_t *p_hmac)
Suspend some registers related to HMAC configuration before sleep.
_hmac_handle::state
__IO hal_hmac_state_t state
Definition: gr55xx_hal_hmac.h:145
HAL_HMAC_STATE_TIMEOUT
@ HAL_HMAC_STATE_TIMEOUT
Definition: gr55xx_hal_hmac.h:82
hal_hmac_msp_init
void hal_hmac_msp_init(hmac_handle_t *p_hmac)
Initialize the HMAC MSP.
_hmac_handle::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_hmac.h:147
HAL_HMAC_STATE_SUSPENDED
@ HAL_HMAC_STATE_SUSPENDED
Definition: gr55xx_hal_hmac.h:83
_hmac_handle::init
hmac_init_t init
Definition: gr55xx_hal_hmac.h:131
hal_hmac_msp_deinit
void hal_hmac_msp_deinit(hmac_handle_t *p_hmac)
De-initialize the HMAC MSP.
hal_hmac_init
hal_status_t hal_hmac_init(hmac_handle_t *p_hmac)
Initialize the HMAC according to the specified parameters in the hmac_init_t and initialize the assoc...
_hal_hmac_callback::hmac_error_callback
void(* hmac_error_callback)(hmac_handle_t *p_hmac)
Definition: gr55xx_hal_hmac.h:176
HAL_HMAC_STATE_ERROR
@ HAL_HMAC_STATE_ERROR
Definition: gr55xx_hal_hmac.h:81
hal_hmac_callback_t
struct _hal_hmac_callback hal_hmac_callback_t
HAL_HMAC Callback function definition.
_hmac_handle::p_instance
hmac_regs_t * p_instance
Definition: gr55xx_hal_hmac.h:129
HAL_HMAC_STATE_RESET
@ HAL_HMAC_STATE_RESET
Definition: gr55xx_hal_hmac.h:78
hmac_init_t
struct _hmac_init hmac_init_t
HMAC init Structure definition.
hal_hmac_sha256_digest_it
hal_status_t hal_hmac_sha256_digest_it(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest)
xxx in non-blocking mode with interrupt in SHA/HMAC mode.
hal_hmac_set_timeout
void hal_hmac_set_timeout(hmac_handle_t *p_hmac, uint32_t timeout)
Set the HMAC internal process timeout value.
hal_hmac_error_callback
void hal_hmac_error_callback(hmac_handle_t *p_hmac)
HMAC error callback.
_hmac_init::dpa_mode
uint32_t dpa_mode
Definition: gr55xx_hal_hmac.h:115
_hmac_handle::block_count
uint32_t block_count
Definition: gr55xx_hal_hmac.h:139
_hmac_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_hmac.h:143
_hmac_init::p_key
uint32_t * p_key
Definition: gr55xx_hal_hmac.h:106
hal_hmac_get_state
hal_hmac_state_t hal_hmac_get_state(hmac_handle_t *p_hmac)
Return the HMAC handle state.
hal_hmac_sha256_digest
hal_status_t hal_hmac_sha256_digest(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest, uint32_t timeout)
xxx in blocking mode in SHA/HMAC mode.
_hmac_handle
HMAC handle Structure definition.
Definition: gr55xx_hal_hmac.h:128
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
_hal_hmac_callback::hmac_msp_deinit
void(* hmac_msp_deinit)(hmac_handle_t *p_hmac)
Definition: gr55xx_hal_hmac.h:174
_hal_hmac_callback::hmac_done_callback
void(* hmac_done_callback)(hmac_handle_t *p_hmac)
Definition: gr55xx_hal_hmac.h:175
hal_hmac_done_callback
void hal_hmac_done_callback(hmac_handle_t *p_hmac)
Digest Done callback.
HAL_HMAC_STATE_READY
@ HAL_HMAC_STATE_READY
Definition: gr55xx_hal_hmac.h:79
_hmac_init::mode
uint32_t mode
Definition: gr55xx_hal_hmac.h:104
_hmac_handle::is_last_trans
uint32_t is_last_trans
Definition: gr55xx_hal_hmac.h:141
hal_hmac_state_t
hal_hmac_state_t
HAL HMAC State enumerations definition.
Definition: gr55xx_hal_hmac.h:77
_hmac_handle::block_size
uint32_t block_size
Definition: gr55xx_hal_hmac.h:137
hal_hmac_deinit
hal_status_t hal_hmac_deinit(hmac_handle_t *p_hmac)
De-initialize the HMAC peripheral.
_hmac_handle::p_digest
uint32_t * p_digest
Definition: gr55xx_hal_hmac.h:135
_hmac_handle::retention
uint32_t retention[17]
Definition: gr55xx_hal_hmac.h:151
_hmac_handle::timeout
uint32_t timeout
Definition: gr55xx_hal_hmac.h:149
gr55xx_ll_hmac.h
Header file containing functions prototypes of HMAC LL library.
_hal_hmac_callback
HAL_HMAC Callback function definition.
Definition: gr55xx_hal_hmac.h:172
hal_hmac_sha256_digest_dma
hal_status_t hal_hmac_sha256_digest_dma(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest)
xxx in non-blocking mode with DMA in SHA/HMAC mode.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
HAL_HMAC_STATE_BUSY
@ HAL_HMAC_STATE_BUSY
Definition: gr55xx_hal_hmac.h:80