1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/* Module for encryption using MD5.
*
* (C) 2003-2014 Anope Team
* Contact us at team@anope.org
*
* This program is free but copyrighted software; see the file COPYING for
* details.
*/
#include "module.h"
static int plain_encrypt(const char *src,int len,char *dest,int size);
static int plain_encrypt_check_len(int passlen, int bufsize);
static int plain_decrypt(const char *src, char *dest, int size);
static int plain_check_password(const char *plaintext, const char *password);
int AnopeInit(int argc, char **argv) {
moduleAddAuthor("Anope");
moduleAddVersion(VERSION_STRING);
moduleSetType(ENCRYPTION);
encmodule_encrypt(plain_encrypt);
encmodule_encrypt_check_len(plain_encrypt_check_len);
encmodule_decrypt(plain_decrypt);
encmodule_check_password(plain_check_password);
return MOD_CONT;
}
void AnopeFini(void) {
encmodule_encrypt(NULL);
encmodule_encrypt_check_len(NULL);
encmodule_decrypt(NULL);
encmodule_check_password(NULL);
}
static int plain_encrypt(const char *src,int len,char *dest,int size) {
if(size>=len) {
memset(dest,0,size);
strncpy(dest,src,len);
dest[len] = '\0';
return 0;
}
return -1;
}
static int plain_encrypt_check_len(int passlen, int bufsize) {
if(bufsize>=passlen) {
return 0;
}
return bufsize;
}
static int plain_decrypt(const char *src, char *dest, int size) {
memset(dest,0,size);
strncpy(dest,src,size);
dest[size] = '\0';
return 1;
}
static int plain_check_password(const char *plaintext, const char *password) {
if(strcmp(plaintext,password)==0) {
return 1;
}
return 0;
}
/* EOF */
|