gr55xx_hal_pkc.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_pkc.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of PKC HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_PKC PKC
47  * @brief PKC HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_PKC_H__
53 #define __GR55xx_HAL_PKC_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_pkc.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_PKC_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /** @defgroup HAL_PKC_state HAL PKC state
69  * @{
70  */
71 
72 /**
73  * @brief HAL PKC State Enumerations definition
74  */
75 typedef enum
76 {
77  HAL_PKC_STATE_RESET = 0x00, /**< Peripheral not initialized */
78  HAL_PKC_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
79  HAL_PKC_STATE_BUSY = 0x02, /**< Peripheral in indirect mode and busy */
80  HAL_PKC_STATE_ERROR = 0x04, /**< Peripheral in error */
81  HAL_PKC_STATE_TIMEOUT = 0x08, /**< Peripheral in timeout */
82 
84 
85 /** @} */
86 
87 /** @} */
88 
89 /** @addtogroup HAL_PKC_STRUCTURES Structures
90  * @{
91  */
92 
93 /** @defgroup PKC_Configuration PKC Configuration
94  * @{
95  */
96 
97 /**
98  * @brief PKC ECC Point Structure definition
99  */
100 typedef struct _ll_ecc_point ecc_point_t;
101 
102 /**
103  * @brief PKC ECC P-256 Elliptic Curve Init Structure definition
104  */
105 typedef struct _ll_ecc_curve_init ecc_curve_init_t;
106 
107 /**
108  * @brief PKC Init Structure definition
109  */
110 typedef struct
111 {
112  ecc_curve_init_t *p_ecc_curve; /**< Specifies the pointer to elliptic curve description */
113 
114  uint32_t data_bits; /**< Specifies the Data size: 256 ~ 2048 bits */
115 
116  uint32_t secure_mode; /**< Specifies the Secure Mode. It indicates that DPA-resistance software algorithm
117  and hardware measures are applied at a cost of about 35%- 50% performance loss.
118  This parameter can be a value of @ref PKC_Secure_Mode. */
119 
120  uint32_t (*random_func)(void); /**< Specifies the function to generate random number. */
121 
122 } pkc_init_t;
123 
124 /** @} */
125 
126 /** @defgroup PKC_handle PKC handle
127  * @{
128  */
129 
130 /**
131  * @brief PKC handle Structure definition
132  */
133 typedef struct _pkc_handle
134 {
135  pkc_regs_t *p_instance; /**< PKC registers base address */
136 
137  pkc_init_t init; /**< PKC operation parameters */
138 
139  void *p_result; /**< Pointer to PKC result buffer */
140 
141  uint32_t shift_count; /**< Count to left shift */
142 
143  uint32_t *p_P; /**< Prime number */
144 
145  __IO hal_lock_t lock; /**< Locking object */
146 
147  __IO hal_pkc_state_t state; /**< PKC operation state */
148 
149  __IO uint32_t error_code; /**< PKC Error code */
150 
151  uint32_t timeout; /**< Timeout for the PKC operation */
152 
153  uint32_t retention[1]; /**< pkc important register information. */
155 /** @} */
156 
157 /** @defgroup PKC_Expression_Input PKC expression input
158  * @{
159  */
160 
161 /**
162  * @brief PKC ECC Point Multiplication expression input
163  * @note Result = K * Point
164  */
165 typedef struct _pkc_ecc_point_multi
166 {
167  uint32_t *p_K; /**< Pointer to operand K */
168  ecc_point_t *p_ecc_point; /**< Pointer to ECC Point */
170 
171 /**
172  * @brief PKC RSA Modular Exponentiation expression input
173  * @note Result = A^B mod P
174  */
176 {
177  uint32_t *p_A; /**< Pointer to operand A */
178  uint32_t *p_B; /**< Pointer to operand B */
179  uint32_t *p_P; /**< Pointer to prime number P */
180  uint32_t *p_P_R2; /**< P_R2 = R^2 mod P, where R = 2^DataBits */
181  uint32_t ConstP; /**< Montgomery multiplication constant of P */
183 
184 /**
185  * @brief PKC Modular Addition expression input
186  * @note Result = (A + B) mod P
187  */
188 typedef struct _pkc_modular_add
189 {
190  uint32_t *p_A; /**< Pointer to operand A */
191  uint32_t *p_B; /**< Pointer to operand B */
192  uint32_t *p_P; /**< Pointer to prime number P */
194 
195 /**
196  * @brief PKC Modular Subtraction expression input
197  * @note Result = (A - B) mod P
198  */
199 typedef struct _pkc_modular_sub
200 {
201  uint32_t *p_A; /**< Pointer to operand A */
202  uint32_t *p_B; /**< Pointer to operand B */
203  uint32_t *p_P; /**< Pointer to prime number P */
205 
206 /**
207  * @brief PKC Modular Left Shift expression input
208  * @note Result = (A << ShiftBits) mod P
209  */
210 typedef struct _pkc_modular_shift
211 {
212  uint32_t *p_A; /**< Pointer to operand A */
213  uint32_t shift_bits; /**< Pointer to operand A */
214  uint32_t *p_P; /**< Pointer to prime number P */
216 
217 /**
218  * @brief PKC Modular Comparison expression input
219  * @note Result = A mod P
220  */
221 typedef struct _pkc_modular_compare
222 {
223  uint32_t *p_A; /**< Pointer to operand A */
224  uint32_t *p_P; /**< Pointer to prime number P */
226 
227 /**
228  * @brief PKC Montgomery Modular Multiplication expression input
229  * @note Result = A * B * R^(-1) mod P, where R = 2^DataBits
230  */
231 typedef struct _pkc_montgomery_multi
232 {
233  uint32_t *p_A; /**< Pointer to operand A */
234  uint32_t *p_B; /**< Pointer to operand B */
235  uint32_t *p_P; /**< Pointer to prime number P */
236  uint32_t ConstP; /**< Montgomery multiplication constant for P,
237  where constp = (-P[0])^(-1) mod 2^32 */
239 
240 /**
241  * @brief PKC Montgomery Inversion expression input
242  * @note Result = A^(-1) * 2^(K) mod P
243  */
245 {
246  uint32_t *p_A; /**< Pointer to operand A */
247  uint32_t *p_P; /**< Pointer to prime number P */
248  uint32_t ConstP; /**< Montgomery multiplication constant for P,
249  where ConstP = (-P[0])^(-1) mod 2^32 */
251 
252 /**
253  * @brief PKC Big Number Multiplication expression input
254  * @note Result = A * B, up to 1024 bits
255  */
256 typedef struct _pkc_big_number_multi
257 {
258  uint32_t *p_A; /**< Pointer to operand A */
259  uint32_t *p_B; /**< Pointer to operand B */
261 
262 /**
263  * @brief PKC Big Number Addition expression input
264  * @note Result = A + B, up to 2048 bits
265  */
266 typedef struct _pkc_big_number_add
267 {
268  uint32_t *p_A; /**< Pointer to operand A */
269  uint32_t *p_B; /**< Pointer to operand B */
271 
272 /** @} */
273 
274 /** @} */
275 
276 /** @addtogroup HAL_PKC_CALLBACK_STRUCTURES Callback Structures
277  * @{
278  */
279 
280 /** @defgroup HAL_PKC_Callback Callback
281  * @{
282  */
283 
284 /**
285  * @brief HAL_PKC Callback function definition
286  */
287 
288 typedef struct _hal_pkc_callback
289 {
290  void (*pkc_msp_init)(pkc_handle_t *p_pkc); /**< PKC init MSP callback */
291  void (*pkc_msp_deinit)(pkc_handle_t *p_pkc); /**< PKC de-init MSP callback */
292  void (*pkc_done_callback)(pkc_handle_t *p_pkc); /**< PKC calculate done callback */
293  void (*pkc_error_callback)(pkc_handle_t *p_pkc); /**< PKC error callback */
294  void (*pkc_overflow_callback)(pkc_handle_t *p_pkc); /**< PKC over flow callback */
296 
297 /** @} */
298 
299 /** @} */
300 
301 /**
302  * @defgroup HAL_PKC_MACRO Defines
303  * @{
304  */
305 
306 /* Exported constants --------------------------------------------------------*/
307 /** @defgroup PKC_Exported_Constants PKC Exported Constants
308  * @{
309  */
310 
311 /** @defgroup PKC_Error_Code PKC Error Code
312  * @{
313  */
314 #define HAL_PKC_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
315 #define HAL_PKC_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
316 #define HAL_PKC_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
317 #define HAL_PKC_ERROR_OVERFLOW ((uint32_t)0x00000004) /**< Result overflow error */
318 #define HAL_PKC_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
319 #define HAL_PKC_ERROR_INVERSE_K ((uint32_t)0x00000010) /**< Inverse K error */
320 #define HAL_PKC_ERROR_IRREVERSIBLE ((uint32_t)0x00000020) /**< Irreversible error */
321 /** @} */
322 
323 /** @defgroup PKC_Secure_Mode PKC Secure Mode
324  * @{
325  */
326 #define PKC_SECURE_MODE_DISABLE ((uint32_t)0x00000000) /**< Secure mode disable */
327 #define PKC_SECURE_MODE_ENABLE ((uint32_t)0x00000001) /**< Secure mode enable */
328 /** @} */
329 
330 /** @defgroup PKC_Operation_Mode PKC Operation Mode
331  * @{
332  */
333 #define PKC_OPERATION_MODE_MULTI LL_PKC_operation_mode_MULTIPLY /**< Multiplication operation mode */
334 #define PKC_OPERATION_MODE_INVER LL_PKC_operation_mode_INVERTION /**< Inversion operation mode */
335 #define PKC_OPERATION_MODE_ADD LL_PKC_operation_mode_ADD /**< Addition operation mode */
336 #define PKC_OPERATION_MODE_SUB LL_PKC_operation_mode_SUB /**< Subtraction operation mode */
337 #define PKC_OPERATION_MODE_CMP LL_PKC_operation_mode_COMPARE /**< Comparison operation mode */
338 #define PKC_OPERATION_MODE_LSHIFT LL_PKC_operation_mode_LEFTSHIFT /**< Left Shift operation mode */
339 #define PKC_OPERATION_MODE_BIGMULTI LL_PKC_operation_mode_BIGINTEGERMULTIPLY /**< Big Number Multiplication operation mode */
340 #define PKC_OPERATION_MODE_BIGADD LL_PKC_operation_mode_BIGINTEGERADD /**< Big Number Addition operation mode */
341 /** @} */
342 
343 /** @defgroup PKC_Bits_Length PKC Bits Length
344  * @{
345  */
346 #define PKC_BITS_LENGTH_MIN LL_PKC_BITS_LENGTH_MIN /**< Min value of bits length */
347 #define PKC_BITS_LENGTH_MAX LL_PKC_BITS_LENGTH_MAX /**< Max value of bits length */
348 #define PKC_BIGMULTI_BITS_LENGTH_MAX LL_PKC_BIGMULTI_BITS_LENGTH_MAX /**< Max value of big number multiplication bits length */
349 /** @} */
350 
351 /** @defgroup PKC_Flags PKC Flags
352  * @{
353  */
354 #define PKC_FLAG_BUSY LL_PKC_WORKSTAT_BUSY /**< Busy flag */
355 /** @} */
356 
357 /** @defgroup PKC_Interrupt_definition PKC Interrupt_definition
358  * @{
359  */
360 #define PKC_IT_DONE LL_PKC_INTEN_DONE /**< Operation Done Interrupt source */
361 #define PKC_IT_ERR LL_PKC_INTEN_ERR /**< Operation Error Interrupt source */
362 #define PKC_IT_OVF LL_PKC_INTEN_BAOVF /**< Big Integer Result Overflow Interrupt source */
363 /** @} */
364 
365 /** @defgroup PKC_Timeout_definition PKC Timeout_definition
366  * @{
367  */
368 #define HAL_PKC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< The default value of PKC timeout is 5s */
369 /** @} */
370 
371 /** @} */
372 
373 /* Exported macro ------------------------------------------------------------*/
374 /** @defgroup PKC_Exported_Macros PKC Exported Macros
375  * @{
376  */
377 
378 /** @brief Reset PKC handle states.
379  * @param __HANDLE__ PKC handle.
380  * @retval None
381  */
382 #define __HAL_PKC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_PKC_STATE_RESET)
383 
384 /** @brief Reset the specified PKC peripheral.
385  * @param __HANDLE__ PKC handle.
386  * @retval None
387  */
388 #define __HAL_PKC_RESET(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_SWRST); \
389  SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_SWRST)
390 
391 /** @brief Enable the specified PKC peripheral.
392  * @param __HANDLE__ Specifies the PKC Handle.
393  * @retval None
394  */
395 #define __HAL_PKC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
396 
397 /** @brief Disable the specified PKC peripheral.
398  * @param __HANDLE__ Specifies the PKC Handle.
399  * @retval None
400  */
401 #define __HAL_PKC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
402 
403 /** @brief Enable the specified PKC interrupts.
404  * @param __HANDLE__ Specifies the PKC Handle.
405  * @param __INTERRUPT__ Specifies the interrupt source to enable.
406  * This parameter can be one of the following values:
407  * @arg @ref PKC_IT_DONE Operation Done Interrupt source
408  * @arg @ref PKC_IT_ERR Operation Error Interrupt source
409  * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
410  * @retval None
411  */
412 #define __HAL_PKC_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INTEN, (__INTERRUPT__))
413 
414 /** @brief Disable the specified PKC interrupts.
415  * @param __HANDLE__ Specifies the PKC Handle.
416  * @param __INTERRUPT__ Specifies the interrupt source to disable.
417  * This parameter can be one of the following values:
418  * @arg @ref PKC_IT_DONE Operation Done Interrupt source
419  * @arg @ref PKC_IT_ERR Operation Error Interrupt source
420  * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
421  * @retval None
422  */
423 #define __HAL_PKC_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INTEN, (__INTERRUPT__))
424 
425 /** @brief Check whether the specified PKC interrupt flag is set or not.
426  * @param __HANDLE__ Specifies the PKC Handle.
427  * @param __FLAG__ Specifies the interrupt flag to check.
428  * This parameter can be one of the following values:
429  * @arg @ref PKC_IT_DONE Operation Done Interrupt source
430  * @arg @ref PKC_IT_ERR Operation Error Interrupt source
431  * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
432  * @retval The new state of __FLAG__ (TRUE or FALSE).
433  */
434 #define __HAL_PKC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INTSTAT, (__FLAG__)) == (__FLAG__))
435 
436 /** @brief Clear the specified PKC interrupt flag.
437  * @param __HANDLE__ Specifies the PKC Handle.
438  * @param __FLAG__ Specifies the interrupt flag to clear.
439  * This parameter can be one of the following values:
440  * @arg @ref PKC_IT_DONE Operation Done Interrupt source
441  * @arg @ref PKC_IT_ERR Operation Error Interrupt source
442  * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
443  * @retval None
444  */
445 #define __HAL_PKC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INTSTAT, (__FLAG__))
446 
447 /** @brief Check whether the specified PKC flag is set or not.
448  * @param __HANDLE__ Specifies the PKC Handle.
449  * @param __FLAG__ Specifies the flag to check.
450  * This parameter can be one of the following values:
451  * @arg @ref PKC_FLAG_BUSY Busy flag
452  * @retval The new state of __FLAG__ (TRUE or FALSE).
453  */
454 #define __HAL_PKC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->WORKSTAT, (__FLAG__)) != 0) ? SET : RESET)
455 
456 /** @} */
457 
458 /* Private macros ------------------------------------------------------------*/
459 /** @defgroup PKC_Private_Macro PKC Private Macros
460  * @{
461  */
462 
463 /** @brief Check if PKC Bits Length is valid.
464  * @param __BITS__ PKC Bits Length.
465  * @retval SET (__BITS__ is valid) or RESET (__BITS__ is invalid)
466  */
467 #define IS_PKC_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BITS_LENGTH_MAX))
468 
469 /** @brief Check if PKC Big Number Multiplication Bits Length is valid.
470  * @param __BITS__ PKC Big Number Multiplication Bits Length.
471  * @retval SET (__BITS__ is valid) or RESET (__BITS__ is invalid)
472  */
473 #define IS_PKC_BIGMULTI_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BIGMULTI_BITS_LENGTH_MAX))
474 
475 /** @brief Check if PKC Secure Mode is valid.
476  * @param __MODE__ PKC Secure Mode.
477  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
478  */
479 #define IS_PKC_SECURE_MODE(__MODE__) (((__MODE__) == PKC_SECURE_MODE_DISABLE) || \
480  ((__MODE__) == PKC_SECURE_MODE_ENABLE))
481 
482 /** @brief Check if PKC Operation Mode is valid.
483  * @param __MODE__ PKC Operation Mode.
484  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
485  */
486 #define IS_PKC_OPERATION_MODE(__MODE__) (((__MODE__) == PKC_OPERATION_MODE_MULTI) || \
487  ((__MODE__) == PKC_OPERATION_MODE_INVER) || \
488  ((__MODE__) == PKC_OPERATION_MODE_ADD) || \
489  ((__MODE__) == PKC_OPERATION_MODE_SUB) || \
490  ((__MODE__) == PKC_OPERATION_MODE_CMP) || \
491  ((__MODE__) == PKC_OPERATION_MODE_LSHIFT) || \
492  ((__MODE__) == PKC_OPERATION_MODE_BIGMULTI) || \
493  ((__MODE__) == PKC_OPERATION_MODE_BIGADD))
494 
495 /** @} */
496 
497 /** @} */
498 
499 
500 
501 /* Exported functions --------------------------------------------------------*/
502 /** @addtogroup HAL_PKC_DRIVER_FUNCTIONS Functions
503  * @{
504  */
505 
506 /** @defgroup PKC_Exported_Functions_Group1 Initialization and de-initialization functions
507  * @brief Initialization and de-initialization functions
508  *
509 @verbatim
510  ===============================================================================
511  ##### Initialization and de-initialization functions #####
512  ===============================================================================
513  [..] This subsection provides a set of functions allowing to initialize and
514  de-initialize the PKC peripheral:
515 
516  (+) User must implement hal_pkc_msp_init() function in which it configures
517  all related peripherals resources (IT and NVIC ).
518 
519  (+) Call the function hal_pkc_init() to configure the selected device with
520  the selected configuration:
521  (++) pECC_Curve
522  (++) DataBits
523  (++) SecureMode
524  (++) pRandomFunc
525 
526  (+) Call the function hal_pkc_deinit() to restore the default configuration
527  of the selected PKC peripheral.
528 
529 @endverbatim
530  * @{
531  */
532 
533 /**
534  ****************************************************************************************
535  * @brief Initialize the PKC according to the specified parameters
536  * in the pkc_init_t and initialize the associated handle.
537  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
538  * information for the specified PKC module.
539  * @retval ::HAL_OK: Operation is OK.
540  * @retval ::HAL_ERROR: Parameter error or operation not supported.
541  * @retval ::HAL_BUSY: Driver is busy.
542  * @retval ::HAL_TIMEOUT: Timeout occurred.
543  ****************************************************************************************
544  */
546 
547 /**
548  ****************************************************************************************
549  * @brief De-initialize the PKC peripheral.
550  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
551  * information for the specified PKC module.
552  * @retval ::HAL_OK: Operation is OK.
553  * @retval ::HAL_ERROR: Parameter error or operation not supported.
554  * @retval ::HAL_BUSY: Driver is busy.
555  * @retval ::HAL_TIMEOUT: Timeout occurred.
556  ****************************************************************************************
557  */
559 
560 /**
561  ****************************************************************************************
562  * @brief Initialize the PKC MSP.
563  * @note This function should not be modified. When the callback is needed,
564  the hal_pkc_msp_deinit can be implemented in the user file.
565  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
566  * information for the specified PKC module.
567  ****************************************************************************************
568  */
570 
571 /**
572  ****************************************************************************************
573  * @brief De-initialize the PKC MSP.
574  * @note This function should not be modified. When the callback is needed,
575  the hal_pkc_msp_deinit can be implemented in the user file.
576  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
577  * information for the specified PKC module.
578  ****************************************************************************************
579  */
581 
582 /** @} */
583 
584 /** @defgroup PKC_Exported_Functions_Group2 IO Operation Functions
585  * @brief Data transfers functions
586  *
587 @verbatim
588  ==============================================================================
589  ##### IO operation functions #####
590  ===============================================================================
591  [..]
592  This subsection provides a set of functions allowing to manage the PKC
593  data transfers.
594 
595  (#) There are two modes of transfer:
596  (++) Blocking mode: The communication is performed in polling mode.
597  The HAL status of all data processing is returned by the same function
598  after finishing transfer.
599  (++) No-Blocking mode: The communication is performed using Interrupts
600  , These APIs return the HAL status.
601  The end of the data processing will be indicated through the
602  dedicated PKC IRQ when using Interrupt mode.
603  The hal_pkc_done_callback() user callbacks will be executed respectively at the end of the calculate process
604  The hal_pkc_error_callback() user callback will be executed when a communication error is detected
605 
606 @endverbatim
607  * @{
608  */
609 
610 /**
611  ****************************************************************************************
612  * @brief Execute RSA Modular Exponentiation in blocking mode.
613  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
614  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
615  * information for the specified PKC module.
616  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
617  * @param[in] timeout: Timeout duration
618  * @retval ::HAL_OK: Operation is OK.
619  * @retval ::HAL_ERROR: Parameter error or operation not supported.
620  * @retval ::HAL_BUSY: Driver is busy.
621  * @retval ::HAL_TIMEOUT: Timeout occurred.
622  ****************************************************************************************
623  */
625 
626 /**
627  ****************************************************************************************
628  * @brief Execute ECC Point Multiplication in blocking mode.
629  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
630  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
631  * information for the specified PKC module.
632  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
633  * @param[in] timeout: Timeout duration
634  * @retval ::HAL_OK: Operation is OK.
635  * @retval ::HAL_ERROR: Parameter error or operation not supported.
636  * @retval ::HAL_BUSY: Driver is busy.
637  * @retval ::HAL_TIMEOUT: Timeout occurred.
638  ****************************************************************************************
639  */
641 
642 /**
643  ****************************************************************************************
644  * @brief Execute ECC Point Multiplication in non-blocking mode with Interrupt.
645  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
646  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
647  * information for the specified PKC module.
648  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
649  * @retval ::HAL_OK: Operation is OK.
650  * @retval ::HAL_ERROR: Parameter error or operation not supported.
651  * @retval ::HAL_BUSY: Driver is busy.
652  * @retval ::HAL_TIMEOUT: Timeout occurred.
653  ****************************************************************************************
654  */
656 
657 /**
658  ****************************************************************************************
659  * @brief Execute Modular Addition in blocking mode.
660  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
661  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
662  * information for the specified PKC module.
663  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
664  * @param[in] timeout: Timeout duration
665  * @retval ::HAL_OK: Operation is OK.
666  * @retval ::HAL_ERROR: Parameter error or operation not supported.
667  * @retval ::HAL_BUSY: Driver is busy.
668  * @retval ::HAL_TIMEOUT: Timeout occurred.
669  ****************************************************************************************
670  */
672 
673 /**
674  ****************************************************************************************
675  * @brief Execute Modular Addition in non-blocking mode with Interrupt.
676  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
677  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
678  * information for the specified PKC module.
679  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
680  * @retval ::HAL_OK: Operation is OK.
681  * @retval ::HAL_ERROR: Parameter error or operation not supported.
682  * @retval ::HAL_BUSY: Driver is busy.
683  * @retval ::HAL_TIMEOUT: Timeout occurred.
684  ****************************************************************************************
685  */
687 
688 /**
689  ****************************************************************************************
690  * @brief Execute Modular Subtraction in blocking mode.
691  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
692  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
693  * information for the specified PKC module.
694  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
695  * @param[in] timeout: Timeout duration
696  * @retval ::HAL_OK: Operation is OK.
697  * @retval ::HAL_ERROR: Parameter error or operation not supported.
698  * @retval ::HAL_BUSY: Driver is busy.
699  * @retval ::HAL_TIMEOUT: Timeout occurred.
700  ****************************************************************************************
701  */
703 
704 /**
705  ****************************************************************************************
706  * @brief Execute Modular Subtraction in non-blocking mode with Interrupt.
707  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
708  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
709  * information for the specified PKC module.
710  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
711  * @retval ::HAL_OK: Operation is OK.
712  * @retval ::HAL_ERROR: Parameter error or operation not supported.
713  * @retval ::HAL_BUSY: Driver is busy.
714  * @retval ::HAL_TIMEOUT: Timeout occurred.
715  ****************************************************************************************
716  */
718 
719 /**
720  ****************************************************************************************
721  * @brief Execute Modular Left Shift in blocking mode.
722  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
723  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
724  * information for the specified PKC module.
725  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
726  * @param[in] timeout: Timeout duration
727  * @retval ::HAL_OK: Operation is OK.
728  * @retval ::HAL_ERROR: Parameter error or operation not supported.
729  * @retval ::HAL_BUSY: Driver is busy.
730  * @retval ::HAL_TIMEOUT: Timeout occurred.
731  ****************************************************************************************
732  */
734 
735 /**
736  ****************************************************************************************
737  * @brief Execute Modular Left Shift in non-blocking mode with Interrupt.
738  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
739  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
740  * information for the specified PKC module.
741  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
742  * @retval ::HAL_OK: Operation is OK.
743  * @retval ::HAL_ERROR: Parameter error or operation not supported.
744  * @retval ::HAL_BUSY: Driver is busy.
745  * @retval ::HAL_TIMEOUT: Timeout occurred.
746  ****************************************************************************************
747  */
749 
750 /**
751  ****************************************************************************************
752  * @brief Execute Modular Comparison in blocking mode.
753  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
754  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
755  * information for the specified PKC module.
756  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
757  * @param[in] timeout: Timeout duration
758  * @retval ::HAL_OK: Operation is OK.
759  * @retval ::HAL_ERROR: Parameter error or operation not supported.
760  * @retval ::HAL_BUSY: Driver is busy.
761  * @retval ::HAL_TIMEOUT: Timeout occurred.
762  ****************************************************************************************
763  */
765 
766 /**
767  ****************************************************************************************
768  * @brief Execute Modular Comparison in non-blocking mode with Interrupt.
769  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
770  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
771  * information for the specified PKC module.
772  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
773  * @retval ::HAL_OK: Operation is OK.
774  * @retval ::HAL_ERROR: Parameter error or operation not supported.
775  * @retval ::HAL_BUSY: Driver is busy.
776  * @retval ::HAL_TIMEOUT: Timeout occurred.
777  ****************************************************************************************
778  */
780 
781 /**
782  ****************************************************************************************
783  * @brief Execute Montgomery Modular Multiplication in blocking mode.
784  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
785  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
786  * information for the specified PKC module.
787  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
788  * @param[in] timeout: Timeout duration
789  * @retval ::HAL_OK: Operation is OK.
790  * @retval ::HAL_ERROR: Parameter error or operation not supported.
791  * @retval ::HAL_BUSY: Driver is busy.
792  * @retval ::HAL_TIMEOUT: Timeout occurred.
793  ****************************************************************************************
794  */
796 
797 /**
798  ****************************************************************************************
799  * @brief Execute Montgomery Modular Multiplication in non-blocking mode with Interrupt.
800  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
801  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
802  * information for the specified PKC module.
803  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
804  * @retval ::HAL_OK: Operation is OK.
805  * @retval ::HAL_ERROR: Parameter error or operation not supported.
806  * @retval ::HAL_BUSY: Driver is busy.
807  * @retval ::HAL_TIMEOUT: Timeout occurred.
808  ****************************************************************************************
809  */
811 
812 /**
813  ****************************************************************************************
814  * @brief Execute Montgomery Inversion in blocking mode.
815  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
816  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
817  * information for the specified PKC module.
818  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
819  * @param[in] timeout: Timeout duration
820  * @retval ::HAL_OK: Operation is OK.
821  * @retval ::HAL_ERROR: Parameter error or operation not supported.
822  * @retval ::HAL_BUSY: Driver is busy.
823  * @retval ::HAL_TIMEOUT: Timeout occurred.
824  ****************************************************************************************
825  */
827 
828 /**
829  ****************************************************************************************
830  * @brief Execute Montgomery Inversion in non-blocking mode with Interrupt.
831  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
832  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
833  * information for the specified PKC module.
834  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
835  * @retval ::HAL_OK: Operation is OK.
836  * @retval ::HAL_ERROR: Parameter error or operation not supported.
837  * @retval ::HAL_BUSY: Driver is busy.
838  * @retval ::HAL_TIMEOUT: Timeout occurred.
839  ****************************************************************************************
840  */
842 
843 /**
844  ****************************************************************************************
845  * @brief Execute Big Number Multiplication in blocking mode.
846  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
847  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
848  * information for the specified PKC module.
849  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
850  * @param[in] timeout: Timeout duration
851  * @retval ::HAL_OK: Operation is OK.
852  * @retval ::HAL_ERROR: Parameter error or operation not supported.
853  * @retval ::HAL_BUSY: Driver is busy.
854  * @retval ::HAL_TIMEOUT: Timeout occurred.
855  ****************************************************************************************
856  */
858 
859 /**
860  ****************************************************************************************
861  * @brief Execute Big Number Multiplication in non-blocking mode with Interrupt.
862  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
863  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
864  * information for the specified PKC module.
865  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
866  * @retval ::HAL_OK: Operation is OK.
867  * @retval ::HAL_ERROR: Parameter error or operation not supported.
868  * @retval ::HAL_BUSY: Driver is busy.
869  * @retval ::HAL_TIMEOUT: Timeout occurred.
870  ****************************************************************************************
871  */
873 
874 /**
875  ****************************************************************************************
876  * @brief Execute Big Number Addition in blocking mode.
877  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
878  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
879  * information for the specified PKC module.
880  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
881  * @param[in] timeout: Timeout duration
882  * @retval ::HAL_OK: Operation is OK.
883  * @retval ::HAL_ERROR: Parameter error or operation not supported.
884  * @retval ::HAL_BUSY: Driver is busy.
885  * @retval ::HAL_TIMEOUT: Timeout occurred.
886  ****************************************************************************************
887  */
889 
890 /**
891  ****************************************************************************************
892  * @brief Execute Big Number Addition in non-blocking mode with Interrupt.
893  * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
894  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
895  * information for the specified PKC module.
896  * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
897  * @retval ::HAL_OK: Operation is OK.
898  * @retval ::HAL_ERROR: Parameter error or operation not supported.
899  * @retval ::HAL_BUSY: Driver is busy.
900  * @retval ::HAL_TIMEOUT: Timeout occurred.
901  ****************************************************************************************
902  */
904 
905 /** @} */
906 
907 /** @addtogroup PKC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
908  * @brief IRQ Handler and Callbacks functions
909  * @{
910  */
911 
912 /**
913  ****************************************************************************************
914  * @brief Handle PKC interrupt request.
915  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
916  * information for the specified PKC module.
917  ****************************************************************************************
918  */
920 
921 /**
922  ****************************************************************************************
923  * @brief PKC calculate done callback.
924  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
925  * information for the specified PKC module.
926  ****************************************************************************************
927  */
929 
930 /**
931  ****************************************************************************************
932  * @brief PKC error callback.
933  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
934  * information for the specified PKC module.
935  ****************************************************************************************
936  */
938 
939 /**
940  ****************************************************************************************
941  * @brief PKC over flow callback.
942  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
943  * information for the specified PKC module.
944  ****************************************************************************************
945  */
947 
948 /** @} */
949 
950 /** @addtogroup PKC_Exported_Functions_Group3 Peripheral Control and State functions
951  * @brief PKC Peripheral State functions
952  *
953 @verbatim
954  ==============================================================================
955  ##### Peripheral Control and State functions #####
956  ==============================================================================
957  [..]
958  This subsection provides functions allowing to :
959  (+) Return the PKC handle state.
960  (+) Return the PKC handle error code.
961  (+) Set the timeout during internal process.
962 
963 @endverbatim
964  * @{
965  */
966 
967 /**
968  ****************************************************************************************
969  * @brief Return the PKC handle state.
970  * @param[in] p_pkc: Pointer to a pkc_handle_t structure that contains
971  * the configuration information for the specified PKC.
972  * @retval ::HAL_PKC_STATE_RESET: Peripheral not initialized.
973  * @retval ::HAL_PKC_STATE_READY: Peripheral initialized and ready for use.
974  * @retval ::HAL_PKC_STATE_BUSY: Peripheral in indirect mode and busy.
975  * @retval ::HAL_PKC_STATE_ERROR: Peripheral in error.
976  * @retval ::HAL_PKC_STATE_TIMEOUT: Peripheral in timeout.
977  ****************************************************************************************
978  */
980 
981 /**
982  ****************************************************************************************
983  * @brief Return the PKC error code.
984  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
985  * information for the specified PKC module.
986  * @return PKC error code in bitmap format
987  ****************************************************************************************
988  */
990 
991 /**
992  ****************************************************************************************
993  * @brief Set the PKC internal process timeout value.
994  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
995  * information for the specified PKC module.
996  * @param[in] timeout: Internal process timeout value.
997  ****************************************************************************************
998  */
999 void hal_pkc_set_timeout(pkc_handle_t *p_pkc, uint32_t timeout);
1000 
1001 /**
1002  ****************************************************************************************
1003  * @brief Suspend some registers related to PKC configuration before sleep.
1004  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1005  * information for the specified PKC module.
1006  * @retval ::HAL_OK: Operation is OK.
1007  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1008  * @retval ::HAL_BUSY: Driver is busy.
1009  * @retval ::HAL_TIMEOUT: Timeout occurred.
1010  ****************************************************************************************
1011  */
1012 
1014 /**
1015  ****************************************************************************************
1016  * @brief Restore some registers related to PKC configuration after sleep.
1017  * This function must be used in conjunction with the hal_hmac_suspend_reg().
1018  * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1019  * information for the specified PKC module.
1020  * @retval ::HAL_OK: Operation is OK.
1021  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1022  * @retval ::HAL_BUSY: Driver is busy.
1023  * @retval ::HAL_TIMEOUT: Timeout occurred.
1024  ****************************************************************************************
1025  */
1026 
1028 
1029 /** @} */
1030 
1031 /** @} */
1032 
1033 #ifdef __cplusplus
1034 }
1035 #endif
1036 
1037 #endif /* __GR55xx_HAL_PKC_H__ */
1038 
1039 /** @} */
1040 
1041 /** @} */
1042 
1043 /** @} */
hal_pkc_rsa_modular_exponent
hal_status_t hal_pkc_rsa_modular_exponent(pkc_handle_t *p_pkc, pkc_rsa_modular_exponent_t *p_input, uint32_t timeout)
Execute RSA Modular Exponentiation in blocking mode.
hal_pkc_montgomery_multi
hal_status_t hal_pkc_montgomery_multi(pkc_handle_t *p_pkc, pkc_montgomery_multi_t *p_input, uint32_t timeout)
Execute Montgomery Modular Multiplication in blocking mode.
_pkc_modular_sub::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:202
_pkc_modular_add::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:191
_pkc_big_number_add::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:268
_pkc_handle::p_instance
pkc_regs_t * p_instance
PKC registers base address
Definition: gr55xx_hal_pkc.h:135
_pkc_montgomery_multi::ConstP
uint32_t ConstP
Montgomery multiplication constant for P, where constp = (-P[0])^(-1) mod 2^32.
Definition: gr55xx_hal_pkc.h:236
_pkc_handle::shift_count
uint32_t shift_count
Count to left shift
Definition: gr55xx_hal_pkc.h:141
HAL_PKC_STATE_RESET
@ HAL_PKC_STATE_RESET
Peripheral not initialized
Definition: gr55xx_hal_pkc.h:77
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_pkc_montgomery_multi
PKC Montgomery Modular Multiplication expression input.
Definition: gr55xx_hal_pkc.h:232
hal_pkc_modular_sub
hal_status_t hal_pkc_modular_sub(pkc_handle_t *p_pkc, pkc_modular_sub_t *p_input, uint32_t timeout)
Execute Modular Subtraction in blocking mode.
_pkc_modular_shift::shift_bits
uint32_t shift_bits
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:213
_pkc_ecc_point_multi::p_ecc_point
ecc_point_t * p_ecc_point
Pointer to ECC Point.
Definition: gr55xx_hal_pkc.h:168
_pkc_modular_sub::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:203
_pkc_montgomery_multi::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:233
_pkc_montgomery_inversion
PKC Montgomery Inversion expression input.
Definition: gr55xx_hal_pkc.h:245
_pkc_big_number_add::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:269
hal_pkc_montgomery_inversion
hal_status_t hal_pkc_montgomery_inversion(pkc_handle_t *p_pkc, pkc_montgomery_inversion_t *p_input, uint32_t timeout)
Execute Montgomery Inversion in blocking mode.
_pkc_modular_shift
PKC Modular Left Shift expression input.
Definition: gr55xx_hal_pkc.h:211
hal_pkc_modular_compare
hal_status_t hal_pkc_modular_compare(pkc_handle_t *p_pkc, pkc_modular_compare_t *p_input, uint32_t timeout)
Execute Modular Comparison in blocking mode.
pkc_montgomery_inversion_t
struct _pkc_montgomery_inversion pkc_montgomery_inversion_t
PKC Montgomery Inversion expression input.
_pkc_montgomery_inversion::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:247
hal_pkc_resume_reg
hal_status_t hal_pkc_resume_reg(pkc_handle_t *p_pkc)
Restore some registers related to PKC configuration after sleep.
hal_pkc_ecc_point_multi
hal_status_t hal_pkc_ecc_point_multi(pkc_handle_t *p_pkc, pkc_ecc_point_multi_t *p_input, uint32_t timeout)
Execute ECC Point Multiplication in blocking mode.
_pkc_handle::state
__IO hal_pkc_state_t state
PKC operation state
Definition: gr55xx_hal_pkc.h:147
_hal_pkc_callback::pkc_error_callback
void(* pkc_error_callback)(pkc_handle_t *p_pkc)
PKC error callback
Definition: gr55xx_hal_pkc.h:293
HAL_PKC_STATE_READY
@ HAL_PKC_STATE_READY
Peripheral initialized and ready for use
Definition: gr55xx_hal_pkc.h:78
_pkc_modular_compare
PKC Modular Comparison expression input.
Definition: gr55xx_hal_pkc.h:222
_pkc_handle::error_code
__IO uint32_t error_code
PKC Error code
Definition: gr55xx_hal_pkc.h:149
_pkc_modular_add::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:190
pkc_init_t::p_ecc_curve
ecc_curve_init_t * p_ecc_curve
Specifies the pointer to elliptic curve description.
Definition: gr55xx_hal_pkc.h:112
_pkc_handle::retention
uint32_t retention[1]
pkc important register information.
Definition: gr55xx_hal_pkc.h:153
_pkc_modular_shift::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:214
hal_pkc_modular_left_shift_it
hal_status_t hal_pkc_modular_left_shift_it(pkc_handle_t *p_pkc, pkc_modular_shift_t *p_input)
Execute Modular Left Shift in non-blocking mode with Interrupt.
_pkc_handle
PKC handle Structure definition.
Definition: gr55xx_hal_pkc.h:134
_pkc_big_number_add
PKC Big Number Addition expression input.
Definition: gr55xx_hal_pkc.h:267
hal_pkc_init
hal_status_t hal_pkc_init(pkc_handle_t *p_pkc)
Initialize the PKC according to the specified parameters in the pkc_init_t and initialize the associa...
hal_pkc_get_state
hal_pkc_state_t hal_pkc_get_state(pkc_handle_t *p_pkc)
Return the PKC handle state.
HAL_PKC_STATE_TIMEOUT
@ HAL_PKC_STATE_TIMEOUT
Peripheral in timeout
Definition: gr55xx_hal_pkc.h:81
gr55xx_ll_pkc.h
Header file containing functions prototypes of PKC LL library.
_pkc_montgomery_multi::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:234
_ll_ecc_curve_init
LL PKC ECC P-256 Elliptic Curve Init Structure definition.
Definition: gr55xx_ll_pkc.h:103
_pkc_handle::p_P
uint32_t * p_P
Prime number
Definition: gr55xx_hal_pkc.h:143
pkc_modular_sub_t
struct _pkc_modular_sub pkc_modular_sub_t
PKC Modular Subtraction expression input.
hal_pkc_deinit
hal_status_t hal_pkc_deinit(pkc_handle_t *p_pkc)
De-initialize the PKC peripheral.
_pkc_ecc_point_multi::p_K
uint32_t * p_K
Pointer to operand K.
Definition: gr55xx_hal_pkc.h:167
_pkc_modular_add::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:192
hal_pkc_suspend_reg
hal_status_t hal_pkc_suspend_reg(pkc_handle_t *p_pkc)
Suspend some registers related to PKC configuration before sleep.
_pkc_handle::lock
__IO hal_lock_t lock
Locking object
Definition: gr55xx_hal_pkc.h:145
pkc_ecc_point_multi_t
struct _pkc_ecc_point_multi pkc_ecc_point_multi_t
PKC ECC Point Multiplication expression input.
pkc_big_number_multi_t
struct _pkc_big_number_multi pkc_big_number_multi_t
PKC Big Number Multiplication expression input.
hal_pkc_montgomery_multi_it
hal_status_t hal_pkc_montgomery_multi_it(pkc_handle_t *p_pkc, pkc_montgomery_multi_t *p_input)
Execute Montgomery Modular Multiplication in non-blocking mode with Interrupt.
hal_pkc_modular_add
hal_status_t hal_pkc_modular_add(pkc_handle_t *p_pkc, pkc_modular_add_t *p_input, uint32_t timeout)
Execute Modular Addition in blocking mode.
_pkc_big_number_multi::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:258
pkc_init_t::secure_mode
uint32_t secure_mode
Specifies the Secure Mode.
Definition: gr55xx_hal_pkc.h:116
hal_pkc_modular_sub_it
hal_status_t hal_pkc_modular_sub_it(pkc_handle_t *p_pkc, pkc_modular_sub_t *p_input)
Execute Modular Subtraction in non-blocking mode with Interrupt.
pkc_init_t
PKC Init Structure definition.
Definition: gr55xx_hal_pkc.h:111
hal_pkc_msp_init
void hal_pkc_msp_init(pkc_handle_t *p_pkc)
Initialize the PKC MSP.
HAL_PKC_STATE_ERROR
@ HAL_PKC_STATE_ERROR
Peripheral in error
Definition: gr55xx_hal_pkc.h:80
_pkc_modular_sub
PKC Modular Subtraction expression input.
Definition: gr55xx_hal_pkc.h:200
pkc_modular_compare_t
struct _pkc_modular_compare pkc_modular_compare_t
PKC Modular Comparison expression input.
_pkc_modular_compare::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:223
_pkc_rsa_modular_exponent::p_P_R2
uint32_t * p_P_R2
P_R2 = R^2 mod P, where R = 2^DataBits
Definition: gr55xx_hal_pkc.h:180
hal_pkc_msp_deinit
void hal_pkc_msp_deinit(pkc_handle_t *p_pkc)
De-initialize the PKC MSP.
_pkc_montgomery_inversion::ConstP
uint32_t ConstP
Montgomery multiplication constant for P, where ConstP = (-P[0])^(-1) mod 2^32.
Definition: gr55xx_hal_pkc.h:248
_pkc_handle::init
pkc_init_t init
PKC operation parameters
Definition: gr55xx_hal_pkc.h:137
hal_pkc_overflow_callback
void hal_pkc_overflow_callback(pkc_handle_t *p_pkc)
PKC over flow callback.
_pkc_handle::p_result
void * p_result
Pointer to PKC result buffer
Definition: gr55xx_hal_pkc.h:139
_pkc_handle::timeout
uint32_t timeout
Timeout for the PKC operation
Definition: gr55xx_hal_pkc.h:151
_pkc_rsa_modular_exponent::ConstP
uint32_t ConstP
Montgomery multiplication constant of P.
Definition: gr55xx_hal_pkc.h:181
_ll_ecc_point
LL PKC ECC Point Structure definition.
Definition: gr55xx_ll_pkc.h:92
_pkc_modular_sub::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:201
_hal_pkc_callback::pkc_done_callback
void(* pkc_done_callback)(pkc_handle_t *p_pkc)
PKC calculate done callback
Definition: gr55xx_hal_pkc.h:292
_pkc_ecc_point_multi
PKC ECC Point Multiplication expression input.
Definition: gr55xx_hal_pkc.h:166
pkc_big_number_add_t
struct _pkc_big_number_add pkc_big_number_add_t
PKC Big Number Addition expression input.
hal_pkc_modular_left_shift
hal_status_t hal_pkc_modular_left_shift(pkc_handle_t *p_pkc, pkc_modular_shift_t *p_input, uint32_t timeout)
Execute Modular Left Shift in blocking mode.
pkc_modular_shift_t
struct _pkc_modular_shift pkc_modular_shift_t
PKC Modular Left Shift expression input.
_pkc_rsa_modular_exponent::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:178
pkc_init_t::data_bits
uint32_t data_bits
Specifies the Data size: 256 ~ 2048 bits
Definition: gr55xx_hal_pkc.h:114
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_pkc_done_callback
void hal_pkc_done_callback(pkc_handle_t *p_pkc)
PKC calculate done callback.
_pkc_big_number_multi::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:259
_pkc_rsa_modular_exponent::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:177
_pkc_montgomery_inversion::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:246
hal_pkc_big_number_add_it
hal_status_t hal_pkc_big_number_add_it(pkc_handle_t *p_pkc, pkc_big_number_add_t *p_input)
Execute Big Number Addition in non-blocking mode with Interrupt.
_pkc_montgomery_multi::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:235
hal_pkc_modular_add_it
hal_status_t hal_pkc_modular_add_it(pkc_handle_t *p_pkc, pkc_modular_add_t *p_input)
Execute Modular Addition in non-blocking mode with Interrupt.
hal_pkc_error_callback
void hal_pkc_error_callback(pkc_handle_t *p_pkc)
PKC error callback.
hal_pkc_big_number_add
hal_status_t hal_pkc_big_number_add(pkc_handle_t *p_pkc, pkc_big_number_add_t *p_input, uint32_t timeout)
Execute Big Number Addition in blocking mode.
hal_pkc_montgomery_inversion_it
hal_status_t hal_pkc_montgomery_inversion_it(pkc_handle_t *p_pkc, pkc_montgomery_inversion_t *p_input)
Execute Montgomery Inversion in non-blocking mode with Interrupt.
hal_pkc_big_number_multi_it
hal_status_t hal_pkc_big_number_multi_it(pkc_handle_t *p_pkc, pkc_big_number_multi_t *p_input)
Execute Big Number Multiplication in non-blocking mode with Interrupt.
HAL_PKC_STATE_BUSY
@ HAL_PKC_STATE_BUSY
Peripheral in indirect mode and busy
Definition: gr55xx_hal_pkc.h:79
hal_pkc_modular_compare_it
hal_status_t hal_pkc_modular_compare_it(pkc_handle_t *p_pkc, pkc_modular_compare_t *p_input)
Execute Modular Comparison in non-blocking mode with Interrupt.
hal_pkc_irq_handler
void hal_pkc_irq_handler(pkc_handle_t *p_pkc)
Handle PKC interrupt request.
pkc_modular_add_t
struct _pkc_modular_add pkc_modular_add_t
PKC Modular Addition expression input.
_hal_pkc_callback
HAL_PKC Callback function definition.
Definition: gr55xx_hal_pkc.h:289
_pkc_modular_add
PKC Modular Addition expression input.
Definition: gr55xx_hal_pkc.h:189
_pkc_big_number_multi
PKC Big Number Multiplication expression input.
Definition: gr55xx_hal_pkc.h:257
_pkc_modular_shift::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:212
pkc_rsa_modular_exponent_t
struct _pkc_rsa_modular_exponent pkc_rsa_modular_exponent_t
PKC RSA Modular Exponentiation expression input.
hal_pkc_state_t
hal_pkc_state_t
HAL PKC State Enumerations definition.
Definition: gr55xx_hal_pkc.h:76
_hal_pkc_callback::pkc_msp_deinit
void(* pkc_msp_deinit)(pkc_handle_t *p_pkc)
PKC de-init MSP callback
Definition: gr55xx_hal_pkc.h:291
_hal_pkc_callback::pkc_overflow_callback
void(* pkc_overflow_callback)(pkc_handle_t *p_pkc)
PKC over flow callback
Definition: gr55xx_hal_pkc.h:294
hal_pkc_callback_t
struct _hal_pkc_callback hal_pkc_callback_t
HAL_PKC Callback function definition.
_pkc_rsa_modular_exponent::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:179
_pkc_modular_compare::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:224
pkc_handle_t
struct _pkc_handle pkc_handle_t
PKC handle Structure definition.
_hal_pkc_callback::pkc_msp_init
void(* pkc_msp_init)(pkc_handle_t *p_pkc)
PKC init MSP callback
Definition: gr55xx_hal_pkc.h:290
_pkc_rsa_modular_exponent
PKC RSA Modular Exponentiation expression input.
Definition: gr55xx_hal_pkc.h:176
pkc_montgomery_multi_t
struct _pkc_montgomery_multi pkc_montgomery_multi_t
PKC Montgomery Modular Multiplication expression input.
hal_pkc_get_error
uint32_t hal_pkc_get_error(pkc_handle_t *p_pkc)
Return the PKC error code.
hal_pkc_big_number_multi
hal_status_t hal_pkc_big_number_multi(pkc_handle_t *p_pkc, pkc_big_number_multi_t *p_input, uint32_t timeout)
Execute Big Number Multiplication in blocking mode.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_pkc_set_timeout
void hal_pkc_set_timeout(pkc_handle_t *p_pkc, uint32_t timeout)
Set the PKC internal process timeout value.
hal_pkc_ecc_point_multi_it
hal_status_t hal_pkc_ecc_point_multi_it(pkc_handle_t *p_pkc, pkc_ecc_point_multi_t *p_input)
Execute ECC Point Multiplication in non-blocking mode with Interrupt.