1 /* $NetBSD: cdnskey_60.c,v 1.5 2021/02/19 16:42:17 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14 /* draft-ietf-dnsop-delegation-trust-maintainance-14 */ 15 16 #ifndef RDATA_GENERIC_CDNSKEY_60_C 17 #define RDATA_GENERIC_CDNSKEY_60_C 18 19 #include <dst/dst.h> 20 21 #define RRTYPE_CDNSKEY_ATTRIBUTES 0 22 23 static inline isc_result_t 24 fromtext_cdnskey(ARGS_FROMTEXT) { 25 REQUIRE(type == dns_rdatatype_cdnskey); 26 27 return (generic_fromtext_key(rdclass, type, lexer, origin, options, 28 target, callbacks)); 29 } 30 31 static inline isc_result_t 32 totext_cdnskey(ARGS_TOTEXT) { 33 REQUIRE(rdata != NULL); 34 REQUIRE(rdata->type == dns_rdatatype_cdnskey); 35 36 return (generic_totext_key(rdata, tctx, target)); 37 } 38 39 static inline isc_result_t 40 fromwire_cdnskey(ARGS_FROMWIRE) { 41 REQUIRE(type == dns_rdatatype_cdnskey); 42 43 return (generic_fromwire_key(rdclass, type, source, dctx, options, 44 target)); 45 } 46 47 static inline isc_result_t 48 towire_cdnskey(ARGS_TOWIRE) { 49 isc_region_t sr; 50 51 REQUIRE(rdata->type == dns_rdatatype_cdnskey); 52 REQUIRE(rdata->length != 0); 53 54 UNUSED(cctx); 55 56 dns_rdata_toregion(rdata, &sr); 57 return (mem_tobuffer(target, sr.base, sr.length)); 58 } 59 60 static inline int 61 compare_cdnskey(ARGS_COMPARE) { 62 isc_region_t r1; 63 isc_region_t r2; 64 65 REQUIRE(rdata1 != NULL); 66 REQUIRE(rdata2 != NULL); 67 REQUIRE(rdata1->type == rdata2->type); 68 REQUIRE(rdata1->rdclass == rdata2->rdclass); 69 REQUIRE(rdata1->type == dns_rdatatype_cdnskey); 70 REQUIRE(rdata1->length != 0); 71 REQUIRE(rdata2->length != 0); 72 73 dns_rdata_toregion(rdata1, &r1); 74 dns_rdata_toregion(rdata2, &r2); 75 return (isc_region_compare(&r1, &r2)); 76 } 77 78 static inline isc_result_t 79 fromstruct_cdnskey(ARGS_FROMSTRUCT) { 80 REQUIRE(type == dns_rdatatype_cdnskey); 81 82 return (generic_fromstruct_key(rdclass, type, source, target)); 83 } 84 85 static inline isc_result_t 86 tostruct_cdnskey(ARGS_TOSTRUCT) { 87 dns_rdata_cdnskey_t *dnskey = target; 88 89 REQUIRE(dnskey != NULL); 90 REQUIRE(rdata != NULL); 91 REQUIRE(rdata->type == dns_rdatatype_cdnskey); 92 93 dnskey->common.rdclass = rdata->rdclass; 94 dnskey->common.rdtype = rdata->type; 95 ISC_LINK_INIT(&dnskey->common, link); 96 97 return (generic_tostruct_key(rdata, target, mctx)); 98 } 99 100 static inline void 101 freestruct_cdnskey(ARGS_FREESTRUCT) { 102 dns_rdata_cdnskey_t *dnskey = (dns_rdata_cdnskey_t *)source; 103 104 REQUIRE(dnskey != NULL); 105 REQUIRE(dnskey->common.rdtype == dns_rdatatype_cdnskey); 106 107 generic_freestruct_key(source); 108 } 109 110 static inline isc_result_t 111 additionaldata_cdnskey(ARGS_ADDLDATA) { 112 REQUIRE(rdata->type == dns_rdatatype_cdnskey); 113 114 UNUSED(rdata); 115 UNUSED(add); 116 UNUSED(arg); 117 118 return (ISC_R_SUCCESS); 119 } 120 121 static inline isc_result_t 122 digest_cdnskey(ARGS_DIGEST) { 123 isc_region_t r; 124 125 REQUIRE(rdata != NULL); 126 REQUIRE(rdata->type == dns_rdatatype_cdnskey); 127 128 dns_rdata_toregion(rdata, &r); 129 130 return ((digest)(arg, &r)); 131 } 132 133 static inline bool 134 checkowner_cdnskey(ARGS_CHECKOWNER) { 135 REQUIRE(type == dns_rdatatype_cdnskey); 136 137 UNUSED(name); 138 UNUSED(type); 139 UNUSED(rdclass); 140 UNUSED(wildcard); 141 142 return (true); 143 } 144 145 static inline bool 146 checknames_cdnskey(ARGS_CHECKNAMES) { 147 REQUIRE(rdata != NULL); 148 REQUIRE(rdata->type == dns_rdatatype_cdnskey); 149 150 UNUSED(rdata); 151 UNUSED(owner); 152 UNUSED(bad); 153 154 return (true); 155 } 156 157 static inline int 158 casecompare_cdnskey(ARGS_COMPARE) { 159 /* 160 * Treat ALG 253 (private DNS) subtype name case sensitively. 161 */ 162 return (compare_cdnskey(rdata1, rdata2)); 163 } 164 165 #endif /* RDATA_GENERIC_CDNSKEY_60_C */ 166