Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #558 from ahf/quakenet-sha256

Use HMAC-SHA-256 instead of HMAC-MD5
  • Loading branch information...
commit 26af767ea7d115e191c26e63d7bb105eabffec93 2 parents 5d001cd + 2264812
@DarthGandalf DarthGandalf authored
Showing with 10 additions and 10 deletions.
  1. +10 −10 modules/q.cpp
View
20 modules/q.cpp
@@ -395,12 +395,12 @@ class CQModule : public CModule {
.Replace_n("[", "{")
.Replace_n("]", "}")
.Replace_n("\\", "|");
- CString sPasswordHash = m_sPassword.Left(10).MD5();
- CString sKey = CString(sUsername + ":" + sPasswordHash).MD5();
- CString sResponse = HMAC_MD5(sKey, sChallenge);
+ CString sPasswordHash = m_sPassword.Left(10).SHA256();
+ CString sKey = CString(sUsername + ":" + sPasswordHash).SHA256();
+ CString sResponse = HMAC_SHA256(sKey, sChallenge);
PutModule("Auth: Received challenge, sending CHALLENGEAUTH request...");
- PutQ("CHALLENGEAUTH " + m_sUsername + " " + sResponse + " HMAC-MD5");
+ PutQ("CHALLENGEAUTH " + m_sUsername + " " + sResponse + " HMAC-SHA-256");
}
EModRet HandleMessage(const CNick& Nick, CString sMessage) {
@@ -454,10 +454,10 @@ class CQModule : public CModule {
if (sMessage.find("not available once you have authed") != CString::npos) {
m_bAuthed = true;
} else {
- if (sMessage.find("HMAC-MD5") != CString::npos) {
+ if (sMessage.find("HMAC-SHA-256") != CString::npos) {
ChallengeAuth(sMessage.Token(1));
} else {
- PutModule("Auth failed: Q does not support HMAC-MD5 for CHALLENGEAUTH, falling back to standard AUTH.");
+ PutModule("Auth failed: Q does not support HMAC-SHA-256 for CHALLENGEAUTH, falling back to standard AUTH.");
SetUseChallenge(false);
Auth();
}
@@ -531,10 +531,10 @@ class CQModule : public CModule {
return true;
}
- CString HMAC_MD5(const CString& sKey, const CString& sData) {
+ CString HMAC_SHA256(const CString& sKey, const CString& sData) {
CString sRealKey;
if (sKey.length() > 64)
- PackHex(sKey.MD5(), sRealKey);
+ PackHex(sKey.SHA256(), sRealKey);
else
sRealKey = sKey;
@@ -547,8 +547,8 @@ class CQModule : public CModule {
}
CString sInnerHash;
- PackHex(CString(sInnerKey + sData).MD5(), sInnerHash);
- return CString(sOuterKey + sInnerHash).MD5();
+ PackHex(CString(sInnerKey + sData).SHA256(), sInnerHash);
+ return CString(sOuterKey + sInnerHash).SHA256();
}
/* Settings */
Please sign in to comment.
Something went wrong with that request. Please try again.