Merge from vendor branch WPA_SUPPLICANT:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / validator.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: validator.h,v 1.18.2.1 2004/03/09 06:11:24 marka Exp $ */
19
20 #ifndef DNS_VALIDATOR_H
21 #define DNS_VALIDATOR_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*
28  * DNS Validator
29  *
30  * XXX <TBS> XXX
31  *
32  * MP:
33  *      The module ensures appropriate synchronization of data structures it
34  *      creates and manipulates.
35  *
36  * Reliability:
37  *      No anticipated impact.
38  *
39  * Resources:
40  *      <TBS>
41  *
42  * Security:
43  *      No anticipated impact.
44  *
45  * Standards:
46  *      RFCs:   1034, 1035, 2181, 2535, <TBS>
47  *      Drafts: <TBS>
48  */
49
50 #include <isc/lang.h>
51 #include <isc/event.h>
52 #include <isc/mutex.h>
53
54 #include <dns/types.h>
55 #include <dns/rdataset.h>
56 #include <dns/rdatastruct.h> /* for dns_rdata_sig_t */
57
58 #include <dst/dst.h>
59
60 /*
61  * A dns_validatorevent_t is sent when a 'validation' completes.
62  *
63  * 'name', 'rdataset', 'sigrdataset', and 'message' are the values that were
64  * supplied when dns_validator_create() was called.  They are returned to the
65  * caller so that they may be freed.
66  */
67 typedef struct dns_validatorevent {
68         ISC_EVENT_COMMON(struct dns_validatorevent);
69         dns_validator_t *               validator;
70         isc_result_t                    result;
71         dns_name_t *                    name;
72         dns_rdatatype_t                 type;
73         dns_rdataset_t *                rdataset;
74         dns_rdataset_t *                sigrdataset;
75         dns_message_t *                 message;
76 } dns_validatorevent_t;
77
78
79 /*
80  * A validator object represents a validation in procgress.
81  *
82  * Clients are strongly discouraged from using this type directly, with
83  * the exception of the 'link' field, which may be used directly for
84  * whatever purpose the client desires.
85  */
86 struct dns_validator {
87         /* Unlocked. */
88         unsigned int                    magic;
89         isc_mutex_t                     lock;
90         dns_view_t *                    view;
91         /* Locked by lock. */
92         unsigned int                    options;
93         unsigned int                    attributes;
94         dns_validatorevent_t *          event;
95         dns_fetch_t *                   fetch;
96         dns_validator_t *               keyvalidator;
97         dns_validator_t *               authvalidator;
98         dns_keytable_t *                keytable;
99         dns_keynode_t *                 keynode;
100         dst_key_t *                     key;
101         dns_rdata_sig_t *               siginfo;
102         isc_task_t *                    task;
103         isc_taskaction_t                action;
104         void *                          arg;
105         unsigned int                    labels;
106         dns_rdataset_t *                currentset;
107         isc_boolean_t                   seensig;
108         dns_rdataset_t *                keyset;
109         dns_rdataset_t                  frdataset;
110         dns_rdataset_t                  fsigrdataset;
111         ISC_LINK(dns_validator_t)       link;
112 };
113
114 ISC_LANG_BEGINDECLS
115
116 isc_result_t
117 dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
118                      dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
119                      dns_message_t *message, unsigned int options,
120                      isc_task_t *task, isc_taskaction_t action, void *arg,
121                      dns_validator_t **validatorp);
122 /*
123  * Start a DNSSEC validation.
124  *
125  * This validates a response to the question given by
126  * 'name' and 'type'.
127  *
128  * To validate a positive response, the response data is
129  * given by 'rdataset' and 'sigrdataset'.  If 'sigrdataset'
130  * is NULL, the data is presumed insecure and an attempt
131  * is made to prove its insecurity by finding the appropriate
132  * null key.
133  *
134  * The complete response message may be given in 'message',
135  * to make available any authority section NXTs that may be
136  * needed for validation of a response resulting from a
137  * wildcard expansion (though no such wildcard validation
138  * is implemented yet).  If the complete response message
139  * is not available, 'message' is NULL.
140  *
141  * To validate a negative response, the complete negative response
142  * message is given in 'message'.  The 'rdataset', and
143  * 'sigrdataset' arguments must be NULL, but the 'name' and 'type'
144  * arguments must be provided.
145  *
146  * The validation is performed in the context of 'view'.
147  * 'options' must be zero.
148  *
149  * When the validation finishes, a dns_validatorevent_t with
150  * the given 'action' and 'arg' are sent to 'task'.
151  * Its 'result' field will be ISC_R_SUCCESS iff the
152  * response was successfully proven to be either secure or
153  * part of a known insecure domain.
154  */
155
156 void
157 dns_validator_cancel(dns_validator_t *validator);
158 /*
159  * Cancel a DNSSEC validation in progress.
160  *
161  * Requires:
162  *      'validator' points to a valid DNSSEC validator, which
163  *      may or may not already have completed.
164  *
165  * Ensures:
166  *      It the validator has not already sent its completion
167  *      event, it will send it with result code ISC_R_CANCELED.
168  */
169
170 void
171 dns_validator_destroy(dns_validator_t **validatorp);
172 /*
173  * Destroy a DNSSEC validator.
174  *
175  * Requires:
176  *      '*validatorp' points to a valid DNSSEC validator.
177  *      The validator must have completed and sent its completion
178  *      event.
179  *
180  * Ensures:
181  *      All resources used by the validator are freed.
182  */
183
184 ISC_LANG_ENDDECLS
185
186 #endif /* DNS_VALIDATOR_H */