Improve: Generate HMAC while generating pass code

This commit is contained in:
yuanyuanxiang
2025-11-08 21:16:51 +08:00
parent 0f0dc968f7
commit 2cb46a57e6
5 changed files with 8 additions and 1 deletions

Binary file not shown.

View File

@@ -3139,8 +3139,10 @@ void CMy2015RemoteDlg::OnToolInputPassword()
CInputDialog dlg(this); CInputDialog dlg(this);
dlg.m_str = pwd; dlg.m_str = pwd;
dlg.Init("更改口令", "请输入新的口令:"); dlg.Init("更改口令", "请输入新的口令:");
dlg.Init2("HMAC (非必须):", THIS_CFG.GetStr("settings", "HMAC", "").c_str());
if (dlg.DoModal() == IDOK) { if (dlg.DoModal() == IDOK) {
THIS_CFG.SetStr("settings", "Password", dlg.m_str.GetString()); THIS_CFG.SetStr("settings", "Password", dlg.m_str.GetString());
THIS_CFG.SetStr("settings", "HMAC", dlg.m_sSecondInput.GetString());
#ifdef _DEBUG #ifdef _DEBUG
SetTimer(TIMER_CHECK, 10 * 1000, NULL); SetTimer(TIMER_CHECK, 10 * 1000, NULL);
#else #else
@@ -3613,7 +3615,7 @@ LRESULT CALLBACK CMy2015RemoteDlg::LowLevelKeyboardProc(int nCode, WPARAM wParam
} }
} }
} }
else if (g_2015RemoteDlg->m_pActiveSession) else if (g_2015RemoteDlg->m_pActiveSession && operateWnd)
{ {
auto screen = (CScreenSpyDlg*)(g_2015RemoteDlg->m_pActiveSession); auto screen = (CScreenSpyDlg*)(g_2015RemoteDlg->m_pActiveSession);
if (!screen->m_bIsCtrl) { if (!screen->m_bIsCtrl) {

View File

@@ -164,6 +164,7 @@ void CPwdGenDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_EDIT_HOSTNUM, m_EditHostNum); DDX_Control(pDX, IDC_EDIT_HOSTNUM, m_EditHostNum);
DDX_Text(pDX, IDC_EDIT_HOSTNUM, m_nHostNum); DDX_Text(pDX, IDC_EDIT_HOSTNUM, m_nHostNum);
DDV_MinMaxInt(pDX, m_nHostNum, 2, 10000); DDV_MinMaxInt(pDX, m_nHostNum, 2, 10000);
DDX_Control(pDX, IDC_EDIT_HMAC, m_EditHMAC);
} }
@@ -197,9 +198,12 @@ void CPwdGenDlg::OnBnClickedButtonGenkey()
std::string hardwareID = getHardwareID(); std::string hardwareID = getHardwareID();
std::string hashedID = hashSHA256(hardwareID); std::string hashedID = hashSHA256(hardwareID);
std::string deviceID = getFixedLengthID(hashedID); std::string deviceID = getFixedLengthID(hashedID);
std::string hmac = genHMAC(pwdHash, m_sUserPwd.GetString());
m_EditHMAC.SetWindowTextA(hmac.c_str());
if (deviceID == m_sDeviceID.GetString()) { // 授权的是当前主控程序 if (deviceID == m_sDeviceID.GetString()) { // 授权的是当前主控程序
auto settings = "settings", pwdKey = "Password"; auto settings = "settings", pwdKey = "Password";
THIS_CFG.SetStr(settings, pwdKey, fixedKey.c_str()); THIS_CFG.SetStr(settings, pwdKey, fixedKey.c_str());
THIS_CFG.SetStr(settings, "HMAC", hmac);
} }
} }

View File

@@ -76,4 +76,5 @@ public:
virtual BOOL OnInitDialog(); virtual BOOL OnInitDialog();
CEdit m_EditHostNum; CEdit m_EditHostNum;
int m_nHostNum; int m_nHostNum;
CEdit m_EditHMAC;
}; };

Binary file not shown.