WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
hal_pke.c 文件参考
#include "hal_pke.h"
#include "hal_pke_reg.h"
#include "crypto_errno.h"
#include "crypto_osal_adapt.h"
#include "crypto_drv_common.h"
#include "crypto_common_macro.h"
#include "hal_cipher_trng.h"
hal_pke.c 的引用(Include)关系图:

结构体

struct  pke_wait_event_type
 

宏定义

#define PKE_COMPAT_ERRNO(err_code)   HAL_COMPAT_ERRNO(ERROR_MODULE_PKE, err_code)
 
#define crypto_dump_buffer(fmt, args...)
 

函数

td_s32 pke_lock_condition (const td_void *param __attribute__((unused)))
 
td_void hal_pke_calc_int_enable (void)
 
td_void hal_pke_calc_int_disable (void)
 
td_s32 hal_pke_check_robust_warn (void)
 
td_s32 hal_pke_error_code (void)
 
td_s32 check_instr_rdy (pke_mode mode)
 
void hal_pke_start_pre_process (void)
 
void hal_pke_start0 (void)
 start PKE calculate in single instruction0 mode
 
void hal_pke_start1 (void)
 start PKE calculate in sigle instruction1 mode
 
void hal_pke_batch_start (void)
 start PKE calculate in batch processing mode
 
td_s32 hal_pke_wait_free (void)
 PKE wait for free in loop
 
td_s32 wait_free_condition (const td_void *param __attribute__((unused)))
 
td_s32 hal_pke_wait_free_int (void)
 PKE wait for free by interrupt
 
td_s32 hal_pke_init (void)
 
td_s32 hal_pke_deinit (void)
 
td_s32 get_lock_code (td_u32 *lock_code)
 
td_s32 hal_pke_lock (void)
 
void hal_pke_unlock (void)
 
void hal_pke_enable_noise (void)
 
void hal_pke_disable_noise (void)
 
td_s32 hal_pke_pre_process (void)
 set mask random into registerfor set_ram and get_ram.
 
void hal_pke_set_wait_event (crypto_wait_t *wait, const crypto_wait_timeout_interruptible wait_func, const td_u32 timeout_ms, const td_bool wait_done)
 
td_s32 hal_pke_check_free (void)
 check PKE busy, if success, then do next steps.
 
td_void hal_pke_set_ram (td_u32 ram_section, const td_u8 *data, td_u32 data_len, td_u32 aligned_len CIPHER_CHECK_WORD)
 set data to PKE DRAM.
 
td_void hal_pke_get_ram (td_u32 ram_section, td_u8 *data, td_u32 data_len CIPHER_CHECK_WORD)
 get result data in PKE DRAM
 
td_s32 hal_pke_clean_ram (void)
 clear the data in DRAM as random value. Only need to clear at the last calculate.
 
td_s32 hal_pke_set_mode (pke_mode mode, td_u32 single_instr, const rom_lib *batch_instr, pke_data_work_len work_len CIPHER_CHECK_WORD)
 set calculate mode, work_len and instr to register.
 
td_s32 hal_pke_start (pke_mode mode CIPHER_CHECK_WORD)
 start PKE calculate
 
td_s32 hal_pke_wait_done (void)
 PKE wait calculation finish
 
td_s32 hal_pke_get_align_val (const td_u32 len, td_u32 *aligned_len)
 Get the align val object of PKE, which depending on the chip version.
 
td_s32 hal_pke_set_mont_para (td_u32 low_bit, td_u32 high_bit CIPHER_CHECK_WORD)
 Set the montgomery parameter for modular multiplication.
 
td_s32 hal_pke_set_curve_param (const pke_ecc_init_param *init_param, const drv_pke_ecc_curve *ecc_curve)
 
td_s32 hal_pke_set_ed_param (const pke_ecc_init_param *init_param, const drv_pke_ecc_curve *ecc_curve)
 
td_s32 hal_pke_set_ecc_param (const pke_ecc_init_param *init_param, const drv_pke_ecc_curve *ecc_curve)
 
td_s32 hal_pke_set_init_param (const pke_ecc_init_param *init_param, const drv_pke_ecc_curve *ecc_curve)
 set the initial parameters into DRAM.
 

