1 |
/* |
2 |
* crypto.C: Cryptographic module support. |
3 |
* Rights to this code are documented in doc/pod/license.pod. |
4 |
* |
5 |
* Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 |
*/ |
7 |
|
8 |
static char const rcsid[] = "$Id: crypto.C,v 1.4 2007-08-28 17:08:12 pippijn Exp $"; |
9 |
|
10 |
#include "atheme.h" |
11 |
#include <ermyth/crypto.h> |
12 |
|
13 |
static char saltbuf[BUFSIZE]; |
14 |
bool crypto::handler::loaded = false; |
15 |
|
16 |
/* |
17 |
* crypto::handler::crypt is just like crypt(3) under UNIX |
18 |
* systems. Modules provide this function, otherwise |
19 |
* it returns the string unencrypted. |
20 |
*/ |
21 |
namespace crypto |
22 |
{ |
23 |
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 = crypter->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 |