?? pkcs11layer.cpp
字號:
/*===========================================================================
===========================================================================
說明:
通用函數 支持平臺:WIN98/2K/XP...
文件名:
Pkcs11Layer.cpp
---------------------------------------------------------------------------
描述:
---------------------------------------------------------------------------
修改:
*===========================================================================*/
#include "stdafx.h"
#include "Pkcs11Layer.h"
#include "KeyCommon.h"
#include "KeyExport.h"
CPkcs11Layer::CPkcs11Layer(void)
{
m_bTrue = TRUE;
m_bFalse = FALSE;
m_dwErrCode = CKR_OK;
m_hLibPkcs11 = NULL_PTR;
m_Pkcs11FuncList = NULL_PTR;
m_AuxPkcs11FuncList = NULL_PTR;
LoadPkcs11Libary();
}
CPkcs11Layer::~CPkcs11Layer(void)
{
DebugOutFunc("~CPkcs11Layer");
FreePkcs11Libary();
m_hLibPkcs11 = NULL_PTR;
m_Pkcs11FuncList = NULL_PTR;
m_AuxPkcs11FuncList = NULL_PTR;
}
//libary
long CPkcs11Layer::LoadPkcs11Libary()
{
DebugOutFunc("LoadPkcs11Libary");
m_dwErrCode = CKR_OK;
#ifdef FTIAN_KEY
m_hLibPkcs11 = LoadLibrary("ngp11v211.dll");
#else
m_hLibPkcs11 = LoadLibrary("zhtp11v211.dll");
#endif
if(NULL_PTR == m_hLibPkcs11)
{
m_dwErrCode = USBKEY_INVALID_LIBRARY_PATH;
DebugOutPosition(__FILE__, __LINE__);
goto end;
}
end:
DebugOutRet(m_dwErrCode);
}
long CPkcs11Layer::FreePkcs11Libary()
{
DebugOutFunc("FreePkcs11Libary");
m_dwErrCode = CKR_OK;
if(NULL_PTR != m_hLibPkcs11)
{
FreeLibrary(m_hLibPkcs11);
}
DebugOutRet(m_dwErrCode);
}
bool CPkcs11Layer::CheckPkcs11FuncList()
{
if(NULL_PTR != m_Pkcs11FuncList && NULL_PTR != m_AuxPkcs11FuncList)
return TRUE;
else
{
C_GETFUNCTIONLISTPROC pC_GetFunctionList = NULL_PTR;
pC_GetFunctionList = (C_GETFUNCTIONLISTPROC)GetProcAddress(m_hLibPkcs11, "C_GetFunctionList");
if(pC_GetFunctionList == NULL_PTR)
{
m_dwErrCode = USBKEY_INVALID_LIBRARY_PATH;
DebugOutPosition(__FILE__, __LINE__);
goto end;
}
pE_GetAuxFunctionList = (EP_GetAuxFunctionList)GetProcAddress(m_hLibPkcs11, "E_GetAuxFunctionList");
if(pE_GetAuxFunctionList == NULL_PTR)
{
m_dwErrCode = USBKEY_INVALID_LIBRARY_PATH;
DebugOutPosition(__FILE__, __LINE__);
goto end;
}
if(CKR_OK != pC_GetFunctionList(&m_Pkcs11FuncList))
{
m_dwErrCode = USBKEY_INVALID_LIBRARY_PATH;
DebugOutPosition(__FILE__, __LINE__);
goto end;
}
if(CKR_OK != pE_GetAuxFunctionList(&m_AuxPkcs11FuncList))
{
m_dwErrCode = USBKEY_INVALID_LIBRARY_PATH;
DebugOutPosition(__FILE__, __LINE__);
goto end;
}
if(NULL_PTR == m_Pkcs11FuncList || NULL_PTR == m_AuxPkcs11FuncList)
{
m_dwErrCode = USBKEY_INVALID_LIBRARY_PATH;
DebugOutPosition(__FILE__, __LINE__);
goto end;
}
m_dwErrCode = m_Pkcs11FuncList->C_Initialize(NULL_PTR);
return TRUE;
}
end:
return FALSE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -