00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "services.h"
00016 #include "encrypt.h"
00017
00018 Encryption encryption;
00019
00020
00021 void encmodule_encrypt(int (*func)
00022 (const char *src, int len, char *dest, int size))
00023 {
00024 encryption.encrypt = func;
00025 }
00026
00027 void encmodule_encrypt_in_place(int (*func) (char *buf, int size))
00028 {
00029 encryption.encrypt_in_place = func;
00030 }
00031
00032 void encmodule_encrypt_check_len(int (*func) (int passlen, int bufsize))
00033 {
00034 encryption.encrypt_check_len = func;
00035 }
00036
00037 void encmodule_decrypt(int (*func) (const char *src, char *dest, int size))
00038 {
00039 encryption.decrypt = func;
00040 }
00041
00042 void encmodule_check_password(int (*func)
00043 (const char *plaintext,
00044 const char *password))
00045 {
00046 encryption.check_password = func;
00047 }
00048
00049
00050
00051
00056 int enc_encrypt(const char *src, int len, char *dest, int size)
00057 {
00058 if (encryption.encrypt) {
00059 return encryption.encrypt(src, len, dest, size);
00060 }
00061 return -1;
00062 }
00063
00069 int enc_encrypt_in_place(char *buf, int size)
00070 {
00071 if (encryption.encrypt_in_place) {
00072 return encryption.encrypt_in_place(buf, size);
00073 }
00074 return -1;
00075 }
00076
00085 int enc_encrypt_check_len(int passlen, int bufsize)
00086 {
00087 if (encryption.encrypt_check_len) {
00088 return encryption.encrypt_check_len(passlen, bufsize);
00089 }
00090 return -1;
00091 }
00092
00099 int enc_decrypt(const char *src, char *dest, int size)
00100 {
00101 if (encryption.decrypt) {
00102 return encryption.decrypt(src, dest, size);
00103 }
00104 return -1;
00105 }
00106
00114 int enc_check_password(const char *plaintext, const char *password)
00115 {
00116 if (encryption.check_password) {
00117 return encryption.check_password(plaintext, password);
00118 }
00119 return -1;
00120 }
00121
00122