WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
mbedtls_harden_adapt.c 文件参考
#include "mbedtls_harden_adapt.h"
#include "kapi_hash.h"
#include "kapi_km.h"
#include "kapi_pke.h"
#include "kapi_pke_cal.h"
#include "kapi_symc.h"
#include "kapi_trng.h"
#include "hash_harden_impl.h"
#include "aes_harden_impl.h"
#include "ecp_harden_impl.h"
mbedtls_harden_adapt.c 的引用(Include)关系图:

结构体

struct  mbedtls_harden_cipher_func
 

宏定义

#define MALLOC_BOUNDARY   32
 

类型定义

typedef int32_t(* func_hash_init) (void)
 
typedef int32_t(* func_hash_deinit) (void)
 
typedef int32_t(* func_hash_start) (uint32_t *uapi_hash_handle, const crypto_hash_attr *hash_attr)
 
typedef int32_t(* func_hash_update) (uint32_t uapi_hash_handle, const crypto_buf_attr *src_buf, const uint32_t len)
 
typedef int32_t(* func_hash_get) (uint32_t uapi_hash_handle, crypto_hash_clone_ctx *hash_clone_ctx)
 
typedef int32_t(* func_hash_set) (uint32_t uapi_hash_handle, const crypto_hash_clone_ctx *hash_clone_ctx)
 
typedef int32_t(* func_hash_destroy) (uint32_t uapi_hash_handle)
 
typedef int32_t(* func_hash_finish) (uint32_t uapi_hash_handle, uint8_t *out, uint32_t *out_len)
 
typedef int32_t(* func_hkdf) (crypto_hkdf_t *hkdf_param, uint8_t *okm, uint32_t okm_length)
 
typedef int32_t(* func_hkdf_extract) (crypto_hkdf_extract_t *extract_param, uint8_t *prk, uint32_t *prk_length)
 
typedef int32_t(* func_hkdf_expand) (const crypto_hkdf_expand_t *expand_param, uint8_t *okm, uint32_t okm_length)
 
typedef int32_t(* func_trng_get_random) (uint32_t *randnum)
 
typedef int32_t(* func_trng_get_multi_random) (uint32_t size, uint8_t *randnum)
 
typedef int32_t(* func_pbkdf2) (const crypto_kdf_pbkdf2_param *param, uint8_t *out, const uint32_t out_len)
 
typedef int32_t(* func_symc_init) (void)
 
typedef int32_t(* func_symc_deinit) (void)
 
typedef int32_t(* func_symc_create) (uint32_t *symc_handle, const crypto_symc_attr *symc_attr)
 
typedef int32_t(* func_symc_destroy) (uint32_t symc_handle)
 
typedef int32_t(* func_symc_set_config) (uint32_t symc_handle, const crypto_symc_ctrl_t *symc_ctrl)
 
typedef int32_t(* func_symc_get_config) (uint32_t symc_handle, crypto_symc_ctrl_t *symc_ctrl)
 
typedef int32_t(* func_symc_attach) (uint32_t symc_handle, uint32_t keyslot_handle)
 
typedef int32_t(* func_symc_encrypt) (uint32_t symc_handle, const crypto_buf_attr *src_buf, const crypto_buf_attr *dst_buf, uint32_t length)
 
typedef int32_t(* func_symc_decrypt) (uint32_t symc_handle, const crypto_buf_attr *src_buf, const crypto_buf_attr *dst_buf, uint32_t length)
 
typedef int32_t(* func_symc_get_tag) (uint32_t symc_handle, uint8_t *tag, uint32_t tag_length)
 
typedef int32_t(* func_symc_mac_start) (uint32_t *symc_handle, const crypto_symc_mac_attr *mac_attr)
 
typedef int32_t(* func_symc_mac_update) (uint32_t symc_handle, const crypto_buf_attr *src_buf, uint32_t length)
 
typedef int32_t(* func_symc_mac_finish) (uint32_t symc_handle, uint8_t *mac, uint32_t *mac_length)
 
typedef int32_t(* func_pke_init) (void)
 
typedef int32_t(* func_pke_deinit) (void)
 
typedef int32_t(* func_pke_mod) (const drv_pke_data *a, const drv_pke_data *p, const drv_pke_data *c)
 
typedef int32_t(* func_pke_exp_mod) (const drv_pke_data *n, const drv_pke_data *k, const drv_pke_data *in, const drv_pke_data *out)
 
