|
@@ -125,15 +125,16 @@ void CInitializerEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLog
|
|
|
{
|
|
|
Dbg("收到EVENT_UKEY_PULLOUT");
|
|
|
m_strUserID = "";
|
|
|
-
|
|
|
+ /*
|
|
|
if (m_hGUIWindow != 0)
|
|
|
{
|
|
|
- //PostMessage(m_hGUIWindow, WM_CLOSE_DLG, 0, 0);
|
|
|
+ PostMessage(m_hGUIWindow, WM_CLOSE_DLG, 0, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Dbg("密钥初始化窗口句柄为空");
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -170,6 +171,7 @@ ErrorCodeEnum CInitializerEntity::StartInitializeNew(const char *pszAuthServer,
|
|
|
// KMC初始化
|
|
|
ErrorCodeEnum CInitializerEntity::InitKMC(int nPinPadCapability)
|
|
|
{
|
|
|
+ /*
|
|
|
CSystemStaticInfo si;
|
|
|
ErrorCodeEnum rc = GetFunction()->GetSystemStaticInfo(si);
|
|
|
if (rc != Error_Succeed)
|
|
@@ -177,7 +179,6 @@ ErrorCodeEnum CInitializerEntity::InitKMC(int nPinPadCapability)
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_GET_SYSTEM_STATIC_INFO,
|
|
|
GetOutPutStr("%s%08X", "GetSystemStaticInfo", rc).c_str());
|
|
|
m_strLastErrMsg = "获取配置信息失败(GetSystemStaticInfo)";
|
|
|
- LogError(Severity_Middle, rc, ERROR_ACCESSAUTH_GETSTATICINFO, "InitKMC()=>GetSystemStaticInfo() fail");
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
@@ -278,7 +279,7 @@ ErrorCodeEnum CInitializerEntity::InitKMC(int nPinPadCapability)
|
|
|
m_strLastErrMsg = CSimpleStringA::Format("KMC初始化失败, 错误信息[%s], 返回值[%d]", (const char*)GetKMCLastErrMsg(), nRet);
|
|
|
return Error_DevLoadFileFailed;
|
|
|
}
|
|
|
-
|
|
|
+ */
|
|
|
Dbg("kmc init succeed!");
|
|
|
return Error_Succeed;
|
|
|
}
|
|
@@ -287,7 +288,7 @@ CSimpleStringA CInitializerEntity::GetKMCLastErrMsg()
|
|
|
{
|
|
|
char szBuf[256];
|
|
|
memset(szBuf, 0, 256);
|
|
|
-
|
|
|
+ /*
|
|
|
int nBufLen = 256;
|
|
|
|
|
|
if (HasCkCodeFlg())
|
|
@@ -298,12 +299,13 @@ CSimpleStringA CInitializerEntity::GetKMCLastErrMsg()
|
|
|
{
|
|
|
GetLastErrorMsg(szBuf, &nBufLen);
|
|
|
}
|
|
|
-
|
|
|
+ */
|
|
|
return szBuf;
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum CInitializerEntity::ReleaseKMC()
|
|
|
{
|
|
|
+ /*
|
|
|
if (HasCkCodeFlg())
|
|
|
{
|
|
|
::RvcRelease();
|
|
@@ -312,7 +314,7 @@ ErrorCodeEnum CInitializerEntity::ReleaseKMC()
|
|
|
{
|
|
|
::Release();
|
|
|
}
|
|
|
-
|
|
|
+ */
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
@@ -390,6 +392,7 @@ string CInitializerEntity::ByteArrayToHexStr(BYTE *pBuf, int nBufLen)
|
|
|
// 加载主密钥
|
|
|
ErrorCodeEnum CInitializerEntity::LoadKeysToPinPad(bool bSM)
|
|
|
{
|
|
|
+ /*
|
|
|
// 取出主密钥
|
|
|
char keyBuf[64];
|
|
|
int nKeyBufLen = 64;
|
|
@@ -707,11 +710,13 @@ ErrorCodeEnum CInitializerEntity::LoadKeysToPinPad(bool bSM)
|
|
|
return rc;
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
+ return Error_Succeed;
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum CInitializerEntity::CreateInitMKData(CBlob &blob, bool bSM)
|
|
|
{
|
|
|
- if (blob.m_iLength < 600)
|
|
|
+ /*if (blob.m_iLength < 600)
|
|
|
blob.Alloc(600);
|
|
|
|
|
|
char TempKey[64] = {0};
|
|
@@ -743,7 +748,7 @@ ErrorCodeEnum CInitializerEntity::CreateInitMKData(CBlob &blob, bool bSM)
|
|
|
bSM ? "CreateInitSMTMKReq()" : "CreateInitTMKReq",
|
|
|
(const char*)GetKMCLastErrMsg(), nRet));
|
|
|
return Error_Unexpect;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
return Error_Succeed;
|
|
|
}
|
|
@@ -751,41 +756,41 @@ ErrorCodeEnum CInitializerEntity::CreateInitMKData(CBlob &blob, bool bSM)
|
|
|
// 解析返回DES主密钥
|
|
|
ErrorCodeEnum CInitializerEntity::ParseInitMKResult(CBlob &blob, bool bSM)
|
|
|
{
|
|
|
- // 调用KMC解析返回
|
|
|
- int nRet = 0;
|
|
|
-
|
|
|
- //Dbg("parse %s TMK data: [%s], len: %d", bSM ? "SM" : "DES", blob.m_pData, blob.m_iLength);
|
|
|
-
|
|
|
- int nKeyBufLen = 64;
|
|
|
- memset(m_cTDESTMK, 0, 64);
|
|
|
- memset(m_cSM2TMK, 0, 64);
|
|
|
-
|
|
|
- if (HasCkCodeFlg())
|
|
|
- {
|
|
|
- if (bSM)
|
|
|
- {
|
|
|
- nRet = ::RvcParseTMKRes((char*)blob.m_pData, blob.m_iLength, SM4, m_cSM2TMK, &nKeyBufLen, &m_pkeys);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nRet = ::RvcParseTMKRes((char*)blob.m_pData, blob.m_iLength, DES, m_cTDESTMK, &nKeyBufLen, &m_pkeys);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (bSM)
|
|
|
- nRet = ::ParseSMTMKRes((char*)blob.m_pData, blob.m_iLength);
|
|
|
- else
|
|
|
- nRet = ::ParseTMKRes((char*)blob.m_pData, blob.m_iLength);
|
|
|
- }
|
|
|
-
|
|
|
- if (nRet != 0)
|
|
|
- {
|
|
|
- LogError(Severity_Low, Error_Unexpect, ERROR_INITIALIZER_PARSEINITMKRES, (const char*)CSimpleStringA::Format("parse %s TMK return data fail, GetKMCLastErrMsg[%s], return [%d]",
|
|
|
- bSM ? "SM" : "DES",
|
|
|
- (const char*)GetKMCLastErrMsg(), nRet));
|
|
|
- return Error_Unexpect;
|
|
|
- }
|
|
|
+ //// 调用KMC解析返回
|
|
|
+ //int nRet = 0;
|
|
|
+ //
|
|
|
+ ////Dbg("parse %s TMK data: [%s], len: %d", bSM ? "SM" : "DES", blob.m_pData, blob.m_iLength);
|
|
|
+ //
|
|
|
+ //int nKeyBufLen = 64;
|
|
|
+ //memset(m_cTDESTMK, 0, 64);
|
|
|
+ //memset(m_cSM2TMK, 0, 64);
|
|
|
+
|
|
|
+ //if (HasCkCodeFlg())
|
|
|
+ //{
|
|
|
+ // if (bSM)
|
|
|
+ // {
|
|
|
+ // nRet = ::RvcParseTMKRes((char*)blob.m_pData, blob.m_iLength, SM4, m_cSM2TMK, &nKeyBufLen, &m_pkeys);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // nRet = ::RvcParseTMKRes((char*)blob.m_pData, blob.m_iLength, DES, m_cTDESTMK, &nKeyBufLen, &m_pkeys);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // if (bSM)
|
|
|
+ // nRet = ::ParseSMTMKRes((char*)blob.m_pData, blob.m_iLength);
|
|
|
+ // else
|
|
|
+ // nRet = ::ParseTMKRes((char*)blob.m_pData, blob.m_iLength);
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //if (nRet != 0)
|
|
|
+ //{
|
|
|
+ // LogError(Severity_Low, Error_Unexpect, ERROR_INITIALIZER_PARSEINITMKRES, (const char*)CSimpleStringA::Format("parse %s TMK return data fail, GetKMCLastErrMsg[%s], return [%d]",
|
|
|
+ // bSM ? "SM" : "DES",
|
|
|
+ // (const char*)GetKMCLastErrMsg(), nRet));
|
|
|
+ // return Error_Unexpect;
|
|
|
+ //}
|
|
|
|
|
|
return Error_Succeed;
|
|
|
}
|
|
@@ -843,7 +848,8 @@ bool CInitializerEntity::SetCenterSettingAddr(const char *pszAddr, int nPort)
|
|
|
GetFunction()->GetPath("CenterSetting", strPath);
|
|
|
|
|
|
auto strAuthAccessAddr = CSimpleStringA::Format("%s %d", pszAddr, nPort);
|
|
|
- return !!WritePrivateProfileString("CenterSetting", "Server", strAuthAccessAddr, strPath);
|
|
|
+ //return !!WritePrivateProfileString("CenterSetting", "Server", strAuthAccessAddr, strPath);
|
|
|
+ return inifile_format_write(strPath.GetData(), "CenterSetting", "Server", "%s", strAuthAccessAddr.GetData());
|
|
|
}
|
|
|
|
|
|
bool CInitializerEntity::GetInitUkeyFlg(int &nUkeyFlg)
|
|
@@ -970,7 +976,7 @@ ErrorCodeEnum CInitializerEntity::DownloadCfg(const char *pszSettingServer, int
|
|
|
{
|
|
|
if (!IsServiceAvailable(pszSettingServer, nSettingPort))
|
|
|
{
|
|
|
- m_strLastErrMsg = CSimpleStringA::Format("集中配置服务[%s:%d]无法连接(error:%d)", pszSettingServer, nSettingPort, WSAGetLastError());
|
|
|
+ m_strLastErrMsg = CSimpleStringA::Format("集中配置服务[%s:%d]无法连接", pszSettingServer, nSettingPort);
|
|
|
return Error_Param;
|
|
|
}
|
|
|
|
|
@@ -1210,7 +1216,7 @@ void CInitializerEntity::EndLogin(ErrorCodeEnum rc, const char *pErrMsg)
|
|
|
GetOutPutStr("%s%08X%s%s", "EndLogin", rc, "pErrMsg", pErrMsg).c_str());
|
|
|
m_eErrNum = rc;
|
|
|
m_strLastErrMsg = pErrMsg;
|
|
|
- if (m_hGUIWindow == 0)
|
|
|
+ //if (m_hGUIWindow == 0)
|
|
|
{
|
|
|
if (m_type != 1)
|
|
|
{
|
|
@@ -1231,11 +1237,11 @@ void CInitializerEntity::EndLogin(ErrorCodeEnum rc, const char *pErrMsg)
|
|
|
m_strLastErrMsg = "";
|
|
|
}
|
|
|
|
|
|
- if (m_hGUIWindow != 0)
|
|
|
+ //if (m_hGUIWindow != 0)
|
|
|
{
|
|
|
//PostMessage(m_hGUIWindow, WM_LOGIN_RESULT, rc, 0);
|
|
|
}
|
|
|
- else
|
|
|
+ //else
|
|
|
{
|
|
|
if (rc == Error_Succeed)
|
|
|
{
|
|
@@ -1287,7 +1293,7 @@ void CInitializerEntity::EndSyncPK(ErrorCodeEnum rc, const char *pszErrMsg)
|
|
|
GetOutPutStr("%s%08X%s%s", "EndSyncPK", rc, "pszErrMsg", pszErrMsg).c_str());
|
|
|
m_eErrNum = rc;
|
|
|
m_strLastErrMsg = pszErrMsg;
|
|
|
- if (m_hGUIWindow == 0)
|
|
|
+ //if (m_hGUIWindow == 0)
|
|
|
{
|
|
|
if (m_type == 0) {
|
|
|
m_ctx->Ans.Errcode = rc;
|
|
@@ -1307,11 +1313,11 @@ void CInitializerEntity::EndSyncPK(ErrorCodeEnum rc, const char *pszErrMsg)
|
|
|
m_strLastErrMsg = "";
|
|
|
}
|
|
|
|
|
|
- if (m_hGUIWindow != 0)
|
|
|
+ //if (m_hGUIWindow != 0)
|
|
|
{
|
|
|
//PostMessage(m_hGUIWindow, WM_SYNCPK_RESULT, rc, 0);
|
|
|
}
|
|
|
- else
|
|
|
+ //else
|
|
|
{
|
|
|
if (rc == Error_Succeed)
|
|
|
{
|
|
@@ -1498,11 +1504,11 @@ void CInitializerEntity::EndInitMK(ErrorCodeEnum rc, const char *pszErrMsg)
|
|
|
m_FSM.PostEventFIFO(pEvent);
|
|
|
|
|
|
// 通知UI窗口
|
|
|
- if (m_hGUIWindow != 0)
|
|
|
+ //if (m_hGUIWindow != 0)
|
|
|
{
|
|
|
//PostMessage(m_hGUIWindow, WM_INITMK_RESULT, rc, 0);
|
|
|
}
|
|
|
- else
|
|
|
+ //else
|
|
|
{
|
|
|
int nInitializedFlg = 1;
|
|
|
GetInitializedFlg(nInitializedFlg);
|
|
@@ -1650,12 +1656,13 @@ ErrorCodeEnum CInitializerEntity::StartGUINew()
|
|
|
|
|
|
ErrorCodeEnum CInitializerEntity::CloseGUI()
|
|
|
{
|
|
|
- if (m_hGUIWindow ==0)
|
|
|
+
|
|
|
+ /*if (m_hGUIWindow ==0)
|
|
|
return Error_NotInit;
|
|
|
|
|
|
ResetEvent(m_hGUIClosedEvent);
|
|
|
PostMessage(m_hGUIWindow, WM_CLOSE, 0, 0);
|
|
|
- WaitForSingleObject(m_hGUIClosedEvent, INFINITE);
|
|
|
+ WaitForSingleObject(m_hGUIClosedEvent, INFINITE);*/
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
@@ -1940,69 +1947,89 @@ static char* ConvertBytesToHexStr(BYTE *pBuf, int nLen)
|
|
|
|
|
|
bool CInitializerEntity::GetTerminalFingerPrint(BYTE *pBuf, int &nBufLen)
|
|
|
{
|
|
|
- char szTmp[1024] = {};
|
|
|
+ char szTmp[1024] = {0};
|
|
|
+ string strTmp;
|
|
|
int nTmpBufLen = 1024;
|
|
|
|
|
|
CSimpleStringA strRet;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
if (!QueryWMIDevice(Processor, "ProcessorId", szTmp, &nTmpBufLen))
|
|
|
+#else
|
|
|
+ if(!get_cpu_id_by_asm(strTmp))
|
|
|
+#endif // RVC_OS_WIN
|
|
|
{
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_GET_PROCCESSOR_ID,
|
|
|
- GetOutPutStr("%s%s%s%d", "Processor", "False","ErrorCode", GetLastError()).c_str());
|
|
|
- //LogError(Severity_Low, Error_Unexpect, ERROR_ACCESSAUTH_GETCPUID, CSimpleStringA::Format("query cpu id fail: %d", GetLastError()));
|
|
|
- m_strLastErrMsg = CSimpleStringA::Format("query cpu id fail, 错误码[%d], 请重启机器并重新初始化", GetLastError());
|
|
|
+ GetOutPutStr("%s%s", "Processor", "False").c_str());
|
|
|
+ m_strLastErrMsg = CSimpleStringA::Format("查询CPU ID失败,请重启机器并重新初始化");
|
|
|
return false;
|
|
|
}
|
|
|
- strRet = szTmp;
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
//Dbg("cpu id: %s", szTmp);
|
|
|
-
|
|
|
+ strRet = szTmp;
|
|
|
nTmpBufLen = 1024;
|
|
|
memset(szTmp, 0, sizeof(szTmp));
|
|
|
if (!QueryWMIDevice(BaseBoard, "SerialNumber", szTmp, &nTmpBufLen))
|
|
|
+#else
|
|
|
+ Dbg("cpu id: %s", strTmp.c_str());
|
|
|
+ strRet = strTmp.c_str();
|
|
|
+ strTmp.clear();
|
|
|
+ if(!get_board_serial_by_system(strTmp))
|
|
|
+#endif // RVC_OS_WIN
|
|
|
{
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_GET_BASEBOARD_ID,
|
|
|
- GetOutPutStr("%s%s%s%d", "BaseBoard", "False", "ErrorCode", GetLastError()).c_str());
|
|
|
- //LogError(Severity_Low, Error_Unexpect, ERROR_ACCESSAUTH_GETBASEBOARDSN, CSimpleStringA::Format("query baseboard sn fail: %d", GetLastError()));
|
|
|
- m_strLastErrMsg = CSimpleStringA::Format("query baseboard sn fail, 错误码[%d], 请重启机器并重新初始化", GetLastError());
|
|
|
+ GetOutPutStr("%s%s", "BaseBoard", "False").c_str());
|
|
|
+ m_strLastErrMsg = CSimpleStringA::Format("查询主板序列号失败, 请重启机器并重新初始化");
|
|
|
return false;
|
|
|
}
|
|
|
- //Dbg("baseboard sn: %s", szTmp);
|
|
|
-
|
|
|
strRet += "|";
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ //Dbg("baseboard sn: %s", szTmp);
|
|
|
strRet += szTmp;
|
|
|
-
|
|
|
nTmpBufLen = 1024;
|
|
|
memset(szTmp, 0, sizeof(szTmp));
|
|
|
if (!QueryWMIDevice(DiskDrive, "SerialNumber", szTmp, &nTmpBufLen))
|
|
|
+#else
|
|
|
+ Dbg("baseboard sn: %s", strTmp.c_str());
|
|
|
+ strRet += strTmp.c_str();
|
|
|
+ vector<string> disk;
|
|
|
+ if(!get_disk_serial_by_system(disk))
|
|
|
+#endif // RVC_OS_WIN
|
|
|
{
|
|
|
-
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_GET_DISKDRIVE_ID,
|
|
|
- GetOutPutStr("%s%s%s%d", "DiskDrive", "False", "ErrorCode", GetLastError()).c_str());
|
|
|
- //LogError(Severity_Low, Error_Unexpect, ERROR_ACCESSAUTH_DISKDRIVESN, CSimpleStringA::Format("query harddisk sn fail: %d", GetLastError()));
|
|
|
- m_strLastErrMsg = CSimpleStringA::Format("query harddisk sn fail, 错误码[%d], 请重启机器并重新初始化", GetLastError());
|
|
|
+ GetOutPutStr("%s%s", "DiskDrive", "False").c_str());
|
|
|
+ m_strLastErrMsg = CSimpleStringA::Format("查询磁盘序列号失败, 请重启机器并重新初始化");
|
|
|
return false;
|
|
|
}
|
|
|
- //Dbg("harddisk sn: %s", szTmp);
|
|
|
-
|
|
|
+
|
|
|
strRet += "|";
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ //Dbg("harddisk sn: %s", szTmp);
|
|
|
strRet += szTmp;
|
|
|
+#else
|
|
|
+ strTmp = "";
|
|
|
+ vector<string>::iterator it = disk.begin();
|
|
|
+ while (it != disk.end()) {
|
|
|
+ strTmp += *it;
|
|
|
+ it++;
|
|
|
+ }
|
|
|
+ Dbg("harddisk sn: %s", strTmp.c_str());
|
|
|
+ strRet += strTmp.c_str();
|
|
|
+#endif // RVC_OS_WIN
|
|
|
|
|
|
Dbg("device info: [%s]", (const char*)strRet);
|
|
|
-
|
|
|
// md5 hash
|
|
|
BYTE md5[16] = {};
|
|
|
if (!GetMD5Hash((const char*)strRet, md5))
|
|
|
{
|
|
|
-
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_GET_STR_HASH,
|
|
|
GetOutPutStr("%s%s", "GetMD5Hash", "False").c_str());
|
|
|
- //LogError(Severity_Low, Error_Unexpect, ERROR_ACCESSAUTH_GETMD5HASH, "get md5 hash as fingerprint fail");
|
|
|
m_strLastErrMsg = "get md5 hash as fingerprint fail";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (nBufLen < 16)
|
|
|
{
|
|
|
- //LogError(Severity_Low, Error_Unexpect, ERROR_ACCESSAUTH_GETMD5HASH, "GetTerminalFingerPrint, buf len is too small");
|
|
|
m_strLastErrMsg = "GetTerminalFingerPrint, buf len is too small";
|
|
|
Dbg("GetTerminalFingerPrint, buf len is too small.");
|
|
|
return false;
|