2 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000-2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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.27.18.10 2007/09/26 04:39:45 each Exp $ */
20 #ifndef DNS_VALIDATOR_H
21 #define DNS_VALIDATOR_H 1
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.
42 *\li The module ensures appropriate synchronization of data structures it
43 * creates and manipulates.
46 *\li No anticipated impact.
52 *\li No anticipated impact.
55 *\li RFCs: 1034, 1035, 2181, 4033, 4034, 4035.
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 */
70 * A dns_validatorevent_t is sent when a 'validation' completes.
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;
85 * Name and type of the response to be validated.
90 * Rdata and RRSIG (if any) for positive responses.
92 dns_rdataset_t * rdataset;
93 dns_rdataset_t * sigrdataset;
95 * The full response. Required for negative responses.
96 * Also required for positive wildcard responses.
98 dns_message_t * message;
100 * Proofs to be cached.
102 dns_name_t * proofs[3];
103 } dns_validatorevent_t;
105 #define DNS_VALIDATOR_NOQNAMEPROOF 0
106 #define DNS_VALIDATOR_NODATAPROOF 1
107 #define DNS_VALIDATOR_NOWILDCARDPROOF 2
110 * A validator object represents a validation in progress.
112 * Clients are strongly discouraged from using this type directly, with
113 * the exception of the 'link' field, which may be used directly for
114 * whatever purpose the client desires.
116 struct dns_validator {
121 /* Locked by lock. */
122 unsigned int options;
123 unsigned int attributes;
124 dns_validatorevent_t * event;
126 dns_validator_t * subvalidator;
127 dns_validator_t * parent;
128 dns_keytable_t * keytable;
129 dns_keynode_t * keynode;
131 dns_rdata_rrsig_t * siginfo;
133 isc_taskaction_t action;
136 dns_rdataset_t * currentset;
137 isc_boolean_t seensig;
138 dns_rdataset_t * keyset;
139 dns_rdataset_t * dsset;
140 dns_rdataset_t * soaset;
141 dns_rdataset_t * nsecset;
142 dns_name_t * soaname;
143 dns_rdataset_t frdataset;
144 dns_rdataset_t fsigrdataset;
145 dns_fixedname_t fname;
146 dns_fixedname_t wild;
147 ISC_LINK(dns_validator_t) link;
149 dns_fixedname_t dlvsep;
150 isc_boolean_t havedlvsep;
151 isc_boolean_t mustbesecure;
152 unsigned int dlvlabels;
157 * dns_validator_create() options.
159 #define DNS_VALIDATOR_DLV 1U
160 #define DNS_VALIDATOR_DEFER 2U
165 dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
166 dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
167 dns_message_t *message, unsigned int options,
168 isc_task_t *task, isc_taskaction_t action, void *arg,
169 dns_validator_t **validatorp);
171 * Start a DNSSEC validation.
173 * This validates a response to the question given by
176 * To validate a positive response, the response data is
177 * given by 'rdataset' and 'sigrdataset'. If 'sigrdataset'
178 * is NULL, the data is presumed insecure and an attempt
179 * is made to prove its insecurity by finding the appropriate
182 * The complete response message may be given in 'message',
183 * to make available any authority section NSECs that may be
184 * needed for validation of a response resulting from a
185 * wildcard expansion (though no such wildcard validation
186 * is implemented yet). If the complete response message
187 * is not available, 'message' is NULL.
189 * To validate a negative response, the complete negative response
190 * message is given in 'message'. The 'rdataset', and
191 * 'sigrdataset' arguments must be NULL, but the 'name' and 'type'
192 * arguments must be provided.
194 * The validation is performed in the context of 'view'.
196 * When the validation finishes, a dns_validatorevent_t with
197 * the given 'action' and 'arg' are sent to 'task'.
198 * Its 'result' field will be ISC_R_SUCCESS iff the
199 * response was successfully proven to be either secure or
200 * part of a known insecure domain.
203 * If DNS_VALIDATOR_DLV is set the caller knows there is not a
204 * trusted key and the validator should immediately attempt to validate
205 * the answer by looking for a appopriate DLV RRset.
209 dns_validator_send(dns_validator_t *validator);
211 * Send a deferred validation request
214 * 'validator' to points to a valid DNSSEC validator.
218 dns_validator_cancel(dns_validator_t *validator);
220 * Cancel a DNSSEC validation in progress.
223 *\li 'validator' points to a valid DNSSEC validator, which
224 * may or may not already have completed.
227 *\li It the validator has not already sent its completion
228 * event, it will send it with result code ISC_R_CANCELED.
232 dns_validator_destroy(dns_validator_t **validatorp);
234 * Destroy a DNSSEC validator.
237 *\li '*validatorp' points to a valid DNSSEC validator.
238 * \li The validator must have completed and sent its completion
242 *\li All resources used by the validator are freed.
247 #endif /* DNS_VALIDATOR_H */