Anope IRC Services  Version 1.8
encrypt.c
Go to the documentation of this file.
1 /* Include file for high-level encryption routines.
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 
14 #include "services.h"
15 #include "encrypt.h"
16 
18 
19 /******************************************************************************/
20 void encmodule_encrypt(int (*func)
21  (const char *src, int len, char *dest, int size))
22 {
23  encryption.encrypt = func;
24 }
25 
26 void encmodule_encrypt_check_len(int (*func) (int passlen, int bufsize))
27 {
28  encryption.encrypt_check_len = func;
29 }
30 
31 void encmodule_decrypt(int (*func) (const char *src, char *dest, int size))
32 {
33  encryption.decrypt = func;
34 }
35 
36 void encmodule_check_password(int (*func)
37  (const char *plaintext,
38  const char *password))
39 {
40  encryption.check_password = func;
41 }
42 
43 /******************************************************************************/
44 
45 
50 int enc_encrypt(const char *src, int len, char *dest, int size)
51 {
52  if (encryption.encrypt) {
53  return encryption.encrypt(src, len, dest, size);
54  }
55  return -1;
56 }
57 
66 int enc_encrypt_check_len(int passlen, int bufsize)
67 {
68  if (encryption.encrypt_check_len) {
69  return encryption.encrypt_check_len(passlen, bufsize);
70  }
71  return -1;
72 }
73 
80 int enc_decrypt(const char *src, char *dest, int size)
81 {
82  if (encryption.decrypt) {
83  return encryption.decrypt(src, dest, size);
84  }
85  return -1;
86 }
87 
95 int enc_check_password(const char *plaintext, const char *password)
96 {
97  if (encryption.check_password) {
98  return encryption.check_password(plaintext, password);
99  }
100  return -1;
101 }
102 
103 /* EOF */
int(* decrypt)(const char *src, char *dest, int size)
Definition: encrypt.h:17
int(* check_password)(const char *plaintext, const char *password)
Definition: encrypt.h:18
int enc_decrypt(const char *src, char *dest, int size)
Definition: encrypt.c:80
int enc_encrypt(const char *src, int len, char *dest, int size)
Definition: encrypt.c:50
int(* encrypt)(const char *src, int len, char *dest, int size)
Definition: encrypt.h:15
void encmodule_encrypt_check_len(int(*func)(int passlen, int bufsize))
Definition: encrypt.c:26
Encryption encryption
Definition: encrypt.c:17
int enc_encrypt_check_len(int passlen, int bufsize)
Definition: encrypt.c:66
int enc_check_password(const char *plaintext, const char *password)
Definition: encrypt.c:95
void encmodule_check_password(int(*func)(const char *plaintext, const char *password))
Definition: encrypt.c:36
void encmodule_encrypt(int(*func)(const char *src, int len, char *dest, int size))
Definition: encrypt.c:20
void encmodule_decrypt(int(*func)(const char *src, char *dest, int size))
Definition: encrypt.c:31
int(* encrypt_check_len)(int passlen, int bufsize)
Definition: encrypt.h:16