Author: Isomer <isomer@undernet.org>
[ircu2.10.12-pk.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  * $Id$
20  */
21 #ifndef INCLUDED_ircd_crypt_h
22 #define INCLUDED_ircd_crypt_h
23
24 /* forward planning for modularisation */
25 struct crypt_mech_s {
26  char* mechname;     /* name of the mechanism */
27  char* shortname;    /* short name of the module */
28  char* description;  /* description of the mechanism */
29
30  const char* (*crypt_function)(const char *, const char *); 
31                      /* pointer to the crypt function */
32
33  char* crypt_token;  /* what identifies a password string 
34                         as belonging to this mechanism */
35
36  int crypt_token_size; /* how long is the token */
37 };
38
39 typedef struct crypt_mech_s crypt_mech_t;
40
41 struct crypt_mechs_s;
42 typedef struct crypt_mechs_s crypt_mechs_t;
43
44 struct crypt_mechs_s {
45  crypt_mech_t* mech;
46  crypt_mechs_t* next;
47  crypt_mechs_t* prev;
48 };
49
50 /* access macros */
51 #define MechName(x) x->mechname
52 #define ShortName(x) x->shortname
53 #define Description(x) x->description
54 #define CryptFunc(x) x->crypt_function
55 #define CryptTok(x) x->crypt_token
56 #define CryptTokSize(x) x->crypt_token_size
57
58 /* exported functions */
59 extern void ircd_crypt_init(void);
60 extern const char* ircd_crypt(const char* key, const char* salt);
61 extern int ircd_crypt_register_mech(crypt_mech_t* mechanism);
62 extern int ircd_crypt_unregister_mech(crypt_mech_t* mechanism);
63
64 /* exported variables */
65 extern crypt_mechs_t* crypt_mechs_root;
66
67 #endif /* INCLUDED_ircd_crypt_h */
68