Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_PKC_H__
53 #define __GR55xx_HAL_PKC_H__
120 uint32_t (*random_func)(void);
315 #define HAL_PKC_ERROR_NONE ((uint32_t)0x00000000)
316 #define HAL_PKC_ERROR_TIMEOUT ((uint32_t)0x00000001)
317 #define HAL_PKC_ERROR_TRANSFER ((uint32_t)0x00000002)
318 #define HAL_PKC_ERROR_OVERFLOW ((uint32_t)0x00000004)
319 #define HAL_PKC_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
320 #define HAL_PKC_ERROR_INVERSE_K ((uint32_t)0x00000010)
321 #define HAL_PKC_ERROR_IRREVERSIBLE ((uint32_t)0x00000020)
327 #define PKC_SECURE_MODE_DISABLE ((uint32_t)0x00000000)
328 #define PKC_SECURE_MODE_ENABLE ((uint32_t)0x00000001)
334 #define PKC_OPERATION_MODE_MULTI LL_PKC_operation_mode_MULTIPLY
335 #define PKC_OPERATION_MODE_INVER LL_PKC_operation_mode_INVERTION
336 #define PKC_OPERATION_MODE_ADD LL_PKC_operation_mode_ADD
337 #define PKC_OPERATION_MODE_SUB LL_PKC_operation_mode_SUB
338 #define PKC_OPERATION_MODE_CMP LL_PKC_operation_mode_COMPARE
339 #define PKC_OPERATION_MODE_LSHIFT LL_PKC_operation_mode_LEFTSHIFT
340 #define PKC_OPERATION_MODE_BIGMULTI LL_PKC_operation_mode_BIGINTEGERMULTIPLY
341 #define PKC_OPERATION_MODE_BIGADD LL_PKC_operation_mode_BIGINTEGERADD
347 #define PKC_BITS_LENGTH_MIN LL_PKC_BITS_LENGTH_MIN
348 #define PKC_BITS_LENGTH_MAX LL_PKC_BITS_LENGTH_MAX
349 #define PKC_BIGMULTI_BITS_LENGTH_MAX LL_PKC_BIGMULTI_BITS_LENGTH_MAX
355 #define PKC_FLAG_BUSY LL_PKC_WORKSTAT_BUSY
361 #define PKC_IT_DONE LL_PKC_INTEN_DONE
362 #define PKC_IT_ERR LL_PKC_INTEN_ERR
363 #define PKC_IT_OVF LL_PKC_INTEN_BAOVF
369 #define HAL_PKC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
383 #define __HAL_PKC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_PKC_STATE_RESET)
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)
396 #define __HAL_PKC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
402 #define __HAL_PKC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
413 #define __HAL_PKC_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INTEN, (__INTERRUPT__))
424 #define __HAL_PKC_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INTEN, (__INTERRUPT__))
435 #define __HAL_PKC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INTSTAT, (__FLAG__)) == (__FLAG__))
446 #define __HAL_PKC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INTSTAT, (__FLAG__))
455 #define __HAL_PKC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->WORKSTAT, (__FLAG__)) != 0) ? SET : RESET)
468 #define IS_PKC_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BITS_LENGTH_MAX))
474 #define IS_PKC_BIGMULTI_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BIGMULTI_BITS_LENGTH_MAX))
480 #define IS_PKC_SECURE_MODE(__MODE__) (((__MODE__) == PKC_SECURE_MODE_DISABLE) || \
481 ((__MODE__) == PKC_SECURE_MODE_ENABLE))
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))
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_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.
uint32_t * p_B
Pointer to operand B.
uint32_t * p_B
Pointer to operand B.
uint32_t * p_A
Pointer to operand A.
pkc_regs_t * p_instance
PKC registers base address
uint32_t ConstP
Montgomery multiplication constant for P, where constp = (-P[0])^(-1) mod 2^32.
uint32_t shift_count
Count to left shift
@ HAL_PKC_STATE_RESET
Peripheral not initialized
hal_lock_t
HAL Lock structures definition.
PKC Montgomery Modular Multiplication expression input.
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.
uint32_t shift_bits
Pointer to operand A.
ecc_point_t * p_ecc_point
Pointer to ECC Point.
uint32_t * p_P
Pointer to prime number P.
uint32_t * p_A
Pointer to operand A.
PKC Montgomery Inversion expression input.
uint32_t * p_B
Pointer to operand B.
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 Left Shift expression input.
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.
uint32_t * p_P
Pointer to prime number P.
hal_status_t hal_pkc_resume_reg(pkc_handle_t *p_pkc)
Restore some registers related to PKC configuration after sleep.
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.
__IO hal_pkc_state_t state
PKC operation state
void(* pkc_error_callback)(pkc_handle_t *p_pkc)
PKC error callback
@ HAL_PKC_STATE_READY
Peripheral initialized and ready for use
PKC Modular Comparison expression input.
__IO uint32_t error_code
PKC Error code
uint32_t * p_A
Pointer to operand A.
ecc_curve_init_t * p_ecc_curve
Specifies the pointer to elliptic curve description.
uint32_t retention[1]
pkc important register information.
uint32_t * p_P
Pointer to prime number P.
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 Structure definition.
PKC Big Number Addition expression input.
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_state_t hal_pkc_get_state(pkc_handle_t *p_pkc)
Return the PKC handle state.
@ HAL_PKC_STATE_TIMEOUT
Peripheral in timeout
Header file containing functions prototypes of PKC LL library.
uint32_t * p_B
Pointer to operand B.
LL PKC ECC P-256 Elliptic Curve Init Structure definition.
uint32_t * p_P
Prime number
hal_status_t hal_pkc_deinit(pkc_handle_t *p_pkc)
De-initialize the PKC peripheral.
uint32_t * p_K
Pointer to operand K.
uint32_t * p_P
Pointer to prime number P.
hal_status_t hal_pkc_suspend_reg(pkc_handle_t *p_pkc)
Suspend some registers related to PKC configuration before sleep.
__IO hal_lock_t lock
Locking object
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_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.
uint32_t * p_A
Pointer to operand A.
uint32_t secure_mode
Specifies the Secure Mode.
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 Structure definition.
void hal_pkc_msp_init(pkc_handle_t *p_pkc)
Initialize the PKC MSP.
@ HAL_PKC_STATE_ERROR
Peripheral in error
PKC Modular Subtraction expression input.
uint32_t * p_A
Pointer to operand A.
uint32_t * p_P_R2
P_R2 = R^2 mod P, where R = 2^DataBits
void hal_pkc_msp_deinit(pkc_handle_t *p_pkc)
De-initialize the PKC MSP.
uint32_t ConstP
Montgomery multiplication constant for P, where ConstP = (-P[0])^(-1) mod 2^32.
pkc_init_t init
PKC operation parameters
void hal_pkc_overflow_callback(pkc_handle_t *p_pkc)
PKC over flow callback.
void * p_result
Pointer to PKC result buffer
uint32_t timeout
Timeout for the PKC operation
uint32_t ConstP
Montgomery multiplication constant of P.
LL PKC ECC Point Structure definition.
uint32_t * p_A
Pointer to operand A.
void(* pkc_done_callback)(pkc_handle_t *p_pkc)
PKC calculate done callback
PKC ECC Point Multiplication expression input.
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.
uint32_t * p_B
Pointer to operand B.
uint32_t data_bits
Specifies the Data size: 256 ~ 2048 bits
hal_status_t
HAL Status structures definition.
void hal_pkc_done_callback(pkc_handle_t *p_pkc)
PKC calculate done callback.
uint32_t * p_B
Pointer to operand B.
uint32_t * p_A
Pointer to operand A.
uint32_t * p_A
Pointer to operand A.
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.
uint32_t * p_P
Pointer to prime number P.
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.
void hal_pkc_error_callback(pkc_handle_t *p_pkc)
PKC error callback.
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_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_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
Peripheral in indirect mode and busy
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.
void hal_pkc_irq_handler(pkc_handle_t *p_pkc)
Handle PKC interrupt request.
HAL_PKC Callback function definition.
PKC Modular Addition expression input.
PKC Big Number Multiplication expression input.
uint32_t * p_A
Pointer to operand A.
hal_pkc_state_t
HAL PKC State Enumerations definition.
void(* pkc_msp_deinit)(pkc_handle_t *p_pkc)
PKC de-init MSP callback
void(* pkc_overflow_callback)(pkc_handle_t *p_pkc)
PKC over flow callback
struct _hal_pkc_callback hal_pkc_callback_t
HAL_PKC Callback function definition.
uint32_t * p_P
Pointer to prime number P.
uint32_t * p_P
Pointer to prime number P.
struct _pkc_handle pkc_handle_t
PKC handle Structure definition.
void(* pkc_msp_init)(pkc_handle_t *p_pkc)
PKC init MSP callback
PKC RSA Modular Exponentiation expression input.
uint32_t hal_pkc_get_error(pkc_handle_t *p_pkc)
Return the PKC error code.
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.
This file contains HAL common definitions, enumeration, macros and structures definitions.
void hal_pkc_set_timeout(pkc_handle_t *p_pkc, uint32_t timeout)
Set the PKC internal process timeout value.
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.