]> jfr.im git - irc/quakenet/snircd.git/blob - include/ircd_crypt.h
forward port of asuka-check.patch to .12
[irc/quakenet/snircd.git] / include / ircd_crypt.h
1 /*
2 * IRC - Internet Relay Chat, include/ircd_crypt.h
3 * Copyright (C) 2002 hikari
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 1, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /** @file
20 * @brief Core password encryption and hashing APIs.
21 * @version $Id: ircd_crypt.h,v 1.3 2004/11/07 21:04:58 entrope Exp $
22 */
23 #ifndef INCLUDED_ircd_crypt_h
24 #define INCLUDED_ircd_crypt_h
25
26 /* forward planning for modularisation */
27 struct crypt_mech_s {
28 char* mechname; /* name of the mechanism */
29 char* shortname; /* short name of the module */
30 char* description; /* description of the mechanism */
31
32 const char* (*crypt_function)(const char *, const char *);
33 /* pointer to the crypt function */
34
35 char* crypt_token; /* what identifies a password string
36 as belonging to this mechanism */
37
38 int crypt_token_size; /* how long is the token */
39 };
40
41 typedef struct crypt_mech_s crypt_mech_t;
42
43 struct crypt_mechs_s;
44 typedef struct crypt_mechs_s crypt_mechs_t;
45
46 struct crypt_mechs_s {
47 crypt_mech_t* mech;
48 crypt_mechs_t* next;
49 crypt_mechs_t* prev;
50 };
51
52 /* access macros */
53 #define MechName(x) x->mechname
54 #define ShortName(x) x->shortname
55 #define Description(x) x->description
56 #define CryptFunc(x) x->crypt_function
57 #define CryptTok(x) x->crypt_token
58 #define CryptTokSize(x) x->crypt_token_size
59
60 /* exported functions */
61 extern void ircd_crypt_init(void);
62 extern char* ircd_crypt(const char* key, const char* salt);
63 extern int ircd_crypt_register_mech(crypt_mech_t* mechanism);
64 extern int ircd_crypt_unregister_mech(crypt_mech_t* mechanism);
65
66 /* exported variables */
67 extern crypt_mechs_t* crypt_mechs_root;
68
69 #endif /* INCLUDED_ircd_crypt_h */
70