⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auxiliary.h

📁 PKCS#11 读取USB KEY证书
💻 H
字号:
/*
[]======================================================================[]

FILE:
	auxiliary.h

DESC:
	this file will include the auxiliary functions such as:
	token label modification function,
	container query function,

NOTE:
	you should include "cryptoki.h" before include this header file

[]======================================================================[]
*/

#ifndef __AUXILIARY_H__
#define __AUXILIARY_H__

#ifdef __cplusplus
extern "C" {
#endif

// ES_EVENT_XXXX must in range of 0x0001 to 0xFFFF
// Event code returned in the parameter pulEvent of function E_WaitForSlotEvent
#define ES_EVENT_TOKEN_INSERTED			0x0001
#define ES_EVENT_TOKEN_REMOVED			0x0002
#define ES_EVENT_OBJ_CREATE				0x0003
#define ES_EVENT_OBJ_DELETE				0x0004
#define ES_EVENT_OBJ_UPDATE				0x0005
#define ES_EVENT_PIN_CHANGED			0x0006
#define ES_EVENT_PIN_BLOCKED			0x0007
#define ES_EVENT_TOKEN_NAME				0x0008

#define ES_EVENT_READ_BEGIN				0x0100
#define ES_EVENT_READ_END				0x0101
#define ES_EVENT_READ_ERR				0x0102

#define ES_EVENT_WRITE_BEGIN			0x0103
#define ES_EVENT_WRITE_END				0x0104
#define ES_EVENT_WRITE_ERR				0x0105

#define ES_EVENT_GEN_KEYPAIR_BEGIN		0x0106
#define ES_EVENT_GEN_KEYPAIR_END		0x0107
#define ES_EVENT_GEN_KEYPAIR_ERR		0x0108

#define ES_EVENT_TOKEN_LOWINIT_BEGIN	0x0109
#define ES_EVENT_TOKEN_LOWINIT_END		0x010A
#define ES_EVENT_TOKEN_LOWINIT_ERR		0x010B

#define ES_EVENT_TOKEN_INIT_BEGIN		0x010C
#define ES_EVENT_TOKEN_INIT_END			0x010D
#define ES_EVENT_TOKEN_INIT_ERR			0x010E

// Offset to Call EP_XXX
// Using with the parameter pAuxFunc in function E_GetAuxFunctionList 
#define EP_INIT_TOKEN_PRIVATE			0
#define EP_SET_TOKEN_LABEL				1
#define EP_GET_PIN_INFO					2
#define EP_WAITFORSLOTEVENT				3
#define EP_PARSE_P12_CERT				4

#define EP_FUNC_MAX_COUNT				20
	
#pragma pack(1)

typedef struct _AUX_INIT_TOKEN_LOWLEVL_PKI
{
	CK_VERSION	version;
	char*		strTokenName;
	char*		strOldSOPin;
	char*		strSOPin;
	char*		strUserPin;
	CK_BYTE		ucSOMaxPinEC;
	CK_BYTE		ucUserMaxPinEC;
	CK_BYTE		nRSAKeyPairCount;
	CK_BYTE		nDSAKeyPairCount;
	CK_ULONG	ulPubSize;
	CK_ULONG	ulPrvSize;
	CK_ULONG	ulComputerID;
	CK_BYTE		ucCompareOEMID;
	
} AUX_INIT_TOKEN_LOWLEVL_PKI;

typedef AUX_INIT_TOKEN_LOWLEVL_PKI CK_PTR AUX_INIT_TOKEN_LOWLEVL_PKI_PTR;

struct AUX_PIN_INFO
{
	CK_BYTE		bSOPinMaxRetries;
	CK_BYTE		bSOPinCurCounter;
	CK_BYTE		bUserPinMaxRetries;
	CK_BYTE		bUserPinCurCounter;
	CK_FLAGS	pinflags;
};

typedef AUX_PIN_INFO CK_PTR AUX_PIN_INFO_PTR;

struct AUX_FUNC_LIST
{
	CK_VERSION	version;  /* Auxiliary Version */
	void*		pFunc[EP_FUNC_MAX_COUNT];
};

typedef AUX_FUNC_LIST CK_PTR AUX_FUNC_LIST_PTR;
typedef AUX_FUNC_LIST_PTR CK_PTR AUX_FUNC_LIST_PTR_PTR;

#pragma pack ()


// Low level initialize the token
typedef
CK_DECLARE_FUNCTION_POINTER(CK_RV, EP_InitTokenPrivate)
(	
	CK_SLOT_ID						slotID,		// ID of the token's slot
	AUX_INIT_TOKEN_LOWLEVL_PKI_PTR	pInitParam
);

// set the token name (label) 
// rule: 
// 1. if (pPin == NULL or ulPinLen == 0), user must have login
// 2. userType != CKU_SO && userType != CKU_USER, user must have login
typedef
CK_DECLARE_FUNCTION_POINTER(CK_RV, EP_SetTokenLabel)
(	
	CK_SLOT_ID		slotID,		// ID of the token's slot
	CK_USER_TYPE	userType,	// the user type
	CK_CHAR_PTR		pPin,		// the user pin
	CK_ULONG		ulPinLen,	// length in bytes of the PIN
	CK_CHAR_PTR		pLabel		// 32-byte token label (blank padded)
);

typedef
CK_DECLARE_FUNCTION_POINTER(CK_RV, EP_GetPinInfo)
(
	CK_SLOT_ID			slotID,			// (IN) ID of the token's slot
	AUX_PIN_INFO_PTR	pPinInfo		// (OUT) pin info of this token
);

typedef
CK_DECLARE_FUNCTION_POINTER(CK_RV, EP_WaitForSlotEvent)
(
	CK_FLAGS			flags,		// (IN)  block or non-block mode.
	CK_SLOT_ID_PTR		pSlotId,	// (OUT) ID of the slot which have an event.
	CK_ULONG*			pulEvent,	// (OUT) the event happened.
	CK_ULONG*			pulExtData,
	CK_VOID_PTR			pReserved
);

CK_DECLARE_FUNCTION(CK_RV, E_GetAuxFunctionList)
(
	AUX_FUNC_LIST_PTR_PTR pAuxFunc
);

typedef
CK_DECLARE_FUNCTION_POINTER(CK_RV, EP_GetAuxFunctionList)
(
	AUX_FUNC_LIST_PTR_PTR pAuxFunc
);

#ifdef __cplusplus
}
#endif

#endif // __AUXILIARY_H__

// EOF


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -