]> CyberLeo.Net >> Repos - FreeBSD/releng/8.0.git/blob - contrib/bind9/lib/dns/include/dns/nsec3.h
Adjust to reflect 8.0-RELEASE.
[FreeBSD/releng/8.0.git] / contrib / bind9 / lib / dns / include / dns / nsec3.h
1 /*
2  * Copyright (C) 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14  * PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 /* $Id: nsec3.h,v 1.5.48.2 2009/01/18 23:47:41 tbox Exp $ */
18
19 #ifndef DNS_NSEC3_H
20 #define DNS_NSEC3_H 1
21
22 #include <isc/lang.h>
23 #include <isc/iterated_hash.h>
24
25 #include <dns/db.h>
26 #include <dns/diff.h>
27 #include <dns/name.h>
28 #include <dns/rdatastruct.h>
29 #include <dns/types.h>
30
31 /*
32  * hash = 1, flags =1, iterations = 2, salt length = 1, salt = 255 (max)
33  * hash length = 1, hash = 255 (max), bitmap = 8192 + 512 (max)
34  */
35 #define DNS_NSEC3_BUFFERSIZE (6 + 255 + 255 + 8192 + 512)
36 /*
37  * hash = 1, flags = 1, iterations = 2, salt length = 1, salt = 255 (max)
38  */
39 #define DNS_NSEC3PARAM_BUFFERSIZE (5 + 255)
40
41 /*
42  * Test "unknown" algorithm.  Is mapped to dns_hash_sha1.
43  */
44 #define DNS_NSEC3_UNKNOWNALG 245U
45
46 ISC_LANG_BEGINDECLS
47
48 isc_result_t
49 dns_nsec3_buildrdata(dns_db_t *db, dns_dbversion_t *version,
50                      dns_dbnode_t *node, unsigned int hashalg,
51                      unsigned int optin, unsigned int iterations,
52                      const unsigned char *salt, size_t salt_length,
53                      const unsigned char *nexthash, size_t hash_length,
54                      unsigned char *buffer, dns_rdata_t *rdata);
55 /*%<
56  * Build the rdata of a NSEC3 record for the data at 'node'.
57  * Note: 'node' is not the node where the NSEC3 record will be stored.
58  *
59  * Requires:
60  *      buffer  Points to a temporary buffer of at least
61  *              DNS_NSEC_BUFFERSIZE bytes.
62  *      rdata   Points to an initialized dns_rdata_t.
63  *
64  * Ensures:
65  *      *rdata  Contains a valid NSEC3 rdata.  The 'data' member refers
66  *              to 'buffer'.
67  */
68
69 isc_boolean_t
70 dns_nsec3_typepresent(dns_rdata_t *nsec, dns_rdatatype_t type);
71 /*%<
72  * Determine if a type is marked as present in an NSEC3 record.
73  *
74  * Requires:
75  *      'nsec' points to a valid rdataset of type NSEC3
76  */
77
78 isc_result_t
79 dns_nsec3_hashname(dns_fixedname_t *result,
80                    unsigned char rethash[NSEC3_MAX_HASH_LENGTH],
81                    size_t *hash_length, dns_name_t *name, dns_name_t *origin,
82                    dns_hash_t hashalg, unsigned int iterations,
83                    const unsigned char *salt, size_t saltlength);
84 /*%<
85  * Make a hashed domain name from an unhashed one. If rethash is not NULL
86  * the raw hash is stored there.
87  */
88
89 unsigned int
90 dns_nsec3_hashlength(dns_hash_t hash);
91 /*%<
92  * Return the length of the hash produced by the specified algorithm
93  * or zero when unknown.
94  */
95
96 isc_boolean_t
97 dns_nsec3_supportedhash(dns_hash_t hash);
98 /*%<
99  * Return whether we support this hash algorithm or not.
100  */
101
102 isc_result_t
103 dns_nsec3_addnsec3(dns_db_t *db, dns_dbversion_t *version,
104                    dns_name_t *name, const dns_rdata_nsec3param_t *nsec3param,
105                    dns_ttl_t nsecttl, isc_boolean_t unsecure, dns_diff_t *diff);
106
107 isc_result_t
108 dns_nsec3_addnsec3s(dns_db_t *db, dns_dbversion_t *version,
109                     dns_name_t *name, dns_ttl_t nsecttl,
110                     isc_boolean_t unsecure, dns_diff_t *diff);
111 /*%<
112  * Add NSEC3 records for 'name', recording the change in 'diff'.
113  * Adjust previous NSEC3 records, if any, to reflect the addition.
114  * The existing NSEC3 records are removed.
115  *
116  * dns_nsec3_addnsec3() will only add records to the chain identified by
117  * 'nsec3param'.
118  *
119  * 'unsecure' should be set to reflect if this is a potentially
120  * unsecure delegation (no DS record).
121  *
122  * dns_nsec3_addnsec3s() will examine the NSEC3PARAM RRset to determine which
123  * chains to be updated.  NSEC3PARAM records with the DNS_NSEC3FLAG_CREATE
124  * will be preferentially chosen over NSEC3PARAM records without
125  * DNS_NSEC3FLAG_CREATE set.  NSEC3PARAM records with DNS_NSEC3FLAG_REMOVE
126  * set will be ignored by dns_nsec3_addnsec3s().  If DNS_NSEC3FLAG_CREATE
127  * is set then the new NSEC3 will have OPTOUT set to match the that in the
128  * NSEC3PARAM record otherwise OPTOUT will be inherited from the previous
129  * record in the chain.
130  *
131  * Requires:
132  *      'db' to be valid.
133  *      'version' to be valid or NULL.
134  *      'name' to be valid.
135  *      'nsec3param' to be valid.
136  *      'diff' to be valid.
137  */
138
139 isc_result_t
140 dns_nsec3_delnsec3(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name,
141                    const dns_rdata_nsec3param_t *nsec3param, dns_diff_t *diff);
142
143 isc_result_t
144 dns_nsec3_delnsec3s(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name,
145                     dns_diff_t *diff);
146 /*%<
147  * Remove NSEC3 records for 'name', recording the change in 'diff'.
148  * Adjust previous NSEC3 records, if any, to reflect the removal.
149  *
150  * dns_nsec3_delnsec3() performs the above for the chain identified by
151  * 'nsec3param'.
152  *
153  * dns_nsec3_delnsec3s() examines the NSEC3PARAM RRset in a similar manner
154  * to dns_nsec3_addnsec3s().  Unlike dns_nsec3_addnsec3s() updated NSEC3
155  * records have the OPTOUT flag preserved.
156  *
157  * Requires:
158  *      'db' to be valid.
159  *      'version' to be valid or NULL.
160  *      'name' to be valid.
161  *      'nsec3param' to be valid.
162  *      'diff' to be valid.
163  */
164
165 isc_result_t
166 dns_nsec3_active(dns_db_t *db, dns_dbversion_t *version,
167                  isc_boolean_t complete, isc_boolean_t *answer);
168 /*%<
169  * Check if there are any complete/to be built NSEC3 chains.
170  * If 'complete' is ISC_TRUE only complete chains will be recognized.
171  *
172  * Requires:
173  *      'db' to be valid.
174  *      'version' to be valid or NULL.
175  *      'answer' to be non NULL.
176  */
177
178 isc_result_t
179 dns_nsec3_maxiterations(dns_db_t *db, dns_dbversion_t *version,
180                         isc_mem_t *mctx, unsigned int *iterationsp);
181 /*%<
182  * Find the maximum permissible number of iterations allowed based on
183  * the key strength.
184  *
185  * Requires:
186  *      'db' to be valid.
187  *      'version' to be valid or NULL.
188  *      'mctx' to be valid.
189  *      'iterationsp' to be non NULL.
190  */
191
192 ISC_LANG_ENDDECLS
193
194 #endif /* DNS_NSEC3_H */