ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/crypto.C
Revision: 1.5
Committed: Tue Sep 4 11:13:25 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +2 -2 lines
Log Message:
- fixed bug in crypto
- merged with upstream

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.5 static char const rcsid[] = "$Id: crypto.C,v 1.4 2007-08-28 17:08:12 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 pippijn 1.5 char const * const cstr = crypter->crypt (uinput, pass);
36 pippijn 1.4
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