Enhancement: Add HMAC to verify master's Passcode

This commit is contained in:
yuanyuanxiang
2025-12-19 21:16:05 +01:00
parent 5b32eda17d
commit d546e03dd0
4 changed files with 20 additions and 8 deletions

View File

@@ -201,11 +201,13 @@ void CPwdGenDlg::OnBnClickedButtonGenkey()
std::string hashedID = hashSHA256(hardwareID);
std::string deviceID = getFixedLengthID(hashedID);
std::string hmac = genHMAC(pwdHash, m_sUserPwd.GetString());
m_EditHMAC.SetWindowTextA(hmac.c_str());
uint64_t pwdHmac = SignMessage(m_sUserPwd.GetString(), (BYTE*)fixedKey.c_str(), fixedKey.length());
m_EditHMAC.SetWindowTextA(std::to_string(pwdHmac).c_str());
if (deviceID == m_sDeviceID.GetString()) { // 授权的是当前主控程序
auto settings = "settings", pwdKey = "Password";
THIS_CFG.SetStr(settings, pwdKey, fixedKey.c_str());
THIS_CFG.SetStr(settings, "HMAC", hmac);
THIS_CFG.SetStr(settings, "PwdHmac", std::to_string(pwdHmac));
}
}