Ejemplo n.º 1
0
 /// <summary>
 /// Get delegates from unmanaged function pointers
 /// </summary>
 /// <param name="ckFunctionList">Structure which contains cryptoki function pointers</param>
 private void Initialize(CK_FUNCTION_LIST ckFunctionList)
 {
     C_Initialize = UnmanagedLibrary.GetDelegateForFunctionPointer<C_InitializeDelegate>(ckFunctionList.C_Initialize);
     C_Finalize = UnmanagedLibrary.GetDelegateForFunctionPointer<C_FinalizeDelegate>(ckFunctionList.C_Finalize);
     C_GetInfo = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetInfoDelegate>(ckFunctionList.C_GetInfo);
     C_GetFunctionList = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetFunctionListDelegate>(ckFunctionList.C_GetFunctionList);
     C_GetSlotList = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetSlotListDelegate>(ckFunctionList.C_GetSlotList);
     C_GetSlotInfo = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetSlotInfoDelegate>(ckFunctionList.C_GetSlotInfo);
     C_GetTokenInfo = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetTokenInfoDelegate>(ckFunctionList.C_GetTokenInfo);
     C_GetMechanismList = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetMechanismListDelegate>(ckFunctionList.C_GetMechanismList);
     C_GetMechanismInfo = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetMechanismInfoDelegate>(ckFunctionList.C_GetMechanismInfo);
     C_InitToken = UnmanagedLibrary.GetDelegateForFunctionPointer<C_InitTokenDelegate>(ckFunctionList.C_InitToken);
     C_InitPIN = UnmanagedLibrary.GetDelegateForFunctionPointer<C_InitPINDelegate>(ckFunctionList.C_InitPIN);
     C_SetPIN = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SetPINDelegate>(ckFunctionList.C_SetPIN);
     C_OpenSession = UnmanagedLibrary.GetDelegateForFunctionPointer<C_OpenSessionDelegate>(ckFunctionList.C_OpenSession);
     C_CloseSession = UnmanagedLibrary.GetDelegateForFunctionPointer<C_CloseSessionDelegate>(ckFunctionList.C_CloseSession);
     C_CloseAllSessions = UnmanagedLibrary.GetDelegateForFunctionPointer<C_CloseAllSessionsDelegate>(ckFunctionList.C_CloseAllSessions);
     C_GetSessionInfo = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetSessionInfoDelegate>(ckFunctionList.C_GetSessionInfo);
     C_GetOperationState = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetOperationStateDelegate>(ckFunctionList.C_GetOperationState);
     C_SetOperationState = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SetOperationStateDelegate>(ckFunctionList.C_SetOperationState);
     C_Login = UnmanagedLibrary.GetDelegateForFunctionPointer<C_LoginDelegate>(ckFunctionList.C_Login);
     C_Logout = UnmanagedLibrary.GetDelegateForFunctionPointer<C_LogoutDelegate>(ckFunctionList.C_Logout);
     C_CreateObject = UnmanagedLibrary.GetDelegateForFunctionPointer<C_CreateObjectDelegate>(ckFunctionList.C_CreateObject);
     C_CopyObject = UnmanagedLibrary.GetDelegateForFunctionPointer<C_CopyObjectDelegate>(ckFunctionList.C_CopyObject);
     C_DestroyObject = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DestroyObjectDelegate>(ckFunctionList.C_DestroyObject);
     C_GetObjectSize = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetObjectSizeDelegate>(ckFunctionList.C_GetObjectSize);
     C_GetAttributeValue = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetAttributeValueDelegate>(ckFunctionList.C_GetAttributeValue);
     C_SetAttributeValue = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SetAttributeValueDelegate>(ckFunctionList.C_SetAttributeValue);
     C_FindObjectsInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_FindObjectsInitDelegate>(ckFunctionList.C_FindObjectsInit);
     C_FindObjects = UnmanagedLibrary.GetDelegateForFunctionPointer<C_FindObjectsDelegate>(ckFunctionList.C_FindObjects);
     C_FindObjectsFinal = UnmanagedLibrary.GetDelegateForFunctionPointer<C_FindObjectsFinalDelegate>(ckFunctionList.C_FindObjectsFinal);
     C_EncryptInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_EncryptInitDelegate>(ckFunctionList.C_EncryptInit);
     C_Encrypt = UnmanagedLibrary.GetDelegateForFunctionPointer<C_EncryptDelegate>(ckFunctionList.C_Encrypt);
     C_EncryptUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_EncryptUpdateDelegate>(ckFunctionList.C_EncryptUpdate);
     C_EncryptFinal = UnmanagedLibrary.GetDelegateForFunctionPointer<C_EncryptFinalDelegate>(ckFunctionList.C_EncryptFinal);
     C_DecryptInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DecryptInitDelegate>(ckFunctionList.C_DecryptInit);
     C_Decrypt = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DecryptDelegate>(ckFunctionList.C_Decrypt);
     C_DecryptUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DecryptUpdateDelegate>(ckFunctionList.C_DecryptUpdate);
     C_DecryptFinal = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DecryptFinalDelegate>(ckFunctionList.C_DecryptFinal);
     C_DigestInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DigestInitDelegate>(ckFunctionList.C_DigestInit);
     C_Digest = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DigestDelegate>(ckFunctionList.C_Digest);
     C_DigestUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DigestUpdateDelegate>(ckFunctionList.C_DigestUpdate);
     C_DigestKey = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DigestKeyDelegate>(ckFunctionList.C_DigestKey);
     C_DigestFinal = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DigestFinalDelegate>(ckFunctionList.C_DigestFinal);
     C_SignInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignInitDelegate>(ckFunctionList.C_SignInit);
     C_Sign = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignDelegate>(ckFunctionList.C_Sign);
     C_SignUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignUpdateDelegate>(ckFunctionList.C_SignUpdate);
     C_SignFinal = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignFinalDelegate>(ckFunctionList.C_SignFinal);
     C_SignRecoverInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignRecoverInitDelegate>(ckFunctionList.C_SignRecoverInit);
     C_SignRecover = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignRecoverDelegate>(ckFunctionList.C_SignRecover);
     C_VerifyInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_VerifyInitDelegate>(ckFunctionList.C_VerifyInit);
     C_Verify = UnmanagedLibrary.GetDelegateForFunctionPointer<C_VerifyDelegate>(ckFunctionList.C_Verify);
     C_VerifyUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_VerifyUpdateDelegate>(ckFunctionList.C_VerifyUpdate);
     C_VerifyFinal = UnmanagedLibrary.GetDelegateForFunctionPointer<C_VerifyFinalDelegate>(ckFunctionList.C_VerifyFinal);
     C_VerifyRecoverInit = UnmanagedLibrary.GetDelegateForFunctionPointer<C_VerifyRecoverInitDelegate>(ckFunctionList.C_VerifyRecoverInit);
     C_VerifyRecover = UnmanagedLibrary.GetDelegateForFunctionPointer<C_VerifyRecoverDelegate>(ckFunctionList.C_VerifyRecover);
     C_DigestEncryptUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DigestEncryptUpdateDelegate>(ckFunctionList.C_DigestEncryptUpdate);
     C_DecryptDigestUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DecryptDigestUpdateDelegate>(ckFunctionList.C_DecryptDigestUpdate);
     C_SignEncryptUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SignEncryptUpdateDelegate>(ckFunctionList.C_SignEncryptUpdate);
     C_DecryptVerifyUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DecryptVerifyUpdateDelegate>(ckFunctionList.C_DecryptVerifyUpdate);
     C_GenerateKey = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GenerateKeyDelegate>(ckFunctionList.C_GenerateKey);
     C_GenerateKeyPair = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GenerateKeyPairDelegate>(ckFunctionList.C_GenerateKeyPair);
     C_WrapKey = UnmanagedLibrary.GetDelegateForFunctionPointer<C_WrapKeyDelegate>(ckFunctionList.C_WrapKey);
     C_UnwrapKey = UnmanagedLibrary.GetDelegateForFunctionPointer<C_UnwrapKeyDelegate>(ckFunctionList.C_UnwrapKey);
     C_DeriveKey = UnmanagedLibrary.GetDelegateForFunctionPointer<C_DeriveKeyDelegate>(ckFunctionList.C_DeriveKey);
     C_SeedRandom = UnmanagedLibrary.GetDelegateForFunctionPointer<C_SeedRandomDelegate>(ckFunctionList.C_SeedRandom);
     C_GenerateRandom = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GenerateRandomDelegate>(ckFunctionList.C_GenerateRandom);
     C_GetFunctionStatus = UnmanagedLibrary.GetDelegateForFunctionPointer<C_GetFunctionStatusDelegate>(ckFunctionList.C_GetFunctionStatus);
     C_CancelFunction = UnmanagedLibrary.GetDelegateForFunctionPointer<C_CancelFunctionDelegate>(ckFunctionList.C_CancelFunction);
     C_WaitForSlotEvent = UnmanagedLibrary.GetDelegateForFunctionPointer<C_WaitForSlotEventDelegate>(ckFunctionList.C_WaitForSlotEvent);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get delegates without C_GetFunctionList function from the statically linked PKCS#11 library
 /// </summary>
 private void InitializeWithoutGetFunctionList()
 {
     C_Initialize = NativeMethods.C_Initialize;
     C_Finalize = NativeMethods.C_Finalize;
     C_GetInfo = NativeMethods.C_GetInfo;
     C_GetFunctionList = NativeMethods.C_GetFunctionList;
     C_GetSlotList = NativeMethods.C_GetSlotList;
     C_GetSlotInfo = NativeMethods.C_GetSlotInfo;
     C_GetTokenInfo = NativeMethods.C_GetTokenInfo;
     C_GetMechanismList = NativeMethods.C_GetMechanismList;
     C_GetMechanismInfo = NativeMethods.C_GetMechanismInfo;
     C_InitToken = NativeMethods.C_InitToken;
     C_InitPIN = NativeMethods.C_InitPIN;
     C_SetPIN = NativeMethods.C_SetPIN;
     C_OpenSession = NativeMethods.C_OpenSession;
     C_CloseSession = NativeMethods.C_CloseSession;
     C_CloseAllSessions = NativeMethods.C_CloseAllSessions;
     C_GetSessionInfo = NativeMethods.C_GetSessionInfo;
     C_GetOperationState = NativeMethods.C_GetOperationState;
     C_SetOperationState = NativeMethods.C_SetOperationState;
     C_Login = NativeMethods.C_Login;
     C_Logout = NativeMethods.C_Logout;
     C_CreateObject = NativeMethods.C_CreateObject;
     C_CopyObject = NativeMethods.C_CopyObject;
     C_DestroyObject = NativeMethods.C_DestroyObject;
     C_GetObjectSize = NativeMethods.C_GetObjectSize;
     C_GetAttributeValue = NativeMethods.C_GetAttributeValue;
     C_SetAttributeValue = NativeMethods.C_SetAttributeValue;
     C_FindObjectsInit = NativeMethods.C_FindObjectsInit;
     C_FindObjects = NativeMethods.C_FindObjects;
     C_FindObjectsFinal = NativeMethods.C_FindObjectsFinal;
     C_EncryptInit = NativeMethods.C_EncryptInit;
     C_Encrypt = NativeMethods.C_Encrypt;
     C_EncryptUpdate = NativeMethods.C_EncryptUpdate;
     C_EncryptFinal = NativeMethods.C_EncryptFinal;
     C_DecryptInit = NativeMethods.C_DecryptInit;
     C_Decrypt = NativeMethods.C_Decrypt;
     C_DecryptUpdate = NativeMethods.C_DecryptUpdate;
     C_DecryptFinal = NativeMethods.C_DecryptFinal;
     C_DigestInit = NativeMethods.C_DigestInit;
     C_Digest = NativeMethods.C_Digest;
     C_DigestUpdate = NativeMethods.C_DigestUpdate;
     C_DigestKey = NativeMethods.C_DigestKey;
     C_DigestFinal = NativeMethods.C_DigestFinal;
     C_SignInit = NativeMethods.C_SignInit;
     C_Sign = NativeMethods.C_Sign;
     C_SignUpdate = NativeMethods.C_SignUpdate;
     C_SignFinal = NativeMethods.C_SignFinal;
     C_SignRecoverInit = NativeMethods.C_SignRecoverInit;
     C_SignRecover = NativeMethods.C_SignRecover;
     C_VerifyInit = NativeMethods.C_VerifyInit;
     C_Verify = NativeMethods.C_Verify;
     C_VerifyUpdate = NativeMethods.C_VerifyUpdate;
     C_VerifyFinal = NativeMethods.C_VerifyFinal;
     C_VerifyRecoverInit = NativeMethods.C_VerifyRecoverInit;
     C_VerifyRecover = NativeMethods.C_VerifyRecover;
     C_DigestEncryptUpdate = NativeMethods.C_DigestEncryptUpdate;
     C_DecryptDigestUpdate = NativeMethods.C_DecryptDigestUpdate;
     C_SignEncryptUpdate = NativeMethods.C_SignEncryptUpdate;
     C_DecryptVerifyUpdate = NativeMethods.C_DecryptVerifyUpdate;
     C_GenerateKey = NativeMethods.C_GenerateKey;
     C_GenerateKeyPair = NativeMethods.C_GenerateKeyPair;
     C_WrapKey = NativeMethods.C_WrapKey;
     C_UnwrapKey = NativeMethods.C_UnwrapKey;
     C_DeriveKey = NativeMethods.C_DeriveKey;
     C_SeedRandom = NativeMethods.C_SeedRandom;
     C_GenerateRandom = NativeMethods.C_GenerateRandom;
     C_GetFunctionStatus = NativeMethods.C_GetFunctionStatus;
     C_CancelFunction = NativeMethods.C_CancelFunction;
     C_WaitForSlotEvent = NativeMethods.C_WaitForSlotEvent;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Get delegates without C_GetFunctionList function from the statically linked PKCS#11 library
 /// </summary>
 private void InitializeWithoutGetFunctionList()
 {
     C_Initialize        = NativeMethods.C_Initialize;
     C_Finalize          = NativeMethods.C_Finalize;
     C_GetInfo           = NativeMethods.C_GetInfo;
     C_GetFunctionList   = NativeMethods.C_GetFunctionList;
     C_GetSlotList       = NativeMethods.C_GetSlotList;
     C_GetSlotInfo       = NativeMethods.C_GetSlotInfo;
     C_GetTokenInfo      = NativeMethods.C_GetTokenInfo;
     C_GetMechanismList  = NativeMethods.C_GetMechanismList;
     C_GetMechanismInfo  = NativeMethods.C_GetMechanismInfo;
     C_InitToken         = NativeMethods.C_InitToken;
     C_InitPIN           = NativeMethods.C_InitPIN;
     C_SetPIN            = NativeMethods.C_SetPIN;
     C_OpenSession       = NativeMethods.C_OpenSession;
     C_CloseSession      = NativeMethods.C_CloseSession;
     C_CloseAllSessions  = NativeMethods.C_CloseAllSessions;
     C_GetSessionInfo    = NativeMethods.C_GetSessionInfo;
     C_GetOperationState = NativeMethods.C_GetOperationState;
     C_SetOperationState = NativeMethods.C_SetOperationState;
     C_Login             = NativeMethods.C_Login;
     C_Logout            = NativeMethods.C_Logout;
     C_CreateObject      = NativeMethods.C_CreateObject;
     C_CopyObject        = NativeMethods.C_CopyObject;
     C_DestroyObject     = NativeMethods.C_DestroyObject;
     C_GetObjectSize     = NativeMethods.C_GetObjectSize;
     C_GetAttributeValue = NativeMethods.C_GetAttributeValue;
     C_SetAttributeValue = NativeMethods.C_SetAttributeValue;
     C_FindObjectsInit   = NativeMethods.C_FindObjectsInit;
     C_FindObjects       = NativeMethods.C_FindObjects;
     C_FindObjectsFinal  = NativeMethods.C_FindObjectsFinal;
     C_EncryptInit       = NativeMethods.C_EncryptInit;
     C_Encrypt           = NativeMethods.C_Encrypt;
     C_EncryptUpdate     = NativeMethods.C_EncryptUpdate;
     C_EncryptFinal      = NativeMethods.C_EncryptFinal;
     C_DecryptInit       = NativeMethods.C_DecryptInit;
     C_Decrypt           = NativeMethods.C_Decrypt;
     C_DecryptUpdate     = NativeMethods.C_DecryptUpdate;
     C_DecryptFinal      = NativeMethods.C_DecryptFinal;
     C_DigestInit        = NativeMethods.C_DigestInit;
     C_Digest            = NativeMethods.C_Digest;
     C_DigestUpdate      = NativeMethods.C_DigestUpdate;
     C_DigestKey         = NativeMethods.C_DigestKey;
     C_DigestFinal       = NativeMethods.C_DigestFinal;
     C_SignInit          = NativeMethods.C_SignInit;
     C_Sign                = NativeMethods.C_Sign;
     C_SignUpdate          = NativeMethods.C_SignUpdate;
     C_SignFinal           = NativeMethods.C_SignFinal;
     C_SignRecoverInit     = NativeMethods.C_SignRecoverInit;
     C_SignRecover         = NativeMethods.C_SignRecover;
     C_VerifyInit          = NativeMethods.C_VerifyInit;
     C_Verify              = NativeMethods.C_Verify;
     C_VerifyUpdate        = NativeMethods.C_VerifyUpdate;
     C_VerifyFinal         = NativeMethods.C_VerifyFinal;
     C_VerifyRecoverInit   = NativeMethods.C_VerifyRecoverInit;
     C_VerifyRecover       = NativeMethods.C_VerifyRecover;
     C_DigestEncryptUpdate = NativeMethods.C_DigestEncryptUpdate;
     C_DecryptDigestUpdate = NativeMethods.C_DecryptDigestUpdate;
     C_SignEncryptUpdate   = NativeMethods.C_SignEncryptUpdate;
     C_DecryptVerifyUpdate = NativeMethods.C_DecryptVerifyUpdate;
     C_GenerateKey         = NativeMethods.C_GenerateKey;
     C_GenerateKeyPair     = NativeMethods.C_GenerateKeyPair;
     C_WrapKey             = NativeMethods.C_WrapKey;
     C_UnwrapKey           = NativeMethods.C_UnwrapKey;
     C_DeriveKey           = NativeMethods.C_DeriveKey;
     C_SeedRandom          = NativeMethods.C_SeedRandom;
     C_GenerateRandom      = NativeMethods.C_GenerateRandom;
     C_GetFunctionStatus   = NativeMethods.C_GetFunctionStatus;
     C_CancelFunction      = NativeMethods.C_CancelFunction;
     C_WaitForSlotEvent    = NativeMethods.C_WaitForSlotEvent;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Get delegates from unmanaged function pointers
 /// </summary>
 /// <param name="ckFunctionList">Structure which contains cryptoki function pointers</param>
 private void Initialize(CK_FUNCTION_LIST ckFunctionList)
 {
     C_Initialize        = UnmanagedLibrary.GetDelegateForFunctionPointer <C_InitializeDelegate>(ckFunctionList.C_Initialize);
     C_Finalize          = UnmanagedLibrary.GetDelegateForFunctionPointer <C_FinalizeDelegate>(ckFunctionList.C_Finalize);
     C_GetInfo           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetInfoDelegate>(ckFunctionList.C_GetInfo);
     C_GetFunctionList   = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetFunctionListDelegate>(ckFunctionList.C_GetFunctionList);
     C_GetSlotList       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetSlotListDelegate>(ckFunctionList.C_GetSlotList);
     C_GetSlotInfo       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetSlotInfoDelegate>(ckFunctionList.C_GetSlotInfo);
     C_GetTokenInfo      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetTokenInfoDelegate>(ckFunctionList.C_GetTokenInfo);
     C_GetMechanismList  = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetMechanismListDelegate>(ckFunctionList.C_GetMechanismList);
     C_GetMechanismInfo  = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetMechanismInfoDelegate>(ckFunctionList.C_GetMechanismInfo);
     C_InitToken         = UnmanagedLibrary.GetDelegateForFunctionPointer <C_InitTokenDelegate>(ckFunctionList.C_InitToken);
     C_InitPIN           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_InitPINDelegate>(ckFunctionList.C_InitPIN);
     C_SetPIN            = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SetPINDelegate>(ckFunctionList.C_SetPIN);
     C_OpenSession       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_OpenSessionDelegate>(ckFunctionList.C_OpenSession);
     C_CloseSession      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_CloseSessionDelegate>(ckFunctionList.C_CloseSession);
     C_CloseAllSessions  = UnmanagedLibrary.GetDelegateForFunctionPointer <C_CloseAllSessionsDelegate>(ckFunctionList.C_CloseAllSessions);
     C_GetSessionInfo    = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetSessionInfoDelegate>(ckFunctionList.C_GetSessionInfo);
     C_GetOperationState = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetOperationStateDelegate>(ckFunctionList.C_GetOperationState);
     C_SetOperationState = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SetOperationStateDelegate>(ckFunctionList.C_SetOperationState);
     C_Login             = UnmanagedLibrary.GetDelegateForFunctionPointer <C_LoginDelegate>(ckFunctionList.C_Login);
     C_Logout            = UnmanagedLibrary.GetDelegateForFunctionPointer <C_LogoutDelegate>(ckFunctionList.C_Logout);
     C_CreateObject      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_CreateObjectDelegate>(ckFunctionList.C_CreateObject);
     C_CopyObject        = UnmanagedLibrary.GetDelegateForFunctionPointer <C_CopyObjectDelegate>(ckFunctionList.C_CopyObject);
     C_DestroyObject     = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DestroyObjectDelegate>(ckFunctionList.C_DestroyObject);
     C_GetObjectSize     = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetObjectSizeDelegate>(ckFunctionList.C_GetObjectSize);
     C_GetAttributeValue = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetAttributeValueDelegate>(ckFunctionList.C_GetAttributeValue);
     C_SetAttributeValue = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SetAttributeValueDelegate>(ckFunctionList.C_SetAttributeValue);
     C_FindObjectsInit   = UnmanagedLibrary.GetDelegateForFunctionPointer <C_FindObjectsInitDelegate>(ckFunctionList.C_FindObjectsInit);
     C_FindObjects       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_FindObjectsDelegate>(ckFunctionList.C_FindObjects);
     C_FindObjectsFinal  = UnmanagedLibrary.GetDelegateForFunctionPointer <C_FindObjectsFinalDelegate>(ckFunctionList.C_FindObjectsFinal);
     C_EncryptInit       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_EncryptInitDelegate>(ckFunctionList.C_EncryptInit);
     C_Encrypt           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_EncryptDelegate>(ckFunctionList.C_Encrypt);
     C_EncryptUpdate     = UnmanagedLibrary.GetDelegateForFunctionPointer <C_EncryptUpdateDelegate>(ckFunctionList.C_EncryptUpdate);
     C_EncryptFinal      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_EncryptFinalDelegate>(ckFunctionList.C_EncryptFinal);
     C_DecryptInit       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DecryptInitDelegate>(ckFunctionList.C_DecryptInit);
     C_Decrypt           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DecryptDelegate>(ckFunctionList.C_Decrypt);
     C_DecryptUpdate     = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DecryptUpdateDelegate>(ckFunctionList.C_DecryptUpdate);
     C_DecryptFinal      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DecryptFinalDelegate>(ckFunctionList.C_DecryptFinal);
     C_DigestInit        = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DigestInitDelegate>(ckFunctionList.C_DigestInit);
     C_Digest            = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DigestDelegate>(ckFunctionList.C_Digest);
     C_DigestUpdate      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DigestUpdateDelegate>(ckFunctionList.C_DigestUpdate);
     C_DigestKey         = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DigestKeyDelegate>(ckFunctionList.C_DigestKey);
     C_DigestFinal       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DigestFinalDelegate>(ckFunctionList.C_DigestFinal);
     C_SignInit          = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignInitDelegate>(ckFunctionList.C_SignInit);
     C_Sign                = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignDelegate>(ckFunctionList.C_Sign);
     C_SignUpdate          = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignUpdateDelegate>(ckFunctionList.C_SignUpdate);
     C_SignFinal           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignFinalDelegate>(ckFunctionList.C_SignFinal);
     C_SignRecoverInit     = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignRecoverInitDelegate>(ckFunctionList.C_SignRecoverInit);
     C_SignRecover         = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignRecoverDelegate>(ckFunctionList.C_SignRecover);
     C_VerifyInit          = UnmanagedLibrary.GetDelegateForFunctionPointer <C_VerifyInitDelegate>(ckFunctionList.C_VerifyInit);
     C_Verify              = UnmanagedLibrary.GetDelegateForFunctionPointer <C_VerifyDelegate>(ckFunctionList.C_Verify);
     C_VerifyUpdate        = UnmanagedLibrary.GetDelegateForFunctionPointer <C_VerifyUpdateDelegate>(ckFunctionList.C_VerifyUpdate);
     C_VerifyFinal         = UnmanagedLibrary.GetDelegateForFunctionPointer <C_VerifyFinalDelegate>(ckFunctionList.C_VerifyFinal);
     C_VerifyRecoverInit   = UnmanagedLibrary.GetDelegateForFunctionPointer <C_VerifyRecoverInitDelegate>(ckFunctionList.C_VerifyRecoverInit);
     C_VerifyRecover       = UnmanagedLibrary.GetDelegateForFunctionPointer <C_VerifyRecoverDelegate>(ckFunctionList.C_VerifyRecover);
     C_DigestEncryptUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DigestEncryptUpdateDelegate>(ckFunctionList.C_DigestEncryptUpdate);
     C_DecryptDigestUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DecryptDigestUpdateDelegate>(ckFunctionList.C_DecryptDigestUpdate);
     C_SignEncryptUpdate   = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SignEncryptUpdateDelegate>(ckFunctionList.C_SignEncryptUpdate);
     C_DecryptVerifyUpdate = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DecryptVerifyUpdateDelegate>(ckFunctionList.C_DecryptVerifyUpdate);
     C_GenerateKey         = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GenerateKeyDelegate>(ckFunctionList.C_GenerateKey);
     C_GenerateKeyPair     = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GenerateKeyPairDelegate>(ckFunctionList.C_GenerateKeyPair);
     C_WrapKey             = UnmanagedLibrary.GetDelegateForFunctionPointer <C_WrapKeyDelegate>(ckFunctionList.C_WrapKey);
     C_UnwrapKey           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_UnwrapKeyDelegate>(ckFunctionList.C_UnwrapKey);
     C_DeriveKey           = UnmanagedLibrary.GetDelegateForFunctionPointer <C_DeriveKeyDelegate>(ckFunctionList.C_DeriveKey);
     C_SeedRandom          = UnmanagedLibrary.GetDelegateForFunctionPointer <C_SeedRandomDelegate>(ckFunctionList.C_SeedRandom);
     C_GenerateRandom      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GenerateRandomDelegate>(ckFunctionList.C_GenerateRandom);
     C_GetFunctionStatus   = UnmanagedLibrary.GetDelegateForFunctionPointer <C_GetFunctionStatusDelegate>(ckFunctionList.C_GetFunctionStatus);
     C_CancelFunction      = UnmanagedLibrary.GetDelegateForFunctionPointer <C_CancelFunctionDelegate>(ckFunctionList.C_CancelFunction);
     C_WaitForSlotEvent    = UnmanagedLibrary.GetDelegateForFunctionPointer <C_WaitForSlotEventDelegate>(ckFunctionList.C_WaitForSlotEvent);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Get delegates from unmanaged function pointers
 /// </summary>
 /// <param name="ckFunctionList">Structure which contains cryptoki function pointers</param>
 private void Initialize(CK_FUNCTION_LIST ckFunctionList)
 {
     C_Initialize = (C_InitializeDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Initialize, typeof(C_InitializeDelegate));
     C_Finalize = (C_FinalizeDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Finalize, typeof(C_FinalizeDelegate));
     C_GetInfo = (C_GetInfoDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetInfo, typeof(C_GetInfoDelegate));
     C_GetFunctionList = (C_GetFunctionListDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetFunctionList, typeof(C_GetFunctionListDelegate));
     C_GetSlotList = (C_GetSlotListDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetSlotList, typeof(C_GetSlotListDelegate));
     C_GetSlotInfo = (C_GetSlotInfoDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetSlotInfo, typeof(C_GetSlotInfoDelegate));
     C_GetTokenInfo = (C_GetTokenInfoDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetTokenInfo, typeof(C_GetTokenInfoDelegate));
     C_GetMechanismList = (C_GetMechanismListDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetMechanismList, typeof(C_GetMechanismListDelegate));
     C_GetMechanismInfo = (C_GetMechanismInfoDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetMechanismInfo, typeof(C_GetMechanismInfoDelegate));
     C_InitToken = (C_InitTokenDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_InitToken, typeof(C_InitTokenDelegate));
     C_InitPIN = (C_InitPINDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_InitPIN, typeof(C_InitPINDelegate));
     C_SetPIN = (C_SetPINDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SetPIN, typeof(C_SetPINDelegate));
     C_OpenSession = (C_OpenSessionDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_OpenSession, typeof(C_OpenSessionDelegate));
     C_CloseSession = (C_CloseSessionDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_CloseSession, typeof(C_CloseSessionDelegate));
     C_CloseAllSessions = (C_CloseAllSessionsDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_CloseAllSessions, typeof(C_CloseAllSessionsDelegate));
     C_GetSessionInfo = (C_GetSessionInfoDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetSessionInfo, typeof(C_GetSessionInfoDelegate));
     C_GetOperationState = (C_GetOperationStateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetOperationState, typeof(C_GetOperationStateDelegate));
     C_SetOperationState = (C_SetOperationStateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SetOperationState, typeof(C_SetOperationStateDelegate));
     C_Login = (C_LoginDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Login, typeof(C_LoginDelegate));
     C_Logout = (C_LogoutDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Logout, typeof(C_LogoutDelegate));
     C_CreateObject = (C_CreateObjectDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_CreateObject, typeof(C_CreateObjectDelegate));
     C_CopyObject = (C_CopyObjectDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_CopyObject, typeof(C_CopyObjectDelegate));
     C_DestroyObject = (C_DestroyObjectDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DestroyObject, typeof(C_DestroyObjectDelegate));
     C_GetObjectSize = (C_GetObjectSizeDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetObjectSize, typeof(C_GetObjectSizeDelegate));
     C_GetAttributeValue = (C_GetAttributeValueDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetAttributeValue, typeof(C_GetAttributeValueDelegate));
     C_SetAttributeValue = (C_SetAttributeValueDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SetAttributeValue, typeof(C_SetAttributeValueDelegate));
     C_FindObjectsInit = (C_FindObjectsInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_FindObjectsInit, typeof(C_FindObjectsInitDelegate));
     C_FindObjects = (C_FindObjectsDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_FindObjects, typeof(C_FindObjectsDelegate));
     C_FindObjectsFinal = (C_FindObjectsFinalDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_FindObjectsFinal, typeof(C_FindObjectsFinalDelegate));
     C_EncryptInit = (C_EncryptInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_EncryptInit, typeof(C_EncryptInitDelegate));
     C_Encrypt = (C_EncryptDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Encrypt, typeof(C_EncryptDelegate));
     C_EncryptUpdate = (C_EncryptUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_EncryptUpdate, typeof(C_EncryptUpdateDelegate));
     C_EncryptFinal = (C_EncryptFinalDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_EncryptFinal, typeof(C_EncryptFinalDelegate));
     C_DecryptInit = (C_DecryptInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DecryptInit, typeof(C_DecryptInitDelegate));
     C_Decrypt = (C_DecryptDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Decrypt, typeof(C_DecryptDelegate));
     C_DecryptUpdate = (C_DecryptUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DecryptUpdate, typeof(C_DecryptUpdateDelegate));
     C_DecryptFinal = (C_DecryptFinalDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DecryptFinal, typeof(C_DecryptFinalDelegate));
     C_DigestInit = (C_DigestInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DigestInit, typeof(C_DigestInitDelegate));
     C_Digest = (C_DigestDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Digest, typeof(C_DigestDelegate));
     C_DigestUpdate = (C_DigestUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DigestUpdate, typeof(C_DigestUpdateDelegate));
     C_DigestKey = (C_DigestKeyDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DigestKey, typeof(C_DigestKeyDelegate));
     C_DigestFinal = (C_DigestFinalDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DigestFinal, typeof(C_DigestFinalDelegate));
     C_SignInit = (C_SignInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SignInit, typeof(C_SignInitDelegate));
     C_Sign = (C_SignDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Sign, typeof(C_SignDelegate));
     C_SignUpdate = (C_SignUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SignUpdate, typeof(C_SignUpdateDelegate));
     C_SignFinal = (C_SignFinalDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SignFinal, typeof(C_SignFinalDelegate));
     C_SignRecoverInit = (C_SignRecoverInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SignRecoverInit, typeof(C_SignRecoverInitDelegate));
     C_SignRecover = (C_SignRecoverDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SignRecover, typeof(C_SignRecoverDelegate));
     C_VerifyInit = (C_VerifyInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_VerifyInit, typeof(C_VerifyInitDelegate));
     C_Verify = (C_VerifyDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_Verify, typeof(C_VerifyDelegate));
     C_VerifyUpdate = (C_VerifyUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_VerifyUpdate, typeof(C_VerifyUpdateDelegate));
     C_VerifyFinal = (C_VerifyFinalDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_VerifyFinal, typeof(C_VerifyFinalDelegate));
     C_VerifyRecoverInit = (C_VerifyRecoverInitDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_VerifyRecoverInit, typeof(C_VerifyRecoverInitDelegate));
     C_VerifyRecover = (C_VerifyRecoverDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_VerifyRecover, typeof(C_VerifyRecoverDelegate));
     C_DigestEncryptUpdate = (C_DigestEncryptUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DigestEncryptUpdate, typeof(C_DigestEncryptUpdateDelegate));
     C_DecryptDigestUpdate = (C_DecryptDigestUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DecryptDigestUpdate, typeof(C_DecryptDigestUpdateDelegate));
     C_SignEncryptUpdate = (C_SignEncryptUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SignEncryptUpdate, typeof(C_SignEncryptUpdateDelegate));
     C_DecryptVerifyUpdate = (C_DecryptVerifyUpdateDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DecryptVerifyUpdate, typeof(C_DecryptVerifyUpdateDelegate));
     C_GenerateKey = (C_GenerateKeyDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GenerateKey, typeof(C_GenerateKeyDelegate));
     C_GenerateKeyPair = (C_GenerateKeyPairDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GenerateKeyPair, typeof(C_GenerateKeyPairDelegate));
     C_WrapKey = (C_WrapKeyDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_WrapKey, typeof(C_WrapKeyDelegate));
     C_UnwrapKey = (C_UnwrapKeyDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_UnwrapKey, typeof(C_UnwrapKeyDelegate));
     C_DeriveKey = (C_DeriveKeyDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_DeriveKey, typeof(C_DeriveKeyDelegate));
     C_SeedRandom = (C_SeedRandomDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_SeedRandom, typeof(C_SeedRandomDelegate));
     C_GenerateRandom = (C_GenerateRandomDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GenerateRandom, typeof(C_GenerateRandomDelegate));
     C_GetFunctionStatus = (C_GetFunctionStatusDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_GetFunctionStatus, typeof(C_GetFunctionStatusDelegate));
     C_CancelFunction = (C_CancelFunctionDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_CancelFunction, typeof(C_CancelFunctionDelegate));
     C_WaitForSlotEvent = (C_WaitForSlotEventDelegate)Marshal.GetDelegateForFunctionPointer(ckFunctionList.C_WaitForSlotEvent, typeof(C_WaitForSlotEventDelegate));
 }