1 /* $NetBSD: nsec.h,v 1.6 2022/09/23 12:15:30 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #ifndef DNS_NSEC_H 17 #define DNS_NSEC_H 1 18 19 /*! \file dns/nsec.h */ 20 21 #include <stdbool.h> 22 23 #include <isc/lang.h> 24 25 #include <dns/name.h> 26 #include <dns/types.h> 27 28 #define DNS_NSEC_BUFFERSIZE (DNS_NAME_MAXWIRE + 8192 + 512) 29 30 ISC_LANG_BEGINDECLS 31 32 isc_result_t 33 dns_nsec_buildrdata(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, 34 const dns_name_t *target, unsigned char *buffer, 35 dns_rdata_t *rdata); 36 /*%< 37 * Build the rdata of a NSEC record. 38 * 39 * Requires: 40 *\li buffer Points to a temporary buffer of at least 41 * DNS_NSEC_BUFFERSIZE bytes. 42 *\li rdata Points to an initialized dns_rdata_t. 43 * 44 * Ensures: 45 * \li *rdata Contains a valid NSEC rdata. The 'data' member refers 46 * to 'buffer'. 47 */ 48 49 isc_result_t 50 dns_nsec_build(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, 51 const dns_name_t *target, dns_ttl_t ttl); 52 /*%< 53 * Build a NSEC record and add it to a database. 54 */ 55 56 bool 57 dns_nsec_typepresent(dns_rdata_t *nsec, dns_rdatatype_t type); 58 /*%< 59 * Determine if a type is marked as present in an NSEC record. 60 * 61 * Requires: 62 *\li 'nsec' points to a valid rdataset of type NSEC 63 */ 64 65 isc_result_t 66 dns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version, bool *answer); 67 /* 68 * Report whether the DNSKEY RRset has a NSEC only algorithm. Unknown 69 * algorithms are assumed to support NSEC3. If DNSKEY is not found, 70 * *answer is set to false, and ISC_R_NOTFOUND is returned. 71 * 72 * Requires: 73 * 'answer' to be non NULL. 74 */ 75 76 unsigned int 77 dns_nsec_compressbitmap(unsigned char *map, const unsigned char *raw, 78 unsigned int max_type); 79 /*%< 80 * Convert a raw bitmap into a compressed windowed bit map. 'map' and 'raw' 81 * may overlap. 82 * 83 * Returns the length of the compressed windowed bit map. 84 */ 85 86 void 87 dns_nsec_setbit(unsigned char *array, unsigned int type, unsigned int bit); 88 /*%< 89 * Set type bit in raw 'array' to 'bit'. 90 */ 91 92 bool 93 dns_nsec_isset(const unsigned char *array, unsigned int type); 94 /*%< 95 * Test if the corresponding 'type' bit is set in 'array'. 96 */ 97 98 isc_result_t 99 dns_nsec_noexistnodata(dns_rdatatype_t type, const dns_name_t *name, 100 const dns_name_t *nsecname, dns_rdataset_t *nsecset, 101 bool *exists, bool *data, dns_name_t *wild, 102 dns_nseclog_t log, void *arg); 103 /*% 104 * Return ISC_R_SUCCESS if we can determine that the name doesn't exist 105 * or we can determine whether there is data or not at the name. 106 * If the name does not exist return the wildcard name. 107 * 108 * Return DNS_R_DNAME when the NSEC indicates that name is covered by 109 * a DNAME. 'wild' is not set in this case. 110 * 111 * Return ISC_R_IGNORE when the NSEC is not the appropriate one. 112 */ 113 114 ISC_LANG_ENDDECLS 115 116 #endif /* DNS_NSEC_H */ 117