diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-04 11:49:43 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-04 11:49:43 +0000 |
commit | dd0f59211e200c9c29f8c76daa7e5b24fb392613 (patch) | |
tree | 200c079bde17ba28edd36681a82d10f153e7eb1c | |
parent | a3f89e772514aca9aa4615ebe1656010111fc455 (diff) |
Move a piece of HMAC to hmac.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8815 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_spanningtree/hmac.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 18 |
2 files changed, 17 insertions, 18 deletions
diff --git a/src/modules/m_spanningtree/hmac.cpp b/src/modules/m_spanningtree/hmac.cpp index 1aa2afddb..4b99a3eb7 100644 --- a/src/modules/m_spanningtree/hmac.cpp +++ b/src/modules/m_spanningtree/hmac.cpp @@ -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; +} diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 5673aae6a..7fbf9b4ad 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -119,24 +119,6 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string> return true; } -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; -} - bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> ¶ms) { if (params.size() < 5) |