变量

td_u32 g_pke_initialize
 
pke_wait_event_type g_pke_wait_event
 

宏定义说明

◆ crypto_dump_buffer

#define crypto_dump_buffer (   fmt,
  args... 
)

◆ PKE_COMPAT_ERRNO

#define PKE_COMPAT_ERRNO (   err_code)    HAL_COMPAT_ERRNO(ERROR_MODULE_PKE, err_code)

Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2022-2022. All rights reserved. Description: PKE driver HAL API and logical algorithm compelement.

Create: 2022-08-09

函数说明

◆ check_instr_rdy()

td_s32 check_instr_rdy ( pke_mode  mode)

◆ get_lock_code()

td_s32 get_lock_code ( td_u32 lock_code)

◆ hal_pke_batch_start()

void hal_pke_batch_start ( void  )

start PKE calculate in batch processing mode

◆ hal_pke_calc_int_disable()

td_void hal_pke_calc_int_disable ( void  )

◆ hal_pke_calc_int_enable()

td_void hal_pke_calc_int_enable ( void  )

◆ hal_pke_check_free()

td_s32 hal_pke_check_free ( void  )

check PKE busy, if success, then do next steps.

返回
td_s32 TD_SUCCESS or other.

◆ hal_pke_check_robust_warn()

td_s32 hal_pke_check_robust_warn ( void  )

◆ hal_pke_clean_ram()

td_s32 hal_pke_clean_ram ( void  )

clear the data in DRAM as random value. Only need to clear at the last calculate.

返回
td_s32

◆ hal_pke_deinit()

td_s32 hal_pke_deinit ( void  )

◆ hal_pke_disable_noise()

void hal_pke_disable_noise ( void  )

◆ hal_pke_enable_noise()

void hal_pke_enable_noise ( void  )

◆ hal_pke_error_code()

td_s32 hal_pke_error_code ( void  )

◆ hal_pke_get_align_val()

td_s32 hal_pke_get_align_val ( const td_u32  len,
td_u32 aligned_len 
)

Get the align val object of PKE, which depending on the chip version.

参数
lenthe input data len.
aligned_lenthe aligned length used to calculate.

◆ hal_pke_get_ram()

td_void hal_pke_get_ram ( td_u32  ram_section,
td_u8 data,
td_u32 data_len  CIPHER_CHECK_WORD 
)

get result data in PKE DRAM

参数
ram_sectionthe address of offset block in DRAM for data to get out.
datathe data value.
data_lenthe effective length of data in byte.
CIPHER_CHECK_WORDifdef SEC_ENHANCE, the value is XOR result of parameters, otherwise it doesn't exist.

◆ hal_pke_init()

td_s32 hal_pke_init ( void  )

Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved. Description: Corresponds ROM functions to their implementation ROM addresses.

Create: 2023-05-17

◆ hal_pke_lock()

td_s32 hal_pke_lock ( void  )

◆ hal_pke_pre_process()

td_s32 hal_pke_pre_process ( void  )

set mask random into registerfor set_ram and get_ram.

返回
td_s32

◆ hal_pke_set_curve_param()

td_s32 hal_pke_set_curve_param ( const pke_ecc_init_param init_param,
const drv_pke_ecc_curve ecc_curve 
)

◆ hal_pke_set_ecc_param()

td_s32 hal_pke_set_ecc_param ( const pke_ecc_init_param init_param,
const drv_pke_ecc_curve ecc_curve 
)

◆ hal_pke_set_ed_param()

td_s32 hal_pke_set_ed_param ( const pke_ecc_init_param init_param,
const drv_pke_ecc_curve ecc_curve 
)

◆ hal_pke_set_init_param()

td_s32 hal_pke_set_init_param ( const pke_ecc_init_param init_param,
const drv_pke_ecc_curve ecc_curve 
)

set the initial parameters into DRAM.

参数
init_paramthe initial parameters.
ecc_curvethe ecc curve type.
返回
td_s32 TD_SUCCESS or others.

◆ hal_pke_set_mode()

td_s32 hal_pke_set_mode ( pke_mode  mode,
td_u32  single_instr,
const rom_lib batch_instr,
pke_data_work_len work_len  CIPHER_CHECK_WORD 
)