typedef int32_t(* func_pke_ecc_gen_key) (drv_pke_ecc_curve_type curve_type, const drv_pke_data *input_priv_key, const drv_pke_data *output_priv_key, const drv_pke_ecc_point *output_pub_key)
 
typedef int32_t(* func_pke_ecdsa_sign) (drv_pke_ecc_curve_type curve_type, const drv_pke_data *priv_key, const drv_pke_data *hash, const drv_pke_ecc_sig *sig)
 
typedef int32_t(* func_pke_ecdsa_verify) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *pub_key, const drv_pke_data *hash, const drv_pke_ecc_sig *sig)
 
typedef int32_t(* func_pke_eddsa_sign) (drv_pke_ecc_curve_type curve_type, const drv_pke_data *priv_key, const drv_pke_msg *msg, const drv_pke_ecc_sig *sig)
 
typedef int32_t(* func_pke_eddsa_verify) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *pub_key, const drv_pke_msg *msg, const drv_pke_ecc_sig *sig)
 
typedef int32_t(* func_pke_gen_ecdh_key) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *input_pub_key, const drv_pke_data *input_priv_key, const drv_pke_data *output_shared_key)
 
typedef int32_t(* func_pke_check_dot_on_curve) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *pub_key, uint8_t *is_on_curve)
 
typedef int32_t(* func_pke_rsa_sign) (const drv_pke_rsa_priv_key *priv_key, drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, const drv_pke_data *input_hash, drv_pke_data *sign)
 
typedef int32_t(* func_pke_rsa_verify) (const drv_pke_rsa_pub_key *pub_key, drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, drv_pke_data *input_hash, const drv_pke_data *sig)
 
typedef int32_t(* func_pke_rsa_public_encrypt) (drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, const drv_pke_rsa_pub_key *pub_key, const drv_pke_data *input, const drv_pke_data *label, drv_pke_data *output)
 
typedef int32_t(* func_pke_rsa_private_decrypt) (drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, const drv_pke_rsa_priv_key *priv_key, const drv_pke_data *input, const drv_pke_data *label, drv_pke_data *output)
 
typedef int32_t(* func_km_init) (void)
 
typedef int32_t(* func_km_deinit) (void)
 
typedef int32_t(* func_km_create_keyslot) (uint32_t *keyslot_handle, km_keyslot_engine key_engine)
 
typedef void(* func_km_destroy_keyslot) (uint32_t keyslot_handle)
 
typedef int32_t(* func_km_set_clear_key) (uint32_t keyslot_handle, uint8_t *key, uint32_t keylen, km_keyslot_engine key_engine)
 
typedef int32_t(* func_alloc_phys_buf) (crypto_buf_attr *buf_attr, void **virt_addr, uint32_t size)
 
typedef void(* func_free_phys_buf) (crypto_buf_attr *buf_attr, void *virt_addr, uint32_t size)
 
typedef int32_t(* func_get_phys_mem_addr) (const void *virt_addr, uintptr_t *phys_addr)
 

枚举

enum  km_keyslot_engine {
  KM_KEYSLOT_ENGINE_AES = 0 , KM_KEYSLOT_ENGINE_SM4 , KM_KEYSLOT_ENGINE_HMAC_SHA1 , KM_KEYSLOT_ENGINE_HMAC_SHA224 ,
  KM_KEYSLOT_ENGINE_HMAC_SHA256 , KM_KEYSLOT_ENGINE_HMAC_SHA384 , KM_KEYSLOT_ENGINE_HMAC_SHA512 , KM_KEYSLOT_ENGINE_HMAC_SM3
}
 

函数

void mbedtls_cipher_adapt_register_func (mbedtls_harden_cipher_func *harden_cipher_func)
 
int32_t mbedtls_adapt_register_func (void)
 security_unified 模块对接第三方 mbedtls 接口需要注册的函数,若开启第三方对接宏 MBEDTLS_HARDEN_OPEN, 该接口由对接适配层调用。
 

宏定义说明

◆ MALLOC_BOUNDARY

#define MALLOC_BOUNDARY   32

Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved. Description: define the functions, which will be registered to mbedtls.

Create: 2023-07-11

类型定义说明

◆ func_alloc_phys_buf

typedef int32_t(* func_alloc_phys_buf) (crypto_buf_attr *buf_attr, void **virt_addr, uint32_t size)

◆ func_free_phys_buf

