/// <summary> /// Initializes new instance of MockDelegates class /// </summary> /// <param name="libraryHandle">Handle to the PKCS#11 library</param> internal MockDelegates(IntPtr libraryHandle) { // Get delegates from the dynamically loaded shared PKCS#11 library if (libraryHandle != IntPtr.Zero) { this.C_GetUnmanagedStructSizeList = UnmanagedLibrary.GetFunctionDelegate <C_GetUnmanagedStructSizeListDelegate>(libraryHandle, "C_GetUnmanagedStructSizeList"); this.C_EjectToken = UnmanagedLibrary.GetFunctionDelegate <C_EjectTokenDelegate>(libraryHandle, "C_EjectToken"); this.C_InteractiveLogin = UnmanagedLibrary.GetFunctionDelegate <C_InteractiveLoginDelegate>(libraryHandle, "C_InteractiveLogin"); } // Get delegates from the statically linked PKCS#11 library else { this.C_GetUnmanagedStructSizeList = NativeMethods.C_GetUnmanagedStructSizeList; this.C_EjectToken = NativeMethods.C_EjectToken; this.C_InteractiveLogin = NativeMethods.C_InteractiveLogin; } }
/// <summary> /// Initializes new instance of MockDelegates class /// </summary> /// <param name="libraryHandle">Handle to the PKCS#11 library</param> internal RutokenDelegates(IntPtr libraryHandle) { // Get delegates from the dynamically loaded shared PKCS#11 library if (libraryHandle != IntPtr.Zero) { this.C_EX_GetTokenInfoExtended = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetTokenInfoExtendedDelegate>(libraryHandle, "C_EX_GetTokenInfoExtended"); this.C_EX_InitToken = UnmanagedLibrary.GetFunctionDelegate <C_EX_InitTokenDelegate>(libraryHandle, "C_EX_InitToken"); this.C_EX_UnblockUserPIN = UnmanagedLibrary.GetFunctionDelegate <C_EX_UnblockUserPINDelegate>(libraryHandle, "C_EX_UnblockUserPIN"); this.C_EX_SetTokenName = UnmanagedLibrary.GetFunctionDelegate <C_EX_SetTokenNameDelegate>(libraryHandle, "C_EX_SetTokenName"); this.C_EX_GetTokenName = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetTokenNameDelegate>(libraryHandle, "C_EX_GetTokenName"); this.C_EX_GetJournal = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetJournalDelegate>(libraryHandle, "C_EX_GetJournal"); this.C_EX_SignInvisibleInit = UnmanagedLibrary.GetFunctionDelegate <C_EX_SignInvisibleInitDelegate>(libraryHandle, "C_EX_SignInvisibleInit"); this.C_EX_SignInvisible = UnmanagedLibrary.GetFunctionDelegate <C_EX_SignInvisibleDelegate>(libraryHandle, "C_EX_SignInvisible"); this.C_EX_SetLocalPIN = UnmanagedLibrary.GetFunctionDelegate <C_EX_SetLocalPINDelegate>(libraryHandle, "C_EX_SetLocalPIN"); this.C_EX_GetDriveSize = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetDriveSizeDelegate>(libraryHandle, "C_EX_GetDriveSize"); this.C_EX_FormatDrive = UnmanagedLibrary.GetFunctionDelegate <C_EX_FormatDriveDelegate>(libraryHandle, "C_EX_FormatDrive"); this.C_EX_GetVolumesInfo = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetVolumesInfoDelegate>(libraryHandle, "C_EX_GetVolumesInfo"); this.C_EX_ChangeVolumeAttributes = UnmanagedLibrary.GetFunctionDelegate <C_EX_ChangeVolumeAttributesDelegate>(libraryHandle, "C_EX_ChangeVolumeAttributes"); this.C_EX_SetLicense = UnmanagedLibrary.GetFunctionDelegate <C_EX_SetLicenseDelegate>(libraryHandle, "C_EX_SetLicense"); this.C_EX_GetLicense = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetLicenseDelegate>(libraryHandle, "C_EX_GetLicense"); this.C_EX_GenerateActivationPassword = UnmanagedLibrary.GetFunctionDelegate <C_EX_GenerateActivationPasswordDelegate>(libraryHandle, "C_EX_GenerateActivationPassword"); this.C_EX_LoadActivationKey = UnmanagedLibrary.GetFunctionDelegate <C_EX_LoadActivationKeyDelegate>(libraryHandle, "C_EX_LoadActivationKey"); this.C_EX_SetActivationPassword = UnmanagedLibrary.GetFunctionDelegate <C_EX_SetActivationPasswordDelegate>(libraryHandle, "C_EX_SetActivationPassword"); this.C_EX_TokenManage = UnmanagedLibrary.GetFunctionDelegate <C_EX_TokenManageDelegate>(libraryHandle, "C_EX_TokenManage"); this.C_EX_SlotManage = UnmanagedLibrary.GetFunctionDelegate <C_EX_SlotManageDelegate>(libraryHandle, "C_EX_SlotManage"); this.C_EX_WrapKey = UnmanagedLibrary.GetFunctionDelegate <C_EX_WrapKeyDelegate>(libraryHandle, "C_EX_WrapKey"); this.C_EX_UnwrapKey = UnmanagedLibrary.GetFunctionDelegate <C_EX_UnwrapKeyDelegate>(libraryHandle, "C_EX_UnwrapKey"); this.C_EX_CreateCSR = UnmanagedLibrary.GetFunctionDelegate <C_EX_CreateCSRDelegate>(libraryHandle, "C_EX_CreateCSR"); this.C_EX_GetCertificateInfoText = UnmanagedLibrary.GetFunctionDelegate <C_EX_GetCertificateInfoTextDelegate>(libraryHandle, "C_EX_GetCertificateInfoText"); this.C_EX_PKCS7Sign = UnmanagedLibrary.GetFunctionDelegate <C_EX_PKCS7SignDelegate>(libraryHandle, "C_EX_PKCS7Sign"); this.C_EX_PKCS7VerifyInit = UnmanagedLibrary.GetFunctionDelegate <C_EX_PKCS7VerifyInitDelegate>(libraryHandle, "C_EX_PKCS7VerifyInit"); this.C_EX_PKCS7Verify = UnmanagedLibrary.GetFunctionDelegate <C_EX_PKCS7VerifyDelegate>(libraryHandle, "C_EX_PKCS7Verify"); this.C_EX_PKCS7VerifyUpdate = UnmanagedLibrary.GetFunctionDelegate <C_EX_PKCS7VerifyUpdateDelegate>(libraryHandle, "C_EX_PKCS7VerifyUpdate"); this.C_EX_PKCS7VerifyFinal = UnmanagedLibrary.GetFunctionDelegate <C_EX_PKCS7VerifyFinalDelegate>(libraryHandle, "C_EX_PKCS7VerifyFinal"); this.C_EX_FreeBuffer = UnmanagedLibrary.GetFunctionDelegate <C_EX_FreeBufferDelegate>(libraryHandle, "C_EX_FreeBuffer"); } // Get delegates from the statically linked PKCS#11 library else { this.C_EX_GetTokenInfoExtended = RutokenNativeMethods.C_EX_GetTokenInfoExtended; this.C_EX_InitToken = RutokenNativeMethods.C_EX_InitToken; this.C_EX_UnblockUserPIN = RutokenNativeMethods.C_EX_UnblockUserPIN; this.C_EX_SetTokenName = RutokenNativeMethods.C_EX_SetTokenName; this.C_EX_GetTokenName = RutokenNativeMethods.C_EX_GetTokenName; this.C_EX_GetJournal = RutokenNativeMethods.C_EX_GetJournal; this.C_EX_SignInvisibleInit = RutokenNativeMethods.C_EX_SignInvisibleInit; this.C_EX_SignInvisible = RutokenNativeMethods.C_EX_SignInvisible; this.C_EX_SetLocalPIN = RutokenNativeMethods.C_EX_SetLocalPIN; this.C_EX_GetDriveSize = RutokenNativeMethods.C_EX_GetDriveSize; this.C_EX_FormatDrive = RutokenNativeMethods.C_EX_FormatDrive; this.C_EX_GetVolumesInfo = RutokenNativeMethods.C_EX_GetVolumesInfo; this.C_EX_ChangeVolumeAttributes = RutokenNativeMethods.C_EX_ChangeVolumeAttributes; this.C_EX_SetLicense = RutokenNativeMethods.C_EX_SetLicense; this.C_EX_GetLicense = RutokenNativeMethods.C_EX_GetLicense; this.C_EX_GenerateActivationPassword = RutokenNativeMethods.C_EX_GenerateActivationPassword; this.C_EX_LoadActivationKey = RutokenNativeMethods.C_EX_LoadActivationKey; this.C_EX_SetActivationPassword = RutokenNativeMethods.C_EX_SetActivationPassword; this.C_EX_TokenManage = RutokenNativeMethods.C_EX_TokenManage; this.C_EX_SlotManage = RutokenNativeMethods.C_EX_SlotManage; this.C_EX_WrapKey = RutokenNativeMethods.C_EX_WrapKey; this.C_EX_UnwrapKey = RutokenNativeMethods.C_EX_UnwrapKey; this.C_EX_CreateCSR = RutokenNativeMethods.C_EX_CreateCSR; this.C_EX_GetCertificateInfoText = RutokenNativeMethods.C_EX_GetCertificateInfoText; this.C_EX_PKCS7Sign = RutokenNativeMethods.C_EX_PKCS7Sign; this.C_EX_PKCS7VerifyInit = RutokenNativeMethods.C_EX_PKCS7VerifyInit; this.C_EX_PKCS7Verify = RutokenNativeMethods.C_EX_PKCS7Verify; this.C_EX_PKCS7VerifyUpdate = RutokenNativeMethods.C_EX_PKCS7VerifyUpdate; this.C_EX_PKCS7VerifyFinal = RutokenNativeMethods.C_EX_PKCS7VerifyFinal; this.C_EX_FreeBuffer = RutokenNativeMethods.C_EX_FreeBuffer; } }