diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-06-28 18:25:05 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-06-28 18:25:05 +0200 |
commit | 098602163498b06ec865ab02625cc0ba19f43786 (patch) | |
tree | 0adb038340313f898056f7bdd00abafb937b4291 /include | |
parent | 0c9a94ea9285d1094c031d0c4ed06326b99cf890 (diff) |
Add InspIRCd::TimingSafeCompare() function that compares strings in a timing-safe way
Diffstat (limited to 'include')
-rw-r--r-- | include/inspircd.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 584a330ba..b16df9d71 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -669,6 +669,15 @@ class CoreExport InspIRCd */ static std::string TimeString(time_t curtime, const char* format = NULL, bool utc = false); + /** Compare two strings in a timing-safe way. If the lengths of the strings differ, the function + * returns false immediately (leaking information about the length), otherwise it compares each + * character and only returns after all characters have been compared. + * @param one First string + * @param two Second string + * @return True if the strings match, false if they don't + */ + static bool TimingSafeCompare(const std::string& one, const std::string& two); + /** Begin execution of the server. * NOTE: this function NEVER returns. Internally, * it will repeatedly loop. |