Coverage Report

Created: 2025-11-11 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/rdata/generic/openpgpkey_61.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
#ifndef RDATA_GENERIC_OPENPGPKEY_61_C
15
#define RDATA_GENERIC_OPENPGPKEY_61_C
16
17
24.3k
#define RRTYPE_OPENPGPKEY_ATTRIBUTES 0
18
19
static isc_result_t
20
504
fromtext_openpgpkey(ARGS_FROMTEXT) {
21
504
  REQUIRE(type == dns_rdatatype_openpgpkey);
22
23
504
  UNUSED(type);
24
504
  UNUSED(rdclass);
25
504
  UNUSED(callbacks);
26
504
  UNUSED(options);
27
504
  UNUSED(origin);
28
29
  /*
30
   * Keyring.
31
   */
32
504
  return isc_base64_tobuffer(lexer, target, -2);
33
504
}
34
35
static isc_result_t
36
1.37k
totext_openpgpkey(ARGS_TOTEXT) {
37
1.37k
  isc_region_t sr;
38
39
1.37k
  REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
40
1.37k
  REQUIRE(rdata->length != 0);
41
42
1.37k
  dns_rdata_toregion(rdata, &sr);
43
44
  /*
45
   * Keyring
46
   */
47
1.37k
  if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
48
38
    RETERR(str_totext("( ", target));
49
38
  }
50
51
1.37k
  if ((tctx->flags & DNS_STYLEFLAG_NOCRYPTO) == 0) {
52
1.37k
    if (tctx->width == 0) { /* No splitting */
53
0
      RETERR(isc_base64_totext(&sr, 60, "", target));
54
1.37k
    } else {
55
1.37k
      RETERR(isc_base64_totext(&sr, tctx->width - 2,
56
1.37k
             tctx->linebreak, target));
57
1.37k
    }
58
1.37k
  } else {
59
0
    RETERR(str_totext("[omitted]", target));
60
0
  }
61
62
1.37k
  if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
63
38
    RETERR(str_totext(" )", target));
64
38
  }
65
66
1.37k
  return ISC_R_SUCCESS;
