X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_md5.cpp;h=6096f9afa9bd4116f4449f9a0b91633eb3e7601a;hb=f9ef4ebc9dc4fd46cdafcc76df644b4896251dac;hp=3b7df836994ce1d24219d95184745cd9206919d7;hpb=2b8ce39c6ea5e7a22fe39b21756f82051465f143;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index 3b7df8369..6096f9afa 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -18,9 +18,6 @@ #ifdef HAS_STDINT #include #endif -#include "users.h" -#include "channels.h" -#include "modules.h" #include "m_hash.h" /* The four core functions - F1 is optimized somewhat */ @@ -64,10 +61,10 @@ class ModuleMD5 : public Module } while (--words); } - void MD5Init(MD5Context *ctx, unsigned int* key = NULL) + void MD5Init(MD5Context *ctx, unsigned int* ikey = NULL) { /* These are the defaults for md5 */ - if (!key) + if (!ikey) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; @@ -76,10 +73,10 @@ class ModuleMD5 : public Module } else { - ctx->buf[0] = key[0]; - ctx->buf[1] = key[1]; - ctx->buf[2] = key[2]; - ctx->buf[3] = key[3]; + ctx->buf[0] = ikey[0]; + ctx->buf[1] = ikey[1]; + ctx->buf[2] = ikey[2]; + ctx->buf[3] = ikey[3]; } ctx->bytes[0] = 0; @@ -239,20 +236,20 @@ class ModuleMD5 : public Module } - void MyMD5(void *dest, void *orig, int len, unsigned int* key) + void MyMD5(void *dest, void *orig, int len, unsigned int* ikey) { MD5Context context; - MD5Init(&context, key); + MD5Init(&context, ikey); MD5Update(&context, (const unsigned char*)orig, len); MD5Final((unsigned char*)dest, &context); } - void GenHash(const char* src, char* dest, const char* xtab, unsigned int* key) + void GenHash(const char* src, char* dest, const char* xtab, unsigned int* ikey, size_t srclen) { unsigned char bytes[16]; - MyMD5((char*)bytes, (void*)src, strlen(src), key); + MyMD5((char*)bytes, (void*)src, srclen, ikey); for (int i = 0; i < 16; i++) { @@ -270,20 +267,18 @@ class ModuleMD5 : public Module ModuleMD5(InspIRCd* Me) : Module(Me), key(NULL), chars(NULL) { - ServerInstance->PublishInterface("HashRequest", this); + ServerInstance->Modules->PublishInterface("HashRequest", this); + Implementation eventlist[] = { I_OnRequest }; + ServerInstance->Modules->Attach(eventlist, this, 1); } virtual ~ModuleMD5() { - ServerInstance->UnpublishInterface("HashRequest", this); + ServerInstance->Modules->UnpublishInterface("HashRequest", this); } - void Implements(char* List) - { - List[I_OnRequest] = 1; - } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { HashRequest* MD5 = (HashRequest*)request; @@ -298,7 +293,7 @@ class ModuleMD5 : public Module else if (strcmp("SUM", request->GetId()) == 0) { static char data[MAXBUF]; - GenHash((const char*)MD5->GetHashData(), data, chars ? chars : "0123456789abcdef", key); + GenHash(MD5->GetHashData().data(), data, chars ? chars : "0123456789abcdef", key, MD5->GetHashData().length()); return data; } else if (strcmp("NAME", request->GetId()) == 0) @@ -315,7 +310,7 @@ class ModuleMD5 : public Module virtual Version GetVersion() { - return Version(1,1,0,1,VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION); + return Version(1,2,0,1,VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION); } };