Coverage Report

Created: 2025-11-24 06:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/rdata/generic/dnskey_48.c
Line
Count
Source
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
 * SPDX-License-Identifier: MPL-2.0
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
/* RFC2535 */
15
16
#ifndef RDATA_GENERIC_DNSKEY_48_C
17
#define RDATA_GENERIC_DNSKEY_48_C
18
19
#include <dst/dst.h>
20
21
14.8k
#define RRTYPE_DNSKEY_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC)
22
23
static isc_result_t
24
686
fromtext_dnskey(ARGS_FROMTEXT) {
25
686
  REQUIRE(type == dns_rdatatype_dnskey);
26
27
686
  return generic_fromtext_key(CALL_FROMTEXT);
28
686
}
29
30
static isc_result_t
31
2.45k
totext_dnskey(ARGS_TOTEXT) {
32
2.45k
  REQUIRE(rdata != NULL);
33
2.45k
  REQUIRE(rdata->type == dns_rdatatype_dnskey);
34
35
2.45k
  return generic_totext_key(CALL_TOTEXT);
36
2.45k
}
37
38
static isc_result_t
39
4.48k
fromwire_dnskey(ARGS_FROMWIRE) {
40
4.48k
  REQUIRE(type == dns_rdatatype_dnskey);
41
42
4.48k
  return generic_fromwire_key(CALL_FROMWIRE);
43
4.48k
}
44
45
static isc_result_t
46
1.27k
towire_dnskey(ARGS_TOWIRE) {
47
1.27k
  isc_region_t sr;
48
49
1.27k
  REQUIRE(rdata != NULL);
50
1.27k
  REQUIRE(rdata->type == dns_rdatatype_dnskey);
51
1.27k
  REQUIRE(rdata->length != 0);
52
53
1.27k
  UNUSED(cctx);
54
55
1.27k
  dns_rdata_toregion(rdata, &sr);
56
1.27k
  return mem_tobuffer(target, sr.base, sr.length);
57
1.27k
}
58
59
static int
60
2.51k
compare_dnskey(ARGS_COMPARE) {
61
2.51k
  isc_region_t r1;
62
2.51k
  isc_region_t r2;
63
64
2.51k
  REQUIRE(rdata1 != NULL);
65
2.51k
  REQUIRE(rdata2 != NULL);
66
2.51k
  REQUIRE(rdata1->type == rdata2->type);
67
2.51k
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
68
2.51k
  REQUIRE(rdata1->type == dns_rdatatype_dnskey);
69
2.51k
  REQUIRE(rdata1->length != 0);
70
2.51k
  REQUIRE(rdata2->length != 0);
71
72
2.51k
  dns_rdata_toregion(rdata1, &r1);
73
2.51k
  dns_rdata_toregion(rdata2, &r2);
74
2.51k
  return isc_region_compare(&r1, &r2);
75
2.51k
}
76
77
static isc_result_t
78
0
fromstruct_dnskey(ARGS_FROMSTRUCT) {
79
0
  REQUIRE(type == dns_rdatatype_dnskey);
80
81
0
  return generic_fromstruct_key(CALL_FROMSTRUCT);
82
0
}
83
84
static isc_result_t
85
96
tostruct_dnskey(ARGS_TOSTRUCT) {
86
96
  dns_rdata_dnskey_t *dnskey = target;
87
88
96
  REQUIRE(dnskey != NULL);
89
96
  REQUIRE(rdata != NULL);
90
96
  REQUIRE(rdata->type == dns_rdatatype_dnskey);
91
92
96
  DNS_RDATACOMMON_INIT(dnskey, rdata->type, rdata->rdclass);
93
94
96
  return generic_tostruct_key(CALL_TOSTRUCT);
95
96
}
96
97
static void
98
0
freestruct_dnskey(ARGS_FREESTRUCT) {
99
0
  dns_rdata_dnskey_t *dnskey = (dns_rdata_dnskey_t *)source;
100
101
0
  REQUIRE(dnskey != NULL);
102
0
  REQUIRE(dnskey->common.rdtype == dns_rdatatype_dnskey);
103
104
0
  generic_freestruct_key(source);
105
0
}
106
107
static isc_result_t
108
0
additionaldata_dnskey(ARGS_ADDLDATA) {
109
0
  REQUIRE(rdata->type == dns_rdatatype_dnskey);
110
111
0
  UNUSED(rdata);
112
0
  UNUSED(owner);
113
0
  UNUSED(add);
114
0
  UNUSED(arg);
115
116
0
  return ISC_R_SUCCESS;
117
0
}
118
119
static isc_result_t
120
0
digest_dnskey(ARGS_DIGEST) {
121
0
  isc_region_t r;
122
123
0
  REQUIRE(rdata != NULL);
124
0
  REQUIRE(rdata->type == dns_rdatatype_dnskey);
125
126
0
  dns_rdata_toregion(rdata, &r);
127
128
0
  return (digest)(arg, &r);
129
0
}
130
131
static bool
132
0
checkowner_dnskey(ARGS_CHECKOWNER) {
133
0
  REQUIRE(type == dns_rdatatype_dnskey);
134
135
0
  UNUSED(name);
136
0
  UNUSED(type);
137
0
  UNUSED(rdclass);
138
0
  UNUSED(wildcard);
139
140
0
  return true;
141
0
}
142
143
static bool
144
0
checknames_dnskey(ARGS_CHECKNAMES) {
145
0
  REQUIRE(rdata != NULL);
146
0
  REQUIRE(rdata->type == dns_rdatatype_dnskey);
147
148
0
  UNUSED(rdata);
149
0
  UNUSED(owner);
150
0
  UNUSED(bad);
151
152
0
  return true;
153
0
}
154
155
static int
156
0
casecompare_dnskey(ARGS_COMPARE) {
157
  /*
158
   * Treat ALG 253 (private DNS) subtype name case sensitively.
159
   */
160
0
  return compare_dnskey(rdata1, rdata2);
161
0
}
162
163
#endif /* RDATA_GENERIC_DNSKEY_48_C */