Home | History | Annotate | Line # | Download | only in generic
      1 /*	$NetBSD: cdnskey_60.c,v 1.10 2026/01/29 18:37:51 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 /* draft-ietf-dnsop-delegation-trust-maintainance-14 */
     17 
     18 #ifndef RDATA_GENERIC_CDNSKEY_60_C
     19 #define RDATA_GENERIC_CDNSKEY_60_C
     20 
     21 #include <dst/dst.h>
     22 
     23 #define RRTYPE_CDNSKEY_ATTRIBUTES 0
     24 
     25 static isc_result_t
     26 fromtext_cdnskey(ARGS_FROMTEXT) {
     27 	REQUIRE(type == dns_rdatatype_cdnskey);
     28 
     29 	return generic_fromtext_key(CALL_FROMTEXT);
     30 }
     31 
     32 static isc_result_t
     33 totext_cdnskey(ARGS_TOTEXT) {
     34 	REQUIRE(rdata != NULL);
     35 	REQUIRE(rdata->type == dns_rdatatype_cdnskey);
     36 
     37 	return generic_totext_key(CALL_TOTEXT);
     38 }
     39 
     40 static isc_result_t
     41 fromwire_cdnskey(ARGS_FROMWIRE) {
     42 	REQUIRE(type == dns_rdatatype_cdnskey);
     43 
     44 	return generic_fromwire_key(CALL_FROMWIRE);
     45 }
     46 
     47 static 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 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 isc_result_t
     79 fromstruct_cdnskey(ARGS_FROMSTRUCT) {
     80 	REQUIRE(type == dns_rdatatype_cdnskey);
     81 
     82 	return generic_fromstruct_key(CALL_FROMSTRUCT);
     83 }
     84 
     85 static 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 	DNS_RDATACOMMON_INIT(dnskey, rdata->type, rdata->rdclass);
     94 
     95 	return generic_tostruct_key(CALL_TOSTRUCT);
     96 }
     97 
     98 static void
     99 freestruct_cdnskey(ARGS_FREESTRUCT) {
    100 	dns_rdata_cdnskey_t *dnskey = (dns_rdata_cdnskey_t *)source;
    101 
    102 	REQUIRE(dnskey != NULL);
    103 	REQUIRE(dnskey->common.rdtype == dns_rdatatype_cdnskey);
    104 
    105 	generic_freestruct_key(source);
    106 }
    107 
    108 static isc_result_t
    109 additionaldata_cdnskey(ARGS_ADDLDATA) {
    110 	REQUIRE(rdata->type == dns_rdatatype_cdnskey);
    111 
    112 	UNUSED(rdata);
    113 	UNUSED(owner);
    114 	UNUSED(add);
    115 	UNUSED(arg);
    116 
    117 	return ISC_R_SUCCESS;
    118 }
    119 
    120 static isc_result_t
    121 digest_cdnskey(ARGS_DIGEST) {
    122 	isc_region_t r;
    123 
    124 	REQUIRE(rdata != NULL);
    125 	REQUIRE(rdata->type == dns_rdatatype_cdnskey);
    126 
    127 	dns_rdata_toregion(rdata, &r);
    128 
    129 	return (digest)(arg, &r);
    130 }
    131 
    132 static bool
    133 checkowner_cdnskey(ARGS_CHECKOWNER) {
    134 	REQUIRE(type == dns_rdatatype_cdnskey);
    135 
    136 	UNUSED(name);
    137 	UNUSED(type);
    138 	UNUSED(rdclass);
    139 	UNUSED(wildcard);
    140 
    141 	return true;
    142 }
    143 
    144 static bool
    145 checknames_cdnskey(ARGS_CHECKNAMES) {
    146 	REQUIRE(rdata != NULL);
    147 	REQUIRE(rdata->type == dns_rdatatype_cdnskey);
    148 
    149 	UNUSED(rdata);
    150 	UNUSED(owner);
    151 	UNUSED(bad);
    152 
    153 	return true;
    154 }
    155 
    156 static int
    157 casecompare_cdnskey(ARGS_COMPARE) {
    158 	/*
    159 	 * Treat ALG 253 (private DNS) subtype name case sensitively.
    160 	 */
    161 	return compare_cdnskey(rdata1, rdata2);
    162 }
    163 
    164 #endif /* RDATA_GENERIC_CDNSKEY_60_C */
    165