ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/crypto.C
Revision: 1.1
Committed: Thu Jul 19 08:24:56 2007 UTC (16 years, 10 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * crypto.C: Cryptographic module support.
3     * Rights to this code are documented in doc/LICENSE.
4     *
5     * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6     */
7    
8     static char const rcsid[] = "$Id";
9    
10     #include "atheme.h"
11    
12     static char saltbuf[BUFSIZE];
13     bool crypto_module_loaded = false;
14    
15     /*
16     * crypt_string is just like crypt(3) under UNIX
17     * systems. Modules provide this function, otherwise
18     * it returns the string unencrypted.
19     */
20     char *(*crypt_string) (char *str, char *salt) = &generic_crypt_string;
21    
22     char *
23     generic_crypt_string (char *str, char *salt)
24     {
25     return str;
26     }
27    
28     /*
29     * crypt_verify_password is a frontend to crypt_string().
30     */
31     bool
32     crypt_verify_password (char *uinput, char *pass)
33     {
34     char *cstr = crypt_string (uinput, pass);
35    
36     if (!strcmp (cstr, pass))
37     return true;
38    
39     return false;
40     }
41    
42     char *
43     gen_salt (void)
44     {
45     char *ht = gen_pw (6);
46    
47     strlcpy (saltbuf, "$1$", BUFSIZE);
48     strlcat (saltbuf, ht, BUFSIZE);
49     strlcat (saltbuf, "$", BUFSIZE);
50    
51     free (ht);
52    
53     return saltbuf;
54     }
55    
56     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
57     * vim:ts=8
58     * vim:sw=8
59     * vim:noexpandtab
60     */