User,Utils: move ConstantTimeEquals to CUtils and add tests (#2011)

This commit is contained in:
MarkLee131
2026-04-25 17:37:33 +08:00
parent 794ae6cd60
commit f0c3341e35
5 changed files with 102 additions and 22 deletions
+5
View File
@@ -62,6 +62,11 @@ class CUtils {
static CString SaltedMD5Hash(const CString& sPass, const CString& sSalt);
static CString SaltedSHA256Hash(const CString& sPass, const CString& sSalt);
static CString SaltedHash(const CString& sPass, const CString& sSalt);
/** Byte-wise compare in time proportional to the shorter of the two
* lengths, without short-circuiting on the first differing byte. Used
* for password / hash comparisons so a remote attacker can't recover
* the stored secret one byte at a time via response timing. */
static bool ConstantTimeEquals(const CString& a, const CString& b);
static CString GetPass(const CString& sPrompt);
static bool GetInput(const CString& sPrompt, CString& sRet,
const CString& sDefault = "",