ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/crypto.C
Revision: 1.2
Committed: Sat Jul 21 01:29:10 2007 UTC (16 years, 10 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
- moved to new documentation system
- fixed small build error

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     * 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     */