📄 h_extern.h
字号:
All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. *//* (C) COPYRIGHT International Business Machines Corp. 2001 */#ifndef _H_EXTERN_H#define _H_EXTERN_H#include "pkcs11types.h"#include "defs.h"// Both of the strings below have a length of 32 chars and must be// padded with spaces, and non-null terminated.//#define PKW_CRYPTOKI_VERSION_MAJOR 2#define PKW_CRYPTOKI_VERSION_MINOR 1#define PKW_CRYPTOKI_MANUFACTURER "IBM Corp. "#define PKW_CRYPTOKI_LIBDESC "PKCS#11 Interface for IBM 4758 "#define PKW_CRYPTOKI_LIB_VERSION_MAJOR 1#define PKW_CRYPTOKI_LIB_VERSION_MINOR 0// Maximum number of supported devices (rather arbitrary)//#define PKW_MAX_DEVICES 10////#define MY_RV CK_RV CK_ENTRY// Session handles can range anywhere from 0 to sizeof(ULONG). Furthermore,// a single application can open as many sessions as it wants, and the// handles are not guaranteed to be unique between tokens. We therefore// save the slot id and session handle away in a struct, and give the// address of the struct to the application instead of the real session// handle. When it calls us back with that value, we simply dereference// it and once again have the real session handle and the correct slot// number. (This is not 64-bit safe.)//extern CK_BBOOL initialized;#ifdef PKCS64extern CK_ULONG_32 pid_list[ PKW_MAX_DEVICES ];#elseextern CK_ULONG pid_list[ PKW_MAX_DEVICES ];#endiftypedef struct _HOST_SESSION_HANDLE { CK_SESSION_HANDLE handle; // token-assigned session handle CK_SESSION_HANDLE host_session; // pseudo session handle CK_SLOT_ID slot_id;} HOST_SESSION_HANDLE;// Endianness-conversion routines. This will be useful for folks trying// to use the coprocessor on a big-endian architecture...//// htocl -- host to card long// ctohl -- card to host long//#ifdef PKCS64CK_ULONG_32 long_reverse( CK_ULONG_32 x );#elseCK_ULONG long_reverse( CK_ULONG x );#endif#ifdef LITTLE_ENDIAN #define HTOCL(x) (x) #define CTOHL(x) (x)#else #define HTOCL(x) (long_reverse(x)) #define CTOHL(x) (long_reverse(x))#endif//// PKCS#11 Function Definitions |// ..as per the RSA Labs PKCS#11 documentation, v2.01. |//// General-purpose functions//MY_RV C_Initialize ( CK_VOID_PTR pInitArgs );MY_RV C_Finalize ( CK_VOID_PTR pReserved );MY_RV C_GetInfo ( CK_INFO_PTR pInfo );MY_RV C_GetFunctionList ( CK_FUNCTION_LIST_PTR_PTR ppFunctionList );// Slot and token management functions//MY_RV C_GetSlotList ( CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount );MY_RV C_GetSlotInfo ( CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo );MY_RV C_GetTokenInfo ( CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo );MY_RV C_WaitForSlotEvent ( CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved );MY_RV C_GetMechanismList ( CK_SLOT_ID slotID, CK_MECHANISM_TYPE_PTR pMechanismList, CK_ULONG_PTR pulCount );MY_RV C_GetMechanismInfo ( CK_SLOT_ID slotID, CK_MECHANISM_TYPE type, CK_MECHANISM_INFO_PTR pInfo );MY_RV C_InitToken ( CK_SLOT_ID slotID, CK_CHAR_PTR pPin, CK_ULONG ulPinLen, CK_CHAR_PTR pLabel );MY_RV C_InitPIN ( CK_SESSION_HANDLE hSession, CK_CHAR_PTR pPin, CK_ULONG ulPinLen );MY_RV C_SetPIN ( CK_SESSION_HANDLE hSession, CK_CHAR_PTR pOldPin, CK_ULONG ulOldLen, CK_CHAR_PTR pNewPin, CK_ULONG ulNewLen );// Session management functions//MY_RV C_OpenSession ( CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication, CK_NOTIFY Notify, CK_SESSION_HANDLE_PTR phSession );MY_RV C_CloseSession ( CK_SESSION_HANDLE hSession );MY_RV C_CloseAllSessions ( CK_SLOT_ID slotID );MY_RV C_GetSessionInfo ( CK_SESSION_HANDLE hSession, CK_SESSION_INFO_PTR pInfo );MY_RV C_GetOperationState ( CK_SESSION_HANDLE hSession, CK_BYTE_PTR pOperationState, CK_ULONG_PTR pulOperationStateLen );MY_RV C_SetOperationState ( CK_SESSION_HANDLE hSession, CK_BYTE_PTR pOperationState, CK_ULONG ulOperationStateLen, CK_OBJECT_HANDLE hEncryptionKey, CK_OBJECT_HANDLE hAuthenticationKey );MY_RV C_Login ( CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK_CHAR_PTR pPin, CK_ULONG uPinLen );MY_RV C_Logout ( CK_SESSION_HANDLE hSession );// Object management functions//MY_RV C_CreateObject ( CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR phObject );MY_RV C_CopyObject ( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR phNewObject );MY_RV C_DestroyObject ( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject );MY_RV C_GetObjectSize ( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ULONG_PTR pulSize );MY_RV C_GetAttributeValue ( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount );MY_RV C_SetAttributeValue ( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount );MY_RV C_FindObjectsInit ( CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount );MY_RV C_FindObjects ( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulMaxObjectCount,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -