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
83 } hal_pkc_state_t;
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. */
154 } pkc_handle_t;
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 */
169 } pkc_ecc_point_multi_t;
170
171 /**
172 * @brief PKC RSA Modular Exponentiation expression input
173 * @note Result = A^B mod P
174 */
175 typedef struct _pkc_rsa_modular_exponent
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 */
182 } pkc_rsa_modular_exponent_t;
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 */
193 } pkc_modular_add_t;
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 */
204 } pkc_modular_sub_t;
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 */
215 } pkc_modular_shift_t;
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 */
225 } pkc_modular_compare_t;
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 */
238 } pkc_montgomery_multi_t;
239
240 /**
241 * @brief PKC Montgomery Inversion expression input
242 * @note Result = A^(-1) * 2^(K) mod P
243 */
244 typedef struct _pkc_montgomery_inversion
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 */
250 } pkc_montgomery_inversion_t;
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 */
260 } pkc_big_number_multi_t;
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 */
270 } pkc_big_number_add_t;
271
272 /** @} */
273
274 /** @} */
275
276 /** @addtogroup HAL_PKC_CALLBACK_STRUCTURES Callback Structures
277 * @{
278 */
279
280 /** @defgroup PKC_Callback PKC 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 */
295 } hal_pkc_callback_t;
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
389 #define __HAL_PKC_RESET(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_RST); \
390 SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_RST)
391
392 /** @brief Enable the specified PKC peripheral.
393 * @param __HANDLE__ Specifies the PKC Handle.
394 * @retval None
395 */
396 #define __HAL_PKC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
397
398 /** @brief Disable the specified PKC peripheral.
399 * @param __HANDLE__ Specifies the PKC Handle.
400 * @retval None
401 */
402 #define __HAL_PKC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
403
404 /** @brief Enable the specified PKC interrupts.
405 * @param __HANDLE__ Specifies the PKC Handle.
406 * @param __INTERRUPT__ Specifies the interrupt source to enable.
407 * This parameter can be one of the following values:
408 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
409 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
410 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
411 * @retval None
412 */
413
414 #define __HAL_PKC_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INT_EN, (__INTERRUPT__))
415
416 /** @brief Disable the specified PKC interrupts.
417 * @param __HANDLE__ Specifies the PKC Handle.
418 * @param __INTERRUPT__ Specifies the interrupt source to disable.
419 * This parameter can be one of the following values:
420 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
421 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
422 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
423 * @retval None
424 */
425
426 #define __HAL_PKC_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INT_EN, (__INTERRUPT__))
427
428 /** @brief Check whether the specified PKC interrupt flag is set or not.
429 * @param __HANDLE__ Specifies the PKC Handle.
430 * @param __FLAG__ Specifies the interrupt flag to check.
431 * This parameter can be one of the following values:
432 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
433 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
434 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
435 * @retval The new state of __FLAG__ (TRUE or FALSE).
436 */
437
438 #define __HAL_PKC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INT_STAT, (__FLAG__)) == (__FLAG__))
439
440 /** @brief Clear the specified PKC interrupt flag.
441 * @param __HANDLE__ Specifies the PKC Handle.
442 * @param __FLAG__ Specifies the interrupt flag to clear.
443 * This parameter can be one of the following values:
444 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
445 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
446 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
447 * @retval None
448 */
449
450 #define __HAL_PKC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INT_STAT, (__FLAG__))
451
452 /** @brief Check whether the specified PKC flag is set or not.
453 * @param __HANDLE__ Specifies the PKC Handle.
454 * @param __FLAG__ Specifies the flag to check.
455 * This parameter can be one of the following values:
456 * @arg @ref PKC_FLAG_BUSY Busy flag
457 * @retval The new state of __FLAG__ (TRUE or FALSE).
458 */
459
460 #define __HAL_PKC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
461
462 /** @} */
463
464 /* Private macros ------------------------------------------------------------*/
465 /** @defgroup PKC_Private_Macro PKC Private Macros
466 * @{
467 */
468
469 /** @brief Check if PKC Bits Length is valid.
470 * @param __BITS__ PKC Bits Length.
471 * @retval SET (__BITS__ is valid) or RESET (__BITS__ is invalid)
472 */
473 #define IS_PKC_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BITS_LENGTH_MAX))
474
475 /** @brief Check if PKC Big Number Multiplication Bits Length is valid.
476 * @param __BITS__ PKC Big Number Multiplication Bits Length.
477 * @retval SET (__BITS__ is valid) or RESET (__BITS__ is invalid)
478 */
479 #define IS_PKC_BIGMULTI_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BIGMULTI_BITS_LENGTH_MAX))
480
481 /** @brief Check if PKC Secure Mode is valid.
482 * @param __MODE__ PKC Secure Mode.
483 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
484 */
485 #define IS_PKC_SECURE_MODE(__MODE__) (((__MODE__) == PKC_SECURE_MODE_DISABLE) || \
486 ((__MODE__) == PKC_SECURE_MODE_ENABLE))
487
488 /** @brief Check if PKC Operation Mode is valid.
489 * @param __MODE__ PKC Operation Mode.
490 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
491 */
492 #define IS_PKC_OPERATION_MODE(__MODE__) (((__MODE__) == PKC_OPERATION_MODE_MULTI) || \
493 ((__MODE__) == PKC_OPERATION_MODE_INVER) || \
494 ((__MODE__) == PKC_OPERATION_MODE_ADD) || \
495 ((__MODE__) == PKC_OPERATION_MODE_SUB) || \
496 ((__MODE__) == PKC_OPERATION_MODE_CMP) || \
497 ((__MODE__) == PKC_OPERATION_MODE_LSHIFT) || \
498 ((__MODE__) == PKC_OPERATION_MODE_BIGMULTI) || \
499 ((__MODE__) == PKC_OPERATION_MODE_BIGADD))
500
501 /** @} */
502
503 /** @} */
504
505
506
507 /* Exported functions --------------------------------------------------------*/
508 /** @addtogroup HAL_PKC_DRIVER_FUNCTIONS Functions
509 * @{
510 */
511
512 /** @defgroup PKC_Exported_Functions_Group1 Initialization and de-initialization functions
513 * @brief Initialization and de-initialization functions
514 *
515 @verbatim
516 ===============================================================================
517 ##### Initialization and de-initialization functions #####
518 ===============================================================================
519 [..] This subsection provides a set of functions allowing to initialize and
520 de-initialize the PKC peripheral:
521
522 (+) User must implement hal_pkc_msp_init() function in which it configures
523 all related peripherals resources (IT and NVIC ).
524
525 (+) Call the function hal_pkc_init() to configure the selected device with
526 the selected configuration:
527 (++) pECC_Curve
528 (++) DataBits
529 (++) SecureMode
530 (++) pRandomFunc
531
532 (+) Call the function hal_pkc_deinit() to restore the default configuration
533 of the selected PKC peripheral.
534
535 @endverbatim
536 * @{
537 */
538
539 /**
540 ****************************************************************************************
541 * @brief Initialize the PKC according to the specified parameters
542 * in the pkc_init_t and initialize the associated handle.
543 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
544 * information for the specified PKC module.
545 * @retval ::HAL_OK: Operation is OK.
546 * @retval ::HAL_ERROR: Parameter error or operation not supported.
547 * @retval ::HAL_BUSY: Driver is busy.
548 * @retval ::HAL_TIMEOUT: Timeout occurred.
549 ****************************************************************************************
550 */
551 hal_status_t hal_pkc_init(pkc_handle_t *p_pkc);
552
553 /**
554 ****************************************************************************************
555 * @brief De-initialize the PKC peripheral.
556 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
557 * information for the specified PKC module.
558 * @retval ::HAL_OK: Operation is OK.
559 * @retval ::HAL_ERROR: Parameter error or operation not supported.
560 * @retval ::HAL_BUSY: Driver is busy.
561 * @retval ::HAL_TIMEOUT: Timeout occurred.
562 ****************************************************************************************
563 */
564 hal_status_t hal_pkc_deinit(pkc_handle_t *p_pkc);
565
566 /**
567 ****************************************************************************************
568 * @brief Initialize the PKC MSP.
569 * @note This function should not be modified. When the callback is needed,
570 the hal_pkc_msp_deinit can be implemented in the user file.
571 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
572 * information for the specified PKC module.
573 ****************************************************************************************
574 */
575 void hal_pkc_msp_init(pkc_handle_t *p_pkc);
576
577 /**
578 ****************************************************************************************
579 * @brief De-initialize the PKC MSP.
580 * @note This function should not be modified. When the callback is needed,
581 the hal_pkc_msp_deinit can be implemented in the user file.
582 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
583 * information for the specified PKC module.
584 ****************************************************************************************
585 */
586 void hal_pkc_msp_deinit(pkc_handle_t *p_pkc);
587
588 /** @} */
589
590 /** @defgroup PKC_Exported_Functions_Group2 IO Operation Functions
591 * @brief Data transfers functions
592 *
593 @verbatim
594 ==============================================================================
595 ##### IO operation functions #####
596 ===============================================================================
597 [..]
598 This subsection provides a set of functions allowing to manage the PKC
599 data transfers.
600
601 (#) There are two modes of transfer:
602 (++) Blocking mode: The communication is performed in polling mode.
603 The HAL status of all data processing is returned by the same function
604 after finishing transfer.
605 (++) No-Blocking mode: The communication is performed using Interrupts
606 , These APIs return the HAL status.
607 The end of the data processing will be indicated through the
608 dedicated PKC IRQ when using Interrupt mode.
609 The hal_pkc_done_callback() user callbacks will be executed respectively at the end of the calculate process
610 The hal_pkc_error_callback() user callback will be executed when a communication error is detected
611
612 @endverbatim
613 * @{
614 */
615
616 /**
617 ****************************************************************************************
618 * @brief Execute RSA Modular Exponentiation in blocking mode.
619 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
620 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
621 * information for the specified PKC module.
622 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
623 * @param[in] timeout: Timeout duration
624 * @retval ::HAL_OK: Operation is OK.
625 * @retval ::HAL_ERROR: Parameter error or operation not supported.
626 * @retval ::HAL_BUSY: Driver is busy.
627 * @retval ::HAL_TIMEOUT: Timeout occurred.
628 ****************************************************************************************
629 */
630 hal_status_t hal_pkc_rsa_modular_exponent(pkc_handle_t *p_pkc, pkc_rsa_modular_exponent_t *p_input, uint32_t timeout);
631
632 /**
633 ****************************************************************************************
634 * @brief Execute ECC Point Multiplication in blocking mode.
635 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
636 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
637 * information for the specified PKC module.
638 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
639 * @param[in] timeout: Timeout duration
640 * @retval ::HAL_OK: Operation is OK.
641 * @retval ::HAL_ERROR: Parameter error or operation not supported.
642 * @retval ::HAL_BUSY: Driver is busy.
643 * @retval ::HAL_TIMEOUT: Timeout occurred.
644 ****************************************************************************************
645 */
646 hal_status_t hal_pkc_ecc_point_multi(pkc_handle_t *p_pkc, pkc_ecc_point_multi_t *p_input, uint32_t timeout);
647
648 /**
649 ****************************************************************************************
650 * @brief Execute ECC Point Multiplication in non-blocking mode with Interrupt.
651 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
652 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
653 * information for the specified PKC module.
654 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
655 * @retval ::HAL_OK: Operation is OK.
656 * @retval ::HAL_ERROR: Parameter error or operation not supported.
657 * @retval ::HAL_BUSY: Driver is busy.
658 * @retval ::HAL_TIMEOUT: Timeout occurred.
659 ****************************************************************************************
660 */
661 hal_status_t hal_pkc_ecc_point_multi_it(pkc_handle_t *p_pkc, pkc_ecc_point_multi_t *p_input);
662
663 /**
664 ****************************************************************************************
665 * @brief Execute Modular Addition in blocking mode.
666 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
667 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
668 * information for the specified PKC module.
669 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
670 * @param[in] timeout: Timeout duration
671 * @retval ::HAL_OK: Operation is OK.
672 * @retval ::HAL_ERROR: Parameter error or operation not supported.
673 * @retval ::HAL_BUSY: Driver is busy.
674 * @retval ::HAL_TIMEOUT: Timeout occurred.
675 ****************************************************************************************
676 */
677 hal_status_t hal_pkc_modular_add(pkc_handle_t *p_pkc, pkc_modular_add_t *p_input, uint32_t timeout);
678
679 /**
680 ****************************************************************************************
681 * @brief Execute Modular Addition in non-blocking mode with Interrupt.
682 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
683 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
684 * information for the specified PKC module.
685 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
686 * @retval ::HAL_OK: Operation is OK.
687 * @retval ::HAL_ERROR: Parameter error or operation not supported.
688 * @retval ::HAL_BUSY: Driver is busy.
689 * @retval ::HAL_TIMEOUT: Timeout occurred.
690 ****************************************************************************************
691 */
692 hal_status_t hal_pkc_modular_add_it(pkc_handle_t *p_pkc, pkc_modular_add_t *p_input);
693
694 /**
695 ****************************************************************************************
696 * @brief Execute Modular Subtraction in blocking mode.
697 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
698 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
699 * information for the specified PKC module.
700 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
701 * @param[in] timeout: Timeout duration
702 * @retval ::HAL_OK: Operation is OK.
703 * @retval ::HAL_ERROR: Parameter error or operation not supported.
704 * @retval ::HAL_BUSY: Driver is busy.
705 * @retval ::HAL_TIMEOUT: Timeout occurred.
706 ****************************************************************************************
707 */
708 hal_status_t hal_pkc_modular_sub(pkc_handle_t *p_pkc, pkc_modular_sub_t *p_input, uint32_t timeout);
709
710 /**
711 ****************************************************************************************
712 * @brief Execute Modular Subtraction in non-blocking mode with Interrupt.
713 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
714 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
715 * information for the specified PKC module.
716 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
717 * @retval ::HAL_OK: Operation is OK.
718 * @retval ::HAL_ERROR: Parameter error or operation not supported.
719 * @retval ::HAL_BUSY: Driver is busy.
720 * @retval ::HAL_TIMEOUT: Timeout occurred.
721 ****************************************************************************************
722 */
723 hal_status_t hal_pkc_modular_sub_it(pkc_handle_t *p_pkc, pkc_modular_sub_t *p_input);
724
725 /**
726 ****************************************************************************************
727 * @brief Execute Modular Left Shift in blocking mode.
728 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
729 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
730 * information for the specified PKC module.
731 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
732 * @param[in] timeout: Timeout duration
733 * @retval ::HAL_OK: Operation is OK.
734 * @retval ::HAL_ERROR: Parameter error or operation not supported.
735 * @retval ::HAL_BUSY: Driver is busy.
736 * @retval ::HAL_TIMEOUT: Timeout occurred.
737 ****************************************************************************************
738 */
739 hal_status_t hal_pkc_modular_left_shift(pkc_handle_t *p_pkc, pkc_modular_shift_t *p_input, uint32_t timeout);
740
741 /**
742 ****************************************************************************************
743 * @brief Execute Modular Left Shift in non-blocking mode with Interrupt.
744 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
745 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
746 * information for the specified PKC module.
747 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
748 * @retval ::HAL_OK: Operation is OK.
749 * @retval ::HAL_ERROR: Parameter error or operation not supported.
750 * @retval ::HAL_BUSY: Driver is busy.
751 * @retval ::HAL_TIMEOUT: Timeout occurred.
752 ****************************************************************************************
753 */
754 hal_status_t hal_pkc_modular_left_shift_it(pkc_handle_t *p_pkc, pkc_modular_shift_t *p_input);
755
756 /**
757 ****************************************************************************************
758 * @brief Execute Modular Comparison in blocking mode.
759 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
760 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
761 * information for the specified PKC module.
762 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
763 * @param[in] timeout: Timeout duration
764 * @retval ::HAL_OK: Operation is OK.
765 * @retval ::HAL_ERROR: Parameter error or operation not supported.
766 * @retval ::HAL_BUSY: Driver is busy.
767 * @retval ::HAL_TIMEOUT: Timeout occurred.
768 ****************************************************************************************
769 */
770 hal_status_t hal_pkc_modular_compare(pkc_handle_t *p_pkc, pkc_modular_compare_t *p_input, uint32_t timeout);
771
772 /**
773 ****************************************************************************************
774 * @brief Execute Modular Comparison in non-blocking mode with Interrupt.
775 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
776 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
777 * information for the specified PKC module.
778 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
779 * @retval ::HAL_OK: Operation is OK.
780 * @retval ::HAL_ERROR: Parameter error or operation not supported.
781 * @retval ::HAL_BUSY: Driver is busy.
782 * @retval ::HAL_TIMEOUT: Timeout occurred.
783 ****************************************************************************************
784 */
785 hal_status_t hal_pkc_modular_compare_it(pkc_handle_t *p_pkc, pkc_modular_compare_t *p_input);
786
787 /**
788 ****************************************************************************************
789 * @brief Execute Montgomery Modular Multiplication in blocking mode.
790 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
791 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
792 * information for the specified PKC module.
793 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
794 * @param[in] timeout: Timeout duration
795 * @retval ::HAL_OK: Operation is OK.
796 * @retval ::HAL_ERROR: Parameter error or operation not supported.
797 * @retval ::HAL_BUSY: Driver is busy.
798 * @retval ::HAL_TIMEOUT: Timeout occurred.
799 ****************************************************************************************
800 */
801 hal_status_t hal_pkc_montgomery_multi(pkc_handle_t *p_pkc, pkc_montgomery_multi_t *p_input, uint32_t timeout);
802
803 /**
804 ****************************************************************************************
805 * @brief Execute Montgomery Modular Multiplication in non-blocking mode with Interrupt.
806 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
807 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
808 * information for the specified PKC module.
809 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
810 * @retval ::HAL_OK: Operation is OK.
811 * @retval ::HAL_ERROR: Parameter error or operation not supported.
812 * @retval ::HAL_BUSY: Driver is busy.
813 * @retval ::HAL_TIMEOUT: Timeout occurred.
814 ****************************************************************************************
815 */
816 hal_status_t hal_pkc_montgomery_multi_it(pkc_handle_t *p_pkc, pkc_montgomery_multi_t *p_input);
817
818 /**
819 ****************************************************************************************
820 * @brief Execute Montgomery Inversion in blocking mode.
821 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
822 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
823 * information for the specified PKC module.
824 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
825 * @param[in] timeout: Timeout duration
826 * @retval ::HAL_OK: Operation is OK.
827 * @retval ::HAL_ERROR: Parameter error or operation not supported.
828 * @retval ::HAL_BUSY: Driver is busy.
829 * @retval ::HAL_TIMEOUT: Timeout occurred.
830 ****************************************************************************************
831 */
832 hal_status_t hal_pkc_montgomery_inversion(pkc_handle_t *p_pkc, pkc_montgomery_inversion_t *p_input, uint32_t timeout);
833
834 /**
835 ****************************************************************************************
836 * @brief Execute Montgomery Inversion in non-blocking mode with Interrupt.
837 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
838 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
839 * information for the specified PKC module.
840 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
841 * @retval ::HAL_OK: Operation is OK.
842 * @retval ::HAL_ERROR: Parameter error or operation not supported.
843 * @retval ::HAL_BUSY: Driver is busy.
844 * @retval ::HAL_TIMEOUT: Timeout occurred.
845 ****************************************************************************************
846 */
847 hal_status_t hal_pkc_montgomery_inversion_it(pkc_handle_t *p_pkc, pkc_montgomery_inversion_t *p_input);
848
849 /**
850 ****************************************************************************************
851 * @brief Execute Big Number Multiplication in blocking mode.
852 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
853 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
854 * information for the specified PKC module.
855 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
856 * @param[in] timeout: Timeout duration
857 * @retval ::HAL_OK: Operation is OK.
858 * @retval ::HAL_ERROR: Parameter error or operation not supported.
859 * @retval ::HAL_BUSY: Driver is busy.
860 * @retval ::HAL_TIMEOUT: Timeout occurred.
861 ****************************************************************************************
862 */
863 hal_status_t hal_pkc_big_number_multi(pkc_handle_t *p_pkc, pkc_big_number_multi_t *p_input, uint32_t timeout);
864
865 /**
866 ****************************************************************************************
867 * @brief Execute Big Number Multiplication in non-blocking mode with Interrupt.
868 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
869 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
870 * information for the specified PKC module.
871 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
872 * @retval ::HAL_OK: Operation is OK.
873 * @retval ::HAL_ERROR: Parameter error or operation not supported.
874 * @retval ::HAL_BUSY: Driver is busy.
875 * @retval ::HAL_TIMEOUT: Timeout occurred.
876 ****************************************************************************************
877 */
878 hal_status_t hal_pkc_big_number_multi_it(pkc_handle_t *p_pkc, pkc_big_number_multi_t *p_input);
879
880 /**
881 ****************************************************************************************
882 * @brief Execute Big Number Addition in blocking mode.
883 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
884 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
885 * information for the specified PKC module.
886 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
887 * @param[in] timeout: Timeout duration
888 * @retval ::HAL_OK: Operation is OK.
889 * @retval ::HAL_ERROR: Parameter error or operation not supported.
890 * @retval ::HAL_BUSY: Driver is busy.
891 * @retval ::HAL_TIMEOUT: Timeout occurred.
892 ****************************************************************************************
893 */
894 hal_status_t hal_pkc_big_number_add(pkc_handle_t *p_pkc, pkc_big_number_add_t *p_input, uint32_t timeout);
895
896 /**
897 ****************************************************************************************
898 * @brief Execute Big Number Addition in non-blocking mode with Interrupt.
899 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
900 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
901 * information for the specified PKC module.
902 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
903 * @retval ::HAL_OK: Operation is OK.
904 * @retval ::HAL_ERROR: Parameter error or operation not supported.
905 * @retval ::HAL_BUSY: Driver is busy.
906 * @retval ::HAL_TIMEOUT: Timeout occurred.
907 ****************************************************************************************
908 */
909 hal_status_t hal_pkc_big_number_add_it(pkc_handle_t *p_pkc, pkc_big_number_add_t *p_input);
910
911 /** @} */
912
913 /** @addtogroup PKC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
914 * @brief IRQ Handler and Callbacks functions
915 * @{
916 */
917
918 /**
919 ****************************************************************************************
920 * @brief Handle PKC interrupt request.
921 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
922 * information for the specified PKC module.
923 ****************************************************************************************
924 */
925 void hal_pkc_irq_handler(pkc_handle_t *p_pkc);
926
927 /**
928 ****************************************************************************************
929 * @brief PKC calculate done callback.
930 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
931 * information for the specified PKC module.
932 ****************************************************************************************
933 */
934 void hal_pkc_done_callback(pkc_handle_t *p_pkc);
935
936 /**
937 ****************************************************************************************
938 * @brief PKC error callback.
939 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
940 * information for the specified PKC module.
941 ****************************************************************************************
942 */
943 void hal_pkc_error_callback(pkc_handle_t *p_pkc);
944
945 /**
946 ****************************************************************************************
947 * @brief PKC over flow callback.
948 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
949 * information for the specified PKC module.
950 ****************************************************************************************
951 */
952 void hal_pkc_overflow_callback(pkc_handle_t *p_pkc);
953
954 /** @} */
955
956 /** @addtogroup PKC_Exported_Functions_Group3 Peripheral Control and State functions
957 * @brief PKC Peripheral State functions
958 *
959 @verbatim
960 ==============================================================================
961 ##### Peripheral Control and State functions #####
962 ==============================================================================
963 [..]
964 This subsection provides functions allowing to :
965 (+) Return the PKC handle state.
966 (+) Return the PKC handle error code.
967 (+) Set the timeout during internal process.
968
969 @endverbatim
970 * @{
971 */
972
973 /**
974 ****************************************************************************************
975 * @brief Return the PKC handle state.
976 * @param[in] p_pkc: Pointer to a pkc_handle_t structure that contains
977 * the configuration information for the specified PKC.
978 * @retval ::HAL_PKC_STATE_RESET: Peripheral not initialized.
979 * @retval ::HAL_PKC_STATE_READY: Peripheral initialized and ready for use.
980 * @retval ::HAL_PKC_STATE_BUSY: Peripheral in indirect mode and busy.
981 * @retval ::HAL_PKC_STATE_ERROR: Peripheral in error.
982 * @retval ::HAL_PKC_STATE_TIMEOUT: Peripheral in timeout.
983 ****************************************************************************************
984 */
985 hal_pkc_state_t hal_pkc_get_state(pkc_handle_t *p_pkc);
986
987 /**
988 ****************************************************************************************
989 * @brief Return the PKC error code.
990 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
991 * information for the specified PKC module.
992 * @return PKC error code in bitmap format
993 ****************************************************************************************
994 */
995 uint32_t hal_pkc_get_error(pkc_handle_t *p_pkc);
996
997 /**
998 ****************************************************************************************
999 * @brief Set the PKC internal process timeout value.
1000 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1001 * information for the specified PKC module.
1002 * @param[in] timeout: Internal process timeout value.
1003 ****************************************************************************************
1004 */
1005 void hal_pkc_set_timeout(pkc_handle_t *p_pkc, uint32_t timeout);
1006
1007 /**
1008 ****************************************************************************************
1009 * @brief Suspend some registers related to PKC configuration before sleep.
1010 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1011 * information for the specified PKC module.
1012 * @retval ::HAL_OK: Operation is OK.
1013 * @retval ::HAL_ERROR: Parameter error or operation not supported.
1014 * @retval ::HAL_BUSY: Driver is busy.
1015 * @retval ::HAL_TIMEOUT: Timeout occurred.
1016 ****************************************************************************************
1017 */
1018
1019 hal_status_t hal_pkc_suspend_reg(pkc_handle_t *p_pkc);
1020 /**
1021 ****************************************************************************************
1022 * @brief Restore some registers related to PKC configuration after sleep.
1023 * This function must be used in conjunction with the hal_hmac_suspend_reg().
1024 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1025 * information for the specified PKC module.
1026 * @retval ::HAL_OK: Operation is OK.
1027 * @retval ::HAL_ERROR: Parameter error or operation not supported.
1028 * @retval ::HAL_BUSY: Driver is busy.
1029 * @retval ::HAL_TIMEOUT: Timeout occurred.
1030 ****************************************************************************************
1031 */
1032
1033 hal_status_t hal_pkc_resume_reg(pkc_handle_t *p_pkc);
1034
1035 /** @} */
1036
1037 /** @} */
1038
1039 #ifdef __cplusplus
1040 }
1041 #endif
1042
1043 #endif /* __GR55xx_HAL_PKC_H__ */
1044
1045 /** @} */
1046
1047 /** @} */
1048
1049 /** @} */
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
hal_pkc_callback_t
struct _hal_pkc_callback hal_pkc_callback_t
HAL_PKC Callback function definition.
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
_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.