]> git.ipfire.org Git - thirdparty/dhcp.git/blob - common/auth.c
27ac2f92d83d53fd061c7046d30cc6ca8aca40f2
[thirdparty/dhcp.git] / common / auth.c
1 /* auth.c
2
3 Subroutines having to do with authentication. */
4
5 /*
6 * Copyright (c) 1995, 1996, 1997, 1998, 1999
7 * The Internet Software Consortium. All rights reserved.
8 *
9 * Redistribution and use of this source file, source files derived in whole
10 * or in part from this source file, and binary files derived in whole or in
11 * part from this source file, with or without modification, are permitted
12 * provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * This copyright notice must appear directly below any initial commentary
17 * describing the file, and may not be preceded by any other copyright
18 * notice.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. Neither the name of The Internet Software Consortium (hereafter
23 * referred to as "the ISC") nor the names of its contributors may be
24 * used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 * 4. This software is a part of the ISC DHCP Distribution. Redistributions
27 * of this source file or binary files derived from this source file
28 * MUST include all documentation accompanying the ISC release from
29 * which such redistributions are derived of this source file, specifically
30 * the following files (listed relative to the top of the ISC DHCP
31 * distribution directory tree):
32 *
33 * README
34 * common/dhcp-contrib.5
35 * common/dhcp-options.5
36 * server/dhcpd.8
37 * server/dhcpd.conf.5
38 * server/dhcpd.leases.5
39 * client/dhclient.8
40 * client/dhclient.conf.5
41 * client/dhclient-script.8
42 * client/dhclient.leases.5
43 * relay/dhcrelay.8
44 *
45 * Absence of these files from a distribution you receive does not excuse
46 * you from this requirement - if the distribution you receive does not
47 * contain these files, you must get them from the ISC and include them
48 * in any redistribution of this source file or any derivative work based
49 * wholly or in part on this source file. It is permissible in a binary
50 * redistribution derived from this source file to include formatted
51 * versions of the manual pages mentioned above, and also to add to or
52 * correct the manual pages and README file mentioned above so long as the
53 * sections labeled CONTRIBUTIONS in these documents are unchanged except
54 * with respect to formatting, so long as the order in which the
55 * CONTRIBUTIONS section appears in these documents is not changed, and
56 * so long as the dhcp-contrib.5 manual page is unchanged except with
57 * respect to formatting. It is also permissible to redistribute this
58 * source file, source files derived wholly or in part from this source
59 * file, and binaries derived wholly or in part from this source file
60 * accompanied by the aforementioned manual pages translated into another
61 * language. In this case, the CONTRIBUTIONS section and the
62 * dhcp-contrib.5 section may either be left in their original language
63 * or translated into the new language with such care and diligence as
64 * is required to preserve the original meaning.
65 * 5. If, in addition to the documentation mentioned in section 4, this
66 * source file, a source file derived wholly or in part from this source
67 * file, or a binary file derived wholly or in part from this source file
68 * is redistributed with additional printed or electronic documentation,
69 * then that documentation must refer to the dhcp-contrib.5 manual page
70 * in as conspicuous a way as the aforementioned documentation refers to
71 * it, and the dhcp-contrib.5 manual page must be converted into the same
72 * format and be made easily accessible to any recipient of such
73 * redistributions.
74 *
75 * THIS SOFTWARE IS PROVIDED BY THE ISC AND CONTRIBUTORS ``AS IS'' AND ANY
76 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
77 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78 * DISCLAIMED. IN NO EVENT SHALL THE ISC OR CONTRIBUTORS BE LIABLE FOR ANY
79 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
80 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
81 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
82 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
83 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
84 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
85 * SUCH DAMAGE.
86 *
87 * This software has been written for the ISC by Ted Lemon <mellon@isc.org>
88 * in cooperation with Vixie Enterprises and Internet Engines, Inc. To
89 * learn more about the ISC, see ``http://www.vix.com/isc''. Development
90 * of this software is funded through contributions and support contracts.
91 * Please see the dhcp-contrib manual page that accompanies this file for
92 * information on how you can contribute.
93 */
94
95 #ifndef lint
96 static char ocopyright[] =
97 "$Id: auth.c,v 1.1 1999/02/25 23:30:33 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
98 #endif
99
100 #include "dhcpd.h"
101
102 static struct hash_table *auth_key_hash;
103
104 void enter_auth_key (key_id, key)
105 struct data_string *key_id;
106 struct auth_key *key;
107 {
108 if (!auth_key_hash)
109 auth_key_hash = new_hash ();
110 if (!auth_key_hash)
111 log_fatal ("Can't allocate authentication key hash.");
112 add_hash (auth_key_hash, key_id -> data, key_id -> len,
113 (unsigned char *)key);
114 }
115
116 struct auth_key *auth_key_lookup (key_id)
117 struct data_string *key_id;
118 {
119 return (struct auth_key *)hash_lookup (auth_key_hash,
120 key_id -> data, key_id -> len);
121 }
122