app_pkc.h
Go to the documentation of this file.
1
52 #ifndef _APP_PKC_H_
53 #define _APP_PKC_H_
54
55 #include "gr55xx_hal.h"
56 #include "app_drv_error.h"
57 #ifdef ENV_USE_FREERTOS
58 #include "app_rtos_cfg.h"
59 #endif
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65 #ifdef HAL_PKC_MODULE_ENABLED
66
74 typedef enum
75 {
76 APP_PKC_TYPE_INTERRUPT,
77 APP_PKC_TYPE_POLLING,
78 APP_PKC_TYPE_MAX
79 } app_pkc_type_t;
80
81
85 typedef enum
86 {
87 APP_PKC_EVT_ERROR,
88 APP_PKC_EVT_DONE
89 } app_pkc_evt_type_t;
100 typedef struct
101 {
102 app_pkc_type_t use_type;
103 pkc_init_t init;
104 void *p_result;
105 uint32_t *p_kout;
106 } app_pkc_params_t;
107
111 typedef struct
112 {
113 app_pkc_evt_type_t type;
114 uint32_t error_code;
115 } app_pkc_evt_t;
121 typedef pkc_ecc_point_multi_t app_pkc_ecc_point_multi_t;
122 typedef pkc_modular_add_t app_pkc_modular_add_t;
123 typedef pkc_modular_sub_t app_pkc_modular_sub_t;
124 typedef pkc_modular_shift_t app_pkc_modular_shift_t;
125 typedef pkc_modular_compare_t app_pkc_modular_compare_t;
126 typedef pkc_montgomery_multi_t app_pkc_montgomery_multi_t;
127 typedef pkc_montgomery_inversion_t app_pkc_montgomery_inversion_t;
128 typedef pkc_big_number_multi_t app_pkc_big_number_multi_t;
129 typedef pkc_big_number_add_t app_pkc_big_number_add_t;
134 typedef void (*app_pkc_evt_handler_t)(app_pkc_evt_t *p_evt);
135
138 /* Exported functions --------------------------------------------------------*/
156 uint16_t app_pkc_init(app_pkc_params_t *p_params, app_pkc_evt_handler_t evt_handler);
157
165 uint16_t app_pkc_deinit(void);
166
177 uint16_t app_pkc_ecc_point_multi_sync(app_pkc_ecc_point_multi_t *p_input, uint32_t timeout);
178
188 uint16_t app_pkc_ecc_point_multi_async(app_pkc_ecc_point_multi_t *p_input);
189
200 uint16_t app_pkc_modular_add_sync(app_pkc_modular_add_t *p_input, uint32_t timeout);
201
211 uint16_t app_pkc_modular_add_async(app_pkc_modular_add_t *p_input);
212
223 uint16_t app_pkc_modular_sub_sync(app_pkc_modular_sub_t *p_input, uint32_t timeout);
224
234 uint16_t app_pkc_modular_sub_async(app_pkc_modular_sub_t *p_input);
235
246 uint16_t app_pkc_modular_left_shift_sync(app_pkc_modular_shift_t *p_input, uint32_t timeout);
247
257 uint16_t app_pkc_modular_left_shift_async(app_pkc_modular_shift_t *p_input);
258
269 uint16_t app_pkc_modular_compare_sync(app_pkc_modular_compare_t *p_input, uint32_t timeout);
270
280 uint16_t app_pkc_modular_compare_async(app_pkc_modular_compare_t *p_input);
281
292 uint16_t app_pkc_montgomery_multi_sync(app_pkc_montgomery_multi_t *p_input, uint32_t timeout);
293
303 uint16_t app_pkc_montgomery_multi_async(app_pkc_montgomery_multi_t *p_input);
304
316 uint16_t app_pkc_montgomery_inversion_sync(app_pkc_montgomery_inversion_t *p_input, uint32_t *p_K, uint32_t timeout);
317
328 uint16_t app_pkc_montgomery_inversion_async(app_pkc_montgomery_inversion_t *p_input, uint32_t *p_K);
329
340 uint16_t app_pkc_big_number_multi_sync(app_pkc_big_number_multi_t *p_input, uint32_t timeout);
341
351 uint16_t app_pkc_big_number_multi_async(app_pkc_big_number_multi_t *p_input);
352
363 uint16_t app_pkc_big_number_add_sync(app_pkc_big_number_add_t *p_input, uint32_t timeout);
364
374 uint16_t app_pkc_big_number_add_async(app_pkc_big_number_add_t *p_input);
375
383 pkc_handle_t *app_pkc_get_handle(void);
384
385 #ifdef ENV_RTOS_USE_SEMP
386 #endif
387
390 #endif
391
392 #ifdef __cplusplus
393 }
394 #endif
395
396 #endif
397
app_pkc_ecc_point_multi_sync
uint16_t app_pkc_ecc_point_multi_sync(app_pkc_ecc_point_multi_t *p_input, uint32_t timeout)
Realize the point multiplication operation of ECC ellipse algorithm，: result = k * point，Polling mode...
app_pkc_montgomery_inversion_sync
uint16_t app_pkc_montgomery_inversion_sync(app_pkc_montgomery_inversion_t *p_input, uint32_t *p_K, uint32_t timeout)
Realization of modular inversion: result = A^(-1)mod P，Polling mode.
app_pkc_params_t::use_type
app_pkc_type_t use_type
Definition: app_pkc.h:102
_pkc_montgomery_multi
PKC Montgomery Modular Multiplication expression input.
Definition: gr55xx_hal_pkc.h:232
_pkc_montgomery_inversion
PKC Montgomery Inversion expression input.
Definition: gr55xx_hal_pkc.h:245
app_pkc_modular_compare_async
uint16_t app_pkc_modular_compare_async(app_pkc_modular_compare_t *p_input)
Realization of modular comparison operation: result = A mod P，Interrupt mode.
_pkc_modular_shift
PKC Modular Left Shift expression input.
Definition: gr55xx_hal_pkc.h:211
app_pkc_init
uint16_t app_pkc_init(app_pkc_params_t *p_params, app_pkc_evt_handler_t evt_handler)
Initialize the APP PKC DRIVER according to the specified parameters in the app_pkc_params_t and app_p...
app_pkc_big_number_add_t
pkc_big_number_add_t app_pkc_big_number_add_t
Definition: app_pkc.h:129
app_pkc_modular_shift_t
pkc_modular_shift_t app_pkc_modular_shift_t
Definition: app_pkc.h:124
APP_PKC_TYPE_MAX
@ APP_PKC_TYPE_MAX
Definition: app_pkc.h:78
app_pkc_montgomery_multi_async
uint16_t app_pkc_montgomery_multi_async(app_pkc_montgomery_multi_t *p_input)
Realization of modular multiplication: result = A*B mod P，Interrupt mode.
app_pkc_big_number_add_async
uint16_t app_pkc_big_number_add_async(app_pkc_big_number_add_t *p_input)
Realize addition of large numbers: result = A+B，Interrupt mode.
_pkc_modular_compare
PKC Modular Comparison expression input.
Definition: gr55xx_hal_pkc.h:222
app_pkc_params_t::init
pkc_init_t init
Definition: app_pkc.h:103
app_pkc_evt_handler_t
void(* app_pkc_evt_handler_t)(app_pkc_evt_t *p_evt)
PKC event callback definition.
Definition: app_pkc.h:134
_pkc_handle
PKC handle Structure definition.
Definition: gr55xx_hal_pkc.h:134
app_pkc_params_t::p_kout
uint32_t * p_kout
Definition: app_pkc.h:105
_pkc_big_number_add
PKC Big Number Addition expression input.
Definition: gr55xx_hal_pkc.h:267
app_pkc_evt_t::error_code
uint32_t error_code
Definition: app_pkc.h:114
app_pkc_modular_left_shift_sync
uint16_t app_pkc_modular_left_shift_sync(app_pkc_modular_shift_t *p_input, uint32_t timeout)
Realization of module shift left operation: result = (A<<ShiftBits) mod P，Polling mode.
app_pkc_modular_add_t
pkc_modular_add_t app_pkc_modular_add_t
Definition: app_pkc.h:122
app_pkc_montgomery_inversion_t
pkc_montgomery_inversion_t app_pkc_montgomery_inversion_t
Definition: app_pkc.h:127
app_pkc_big_number_multi_sync
uint16_t app_pkc_big_number_multi_sync(app_pkc_big_number_multi_t *p_input, uint32_t timeout)
Realize multiplication of large numbers: result = A*B，Polling mode.
app_pkc_type_t
app_pkc_type_t
PKC operating mode Enumerations definition.
Definition: app_pkc.h:75
APP_PKC_TYPE_POLLING
@ APP_PKC_TYPE_POLLING
Definition: app_pkc.h:77
pkc_init_t
PKC Init Structure definition.
Definition: gr55xx_hal_pkc.h:111
app_pkc_evt_type_t
app_pkc_evt_type_t
PKC event Enumerations definition.
Definition: app_pkc.h:86
_pkc_modular_sub
PKC Modular Subtraction expression input.
Definition: gr55xx_hal_pkc.h:200
app_pkc_big_number_multi_async
uint16_t app_pkc_big_number_multi_async(app_pkc_big_number_multi_t *p_input)
Realize multiplication of large numbers: result = A*B，Interrupt mode.
app_pkc_big_number_add_sync
uint16_t app_pkc_big_number_add_sync(app_pkc_big_number_add_t *p_input, uint32_t timeout)
Realize addition of large numbers: result = A+B，Polling mode.
APP_PKC_EVT_ERROR
@ APP_PKC_EVT_ERROR
Definition: app_pkc.h:87
app_pkc_montgomery_multi_sync
uint16_t app_pkc_montgomery_multi_sync(app_pkc_montgomery_multi_t *p_input, uint32_t timeout)
Realization of modular multiplication: result = A*B mod P，Polling mode.
app_pkc_modular_sub_t
pkc_modular_sub_t app_pkc_modular_sub_t
Definition: app_pkc.h:123
app_pkc_ecc_point_multi_async
uint16_t app_pkc_ecc_point_multi_async(app_pkc_ecc_point_multi_t *p_input)
Realize the point multiplication operation of ECC ellipse algorithm，: result = k * point，Interrupt mo...
app_pkc_montgomery_multi_t
pkc_montgomery_multi_t app_pkc_montgomery_multi_t
Definition: app_pkc.h:126
_pkc_ecc_point_multi
PKC ECC Point Multiplication expression input.
Definition: gr55xx_hal_pkc.h:166
app_pkc_modular_left_shift_async
uint16_t app_pkc_modular_left_shift_async(app_pkc_modular_shift_t *p_input)
Realization of module shift left operation: result = (A<<ShiftBits) mod P，Interrupt mode.
app_pkc_params_t::p_result
void * p_result
Definition: app_pkc.h:104
app_pkc_modular_add_async
uint16_t app_pkc_modular_add_async(app_pkc_modular_add_t *p_input)
Realization of modular addition: result = (A + B) mod P，Interrupt mode.
app_pkc_deinit
uint16_t app_pkc_deinit(void)
De-initialize the APP PKC DRIVER peripheral.
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_pkc_montgomery_inversion_async
uint16_t app_pkc_montgomery_inversion_async(app_pkc_montgomery_inversion_t *p_input, uint32_t *p_K)
Realization of modular inversion: result = A^(-1)mod P，Interrupt mode.
app_pkc_ecc_point_multi_t
pkc_ecc_point_multi_t app_pkc_ecc_point_multi_t
Definition: app_pkc.h:121
APP_PKC_TYPE_INTERRUPT
@ APP_PKC_TYPE_INTERRUPT
Definition: app_pkc.h:76
_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
app_pkc_modular_sub_async
uint16_t app_pkc_modular_sub_async(app_pkc_modular_sub_t *p_input)
Implementation of modular subtraction: result = (A - B) mod P，Interrupt mode.
app_pkc_params_t
PKC parameters structure definition.
Definition: app_pkc.h:101
app_pkc_get_handle
pkc_handle_t * app_pkc_get_handle(void)
Return the PKC handle.
app_pkc_big_number_multi_t
pkc_big_number_multi_t app_pkc_big_number_multi_t
Definition: app_pkc.h:128
app_pkc_modular_compare_sync
uint16_t app_pkc_modular_compare_sync(app_pkc_modular_compare_t *p_input, uint32_t timeout)
Realization of modular comparison operation: result = A mod P，Polling mode.
app_rtos_cfg.h
Header file of app rtos config code.
app_pkc_evt_t
PKC event structure definition.
Definition: app_pkc.h:112
app_drv_error.h
Header file of app driver error code.
APP_PKC_EVT_DONE
@ APP_PKC_EVT_DONE
Definition: app_pkc.h:88
app_pkc_modular_add_sync
uint16_t app_pkc_modular_add_sync(app_pkc_modular_add_t *p_input, uint32_t timeout)
Realization of modular addition: result = (A + B) mod P，Polling mode.
app_pkc_evt_t::type
app_pkc_evt_type_t type
Definition: app_pkc.h:113
app_pkc_modular_sub_sync
uint16_t app_pkc_modular_sub_sync(app_pkc_modular_sub_t *p_input, uint32_t timeout)
Implementation of modular subtraction: result = (A - B) mod P，Polling mode.
app_pkc_modular_compare_t
pkc_modular_compare_t app_pkc_modular_compare_t
Definition: app_pkc.h:125