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