]>
git.saurik.com Git - apple/network_cmds.git/blob - unbound/validator/autotrust.h
2 * validator/autotrust.h - RFC5011 trust anchor management for unbound.
4 * Copyright (c) 2009, NLnet Labs. All rights reserved.
6 * This software is open source.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * Contains autotrust definitions.
42 #ifndef VALIDATOR_AUTOTRUST_H
43 #define VALIDATOR_AUTOTRUST_H
44 #include "util/rbtree.h"
45 #include "util/data/packed_rrset.h"
48 struct ub_packed_rrset_key
;
53 /** Autotrust anchor states */
56 AUTR_STATE_ADDPEND
= 1,
58 AUTR_STATE_MISSING
= 3,
59 AUTR_STATE_REVOKED
= 4,
60 AUTR_STATE_REMOVED
= 5
64 * Autotrust metadata for one trust anchor key.
72 size_t rr_len
, dname_len
;
73 /** last update of key state (new pending count keeps date the same) */
78 uint8_t pending_count
;
79 /** fresh TA was seen */
81 /** revoked TA was seen */
86 * Autotrust metadata for a trust point.
87 * This is part of the struct trust_anchor data.
89 struct autr_point_data
{
90 /** file to store the trust point in. chrootdir already applied. */
92 /** rbtree node for probe sort, key is struct trust_anchor */
98 /** last queried DNSKEY set
99 * Not all failures are captured in this entry.
100 * If the validator did not even start (e.g. timeout or localservfail),
101 * then the last_queried and query_failed values are not updated.
104 /** last successful DNSKEY set */
106 /** next probe time */
107 time_t next_probe_time
;
109 /** when to query if !failed */
110 time_t query_interval
;
111 /** when to retry if failed */
115 * How many times did it fail. diagnostic only (has no effect).
116 * Only updated if there was a dnskey rrset that failed to verify.
118 uint8_t query_failed
;
119 /** true if the trust point has been revoked */
124 * Autotrust global metadata.
126 struct autr_global_data
{
127 /** rbtree of autotrust anchors sorted by next probe time.
128 * When time is equal, sorted by anchor class, name. */
133 * Create new global 5011 data structure.
134 * @return new structure or NULL on malloc failure.
136 struct autr_global_data
* autr_global_create(void);
139 * Delete global 5011 data structure.
140 * @param global: global autotrust state to delete.
142 void autr_global_delete(struct autr_global_data
* global
);
145 * See if autotrust anchors are configured and how many.
146 * @param anchors: the trust anchors structure.
147 * @return number of autotrust trust anchors
149 size_t autr_get_num_anchors(struct val_anchors
* anchors
);
152 * Process probe timer. Add new probes if needed.
153 * @param env: module environment with time, with anchors and with the mesh.
154 * @return time of next probe (in seconds from now).
155 * If 0, then there is no next probe anymore (trust points deleted).
157 time_t autr_probe_timer(struct module_env
* env
);
159 /** probe tree compare function */
160 int probetree_cmp(const void* x
, const void* y
);
163 * Read autotrust file.
164 * @param anchors: the anchors structure.
165 * @param nm: name of the file (copied).
166 * @return false on failure.
168 int autr_read_file(struct val_anchors
* anchors
, const char* nm
);
171 * Write autotrust file.
172 * @param env: environment with scratch space.
173 * @param tp: trust point to write.
175 void autr_write_file(struct module_env
* env
, struct trust_anchor
* tp
);
178 * Delete autr anchor, deletes the autr data but does not do
179 * unlinking from trees, caller does that.
180 * @param tp: trust point to delete.
182 void autr_point_delete(struct trust_anchor
* tp
);
185 * Perform autotrust processing.
186 * @param env: qstate environment with the anchors structure.
187 * @param ve: validator environment for verification of rrsigs.
188 * @param tp: trust anchor to process.
189 * @param dnskey_rrset: DNSKEY rrset probed (can be NULL if bad prime result).
190 * allocated in a region. Has not been validated yet.
191 * @return false if trust anchor was revoked completely.
192 * Otherwise logs errors to log, does not change return value.
193 * On errors, likely the trust point has been unchanged.
195 int autr_process_prime(struct module_env
* env
, struct val_env
* ve
,
196 struct trust_anchor
* tp
, struct ub_packed_rrset_key
* dnskey_rrset
);
199 * Debug printout of rfc5011 tracked anchors
200 * @param anchors: all the anchors.
202 void autr_debug_print(struct val_anchors
* anchors
);
204 /** callback for query answer to 5011 probe */
205 void probe_answer_cb(void* arg
, int rcode
, struct sldns_buffer
* buf
,
206 enum sec_status sec
, char* errinf
);
208 #endif /* VALIDATOR_AUTOTRUST_H */