|
@@ -6,7 +6,6 @@
|
|
|
#include "ModuleMix.h"
|
|
|
#include "PinPad_UserErrorCode.h"
|
|
|
#include "CommDevEntityErrorCode.h"
|
|
|
-#include "mod_DevAdptEntityBase.hpp"
|
|
|
#include <map>
|
|
|
#include <thread>
|
|
|
#include <chrono>
|
|
@@ -41,29 +40,6 @@ ErrorCodeEnum CPinPadFSM::OnInit()
|
|
|
m_bPinPadNeedless = TRUE;
|
|
|
if (_strnicmp((const char*)m_csMachineType, "RVC.IL", strlen("RVC.IL")) == 0)
|
|
|
m_bRVCIL = true;
|
|
|
- CEntityStaticInfo esi = {0};
|
|
|
- ErrorCodeEnum ec = GetEntityBase()->GetFunction()->GetEntityStaticInfo(
|
|
|
- GetEntityBase()->GetEntityName(), esi);
|
|
|
- if(ec == Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("wEntityDevelopID: 0x%X", esi.wEntityDevelopID);
|
|
|
- HARDWARE_ENTITY_RESET_ENTITYID(m_entCode, esi.wEntityDevelopID);
|
|
|
- }
|
|
|
-
|
|
|
- //CEntityRunInfo eri = {0};
|
|
|
- //ec = GetEntityBase()->GetFunction()->GetSelfEntityRunInfo(eri);
|
|
|
- //if(ec == Error_Succeed)
|
|
|
- //{
|
|
|
- // Dbg("dwEntityInstanceID: 0x%X", eri.dwEntityInstanceID);
|
|
|
- //}
|
|
|
-
|
|
|
- //m_hInputEvt = CreateEventA(NULL,FALSE,FALSE,NULL);
|
|
|
- //if (m_hInputEvt == NULL)
|
|
|
- //{
|
|
|
- // Dbg("CreateEvent failed(%d).",GetLastError());
|
|
|
- // LogWarn(Severity_Middle, Error_Unexpect, AlarmDECToBusiness(MEC_CREATE_EVENT_FAILED), "OnInit:CreateEventA failed.");
|
|
|
- // return Error_Resource;
|
|
|
- //}
|
|
|
|
|
|
std::thread tmp_thread(&CPinPadFSM::DoWork, this);
|
|
|
tmp_thread.detach();
|
|
@@ -77,16 +53,10 @@ ErrorCodeEnum CPinPadFSM::OnExit()
|
|
|
//SetEvent(m_hInputEvt);
|
|
|
m_hInputConVar.Broadcast();
|
|
|
ErrorCodeEnum eErr = Error_Succeed;
|
|
|
- if (m_pPinPad != NULL)
|
|
|
+ if (m_hDevHelper)
|
|
|
{
|
|
|
- m_pPinPad->StopInput();
|
|
|
- eErr = ReleaseDevComponent((DeviceBaseClass*&)m_pPinPad);
|
|
|
- if (eErr != Error_Succeed)
|
|
|
- {
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, AlarmDECToBusiness(MEC_DEV_OBJECT_RELEASE_FAILED), "OnExit:ReleaseDevComponent failed.");
|
|
|
- Dbg("ReleaseDevComponent failed(%d).",eErr);
|
|
|
- }
|
|
|
- m_pPinPad = NULL;
|
|
|
+ m_hDevHelper->StopInput();
|
|
|
+ m_hDevHelper.TearDown();
|
|
|
}
|
|
|
return eErr;
|
|
|
}
|
|
@@ -475,7 +445,7 @@ int CPinPadFSM::Initial()
|
|
|
do
|
|
|
{
|
|
|
Dbg("dodo");
|
|
|
- if (m_pPinPad == NULL)
|
|
|
+ if (!m_hDevHelper)
|
|
|
{
|
|
|
eErrCode = m_hDevHelper.CreateDevAdptObject();
|
|
|
if(eErrCode != Error_Succeed)
|
|
@@ -485,22 +455,21 @@ int CPinPadFSM::Initial()
|
|
|
initTries++;
|
|
|
continue;
|
|
|
}
|
|
|
- m_pPinPad = m_hDevHelper.GetDevPointer();
|
|
|
}
|
|
|
//PinPadInitParam initParam;
|
|
|
|
|
|
|
|
|
Dbg("%d,%d",port,baudRate);
|
|
|
- hr = m_pPinPad->DevOpen(port,baudRate);
|
|
|
+ hr = m_hDevHelper->DevOpen(port,baudRate);
|
|
|
|
|
|
if (hr == Error_Succeed)
|
|
|
{
|
|
|
initTries = 0;
|
|
|
ErrorCodeEnum errCode1,errCode2,errCode3,errCode4;
|
|
|
- errCode1 = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
|
|
|
- errCode2 = m_pPinPad->SetParam(EPP_PT_SET_MAC_ALGORITH,EPP_MAC_ALGO_ASNIX99);
|
|
|
- errCode3 = m_pPinPad->SetParam(EPP_PT_SET_PIN_ALGORITH,EPP_PIN_ALGO_ISO9564_1_ANSI);
|
|
|
- errCode4 = m_pPinPad->SetParam(EPP_PT_SET_ECB_CBC_MODE,EPP_ALGO_MODE_3DEC_CBC);
|
|
|
+ errCode1 = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
|
|
|
+ errCode2 = m_hDevHelper->SetParam(EPP_PT_SET_MAC_ALGORITH,EPP_MAC_ALGO_ASNIX99);
|
|
|
+ errCode3 = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH,EPP_PIN_ALGO_ISO9564_1_ANSI);
|
|
|
+ errCode4 = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE,EPP_ALGO_MODE_3DEC_CBC);
|
|
|
if(errCode1 != Error_Succeed || errCode2 != Error_Succeed
|
|
|
|| errCode3 != Error_Succeed || errCode4 != Error_Succeed)
|
|
|
{
|
|
@@ -532,7 +501,7 @@ int CPinPadFSM::Initial()
|
|
|
LOG_TRACE("Open pinpad suc.");
|
|
|
//oiltmp comment the following 20160406
|
|
|
//update with the version 1.7.1
|
|
|
- m_encryptkey = m_pPinPad->GetEncryptFunc();
|
|
|
+ m_encryptkey = m_hDevHelper->GetEncryptFunc();
|
|
|
//m_encryptkey = 1;
|
|
|
eErrDev = spEntityFunction->OpenConfig(Config_Run, spConfig);
|
|
|
if (eErrDev != Error_Succeed)
|
|
@@ -557,7 +526,7 @@ int CPinPadFSM::Initial()
|
|
|
ZeroMemory(devInfo.szModel, MAX_DEV_MODEL_LEN);
|
|
|
ZeroMemory(devInfo.szType, MAX_DEV_TYPE_LEN);
|
|
|
ZeroMemory(devInfo.szVendor, MAX_DEV_VENDOR_LEN);
|
|
|
- eErrDev = m_pPinPad->GetDevCategory(devInfo);
|
|
|
+ eErrDev = m_hDevHelper->GetDevCategory(devInfo);
|
|
|
if (eErrDev == Error_Succeed)
|
|
|
{
|
|
|
m_szModel = devInfo.szModel;
|
|
@@ -811,7 +780,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInput_
|
|
|
//memcpy(accInfo.account,"588571006555",12);
|
|
|
accInfo.dwAccLen = 12;
|
|
|
Dbg("acc(%s)",accInfo.account);
|
|
|
- errCode = m_pPinPad->SetAccNo(accInfo);
|
|
|
+ errCode = m_hDevHelper->SetAccNo(accInfo);
|
|
|
if (errCode != Error_Succeed)
|
|
|
{
|
|
|
if (!bSM)
|
|
@@ -822,9 +791,9 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInput_
|
|
|
return Error_DevCommFailed;
|
|
|
}
|
|
|
if (!bSMFlag)
|
|
|
- errCode = m_pPinPad->ActiveWorkingKey(0,0);
|
|
|
+ errCode = m_hDevHelper->ActiveWorkingKey(0,0);
|
|
|
else
|
|
|
- errCode = m_pPinPad->ActiveWorkingKey(1,0);
|
|
|
+ errCode = m_hDevHelper->ActiveWorkingKey(1,0);
|
|
|
if (errCode != Error_Succeed)
|
|
|
{
|
|
|
LOG_PINPAD_ERROR_MSG_MACRO(errCode, ActiveWorkingKey);
|
|
@@ -833,13 +802,13 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInput_
|
|
|
}
|
|
|
if (!bSMFlag)
|
|
|
{
|
|
|
- //errCode = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_3DES);
|
|
|
- errCode = m_pPinPad->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_ISO9564_1_ANSI);
|
|
|
+ //errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_3DES);
|
|
|
+ errCode = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_ISO9564_1_ANSI);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //errCode = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
|
|
|
- errCode = m_pPinPad->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
|
|
|
+ //errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
|
|
|
+ errCode = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
|
|
|
}
|
|
|
if (errCode != Error_Succeed)
|
|
|
{
|
|
@@ -848,7 +817,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInput_
|
|
|
return Error_DevCommFailed;
|
|
|
}
|
|
|
Dbg("to start");
|
|
|
- errCode = m_pPinPad->StartPinInput(len);
|
|
|
+ errCode = m_hDevHelper->StartPinInput(len);
|
|
|
if (errCode != Error_Succeed)
|
|
|
{
|
|
|
LOG_PINPAD_ERROR_MSG_MACRO(errCode, StartPinInput);
|
|
@@ -884,7 +853,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInput_
|
|
|
//char ch[4] = {0};
|
|
|
BYTE btCh;
|
|
|
Sleep(100);
|
|
|
- errCode = m_pPinPad->KeyRead(btCh);
|
|
|
+ errCode = m_hDevHelper->KeyRead(btCh);
|
|
|
if (errCode == Error_Succeed) {
|
|
|
LogEvent(Severity_Middle,LOG_EVT_PINPAD_OP,"PinPad op.");
|
|
|
if (btCh == 0x0d) {
|
|
@@ -947,7 +916,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInput_
|
|
|
//strOutput = buf;
|
|
|
Err:
|
|
|
//oilyang 20131017 commented
|
|
|
- //errCode = m_pPinPad->StopInput();
|
|
|
+ //errCode = m_hDevHelper->StopInput();
|
|
|
//if (errCode != Error_Succeed)
|
|
|
// Dbg("StopInput failed(%d).",errCode);
|
|
|
//else
|
|
@@ -976,7 +945,7 @@ Err:
|
|
|
PinBlock pinBlk;
|
|
|
Dbg("to getpinblk");
|
|
|
Sleep(500);//nantian
|
|
|
- errCode = m_pPinPad->GetPinBlock(pinBlk);
|
|
|
+ errCode = m_hDevHelper->GetPinBlock(pinBlk);
|
|
|
Dbg("getpinblock(%d),size:%d",errCode,pinBlk.dwSize);
|
|
|
if (errCode == Error_Succeed)
|
|
|
{
|
|
@@ -1011,11 +980,11 @@ Err:
|
|
|
memset(dstInfo.data,0,MAX_EN_DECRYPT_DATA_SIZE);
|
|
|
//set param
|
|
|
if (!bSMFlag)
|
|
|
- errCode = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_3DES);
|
|
|
+ errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_3DES);
|
|
|
else
|
|
|
- errCode = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
|
|
|
+ errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
|
|
|
if (errCode == Error_Succeed)
|
|
|
- errCode = m_pPinPad->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
|
|
|
+ errCode = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
|
|
|
|
|
|
if (errCode != Error_Succeed)
|
|
|
{
|
|
@@ -1023,7 +992,7 @@ Err:
|
|
|
LOG_PINPAD_ERROR_MSG_MACRO(errCode, SetParam);
|
|
|
return Error_Param;
|
|
|
}
|
|
|
- errCode = m_pPinPad->EncryptData(srcInfo,dstInfo);
|
|
|
+ errCode = m_hDevHelper->EncryptData(srcInfo,dstInfo);
|
|
|
//if (tmpCheckData != NULL)
|
|
|
//{
|
|
|
// delete []tmpCheckData;
|
|
@@ -1103,7 +1072,7 @@ void CPinPadFSM::OpenInputText(void *pUserdata)
|
|
|
|
|
|
if (!m_bPlainOpen)
|
|
|
{
|
|
|
- err = m_pPinPad->StartPlainInput();
|
|
|
+ err = m_hDevHelper->StartPlainInput();
|
|
|
if (err == Error_Succeed)
|
|
|
{
|
|
|
Dbg("start any input");
|
|
@@ -1134,14 +1103,14 @@ void CPinPadFSM::OpenInputText(void *pUserdata)
|
|
|
//{
|
|
|
// m_dwPinPadRunCount = 0;
|
|
|
// Dbg("stop input in period");
|
|
|
- // m_pPinPad->StopInput();
|
|
|
+ // m_hDevHelper->StopInput();
|
|
|
// m_bPlainOpen = false;
|
|
|
//}
|
|
|
|
|
|
|
|
|
BYTE btCh;
|
|
|
INT64 i64Start = get_tick_count();
|
|
|
- err = m_pPinPad->KeyRead(btCh);
|
|
|
+ err = m_hDevHelper->KeyRead(btCh);
|
|
|
INT64 i64End = get_tick_count();
|
|
|
if ((i64End - i64Start) > 3000)//more than 3 seconds
|
|
|
Dbg("KeyRead cost more than %d seconds.", (i64End - i64Start)/1000);
|
|
@@ -1191,7 +1160,7 @@ ErrorCodeEnum CPinPadFSM::GetText(SpReqAnsContext<PinPadService_GetInput_Req, Pi
|
|
|
//bool bPlainOpen = false;
|
|
|
ErrorCodeEnum err;
|
|
|
//the following several lines just for Nantian as they close pinpad while mag encrypted improve. oilyang 20150513
|
|
|
- err = m_pPinPad->StopInput();
|
|
|
+ err = m_hDevHelper->StopInput();
|
|
|
m_bPlainOpen = false;
|
|
|
Dbg("plain input for nt.%d",err);
|
|
|
Sleep(100);
|
|
@@ -1222,7 +1191,7 @@ ErrorCodeEnum CPinPadFSM::GetText(SpReqAnsContext<PinPadService_GetInput_Req, Pi
|
|
|
if (!m_bPlainOpen)
|
|
|
{
|
|
|
Dbg("start plain input");
|
|
|
- err = m_pPinPad->StartPlainInput();
|
|
|
+ err = m_hDevHelper->StartPlainInput();
|
|
|
if (err == Error_Succeed)
|
|
|
m_bPlainOpen = true;
|
|
|
else
|
|
@@ -1234,11 +1203,11 @@ ErrorCodeEnum CPinPadFSM::GetText(SpReqAnsContext<PinPadService_GetInput_Req, Pi
|
|
|
BYTE btCh;
|
|
|
Sleep(100);//oiltest
|
|
|
//Dbg("start plain KeyRead");
|
|
|
- err = m_pPinPad->KeyRead(btCh);
|
|
|
+ err = m_hDevHelper->KeyRead(btCh);
|
|
|
//Dbg("end plain KeyRead");
|
|
|
if (err == Error_Succeed) {
|
|
|
//DevErrorInfo devErrInfo;
|
|
|
- //m_pPinPad->GetLastErr(devErrInfo);
|
|
|
+ //m_hDevHelper->GetLastErr(devErrInfo);
|
|
|
//Dbg("[%s]",devErrInfo.szErrMsg);
|
|
|
LogEvent(Severity_Middle,LOG_EVT_PINPAD_OP,"PinPad op(T).");
|
|
|
if (btCh == 0x0d) {
|
|
@@ -1356,7 +1325,7 @@ int CPinPadFSM::GetInput(SpReqAnsContext<PinPadService_GetInput_Req, PinPadServi
|
|
|
m_bExit = false;
|
|
|
LogEvent(Severity_Middle,LOG_EVT_PINPAD_GREEN_ON,"PinPad light on.");
|
|
|
//LogEvent(Severity_Middle,LOG_EVT_PINPAD_GREEN_ON,"PinPad green light on.");
|
|
|
- if (m_pPinPad == NULL)
|
|
|
+ if (!m_hDevHelper)
|
|
|
{
|
|
|
LOG_TRACE("PinPad is not available£¡");
|
|
|
if (!bSM)
|
|
@@ -1390,7 +1359,7 @@ int CPinPadFSM::GetInput(SpReqAnsContext<PinPadService_GetInput_Req, PinPadServi
|
|
|
//oilyang@20200428 call StopInput
|
|
|
//if (m_bPlainOpen)
|
|
|
{
|
|
|
- ErrorCodeEnum errClosePinPad = m_pPinPad->StopInput();
|
|
|
+ ErrorCodeEnum errClosePinPad = m_hDevHelper->StopInput();
|
|
|
Dbg("close pinpad(%d).",errClosePinPad);
|
|
|
Sleep(100);
|
|
|
m_bPlainOpen = false;
|
|
@@ -1432,7 +1401,7 @@ int CPinPadFSM::LoadKey(SpReqAnsContext<PinPadService_LoadKeys_Req, PinPadServic
|
|
|
spConfig = NULL;
|
|
|
}
|
|
|
if (m_bPlainOpen)
|
|
|
- m_pPinPad->StopInput();
|
|
|
+ m_hDevHelper->StopInput();
|
|
|
//initialization need load master key
|
|
|
if (ctx->Req.initializeflag)
|
|
|
{
|
|
@@ -1442,7 +1411,7 @@ int CPinPadFSM::LoadKey(SpReqAnsContext<PinPadService_LoadKeys_Req, PinPadServic
|
|
|
memset(mkParam.key,0,MAX_MASTER_KEY_SIZE);
|
|
|
memcpy(mkParam.key,ctx->Req.masterkey,strlen(ctx->Req.masterkey));
|
|
|
//Dbg("%s,%d",mkParam.key,mkParam.dwSN);
|
|
|
- eErr = m_pPinPad->LoadMasterKey(mkParam);
|
|
|
+ eErr = m_hDevHelper->LoadMasterKey(mkParam);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("Load master key failed(%d).",eErr);
|
|
@@ -1467,7 +1436,7 @@ int CPinPadFSM::LoadKey(SpReqAnsContext<PinPadService_LoadKeys_Req, PinPadServic
|
|
|
memcpy(wkParam1.key,ctx->Req.workingkey1,strlen(ctx->Req.workingkey1));
|
|
|
memcpy(wkParam2.key,ctx->Req.workingkey2,strlen(ctx->Req.workingkey2));
|
|
|
wkParam1.smFlag = 0;
|
|
|
- eErr = m_pPinPad->LoadWorkingKey(wkParam1);
|
|
|
+ eErr = m_hDevHelper->LoadWorkingKey(wkParam1);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("load working key 1 failed(%d).",eErr);
|
|
@@ -1480,7 +1449,7 @@ int CPinPadFSM::LoadKey(SpReqAnsContext<PinPadService_LoadKeys_Req, PinPadServic
|
|
|
}
|
|
|
Dbg("Load working key1 suc.");
|
|
|
wkParam2.smFlag = 0;
|
|
|
- eErr = m_pPinPad->LoadWorkingKey(wkParam2);
|
|
|
+ eErr = m_hDevHelper->LoadWorkingKey(wkParam2);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("load working key 2 failed(%d).",eErr);
|
|
@@ -1512,9 +1481,9 @@ int CPinPadFSM::Encrypt(SpReqAnsContext<PinPadService_EncryptData_Req, PinPadSer
|
|
|
LOG_FUNCTION();
|
|
|
ErrorCodeEnum eErr;
|
|
|
//set param
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
|
|
|
if (eErr == Error_Succeed)
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ECB_CBC_MODE,EPP_ALGO_MODE_3DEC_CBC);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE,EPP_ALGO_MODE_3DEC_CBC);
|
|
|
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
@@ -1526,7 +1495,7 @@ int CPinPadFSM::Encrypt(SpReqAnsContext<PinPadService_EncryptData_Req, PinPadSer
|
|
|
return 0;
|
|
|
}
|
|
|
Dbg("SetParam ok.");
|
|
|
- eErr = m_pPinPad->ActiveWorkingKey(0, 1);
|
|
|
+ eErr = m_hDevHelper->ActiveWorkingKey(0, 1);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
//Dbg("pinpad activate WK error,(%d)",eErr);
|
|
@@ -1544,7 +1513,7 @@ int CPinPadFSM::Encrypt(SpReqAnsContext<PinPadService_EncryptData_Req, PinPadSer
|
|
|
srcData.dwSize = strlen(ctx->Req.data);
|
|
|
memcpy(srcData.data,ctx->Req.data,srcData.dwSize);
|
|
|
|
|
|
- eErr = m_pPinPad->EncryptData(srcData,dstData);
|
|
|
+ eErr = m_hDevHelper->EncryptData(srcData,dstData);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
//Dbg("Encrypt data failed(%d).",eErr);
|
|
@@ -1577,7 +1546,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
|
|
|
spConfig = NULL;
|
|
|
}
|
|
|
if (m_bPlainOpen)
|
|
|
- m_pPinPad->StopInput();
|
|
|
+ m_hDevHelper->StopInput();
|
|
|
bool bSM = false;
|
|
|
if (ctx->Req.smflag == 1)
|
|
|
bSM = true;
|
|
@@ -1594,7 +1563,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
|
|
|
Dbg("mkey len:%d", strlen(ctx->Req.masterkey));
|
|
|
memcpy(mkParam.key,ctx->Req.masterkey,strlen(ctx->Req.masterkey));
|
|
|
//Dbg("%s,%d",mkParam.key,mkParam.dwSN);
|
|
|
- eErr = m_pPinPad->LoadMasterKey(mkParam);
|
|
|
+ eErr = m_hDevHelper->LoadMasterKey(mkParam);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("Load master key(%d),mkeysn:%d failed(%d).",bSM,mkParam.dwSN,eErr);
|
|
@@ -1628,7 +1597,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
|
|
|
wkParam2.smFlag = ctx->Req.smflag;
|
|
|
memcpy(wkParam1.key,ctx->Req.workingkey1,strlen(ctx->Req.workingkey1));
|
|
|
memcpy(wkParam2.key,ctx->Req.workingkey2,strlen(ctx->Req.workingkey2));
|
|
|
- eErr = m_pPinPad->LoadWorkingKey(wkParam1);
|
|
|
+ eErr = m_hDevHelper->LoadWorkingKey(wkParam1);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("load working key 1(%d) failed(%d).",bSM,eErr);
|
|
@@ -1641,7 +1610,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
|
|
|
}
|
|
|
Dbg("Load working key1(%d) suc.",bSM);
|
|
|
|
|
|
- eErr = m_pPinPad->LoadWorkingKey(wkParam2);
|
|
|
+ eErr = m_hDevHelper->LoadWorkingKey(wkParam2);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("load working key 2(%d) failed(%d).",bSM,eErr);
|
|
@@ -1683,12 +1652,12 @@ int CPinPadFSM::EncryptSM(SpReqAnsContext<PinPadService_EncryptDataSM_Req, PinPa
|
|
|
bSM = true;
|
|
|
//set param
|
|
|
if (!bSM)
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
|
|
|
else
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_SM4);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_SM4);
|
|
|
|
|
|
if (eErr == Error_Succeed)
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ECB_CBC_MODE,EPP_ALGO_MODE_CBC);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE,EPP_ALGO_MODE_CBC);
|
|
|
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
@@ -1701,9 +1670,9 @@ int CPinPadFSM::EncryptSM(SpReqAnsContext<PinPadService_EncryptDataSM_Req, PinPa
|
|
|
}
|
|
|
Dbg("SetParam ok.");
|
|
|
if (!bSM)
|
|
|
- eErr = m_pPinPad->ActiveWorkingKey(0, 1);
|
|
|
+ eErr = m_hDevHelper->ActiveWorkingKey(0, 1);
|
|
|
else
|
|
|
- eErr = m_pPinPad->ActiveWorkingKey(1, 1);
|
|
|
+ eErr = m_hDevHelper->ActiveWorkingKey(1, 1);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("pinpad activate WK error,(%d)",eErr);
|
|
@@ -1720,7 +1689,7 @@ int CPinPadFSM::EncryptSM(SpReqAnsContext<PinPadService_EncryptDataSM_Req, PinPa
|
|
|
srcData.dwSize = strlen(ctx->Req.data);
|
|
|
memcpy(srcData.data,ctx->Req.data,srcData.dwSize);
|
|
|
|
|
|
- eErr = m_pPinPad->EncryptData(srcData,dstData);
|
|
|
+ eErr = m_hDevHelper->EncryptData(srcData,dstData);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
Dbg("Encrypt data failed(%d).",eErr);
|
|
@@ -1750,16 +1719,16 @@ int CPinPadFSM::GetCheckCode(SpReqAnsContext<PinPadService_GetCheckCode_Req, Pin
|
|
|
Dbg("mSN:%d,wSN:%d", ctx->Req.mSN[i], ctx->Req.wSN[i]);
|
|
|
//set param
|
|
|
if (ctx->Req.mSN[i] == 1)
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
|
|
|
else
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_3DES);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_3DES);
|
|
|
if (eErr == Error_Succeed)
|
|
|
- eErr = m_pPinPad->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
|
|
|
+ eErr = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
|
|
|
else
|
|
|
{
|
|
|
LOG_PINPAD_ERROR_MSG_MACRO(eErr, SetParam);
|
|
|
}
|
|
|
- eErr = m_pPinPad->ActiveWorkingKey(ctx->Req.mSN[i], ctx->Req.wSN[i]);
|
|
|
+ eErr = m_hDevHelper->ActiveWorkingKey(ctx->Req.mSN[i], ctx->Req.wSN[i]);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
LOG_PINPAD_ERROR_MSG_MACRO(eErr, ActiveWorkingKey);
|
|
@@ -1774,7 +1743,7 @@ int CPinPadFSM::GetCheckCode(SpReqAnsContext<PinPadService_GetCheckCode_Req, Pin
|
|
|
srcInfo.dwSize = m_devCheckData.GetLength();
|
|
|
memset(dstInfo.data, 0, MAX_EN_DECRYPT_DATA_SIZE);
|
|
|
|
|
|
- eErr = m_pPinPad->EncryptData(srcInfo, dstInfo);
|
|
|
+ eErr = m_hDevHelper->EncryptData(srcInfo, dstInfo);
|
|
|
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
@@ -1794,7 +1763,7 @@ bool CPinPadFSM::GetDevInfo(DevCategoryInfo &devInfo)
|
|
|
ZeroMemory(info.szModel, MAX_DEV_MODEL_LEN);
|
|
|
ZeroMemory(info.szType, MAX_DEV_TYPE_LEN);
|
|
|
ZeroMemory(info.szVendor, MAX_DEV_VENDOR_LEN);
|
|
|
- ErrorCodeEnum eErrDev = m_pPinPad->GetDevCategory(info);
|
|
|
+ ErrorCodeEnum eErrDev = m_hDevHelper->GetDevCategory(info);
|
|
|
if (eErrDev == Error_Succeed)
|
|
|
{
|
|
|
m_szModel = info.szModel;
|
|
@@ -1852,28 +1821,7 @@ void CPinPadFSM::SelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionCon
|
|
|
else
|
|
|
pTransactionContext->SendAnswer(m_testResult);
|
|
|
//DevCategoryInfo devCatInfo;
|
|
|
- //ErrorCodeEnum eErr = m_pPinPad->GetDevCategory(devCatInfo);
|
|
|
-}
|
|
|
-void CPinPadFSM::LogErrMsg(const char *pMsgHead, ErrorCodeEnum eErrCode, DWORD defaultDevCode, BOOL bAlarm)
|
|
|
-{
|
|
|
- WORD wdErrCode = 0;
|
|
|
- CSimpleStringA csErrMsg(true);
|
|
|
- ErrorCodeEnum ec = DeviceBaseHelper::GetAndSplitDevErrInfo(m_pPinPad, csErrMsg, wdErrCode,
|
|
|
- bAlarm ? NULL : pMsgHead);
|
|
|
- if(ec == Error_Succeed && wdErrCode != 0) {
|
|
|
- //oilyang@20200525 if have been set ErrorCode of entity defined (not device),use it directly
|
|
|
- if ((defaultDevCode >> 20) == m_entCode.dwEntityId)
|
|
|
- UpdateDEC(defaultDevCode);
|
|
|
- else
|
|
|
- UpdateDEC(wdErrCode);
|
|
|
- } else if(defaultDevCode != 0) {
|
|
|
- UpdateDEC(defaultDevCode);
|
|
|
- }
|
|
|
- m_csAlarmMsg = CSimpleStringA::Format("%s failed EC= 0x%x : %s", pMsgHead, eErrCode, (LPCTSTR)csErrMsg);
|
|
|
- if(bAlarm) {
|
|
|
- LogWarn(Severity_High, eErrCode, AlarmDECToBusiness(), (LPCTSTR)m_csAlarmMsg);
|
|
|
- }
|
|
|
- return;
|
|
|
+ //ErrorCodeEnum eErr = m_hDevHelper->GetDevCategory(devCatInfo);
|
|
|
}
|
|
|
|
|
|
void CPinPadFSM::CrossTermCall(SpReqAnsContext<PinPadService_CrossTermCall_Req, PinPadService_CrossTermCall_Ans>::Pointer cctx)
|