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. If set to NULL, it will be
169 modified to the G point of the current curve. */
170 } pkc_ecc_point_multi_t;
171
172 /**
173 * @brief PKC RSA Modular Exponentiation expression input
174 * @note Result = A^B mod P
175 */
176 typedef struct _pkc_rsa_modular_exponent
177 {
178 uint32_t *p_A; /**< Pointer to operand A */
179 uint32_t *p_B; /**< Pointer to operand B */
180 uint32_t *p_P; /**< Pointer to prime number P */
181 uint32_t *p_P_R2; /**< P_R2 = R^2 mod P, where R = 2^DataBits */
182 uint32_t ConstP; /**< Montgomery multiplication constant of P */
183 } pkc_rsa_modular_exponent_t;
184
185 /**
186 * @brief PKC Modular Addition expression input
187 * @note Result = (A + B) mod P
188 */
189 typedef struct _pkc_modular_add
190 {
191 uint32_t *p_A; /**< Pointer to operand A */
192 uint32_t *p_B; /**< Pointer to operand B */
193 uint32_t *p_P; /**< Pointer to prime number P */
194 } pkc_modular_add_t;
195
196 /**
197 * @brief PKC Modular Subtraction expression input
198 * @note Result = (A - B) mod P
199 */
200 typedef struct _pkc_modular_sub
201 {
202 uint32_t *p_A; /**< Pointer to operand A */
203 uint32_t *p_B; /**< Pointer to operand B */
204 uint32_t *p_P; /**< Pointer to prime number P */
205 } pkc_modular_sub_t;
206
207 /**
208 * @brief PKC Modular Left Shift expression input
209 * @note Result = (A << ShiftBits) mod P
210 */
211 typedef struct _pkc_modular_shift
212 {
213 uint32_t *p_A; /**< Pointer to operand A */
214 uint32_t shift_bits; /**< Pointer to operand A */
215 uint32_t *p_P; /**< Pointer to prime number P */
216 } pkc_modular_shift_t;
217
218 /**
219 * @brief PKC Modular Comparison expression input
220 * @note Result = A mod P
221 */
222 typedef struct _pkc_modular_compare
223 {
224 uint32_t *p_A; /**< Pointer to operand A */
225 uint32_t *p_P; /**< Pointer to prime number P */
226 } pkc_modular_compare_t;
227
228 /**
229 * @brief PKC Montgomery Modular Multiplication expression input
230 * @note Result = A * B * R^(-1) mod P, where R = 2^DataBits
231 */
232 typedef struct _pkc_montgomery_multi
233 {
234 uint32_t *p_A; /**< Pointer to operand A */
235 uint32_t *p_B; /**< Pointer to operand B */
236 uint32_t *p_P; /**< Pointer to prime number P */
237 uint32_t ConstP; /**< Montgomery multiplication constant for P,
238 where constp = (-P[0])^(-1) mod 2^32 */
239 } pkc_montgomery_multi_t;
240
241 /**
242 * @brief PKC Montgomery Inversion expression input
243 * @note Result = A^(-1) * 2^(K) mod P
244 */
245 typedef struct _pkc_montgomery_inversion
246 {
247 uint32_t *p_A; /**< Pointer to operand A */
248 uint32_t *p_P; /**< Pointer to prime number P */
249 uint32_t ConstP; /**< Montgomery multiplication constant for P,
250 where ConstP = (-P[0])^(-1) mod 2^32 */
251 } pkc_montgomery_inversion_t;
252
253 /**
254 * @brief PKC Big Number Multiplication expression input
255 * @note Result = A * B, up to 1024 bits
256 */
257 typedef struct _pkc_big_number_multi
258 {
259 uint32_t *p_A; /**< Pointer to operand A */
260 uint32_t *p_B; /**< Pointer to operand B */
261 } pkc_big_number_multi_t;
262
263 /**
264 * @brief PKC Big Number Addition expression input
265 * @note Result = A + B, up to 2048 bits
266 */
267 typedef struct _pkc_big_number_add
268 {
269 uint32_t *p_A; /**< Pointer to operand A */
270 uint32_t *p_B; /**< Pointer to operand B */
271 } pkc_big_number_add_t;
272
273 /** @} */
274
275 /** @} */
276
277 /** @addtogroup HAL_PKC_CALLBACK_STRUCTURES Callback Structures
278 * @{
279 */
280
281 /** @defgroup HAL_PKC_Callback Callback
282 * @{
283 */
284
285 /**
286 * @brief HAL_PKC Callback function definition
287 */
288
289 typedef struct _hal_pkc_callback
290 {
291 void (*pkc_msp_init)(pkc_handle_t *p_pkc); /**< PKC init MSP callback */
292 void (*pkc_msp_deinit)(pkc_handle_t *p_pkc); /**< PKC de-init MSP callback */
293 void (*pkc_done_callback)(pkc_handle_t *p_pkc); /**< PKC calculate done callback */
294 void (*pkc_error_callback)(pkc_handle_t *p_pkc); /**< PKC error callback */
295 void (*pkc_overflow_callback)(pkc_handle_t *p_pkc); /**< PKC over flow callback */
296 } hal_pkc_callback_t;
297
298 /** @} */
299
300 /** @} */
301
302 /**
303 * @defgroup HAL_PKC_MACRO Defines
304 * @{
305 */
306
307 /* Exported constants --------------------------------------------------------*/
308 /** @defgroup PKC_Exported_Constants PKC Exported Constants
309 * @{
310 */
311
312 /** @defgroup PKC_Error_Code PKC Error Code
313 * @{
314 */
315 #define HAL_PKC_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
316 #define HAL_PKC_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
317 #define HAL_PKC_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
318 #define HAL_PKC_ERROR_OVERFLOW ((uint32_t)0x00000004) /**< Result overflow error */
319 #define HAL_PKC_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
320 #define HAL_PKC_ERROR_INVERSE_K ((uint32_t)0x00000010) /**< Inverse K error */
321 #define HAL_PKC_ERROR_IRREVERSIBLE ((uint32_t)0x00000020) /**< Irreversible error */
322 /** @} */
323
324 /** @defgroup PKC_Secure_Mode PKC Secure Mode
325 * @{
326 */
327 #define PKC_SECURE_MODE_DISABLE ((uint32_t)0x00000000) /**< Secure mode disable */
328 #define PKC_SECURE_MODE_ENABLE ((uint32_t)0x00000001) /**< Secure mode enable */
329 /** @} */
330
331 /** @defgroup PKC_Operation_Mode PKC Operation Mode
332 * @{
333 */
334 #define PKC_OPERATION_MODE_MULTI LL_PKC_operation_mode_MULTIPLY /**< Multiplication operation mode */
335 #define PKC_OPERATION_MODE_INVER LL_PKC_operation_mode_INVERTION /**< Inversion operation mode */
336 #define PKC_OPERATION_MODE_ADD LL_PKC_operation_mode_ADD /**< Addition operation mode */
337 #define PKC_OPERATION_MODE_SUB LL_PKC_operation_mode_SUB /**< Subtraction operation mode */
338 #define PKC_OPERATION_MODE_CMP LL_PKC_operation_mode_COMPARE /**< Comparison operation mode */
339 #define PKC_OPERATION_MODE_LSHIFT LL_PKC_operation_mode_LEFTSHIFT /**< Left Shift operation mode */
340 #define PKC_OPERATION_MODE_BIGMULTI LL_PKC_operation_mode_BIGINTEGERMULTIPLY /**< Big Number Multiplication operation mode */
341 #define PKC_OPERATION_MODE_BIGADD LL_PKC_operation_mode_BIGINTEGERADD /**< Big Number Addition operation mode */
342 /** @} */
343
344 /** @defgroup PKC_Bits_Length PKC Bits Length
345 * @{
346 */
347 #define PKC_BITS_LENGTH_MIN LL_PKC_BITS_LENGTH_MIN /**< Min value of bits length */
348 #define PKC_BITS_LENGTH_MAX LL_PKC_BITS_LENGTH_MAX /**< Max value of bits length */
349 #define PKC_BIGMULTI_BITS_LENGTH_MAX LL_PKC_BIGMULTI_BITS_LENGTH_MAX /**< Max value of big number multiplication bits length */
350 /** @} */
351
352 /** @defgroup PKC_Flags PKC Flags
353 * @{
354 */
355 #define PKC_FLAG_BUSY LL_PKC_WORKSTAT_BUSY /**< Busy flag */
356 /** @} */
357
358 /** @defgroup PKC_Interrupt_definition PKC Interrupt_definition
359 * @{
360 */
361 #define PKC_IT_DONE LL_PKC_INTEN_DONE /**< Operation Done Interrupt source */
362 #define PKC_IT_ERR LL_PKC_INTEN_ERR /**< Operation Error Interrupt source */
363 #define PKC_IT_OVF LL_PKC_INTEN_BAOVF /**< Big Integer Result Overflow Interrupt source */
364 /** @} */
365
366 /** @defgroup PKC_Timeout_definition PKC Timeout_definition
367 * @{
368 */
369 #define HAL_PKC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< The default value of PKC timeout is 5s */
370 /** @} */
371
372 /** @} */
373
374 /* Exported macro ------------------------------------------------------------*/
375 /** @defgroup PKC_Exported_Macros PKC Exported Macros
376 * @{
377 */
378
379 /** @brief Reset PKC handle states.
380 * @param __HANDLE__ PKC handle.
381 * @retval None
382 */
383 #define __HAL_PKC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_PKC_STATE_RESET)
384
385 /** @brief Reset the specified PKC peripheral.
386 * @param __HANDLE__ PKC handle.
387 * @retval None
388 */
389 #define __HAL_PKC_RESET(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_SWRST); \
390 SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_SWRST)
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 #define __HAL_PKC_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INTEN, (__INTERRUPT__))
414
415 /** @brief Disable the specified PKC interrupts.
416 * @param __HANDLE__ Specifies the PKC Handle.
417 * @param __INTERRUPT__ Specifies the interrupt source to disable.
418 * This parameter can be one of the following values:
419 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
420 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
421 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
422 * @retval None
423 */
424 #define __HAL_PKC_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INTEN, (__INTERRUPT__))
425
426 /** @brief Check whether the specified PKC interrupt flag is set or not.
427 * @param __HANDLE__ Specifies the PKC Handle.
428 * @param __FLAG__ Specifies the interrupt flag to check.
429 * This parameter can be one of the following values:
430 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
431 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
432 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
433 * @retval The new state of __FLAG__ (TRUE or FALSE).
434 */
435 #define __HAL_PKC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INTSTAT, (__FLAG__)) == (__FLAG__))
436
437 /** @brief Clear the specified PKC interrupt flag.
438 * @param __HANDLE__ Specifies the PKC Handle.
439 * @param __FLAG__ Specifies the interrupt flag to clear.
440 * This parameter can be one of the following values:
441 * @arg @ref PKC_IT_DONE Operation Done Interrupt source
442 * @arg @ref PKC_IT_ERR Operation Error Interrupt source
443 * @arg @ref PKC_IT_OVF Big Integer Result Overflow Interrupt source
444 * @retval None
445 */
446 #define __HAL_PKC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INTSTAT, (__FLAG__))
447
448 /** @brief Check whether the specified PKC flag is set or not.
449 * @param __HANDLE__ Specifies the PKC Handle.
450 * @param __FLAG__ Specifies the flag to check.
451 * This parameter can be one of the following values:
452 * @arg @ref PKC_FLAG_BUSY Busy flag
453 * @retval The new state of __FLAG__ (TRUE or FALSE).
454 */
455 #define __HAL_PKC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->WORKSTAT, (__FLAG__)) != 0) ? SET : RESET)
456
457 /** @} */
458
459 /* Private macros ------------------------------------------------------------*/
460 /** @defgroup PKC_Private_Macro PKC Private Macros
461 * @{
462 */
463
464 /** @brief Check if PKC Bits Length is valid.
465 * @param __BITS__ PKC Bits Length.
466 * @retval SET (__BITS__ is valid) or RESET (__BITS__ is invalid)
467 */
468 #define IS_PKC_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BITS_LENGTH_MAX))
469
470 /** @brief Check if PKC Big Number Multiplication Bits Length is valid.
471 * @param __BITS__ PKC Big Number Multiplication Bits Length.
472 * @retval SET (__BITS__ is valid) or RESET (__BITS__ is invalid)
473 */
474 #define IS_PKC_BIGMULTI_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BIGMULTI_BITS_LENGTH_MAX))
475
476 /** @brief Check if PKC Secure Mode is valid.
477 * @param __MODE__ PKC Secure Mode.
478 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
479 */
480 #define IS_PKC_SECURE_MODE(__MODE__) (((__MODE__) == PKC_SECURE_MODE_DISABLE) || \
481 ((__MODE__) == PKC_SECURE_MODE_ENABLE))
482
483 /** @brief Check if PKC Operation Mode is valid.
484 * @param __MODE__ PKC Operation Mode.
485 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
486 */
487 #define IS_PKC_OPERATION_MODE(__MODE__) (((__MODE__) == PKC_OPERATION_MODE_MULTI) || \
488 ((__MODE__) == PKC_OPERATION_MODE_INVER) || \
489 ((__MODE__) == PKC_OPERATION_MODE_ADD) || \
490 ((__MODE__) == PKC_OPERATION_MODE_SUB) || \
491 ((__MODE__) == PKC_OPERATION_MODE_CMP) || \
492 ((__MODE__) == PKC_OPERATION_MODE_LSHIFT) || \
493 ((__MODE__) == PKC_OPERATION_MODE_BIGMULTI) || \
494 ((__MODE__) == PKC_OPERATION_MODE_BIGADD))
495
496 /** @} */
497
498 /** @} */
499
500
501
502 /* Exported functions --------------------------------------------------------*/
503 /** @addtogroup HAL_PKC_DRIVER_FUNCTIONS Functions
504 * @{
505 */
506
507 /** @defgroup PKC_Exported_Functions_Group1 Initialization and de-initialization functions
508 * @brief Initialization and de-initialization functions
509 *
510 @verbatim
511 ===============================================================================
512 ##### Initialization and de-initialization functions #####
513 ===============================================================================
514 [..] This subsection provides a set of functions allowing to initialize and
515 de-initialize the PKC peripheral:
516
517 (+) User must implement hal_pkc_msp_init() function in which it configures
518 all related peripherals resources (IT and NVIC ).
519
520 (+) Call the function hal_pkc_init() to configure the selected device with
521 the selected configuration:
522 (++) pECC_Curve
523 (++) DataBits
524 (++) SecureMode
525 (++) pRandomFunc
526
527 (+) Call the function hal_pkc_deinit() to restore the default configuration
528 of the selected PKC peripheral.
529
530 @endverbatim
531 * @{
532 */
533
534 /**
535 ****************************************************************************************
536 * @brief Initialize the PKC according to the specified parameters
537 * in the pkc_init_t and initialize the associated handle.
538 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
539 * information for the specified PKC module.
540 * @retval ::HAL_OK: Operation is OK.
541 * @retval ::HAL_ERROR: Parameter error or operation not supported.
542 * @retval ::HAL_BUSY: Driver is busy.
543 * @retval ::HAL_TIMEOUT: Timeout occurred.
544 ****************************************************************************************
545 */
546 hal_status_t hal_pkc_init(pkc_handle_t *p_pkc);
547
548 /**
549 ****************************************************************************************
550 * @brief De-initialize the PKC peripheral.
551 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
552 * information for the specified PKC module.
553 * @retval ::HAL_OK: Operation is OK.
554 * @retval ::HAL_ERROR: Parameter error or operation not supported.
555 * @retval ::HAL_BUSY: Driver is busy.
556 * @retval ::HAL_TIMEOUT: Timeout occurred.
557 ****************************************************************************************
558 */
559 hal_status_t hal_pkc_deinit(pkc_handle_t *p_pkc);
560
561 /**
562 ****************************************************************************************
563 * @brief Initialize the PKC MSP.
564 * @note This function should not be modified. When the callback is needed,
565 the hal_pkc_msp_deinit can be implemented in the user file.
566 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
567 * information for the specified PKC module.
568 ****************************************************************************************
569 */
570 void hal_pkc_msp_init(pkc_handle_t *p_pkc);
571
572 /**
573 ****************************************************************************************
574 * @brief De-initialize the PKC MSP.
575 * @note This function should not be modified. When the callback is needed,
576 the hal_pkc_msp_deinit can be implemented in the user file.
577 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
578 * information for the specified PKC module.
579 ****************************************************************************************
580 */
581 void hal_pkc_msp_deinit(pkc_handle_t *p_pkc);
582
583 /** @} */
584
585 /** @defgroup PKC_Exported_Functions_Group2 IO Operation Functions
586 * @brief Data transfers functions
587 *
588 @verbatim
589 ==============================================================================
590 ##### IO operation functions #####
591 ===============================================================================
592 [..]
593 This subsection provides a set of functions allowing to manage the PKC
594 data transfers.
595
596 (#) There are two modes of transfer:
597 (++) Blocking mode: The communication is performed in polling mode.
598 The HAL status of all data processing is returned by the same function
599 after finishing transfer.
600 (++) No-Blocking mode: The communication is performed using Interrupts
601 , These APIs return the HAL status.
602 The end of the data processing will be indicated through the
603 dedicated PKC IRQ when using Interrupt mode.
604 The hal_pkc_done_callback() user callbacks will be executed respectively at the end of the calculate process
605 The hal_pkc_error_callback() user callback will be executed when a communication error is detected
606
607 @endverbatim
608 * @{
609 */
610
611 /**
612 ****************************************************************************************
613 * @brief Execute RSA Modular Exponentiation in blocking mode.
614 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
615 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
616 * information for the specified PKC module.
617 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
618 * @param[in] timeout: Timeout duration
619 * @retval ::HAL_OK: Operation is OK.
620 * @retval ::HAL_ERROR: Parameter error or operation not supported.
621 * @retval ::HAL_BUSY: Driver is busy.
622 * @retval ::HAL_TIMEOUT: Timeout occurred.
623 ****************************************************************************************
624 */
625 hal_status_t hal_pkc_rsa_modular_exponent(pkc_handle_t *p_pkc, pkc_rsa_modular_exponent_t *p_input, uint32_t timeout);
626
627 /**
628 ****************************************************************************************
629 * @brief Execute ECC Point Multiplication in blocking mode.
630 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
631 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
632 * information for the specified PKC module.
633 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
634 * @param[in] timeout: Timeout duration
635 * @retval ::HAL_OK: Operation is OK.
636 * @retval ::HAL_ERROR: Parameter error or operation not supported.
637 * @retval ::HAL_BUSY: Driver is busy.
638 * @retval ::HAL_TIMEOUT: Timeout occurred.
639 ****************************************************************************************
640 */
641 hal_status_t hal_pkc_ecc_point_multi(pkc_handle_t *p_pkc, pkc_ecc_point_multi_t *p_input, uint32_t timeout);
642
643 /**
644 ****************************************************************************************
645 * @brief Execute ECC Point Multiplication in non-blocking mode with Interrupt.
646 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
647 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
648 * information for the specified PKC module.
649 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
650 * @retval ::HAL_OK: Operation is OK.
651 * @retval ::HAL_ERROR: Parameter error or operation not supported.
652 * @retval ::HAL_BUSY: Driver is busy.
653 * @retval ::HAL_TIMEOUT: Timeout occurred.
654 ****************************************************************************************
655 */
656 hal_status_t hal_pkc_ecc_point_multi_it(pkc_handle_t *p_pkc, pkc_ecc_point_multi_t *p_input);
657
658 /**
659 ****************************************************************************************
660 * @brief Execute Modular Addition in blocking mode.
661 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
662 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
663 * information for the specified PKC module.
664 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
665 * @param[in] timeout: Timeout duration
666 * @retval ::HAL_OK: Operation is OK.
667 * @retval ::HAL_ERROR: Parameter error or operation not supported.
668 * @retval ::HAL_BUSY: Driver is busy.
669 * @retval ::HAL_TIMEOUT: Timeout occurred.
670 ****************************************************************************************
671 */
672 hal_status_t hal_pkc_modular_add(pkc_handle_t *p_pkc, pkc_modular_add_t *p_input, uint32_t timeout);
673
674 /**
675 ****************************************************************************************
676 * @brief Execute Modular Addition in non-blocking mode with Interrupt.
677 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
678 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
679 * information for the specified PKC module.
680 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
681 * @retval ::HAL_OK: Operation is OK.
682 * @retval ::HAL_ERROR: Parameter error or operation not supported.
683 * @retval ::HAL_BUSY: Driver is busy.
684 * @retval ::HAL_TIMEOUT: Timeout occurred.
685 ****************************************************************************************
686 */
687 hal_status_t hal_pkc_modular_add_it(pkc_handle_t *p_pkc, pkc_modular_add_t *p_input);
688
689 /**
690 ****************************************************************************************
691 * @brief Execute Modular Subtraction in blocking mode.
692 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
693 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
694 * information for the specified PKC module.
695 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
696 * @param[in] timeout: Timeout duration
697 * @retval ::HAL_OK: Operation is OK.
698 * @retval ::HAL_ERROR: Parameter error or operation not supported.
699 * @retval ::HAL_BUSY: Driver is busy.
700 * @retval ::HAL_TIMEOUT: Timeout occurred.
701 ****************************************************************************************
702 */
703 hal_status_t hal_pkc_modular_sub(pkc_handle_t *p_pkc, pkc_modular_sub_t *p_input, uint32_t timeout);
704
705 /**
706 ****************************************************************************************
707 * @brief Execute Modular Subtraction in non-blocking mode with Interrupt.
708 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
709 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
710 * information for the specified PKC module.
711 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
712 * @retval ::HAL_OK: Operation is OK.
713 * @retval ::HAL_ERROR: Parameter error or operation not supported.
714 * @retval ::HAL_BUSY: Driver is busy.
715 * @retval ::HAL_TIMEOUT: Timeout occurred.
716 ****************************************************************************************
717 */
718 hal_status_t hal_pkc_modular_sub_it(pkc_handle_t *p_pkc, pkc_modular_sub_t *p_input);
719
720 /**
721 ****************************************************************************************
722 * @brief Execute Modular Left Shift in blocking mode.
723 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
724 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
725 * information for the specified PKC module.
726 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
727 * @param[in] timeout: Timeout duration
728 * @retval ::HAL_OK: Operation is OK.
729 * @retval ::HAL_ERROR: Parameter error or operation not supported.
730 * @retval ::HAL_BUSY: Driver is busy.
731 * @retval ::HAL_TIMEOUT: Timeout occurred.
732 ****************************************************************************************
733 */
734 hal_status_t hal_pkc_modular_left_shift(pkc_handle_t *p_pkc, pkc_modular_shift_t *p_input, uint32_t timeout);
735
736 /**
737 ****************************************************************************************
738 * @brief Execute Modular Left Shift in non-blocking mode with Interrupt.
739 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
740 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
741 * information for the specified PKC module.
742 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
743 * @retval ::HAL_OK: Operation is OK.
744 * @retval ::HAL_ERROR: Parameter error or operation not supported.
745 * @retval ::HAL_BUSY: Driver is busy.
746 * @retval ::HAL_TIMEOUT: Timeout occurred.
747 ****************************************************************************************
748 */
749 hal_status_t hal_pkc_modular_left_shift_it(pkc_handle_t *p_pkc, pkc_modular_shift_t *p_input);
750
751 /**
752 ****************************************************************************************
753 * @brief Execute Modular Comparison in blocking mode.
754 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
755 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
756 * information for the specified PKC module.
757 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
758 * @param[in] timeout: Timeout duration
759 * @retval ::HAL_OK: Operation is OK.
760 * @retval ::HAL_ERROR: Parameter error or operation not supported.
761 * @retval ::HAL_BUSY: Driver is busy.
762 * @retval ::HAL_TIMEOUT: Timeout occurred.
763 ****************************************************************************************
764 */
765 hal_status_t hal_pkc_modular_compare(pkc_handle_t *p_pkc, pkc_modular_compare_t *p_input, uint32_t timeout);
766
767 /**
768 ****************************************************************************************
769 * @brief Execute Modular Comparison in non-blocking mode with Interrupt.
770 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
771 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
772 * information for the specified PKC module.
773 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
774 * @retval ::HAL_OK: Operation is OK.
775 * @retval ::HAL_ERROR: Parameter error or operation not supported.
776 * @retval ::HAL_BUSY: Driver is busy.
777 * @retval ::HAL_TIMEOUT: Timeout occurred.
778 ****************************************************************************************
779 */
780 hal_status_t hal_pkc_modular_compare_it(pkc_handle_t *p_pkc, pkc_modular_compare_t *p_input);
781
782 /**
783 ****************************************************************************************
784 * @brief Execute Montgomery Modular Multiplication in blocking mode.
785 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
786 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
787 * information for the specified PKC module.
788 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
789 * @param[in] timeout: Timeout duration
790 * @retval ::HAL_OK: Operation is OK.
791 * @retval ::HAL_ERROR: Parameter error or operation not supported.
792 * @retval ::HAL_BUSY: Driver is busy.
793 * @retval ::HAL_TIMEOUT: Timeout occurred.
794 ****************************************************************************************
795 */
796 hal_status_t hal_pkc_montgomery_multi(pkc_handle_t *p_pkc, pkc_montgomery_multi_t *p_input, uint32_t timeout);
797
798 /**
799 ****************************************************************************************
800 * @brief Execute Montgomery Modular Multiplication in non-blocking mode with Interrupt.
801 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
802 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
803 * information for the specified PKC module.
804 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
805 * @retval ::HAL_OK: Operation is OK.
806 * @retval ::HAL_ERROR: Parameter error or operation not supported.
807 * @retval ::HAL_BUSY: Driver is busy.
808 * @retval ::HAL_TIMEOUT: Timeout occurred.
809 ****************************************************************************************
810 */
811 hal_status_t hal_pkc_montgomery_multi_it(pkc_handle_t *p_pkc, pkc_montgomery_multi_t *p_input);
812
813 /**
814 ****************************************************************************************
815 * @brief Execute Montgomery Inversion in blocking mode.
816 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
817 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
818 * information for the specified PKC module.
819 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
820 * @param[in] timeout: Timeout duration
821 * @retval ::HAL_OK: Operation is OK.
822 * @retval ::HAL_ERROR: Parameter error or operation not supported.
823 * @retval ::HAL_BUSY: Driver is busy.
824 * @retval ::HAL_TIMEOUT: Timeout occurred.
825 ****************************************************************************************
826 */
827 hal_status_t hal_pkc_montgomery_inversion(pkc_handle_t *p_pkc, pkc_montgomery_inversion_t *p_input, uint32_t timeout);
828
829 /**
830 ****************************************************************************************
831 * @brief Execute Montgomery Inversion in non-blocking mode with Interrupt.
832 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
833 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
834 * information for the specified PKC module.
835 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
836 * @retval ::HAL_OK: Operation is OK.
837 * @retval ::HAL_ERROR: Parameter error or operation not supported.
838 * @retval ::HAL_BUSY: Driver is busy.
839 * @retval ::HAL_TIMEOUT: Timeout occurred.
840 ****************************************************************************************
841 */
842 hal_status_t hal_pkc_montgomery_inversion_it(pkc_handle_t *p_pkc, pkc_montgomery_inversion_t *p_input);
843
844 /**
845 ****************************************************************************************
846 * @brief Execute Big Number Multiplication in blocking mode.
847 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
848 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
849 * information for the specified PKC module.
850 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
851 * @param[in] timeout: Timeout duration
852 * @retval ::HAL_OK: Operation is OK.
853 * @retval ::HAL_ERROR: Parameter error or operation not supported.
854 * @retval ::HAL_BUSY: Driver is busy.
855 * @retval ::HAL_TIMEOUT: Timeout occurred.
856 ****************************************************************************************
857 */
858 hal_status_t hal_pkc_big_number_multi(pkc_handle_t *p_pkc, pkc_big_number_multi_t *p_input, uint32_t timeout);
859
860 /**
861 ****************************************************************************************
862 * @brief Execute Big Number Multiplication in non-blocking mode with Interrupt.
863 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
864 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
865 * information for the specified PKC module.
866 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
867 * @retval ::HAL_OK: Operation is OK.
868 * @retval ::HAL_ERROR: Parameter error or operation not supported.
869 * @retval ::HAL_BUSY: Driver is busy.
870 * @retval ::HAL_TIMEOUT: Timeout occurred.
871 ****************************************************************************************
872 */
873 hal_status_t hal_pkc_big_number_multi_it(pkc_handle_t *p_pkc, pkc_big_number_multi_t *p_input);
874
875 /**
876 ****************************************************************************************
877 * @brief Execute Big Number Addition in blocking mode.
878 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
879 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
880 * information for the specified PKC module.
881 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
882 * @param[in] timeout: Timeout duration
883 * @retval ::HAL_OK: Operation is OK.
884 * @retval ::HAL_ERROR: Parameter error or operation not supported.
885 * @retval ::HAL_BUSY: Driver is busy.
886 * @retval ::HAL_TIMEOUT: Timeout occurred.
887 ****************************************************************************************
888 */
889 hal_status_t hal_pkc_big_number_add(pkc_handle_t *p_pkc, pkc_big_number_add_t *p_input, uint32_t timeout);
890
891 /**
892 ****************************************************************************************
893 * @brief Execute Big Number Addition in non-blocking mode with Interrupt.
894 * @note The computed result will be stored in the buffter pointed by p_pkc->pResult.
895 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
896 * information for the specified PKC module.
897 * @param[in] p_input: Pointer to an expression structure which contains the input computing parameters.
898 * @retval ::HAL_OK: Operation is OK.
899 * @retval ::HAL_ERROR: Parameter error or operation not supported.
900 * @retval ::HAL_BUSY: Driver is busy.
901 * @retval ::HAL_TIMEOUT: Timeout occurred.
902 ****************************************************************************************
903 */
904 hal_status_t hal_pkc_big_number_add_it(pkc_handle_t *p_pkc, pkc_big_number_add_t *p_input);
905
906 /** @} */
907
908 /** @addtogroup PKC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
909 * @brief IRQ Handler and Callbacks functions
910 * @{
911 */
912
913 /**
914 ****************************************************************************************
915 * @brief Handle PKC interrupt request.
916 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
917 * information for the specified PKC module.
918 ****************************************************************************************
919 */
920 void hal_pkc_irq_handler(pkc_handle_t *p_pkc);
921
922 /**
923 ****************************************************************************************
924 * @brief PKC calculate done callback.
925 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
926 * information for the specified PKC module.
927 ****************************************************************************************
928 */
929 void hal_pkc_done_callback(pkc_handle_t *p_pkc);
930
931 /**
932 ****************************************************************************************
933 * @brief PKC error callback.
934 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
935 * information for the specified PKC module.
936 ****************************************************************************************
937 */
938 void hal_pkc_error_callback(pkc_handle_t *p_pkc);
939
940 /**
941 ****************************************************************************************
942 * @brief PKC over flow callback.
943 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
944 * information for the specified PKC module.
945 ****************************************************************************************
946 */
947 void hal_pkc_overflow_callback(pkc_handle_t *p_pkc);
948
949 /** @} */
950
951 /** @addtogroup PKC_Exported_Functions_Group3 Peripheral Control and State functions
952 * @brief PKC Peripheral State functions
953 *
954 @verbatim
955 ==============================================================================
956 ##### Peripheral Control and State functions #####
957 ==============================================================================
958 [..]
959 This subsection provides functions allowing to :
960 (+) Return the PKC handle state.
961 (+) Return the PKC handle error code.
962 (+) Set the timeout during internal process.
963
964 @endverbatim
965 * @{
966 */
967
968 /**
969 ****************************************************************************************
970 * @brief Return the PKC handle state.
971 * @param[in] p_pkc: Pointer to a pkc_handle_t structure that contains
972 * the configuration information for the specified PKC.
973 * @retval ::HAL_PKC_STATE_RESET: Peripheral not initialized.
974 * @retval ::HAL_PKC_STATE_READY: Peripheral initialized and ready for use.
975 * @retval ::HAL_PKC_STATE_BUSY: Peripheral in indirect mode and busy.
976 * @retval ::HAL_PKC_STATE_ERROR: Peripheral in error.
977 * @retval ::HAL_PKC_STATE_TIMEOUT: Peripheral in timeout.
978 ****************************************************************************************
979 */
980 hal_pkc_state_t hal_pkc_get_state(pkc_handle_t *p_pkc);
981
982 /**
983 ****************************************************************************************
984 * @brief Return the PKC error code.
985 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
986 * information for the specified PKC module.
987 * @return PKC error code in bitmap format
988 ****************************************************************************************
989 */
990 uint32_t hal_pkc_get_error(pkc_handle_t *p_pkc);
991
992 /**
993 ****************************************************************************************
994 * @brief Set the PKC internal process timeout value.
995 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
996 * information for the specified PKC module.
997 * @param[in] timeout: Internal process timeout value.
998 ****************************************************************************************
999 */
1000 void hal_pkc_set_timeout(pkc_handle_t *p_pkc, uint32_t timeout);
1001
1002 /**
1003 ****************************************************************************************
1004 * @brief Suspend some registers related to PKC configuration before sleep.
1005 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1006 * information for the specified PKC module.
1007 * @retval ::HAL_OK: Operation is OK.
1008 * @retval ::HAL_ERROR: Parameter error or operation not supported.
1009 * @retval ::HAL_BUSY: Driver is busy.
1010 * @retval ::HAL_TIMEOUT: Timeout occurred.
1011 ****************************************************************************************
1012 */
1013
1014 hal_status_t hal_pkc_suspend_reg(pkc_handle_t *p_pkc);
1015 /**
1016 ****************************************************************************************
1017 * @brief Restore some registers related to PKC configuration after sleep.
1018 * This function must be used in conjunction with the hal_hmac_suspend_reg().
1019 * @param[in] p_pkc: Pointer to a PKC handle which contains the configuration
1020 * information for the specified PKC module.
1021 * @retval ::HAL_OK: Operation is OK.
1022 * @retval ::HAL_ERROR: Parameter error or operation not supported.
1023 * @retval ::HAL_BUSY: Driver is busy.
1024 * @retval ::HAL_TIMEOUT: Timeout occurred.
1025 ****************************************************************************************
1026 */
1027
1028 hal_status_t hal_pkc_resume_reg(pkc_handle_t *p_pkc);
1029
1030 /** @} */
1031
1032 /** @} */
1033
1034 #ifdef __cplusplus
1035 }
1036 #endif
1037
1038 #endif /* __GR55xx_HAL_PKC_H__ */
1039
1040 /** @} */
1041
1042 /** @} */
1043
1044 /** @} */
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:203
_pkc_modular_add::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:192
_pkc_big_number_add::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:269
_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:237
_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:233
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:214
_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:204
_pkc_montgomery_multi::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:234
_pkc_montgomery_inversion
PKC Montgomery Inversion expression input.
Definition: gr55xx_hal_pkc.h:246
_pkc_big_number_add::p_B
uint32_t * p_B
Pointer to operand B.
Definition: gr55xx_hal_pkc.h:270
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:212
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:248
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:294
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:223
_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:191
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:215
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:268
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:235
_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:193
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:259
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:201
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:224
_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:181
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:249
_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:182
_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:202
_hal_pkc_callback::pkc_done_callback
void(* pkc_done_callback)(pkc_handle_t *p_pkc)
PKC calculate done callback
Definition: gr55xx_hal_pkc.h:293
_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:179
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:260
_pkc_rsa_modular_exponent::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:178
_pkc_montgomery_inversion::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:247
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:236
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:290
_pkc_modular_add
PKC Modular Addition expression input.
Definition: gr55xx_hal_pkc.h:190
_pkc_big_number_multi
PKC Big Number Multiplication expression input.
Definition: gr55xx_hal_pkc.h:258
_pkc_modular_shift::p_A
uint32_t * p_A
Pointer to operand A.
Definition: gr55xx_hal_pkc.h:213
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:292
_hal_pkc_callback::pkc_overflow_callback
void(* pkc_overflow_callback)(pkc_handle_t *p_pkc)
PKC over flow callback
Definition: gr55xx_hal_pkc.h:295
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:180
_pkc_modular_compare::p_P
uint32_t * p_P
Pointer to prime number P.
Definition: gr55xx_hal_pkc.h:225
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:291
_pkc_rsa_modular_exponent
PKC RSA Modular Exponentiation expression input.
Definition: gr55xx_hal_pkc.h:177
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.