From 9a0b1efc24e84c7cf17a0e87c98fd1e22fe1c356 Mon Sep 17 00:00:00 2001 From: DukePyrolator Date: Mon, 2 Nov 2009 05:22:35 +0000 Subject: added a way to load multiple encryption modules at the same and to switch between encryption methods git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2602 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/enc_md5.c | 11 +++++++++-- src/core/enc_none.c | 12 ++++++++++-- src/core/enc_old.c | 11 +++++++++-- src/core/enc_sha1.c | 11 +++++++++-- 4 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/enc_md5.c b/src/core/enc_md5.c index 00d9a40ae..103f4bbe7 100644 --- a/src/core/enc_md5.c +++ b/src/core/enc_md5.c @@ -397,7 +397,7 @@ class EMD5 : public Module } - EventReturn OnCheckPassword(const char *plaintext, const char *password) + EventReturn OnCheckPassword(const char *plaintext, char *password) { char buf[BUFSIZE]; @@ -405,9 +405,16 @@ class EMD5 : public Module return EVENT_STOP; if (memcmp(buf, password, 16) == 0) { + /* if we are NOT the first module in the list, + * we want to re-encrypt the pass with the new encryption + */ + if (stricmp(EncModuleList[0], this->name.c_str())) + { + enc_encrypt(plaintext, strlen(password), password, PASSMAX -1 ); + } return EVENT_ALLOW; } - return EVENT_STOP; + return EVENT_CONTINUE; } }; diff --git a/src/core/enc_none.c b/src/core/enc_none.c index 91784bca4..99b3e17a4 100644 --- a/src/core/enc_none.c +++ b/src/core/enc_none.c @@ -56,12 +56,20 @@ class ENone : public Module return EVENT_ALLOW; } - EventReturn OnCheckPassword(const char *plaintext, const char *password) { + EventReturn OnCheckPassword(const char *plaintext, char *password) + { if(strcmp(plaintext,password)==0) { + /* if we are NOT the first module in the list, + * we want to re-encrypt the pass with the new encryption + */ + if (stricmp(EncModuleList[0], this->name.c_str())) + { + enc_encrypt(plaintext, strlen(password), password, PASSMAX -1 ); + } return EVENT_ALLOW; } - return EVENT_STOP; + return EVENT_CONTINUE; } }; diff --git a/src/core/enc_old.c b/src/core/enc_old.c index 3da4e5155..c3db6c4b3 100644 --- a/src/core/enc_old.c +++ b/src/core/enc_old.c @@ -398,7 +398,7 @@ class EOld : public Module /* Compare a plaintext string against an encrypted password. Return 1 if * they match, 0 if not, and -1 if something went wrong. */ - EventReturn OnCheckPassword(const char *plaintext, const char *password) + EventReturn OnCheckPassword(const char *plaintext, char *password) { char buf[BUFSIZE]; @@ -406,9 +406,16 @@ class EOld : public Module return EVENT_STOP; if (memcmp(buf, password, 16) == 0) { + /* when we are NOT the first module in the list, + * we want to re-encrypt the pass with the new encryption + */ + if (stricmp(EncModuleList[0], this->name.c_str())) + { + enc_encrypt(plaintext, strlen(password), password, PASSMAX -1 ); + } return EVENT_ALLOW; } - return EVENT_STOP; + return EVENT_CONTINUE; } EventReturn OnDecrypt(const char *src, char *dest, int size) diff --git a/src/core/enc_sha1.c b/src/core/enc_sha1.c index 398b052fb..9c86875fe 100644 --- a/src/core/enc_sha1.c +++ b/src/core/enc_sha1.c @@ -259,16 +259,23 @@ class ESHA1 : public Module } - EventReturn OnCheckPassword(const char *plaintext, const char *password) + EventReturn OnCheckPassword(const char *plaintext, char *password) { char buf[BUFSIZE]; if (OnEncrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) == EVENT_STOP) return EVENT_STOP; if (memcmp(buf, password, 20) == 0) { + /* when we are NOT the first module in the list, + * we want to re-encrypt the pass with the new encryption + */ + if (stricmp(EncModuleList[0], this->name.c_str())) + { + enc_encrypt(plaintext, strlen(password), password, PASSMAX -1 ); + } return EVENT_ALLOW; } - return EVENT_STOP; + return EVENT_CONTINUE; } }; -- cgit