ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/crypto.C
Revision: 1.6
Committed: Sun Sep 16 18:54:44 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +7 -2 lines
Log Message:
#defines to enum

File Contents

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