Merge from vendor branch BIND:
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / keytable.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: keytable.h,v 1.10.206.1 2004/03/06 08:13:56 marka Exp $ */
19
20 #ifndef DNS_KEYTABLE_H
21 #define DNS_KEYTABLE_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*
28  * Key Tables
29  *
30  * The keytable module provides services for storing and retrieving DNSSEC
31  * trusted keys, as well as the ability to find the deepest matching key
32  * for a given domain name.
33  *
34  * MP:
35  *      The module ensures appropriate synchronization of data structures it
36  *      creates and manipulates.
37  *
38  * Resources:
39  *      <TBS>
40  *
41  * Security:
42  *      No anticipated impact.
43  */
44
45 #include <isc/lang.h>
46
47 #include <dns/types.h>
48
49 #include <dst/dst.h>
50
51 ISC_LANG_BEGINDECLS
52
53 isc_result_t
54 dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep);
55 /*
56  * Create a keytable.
57  *
58  * Requires:
59  *
60  *      'mctx' is a valid memory context.
61  *
62  *      keytablep != NULL && *keytablep == NULL
63  *
64  * Ensures:
65  *
66  *      On success, *keytablep is a valid, empty key table.
67  *
68  * Returns:
69  *
70  *      ISC_R_SUCCESS
71  *
72  *      Any other result indicates failure.
73  */
74
75
76 void
77 dns_keytable_attach(dns_keytable_t *source, dns_keytable_t **targetp);
78 /*
79  * Attach *targetp to source.
80  *
81  * Requires:
82  *
83  *      'source' is a valid keytable.
84  *
85  *      'targetp' points to a NULL dns_keytable_t *.
86  *
87  * Ensures:
88  *
89  *      *targetp is attached to source.
90  */
91
92 void
93 dns_keytable_detach(dns_keytable_t **keytablep);
94 /*
95  * Detach *keytablep from its keytable.
96  *
97  * Requires:
98  *
99  *      'keytablep' points to a valid keytable.
100  *
101  * Ensures:
102  *
103  *      *keytablep is NULL.
104  *
105  *      If '*keytablep' is the last reference to the keytable,
106  *
107  *              All resources used by the keytable will be freed
108  */
109
110 isc_result_t
111 dns_keytable_add(dns_keytable_t *keytable, dst_key_t **keyp);
112 /*
113  * Add '*keyp' to 'keytable'.
114  *
115  * Notes:
116  *
117  *      Ownership of *keyp is transferred to the keytable.
118  *
119  * Requires:
120  *
121  *      keyp != NULL && *keyp is a valid dst_key_t *.
122  *
123  * Ensures:
124  *
125  *      On success, *keyp == NULL
126  *
127  * Returns:
128  *
129  *      ISC_R_SUCCESS
130  *
131  *      Any other result indicates failure.
132  */
133
134 isc_result_t
135 dns_keytable_findkeynode(dns_keytable_t *keytable, dns_name_t *name,
136                          dns_secalg_t algorithm, dns_keytag_t tag,
137                          dns_keynode_t **keynodep);
138 /*
139  * Search for a key named 'name', matching 'algorithm' and 'tag' in
140  * 'keytable'.
141  *
142  * Requires:
143  *
144  *      'keytable' is a valid keytable.
145  *
146  *      'name' is a valid absolute name.
147  *
148  *      keynodep != NULL && *keynodep == NULL
149  *
150  * Returns:
151  *
152  *      ISC_R_SUCCESS
153  *      ISC_R_NOTFOUND
154  *
155  *      Any other result indicates an error.
156  */
157
158 isc_result_t
159 dns_keytable_findnextkeynode(dns_keytable_t *keytable, dns_keynode_t *keynode,
160                                              dns_keynode_t **nextnodep);
161 /*
162  * Search for the next key with the same properties as 'keynode' in
163  * 'keytable'.
164  *
165  * Requires:
166  *
167  *      'keytable' is a valid keytable.
168  *
169  *      'keynode' is a valid keynode.
170  *
171  *      nextnodep != NULL && *nextnodep == NULL
172  *
173  * Returns:
174  *
175  *      ISC_R_SUCCESS
176  *      ISC_R_NOTFOUND
177  *
178  *      Any other result indicates an error.
179  */
180
181 isc_result_t
182 dns_keytable_finddeepestmatch(dns_keytable_t *keytable, dns_name_t *name,
183                               dns_name_t *foundname);
184 /*
185  * Search for the deepest match of 'name' in 'keytable'.
186  *
187  * Requires:
188  *
189  *      'keytable' is a valid keytable.
190  *
191  *      'name' is a valid absolute name.
192  *
193  *      'foundname' is a name with a dedicated buffer.
194  *
195  * Returns:
196  *
197  *      ISC_R_SUCCESS
198  *      ISC_R_NOTFOUND
199  *
200  *      Any other result indicates an error.
201  */
202
203 void
204 dns_keytable_detachkeynode(dns_keytable_t *keytable,
205                            dns_keynode_t **keynodep);
206 /*
207  * Give back a keynode found via dns_keytable_findkeynode().
208  *
209  * Requires:
210  *
211  *      'keytable' is a valid keytable.
212  *
213  *      *keynodep is a valid keynode returned by a call to
214  *      dns_keytable_findkeynode().
215  *
216  * Ensures:
217  *
218  *      *keynodep == NULL
219  */
220
221 isc_result_t
222 dns_keytable_issecuredomain(dns_keytable_t *keytable, dns_name_t *name,
223                             isc_boolean_t *wantdnssecp);
224 /*
225  * Is 'name' at or beneath a trusted key?
226  *
227  * Requires:
228  *
229  *      'keytable' is a valid keytable.
230  *
231  *      'name' is a valid absolute name.
232  *
233  *      '*wantsdnssecp' is a valid isc_boolean_t.
234  *
235  * Ensures:
236  *
237  *      On success, *wantsdnssecp will be ISC_TRUE if and only if 'name'
238  *      is at or beneath a trusted key.
239  *
240  * Returns:
241  *
242  *      ISC_R_SUCCESS
243  *
244  *      Any other result is an error.
245  */
246
247 dst_key_t *
248 dns_keynode_key(dns_keynode_t *keynode);
249 /*
250  * Get the DST key associated with keynode.
251  */
252
253 ISC_LANG_ENDDECLS
254
255 #endif /* DNS_KEYTABLE_H */