typedef void(* func_free_phys_buf) (crypto_buf_attr *buf_attr, void *virt_addr, uint32_t size)

◆ func_get_phys_mem_addr

typedef int32_t(* func_get_phys_mem_addr) (const void *virt_addr, uintptr_t *phys_addr)

◆ func_hash_deinit

typedef int32_t(* func_hash_deinit) (void)

◆ func_hash_destroy

typedef int32_t(* func_hash_destroy) (uint32_t uapi_hash_handle)

◆ func_hash_finish

typedef int32_t(* func_hash_finish) (uint32_t uapi_hash_handle, uint8_t *out, uint32_t *out_len)

◆ func_hash_get

typedef int32_t(* func_hash_get) (uint32_t uapi_hash_handle, crypto_hash_clone_ctx *hash_clone_ctx)

◆ func_hash_init

typedef int32_t(* func_hash_init) (void)

◆ func_hash_set

typedef int32_t(* func_hash_set) (uint32_t uapi_hash_handle, const crypto_hash_clone_ctx *hash_clone_ctx)

◆ func_hash_start

typedef int32_t(* func_hash_start) (uint32_t *uapi_hash_handle, const crypto_hash_attr *hash_attr)

◆ func_hash_update

typedef int32_t(* func_hash_update) (uint32_t uapi_hash_handle, const crypto_buf_attr *src_buf, const uint32_t len)

◆ func_hkdf

typedef int32_t(* func_hkdf) (crypto_hkdf_t *hkdf_param, uint8_t *okm, uint32_t okm_length)

◆ func_hkdf_expand

typedef int32_t(* func_hkdf_expand) (const crypto_hkdf_expand_t *expand_param, uint8_t *okm, uint32_t okm_length)

◆ func_hkdf_extract

typedef int32_t(* func_hkdf_extract) (crypto_hkdf_extract_t *extract_param, uint8_t *prk, uint32_t *prk_length)

◆ func_km_create_keyslot

typedef int32_t(* func_km_create_keyslot) (uint32_t *keyslot_handle, km_keyslot_engine key_engine)

◆ func_km_deinit

typedef int32_t(* func_km_deinit) (void)

◆ func_km_destroy_keyslot

typedef void(* func_km_destroy_keyslot) (uint32_t keyslot_handle)

◆ func_km_init

typedef int32_t(* func_km_init) (void)

◆ func_km_set_clear_key

typedef int32_t(* func_km_set_clear_key) (uint32_t keyslot_handle, uint8_t *key, uint32_t keylen, km_keyslot_engine key_engine)

◆ func_pbkdf2

typedef int32_t(* func_pbkdf2) (const crypto_kdf_pbkdf2_param *param, uint8_t *out, const uint32_t out_len)

◆ func_pke_check_dot_on_curve

typedef int32_t(* func_pke_check_dot_on_curve) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *pub_key, uint8_t *is_on_curve)

◆ func_pke_deinit

typedef int32_t(* func_pke_deinit) (void)

◆ func_pke_ecc_gen_key

typedef int32_t(* func_pke_ecc_gen_key) (drv_pke_ecc_curve_type curve_type, const drv_pke_data *input_priv_key, const drv_pke_data *output_priv_key, const drv_pke_ecc_point *output_pub_key)

◆ func_pke_ecdsa_sign

typedef int32_t(* func_pke_ecdsa_sign) (drv_pke_ecc_curve_type curve_type, const drv_pke_data *priv_key, const drv_pke_data *hash, const drv_pke_ecc_sig *sig)

◆ func_pke_ecdsa_verify

typedef int32_t(* func_pke_ecdsa_verify) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *pub_key, const drv_pke_data *hash, const drv_pke_ecc_sig *sig)

◆ func_pke_eddsa_sign

typedef int32_t(* func_pke_eddsa_sign) (drv_pke_ecc_curve_type curve_type, const drv_pke_data *priv_key, const drv_pke_msg *msg, const drv_pke_ecc_sig *sig)

◆ func_pke_eddsa_verify

typedef int32_t(* func_pke_eddsa_verify) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *pub_key, const drv_pke_msg *msg, const drv_pke_ecc_sig *sig)

◆ func_pke_exp_mod

typedef int32_t(* func_pke_exp_mod) (const drv_pke_data *n, const drv_pke_data *k, const drv_pke_data *in, const drv_pke_data *out)

◆ func_pke_gen_ecdh_key

