fixed ssl.c bug when ssl backend returns IO_BLOCKED but IO engine doesn't get informe...
[ircu2.10.12-pk.git] / ircd / ircd_crypt_plain.c
1 /*
2  * IRC - Internet Relay Chat, ircd/ircd_crypt_plain.c
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  */
20 /**
21  * @file
22  * @brief Routines for PLAIN passwords.
23  * @version $Id: ircd_crypt_plain.c 1271 2004-12-11 05:14:07Z klmitch $
24  * 
25  * PLAIN text encryption.  Oxymoron and a half that.
26  */
27 #include "config.h"
28 #include "ircd_crypt.h"
29 #include "ircd_crypt_plain.h"
30 #include "ircd_log.h"
31 #include "s_debug.h"
32 #include "ircd_alloc.h"
33
34 /* #include <assert.h> -- Now using assert in ircd_log.h */
35 #include <unistd.h>
36
37 /** Just sends back the supplied password.
38  * @param key The password
39  * @param salt The salt
40  * @return The password
41  * 
42  * Yes I know it's an oxymoron, but still, it's handy for testing.
43  * 
44  * What you need more help with seeing what this does?
45  * 
46  */
47 const char* ircd_crypt_plain(const char* key, const char* salt)
48 {
49   assert(NULL != salt);
50   assert(NULL != key);
51
52  Debug((DEBUG_DEBUG, "ircd_crypt_plain: key is %s", key));
53  Debug((DEBUG_DEBUG, "ircd_crypt_plain: salt is %s", salt));
54
55   /* yes, that's it.  we just send key back out again, 
56      pointless I know */
57   return key;
58 }
59
60 /** register ourself with the list of crypt mechanisms 
61  * Registers the PLAIN mechanism in the list of available crypt mechanisms.  
62  * When we're modular this will be the entry function for the module.
63  * 
64  * -- hikari */
65 void ircd_register_crypt_plain(void)
66 {
67 crypt_mech_t* crypt_mech;
68
69  if ((crypt_mech = (crypt_mech_t*)MyMalloc(sizeof(crypt_mech_t))) == NULL)
70  {
71   Debug((DEBUG_MALLOC, "Could not allocate space for crypt_plain"));
72   return;
73  }
74
75  crypt_mech->mechname = "plain";
76  crypt_mech->shortname = "crypt_plain";
77  crypt_mech->description = "Plain text \"crypt\" mechanism.";
78  crypt_mech->crypt_function = &ircd_crypt_plain;
79  crypt_mech->crypt_token = "$PLAIN$";
80  crypt_mech->crypt_token_size = 7;
81
82  ircd_crypt_register_mech(crypt_mech);
83  
84 return;
85 }