|
@@ -614,12 +614,12 @@ int CAccessAuthEntity::GetPinPadCapability()
|
|
|
}
|
|
|
|
|
|
void CAccessAuthEntity::printPasswdError(const string& strErrMsg){
|
|
|
- //string strErrMsg = "密钥集丢失,请重新初始化密钥!";
|
|
|
SetAuthErrMsg(strErrMsg.c_str());
|
|
|
GetFunction()->SetSysVar("AuthErrMsg", strErrMsg.c_str(), true);
|
|
|
m_FSM.doWarnMsg( ERROR_ACCESSAUTH_OPENCRYPTCONTEXT, strErrMsg.c_str(),true, strErrMsg);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520C")("密钥集丢失(私钥为空)");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520C")(strErrMsg.c_str());
|
|
|
}
|
|
|
+
|
|
|
int Char2Int(char * ch) {
|
|
|
int num = 0;
|
|
|
for (int i = 0;i < strlen(ch);i++) {
|
|
@@ -660,7 +660,7 @@ bool CAccessAuthEntity::SaveAuthKey(BYTE *pKey)
|
|
|
#endif // RVC_OS_WIN
|
|
|
if (strlen(privateKey) <= 0)
|
|
|
{
|
|
|
- printPasswdError("密钥集丢失(私钥为空),请重置秘钥进行初始化");
|
|
|
+ printPasswdError("私钥为空,请重置秘钥进行初始化");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -928,59 +928,6 @@ struct PublicKeyBlob
|
|
|
};
|
|
|
#endif // RVC_OS_WIN
|
|
|
|
|
|
-// 生成SM2密钥对,并导出公钥
|
|
|
-bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen)
|
|
|
-{
|
|
|
- CSimpleStringA runInfoPath, iniPath;
|
|
|
- auto rc = GetFunction()->GetPath("runinfo", runInfoPath);
|
|
|
- if (rc != Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")
|
|
|
- ("GetPath runinfo error=%d.", rc);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- char publicKey[BUF_SIZE] = { 0 };
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- iniPath = runInfoPath + "\\runcfg\\AccessAuthorization.ini";
|
|
|
- GetPrivateProfileString("TerminalPD", "PublicKey", "", publicKey, BUF_SIZE, iniPath.GetData());
|
|
|
-#else
|
|
|
- iniPath = runInfoPath + SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "AccessAuthorization.ini";
|
|
|
- char* tmp = inifile_read_str(iniPath.GetData(), "TerminalPD", "PublicKey", "");
|
|
|
- strcpy(publicKey, tmp);
|
|
|
- delete tmp;
|
|
|
-#endif // RVC_OS_WIN
|
|
|
- if (strlen(publicKey) <= 0) {
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- iniPath = runInfoPath + "\\runcfg\\Initializer.ini";
|
|
|
- GetPrivateProfileString("TerminalPD", "PublicKey", "", publicKey, BUF_SIZE, iniPath.GetData());
|
|
|
-#else
|
|
|
- iniPath = runInfoPath + SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "Initializer.ini";
|
|
|
- char* tmp2 = inifile_read_str(iniPath.GetData(), "TerminalPD", "PublicKey", "");
|
|
|
- strcpy(publicKey, tmp2);
|
|
|
- delete tmp2;
|
|
|
-#endif // RVC_OS_WIN
|
|
|
-
|
|
|
- if (strlen(publicKey) <= 0)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("读取公钥失败,公钥长度小于等于零!");
|
|
|
- if (!ExistsFileA(iniPath))
|
|
|
- printPasswdError("密钥集丢失(公钥为空),请重置秘钥进行初始化");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("publickey=%s,%d", publicKey, strlen(publicKey));
|
|
|
-
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- char* pDecodedPublickey = MyBase64::Hex2Str(publicKey, nBufLen);
|
|
|
-#else
|
|
|
- char* pDecodedPublickey = Hex2Str(publicKey, nBufLen);
|
|
|
-#endif // RVC_OS_WIN
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("pDecodedPublickey len=%d", nBufLen);
|
|
|
- memcpy(pBuf, pDecodedPublickey, nBufLen);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("pBuf[0]=%02X,nBufLen=%d", pBuf[0], nBufLen);
|
|
|
- delete[] pDecodedPublickey;
|
|
|
- return true;
|
|
|
-}
|
|
|
// 生成RSA密钥对,并导出公钥
|
|
|
bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& pubkey)
|
|
|
{
|
|
@@ -1069,7 +1016,8 @@ bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& p
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("encode pri key success.");
|
|
|
|
|
|
m_privateKey = pEncodedCryptPrivateKey;
|
|
|
- /*rc = pConfig->WriteConfigValue("TerminalPD", "PrivateKey", pEncodedCryptPrivateKey);
|
|
|
+ /*//不在这里写入私钥,将逻辑修改到函数外部,等服务端返回成功后再写入私钥
|
|
|
+ rc = pConfig->WriteConfigValue("TerminalPD", "PrivateKey", pEncodedCryptPrivateKey);
|
|
|
if (rc != Error_Succeed) {
|
|
|
rc = pConfig->WriteConfigValue("TerminalPD", "PublicKey", "");
|
|
|
delete[] pEncodedCryptPrivateKey;
|