ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/crypto.C
Revision: 1.4
Committed: Tue Aug 28 17:08:12 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +40 -44 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * crypto.C: Cryptographic module support.
3 pippijn 1.2 * Rights to this code are documented in doc/pod/license.pod.
4 pippijn 1.1 *
5 pippijn 1.4 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 pippijn 1.1 */
7    
8 pippijn 1.4 static char const rcsid[] = "$Id: crypto.C,v 1.3 2007-07-21 13:23:21 pippijn Exp $";
9 pippijn 1.1
10     #include "atheme.h"
11 pippijn 1.4 #include <ermyth/crypto.h>
12 pippijn 1.1
13     static char saltbuf[BUFSIZE];
14 pippijn 1.4 bool crypto::handler::loaded = false;
15 pippijn 1.1
16     /*
17 pippijn 1.4 * crypto::handler::crypt is just like crypt(3) under UNIX
18 pippijn 1.1 * systems. Modules provide this function, otherwise
19     * it returns the string unencrypted.
20     */
21 pippijn 1.4 namespace crypto
22 pippijn 1.1 {
23 pippijn 1.4 char const *
24     handler::crypt (char const * const str, char const * const salt)
25     {
26     return str;
27     }
28    
29     /*
30     * crypt_verify_password is a frontend to crypt_string().
31     */
32     bool
33     verify_password (char const * const uinput, char const * const pass)
34     {
35     char const * const cstr = crypt (uinput, pass);
36    
37     if (!strcmp (cstr, pass))
38     return true;
39    
40     return false;
41     }
42    
43     char *
44     gen_salt (void)
45     {
46     char *ht = gen_pw (6);
47    
48     strlcpy (saltbuf, "$1$", BUFSIZE);
49     strlcat (saltbuf, ht, BUFSIZE);
50     strlcat (saltbuf, "$", BUFSIZE);
51    
52     sfree (ht);
53    
54     return saltbuf;
55     }
56     } // namespace crypto