X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_md5.cpp;h=6096f9afa9bd4116f4449f9a0b91633eb3e7601a;hb=f9ef4ebc9dc4fd46cdafcc76df644b4896251dac;hp=d3991083838f9c7a1d5f0ca9d8f375c7f799a7a0;hpb=e4acbc95b8b6cd5b28d38a2242c02e8ff4991e4a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index d39910838..6096f9afa 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -61,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; @@ -73,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; @@ -236,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++) { @@ -278,7 +278,7 @@ class ModuleMD5 : public Module } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { HashRequest* MD5 = (HashRequest*)request; @@ -293,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) @@ -310,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); } };