]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_md5.cpp
Add config <options:disablehmac> to support disabling of HMAC, and tidy up to detect...
[user/henk/code/inspircd.git] / src / modules / m_md5.cpp
index 2500e6b362e19501166eb3dbd995741d7fe9e871..4ed011acf853bb2a26af24344c61e41263db4cbb 100644 (file)
@@ -2,12 +2,9 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
@@ -15,8 +12,7 @@
  */
 
 /* $ModDesc: Allows for MD5 encrypted oper passwords */
-
-using namespace std;
+/* $ModDep: m_hash.h */
 
 #include "inspircd_config.h"
 #ifdef HAS_STDINT
@@ -27,7 +23,7 @@ using namespace std;
 #include "modules.h"
 #include "inspircd.h"
 
-#include "m_md5.h"
+#include "m_hash.h"
 
 /* The four core functions - F1 is optimized somewhat */
 #define F1(x, y, z) (z ^ (x & (y ^ z)))
@@ -277,10 +273,12 @@ class ModuleMD5 : public Module
        ModuleMD5(InspIRCd* Me)
                : Module::Module(Me), key(NULL), chars(NULL)
        {
+               ServerInstance->PublishInterface("HashRequest", this);
        }
        
        virtual ~ModuleMD5()
        {
+               ServerInstance->UnpublishInterface("HashRequest", this);
        }
 
        void Implements(char* List)
@@ -290,22 +288,27 @@ class ModuleMD5 : public Module
        
        virtual char* OnRequest(Request* request)
        {
-               MD5Request* MD5 = (MD5Request*)request;
-               if (strcmp("MD5_KEY", request->GetId()) == 0)
+               HashRequest* MD5 = (HashRequest*)request;
+
+               if (strcmp("KEY", request->GetId()) == 0)
                {
                        this->key = (unsigned int*)MD5->GetKeyData();
                }
-               else if (strcmp("MD5_HEX", request->GetId()) == 0)
+               else if (strcmp("HEX", request->GetId()) == 0)
                {
                        this->chars = (char*)MD5->GetOutputs();
                }
-               else if (strcmp("MD5_SUM", request->GetId()) == 0)
+               else if (strcmp("SUM", request->GetId()) == 0)
                {
                        static char data[MAXBUF];
                        GenHash((const char*)MD5->GetHashData(), data, chars ? chars : "0123456789abcdef", key);
                        return data;
                }
-               else if (strcmp("MD5_RESET", request->GetId()) == 0)
+               else if (strcmp("NAME", request->GetId()) == 0)
+               {
+                       return "md5";
+               }
+               else if (strcmp("RESET", request->GetId()) == 0)
                {
                        this->chars = NULL;
                        this->key = NULL;
@@ -315,7 +318,7 @@ class ModuleMD5 : public Module
 
        virtual Version GetVersion()
        {
-               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
+               return Version(1,1,0,1,VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION);
        }
 };