summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/enc_md5.c11
-rw-r--r--src/core/enc_none.c15
-rw-r--r--src/core/enc_old.c13
-rw-r--r--src/core/enc_sha1.c22
-rw-r--r--src/encrypt.c28
5 files changed, 44 insertions, 45 deletions
diff --git a/src/core/enc_md5.c b/src/core/enc_md5.c
index c7c7ccff7..95b7b20c6 100644
--- a/src/core/enc_md5.c
+++ b/src/core/enc_md5.c
@@ -370,7 +370,7 @@ class EMD5 : public Module
}
}
- return EVENT_STOP;
+ return EVENT_ALLOW;
}
@@ -383,8 +383,11 @@ class EMD5 : public Module
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
{
if (bufsize < 16)
+ {
fatal("enc_md5: md5_check_len(): buffer too small (%d)", bufsize);
- return EVENT_STOP;
+ return EVENT_STOP;
+ }
+ return EVENT_ALLOW;
}
@@ -402,9 +405,9 @@ class EMD5 : public Module
return EVENT_STOP;
if (memcmp(buf, password, 16) == 0)
{
- return EVENT_ALLOW;
+ return EVENT_ALLOW;
}
- return EVENT_CONTINUE;
+ return EVENT_STOP;
}
};
diff --git a/src/core/enc_none.c b/src/core/enc_none.c
index 25f2fe216..fc70c68c2 100644
--- a/src/core/enc_none.c
+++ b/src/core/enc_none.c
@@ -32,22 +32,23 @@ class ENone : public Module
memset(dest,0,size);
strncpy(dest,src,len);
dest[len] = '\0';
- return EVENT_STOP;
+ return EVENT_ALLOW;
}
- return EVENT_STOP;
+ return EVENT_STOP;
}
EventReturn OnEncryptInPlace(char *buf, int size)
{
- return EVENT_STOP;
+ return EVENT_ALLOW;
}
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
{
- if(bufsize>=passlen) {
- return EVENT_STOP;
+ if(bufsize>=passlen)
+ {
+ return EVENT_ALLOW;
}
- return EVENT_ALLOW; // return 1
+ return EVENT_STOP;
}
EventReturn OnDecrypt(const char *src, char *dest, int size) {
@@ -62,7 +63,7 @@ class ENone : public Module
{
return EVENT_ALLOW;
}
- return EVENT_CONTINUE;
+ return EVENT_STOP;
}
};
diff --git a/src/core/enc_old.c b/src/core/enc_old.c
index 399caa584..c70ed23b1 100644
--- a/src/core/enc_old.c
+++ b/src/core/enc_old.c
@@ -367,14 +367,14 @@ class EOld : public Module
for (i = 0; i < 32; i += 2)
dest[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]);
- if(debug)
+ if(debug)
{
memset(tmp,0,33);
binary_to_hex((unsigned char *)dest,tmp,16);
alog("enc_old: Converted [%s] to [%s]",src,tmp);
}
- return EVENT_STOP;
+ return EVENT_ALLOW;
}
@@ -387,8 +387,11 @@ class EOld : public Module
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
{
if (bufsize < 16)
+ {
fatal("enc_old: old_check_len(): buffer too small (%d)", bufsize);
- return EVENT_STOP;
+ return EVENT_STOP;
+ }
+ return EVENT_ALLOW;
}
@@ -405,12 +408,12 @@ class EOld : public Module
{
return EVENT_ALLOW;
}
- return EVENT_CONTINUE;
+ return EVENT_STOP;
}
EventReturn OnDecrypt(const char *src, char *dest, int size)
{
- return EVENT_CONTINUE; // 0
+ return EVENT_STOP; // 0
}
};
diff --git a/src/core/enc_sha1.c b/src/core/enc_sha1.c
index 143f14aa0..d67fd630e 100644
--- a/src/core/enc_sha1.c
+++ b/src/core/enc_sha1.c
@@ -204,7 +204,7 @@ class ESHA1 : public Module
unsigned char tmp[41];
if (size < 20)
- return EVENT_ALLOW;
+ return EVENT_STOP;
memset(dest,0,size);
@@ -224,7 +224,7 @@ class ESHA1 : public Module
alog("enc_sha1: hashed password to [%s]",tmp);
}
}
- return EVENT_STOP;
+ return EVENT_ALLOW;
}
@@ -233,11 +233,10 @@ class ESHA1 : public Module
char tmp[41];
memset(tmp,0,41);
- if(OnEncrypt(buf, strlen(buf), tmp, size)==EVENT_STOP)
+ if(OnEncrypt(buf, strlen(buf), tmp, size)==EVENT_ALLOW)
{
memcpy(buf, tmp, size);
- } else {
- return EVENT_STOP;
+ return EVENT_ALLOW;
}
return EVENT_STOP;
}
@@ -246,8 +245,11 @@ class ESHA1 : public Module
EventReturn OnEncryptCheckLen(int passlen, int bufsize)
{
if (bufsize < 20)
+ {
fatal("enc_sha1: sha1_check_len(): buffer too small (%d)", bufsize);
- return EVENT_STOP;
+ return EVENT_STOP;
+ }
+ return EVENT_ALLOW;
}
@@ -260,13 +262,13 @@ class ESHA1 : public Module
EventReturn OnCheckPassword(const char *plaintext, const char *password)
{
char buf[BUFSIZE];
- if (OnEncrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) == EVENT_ALLOW)
- return EVENT_STOP;
- if (memcmp(buf, password, 20) == 0)
+ if (OnEncrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) == EVENT_STOP)
+ return EVENT_STOP;
+ if (memcmp(buf, password, 20) == 0)
{
return EVENT_ALLOW;
}
- return EVENT_CONTINUE;
+ return EVENT_STOP;
}
};
diff --git a/src/encrypt.c b/src/encrypt.c
index 071aa2d8b..4b5db587e 100644
--- a/src/encrypt.c
+++ b/src/encrypt.c
@@ -26,10 +26,8 @@ int enc_encrypt(const char *src, int len, char *dest, int size)
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, len, dest, size));
if (MOD_RESULT == EVENT_ALLOW)
- return 1;
- if (MOD_RESULT == EVENT_STOP)
- return -1;
- return 0;
+ return 0;
+ return -1;
}
/**
@@ -42,10 +40,8 @@ int enc_encrypt_in_place(char *buf, int size)
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnEncryptInPlace, OnEncryptInPlace(buf, size));
if (MOD_RESULT == EVENT_ALLOW)
- return 1;
- if (MOD_RESULT == EVENT_STOP)
- return -1;
- return 0;
+ return 0;
+ return -1;
}
@@ -62,15 +58,13 @@ int enc_encrypt_check_len(int passlen, int bufsize)
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnEncryptCheckLen, OnEncryptCheckLen(passlen, bufsize));
if (MOD_RESULT == EVENT_ALLOW)
- return 1;
- if (MOD_RESULT == EVENT_STOP)
- return -1;
- return 0;
+ return 0;
+ return -1;
}
/**
* Decrypt encrypted string `src' into buffer `dest' of length `len'.
- * Returns 1 (not 0) on success, 0 if the encryption algorithm does not
+ * Returns 1 (not 0) on success, -1 if the encryption algorithm does not
* allow decryption, and -1 if another failure occurred (e.g. destination
* buffer too small).
**/
@@ -80,9 +74,7 @@ int enc_decrypt(const char *src, char *dest, int size)
FOREACH_RESULT(I_OnDecrypt, OnDecrypt(src, dest, size));
if (MOD_RESULT == EVENT_ALLOW)
return 1;
- if (MOD_RESULT == EVENT_STOP)
- return -1;
- return 0;
+ return -1;
}
/**
@@ -90,7 +82,7 @@ int enc_decrypt(const char *src, char *dest, int size)
* `password'. Return value is:
* 1 if the password matches
* 0 if the password does not match
- * -1 if an error occurred while checking
+ * 0 if an error occurred while checking
**/
int enc_check_password(const char *plaintext, const char *password)
{
@@ -98,8 +90,6 @@ int enc_check_password(const char *plaintext, const char *password)
FOREACH_RESULT(I_OnCheckPassword, OnCheckPassword(plaintext, password));
if (MOD_RESULT == EVENT_ALLOW)
return 1;
- if (MOD_RESULT == EVENT_STOP)
- return -1;
return 0;
}