Go to the documentation of this file.
52 #ifndef __GR5xx_HAL_PKC_H__
53 #define __GR5xx_HAL_PKC_H__
114 uint32_t (*random_func)(void);
295 #define HAL_PKC_ERROR_NONE ((uint32_t)0x00000000)
296 #define HAL_PKC_ERROR_TIMEOUT ((uint32_t)0x00000001)
297 #define HAL_PKC_ERROR_TRANSFER ((uint32_t)0x00000002)
298 #define HAL_PKC_ERROR_OVERFLOW ((uint32_t)0x00000004)
299 #define HAL_PKC_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
300 #define HAL_PKC_ERROR_INVERSE_K ((uint32_t)0x00000010)
301 #define HAL_PKC_ERROR_IRREVERSIBLE ((uint32_t)0x00000020)
307 #define PKC_SECURE_MODE_DISABLE ((uint32_t)0x00000000)
308 #define PKC_SECURE_MODE_ENABLE ((uint32_t)0x00000001)
314 #define PKC_OPERATION_MODE_MULTI LL_PKC_operation_mode_MULTIPLY
315 #define PKC_OPERATION_MODE_INVER LL_PKC_operation_mode_INVERTION
316 #define PKC_OPERATION_MODE_ADD LL_PKC_operation_mode_ADD
317 #define PKC_OPERATION_MODE_SUB LL_PKC_operation_mode_SUB
318 #define PKC_OPERATION_MODE_CMP LL_PKC_operation_mode_COMPARE
319 #define PKC_OPERATION_MODE_LSHIFT LL_PKC_operation_mode_LEFTSHIFT
320 #define PKC_OPERATION_MODE_BIGMULTI LL_PKC_operation_mode_BIGINTEGERMULTIPLY
321 #define PKC_OPERATION_MODE_BIGADD LL_PKC_operation_mode_BIGINTEGERADD
327 #define PKC_BITS_LENGTH_MIN LL_PKC_BITS_LENGTH_MIN
328 #define PKC_BITS_LENGTH_MAX LL_PKC_BITS_LENGTH_MAX
329 #define PKC_BIGMULTI_BITS_LENGTH_MAX LL_PKC_BIGMULTI_BITS_LENGTH_MAX
335 #define PKC_FLAG_BUSY LL_PKC_WORKSTAT_BUSY
341 #define PKC_IT_DONE LL_PKC_INTEN_DONE
342 #define PKC_IT_ERR LL_PKC_INTEN_ERR
343 #define PKC_IT_OVF LL_PKC_INTEN_BAOVF
349 #define HAL_PKC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000U)
355 #define PKC_SPRAM_BASE_ADDR (PKC_BASE + 0x800UL)
356 #define PKC_SPRAM_SIZE (2048U)
371 #define __HAL_PKC_RESET(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_RST); \
372 SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_RST)
378 #define __HAL_PKC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
384 #define __HAL_PKC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, PKC_CTRL_EN)
396 #define __HAL_PKC_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INT_EN, (__INTERRUPT__))
408 #define __HAL_PKC_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INT_EN, (__INTERRUPT__))
420 #define __HAL_PKC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INT_STAT, (__FLAG__)) == (__FLAG__))
432 #define __HAL_PKC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INT_STAT, (__FLAG__))
442 #define __HAL_PKC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0U) ? SET : RESET)
455 #define IS_PKC_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BITS_LENGTH_MAX))
461 #define IS_PKC_BIGMULTI_BITS_LENGTH(__BITS__) (((__BITS__) >= PKC_BITS_LENGTH_MIN) && ((__BITS__) <= PKC_BIGMULTI_BITS_LENGTH_MAX))
467 #define IS_PKC_SECURE_MODE(__MODE__) (((__MODE__) == PKC_SECURE_MODE_DISABLE) || \
468 ((__MODE__) == PKC_SECURE_MODE_ENABLE))
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.
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.
ecc_point_t * p_ecc_point
PKC Montgomery Inversion expression input.
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.
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
void(* pkc_error_callback)(pkc_handle_t *p_pkc)
PKC Modular Comparison expression input.
ecc_curve_init_t * p_ecc_curve
Header file containing functions prototypes of PKC LL library.
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.
LL PKC ECC P-256 Elliptic Curve Init Structure definition.
hal_status_t hal_pkc_deinit(pkc_handle_t *p_pkc)
De-initialize the PKC peripheral.
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.
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.
PKC Modular Subtraction expression input.
void hal_pkc_msp_deinit(pkc_handle_t *p_pkc)
De-initialize the PKC MSP.
void hal_pkc_overflow_callback(pkc_handle_t *p_pkc)
PKC over flow callback.
LL PKC ECC Point Structure definition.
void(* pkc_done_callback)(pkc_handle_t *p_pkc)
PKC ECC Point Multiplication expression input.
hal_status_t
HAL Status structures definition.
This file contains HAL common definitions, enumeration, macros and structures definitions.
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.
void hal_pkc_done_callback(pkc_handle_t *p_pkc)
PKC calculate done callback.
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.
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_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.
hal_pkc_state_t
HAL PKC State Enumerations definition.
void(* pkc_msp_deinit)(pkc_handle_t *p_pkc)
void(* pkc_overflow_callback)(pkc_handle_t *p_pkc)
struct _hal_pkc_callback hal_pkc_callback_t
HAL_PKC Callback function definition.
struct _pkc_handle pkc_handle_t
PKC handle Structure definition.
void(* pkc_msp_init)(pkc_handle_t *p_pkc)
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.
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.