]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/hmac.cpp
Fix m_chanlog crashing.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / hmac.cpp
index 1aa2afddbc746e26fdd418cd841b0f306aba62e2..4b99a3eb7c3dc051fabfc54a3fdc235bdf970948 100644 (file)
@@ -128,3 +128,20 @@ std::string TreeSocket::RandString(unsigned int length)
        return out;
 }
 
+bool TreeSocket::ComparePass(const std::string &ours, const std::string &theirs)
+{
+       if ((!strncmp(ours.c_str(), "HMAC-SHA256:", 12)) || (!strncmp(theirs.c_str(), "HMAC-SHA256:", 12)))
+       {
+               /* One or both of us specified hmac sha256, but we don't have sha256 module loaded!
+                * We can't allow this password as valid.
+                 */
+               if (!Instance->Modules->Find("m_sha256.so") || !Utils->ChallengeResponse)
+                       return false;
+               else
+                       /* Straight string compare of hashes */
+                       return ours == theirs;
+       }
+       else
+               /* Straight string compare of plaintext */
+               return ours == theirs;
+}