]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_md5.cpp
Update m_cloaking to use free-form keys instead of weakening the hash IV
[user/henk/code/inspircd.git] / src / modules / m_md5.cpp
index aea9f2806f5f9ee761bf588cf16e9ab84d06457d..9fa4894fdce51c44eb843e78398a25d5413e627d 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -259,17 +259,11 @@ class ModuleMD5 : public Module
                *dest++ = 0;
        }
 
-       unsigned int *key;
-       char* chars;
-
  public:
 
-       ModuleMD5(InspIRCd* Me)
-               : Module(Me), key(NULL), chars(NULL)
+       ModuleMD5()
        {
                ServerInstance->Modules->PublishInterface("HashRequest", this);
-               Implementation eventlist[] = { I_OnRequest };
-               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
        virtual ~ModuleMD5()
@@ -278,39 +272,31 @@ class ModuleMD5 : public Module
        }
 
 
-       virtual const char* OnRequest(Request* request)
+       void OnRequest(Request& request)
        {
-               HashRequest* MD5 = (HashRequest*)request;
-
-               if (strcmp("KEY", request->GetId()) == 0)
-               {
-                       this->key = (unsigned int*)MD5->GetKeyData();
-               }
-               else if (strcmp("HEX", request->GetId()) == 0)
-               {
-                       this->chars = (char*)MD5->GetOutputs();
-               }
-               else if (strcmp("SUM", request->GetId()) == 0)
+               if (strcmp("HASH", request.id) == 0)
                {
-                       static char data[MAXBUF];
-                       GenHash(MD5->GetHashData().data(), data, chars ? chars : "0123456789abcdef", key, MD5->GetHashData().length());
-                       return data;
+                       char res[16];
+                       HashRequest& req = static_cast<HashRequest&>(request);
+                       MyMD5(res, (void*)req.data.data(), req.data.length(), NULL);
+                       req.binresult.assign(res, 16);
                }
-               else if (strcmp("NAME", request->GetId()) == 0)
+               else if (strcmp("HASH-IV", request.id) == 0)
                {
-                       return "md5";
+                       char res[33];
+                       HashRequestIV& req = static_cast<HashRequestIV&>(request);
+                       GenHash(req.data.data(), res, req.map, req.iv, req.data.length());
+                       req.result = res;
                }
-               else if (strcmp("RESET", request->GetId()) == 0)
+               else if (strcmp("NAME", request.id) == 0)
                {
-                       this->chars = NULL;
-                       this->key = NULL;
+                       static_cast<HashNameRequest&>(request).response = "md5";
                }
-               return NULL;
        }
 
-       virtual Version GetVersion()
+       Version GetVersion()
        {
-               return Version("$Id$",VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION);
+               return Version("Allows for MD5 encrypted oper passwords",VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION);
        }
 };