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