typedef int32_t(* func_pke_gen_ecdh_key) (drv_pke_ecc_curve_type curve_type, const drv_pke_ecc_point *input_pub_key, const drv_pke_data *input_priv_key, const drv_pke_data *output_shared_key)

◆ func_pke_init

typedef int32_t(* func_pke_init) (void)

◆ func_pke_mod

typedef int32_t(* func_pke_mod) (const drv_pke_data *a, const drv_pke_data *p, const drv_pke_data *c)

◆ func_pke_rsa_private_decrypt

typedef int32_t(* func_pke_rsa_private_decrypt) (drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, const drv_pke_rsa_priv_key *priv_key, const drv_pke_data *input, const drv_pke_data *label, drv_pke_data *output)

◆ func_pke_rsa_public_encrypt

typedef int32_t(* func_pke_rsa_public_encrypt) (drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, const drv_pke_rsa_pub_key *pub_key, const drv_pke_data *input, const drv_pke_data *label, drv_pke_data *output)

◆ func_pke_rsa_sign

typedef int32_t(* func_pke_rsa_sign) (const drv_pke_rsa_priv_key *priv_key, drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, const drv_pke_data *input_hash, drv_pke_data *sign)

◆ func_pke_rsa_verify

typedef int32_t(* func_pke_rsa_verify) (const drv_pke_rsa_pub_key *pub_key, drv_pke_rsa_scheme scheme, drv_pke_hash_type hash_type, drv_pke_data *input_hash, const drv_pke_data *sig)

◆ func_symc_attach

typedef int32_t(* func_symc_attach) (uint32_t symc_handle, uint32_t keyslot_handle)

◆ func_symc_create

typedef int32_t(* func_symc_create) (uint32_t *symc_handle, const crypto_symc_attr *symc_attr)

◆ func_symc_decrypt

typedef int32_t(* func_symc_decrypt) (uint32_t symc_handle, const crypto_buf_attr *src_buf, const crypto_buf_attr *dst_buf, uint32_t length)

◆ func_symc_deinit

typedef int32_t(* func_symc_deinit) (void)

◆ func_symc_destroy

typedef int32_t(* func_symc_destroy) (uint32_t symc_handle)

◆ func_symc_encrypt

typedef int32_t(* func_symc_encrypt) (uint32_t symc_handle, const crypto_buf_attr *src_buf, const crypto_buf_attr *dst_buf, uint32_t length)

◆ func_symc_get_config

typedef int32_t(* func_symc_get_config) (uint32_t symc_handle, crypto_symc_ctrl_t *symc_ctrl)

◆ func_symc_get_tag

typedef int32_t(* func_symc_get_tag) (uint32_t symc_handle, uint8_t *tag, uint32_t tag_length)

◆ func_symc_init

typedef int32_t(* func_symc_init) (void)

◆ func_symc_mac_finish

typedef int32_t(* func_symc_mac_finish) (uint32_t symc_handle, uint8_t *mac, uint32_t *mac_length)

◆ func_symc_mac_start

typedef int32_t(* func_symc_mac_start) (uint32_t *symc_handle, const crypto_symc_mac_attr *mac_attr)

◆ func_symc_mac_update

typedef int32_t(* func_symc_mac_update) (uint32_t symc_handle, const crypto_buf_attr *src_buf, uint32_t length)

◆ func_symc_set_config

typedef int32_t(* func_symc_set_config) (uint32_t symc_handle, const crypto_symc_ctrl_t *symc_ctrl)

◆ func_trng_get_multi_random

typedef int32_t(* func_trng_get_multi_random) (uint32_t size, uint8_t *randnum)

◆ func_trng_get_random

typedef int32_t(* func_trng_get_random) (uint32_t *randnum)

枚举类型说明

◆ km_keyslot_engine

枚举值
KM_KEYSLOT_ENGINE_AES 
KM_KEYSLOT_ENGINE_SM4 
KM_KEYSLOT_ENGINE_HMAC_SHA1 
KM_KEYSLOT_ENGINE_HMAC_SHA224 
KM_KEYSLOT_ENGINE_HMAC_SHA256 
KM_KEYSLOT_ENGINE_HMAC_SHA384 
KM_KEYSLOT_ENGINE_HMAC_SHA512 
KM_KEYSLOT_ENGINE_HMAC_SM3 

函数说明

◆ mbedtls_cipher_adapt_register_func()

void mbedtls_cipher_adapt_register_func ( mbedtls_harden_cipher_func harden_cipher_func)