|
|
@@ -943,6 +943,7 @@ Err:
|
|
|
memset(tmpCheckCode, 0, MAX_PIN_BLOCK_SIZE);
|
|
|
//HexBuf2StrBuf(dstInfo.data,&tmpCheckCode,dstInfo.dwSize);
|
|
|
memcpy(tmpCheckCode, dstInfo.data, dstInfo.dwSize);
|
|
|
+
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ckckck[%s], m_keySNSM:%s", tmpCheckCode, m_keySNSM.GetData());
|
|
|
|
|
|
|
|
|
@@ -1160,40 +1161,8 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
|
|
|
//oilyang@20220308 to calc checkcode if called Initializer
|
|
|
if (ctx->Req.initializeflag)
|
|
|
{
|
|
|
- PBYTE pCtMasterKey = new BYTE[48];
|
|
|
- PBYTE pCtPinKey = new BYTE[48];
|
|
|
- BYTE pinKey[16] = { 0 };
|
|
|
- int pinKeyLen = 16;
|
|
|
-
|
|
|
- int ctMLen = SP::Module::Util::StrBuf2HexBuf(ctx->Req.masterkey.GetData(), &pCtMasterKey);
|
|
|
- int ctPinLen = SP::Module::Util::StrBuf2HexBuf(ctx->Req.workingkey1.GetData(), &pCtPinKey);
|
|
|
- //sm4 decrypt
|
|
|
- sm4_context sm4Contxt;
|
|
|
- sm4_setkey_dec(&sm4Contxt, pCtMasterKey);
|
|
|
- sm4_crypt_ecb(&sm4Contxt, SM4_DECRYPT, ctPinLen, pCtPinKey, (BYTE*)pinKey);
|
|
|
-
|
|
|
- BYTE ck[16] = { 0 };
|
|
|
- BYTE ckCode[128] = { 0 };
|
|
|
- sm4_setkey_enc(&sm4Contxt, pinKey);
|
|
|
- sm4_crypt_ecb(&sm4Contxt, SM4_ENCRYPT, 8, ck, (BYTE*)ckCode);
|
|
|
- char* strCkCode = new char[256];
|
|
|
- memset(strCkCode, 0, 256);
|
|
|
- SP::Module::Util::HexBuf2StrBuf((PBYTE)ckCode, &strCkCode, 16);
|
|
|
- LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_PinPad_CkCode_While_Load_SM, strCkCode);
|
|
|
-
|
|
|
- BYTE ckMaster[16] = { 0 };
|
|
|
- BYTE ckCodeMaster[128] = { 0 };
|
|
|
- sm4_setkey_enc(&sm4Contxt, pCtMasterKey);
|
|
|
- sm4_crypt_ecb(&sm4Contxt, SM4_ENCRYPT, 8, ckMaster, (BYTE*)ckCodeMaster);
|
|
|
- char* strCkCodeMaster = new char[256];
|
|
|
- memset(strCkCodeMaster, 0, 256);
|
|
|
- SP::Module::Util::HexBuf2StrBuf((PBYTE)ckCodeMaster, &strCkCodeMaster, 16);
|
|
|
- GetEntityBase()->GetFunction()->SetSysVar("ckCode", strCkCodeMaster, true);
|
|
|
-
|
|
|
- delete[] pCtMasterKey;
|
|
|
- delete[] pCtPinKey;
|
|
|
- delete[] strCkCode;
|
|
|
- delete[] strCkCodeMaster;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the new check code:%s", ctx->Req.reserved4.GetData());
|
|
|
+ LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_PinPad_CkCode_While_Load_SM, ctx->Req.reserved4);
|
|
|
}
|
|
|
|
|
|
m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
|