Import bind-9.3.4
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / validator.h
bloba0d6acb68c0d98af29ec9a2595bb2c02450c101a
1 /*
2 * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000-2003 Internet Software Consortium.
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.
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.
18 /* $Id: validator.h,v 1.18.12.11.6.1 2007/01/11 04:51:39 marka Exp $ */
20 #ifndef DNS_VALIDATOR_H
21 #define DNS_VALIDATOR_H 1
23 /*****
24 ***** Module Info
25 *****/
27 /*! \file
29 * \brief
30 * DNS Validator
31 * This is the BIND 9 validator, the module responsible for validating the
32 * rdatasets and negative responses (messages). It makes use of zones in
33 * the view and may fetch RRset to complete trust chains. It implements
34 * DNSSEC as specified in RFC 4033, 4034 and 4035.
36 * It can also optionally implement ISC's DNSSEC look-aside validation.
38 * Correct operation is critical to preventing spoofed answers from secure
39 * zones being accepted.
41 * MP:
42 *\li The module ensures appropriate synchronization of data structures it
43 * creates and manipulates.
45 * Reliability:
46 *\li No anticipated impact.
48 * Resources:
49 *\li TBS
51 * Security:
52 *\li No anticipated impact.
54 * Standards:
55 *\li RFCs: 1034, 1035, 2181, 4033, 4034, 4035.
58 #include <isc/lang.h>
59 #include <isc/event.h>
60 #include <isc/mutex.h>
62 #include <dns/fixedname.h>
63 #include <dns/types.h>
64 #include <dns/rdataset.h>
65 #include <dns/rdatastruct.h> /* for dns_rdata_rrsig_t */
67 #include <dst/dst.h>
69 /*%
70 * A dns_validatorevent_t is sent when a 'validation' completes.
71 * \brief
72 * 'name', 'rdataset', 'sigrdataset', and 'message' are the values that were
73 * supplied when dns_validator_create() was called. They are returned to the
74 * caller so that they may be freed.
76 * If the RESULT is ISC_R_SUCCESS and the answer is secure then
77 * proofs[] will contain the the names of the NSEC records that hold the
78 * various proofs. Note the same name may appear multiple times.
80 typedef struct dns_validatorevent {
81 ISC_EVENT_COMMON(struct dns_validatorevent);
82 dns_validator_t * validator;
83 isc_result_t result;
84 dns_name_t * name;
85 dns_rdatatype_t type;
86 dns_rdataset_t * rdataset;
87 dns_rdataset_t * sigrdataset;
88 dns_message_t * message;
89 dns_name_t * proofs[3];
90 } dns_validatorevent_t;
92 #define DNS_VALIDATOR_NOQNAMEPROOF 0
93 #define DNS_VALIDATOR_NODATAPROOF 1
94 #define DNS_VALIDATOR_NOWILDCARDPROOF 2
96 /*%
97 * A validator object represents a validation in progress.
98 * \brief
99 * Clients are strongly discouraged from using this type directly, with
100 * the exception of the 'link' field, which may be used directly for
101 * whatever purpose the client desires.
103 struct dns_validator {
104 /* Unlocked. */
105 unsigned int magic;
106 isc_mutex_t lock;
107 dns_view_t * view;
108 /* Locked by lock. */
109 unsigned int options;
110 unsigned int attributes;
111 dns_validatorevent_t * event;
112 dns_fetch_t * fetch;
113 dns_validator_t * subvalidator;
114 dns_validator_t * parent;
115 dns_keytable_t * keytable;
116 dns_keynode_t * keynode;
117 dst_key_t * key;
118 dns_rdata_rrsig_t * siginfo;
119 isc_task_t * task;
120 isc_taskaction_t action;
121 void * arg;
122 unsigned int labels;
123 dns_rdataset_t * currentset;
124 isc_boolean_t seensig;
125 dns_rdataset_t * keyset;
126 dns_rdataset_t * dsset;
127 dns_rdataset_t * soaset;
128 dns_rdataset_t * nsecset;
129 dns_name_t * soaname;
130 dns_rdataset_t frdataset;
131 dns_rdataset_t fsigrdataset;
132 dns_fixedname_t fname;
133 dns_fixedname_t wild;
134 ISC_LINK(dns_validator_t) link;
135 dns_rdataset_t dlv;
136 dns_fixedname_t dlvsep;
137 isc_boolean_t havedlvsep;
138 isc_boolean_t mustbesecure;
139 unsigned int dlvlabels;
140 unsigned int depth;
144 * dns_validator_create() options.
146 #define DNS_VALIDATOR_DLV 1U
147 #define DNS_VALIDATOR_DEFER 2U
149 ISC_LANG_BEGINDECLS
151 isc_result_t
152 dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
153 dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
154 dns_message_t *message, unsigned int options,
155 isc_task_t *task, isc_taskaction_t action, void *arg,
156 dns_validator_t **validatorp);
157 /*%<
158 * Start a DNSSEC validation.
160 * This validates a response to the question given by
161 * 'name' and 'type'.
163 * To validate a positive response, the response data is
164 * given by 'rdataset' and 'sigrdataset'. If 'sigrdataset'
165 * is NULL, the data is presumed insecure and an attempt
166 * is made to prove its insecurity by finding the appropriate
167 * null key.
169 * The complete response message may be given in 'message',
170 * to make available any authority section NSECs that may be
171 * needed for validation of a response resulting from a
172 * wildcard expansion (though no such wildcard validation
173 * is implemented yet). If the complete response message
174 * is not available, 'message' is NULL.
176 * To validate a negative response, the complete negative response
177 * message is given in 'message'. The 'rdataset', and
178 * 'sigrdataset' arguments must be NULL, but the 'name' and 'type'
179 * arguments must be provided.
181 * The validation is performed in the context of 'view'.
183 * When the validation finishes, a dns_validatorevent_t with
184 * the given 'action' and 'arg' are sent to 'task'.
185 * Its 'result' field will be ISC_R_SUCCESS iff the
186 * response was successfully proven to be either secure or
187 * part of a known insecure domain.
189 * options:
190 * If DNS_VALIDATOR_DLV is set the caller knows there is not a
191 * trusted key and the validator should immediately attempt to validate
192 * the answer by looking for a appopriate DLV RRset.
195 void
196 dns_validator_send(dns_validator_t *validator);
197 /*%<
198 * Send a deferred validation request
200 * Requires:
201 * 'validator' to points to a valid DNSSEC validator.
204 void
205 dns_validator_cancel(dns_validator_t *validator);
206 /*%<
207 * Cancel a DNSSEC validation in progress.
209 * Requires:
210 *\li 'validator' points to a valid DNSSEC validator, which
211 * may or may not already have completed.
213 * Ensures:
214 *\li It the validator has not already sent its completion
215 * event, it will send it with result code ISC_R_CANCELED.
218 void
219 dns_validator_destroy(dns_validator_t **validatorp);
220 /*%<
221 * Destroy a DNSSEC validator.
223 * Requires:
224 *\li '*validatorp' points to a valid DNSSEC validator.
225 * \li The validator must have completed and sent its completion
226 * event.
228 * Ensures:
229 *\li All resources used by the validator are freed.
232 ISC_LANG_ENDDECLS
234 #endif /* DNS_VALIDATOR_H */