set calculate mode, work_len and instr to register.

参数
modecalculation mode, see pke_mode.
single_instrIf the mode is PKE_SINGLE_INSTR0 or PKE_SINGLE_INSTR1, then set this. Otherwise, set it 0.
batch_instrIf the mode is PKE_BATCH_INSTR, then set this. Otherwise, set it TD_NULL.
work_lenwork_len=ceiling(width/64), width is the data aligned bit width length, or work_len=ceiling(aligned_len/8).
CIPHER_CHECK_WORDifdef SEC_ENHANCE, the value is XOR result of parameters, otherwise it doesn't exist.
返回
td_s32 TD_SUCCESS or others.

◆ hal_pke_set_mont_para()

td_s32 hal_pke_set_mont_para ( td_u32  low_bit,
td_u32 high_bit  CIPHER_CHECK_WORD 
)

Set the montgomery parameter for modular multiplication.

参数
low_bitthe low 32bit data.
high_bitthe high 32bit data.
CIPHER_CHECK_WORDifdef SEC_ENHANCE, the value is XOR result of parameters, otherwise it doesn't exist.
返回
td_s32 TD_SUCCESS or others.

◆ hal_pke_set_ram()

td_void hal_pke_set_ram ( td_u32  ram_section,
const td_u8 data,
td_u32  data_len,
td_u32 aligned_len  CIPHER_CHECK_WORD 
)

set data to PKE DRAM.

参数
ram_sectionthe address of offset block in DRAM for data to write into.
datathe data value.
data_lenthe effective length of data in byte.
aligned_lenthe aligned length of data in byte when participate in calculate. In old IP, this is the klen, such as 32(256bit), 48(384bit), 64(512bit), 68(521bit), etc. This API mainly used in RSA calculate, for ecc, the input curve parameters are aligned, no need to process.
CIPHER_CHECK_WORDifdef SEC_ENHANCE, the value is XOR result of parameters, otherwise it doesn't exist.
返回
td_void

◆ hal_pke_set_wait_event()

void hal_pke_set_wait_event ( crypto_wait_t wait,
const crypto_wait_timeout_interruptible  wait_func,
const td_u32  timeout_ms,
const td_bool  wait_done 
)

◆ hal_pke_start()

td_s32 hal_pke_start ( pke_mode mode  CIPHER_CHECK_WORD)

start PKE calculate

参数
modeSINGLE_INSTR or BATCH_INSTR
CIPHER_CHECK_WORDifdef SEC_ENHANCE, the value is XOR result of parameters, otherwise it doesn't exist.
返回
td_s32 TD_SUCCESS or others.

◆ hal_pke_start0()

void hal_pke_start0 ( void  )

start PKE calculate in single instruction0 mode

◆ hal_pke_start1()

void hal_pke_start1 ( void  )

start PKE calculate in sigle instruction1 mode

◆ hal_pke_start_pre_process()

void hal_pke_start_pre_process ( void  )

◆ hal_pke_unlock()

void hal_pke_unlock ( void  )

◆ hal_pke_wait_done()

td_s32 hal_pke_wait_done ( void  )

PKE wait calculation finish

返回
td_s32

◆ hal_pke_wait_free()

td_s32 hal_pke_wait_free ( void  )

PKE wait for free in loop

返回
td_s32

◆ hal_pke_wait_free_int()

td_s32 hal_pke_wait_free_int ( void  )

PKE wait for free by interrupt

返回
td_s32

◆ pke_lock_condition()

td_s32 pke_lock_condition ( const td_void *param   __attribute__(unused))

◆ wait_free_condition()

td_s32 wait_free_condition ( const td_void *param   __attribute__(unused))

变量说明

◆ g_pke_initialize

td_u32 g_pke_initialize

◆ g_pke_wait_event

pke_wait_event_type g_pke_wait_event
初始值:
= {
.wait = TD_NULL,
.wait_func = TD_NULL,
.timeout_ms = 0,
.wait_done = TD_FALSE
}
#define TD_FALSE
Definition td_type.h:32
#define TD_NULL
Definition td_type.h:30