#ifndef _IMPORT_CERT_H_
#define _IMPORT_CERT_H_



/*
	函数用途:
		*	导入pfx格式的证书到设备中。
	参数:
		*	hSession	: 会话句柄
		*	lpfl		: p11函数指针
		*	lpCert_Path	: 证书路径，包括文件名
		*	lpCert_Psw	: 证书密码
		*	lphPub		: 接收公钥句柄指针
		*	lphPri		: 接收私钥句柄指针
		*	lphCert		: 接收证书句柄指针数组 给8个 返回顺序 root ca my 
		*	nCertCnt	: 接收证书个数指针 一个则为my 大于等于两个后 root ca .ca .ca  my
	返回值:
		* 成功返回 CKR_OK
		* 失败参考错误码相关定义
*/

#ifdef __cplusplus
extern "C"{
#endif

CK_RV import_cert(CK_SESSION_HANDLE		hSession,		CK_FUNCTION_LIST_PTR	lpfl,\
				  CK_BYTE_PTR			lpCert_Path,	CK_BYTE_PTR				lpCert_Psw,\
				  CK_BYTE_PTR			lpConName,		CK_ULONG ulConNameLen,	CK_ULONG ulKeyUsage,\
				  CK_OBJECT_HANDLE_PTR	lphPub,			CK_OBJECT_HANDLE_PTR	lphPri,\
				  CK_OBJECT_HANDLE_PTR	lphCert,		CK_ULONG_PTR			nCertCnt);
	
#ifdef __cplusplus
};
#endif

//容器信息
#pragma pack(push,1)
typedef struct _Pkcs_con{
	unsigned char default_falg;
	unsigned short con_len;
	unsigned char con_name[256];
	unsigned short sig_cert_len;
	unsigned short sig_cert_fid;
	unsigned short sig_module_bit;
	unsigned short sig_pub_fid;
	unsigned short sig_pri_fid;
	
	unsigned short exc_cert_len;
	unsigned short exc_cert_fid;
	unsigned short exc_module_bit;
	unsigned short exc_pub_fid;
	unsigned short exc_pri_fid;
}Pkcs_con,*lpPkcs_con;

typedef struct _Container_info{
	Pkcs_con con[4];
}Container_info,*lpContainer_info;

#pragma pack(pop)


#define ERROR_BASE		0X12340000
#define ERROR_OPEN_FILE (ERROR_BASE + 1)
#define ERROR_PRASE_CERT (ERROR_BASE + 2)
#define ERROR_IMPORT_PUB (ERROR_BASE + 3)
#define ERROR_PUB_EXIST (ERROR_BASE + 4)
#define ERROR_IMPORT_PRI (ERROR_BASE + 5)
#define ERROR_PRI_EXIST (ERROR_BASE + 6)
#define ERROR_IMPORT_CERT (ERROR_BASE + 7)
#define ERROR_CONTAINER_NOT_EXIST (ERROR_BASE + 8)
#define ERROR_CONTAINER_OCCUPIED (ERROR_BASE + 9)
#define ERROR_GET_CERT_KEY_USAGE (ERROR_BASE + 10)
#define ERROR_CERT_KEY_USAGE_UNMATCHED (ERROR_BASE + 11)


#endif//_IMPORT_CERT_H_