67
1.37k
}
68
69
static isc_result_t
70
8.47k
fromwire_openpgpkey(ARGS_FROMWIRE) {
71
8.47k
  isc_region_t sr;
72
73
8.47k
  REQUIRE(type == dns_rdatatype_openpgpkey);
74
75
8.47k
  UNUSED(type);
76
8.47k
  UNUSED(rdclass);
77
8.47k
  UNUSED(dctx);
78
79
  /*
80
   * Keyring.
81
   */
82
8.47k
  isc_buffer_activeregion(source, &sr);
83
8.47k
  if (sr.length < 1) {
84
5
    return ISC_R_UNEXPECTEDEND;
85
5
  }
86
8.46k
  isc_buffer_forward(source, sr.length);
87
8.46k
  return mem_tobuffer(target, sr.base, sr.length);
88
8.47k
}
89
90
static isc_result_t
91
693
towire_openpgpkey(ARGS_TOWIRE) {
92
693
  isc_region_t sr;
93
94
693
  REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
95
693
  REQUIRE(rdata->length != 0);
96
97
693
  UNUSED(cctx);
98
99
693
  dns_rdata_toregion(rdata, &sr);
100
693
  return mem_tobuffer(target, sr.base, sr.length);
101
693
}
102
103
static int
104
9.87k
compare_openpgpkey(ARGS_COMPARE) {
105
9.87k
  isc_region_t r1;
106
9.87k
  isc_region_t r2;
107
108
9.87k
  REQUIRE(rdata1->type == rdata2->type);
109
9.87k
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
110
9.87k
  REQUIRE(rdata1->type == dns_rdatatype_openpgpkey);
111
9.87k
  REQUIRE(rdata1->length != 0);
112
9.87k
  REQUIRE(rdata2->length != 0);
113
114
9.87k
  dns_rdata_toregion(rdata1, &r1);
115
9.87k
  dns_rdata_toregion(rdata2, &r2);
116
9.87k
  return isc_region_compare(&r1, &r2);
117
9.87k
}
118
119
static isc_result_t
120
0
fromstruct_openpgpkey(ARGS_FROMSTRUCT) {
121
0
  dns_rdata_openpgpkey_t *sig = source;
122
123
0
  REQUIRE(type == dns_rdatatype_openpgpkey);
124
0
  REQUIRE(sig != NULL);
125
0
  REQUIRE(sig->common.rdtype == type);
126
0
  REQUIRE(sig->common.rdclass == rdclass);
127
0
  REQUIRE(sig->keyring != NULL && sig->length != 0);
128
129
0
  UNUSED(type);
130
0
  UNUSED(rdclass);
131
132
  /*
133
   * Keyring.
134
   */
135
0
  return mem_tobuffer(target, sig->keyring, sig->length);
136
0
}
137
138
static isc_result_t
139
0
tostruct_openpgpkey(ARGS_TOSTRUCT) {
140
0
  isc_region_t sr;
141
0
  dns_rdata_openpgpkey_t *sig = target;
142
143
0
  REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
144
0
  REQUIRE(sig != NULL);
145
0
  REQUIRE(rdata->length != 0);
146
147
0
  DNS_RDATACOMMON_INIT(sig, rdata->type, rdata->rdclass);
148
149
0
  dns_rdata_toregion(rdata, &sr);
150
151
  /*
152
   * Keyring.
153
   */
154
0
  sig->length = sr.length;
155
0
  sig->keyring = mem_maybedup(mctx, sr.base, sig->length);
156
0
  sig->mctx = mctx;
157
0
  return ISC_R_SUCCESS;
158
0
}
159
160
static void
161
0
freestruct_openpgpkey(ARGS_FREESTRUCT) {
162
0
  dns_rdata_openpgpkey_t *sig = (dns_rdata_openpgpkey_t *)source;
163
164
0
  REQUIRE(sig != NULL);
165
0
  REQUIRE(sig->common.rdtype == dns_rdatatype_openpgpkey);
166
167
0
  if (sig->mctx == NULL) {
168
0
    return;
169
0
  }
170
171
0
  if (sig->keyring != NULL) {
172
0
    isc_mem_free(sig->mctx, sig->keyring);
173
0
  }
174
0
  sig->mctx = NULL;
175
0
}
176
177
static isc_result_t
178
0
additionaldata_openpgpkey(ARGS_ADDLDATA) {
179
0
  REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
180
181
0
  UNUSED(rdata);
182
0
  UNUSED(owner);
183
0
  UNUSED(add);
184
0
  UNUSED(arg);
185
186
0
  return ISC_R_SUCCESS;
187
0
}
188
189
static isc_result_t
190
0
digest_openpgpkey(ARGS_DIGEST) {
191
0
  isc_region_t r;
192
193
0
  REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
194
195
0
  dns_rdata_toregion(rdata, &r);
196
197
0
  return (digest)(arg, &r);
198
0
}
199
200
static bool
201
0
checkowner_openpgpkey(ARGS_CHECKOWNER) {
202
0
  REQUIRE(type == dns_rdatatype_openpgpkey);
203
204
0
  UNUSED(name);
205
0
  UNUSED(type);
206
0
  UNUSED(rdclass);
207
0
  UNUSED(wildcard);
208
209
0
  return true;
210
0
}
211
212
static bool
213
0
checknames_openpgpkey(ARGS_CHECKNAMES) {
214
0
  REQUIRE(rdata->type == dns_rdatatype_openpgpkey);
215
216
0
  UNUSED(rdata);
217
0
  UNUSED(owner);
218
0
  UNUSED(bad);
219
220
0
  return true;
221
0
}
222
223
static int
224
0
casecompare_openpgpkey(ARGS_COMPARE) {
225
0
  isc_region_t r1;
226
0
  isc_region_t r2;
227
228
0
  REQUIRE(rdata1->type == rdata2->type);
229
0
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
230
0
  REQUIRE(rdata1->type == dns_rdatatype_openpgpkey);
231
0
  REQUIRE(rdata1->length != 0);
232
0
  REQUIRE(rdata2->length != 0);
233
234
0
  dns_rdata_toregion(rdata1, &r1);
235
0
  dns_rdata_toregion(rdata2, &r2);
236
237
0
  return isc_region_compare(&r1, &r2);
238
0
}
239
240
#endif /* RDATA_GENERIC_OPENPGPKEY_61_C */