/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved. * Description: Define API about key slot driver * Author: Hisilicon * Create: 2019-6-26 */ #ifndef UAPI_SLOT_H #define UAPI_SLOT_H #include "td_type.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif /* __cplusplus */ /* * Define the maximum number of TScipher keyslot. * CNcomment: TScipher keyslot的最大值 */ #define UAPI_KEYSLOT_TSCIPHER_MAX 256 /* * Define the maximum number of Mcipher keyslot. * CNcomment: Mcipher keyslot的最大值 */ #define UAPI_KEYSLOT_MCIPHER_MAX 15 /* * Define the maximum number of HMAC keyslot. * CNcomment: HMAC keyslot的最大值 */ #define UAPI_KEYSLOT_HMAC_MAX 1 /* * Define the keyslot type. * CNcomment: keyslot类型 */ typedef enum { UAPI_KEYSLOT_TYPE_TSCIPHER = 0x00, UAPI_KEYSLOT_TYPE_MCIPHER, UAPI_KEYSLOT_TYPE_HMAC, UAPI_KEYSLOT_TYPE_MAX } uapi_keyslot_type; /* * Define the keyslot secure mode. * CNcomment: keyslot安全模式 */ typedef enum { UAPI_KEYSLOT_SECURE_MODE_NONE = 0x00, UAPI_KEYSLOT_SECURE_MODE_TEE, UAPI_KEYSLOT_SECURE_MODE_MAX } uapi_keyslot_secure_mode; /* * Define the keyslot attribute. * CNcomment: keyslot属性 */ typedef struct { uapi_keyslot_type type; uapi_keyslot_secure_mode secure_mode; } uapi_keyslot_attr; /* * brief Initializes the keyslot module. CNcomment:初始化keyslot模块 CNend * attention \n * Before calling any other api in keyslot, you must call this function first. * CNcomment: 在调用keyslot其他接口之前,要求先调用本接口 CNend * param N/A * retval ::TD_SUCCESS Success CNcomment:成功 CNend * retval ::TD_FAILURE Failure CNcomment:失败 CNend * see \n * N/A CNcomment: 无 CNend */ td_s32 uapi_keyslot_init(td_void); /* * brief Deinitializes the keyslot module. CNcomment:去初始化keyslot模块 CNend * attention \n * Before calling this api, you should call uapi_keyslot_destroy to destroy all the keyslot instance. * CNcomment: 在调用keyslot去初始化的接口前,需要调用uapi_keyslot_destroy来销毁所有keyslot实例 CNend * param N/A * retval ::TD_SUCCESS Success CNcomment:成功 CNend * retval ::TD_FAILURE Failure CNcomment:失败 CNend * see \n * N/A CNcomment: 无 CNend */ td_s32 uapi_keyslot_deinit(td_void); /* * brief Creates a keyslot instance. CNcomment:创建一个keyslot实例 CNend * param[in] attr The attribute that created the instance. CNcomment:创建实例所需的属性. CNend * param[out] key_slot Pointer to the handle of an allocated instance. CNcomment:指针类型,指向分配的实例句柄. CNend * retval ::TD_SUCCESS Success CNcomment:成功 CNend * retval ::TD_FAILURE Failure CNcomment:失败 CNend * see \n * N/A CNcomment: 无 CNend */ td_s32 uapi_keyslot_create(const uapi_keyslot_attr *attr, td_handle *key_slot); /* * brief Destroys a keyslot instance. CNcomment:销毁一个keyslot实例 CNend * attention \n * N/A * param[in] key_slot instance handle. CNcomment:实例句柄. CNend * retval ::TD_SUCCESS Success CNcomment:成功 CNend * retval ::TD_FAILURE Failure CNcomment:失败 CNend * see \n * N/A CNcomment: 无 CNend */ td_s32 uapi_keyslot_destroy(td_handle key_slot); #ifdef __cplusplus #if __cplusplus } #endif #endif /* __cplusplus */ #endif /* UAPI_SLOT_H */