rdata_test.c revision 1.5 1 1.1 christos /* $NetBSD: rdata_test.c,v 1.5 2025/05/21 14:48:06 christos Exp $ */
2 1.1 christos
3 1.1 christos /*
4 1.1 christos * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5 1.1 christos *
6 1.1 christos * SPDX-License-Identifier: MPL-2.0
7 1.1 christos *
8 1.1 christos * This Source Code Form is subject to the terms of the Mozilla Public
9 1.1 christos * License, v. 2.0. If a copy of the MPL was not distributed with this
10 1.1 christos * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11 1.1 christos *
12 1.1 christos * See the COPYRIGHT file distributed with this work for additional
13 1.1 christos * information regarding copyright ownership.
14 1.1 christos */
15 1.1 christos
16 1.1 christos #include <inttypes.h>
17 1.1 christos #include <sched.h> /* IWYU pragma: keep */
18 1.1 christos #include <setjmp.h>
19 1.1 christos #include <stdarg.h>
20 1.1 christos #include <stdbool.h>
21 1.1 christos #include <stddef.h>
22 1.1 christos #include <stdlib.h>
23 1.1 christos #include <string.h>
24 1.1 christos #include <unistd.h>
25 1.1 christos
26 1.1 christos #define UNIT_TESTING
27 1.1 christos
28 1.4 christos #include <cmocka.h>
29 1.1 christos #include <openssl_shim.h>
30 1.1 christos
31 1.1 christos #include <openssl/err.h>
32 1.1 christos
33 1.1 christos #include <isc/commandline.h>
34 1.1 christos #include <isc/hex.h>
35 1.1 christos #include <isc/lex.h>
36 1.1 christos #include <isc/stdio.h>
37 1.1 christos #include <isc/types.h>
38 1.1 christos #include <isc/util.h>
39 1.1 christos
40 1.1 christos #include <dns/rdata.h>
41 1.1 christos
42 1.1 christos #include <tests/dns.h>
43 1.1 christos
44 1.1 christos /*
45 1.1 christos * An array of these structures is passed to compare_ok().
46 1.1 christos */
47 1.1 christos struct compare_ok {
48 1.1 christos const char *text1; /* text passed to fromtext_*() */
49 1.1 christos const char *text2; /* text passed to fromtext_*() */
50 1.1 christos int answer; /* -1, 0, 1 */
51 1.1 christos int lineno; /* source line defining this RDATA */
52 1.1 christos };
53 1.1 christos typedef struct compare_ok compare_ok_t;
54 1.1 christos
55 1.1 christos struct textvsunknown {
56 1.1 christos const char *text1;
57 1.1 christos const char *text2;
58 1.1 christos };
59 1.1 christos typedef struct textvsunknown textvsunknown_t;
60 1.1 christos
61 1.1 christos /*
62 1.1 christos * An array of these structures is passed to check_text_ok().
63 1.1 christos */
64 1.1 christos typedef struct text_ok {
65 1.1 christos const char *text_in; /* text passed to fromtext_*() */
66 1.1 christos const char *text_out; /* text expected from totext_*();
67 1.1 christos * NULL indicates text_in is invalid */
68 1.1 christos unsigned int loop;
69 1.1 christos } text_ok_t;
70 1.1 christos
71 1.1 christos /*
72 1.1 christos * An array of these structures is passed to check_wire_ok().
73 1.1 christos */
74 1.1 christos typedef struct wire_ok {
75 1.1 christos unsigned char data[512]; /* RDATA in wire format */
76 1.1 christos size_t len; /* octets of data to parse */
77 1.1 christos bool ok; /* is this RDATA valid? */
78 1.1 christos unsigned int loop;
79 1.1 christos } wire_ok_t;
80 1.1 christos
81 1.3 christos #define COMPARE(r1, r2, answer) { r1, r2, answer, __LINE__ }
82 1.3 christos #define COMPARE_SENTINEL() { NULL, NULL, 0, __LINE__ }
83 1.1 christos
84 1.3 christos #define TEXT_VALID_CHANGED(data_in, data_out) { data_in, data_out, 0 }
85 1.3 christos #define TEXT_VALID(data) { data, data, 0 }
86 1.3 christos #define TEXT_VALID_LOOP(loop, data) { data, data, loop }
87 1.3 christos #define TEXT_VALID_LOOPCHG(loop, data_in, data_out) { data_in, data_out, loop }
88 1.3 christos #define TEXT_INVALID(data) { data, NULL, 0 }
89 1.3 christos #define TEXT_SENTINEL() TEXT_INVALID(NULL)
90 1.1 christos
91 1.1 christos #define VARGC(...) (sizeof((unsigned char[]){ __VA_ARGS__ }))
92 1.3 christos #define WIRE_TEST(ok, loop, ...) \
93 1.3 christos { { __VA_ARGS__ }, VARGC(__VA_ARGS__), ok, loop }
94 1.1 christos #define WIRE_VALID(...) WIRE_TEST(true, 0, __VA_ARGS__)
95 1.1 christos #define WIRE_VALID_LOOP(loop, ...) WIRE_TEST(true, loop, __VA_ARGS__)
96 1.1 christos /*
97 1.1 christos * WIRE_INVALID() test cases must always have at least one octet specified to
98 1.1 christos * distinguish them from WIRE_SENTINEL(). Use the 'empty_ok' parameter passed
99 1.1 christos * to check_wire_ok() for indicating whether empty RDATA is allowed for a given
100 1.1 christos * RR type or not.
101 1.1 christos */
102 1.1 christos #define WIRE_INVALID(FIRST, ...) WIRE_TEST(false, 0, FIRST, __VA_ARGS__)
103 1.1 christos #define WIRE_SENTINEL() WIRE_TEST(false, 0)
104 1.1 christos
105 1.1 christos static void
106 1.1 christos detect_uncleared_libcrypto_error(void) {
107 1.1 christos const char *file, *func, *data;
108 1.1 christos int line, flags;
109 1.1 christos long err;
110 1.1 christos bool leak = false;
111 1.1 christos while ((err = ERR_get_error_all(&file, &line, &func, &data, &flags)) !=
112 1.1 christos 0L)
113 1.1 christos {
114 1.1 christos fprintf(stderr,
115 1.1 christos "# Uncleared libcrypto error: %s:%d %s %s %ld %x\n",
116 1.1 christos file, line, func, data, err, flags);
117 1.1 christos leak = true;
118 1.1 christos }
119 1.1 christos assert_false(leak);
120 1.1 christos }
121 1.1 christos
122 1.1 christos /*
123 1.1 christos * Call dns_rdata_fromwire() for data in 'src', which is 'srclen' octets in
124 1.1 christos * size and represents RDATA of given 'type' and 'class'. Store the resulting
125 1.1 christos * uncompressed wire form in 'dst', which is 'dstlen' octets in size, and make
126 1.1 christos * 'rdata' refer to that uncompressed wire form.
127 1.1 christos */
128 1.1 christos static isc_result_t
129 1.1 christos wire_to_rdata(const unsigned char *src, size_t srclen, dns_rdataclass_t rdclass,
130 1.1 christos dns_rdatatype_t type, unsigned char *dst, size_t dstlen,
131 1.1 christos dns_rdata_t *rdata) {
132 1.1 christos isc_buffer_t source, target;
133 1.1 christos isc_result_t result;
134 1.1 christos
135 1.1 christos /*
136 1.1 christos * Set up len-octet buffer pointing at data.
137 1.1 christos */
138 1.1 christos isc_buffer_constinit(&source, src, srclen);
139 1.1 christos isc_buffer_add(&source, srclen);
140 1.1 christos isc_buffer_setactive(&source, srclen);
141 1.1 christos
142 1.1 christos /*
143 1.1 christos * Initialize target buffer.
144 1.1 christos */
145 1.1 christos isc_buffer_init(&target, dst, dstlen);
146 1.1 christos
147 1.1 christos /*
148 1.1 christos * Try converting input data into uncompressed wire form.
149 1.1 christos */
150 1.4 christos result = dns_rdata_fromwire(rdata, rdclass, type, &source,
151 1.4 christos DNS_DECOMPRESS_ALWAYS, &target);
152 1.1 christos detect_uncleared_libcrypto_error();
153 1.1 christos
154 1.4 christos return result;
155 1.1 christos }
156 1.1 christos
157 1.1 christos /*
158 1.1 christos * Call dns_rdata_towire() for rdata and write to result to dst.
159 1.1 christos */
160 1.1 christos static isc_result_t
161 1.1 christos rdata_towire(dns_rdata_t *rdata, unsigned char *dst, size_t dstlen,
162 1.1 christos size_t *length) {
163 1.1 christos isc_buffer_t target;
164 1.1 christos dns_compress_t cctx;
165 1.1 christos isc_result_t result;
166 1.1 christos
167 1.1 christos /*
168 1.1 christos * Initialize target buffer.
169 1.1 christos */
170 1.1 christos isc_buffer_init(&target, dst, dstlen);
171 1.1 christos
172 1.1 christos /*
173 1.1 christos * Try converting input data into uncompressed wire form.
174 1.1 christos */
175 1.4 christos dns_compress_init(&cctx, mctx, 0);
176 1.1 christos result = dns_rdata_towire(rdata, &cctx, &target);
177 1.1 christos detect_uncleared_libcrypto_error();
178 1.1 christos dns_compress_invalidate(&cctx);
179 1.1 christos
180 1.1 christos *length = isc_buffer_usedlength(&target);
181 1.1 christos
182 1.4 christos return result;
183 1.1 christos }
184 1.1 christos
185 1.1 christos static isc_result_t
186 1.1 christos additionaldata_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype,
187 1.4 christos dns_rdataset_t *found DNS__DB_FLARG) {
188 1.1 christos UNUSED(arg);
189 1.1 christos UNUSED(name);
190 1.1 christos UNUSED(qtype);
191 1.1 christos UNUSED(found);
192 1.4 christos return ISC_R_SUCCESS;
193 1.1 christos }
194 1.1 christos
195 1.1 christos /*
196 1.1 christos * call dns_rdata_additionaldata() for rdata.
197 1.1 christos */
198 1.1 christos static isc_result_t
199 1.1 christos rdata_additionadata(dns_rdata_t *rdata) {
200 1.4 christos return dns_rdata_additionaldata(rdata, dns_rootname, additionaldata_cb,
201 1.4 christos NULL);
202 1.1 christos }
203 1.1 christos
204 1.1 christos /*
205 1.1 christos * Call dns_rdata_checknames() with various owner names chosen to
206 1.1 christos * match well known forms.
207 1.1 christos *
208 1.1 christos * We are currently only checking that the calls do not trigger
209 1.1 christos * assertion failures.
210 1.1 christos *
211 1.1 christos * XXXMPA A future extension could be to record the expected
212 1.1 christos * result and the expected value of 'bad'.
213 1.1 christos */
214 1.1 christos static void
215 1.1 christos rdata_checknames(dns_rdata_t *rdata) {
216 1.1 christos dns_fixedname_t fixed, bfixed;
217 1.1 christos dns_name_t *name, *bad;
218 1.1 christos isc_result_t result;
219 1.1 christos
220 1.1 christos name = dns_fixedname_initname(&fixed);
221 1.1 christos bad = dns_fixedname_initname(&bfixed);
222 1.1 christos
223 1.1 christos (void)dns_rdata_checknames(rdata, dns_rootname, NULL);
224 1.1 christos (void)dns_rdata_checknames(rdata, dns_rootname, bad);
225 1.1 christos
226 1.4 christos result = dns_name_fromstring(name, "example.net", dns_rootname, 0,
227 1.4 christos NULL);
228 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
229 1.1 christos (void)dns_rdata_checknames(rdata, name, NULL);
230 1.1 christos (void)dns_rdata_checknames(rdata, name, bad);
231 1.1 christos
232 1.4 christos result = dns_name_fromstring(name, "in-addr.arpa", dns_rootname, 0,
233 1.4 christos NULL);
234 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
235 1.1 christos (void)dns_rdata_checknames(rdata, name, NULL);
236 1.1 christos (void)dns_rdata_checknames(rdata, name, bad);
237 1.1 christos
238 1.4 christos result = dns_name_fromstring(name, "ip6.arpa", dns_rootname, 0, NULL);
239 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
240 1.1 christos (void)dns_rdata_checknames(rdata, name, NULL);
241 1.1 christos (void)dns_rdata_checknames(rdata, name, bad);
242 1.1 christos }
243 1.1 christos
244 1.1 christos /*
245 1.1 christos * Test whether converting rdata to a type-specific struct and then back to
246 1.1 christos * rdata results in the same uncompressed wire form. This checks whether
247 1.1 christos * tostruct_*() and fromstruct_*() routines for given RR class and type behave
248 1.1 christos * consistently.
249 1.1 christos *
250 1.1 christos * This function is called for every correctly processed input RDATA, from both
251 1.1 christos * check_text_ok_single() and check_wire_ok_single().
252 1.1 christos */
253 1.1 christos static void
254 1.1 christos check_struct_conversions(dns_rdata_t *rdata, size_t structsize,
255 1.1 christos unsigned int loop) {
256 1.1 christos dns_rdataclass_t rdclass = rdata->rdclass;
257 1.1 christos dns_rdatatype_t type = rdata->type;
258 1.1 christos isc_result_t result;
259 1.1 christos isc_buffer_t target;
260 1.1 christos void *rdata_struct;
261 1.1 christos char buf[1024];
262 1.1 christos unsigned int count = 0;
263 1.1 christos
264 1.1 christos rdata_struct = isc_mem_allocate(mctx, structsize);
265 1.1 christos assert_non_null(rdata_struct);
266 1.1 christos
267 1.1 christos /*
268 1.1 christos * Convert from uncompressed wire form into type-specific struct.
269 1.1 christos */
270 1.1 christos result = dns_rdata_tostruct(rdata, rdata_struct, NULL);
271 1.1 christos detect_uncleared_libcrypto_error();
272 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
273 1.1 christos
274 1.1 christos /*
275 1.1 christos * Convert from type-specific struct into uncompressed wire form.
276 1.1 christos */
277 1.1 christos isc_buffer_init(&target, buf, sizeof(buf));
278 1.1 christos result = dns_rdata_fromstruct(NULL, rdclass, type, rdata_struct,
279 1.1 christos &target);
280 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
281 1.1 christos
282 1.1 christos /*
283 1.1 christos * Ensure results are consistent.
284 1.1 christos */
285 1.1 christos assert_int_equal(isc_buffer_usedlength(&target), rdata->length);
286 1.1 christos
287 1.1 christos assert_memory_equal(buf, rdata->data, rdata->length);
288 1.1 christos
289 1.1 christos /*
290 1.1 christos * Check that one can walk hip rendezvous servers and
291 1.1 christos * https/svcb parameters.
292 1.1 christos */
293 1.1 christos switch (type) {
294 1.1 christos case dns_rdatatype_hip: {
295 1.1 christos dns_rdata_hip_t *hip = rdata_struct;
296 1.1 christos
297 1.1 christos for (result = dns_rdata_hip_first(hip); result == ISC_R_SUCCESS;
298 1.1 christos result = dns_rdata_hip_next(hip))
299 1.1 christos {
300 1.1 christos dns_name_t name;
301 1.1 christos dns_name_init(&name, NULL);
302 1.1 christos dns_rdata_hip_current(hip, &name);
303 1.1 christos assert_int_not_equal(dns_name_countlabels(&name), 0);
304 1.1 christos assert_true(dns_name_isabsolute(&name));
305 1.1 christos count++;
306 1.1 christos }
307 1.1 christos assert_int_equal(result, ISC_R_NOMORE);
308 1.1 christos assert_int_equal(count, loop);
309 1.1 christos break;
310 1.1 christos }
311 1.1 christos case dns_rdatatype_https: {
312 1.1 christos dns_rdata_in_https_t *https = rdata_struct;
313 1.1 christos
314 1.1 christos for (result = dns_rdata_in_https_first(https);
315 1.1 christos result == ISC_R_SUCCESS;
316 1.1 christos result = dns_rdata_in_https_next(https))
317 1.1 christos {
318 1.1 christos isc_region_t region;
319 1.1 christos dns_rdata_in_https_current(https, ®ion);
320 1.1 christos assert_true(region.length >= 4);
321 1.1 christos count++;
322 1.1 christos }
323 1.1 christos assert_int_equal(result, ISC_R_NOMORE);
324 1.1 christos assert_int_equal(count, loop);
325 1.1 christos break;
326 1.1 christos }
327 1.1 christos case dns_rdatatype_svcb: {
328 1.1 christos dns_rdata_in_svcb_t *svcb = rdata_struct;
329 1.1 christos
330 1.1 christos for (result = dns_rdata_in_svcb_first(svcb);
331 1.1 christos result == ISC_R_SUCCESS;
332 1.1 christos result = dns_rdata_in_svcb_next(svcb))
333 1.1 christos {
334 1.1 christos isc_region_t region;
335 1.1 christos dns_rdata_in_svcb_current(svcb, ®ion);
336 1.1 christos assert_true(region.length >= 4);
337 1.1 christos count++;
338 1.1 christos }
339 1.1 christos assert_int_equal(result, ISC_R_NOMORE);
340 1.1 christos assert_int_equal(count, loop);
341 1.1 christos break;
342 1.1 christos }
343 1.1 christos }
344 1.1 christos
345 1.1 christos isc_mem_free(mctx, rdata_struct);
346 1.1 christos }
347 1.1 christos
348 1.1 christos /*
349 1.1 christos * Check whether converting supplied text form RDATA into uncompressed wire
350 1.1 christos * form succeeds (tests fromtext_*()). If so, try converting it back into text
351 1.1 christos * form and see if it results in the original text (tests totext_*()).
352 1.1 christos */
353 1.1 christos static void
354 1.1 christos check_text_ok_single(const text_ok_t *text_ok, dns_rdataclass_t rdclass,
355 1.1 christos dns_rdatatype_t type, size_t structsize) {
356 1.1 christos unsigned char buf_fromtext[1024], buf_fromwire[1024], buf_towire[1024];
357 1.1 christos dns_rdata_t rdata = DNS_RDATA_INIT, rdata2 = DNS_RDATA_INIT;
358 1.1 christos char buf_totext[1024] = { 0 };
359 1.1 christos isc_buffer_t target;
360 1.1 christos isc_result_t result;
361 1.1 christos size_t length = 0;
362 1.1 christos
363 1.1 christos if (debug) {
364 1.1 christos fprintf(stdout, "#check_text_ok_single(%s)\n",
365 1.1 christos text_ok->text_in);
366 1.1 christos }
367 1.1 christos /*
368 1.1 christos * Try converting text form RDATA into uncompressed wire form.
369 1.1 christos */
370 1.1 christos result = dns_test_rdatafromstring(&rdata, rdclass, type, buf_fromtext,
371 1.1 christos sizeof(buf_fromtext),
372 1.1 christos text_ok->text_in, false);
373 1.1 christos /*
374 1.1 christos * Check whether result is as expected.
375 1.1 christos */
376 1.1 christos if (text_ok->text_out != NULL) {
377 1.1 christos if (debug && result != ISC_R_SUCCESS) {
378 1.1 christos fprintf(stdout, "# '%s'\n", text_ok->text_in);
379 1.1 christos fprintf(stdout, "# result=%s\n",
380 1.1 christos isc_result_totext(result));
381 1.1 christos }
382 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
383 1.1 christos } else {
384 1.1 christos if (debug && result == ISC_R_SUCCESS) {
385 1.1 christos fprintf(stdout, "#'%s'\n", text_ok->text_in);
386 1.1 christos }
387 1.1 christos assert_int_not_equal(result, ISC_R_SUCCESS);
388 1.1 christos }
389 1.1 christos
390 1.1 christos /*
391 1.1 christos * If text form RDATA was not parsed correctly, performing any
392 1.1 christos * additional checks is pointless.
393 1.1 christos */
394 1.1 christos if (result != ISC_R_SUCCESS) {
395 1.1 christos return;
396 1.1 christos }
397 1.1 christos
398 1.1 christos /*
399 1.1 christos * Try converting uncompressed wire form RDATA back into text form and
400 1.1 christos * check whether the resulting text is the same as the original one.
401 1.1 christos */
402 1.1 christos isc_buffer_init(&target, buf_totext, sizeof(buf_totext));
403 1.1 christos result = dns_rdata_totext(&rdata, NULL, &target);
404 1.1 christos detect_uncleared_libcrypto_error();
405 1.1 christos if (result != ISC_R_SUCCESS && debug) {
406 1.1 christos size_t i;
407 1.1 christos fprintf(stdout, "# dns_rdata_totext -> %s",
408 1.1 christos isc_result_totext(result));
409 1.1 christos for (i = 0; i < rdata.length; i++) {
410 1.1 christos if ((i % 16) == 0) {
411 1.1 christos fprintf(stdout, "\n#");
412 1.1 christos }
413 1.1 christos fprintf(stdout, " %02x", rdata.data[i]);
414 1.1 christos }
415 1.1 christos fprintf(stdout, "\n");
416 1.1 christos }
417 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
418 1.1 christos /*
419 1.1 christos * Ensure buf_totext is properly NUL terminated as dns_rdata_totext()
420 1.1 christos * may attempt different output formats writing into the apparently
421 1.1 christos * unused part of the buffer.
422 1.1 christos */
423 1.1 christos isc_buffer_putuint8(&target, 0);
424 1.1 christos if (debug && strcmp(buf_totext, text_ok->text_out) != 0) {
425 1.1 christos fprintf(stdout, "# '%s' != '%s'\n", buf_totext,
426 1.1 christos text_ok->text_out);
427 1.1 christos }
428 1.1 christos assert_string_equal(buf_totext, text_ok->text_out);
429 1.1 christos
430 1.1 christos if (debug) {
431 1.1 christos fprintf(stdout, "#dns_rdata_totext -> '%s'\n", buf_totext);
432 1.1 christos }
433 1.1 christos
434 1.1 christos /*
435 1.1 christos * Ensure that fromtext_*() output is valid input for fromwire_*().
436 1.1 christos */
437 1.1 christos result = wire_to_rdata(rdata.data, rdata.length, rdclass, type,
438 1.1 christos buf_fromwire, sizeof(buf_fromwire), &rdata2);
439 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
440 1.1 christos assert_int_equal(rdata.length, rdata2.length);
441 1.1 christos assert_memory_equal(rdata.data, buf_fromwire, rdata.length);
442 1.1 christos
443 1.1 christos /*
444 1.1 christos * Ensure that fromtext_*() output is valid input for towire_*().
445 1.1 christos */
446 1.1 christos result = rdata_towire(&rdata, buf_towire, sizeof(buf_towire), &length);
447 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
448 1.1 christos assert_int_equal(rdata.length, length);
449 1.1 christos assert_memory_equal(rdata.data, buf_towire, length);
450 1.1 christos
451 1.1 christos /*
452 1.1 christos * Test that additionaldata_*() succeeded.
453 1.1 christos */
454 1.1 christos result = rdata_additionadata(&rdata);
455 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
456 1.1 christos
457 1.1 christos /*
458 1.1 christos * Exercise checknames_*().
459 1.1 christos */
460 1.1 christos rdata_checknames(&rdata);
461 1.1 christos
462 1.1 christos /*
463 1.1 christos * Perform two-way conversion checks between uncompressed wire form and
464 1.1 christos * type-specific struct.
465 1.1 christos */
466 1.1 christos check_struct_conversions(&rdata, structsize, text_ok->loop);
467 1.1 christos }
468 1.1 christos
469 1.1 christos /*
470 1.1 christos * Test whether converting rdata to text form and then parsing the result of
471 1.1 christos * that conversion again results in the same uncompressed wire form. This
472 1.1 christos * checks whether totext_*() output is parsable by fromtext_*() for given RR
473 1.1 christos * class and type.
474 1.1 christos *
475 1.1 christos * This function is called for every input RDATA which is successfully parsed
476 1.1 christos * by check_wire_ok_single() and whose type is not a meta-type.
477 1.1 christos */
478 1.1 christos static void
479 1.1 christos check_text_conversions(dns_rdata_t *rdata) {
480 1.1 christos char buf_totext[1024] = { 0 };
481 1.1 christos unsigned char buf_fromtext[1024];
482 1.1 christos isc_result_t result;
483 1.1 christos isc_buffer_t target;
484 1.1 christos dns_rdata_t rdata2 = DNS_RDATA_INIT;
485 1.1 christos
486 1.1 christos /*
487 1.1 christos * Convert uncompressed wire form RDATA into text form. This
488 1.1 christos * conversion must succeed since input RDATA was successfully
489 1.1 christos * parsed by check_wire_ok_single().
490 1.1 christos */
491 1.1 christos isc_buffer_init(&target, buf_totext, sizeof(buf_totext));
492 1.1 christos result = dns_rdata_totext(rdata, NULL, &target);
493 1.1 christos detect_uncleared_libcrypto_error();
494 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
495 1.1 christos /*
496 1.1 christos * Ensure buf_totext is properly NUL terminated as dns_rdata_totext()
497 1.1 christos * may attempt different output formats writing into the apparently
498 1.1 christos * unused part of the buffer.
499 1.1 christos */
500 1.1 christos isc_buffer_putuint8(&target, 0);
501 1.1 christos if (debug) {
502 1.1 christos fprintf(stdout, "#'%s'\n", buf_totext);
503 1.1 christos }
504 1.1 christos
505 1.1 christos /*
506 1.1 christos * Try parsing text form RDATA output by dns_rdata_totext() again.
507 1.1 christos */
508 1.1 christos result = dns_test_rdatafromstring(&rdata2, rdata->rdclass, rdata->type,
509 1.1 christos buf_fromtext, sizeof(buf_fromtext),
510 1.1 christos buf_totext, false);
511 1.1 christos if (debug && result != ISC_R_SUCCESS) {
512 1.1 christos fprintf(stdout, "# result = %s\n", isc_result_totext(result));
513 1.1 christos fprintf(stdout, "# '%s'\n", buf_fromtext);
514 1.1 christos }
515 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
516 1.1 christos assert_int_equal(rdata2.length, rdata->length);
517 1.1 christos assert_memory_equal(buf_fromtext, rdata->data, rdata->length);
518 1.1 christos }
519 1.1 christos
520 1.1 christos /*
521 1.1 christos * Test whether converting rdata to multi-line text form and then parsing the
522 1.1 christos * result of that conversion again results in the same uncompressed wire form.
523 1.1 christos * This checks whether multi-line totext_*() output is parsable by fromtext_*()
524 1.1 christos * for given RR class and type.
525 1.1 christos *
526 1.1 christos * This function is called for every input RDATA which is successfully parsed
527 1.1 christos * by check_wire_ok_single() and whose type is not a meta-type.
528 1.1 christos */
529 1.1 christos static void
530 1.1 christos check_multiline_text_conversions(dns_rdata_t *rdata) {
531 1.1 christos char buf_totext[1024] = { 0 };
532 1.1 christos unsigned char buf_fromtext[1024];
533 1.1 christos isc_result_t result;
534 1.1 christos isc_buffer_t target;
535 1.1 christos dns_rdata_t rdata2 = DNS_RDATA_INIT;
536 1.1 christos unsigned int flags;
537 1.1 christos
538 1.1 christos /*
539 1.1 christos * Convert uncompressed wire form RDATA into multi-line text form.
540 1.1 christos * This conversion must succeed since input RDATA was successfully
541 1.1 christos * parsed by check_wire_ok_single().
542 1.1 christos */
543 1.1 christos isc_buffer_init(&target, buf_totext, sizeof(buf_totext));
544 1.1 christos flags = dns_master_styleflags(&dns_master_style_default);
545 1.1 christos result = dns_rdata_tofmttext(rdata, dns_rootname, flags, 80 - 32, 4,
546 1.1 christos "\n", &target);
547 1.1 christos detect_uncleared_libcrypto_error();
548 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
549 1.1 christos /*
550 1.1 christos * Ensure buf_totext is properly NUL terminated as
551 1.1 christos * dns_rdata_tofmttext() may attempt different output formats
552 1.1 christos * writing into the apparently unused part of the buffer.
553 1.1 christos */
554 1.1 christos isc_buffer_putuint8(&target, 0);
555 1.1 christos if (debug) {
556 1.1 christos fprintf(stdout, "#'%s'\n", buf_totext);
557 1.1 christos }
558 1.1 christos
559 1.1 christos /*
560 1.1 christos * Try parsing multi-line text form RDATA output by
561 1.1 christos * dns_rdata_tofmttext() again.
562 1.1 christos */
563 1.1 christos result = dns_test_rdatafromstring(&rdata2, rdata->rdclass, rdata->type,
564 1.1 christos buf_fromtext, sizeof(buf_fromtext),
565 1.1 christos buf_totext, false);
566 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
567 1.1 christos assert_int_equal(rdata2.length, rdata->length);
568 1.1 christos assert_memory_equal(buf_fromtext, rdata->data, rdata->length);
569 1.1 christos }
570 1.1 christos
571 1.1 christos /*
572 1.1 christos * Test whether supplied wire form RDATA is properly handled as being either
573 1.1 christos * valid or invalid for an RR of given rdclass and type.
574 1.1 christos */
575 1.1 christos static void
576 1.1 christos check_wire_ok_single(const wire_ok_t *wire_ok, dns_rdataclass_t rdclass,
577 1.1 christos dns_rdatatype_t type, size_t structsize) {
578 1.1 christos unsigned char buf[1024], buf_towire[1024];
579 1.1 christos isc_result_t result;
580 1.1 christos dns_rdata_t rdata = DNS_RDATA_INIT;
581 1.1 christos size_t length = 0;
582 1.1 christos
583 1.1 christos /*
584 1.1 christos * Try converting wire data into uncompressed wire form.
585 1.1 christos */
586 1.1 christos result = wire_to_rdata(wire_ok->data, wire_ok->len, rdclass, type, buf,
587 1.1 christos sizeof(buf), &rdata);
588 1.1 christos /*
589 1.1 christos * Check whether result is as expected.
590 1.1 christos */
591 1.1 christos if (wire_ok->ok) {
592 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
593 1.1 christos } else {
594 1.1 christos assert_int_not_equal(result, ISC_R_SUCCESS);
595 1.1 christos }
596 1.1 christos
597 1.1 christos if (result != ISC_R_SUCCESS) {
598 1.1 christos return;
599 1.1 christos }
600 1.1 christos
601 1.1 christos /*
602 1.1 christos * If data was parsed correctly, perform two-way conversion checks
603 1.1 christos * between uncompressed wire form and type-specific struct.
604 1.1 christos *
605 1.1 christos * If the RR type is not a meta-type, additionally perform two-way
606 1.1 christos * conversion checks between:
607 1.1 christos *
608 1.1 christos * - uncompressed wire form and text form,
609 1.1 christos * - uncompressed wire form and multi-line text form.
610 1.1 christos */
611 1.1 christos check_struct_conversions(&rdata, structsize, wire_ok->loop);
612 1.1 christos if (!dns_rdatatype_ismeta(rdata.type)) {
613 1.1 christos check_text_conversions(&rdata);
614 1.1 christos check_multiline_text_conversions(&rdata);
615 1.1 christos }
616 1.1 christos
617 1.1 christos /*
618 1.1 christos * Ensure that fromwire_*() output is valid input for towire_*().
619 1.1 christos */
620 1.1 christos result = rdata_towire(&rdata, buf_towire, sizeof(buf_towire), &length);
621 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
622 1.1 christos assert_int_equal(rdata.length, length);
623 1.1 christos assert_memory_equal(rdata.data, buf_towire, length);
624 1.1 christos
625 1.1 christos /*
626 1.1 christos * Test that additionaldata_*() succeeded.
627 1.1 christos */
628 1.1 christos result = rdata_additionadata(&rdata);
629 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
630 1.1 christos
631 1.1 christos /*
632 1.1 christos * Exercise checknames_*().
633 1.1 christos */
634 1.1 christos rdata_checknames(&rdata);
635 1.1 christos }
636 1.1 christos
637 1.1 christos /*
638 1.1 christos * Test fromtext_*() and totext_*() routines for given RR class and type for
639 1.1 christos * each text form RDATA in the supplied array. See the comment for
640 1.1 christos * check_text_ok_single() for an explanation of how exactly these routines are
641 1.1 christos * tested.
642 1.1 christos */
643 1.1 christos static void
644 1.1 christos check_text_ok(const text_ok_t *text_ok, dns_rdataclass_t rdclass,
645 1.1 christos dns_rdatatype_t type, size_t structsize) {
646 1.1 christos size_t i;
647 1.1 christos
648 1.1 christos /*
649 1.1 christos * Check all entries in the supplied array.
650 1.1 christos */
651 1.1 christos for (i = 0; text_ok[i].text_in != NULL; i++) {
652 1.1 christos check_text_ok_single(&text_ok[i], rdclass, type, structsize);
653 1.1 christos }
654 1.1 christos }
655 1.1 christos
656 1.1 christos /*
657 1.1 christos * For each wire form RDATA in the supplied array, check whether it is properly
658 1.1 christos * handled as being either valid or invalid for an RR of given rdclass and
659 1.1 christos * type, then check whether trying to process a zero-length wire data buffer
660 1.1 christos * yields the expected result. This checks whether the fromwire_*() routine
661 1.1 christos * for given RR class and type behaves as expected.
662 1.1 christos */
663 1.1 christos static void
664 1.1 christos check_wire_ok(const wire_ok_t *wire_ok, bool empty_ok, dns_rdataclass_t rdclass,
665 1.1 christos dns_rdatatype_t type, size_t structsize) {
666 1.1 christos wire_ok_t empty_wire = WIRE_TEST(empty_ok, 0);
667 1.1 christos size_t i;
668 1.1 christos
669 1.1 christos /*
670 1.1 christos * Check all entries in the supplied array.
671 1.1 christos */
672 1.1 christos for (i = 0; wire_ok[i].len != 0; i++) {
673 1.1 christos if (debug) {
674 1.1 christos fprintf(stderr, "calling check_wire_ok_single on %zu\n",
675 1.1 christos i);
676 1.1 christos }
677 1.1 christos check_wire_ok_single(&wire_ok[i], rdclass, type, structsize);
678 1.1 christos }
679 1.1 christos
680 1.1 christos /*
681 1.1 christos * Check empty wire data.
682 1.1 christos */
683 1.1 christos check_wire_ok_single(&empty_wire, rdclass, type, structsize);
684 1.1 christos }
685 1.1 christos
686 1.1 christos /*
687 1.1 christos * Check that two records compare as expected with dns_rdata_compare().
688 1.1 christos */
689 1.1 christos static void
690 1.1 christos check_compare_ok_single(const compare_ok_t *compare_ok,
691 1.1 christos dns_rdataclass_t rdclass, dns_rdatatype_t type) {
692 1.1 christos dns_rdata_t rdata1 = DNS_RDATA_INIT, rdata2 = DNS_RDATA_INIT;
693 1.1 christos unsigned char buf1[1024], buf2[1024];
694 1.1 christos isc_result_t result;
695 1.1 christos int answer;
696 1.1 christos
697 1.1 christos result = dns_test_rdatafromstring(&rdata1, rdclass, type, buf1,
698 1.1 christos sizeof(buf1), compare_ok->text1,
699 1.1 christos false);
700 1.1 christos if (result != ISC_R_SUCCESS) {
701 1.1 christos fail_msg("# line %d: '%s': expected success, got failure",
702 1.1 christos compare_ok->lineno, compare_ok->text1);
703 1.1 christos }
704 1.1 christos
705 1.1 christos result = dns_test_rdatafromstring(&rdata2, rdclass, type, buf2,
706 1.1 christos sizeof(buf2), compare_ok->text2,
707 1.1 christos false);
708 1.1 christos
709 1.1 christos if (result != ISC_R_SUCCESS) {
710 1.1 christos fail_msg("# line %d: '%s': expected success, got failure",
711 1.1 christos compare_ok->lineno, compare_ok->text2);
712 1.1 christos }
713 1.1 christos
714 1.1 christos answer = dns_rdata_compare(&rdata1, &rdata2);
715 1.1 christos detect_uncleared_libcrypto_error();
716 1.1 christos if (compare_ok->answer == 0 && answer != 0) {
717 1.1 christos fail_msg("# line %d: dns_rdata_compare('%s', '%s'): "
718 1.1 christos "expected equal, got %s",
719 1.1 christos compare_ok->lineno, compare_ok->text1,
720 1.1 christos compare_ok->text2,
721 1.1 christos (answer > 0) ? "greater than" : "less than");
722 1.1 christos }
723 1.1 christos if (compare_ok->answer < 0 && answer >= 0) {
724 1.1 christos fail_msg("# line %d: dns_rdata_compare('%s', '%s'): "
725 1.1 christos "expected less than, got %s",
726 1.1 christos compare_ok->lineno, compare_ok->text1,
727 1.1 christos compare_ok->text2,
728 1.1 christos (answer == 0) ? "equal" : "greater than");
729 1.1 christos }
730 1.1 christos if (compare_ok->answer > 0 && answer <= 0) {
731 1.1 christos fail_msg("line %d: dns_rdata_compare('%s', '%s'): "
732 1.1 christos "expected greater than, got %s",
733 1.1 christos compare_ok->lineno, compare_ok->text1,
734 1.1 christos compare_ok->text2,
735 1.1 christos (answer == 0) ? "equal" : "less than");
736 1.1 christos }
737 1.1 christos }
738 1.1 christos
739 1.1 christos /*
740 1.1 christos * Check that all the records sets in compare_ok compare as expected
741 1.1 christos * with dns_rdata_compare().
742 1.1 christos */
743 1.1 christos static void
744 1.1 christos check_compare_ok(const compare_ok_t *compare_ok, dns_rdataclass_t rdclass,
745 1.1 christos dns_rdatatype_t type) {
746 1.1 christos size_t i;
747 1.1 christos /*
748 1.1 christos * Check all entries in the supplied array.
749 1.1 christos */
750 1.1 christos for (i = 0; compare_ok[i].text1 != NULL; i++) {
751 1.1 christos check_compare_ok_single(&compare_ok[i], rdclass, type);
752 1.1 christos }
753 1.1 christos }
754 1.1 christos
755 1.1 christos /*
756 1.1 christos * Test whether supplied sets of text form and/or wire form RDATA are handled
757 1.1 christos * as expected.
758 1.1 christos *
759 1.1 christos * The empty_ok argument denotes whether an attempt to parse a zero-length wire
760 1.1 christos * data buffer should succeed or not (it is valid for some RR types). There is
761 1.1 christos * no point in performing a similar check for empty text form RDATA, because
762 1.1 christos * dns_rdata_fromtext() returns ISC_R_UNEXPECTEDEND before calling fromtext_*()
763 1.1 christos * for the given RR class and type.
764 1.1 christos */
765 1.1 christos static void
766 1.1 christos check_rdata(const text_ok_t *text_ok, const wire_ok_t *wire_ok,
767 1.1 christos const compare_ok_t *compare_ok, bool empty_ok,
768 1.1 christos dns_rdataclass_t rdclass, dns_rdatatype_t type, size_t structsize) {
769 1.1 christos if (text_ok != NULL) {
770 1.1 christos check_text_ok(text_ok, rdclass, type, structsize);
771 1.1 christos }
772 1.1 christos if (wire_ok != NULL) {
773 1.1 christos check_wire_ok(wire_ok, empty_ok, rdclass, type, structsize);
774 1.1 christos }
775 1.1 christos if (compare_ok != NULL) {
776 1.1 christos check_compare_ok(compare_ok, rdclass, type);
777 1.1 christos }
778 1.1 christos }
779 1.1 christos
780 1.1 christos /*
781 1.1 christos * Check presentation vs unknown format of the record.
782 1.1 christos */
783 1.1 christos static void
784 1.1 christos check_textvsunknown_single(const textvsunknown_t *textvsunknown,
785 1.1 christos dns_rdataclass_t rdclass, dns_rdatatype_t type) {
786 1.1 christos dns_rdata_t rdata1 = DNS_RDATA_INIT, rdata2 = DNS_RDATA_INIT;
787 1.1 christos unsigned char buf1[1024], buf2[1024];
788 1.1 christos isc_result_t result;
789 1.1 christos
790 1.1 christos result = dns_test_rdatafromstring(&rdata1, rdclass, type, buf1,
791 1.1 christos sizeof(buf1), textvsunknown->text1,
792 1.1 christos false);
793 1.1 christos if (debug && result != ISC_R_SUCCESS) {
794 1.1 christos fprintf(stdout, "# '%s'\n", textvsunknown->text1);
795 1.1 christos fprintf(stdout, "# result=%s\n", isc_result_totext(result));
796 1.1 christos }
797 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
798 1.1 christos result = dns_test_rdatafromstring(&rdata2, rdclass, type, buf2,
799 1.1 christos sizeof(buf2), textvsunknown->text2,
800 1.1 christos false);
801 1.1 christos if (debug && result != ISC_R_SUCCESS) {
802 1.1 christos fprintf(stdout, "# '%s'\n", textvsunknown->text2);
803 1.1 christos fprintf(stdout, "# result=%s\n", isc_result_totext(result));
804 1.1 christos }
805 1.1 christos assert_int_equal(result, ISC_R_SUCCESS);
806 1.1 christos if (debug && rdata1.length != rdata2.length) {
807 1.1 christos fprintf(stdout, "# '%s'\n", textvsunknown->text1);
808 1.1 christos fprintf(stdout, "# rdata1.length (%u) != rdata2.length (%u)\n",
809 1.1 christos rdata1.length, rdata2.length);
810 1.1 christos }
811 1.1 christos assert_int_equal(rdata1.length, rdata2.length);
812 1.1 christos if (debug && memcmp(rdata1.data, rdata2.data, rdata1.length) != 0) {
813 1.1 christos unsigned int i;
814 1.1 christos fprintf(stdout, "# '%s'\n", textvsunknown->text1);
815 1.1 christos for (i = 0; i < rdata1.length; i++) {
816 1.1 christos if (rdata1.data[i] != rdata2.data[i]) {
817 1.1 christos fprintf(stderr, "# %u: %02x != %02x\n", i,
818 1.1 christos rdata1.data[i], rdata2.data[i]);
819 1.1 christos }
820 1.1 christos }
821 1.1 christos }
822 1.1 christos assert_memory_equal(rdata1.data, rdata2.data, rdata1.length);
823 1.1 christos }
824 1.1 christos
825 1.1 christos static void
826 1.1 christos check_textvsunknown(const textvsunknown_t *textvsunknown,
827 1.1 christos dns_rdataclass_t rdclass, dns_rdatatype_t type) {
828 1.1 christos size_t i;
829 1.1 christos
830 1.1 christos /*
831 1.1 christos * Check all entries in the supplied array.
832 1.1 christos */
833 1.1 christos for (i = 0; textvsunknown[i].text1 != NULL; i++) {
834 1.1 christos check_textvsunknown_single(&textvsunknown[i], rdclass, type);
835 1.1 christos }
836 1.1 christos }
837 1.1 christos
838 1.1 christos /*
839 1.1 christos * Common tests for RR types based on KEY that require key data:
840 1.1 christos *
841 1.1 christos * - CDNSKEY (RFC 7344)
842 1.1 christos * - DNSKEY (RFC 4034)
843 1.1 christos * - RKEY (draft-reid-dnsext-rkey-00)
844 1.1 christos */
845 1.1 christos static void
846 1.1 christos key_required(void **state, dns_rdatatype_t type, size_t size) {
847 1.1 christos wire_ok_t wire_ok[] = { /*
848 1.1 christos * RDATA must be at least 5 octets in size:
849 1.1 christos *
850 1.1 christos * - 2 octets for Flags,
851 1.1 christos * - 1 octet for Protocol,
852 1.1 christos * - 1 octet for Algorithm,
853 1.1 christos * - Public Key must not be empty.
854 1.1 christos *
855 1.1 christos * RFC 2535 section 3.1.2 allows the Public Key
856 1.1 christos * to be empty if bits 0-1 of Flags are both
857 1.1 christos * set, but that only applies to KEY records:
858 1.1 christos * for the RR types tested here, the Public Key
859 1.1 christos * must not be empty.
860 1.1 christos */
861 1.1 christos WIRE_INVALID(0x00),
862 1.1 christos WIRE_INVALID(0x00, 0x00),
863 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00),
864 1.1 christos WIRE_INVALID(0xc0, 0x00, 0x00, 0x00),
865 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00),
866 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00),
867 1.1 christos WIRE_SENTINEL()
868 1.1 christos };
869 1.1 christos
870 1.1 christos UNUSED(state);
871 1.1 christos
872 1.1 christos check_rdata(NULL, wire_ok, NULL, false, dns_rdataclass_in, type, size);
873 1.1 christos }
874 1.1 christos
875 1.1 christos /* APL RDATA manipulations */
876 1.1 christos ISC_RUN_TEST_IMPL(apl) {
877 1.1 christos text_ok_t text_ok[] = {
878 1.1 christos /* empty list */
879 1.1 christos TEXT_VALID(""),
880 1.1 christos /* min,max prefix IPv4 */
881 1.1 christos TEXT_VALID("1:0.0.0.0/0"), TEXT_VALID("1:127.0.0.1/32"),
882 1.1 christos /* min,max prefix IPv6 */
883 1.1 christos TEXT_VALID("2:::/0"), TEXT_VALID("2:::1/128"),
884 1.1 christos /* negated */
885 1.1 christos TEXT_VALID("!1:0.0.0.0/0"), TEXT_VALID("!1:127.0.0.1/32"),
886 1.1 christos TEXT_VALID("!2:::/0"), TEXT_VALID("!2:::1/128"),
887 1.1 christos /* bits set after prefix length - not disallowed */
888 1.1 christos TEXT_VALID("1:127.0.0.0/0"), TEXT_VALID("2:8000::/0"),
889 1.1 christos /* multiple */
890 1.1 christos TEXT_VALID("1:0.0.0.0/0 1:127.0.0.1/32"),
891 1.1 christos TEXT_VALID("1:0.0.0.0/0 !1:127.0.0.1/32"),
892 1.1 christos /* family 0, prefix 0, positive */
893 1.1 christos TEXT_VALID("\\# 4 00000000"),
894 1.1 christos /* family 0, prefix 0, negative */
895 1.1 christos TEXT_VALID("\\# 4 00000080"),
896 1.1 christos /* prefix too long */
897 1.1 christos TEXT_INVALID("1:0.0.0.0/33"), TEXT_INVALID("2:::/129"),
898 1.1 christos /*
899 1.1 christos * Sentinel.
900 1.1 christos */
901 1.1 christos TEXT_SENTINEL()
902 1.1 christos };
903 1.1 christos wire_ok_t wire_ok[] = { /* zero length */
904 1.1 christos WIRE_VALID(),
905 1.1 christos /* prefix too big IPv4 */
906 1.1 christos WIRE_INVALID(0x00, 0x01, 33U, 0x00),
907 1.1 christos /* prefix too big IPv6 */
908 1.1 christos WIRE_INVALID(0x00, 0x02, 129U, 0x00),
909 1.1 christos /* trailing zero octet in afdpart */
910 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x01, 0x00),
911 1.1 christos /*
912 1.1 christos * Sentinel.
913 1.1 christos */
914 1.1 christos WIRE_SENTINEL()
915 1.1 christos };
916 1.1 christos
917 1.1 christos check_rdata(text_ok, wire_ok, NULL, true, dns_rdataclass_in,
918 1.1 christos dns_rdatatype_apl, sizeof(dns_rdata_in_apl_t));
919 1.1 christos }
920 1.1 christos
921 1.1 christos /*
922 1.1 christos * http://broadband-forum.org/ftp/pub/approved-specs/af-saa-0069.000.pdf
923 1.1 christos *
924 1.1 christos * ATMA RRs have the following RDATA format:
925 1.1 christos *
926 1.1 christos * 1 1 1 1 1 1
927 1.1 christos * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
928 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
929 1.1 christos * | FORMAT | |
930 1.1 christos * +--+--+--+--+--+--+--+--+ |
931 1.1 christos * / ADDRESS /
932 1.1 christos * | |
933 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
934 1.1 christos *
935 1.1 christos * The fields have the following meaning:
936 1.1 christos *
937 1.1 christos * * FORMAT: One octet that indicates the format of ADDRESS. The two
938 1.1 christos * possible values for FORMAT are value 0 indicating ATM End System Address
939 1.1 christos * (AESA) format and value 1 indicating E.164 format.
940 1.1 christos *
941 1.1 christos * * ADDRESS: Variable length string of octets containing the ATM address of
942 1.1 christos * the node to which this RR pertains.
943 1.1 christos *
944 1.1 christos * When the format value is 0, indicating that the address is in AESA format,
945 1.1 christos * the address is coded as described in ISO 8348/AD 2 using the preferred
946 1.1 christos * binary encoding of the ISO NSAP format. When the format value is 1,
947 1.1 christos * indicating that the address is in E.164 format, the Address/Number Digits
948 1.1 christos * appear in the order in which they would be entered on a numeric keypad.
949 1.1 christos * Digits are coded in IA5 characters with the leftmost bit of each digit set
950 1.1 christos * to 0. This ATM address appears in ATM End System Address Octets field (AESA
951 1.1 christos * format) or the Address/Number Digits field (E.164 format) of the Called
952 1.1 christos * party number information element [ATMUNI3.1]. Subaddress information is
953 1.1 christos * intentionally not included because E.164 subaddress information is used for
954 1.1 christos * routing.
955 1.1 christos *
956 1.1 christos * ATMA RRs cause no additional section processing.
957 1.1 christos */
958 1.1 christos ISC_RUN_TEST_IMPL(atma) {
959 1.1 christos text_ok_t text_ok[] = { TEXT_VALID("00"),
960 1.1 christos TEXT_VALID_CHANGED("0.0", "00"),
961 1.1 christos /*
962 1.1 christos * multiple consecutive periods
963 1.1 christos */
964 1.1 christos TEXT_INVALID("0..0"),
965 1.1 christos /*
966 1.1 christos * trailing period
967 1.1 christos */
968 1.1 christos TEXT_INVALID("00."),
969 1.1 christos /*
970 1.1 christos * leading period
971 1.1 christos */
972 1.1 christos TEXT_INVALID(".00"),
973 1.1 christos /*
974 1.1 christos * Not full octets.
975 1.1 christos */
976 1.1 christos TEXT_INVALID("000"),
977 1.1 christos /*
978 1.1 christos * E.164
979 1.1 christos */
980 1.1 christos TEXT_VALID("+61200000000"),
981 1.1 christos /*
982 1.1 christos * E.164 with periods
983 1.1 christos */
984 1.1 christos TEXT_VALID_CHANGED("+61.2.0000.0000", "+6120000"
985 1.1 christos "0000"),
986 1.1 christos /*
987 1.1 christos * E.164 with period at end
988 1.1 christos */
989 1.1 christos TEXT_INVALID("+61200000000."),
990 1.1 christos /*
991 1.1 christos * E.164 with multiple consecutive periods
992 1.1 christos */
993 1.1 christos TEXT_INVALID("+612..00000000"),
994 1.1 christos /*
995 1.1 christos * E.164 with period before the leading digit.
996 1.1 christos */
997 1.1 christos TEXT_INVALID("+.61200000000"),
998 1.1 christos /*
999 1.1 christos * Sentinel.
1000 1.1 christos */
1001 1.1 christos TEXT_SENTINEL() };
1002 1.1 christos wire_ok_t wire_ok[] = {
1003 1.1 christos /*
1004 1.1 christos * Too short.
1005 1.1 christos */
1006 1.1 christos WIRE_INVALID(0x00), WIRE_INVALID(0x01),
1007 1.1 christos /*
1008 1.1 christos * all digits
1009 1.1 christos */
1010 1.1 christos WIRE_VALID(0x01, '6', '1', '2', '0', '0', '0'),
1011 1.1 christos /*
1012 1.1 christos * non digit
1013 1.1 christos */
1014 1.1 christos WIRE_INVALID(0x01, '+', '6', '1', '2', '0', '0', '0'),
1015 1.1 christos /*
1016 1.1 christos * Sentinel.
1017 1.1 christos */
1018 1.1 christos WIRE_SENTINEL()
1019 1.1 christos };
1020 1.1 christos
1021 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
1022 1.1 christos dns_rdatatype_atma, sizeof(dns_rdata_in_atma_t));
1023 1.1 christos }
1024 1.1 christos
1025 1.1 christos /* AMTRELAY RDATA manipulations */
1026 1.1 christos ISC_RUN_TEST_IMPL(amtrelay) {
1027 1.1 christos text_ok_t text_ok[] = {
1028 1.1 christos TEXT_INVALID(""), TEXT_INVALID("0"), TEXT_INVALID("0 0"),
1029 1.1 christos /* gateway type 0 */
1030 1.1 christos TEXT_VALID("0 0 0"), TEXT_VALID("0 1 0"),
1031 1.1 christos TEXT_INVALID("0 2 0"), /* discovery out of range */
1032 1.1 christos TEXT_VALID("255 1 0"), /* max precedence */
1033 1.1 christos TEXT_INVALID("256 1 0"), /* precedence out of range */
1034 1.1 christos
1035 1.1 christos /* IPv4 gateway */
1036 1.1 christos TEXT_INVALID("0 0 1"), /* no address */
1037 1.1 christos TEXT_VALID("0 0 1 0.0.0.0"),
1038 1.1 christos TEXT_INVALID("0 0 1 0.0.0.0 x"), /* extra */
1039 1.1 christos TEXT_INVALID("0 0 1 0.0.0.0.0"), /* bad address */
1040 1.1 christos TEXT_INVALID("0 0 1 ::"), /* bad address */
1041 1.1 christos TEXT_INVALID("0 0 1 ."), /* bad address */
1042 1.1 christos
1043 1.1 christos /* IPv6 gateway */
1044 1.1 christos TEXT_INVALID("0 0 2"), /* no address */
1045 1.1 christos TEXT_VALID("0 0 2 ::"), TEXT_INVALID("0 0 2 :: xx"), /* extra */
1046 1.1 christos TEXT_INVALID("0 0 2 0.0.0.0"), /* bad address */
1047 1.1 christos TEXT_INVALID("0 0 2 ."), /* bad address */
1048 1.1 christos
1049 1.1 christos /* hostname gateway */
1050 1.1 christos TEXT_INVALID("0 0 3"), /* no name */
1051 1.1 christos /* IPv4 is a valid name */
1052 1.1 christos TEXT_VALID_CHANGED("0 0 3 0.0.0.0", "0 0 3 0.0.0.0."),
1053 1.1 christos /* IPv6 is a valid name */
1054 1.1 christos TEXT_VALID_CHANGED("0 0 3 ::", "0 0 3 ::."),
1055 1.1 christos TEXT_VALID_CHANGED("0 0 3 example", "0 0 3 example."),
1056 1.1 christos TEXT_VALID("0 0 3 example."),
1057 1.1 christos TEXT_INVALID("0 0 3 example. x"), /* extra */
1058 1.1 christos
1059 1.1 christos /* unknown gateway */
1060 1.1 christos TEXT_VALID("\\# 2 0004"), TEXT_VALID("\\# 2 0084"),
1061 1.1 christos TEXT_VALID("\\# 2 007F"), TEXT_VALID("\\# 3 000400"),
1062 1.1 christos TEXT_VALID("\\# 3 008400"), TEXT_VALID("\\# 3 00FF00"),
1063 1.1 christos
1064 1.1 christos /*
1065 1.1 christos * Sentinel.
1066 1.1 christos */
1067 1.1 christos TEXT_SENTINEL()
1068 1.1 christos };
1069 1.1 christos wire_ok_t wire_ok[] = {
1070 1.1 christos WIRE_INVALID(0x00), WIRE_VALID(0x00, 0x00),
1071 1.1 christos WIRE_VALID(0x00, 0x80), WIRE_INVALID(0x00, 0x00, 0x00),
1072 1.1 christos WIRE_INVALID(0x00, 0x80, 0x00),
1073 1.1 christos
1074 1.1 christos WIRE_INVALID(0x00, 0x01), WIRE_INVALID(0x00, 0x01, 0x00),
1075 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00),
1076 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x00),
1077 1.1 christos WIRE_VALID(0x00, 0x01, 0x00, 0x00, 0x00, 0x00),
1078 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00),
1079 1.1 christos
1080 1.1 christos WIRE_INVALID(0x00, 0x02), WIRE_INVALID(0x00, 0x02, 0x00),
1081 1.1 christos WIRE_VALID(0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
1082 1.1 christos 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14,
1083 1.1 christos 0x15),
1084 1.1 christos WIRE_INVALID(0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
1085 1.1 christos 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
1086 1.1 christos 0x14, 0x15, 0x16),
1087 1.1 christos
1088 1.1 christos WIRE_INVALID(0x00, 0x03), WIRE_VALID(0x00, 0x03, 0x00),
1089 1.1 christos WIRE_INVALID(0x00, 0x03, 0x00, 0x00), /* extra */
1090 1.1 christos
1091 1.1 christos WIRE_VALID(0x00, 0x04), WIRE_VALID(0x00, 0x04, 0x00),
1092 1.1 christos /*
1093 1.1 christos * Sentinel.
1094 1.1 christos */
1095 1.1 christos WIRE_SENTINEL()
1096 1.1 christos };
1097 1.1 christos
1098 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
1099 1.1 christos dns_rdatatype_amtrelay, sizeof(dns_rdata_amtrelay_t));
1100 1.1 christos }
1101 1.1 christos
1102 1.1 christos ISC_RUN_TEST_IMPL(cdnskey) {
1103 1.1 christos key_required(state, dns_rdatatype_cdnskey, sizeof(dns_rdata_cdnskey_t));
1104 1.1 christos }
1105 1.1 christos
1106 1.1 christos /*
1107 1.1 christos * CSYNC tests.
1108 1.1 christos *
1109 1.1 christos * RFC 7477:
1110 1.1 christos *
1111 1.1 christos * 2.1. The CSYNC Resource Record Format
1112 1.1 christos *
1113 1.1 christos * 2.1.1. The CSYNC Resource Record Wire Format
1114 1.1 christos *
1115 1.1 christos * The CSYNC RDATA consists of the following fields:
1116 1.1 christos *
1117 1.1 christos * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
1118 1.1 christos * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1119 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1120 1.1 christos * | SOA Serial |
1121 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1122 1.1 christos * | Flags | Type Bit Map /
1123 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1124 1.1 christos * / Type Bit Map (continued) /
1125 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1126 1.1 christos *
1127 1.1 christos * 2.1.1.1. The SOA Serial Field
1128 1.1 christos *
1129 1.1 christos * The SOA Serial field contains a copy of the 32-bit SOA serial number
1130 1.1 christos * from the child zone. If the soaminimum flag is set, parental agents
1131 1.1 christos * querying children's authoritative servers MUST NOT act on data from
1132 1.1 christos * zones advertising an SOA serial number less than this value. See
1133 1.1 christos * [RFC1982] for properly implementing "less than" logic. If the
1134 1.1 christos * soaminimum flag is not set, parental agents MUST ignore the value in
1135 1.1 christos * the SOA Serial field. Clients can set the field to any value if the
1136 1.1 christos * soaminimum flag is unset, such as the number zero.
1137 1.1 christos *
1138 1.1 christos * (...)
1139 1.1 christos *
1140 1.1 christos * 2.1.1.2. The Flags Field
1141 1.1 christos *
1142 1.1 christos * The Flags field contains 16 bits of boolean flags that define
1143 1.1 christos * operations that affect the processing of the CSYNC record. The flags
1144 1.1 christos * defined in this document are as follows:
1145 1.1 christos *
1146 1.1 christos * 0x00 0x01: "immediate"
1147 1.1 christos *
1148 1.1 christos * 0x00 0x02: "soaminimum"
1149 1.1 christos *
1150 1.1 christos * The definitions for how the flags are to be used can be found in
1151 1.1 christos * Section 3.
1152 1.1 christos *
1153 1.1 christos * The remaining flags are reserved for use by future specifications.
1154 1.1 christos * Undefined flags MUST be set to 0 by CSYNC publishers. Parental
1155 1.1 christos * agents MUST NOT process a CSYNC record if it contains a 1 value for a
1156 1.1 christos * flag that is unknown to or unsupported by the parental agent.
1157 1.1 christos *
1158 1.1 christos * 2.1.1.2.1. The Type Bit Map Field
1159 1.1 christos *
1160 1.1 christos * The Type Bit Map field indicates the record types to be processed by
1161 1.1 christos * the parental agent, according to the procedures in Section 3. The
1162 1.1 christos * Type Bit Map field is encoded in the same way as the Type Bit Map
1163 1.1 christos * field of the NSEC record, described in [RFC4034], Section 4.1.2. If
1164 1.1 christos * a bit has been set that a parental agent implementation does not
1165 1.1 christos * understand, the parental agent MUST NOT act upon the record.
1166 1.1 christos * Specifically, a parental agent must not simply copy the data, and it
1167 1.1 christos * must understand the semantics associated with a bit in the Type Bit
1168 1.1 christos * Map field that has been set to 1.
1169 1.1 christos */
1170 1.1 christos ISC_RUN_TEST_IMPL(csync) {
1171 1.1 christos text_ok_t text_ok[] = { TEXT_INVALID(""),
1172 1.1 christos TEXT_INVALID("0"),
1173 1.1 christos TEXT_VALID("0 0"),
1174 1.1 christos TEXT_VALID("0 0 A"),
1175 1.1 christos TEXT_VALID("0 0 NS"),
1176 1.1 christos TEXT_VALID("0 0 AAAA"),
1177 1.1 christos TEXT_VALID("0 0 A AAAA"),
1178 1.1 christos TEXT_VALID("0 0 A NS AAAA"),
1179 1.1 christos TEXT_INVALID("0 0 A NS AAAA BOGUS"),
1180 1.1 christos TEXT_SENTINEL() };
1181 1.1 christos wire_ok_t wire_ok[] = {
1182 1.1 christos /*
1183 1.1 christos * Short.
1184 1.1 christos */
1185 1.1 christos WIRE_INVALID(0x00),
1186 1.1 christos /*
1187 1.1 christos * Short.
1188 1.1 christos */
1189 1.1 christos WIRE_INVALID(0x00, 0x00),
1190 1.1 christos /*
1191 1.1 christos * Short.
1192 1.1 christos */
1193 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00),
1194 1.1 christos /*
1195 1.1 christos * Short.
1196 1.1 christos */
1197 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00),
1198 1.1 christos /*
1199 1.1 christos * Short.
1200 1.1 christos */
1201 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00),
1202 1.1 christos /*
1203 1.1 christos * Serial + flags only.
1204 1.1 christos */
1205 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
1206 1.1 christos /*
1207 1.1 christos * Bad type map.
1208 1.1 christos */
1209 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
1210 1.1 christos /*
1211 1.1 christos * Bad type map.
1212 1.1 christos */
1213 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
1214 1.1 christos /*
1215 1.1 christos * Good type map.
1216 1.1 christos */
1217 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1218 1.1 christos 0x02),
1219 1.1 christos /*
1220 1.1 christos * Sentinel.
1221 1.1 christos */
1222 1.1 christos WIRE_SENTINEL()
1223 1.1 christos };
1224 1.1 christos
1225 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
1226 1.1 christos dns_rdatatype_csync, sizeof(dns_rdata_csync_t));
1227 1.1 christos }
1228 1.1 christos
1229 1.1 christos ISC_RUN_TEST_IMPL(dnskey) {
1230 1.1 christos key_required(state, dns_rdatatype_dnskey, sizeof(dns_rdata_dnskey_t));
1231 1.1 christos }
1232 1.1 christos
1233 1.1 christos /*
1234 1.1 christos * DOA tests.
1235 1.1 christos *
1236 1.1 christos * draft-durand-doa-over-dns-03:
1237 1.1 christos *
1238 1.1 christos * 3.2. DOA RDATA Wire Format
1239 1.1 christos *
1240 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1241 1.1 christos * 0: | |
1242 1.1 christos * | DOA-ENTERPRISE |
1243 1.1 christos * | |
1244 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1245 1.1 christos * 4: | |
1246 1.1 christos * | DOA-TYPE |
1247 1.1 christos * | |
1248 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1249 1.1 christos * 8: | DOA-LOCATION | DOA-MEDIA-TYPE /
1250 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1251 1.1 christos * 10: / /
1252 1.1 christos * / DOA-MEDIA-TYPE (continued) /
1253 1.1 christos * / /
1254 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1255 1.1 christos * / /
1256 1.1 christos * / DOA-DATA /
1257 1.1 christos * / /
1258 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1259 1.1 christos *
1260 1.1 christos * DOA-ENTERPRISE: a 32-bit unsigned integer in network order.
1261 1.1 christos *
1262 1.1 christos * DOA-TYPE: a 32-bit unsigned integer in network order.
1263 1.1 christos *
1264 1.1 christos * DOA-LOCATION: an 8-bit unsigned integer.
1265 1.1 christos *
1266 1.1 christos * DOA-MEDIA-TYPE: A <character-string> (see [RFC1035]). The first
1267 1.1 christos * octet of the <character-string> contains the number of characters to
1268 1.1 christos * follow.
1269 1.1 christos *
1270 1.1 christos * DOA-DATA: A variable length blob of binary data. The length of the
1271 1.1 christos * DOA-DATA is not contained within the wire format of the RR and has to
1272 1.1 christos * be computed from the RDLENGTH of the entire RR once other fields have
1273 1.1 christos * been taken into account.
1274 1.1 christos *
1275 1.1 christos * 3.3. DOA RDATA Presentation Format
1276 1.1 christos *
1277 1.1 christos * The DOA-ENTERPRISE field is presented as an unsigned 32-bit decimal
1278 1.1 christos * integer with range 0 - 4,294,967,295.
1279 1.1 christos *
1280 1.1 christos * The DOA-TYPE field is presented as an unsigned 32-bit decimal integer
1281 1.1 christos * with range 0 - 4,294,967,295.
1282 1.1 christos *
1283 1.1 christos * The DOA-LOCATION field is presented as an unsigned 8-bit decimal
1284 1.1 christos * integer with range 0 - 255.
1285 1.1 christos *
1286 1.1 christos * The DOA-MEDIA-TYPE field is presented as a single <character-string>.
1287 1.1 christos *
1288 1.1 christos * The DOA-DATA is presented as Base64 encoded data [RFC4648] unless the
1289 1.1 christos * DOA-DATA is empty in which case it is presented as a single dash
1290 1.1 christos * character ("-", ASCII 45). White space is permitted within Base64
1291 1.1 christos * data.
1292 1.1 christos */
1293 1.1 christos ISC_RUN_TEST_IMPL(doa) {
1294 1.1 christos text_ok_t text_ok[] = {
1295 1.1 christos /*
1296 1.1 christos * Valid, non-empty DOA-DATA.
1297 1.1 christos */
1298 1.1 christos TEXT_VALID("0 0 1 \"text/plain\" Zm9v"),
1299 1.1 christos /*
1300 1.1 christos * Valid, non-empty DOA-DATA with whitespace in between.
1301 1.1 christos */
1302 1.1 christos TEXT_VALID_CHANGED("0 0 1 \"text/plain\" Zm 9v", "0 0 1 "
1303 1.1 christos "\"text/"
1304 1.1 christos "plain\" "
1305 1.1 christos "Zm9v"),
1306 1.1 christos /*
1307 1.1 christos * Valid, unquoted DOA-MEDIA-TYPE, non-empty DOA-DATA.
1308 1.1 christos */
1309 1.1 christos TEXT_VALID_CHANGED("0 0 1 text/plain Zm9v", "0 0 1 "
1310 1.1 christos "\"text/plain\" "
1311 1.1 christos "Zm9v"),
1312 1.1 christos /*
1313 1.1 christos * Invalid, quoted non-empty DOA-DATA.
1314 1.1 christos */
1315 1.1 christos TEXT_INVALID("0 0 1 \"text/plain\" \"Zm9v\""),
1316 1.1 christos /*
1317 1.1 christos * Valid, empty DOA-DATA.
1318 1.1 christos */
1319 1.1 christos TEXT_VALID("0 0 1 \"text/plain\" -"),
1320 1.1 christos /*
1321 1.1 christos * Invalid, quoted empty DOA-DATA.
1322 1.1 christos */
1323 1.1 christos TEXT_INVALID("0 0 1 \"text/plain\" \"-\""),
1324 1.1 christos /*
1325 1.1 christos * Invalid, missing "-" in empty DOA-DATA.
1326 1.1 christos */
1327 1.1 christos TEXT_INVALID("0 0 1 \"text/plain\""),
1328 1.1 christos /*
1329 1.1 christos * Valid, undefined DOA-LOCATION.
1330 1.1 christos */
1331 1.1 christos TEXT_VALID("0 0 100 \"text/plain\" Zm9v"),
1332 1.1 christos /*
1333 1.1 christos * Invalid, DOA-LOCATION too big.
1334 1.1 christos */
1335 1.1 christos TEXT_INVALID("0 0 256 \"text/plain\" ZM9v"),
1336 1.1 christos /*
1337 1.1 christos * Valid, empty DOA-MEDIA-TYPE, non-empty DOA-DATA.
1338 1.1 christos */
1339 1.1 christos TEXT_VALID("0 0 2 \"\" aHR0cHM6Ly93d3cuaXNjLm9yZy8="),
1340 1.1 christos /*
1341 1.1 christos * Valid, empty DOA-MEDIA-TYPE, empty DOA-DATA.
1342 1.1 christos */
1343 1.1 christos TEXT_VALID("0 0 1 \"\" -"),
1344 1.1 christos /*
1345 1.1 christos * Valid, DOA-MEDIA-TYPE with a space.
1346 1.1 christos */
1347 1.1 christos TEXT_VALID("0 0 1 \"plain text\" Zm9v"),
1348 1.1 christos /*
1349 1.1 christos * Invalid, missing DOA-MEDIA-TYPE.
1350 1.1 christos */
1351 1.1 christos TEXT_INVALID("1234567890 1234567890 1"),
1352 1.1 christos /*
1353 1.1 christos * Valid, DOA-DATA over 255 octets.
1354 1.1 christos */
1355 1.1 christos TEXT_VALID("1234567890 1234567890 1 \"image/gif\" "
1356 1.1 christos "R0lGODlhKAAZAOMCAGZmZgBmmf///zOZzMz//5nM/zNmmWbM"
1357 1.1 christos "/5nMzMzMzACZ/////////////////////yH5BAEKAA8ALAAA"
1358 1.1 christos "AAAoABkAAATH8IFJK5U2a4337F5ogRkpnoCJrly7PrCKyh8c"
1359 1.1 christos "3HgAhzT35MDbbtO7/IJIHbGiOiaTxVTpSVWWLqNq1UVyapNS"
1360 1.1 christos "1wd3OAxug0LhnCubcVhsxysQnOt4ATpvvzHlFzl1AwODhWeF"
1361 1.1 christos "AgRpen5/UhheAYMFdUB4SFcpGEGGdQeCAqBBLTuSk30EeXd9"
1362 1.1 christos "pEsAbKGxjHqDSE0Sp6ixN4N1BJmbc7lIhmsBich1awPAjkY1"
1363 1.1 christos "SZR8bJWrz382SGqIBQQFQd4IsUTaX+ceuudPEQA7"),
1364 1.1 christos /*
1365 1.1 christos * Invalid, bad Base64 in DOA-DATA.
1366 1.1 christos */
1367 1.1 christos TEXT_INVALID("1234567890 1234567890 1 \"image/gif\" R0lGODl"),
1368 1.1 christos /*
1369 1.1 christos * Sentinel.
1370 1.1 christos */
1371 1.1 christos TEXT_SENTINEL()
1372 1.1 christos };
1373 1.1 christos wire_ok_t wire_ok[] = {
1374 1.1 christos /*
1375 1.1 christos * Valid, empty DOA-MEDIA-TYPE, empty DOA-DATA.
1376 1.1 christos */
1377 1.1 christos WIRE_VALID(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x01,
1378 1.1 christos 0x00),
1379 1.1 christos /*
1380 1.1 christos * Invalid, missing DOA-MEDIA-TYPE.
1381 1.1 christos */
1382 1.1 christos WIRE_INVALID(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78,
1383 1.1 christos 0x01),
1384 1.1 christos /*
1385 1.1 christos * Invalid, malformed DOA-MEDIA-TYPE length.
1386 1.1 christos */
1387 1.1 christos WIRE_INVALID(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78,
1388 1.1 christos 0x01, 0xff),
1389 1.1 christos /*
1390 1.1 christos * Valid, empty DOA-DATA.
1391 1.1 christos */
1392 1.1 christos WIRE_VALID(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x01,
1393 1.1 christos 0x03, 0x66, 0x6f, 0x6f),
1394 1.1 christos /*
1395 1.1 christos * Valid, non-empty DOA-DATA.
1396 1.1 christos */
1397 1.1 christos WIRE_VALID(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x01,
1398 1.1 christos 0x03, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72),
1399 1.1 christos /*
1400 1.1 christos * Valid, DOA-DATA over 255 octets.
1401 1.1 christos */
1402 1.1 christos WIRE_VALID(0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x01,
1403 1.1 christos 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x00, 0x66,
1404 1.1 christos 0x99, 0xff, 0xff, 0xff, 0x33, 0x99, 0xcc, 0xcc, 0xff,
1405 1.1 christos 0xff, 0x99, 0xcc, 0xff, 0x33, 0x66, 0x99, 0x66, 0xcc,
1406 1.1 christos 0xff, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x99,
1407 1.1 christos 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1408 1.1 christos 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x21, 0xf9,
1409 1.1 christos 0x04, 0x01, 0x0a, 0x00, 0x0f, 0x00, 0x2c, 0x00, 0x00,
1410 1.1 christos 0x00, 0x00, 0x28, 0x00, 0x19, 0x00, 0x00, 0x04, 0xc7,
1411 1.1 christos 0xf0, 0x81, 0x49, 0x2b, 0x95, 0x36, 0x6b, 0x8d, 0xf7,
1412 1.1 christos 0xec, 0x5e, 0x68, 0x81, 0x19, 0x29, 0x9e, 0x80, 0x89,
1413 1.1 christos 0xae, 0x5c, 0xbb, 0x3e, 0xb0, 0x8a, 0xca, 0x1f, 0x1c,
1414 1.1 christos 0xdc, 0x78, 0x00, 0x87, 0x34, 0xf7, 0xe4, 0xc0, 0xdb,
1415 1.1 christos 0x6e, 0xd3, 0xbb, 0xfc, 0x82, 0x48, 0x1d, 0xb1, 0xa2,
1416 1.1 christos 0x3a, 0x26, 0x93, 0xc5, 0x54, 0xe9, 0x49, 0x55, 0x96,
1417 1.1 christos 0x2e, 0xa3, 0x6a, 0xd5, 0x45, 0x72, 0x6a, 0x93, 0x52,
1418 1.1 christos 0xd7, 0x07, 0x77, 0x38, 0x0c, 0x6e, 0x83, 0x42, 0xe1,
1419 1.1 christos 0x9c, 0x2b, 0x9b, 0x71, 0x58, 0x6c, 0xc7, 0x2b, 0x10,
1420 1.1 christos 0x9c, 0xeb, 0x78, 0x01, 0x3a, 0x6f, 0xbf, 0x31, 0xe5,
1421 1.1 christos 0x17, 0x39, 0x75, 0x03, 0x03, 0x83, 0x85, 0x67, 0x85,
1422 1.1 christos 0x02, 0x04, 0x69, 0x7a, 0x7e, 0x7f, 0x52, 0x18, 0x5e,
1423 1.1 christos 0x01, 0x83, 0x05, 0x75, 0x40, 0x78, 0x48, 0x57, 0x29,
1424 1.1 christos 0x18, 0x41, 0x86, 0x75, 0x07, 0x82, 0x02, 0xa0, 0x41,
1425 1.1 christos 0x2d, 0x3b, 0x92, 0x93, 0x7d, 0x04, 0x79, 0x77, 0x7d,
1426 1.1 christos 0xa4, 0x4b, 0x00, 0x6c, 0xa1, 0xb1, 0x8c, 0x7a, 0x83,
1427 1.1 christos 0x48, 0x4d, 0x12, 0xa7, 0xa8, 0xb1, 0x37, 0x83, 0x75,
1428 1.1 christos 0x04, 0x99, 0x9b, 0x73, 0xb9, 0x48, 0x86, 0x6b, 0x01,
1429 1.1 christos 0x89, 0xc8, 0x75, 0x6b, 0x03, 0xc0, 0x8e, 0x46, 0x35,
1430 1.1 christos 0x49, 0x94, 0x7c, 0x6c, 0x95, 0xab, 0xcf, 0x7f, 0x36,
1431 1.1 christos 0x48, 0x6a, 0x88, 0x05, 0x04, 0x05, 0x41, 0xde, 0x08,
1432 1.1 christos 0xb1, 0x44, 0xda, 0x5f, 0xe7, 0x1e, 0xba, 0xe7, 0x4f,
1433 1.1 christos 0x11, 0x00, 0x3b),
1434 1.1 christos /*
1435 1.1 christos * Sentinel.
1436 1.1 christos */
1437 1.1 christos WIRE_SENTINEL()
1438 1.1 christos };
1439 1.1 christos
1440 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
1441 1.1 christos dns_rdatatype_doa, sizeof(dns_rdata_doa_t));
1442 1.1 christos }
1443 1.1 christos
1444 1.1 christos /*
1445 1.1 christos * DS tests.
1446 1.1 christos *
1447 1.1 christos * RFC 4034:
1448 1.1 christos *
1449 1.1 christos * 5.1. DS RDATA Wire Format
1450 1.1 christos *
1451 1.1 christos * The RDATA for a DS RR consists of a 2 octet Key Tag field, a 1 octet
1452 1.1 christos * Algorithm field, a 1 octet Digest Type field, and a Digest field.
1453 1.1 christos *
1454 1.1 christos * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
1455 1.1 christos * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1456 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1457 1.1 christos * | Key Tag | Algorithm | Digest Type |
1458 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1459 1.1 christos * / /
1460 1.1 christos * / Digest /
1461 1.1 christos * / /
1462 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1463 1.1 christos *
1464 1.1 christos * 5.1.1. The Key Tag Field
1465 1.1 christos *
1466 1.1 christos * The Key Tag field lists the key tag of the DNSKEY RR referred to by
1467 1.1 christos * the DS record, in network byte order.
1468 1.1 christos *
1469 1.1 christos * The Key Tag used by the DS RR is identical to the Key Tag used by
1470 1.1 christos * RRSIG RRs. Appendix B describes how to compute a Key Tag.
1471 1.1 christos *
1472 1.1 christos * 5.1.2. The Algorithm Field
1473 1.1 christos *
1474 1.1 christos * The Algorithm field lists the algorithm number of the DNSKEY RR
1475 1.1 christos * referred to by the DS record.
1476 1.1 christos *
1477 1.1 christos * The algorithm number used by the DS RR is identical to the algorithm
1478 1.1 christos * number used by RRSIG and DNSKEY RRs. Appendix A.1 lists the
1479 1.1 christos * algorithm number types.
1480 1.1 christos *
1481 1.1 christos * 5.1.3. The Digest Type Field
1482 1.1 christos *
1483 1.1 christos * The DS RR refers to a DNSKEY RR by including a digest of that DNSKEY
1484 1.1 christos * RR. The Digest Type field identifies the algorithm used to construct
1485 1.1 christos * the digest. Appendix A.2 lists the possible digest algorithm types.
1486 1.1 christos *
1487 1.1 christos * 5.1.4. The Digest Field
1488 1.1 christos *
1489 1.1 christos * The DS record refers to a DNSKEY RR by including a digest of that
1490 1.1 christos * DNSKEY RR.
1491 1.1 christos *
1492 1.1 christos * The digest is calculated by concatenating the canonical form of the
1493 1.1 christos * fully qualified owner name of the DNSKEY RR with the DNSKEY RDATA,
1494 1.1 christos * and then applying the digest algorithm.
1495 1.1 christos *
1496 1.1 christos * digest = digest_algorithm( DNSKEY owner name | DNSKEY RDATA);
1497 1.1 christos *
1498 1.1 christos * "|" denotes concatenation
1499 1.1 christos *
1500 1.1 christos * DNSKEY RDATA = Flags | Protocol | Algorithm | Public Key.
1501 1.1 christos *
1502 1.1 christos * The size of the digest may vary depending on the digest algorithm and
1503 1.1 christos * DNSKEY RR size. As of the time of this writing, the only defined
1504 1.1 christos * digest algorithm is SHA-1, which produces a 20 octet digest.
1505 1.1 christos */
1506 1.1 christos ISC_RUN_TEST_IMPL(ds) {
1507 1.1 christos text_ok_t text_ok[] = {
1508 1.1 christos /*
1509 1.1 christos * Invalid, empty record.
1510 1.1 christos */
1511 1.1 christos TEXT_INVALID(""),
1512 1.1 christos /*
1513 1.1 christos * Invalid, no algorithm.
1514 1.1 christos */
1515 1.1 christos TEXT_INVALID("0"),
1516 1.1 christos /*
1517 1.1 christos * Invalid, no digest type.
1518 1.1 christos */
1519 1.1 christos TEXT_INVALID("0 0"),
1520 1.1 christos /*
1521 1.1 christos * Invalid, no digest.
1522 1.1 christos */
1523 1.1 christos TEXT_INVALID("0 0 0"),
1524 1.1 christos /*
1525 1.1 christos * Valid, 1-octet digest for a reserved digest type.
1526 1.1 christos */
1527 1.1 christos TEXT_VALID("0 0 0 00"),
1528 1.1 christos /*
1529 1.1 christos * Invalid, short SHA-1 digest.
1530 1.1 christos */
1531 1.1 christos TEXT_INVALID("0 0 1 00"),
1532 1.1 christos TEXT_INVALID("0 0 1 4FDCE83016EDD29077621FE568F8DADDB5809B"),
1533 1.1 christos /*
1534 1.1 christos * Valid, 20-octet SHA-1 digest.
1535 1.1 christos */
1536 1.1 christos TEXT_VALID("0 0 1 4FDCE83016EDD29077621FE568F8DADDB5809B6A"),
1537 1.1 christos /*
1538 1.1 christos * Invalid, excessively long SHA-1 digest.
1539 1.1 christos */
1540 1.1 christos TEXT_INVALID("0 0 1 4FDCE83016EDD29077621FE568F8DADDB5809B"
1541 1.1 christos "6A00"),
1542 1.1 christos /*
1543 1.1 christos * Invalid, short SHA-256 digest.
1544 1.1 christos */
1545 1.1 christos TEXT_INVALID("0 0 2 00"),
1546 1.1 christos TEXT_INVALID("0 0 2 D001BD422FFDA9B745425B71DC17D007E69186"
1547 1.1 christos "9BD59C5F237D9BF85434C313"),
1548 1.1 christos /*
1549 1.1 christos * Valid, 32-octet SHA-256 digest.
1550 1.1 christos */
1551 1.1 christos TEXT_VALID_CHANGED("0 0 2 "
1552 1.1 christos "D001BD422FFDA9B745425B71DC17D007E691869B"
1553 1.1 christos "D59C5F237D9BF85434C3133F",
1554 1.1 christos "0 0 2 "
1555 1.1 christos "D001BD422FFDA9B745425B71DC17D007E691869B"
1556 1.1 christos "D59C5F237D9BF854 34C3133F"),
1557 1.1 christos /*
1558 1.1 christos * Invalid, excessively long SHA-256 digest.
1559 1.1 christos */
1560 1.1 christos TEXT_INVALID("0 0 2 D001BD422FFDA9B745425B71DC17D007E69186"
1561 1.1 christos "9BD59C5F237D9BF85434C3133F00"),
1562 1.1 christos /*
1563 1.1 christos * Valid, GOST is no longer supported, hence no length checks.
1564 1.1 christos */
1565 1.1 christos TEXT_VALID("0 0 3 00"),
1566 1.1 christos /*
1567 1.1 christos * Invalid, short SHA-384 digest.
1568 1.1 christos */
1569 1.1 christos TEXT_INVALID("0 0 4 00"),
1570 1.1 christos TEXT_INVALID("0 0 4 AC748D6C5AA652904A8763D64B7DFFFFA98152"
1571 1.1 christos "BE12128D238BEBB4814B648F5A841E15CAA2DE348891"
1572 1.1 christos "A37A699F65E5"),
1573 1.1 christos /*
1574 1.1 christos * Valid, 48-octet SHA-384 digest.
1575 1.1 christos */
1576 1.1 christos TEXT_VALID_CHANGED("0 0 4 "
1577 1.1 christos "AC748D6C5AA652904A8763D64B7DFFFFA98152BE"
1578 1.1 christos "12128D238BEBB4814B648F5A841E15CAA2DE348891A"
1579 1.1 christos "37A"
1580 1.1 christos "699F65E54D",
1581 1.1 christos "0 0 4 "
1582 1.1 christos "AC748D6C5AA652904A8763D64B7DFFFFA98152BE"
1583 1.1 christos "12128D238BEBB481 "
1584 1.1 christos "4B648F5A841E15CAA2DE348891A37A"
1585 1.1 christos "699F65E54D"),
1586 1.1 christos /*
1587 1.1 christos * Invalid, excessively long SHA-384 digest.
1588 1.1 christos */
1589 1.1 christos TEXT_INVALID("0 0 4 AC748D6C5AA652904A8763D64B7DFFFFA98152"
1590 1.1 christos "BE12128D238BEBB4814B648F5A841E15CAA2DE348891"
1591 1.1 christos "A37A699F65E54D00"),
1592 1.1 christos /*
1593 1.1 christos * Valid, 1-octet digest for an unassigned digest type.
1594 1.1 christos */
1595 1.1 christos TEXT_VALID("0 0 5 00"),
1596 1.1 christos /*
1597 1.1 christos * Sentinel.
1598 1.1 christos */
1599 1.1 christos TEXT_SENTINEL()
1600 1.1 christos };
1601 1.1 christos wire_ok_t wire_ok[] = {
1602 1.1 christos /*
1603 1.1 christos * Invalid, truncated key tag.
1604 1.1 christos */
1605 1.1 christos WIRE_INVALID(0x00),
1606 1.1 christos /*
1607 1.1 christos * Invalid, no algorithm.
1608 1.1 christos */
1609 1.1 christos WIRE_INVALID(0x00, 0x00),
1610 1.1 christos /*
1611 1.1 christos * Invalid, no digest type.
1612 1.1 christos */
1613 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00),
1614 1.1 christos /*
1615 1.1 christos * Invalid, no digest.
1616 1.1 christos */
1617 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00),
1618 1.1 christos /*
1619 1.1 christos * Valid, 1-octet digest for a reserved digest type.
1620 1.1 christos */
1621 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00),
1622 1.1 christos /*
1623 1.1 christos * Invalid, short SHA-1 digest.
1624 1.1 christos */
1625 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x01, 0x00),
1626 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x01, 0x4F, 0xDC, 0xE8, 0x30,
1627 1.1 christos 0x16, 0xED, 0xD2, 0x90, 0x77, 0x62, 0x1F, 0xE5,
1628 1.1 christos 0x68, 0xF8, 0xDA, 0xDD, 0xB5, 0x80, 0x9B),
1629 1.1 christos /*
1630 1.1 christos * Valid, 20-octet SHA-1 digest.
1631 1.1 christos */
1632 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x01, 0x4F, 0xDC, 0xE8, 0x30, 0x16,
1633 1.1 christos 0xED, 0xD2, 0x90, 0x77, 0x62, 0x1F, 0xE5, 0x68, 0xF8,
1634 1.1 christos 0xDA, 0xDD, 0xB5, 0x80, 0x9B, 0x6A),
1635 1.1 christos /*
1636 1.1 christos * Invalid, excessively long SHA-1 digest.
1637 1.1 christos */
1638 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x01, 0x4F, 0xDC, 0xE8, 0x30,
1639 1.1 christos 0x16, 0xED, 0xD2, 0x90, 0x77, 0x62, 0x1F, 0xE5,
1640 1.1 christos 0x68, 0xF8, 0xDA, 0xDD, 0xB5, 0x80, 0x9B, 0x6A,
1641 1.1 christos 0x00),
1642 1.1 christos /*
1643 1.1 christos * Invalid, short SHA-256 digest.
1644 1.1 christos */
1645 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x02, 0x00),
1646 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x02, 0xD0, 0x01, 0xBD, 0x42,
1647 1.1 christos 0x2F, 0xFD, 0xA9, 0xB7, 0x45, 0x42, 0x5B, 0x71,
1648 1.1 christos 0xDC, 0x17, 0xD0, 0x07, 0xE6, 0x91, 0x86, 0x9B,
1649 1.1 christos 0xD5, 0x9C, 0x5F, 0x23, 0x7D, 0x9B, 0xF8, 0x54,
1650 1.1 christos 0x34, 0xC3, 0x13),
1651 1.1 christos /*
1652 1.1 christos * Valid, 32-octet SHA-256 digest.
1653 1.1 christos */
1654 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x02, 0xD0, 0x01, 0xBD, 0x42, 0x2F,
1655 1.1 christos 0xFD, 0xA9, 0xB7, 0x45, 0x42, 0x5B, 0x71, 0xDC, 0x17,
1656 1.1 christos 0xD0, 0x07, 0xE6, 0x91, 0x86, 0x9B, 0xD5, 0x9C, 0x5F,
1657 1.1 christos 0x23, 0x7D, 0x9B, 0xF8, 0x54, 0x34, 0xC3, 0x13,
1658 1.1 christos 0x3F),
1659 1.1 christos /*
1660 1.1 christos * Invalid, excessively long SHA-256 digest.
1661 1.1 christos */
1662 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x02, 0xD0, 0x01, 0xBD, 0x42,
1663 1.1 christos 0x2F, 0xFD, 0xA9, 0xB7, 0x45, 0x42, 0x5B, 0x71,
1664 1.1 christos 0xDC, 0x17, 0xD0, 0x07, 0xE6, 0x91, 0x86, 0x9B,
1665 1.1 christos 0xD5, 0x9C, 0x5F, 0x23, 0x7D, 0x9B, 0xF8, 0x54,
1666 1.1 christos 0x34, 0xC3, 0x13, 0x3F, 0x00),
1667 1.1 christos /*
1668 1.1 christos * Valid, GOST is no longer supported, hence no length checks.
1669 1.1 christos */
1670 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x03, 0x00),
1671 1.1 christos /*
1672 1.1 christos * Invalid, short SHA-384 digest.
1673 1.1 christos */
1674 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x04, 0x00),
1675 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x04, 0xAC, 0x74, 0x8D, 0x6C,
1676 1.1 christos 0x5A, 0xA6, 0x52, 0x90, 0x4A, 0x87, 0x63, 0xD6,
1677 1.1 christos 0x4B, 0x7D, 0xFF, 0xFF, 0xA9, 0x81, 0x52, 0xBE,
1678 1.1 christos 0x12, 0x12, 0x8D, 0x23, 0x8B, 0xEB, 0xB4, 0x81,
1679 1.1 christos 0x4B, 0x64, 0x8F, 0x5A, 0x84, 0x1E, 0x15, 0xCA,
1680 1.1 christos 0xA2, 0xDE, 0x34, 0x88, 0x91, 0xA3, 0x7A, 0x69,
1681 1.1 christos 0x9F, 0x65, 0xE5),
1682 1.1 christos /*
1683 1.1 christos * Valid, 48-octet SHA-384 digest.
1684 1.1 christos */
1685 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x04, 0xAC, 0x74, 0x8D, 0x6C, 0x5A,
1686 1.1 christos 0xA6, 0x52, 0x90, 0x4A, 0x87, 0x63, 0xD6, 0x4B, 0x7D,
1687 1.1 christos 0xFF, 0xFF, 0xA9, 0x81, 0x52, 0xBE, 0x12, 0x12, 0x8D,
1688 1.1 christos 0x23, 0x8B, 0xEB, 0xB4, 0x81, 0x4B, 0x64, 0x8F, 0x5A,
1689 1.1 christos 0x84, 0x1E, 0x15, 0xCA, 0xA2, 0xDE, 0x34, 0x88, 0x91,
1690 1.1 christos 0xA3, 0x7A, 0x69, 0x9F, 0x65, 0xE5, 0x4D),
1691 1.1 christos /*
1692 1.1 christos * Invalid, excessively long SHA-384 digest.
1693 1.1 christos */
1694 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x04, 0xAC, 0x74, 0x8D, 0x6C,
1695 1.1 christos 0x5A, 0xA6, 0x52, 0x90, 0x4A, 0x87, 0x63, 0xD6,
1696 1.1 christos 0x4B, 0x7D, 0xFF, 0xFF, 0xA9, 0x81, 0x52, 0xBE,
1697 1.1 christos 0x12, 0x12, 0x8D, 0x23, 0x8B, 0xEB, 0xB4, 0x81,
1698 1.1 christos 0x4B, 0x64, 0x8F, 0x5A, 0x84, 0x1E, 0x15, 0xCA,
1699 1.1 christos 0xA2, 0xDE, 0x34, 0x88, 0x91, 0xA3, 0x7A, 0x69,
1700 1.1 christos 0x9F, 0x65, 0xE5, 0x4D, 0x00),
1701 1.1 christos WIRE_VALID(0x00, 0x00, 0x04, 0x00, 0x00),
1702 1.1 christos /*
1703 1.1 christos * Sentinel.
1704 1.1 christos */
1705 1.1 christos WIRE_SENTINEL()
1706 1.1 christos };
1707 1.1 christos
1708 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
1709 1.1 christos dns_rdatatype_ds, sizeof(dns_rdata_ds_t));
1710 1.1 christos }
1711 1.1 christos
1712 1.1 christos /*
1713 1.1 christos * EDNS Client Subnet tests.
1714 1.1 christos *
1715 1.1 christos * RFC 7871:
1716 1.1 christos *
1717 1.1 christos * 6. Option Format
1718 1.1 christos *
1719 1.1 christos * This protocol uses an EDNS0 [RFC6891] option to include client
1720 1.1 christos * address information in DNS messages. The option is structured as
1721 1.1 christos * follows:
1722 1.1 christos *
1723 1.1 christos * +0 (MSB) +1 (LSB)
1724 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1725 1.1 christos * 0: | OPTION-CODE |
1726 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1727 1.1 christos * 2: | OPTION-LENGTH |
1728 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1729 1.1 christos * 4: | FAMILY |
1730 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1731 1.1 christos * 6: | SOURCE PREFIX-LENGTH | SCOPE PREFIX-LENGTH |
1732 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1733 1.1 christos * 8: | ADDRESS... /
1734 1.1 christos * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1735 1.1 christos *
1736 1.1 christos * o (Defined in [RFC6891]) OPTION-CODE, 2 octets, for ECS is 8 (0x00
1737 1.1 christos * 0x08).
1738 1.1 christos *
1739 1.1 christos * o (Defined in [RFC6891]) OPTION-LENGTH, 2 octets, contains the
1740 1.1 christos * length of the payload (everything after OPTION-LENGTH) in octets.
1741 1.1 christos *
1742 1.1 christos * o FAMILY, 2 octets, indicates the family of the address contained in
1743 1.1 christos * the option, using address family codes as assigned by IANA in
1744 1.1 christos * Address Family Numbers [Address_Family_Numbers].
1745 1.1 christos *
1746 1.1 christos * The format of the address part depends on the value of FAMILY. This
1747 1.1 christos * document only defines the format for FAMILY 1 (IPv4) and FAMILY 2
1748 1.1 christos * (IPv6), which are as follows:
1749 1.1 christos *
1750 1.1 christos * o SOURCE PREFIX-LENGTH, an unsigned octet representing the leftmost
1751 1.1 christos * number of significant bits of ADDRESS to be used for the lookup.
1752 1.1 christos * In responses, it mirrors the same value as in the queries.
1753 1.1 christos *
1754 1.1 christos * o SCOPE PREFIX-LENGTH, an unsigned octet representing the leftmost
1755 1.1 christos * number of significant bits of ADDRESS that the response covers.
1756 1.1 christos * In queries, it MUST be set to 0.
1757 1.1 christos *
1758 1.1 christos * o ADDRESS, variable number of octets, contains either an IPv4 or
1759 1.1 christos * IPv6 address, depending on FAMILY, which MUST be truncated to the
1760 1.1 christos * number of bits indicated by the SOURCE PREFIX-LENGTH field,
1761 1.1 christos * padding with 0 bits to pad to the end of the last octet needed.
1762 1.1 christos *
1763 1.1 christos * o A server receiving an ECS option that uses either too few or too
1764 1.1 christos * many ADDRESS octets, or that has non-zero ADDRESS bits set beyond
1765 1.1 christos * SOURCE PREFIX-LENGTH, SHOULD return FORMERR to reject the packet,
1766 1.1 christos * as a signal to the software developer making the request to fix
1767 1.1 christos * their implementation.
1768 1.1 christos *
1769 1.1 christos * All fields are in network byte order ("big-endian", per [RFC1700],
1770 1.1 christos * Data Notation).
1771 1.1 christos */
1772 1.1 christos ISC_RUN_TEST_IMPL(edns_client_subnet) {
1773 1.1 christos wire_ok_t wire_ok[] = {
1774 1.1 christos /*
1775 1.1 christos * Option code with no content.
1776 1.1 christos */
1777 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 0x00),
1778 1.1 christos /*
1779 1.1 christos * Option code family 0, source 0, scope 0.
1780 1.1 christos */
1781 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00),
1782 1.1 christos /*
1783 1.1 christos * Option code family 1 (IPv4), source 0, scope 0.
1784 1.1 christos */
1785 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00),
1786 1.1 christos /*
1787 1.1 christos * Option code family 2 (IPv6) , source 0, scope 0.
1788 1.1 christos */
1789 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00),
1790 1.1 christos /*
1791 1.1 christos * Extra octet.
1792 1.1 christos */
1793 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
1794 1.1 christos 0x00),
1795 1.1 christos /*
1796 1.1 christos * Source too long for IPv4.
1797 1.1 christos */
1798 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 8, 0x00, 0x01, 33, 0x00, 0x00,
1799 1.1 christos 0x00, 0x00, 0x00),
1800 1.1 christos /*
1801 1.1 christos * Source too long for IPv6.
1802 1.1 christos */
1803 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 20, 0x00, 0x02, 129, 0x00, 0x00,
1804 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1805 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
1806 1.1 christos /*
1807 1.1 christos * Scope too long for IPv4.
1808 1.1 christos */
1809 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 8, 0x00, 0x01, 0x00, 33, 0x00,
1810 1.1 christos 0x00, 0x00, 0x00),
1811 1.1 christos /*
1812 1.1 christos * Scope too long for IPv6.
1813 1.1 christos */
1814 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 20, 0x00, 0x02, 0x00, 129, 0x00,
1815 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1816 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
1817 1.1 christos /*
1818 1.1 christos * When family=0, source and scope should be 0.
1819 1.1 christos */
1820 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 4, 0x00, 0x00, 0x00, 0x00),
1821 1.1 christos /*
1822 1.1 christos * When family=0, source and scope should be 0.
1823 1.1 christos */
1824 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 5, 0x00, 0x00, 0x01, 0x00, 0x00),
1825 1.1 christos /*
1826 1.1 christos * When family=0, source and scope should be 0.
1827 1.1 christos */
1828 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 5, 0x00, 0x00, 0x00, 0x01, 0x00),
1829 1.1 christos /*
1830 1.1 christos * Length too short for source IPv4.
1831 1.1 christos */
1832 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 7, 0x00, 0x01, 32, 0x00, 0x00,
1833 1.1 christos 0x00, 0x00),
1834 1.1 christos /*
1835 1.1 christos * Length too short for source IPv6.
1836 1.1 christos */
1837 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 19, 0x00, 0x02, 128, 0x00, 0x00,
1838 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1839 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
1840 1.1 christos /*
1841 1.1 christos * Sentinel.
1842 1.1 christos */
1843 1.1 christos WIRE_SENTINEL()
1844 1.1 christos };
1845 1.1 christos
1846 1.1 christos check_rdata(NULL, wire_ok, NULL, true, dns_rdataclass_in,
1847 1.1 christos dns_rdatatype_opt, sizeof(dns_rdata_opt_t));
1848 1.1 christos }
1849 1.1 christos
1850 1.1 christos /*
1851 1.1 christos * http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
1852 1.1 christos *
1853 1.1 christos * The RDATA portion of both the NIMLOC and EID records contains
1854 1.1 christos * uninterpreted binary data. The representation in the text master file
1855 1.1 christos * is an even number of hex characters (0 to 9, a to f), case is not
1856 1.1 christos * significant. For readability, whitespace may be included in the value
1857 1.1 christos * field and should be ignored when reading a master file.
1858 1.1 christos */
1859 1.1 christos ISC_RUN_TEST_IMPL(eid) {
1860 1.1 christos text_ok_t text_ok[] = { TEXT_VALID("AABBCC"),
1861 1.1 christos TEXT_VALID_CHANGED("AA bb cc", "AABBCC"),
1862 1.1 christos TEXT_INVALID("aab"),
1863 1.1 christos /*
1864 1.1 christos * Sentinel.
1865 1.1 christos */
1866 1.1 christos TEXT_SENTINEL() };
1867 1.1 christos wire_ok_t wire_ok[] = { WIRE_VALID(0x00), WIRE_VALID(0xAA, 0xBB, 0xCC),
1868 1.1 christos /*
1869 1.1 christos * Sentinel.
1870 1.1 christos */
1871 1.1 christos WIRE_SENTINEL() };
1872 1.1 christos
1873 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
1874 1.1 christos dns_rdatatype_eid, sizeof(dns_rdata_in_eid_t));
1875 1.1 christos }
1876 1.1 christos
1877 1.1 christos /*
1878 1.1 christos * test that an oversized HIP record will be rejected
1879 1.1 christos */
1880 1.1 christos ISC_RUN_TEST_IMPL(hip) {
1881 1.1 christos text_ok_t text_ok[] = {
1882 1.1 christos /* RFC 8005 examples. */
1883 1.1 christos TEXT_VALID_LOOP(0, "2 200100107B1A74DF365639CC39F1D578 "
1884 1.1 christos "AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cI"
1885 1.1 christos "vM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbW"
1886 1.1 christos "Iy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+b"
1887 1.1 christos "SRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWx"
1888 1.1 christos "Z48AWkskmdHaVDP4BcelrTI3rMXdXF5D"),
1889 1.1 christos TEXT_VALID_LOOP(1, "2 200100107B1A74DF365639CC39F1D578 "
1890 1.1 christos "AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cI"
1891 1.1 christos "vM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbW"
1892 1.1 christos "Iy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+b"
1893 1.1 christos "SRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWx"
1894 1.1 christos "Z48AWkskmdHaVDP4BcelrTI3rMXdXF5D "
1895 1.1 christos "rvs1.example.com."),
1896 1.1 christos TEXT_VALID_LOOP(2, "2 200100107B1A74DF365639CC39F1D578 "
1897 1.1 christos "AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cI"
1898 1.1 christos "vM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbW"
1899 1.1 christos "Iy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+b"
1900 1.1 christos "SRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWx"
1901 1.1 christos "Z48AWkskmdHaVDP4BcelrTI3rMXdXF5D "
1902 1.1 christos "rvs1.example.com. rvs2.example.com."),
1903 1.1 christos /*
1904 1.1 christos * Sentinel.
1905 1.1 christos */
1906 1.1 christos TEXT_SENTINEL()
1907 1.1 christos };
1908 1.1 christos unsigned char hipwire[DNS_RDATA_MAXLENGTH] = { 0x01, 0x00, 0x00, 0x01,
1909 1.1 christos 0x00, 0x00, 0x04, 0x41,
1910 1.1 christos 0x42, 0x43, 0x44, 0x00 };
1911 1.1 christos unsigned char buf[1024 * 1024];
1912 1.1 christos dns_rdata_t rdata = DNS_RDATA_INIT;
1913 1.1 christos isc_result_t result;
1914 1.1 christos size_t i;
1915 1.1 christos
1916 1.1 christos /*
1917 1.1 christos * Fill the rest of input buffer with compression pointers.
1918 1.1 christos */
1919 1.1 christos for (i = 12; i < sizeof(hipwire) - 2; i += 2) {
1920 1.1 christos hipwire[i] = 0xc0;
1921 1.1 christos hipwire[i + 1] = 0x06;
1922 1.1 christos }
1923 1.1 christos
1924 1.1 christos result = wire_to_rdata(hipwire, sizeof(hipwire), dns_rdataclass_in,
1925 1.1 christos dns_rdatatype_hip, buf, sizeof(buf), &rdata);
1926 1.1 christos assert_int_equal(result, DNS_R_FORMERR);
1927 1.1 christos check_text_ok(text_ok, dns_rdataclass_in, dns_rdatatype_hip,
1928 1.1 christos sizeof(dns_rdata_hip_t));
1929 1.1 christos }
1930 1.1 christos
1931 1.1 christos /*
1932 1.1 christos * ISDN tests.
1933 1.1 christos *
1934 1.1 christos * RFC 1183:
1935 1.1 christos *
1936 1.1 christos * 3.2. The ISDN RR
1937 1.1 christos *
1938 1.1 christos * The ISDN RR is defined with mnemonic ISDN and type code 20 (decimal).
1939 1.1 christos *
1940 1.1 christos * An ISDN (Integrated Service Digital Network) number is simply a
1941 1.1 christos * telephone number. The intent of the members of the CCITT is to
1942 1.1 christos * upgrade all telephone and data network service to a common service.
1943 1.1 christos *
1944 1.1 christos * The numbering plan (E.163/E.164) is the same as the familiar
1945 1.1 christos * international plan for POTS (an un-official acronym, meaning Plain
1946 1.1 christos * Old Telephone Service). In E.166, CCITT says "An E.163/E.164
1947 1.1 christos * telephony subscriber may become an ISDN subscriber without a number
1948 1.1 christos * change."
1949 1.1 christos *
1950 1.1 christos * ISDN has the following format:
1951 1.1 christos *
1952 1.1 christos * <owner> <ttl> <class> ISDN <ISDN-address> <sa>
1953 1.1 christos *
1954 1.1 christos * The <ISDN-address> field is required; <sa> is optional.
1955 1.1 christos *
1956 1.1 christos * <ISDN-address> identifies the ISDN number of <owner> and DDI (Direct
1957 1.1 christos * Dial In) if any, as defined by E.164 [8] and E.163 [7], the ISDN and
1958 1.1 christos * PSTN (Public Switched Telephone Network) numbering plan. E.163
1959 1.1 christos * defines the country codes, and E.164 the form of the addresses. Its
1960 1.1 christos * format in master files is a <character-string> syntactically
1961 1.1 christos * identical to that used in TXT and HINFO.
1962 1.1 christos *
1963 1.1 christos * <sa> specifies the subaddress (SA). The format of <sa> in master
1964 1.1 christos * files is a <character-string> syntactically identical to that used in
1965 1.1 christos * TXT and HINFO.
1966 1.1 christos *
1967 1.1 christos * The format of ISDN is class insensitive. ISDN RRs cause no
1968 1.1 christos * additional section processing.
1969 1.1 christos *
1970 1.1 christos * The <ISDN-address> is a string of characters, normally decimal
1971 1.1 christos * digits, beginning with the E.163 country code and ending with the DDI
1972 1.1 christos * if any. Note that ISDN, in Q.931, permits any IA5 character in the
1973 1.1 christos * general case.
1974 1.1 christos *
1975 1.1 christos * The <sa> is a string of hexadecimal digits. For digits 0-9, the
1976 1.1 christos * concrete encoding in the Q.931 call setup information element is
1977 1.1 christos * identical to BCD.
1978 1.1 christos *
1979 1.1 christos * For example:
1980 1.1 christos *
1981 1.1 christos * Relay.Prime.COM. IN ISDN 150862028003217
1982 1.1 christos * sh.Prime.COM. IN ISDN 150862028003217 004
1983 1.1 christos *
1984 1.1 christos * (Note: "1" is the country code for the North American Integrated
1985 1.1 christos * Numbering Area, i.e., the system of "area codes" familiar to people
1986 1.1 christos * in those countries.)
1987 1.1 christos *
1988 1.1 christos * The RR data is the ASCII representation of the digits. It is encoded
1989 1.1 christos * as one or two <character-string>s, i.e., count followed by
1990 1.1 christos * characters.
1991 1.1 christos */
1992 1.1 christos ISC_RUN_TEST_IMPL(isdn) {
1993 1.1 christos wire_ok_t wire_ok[] = { /*
1994 1.1 christos * "".
1995 1.1 christos */
1996 1.1 christos WIRE_VALID(0x00),
1997 1.1 christos /*
1998 1.1 christos * "\001".
1999 1.1 christos */
2000 1.1 christos WIRE_VALID(0x01, 0x01),
2001 1.1 christos /*
2002 1.1 christos * "\001" "".
2003 1.1 christos */
2004 1.1 christos WIRE_VALID(0x01, 0x01, 0x00),
2005 1.1 christos /*
2006 1.1 christos * "\001" "\001".
2007 1.1 christos */
2008 1.1 christos WIRE_VALID(0x01, 0x01, 0x01, 0x01),
2009 1.1 christos /*
2010 1.1 christos * Sentinel.
2011 1.1 christos */
2012 1.1 christos WIRE_SENTINEL()
2013 1.1 christos };
2014 1.1 christos
2015 1.1 christos check_rdata(NULL, wire_ok, NULL, false, dns_rdataclass_in,
2016 1.1 christos dns_rdatatype_isdn, sizeof(dns_rdata_isdn_t));
2017 1.1 christos }
2018 1.1 christos
2019 1.1 christos /*
2020 1.1 christos * KEY tests.
2021 1.1 christos */
2022 1.1 christos ISC_RUN_TEST_IMPL(key) {
2023 1.4 christos wire_ok_t wire_ok[] = {
2024 1.4 christos /*
2025 1.4 christos * RDATA is comprised of:
2026 1.4 christos *
2027 1.4 christos * - 2 octets for Flags,
2028 1.4 christos * - 1 octet for Protocol,
2029 1.4 christos * - 1 octet for Algorithm,
2030 1.4 christos * - variable number of octets for Public Key.
2031 1.4 christos *
2032 1.4 christos * RFC 2535 section 3.1.2 states that if bits
2033 1.4 christos * 0-1 of Flags are both set, the RR stops after
2034 1.4 christos * the algorithm octet and thus its length must
2035 1.4 christos * be 4 octets. In any other case, though, the
2036 1.4 christos * Public Key part must not be empty.
2037 1.4 christos *
2038 1.4 christos * Algorithms PRIVATEDNS (253) and PRIVATEOID (254)
2039 1.4 christos * have an algorithm identifier embedded and the start
2040 1.4 christos * of the public key.
2041 1.4 christos */
2042 1.4 christos WIRE_INVALID(0x00), WIRE_INVALID(0x00, 0x00),
2043 1.4 christos WIRE_INVALID(0x00, 0x00, 0x00),
2044 1.4 christos WIRE_VALID(0xc0, 0x00, 0x00, 0x00),
2045 1.4 christos WIRE_INVALID(0xc0, 0x00, 0x00, 0x00, 0x00),
2046 1.4 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00),
2047 1.4 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00),
2048 1.5 christos /* PRIVATEDNS example. without key data */
2049 1.5 christos WIRE_VALID(0x00, 0x00, 0x00, 253, 0x07, 'e', 'x', 'a', 'm', 'p',
2050 1.5 christos 'l', 'e', 0x00),
2051 1.4 christos /* PRIVATEDNS example. + keydata */
2052 1.4 christos WIRE_VALID(0x00, 0x00, 0x00, 253, 0x07, 'e', 'x', 'a', 'm', 'p',
2053 1.4 christos 'l', 'e', 0x00, 0x00),
2054 1.4 christos /* PRIVATEDNS compression pointer. */
2055 1.4 christos WIRE_INVALID(0x00, 0x00, 0x00, 253, 0xc0, 0x00, 0x00),
2056 1.4 christos /* PRIVATEOID */
2057 1.4 christos WIRE_INVALID(0x00, 0x00, 0x00, 254, 0x00),
2058 1.5 christos /* PRIVATEOID 1.3.6.1.4.1.2495 without key data */
2059 1.5 christos WIRE_VALID(0x00, 0x00, 0x00, 254, 0x09, 0x06, 0x07, 0x2b, 0x06,
2060 1.5 christos 0x01, 0x04, 0x01, 0x93, 0x3f),
2061 1.4 christos /* PRIVATEOID 1.3.6.1.4.1.2495 + keydata */
2062 1.5 christos WIRE_VALID(0x00, 0x00, 0x00, 254, 0x09, 0x06, 0x07, 0x2b, 0x06,
2063 1.5 christos 0x01, 0x04, 0x01, 0x93, 0x3f, 0x00),
2064 1.4 christos /* PRIVATEOID malformed OID - high-bit set on last octet */
2065 1.4 christos WIRE_INVALID(0x00, 0x00, 0x00, 254, 0x06, 0x07, 0x2b, 0x06,
2066 1.4 christos 0x01, 0x04, 0x01, 0x93, 0xbf, 0x00),
2067 1.4 christos /* PRIVATEOID malformed OID - wrong tag */
2068 1.5 christos WIRE_INVALID(0x00, 0x00, 0x00, 254, 0x09, 0x07, 0x07, 0x2b,
2069 1.5 christos 0x06, 0x01, 0x04, 0x01, 0x93, 0x3f, 0x00),
2070 1.4 christos WIRE_SENTINEL()
2071 1.4 christos };
2072 1.4 christos text_ok_t text_ok[] = { /* PRIVATEDNS example. */
2073 1.5 christos TEXT_VALID("0 0 253 B2V4YW1wbGUA"),
2074 1.4 christos /* PRIVATEDNS example. + keydata */
2075 1.4 christos TEXT_VALID("0 0 253 B2V4YW1wbGUAAA=="),
2076 1.4 christos /* PRIVATEDNS compression pointer. */
2077 1.4 christos TEXT_INVALID("0 0 253 wAAA"),
2078 1.4 christos /* PRIVATEOID */
2079 1.4 christos TEXT_INVALID("0 0 254 AA=="),
2080 1.4 christos /* PRIVATEOID 1.3.6.1.4.1.2495 */
2081 1.5 christos TEXT_VALID("0 0 254 CQYHKwYBBAGTPw=="),
2082 1.4 christos /* PRIVATEOID 1.3.6.1.4.1.2495 + keydata */
2083 1.5 christos TEXT_VALID("0 0 254 CQYHKwYBBAGTPwA="),
2084 1.4 christos /* PRIVATEOID malformed OID - high-bit set on
2085 1.4 christos last octet */
2086 1.5 christos TEXT_INVALID("0 0 254 CQYHKwYBBAGTvwA="),
2087 1.4 christos /* PRIVATEOID malformed OID - wrong tag */
2088 1.5 christos TEXT_INVALID("0 0 254 CQcHKwYBBAGTPwA="),
2089 1.4 christos /*
2090 1.4 christos * Sentinel.
2091 1.1 christos */
2092 1.4 christos TEXT_SENTINEL()
2093 1.1 christos };
2094 1.1 christos
2095 1.4 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2096 1.1 christos dns_rdatatype_key, sizeof(dns_rdata_key_t));
2097 1.1 christos }
2098 1.1 christos
2099 1.1 christos /*
2100 1.1 christos * LOC tests.
2101 1.1 christos */
2102 1.1 christos ISC_RUN_TEST_IMPL(loc) {
2103 1.1 christos text_ok_t text_ok[] = {
2104 1.1 christos TEXT_VALID_CHANGED("0 N 0 E 0", "0 0 0.000 N 0 0 0.000 E 0.00m "
2105 1.1 christos "1m 10000m 10m"),
2106 1.1 christos TEXT_VALID_CHANGED("0 S 0 W 0", "0 0 0.000 N 0 0 0.000 E 0.00m "
2107 1.1 christos "1m 10000m 10m"),
2108 1.1 christos TEXT_VALID_CHANGED("0 0 N 0 0 E 0", "0 0 0.000 N 0 0 0.000 E "
2109 1.1 christos "0.00m 1m 10000m 10m"),
2110 1.1 christos TEXT_VALID_CHANGED("0 0 0 N 0 0 0 E 0",
2111 1.1 christos "0 0 0.000 N 0 0 0.000 E 0.00m 1m 10000m "
2112 1.1 christos "10m"),
2113 1.1 christos TEXT_VALID_CHANGED("0 0 0 N 0 0 0 E 0",
2114 1.1 christos "0 0 0.000 N 0 0 0.000 E 0.00m 1m 10000m "
2115 1.1 christos "10m"),
2116 1.1 christos TEXT_VALID_CHANGED("0 0 0. N 0 0 0. E 0",
2117 1.1 christos "0 0 0.000 N 0 0 0.000 E 0.00m 1m 10000m "
2118 1.1 christos "10m"),
2119 1.1 christos TEXT_VALID_CHANGED("0 0 .0 N 0 0 .0 E 0",
2120 1.1 christos "0 0 0.000 N 0 0 0.000 E 0.00m 1m 10000m "
2121 1.1 christos "10m"),
2122 1.1 christos TEXT_INVALID("0 North 0 East 0"),
2123 1.1 christos TEXT_INVALID("0 South 0 West 0"),
2124 1.1 christos TEXT_INVALID("0 0 . N 0 0 0. E 0"),
2125 1.1 christos TEXT_INVALID("0 0 0. N 0 0 . E 0"),
2126 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E m"),
2127 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E 0 ."),
2128 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E 0 m"),
2129 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E 0 0 ."),
2130 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E 0 0 m"),
2131 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E 0 0 0 ."),
2132 1.1 christos TEXT_INVALID("0 0 0. N 0 0 0. E 0 0 0 m"),
2133 1.1 christos TEXT_VALID_CHANGED("90 N 180 E 0", "90 0 0.000 N 180 0 0.000 E "
2134 1.1 christos "0.00m 1m 10000m 10m"),
2135 1.1 christos TEXT_INVALID("90 1 N 180 E 0"),
2136 1.1 christos TEXT_INVALID("90 0 1 N 180 E 0"),
2137 1.1 christos TEXT_INVALID("90 N 180 1 E 0"),
2138 1.1 christos TEXT_INVALID("90 N 180 0 1 E 0"),
2139 1.1 christos TEXT_VALID_CHANGED("90 S 180 W 0", "90 0 0.000 S 180 0 0.000 W "
2140 1.1 christos "0.00m 1m 10000m 10m"),
2141 1.1 christos TEXT_INVALID("90 1 S 180 W 0"),
2142 1.1 christos TEXT_INVALID("90 0 1 S 180 W 0"),
2143 1.1 christos TEXT_INVALID("90 S 180 1 W 0"),
2144 1.1 christos TEXT_INVALID("90 S 180 0 1 W 0"),
2145 1.1 christos TEXT_INVALID("0 0 0.000 E 0 0 0.000 E -0.95m 1m 10000m 10m"),
2146 1.1 christos TEXT_VALID("0 0 0.000 N 0 0 0.000 E -0.95m 1m 10000m 10m"),
2147 1.1 christos TEXT_VALID("0 0 0.000 N 0 0 0.000 E -0.05m 1m 10000m 10m"),
2148 1.1 christos TEXT_VALID("0 0 0.000 N 0 0 0.000 E -100000.00m 1m 10000m 10m"),
2149 1.1 christos TEXT_VALID("0 0 0.000 N 0 0 0.000 E 42849672.95m 1m 10000m "
2150 1.1 christos "10m"),
2151 1.1 christos /*
2152 1.1 christos * Sentinel.
2153 1.1 christos */
2154 1.1 christos TEXT_SENTINEL()
2155 1.1 christos };
2156 1.1 christos
2157 1.1 christos check_rdata(text_ok, 0, NULL, false, dns_rdataclass_in,
2158 1.1 christos dns_rdatatype_loc, sizeof(dns_rdata_loc_t));
2159 1.1 christos }
2160 1.1 christos
2161 1.1 christos /*
2162 1.1 christos * http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
2163 1.1 christos *
2164 1.1 christos * The RDATA portion of both the NIMLOC and EID records contains
2165 1.1 christos * uninterpreted binary data. The representation in the text master file
2166 1.1 christos * is an even number of hex characters (0 to 9, a to f), case is not
2167 1.1 christos * significant. For readability, whitespace may be included in the value
2168 1.1 christos * field and should be ignored when reading a master file.
2169 1.1 christos */
2170 1.1 christos ISC_RUN_TEST_IMPL(nimloc) {
2171 1.1 christos text_ok_t text_ok[] = { TEXT_VALID("AABBCC"),
2172 1.1 christos TEXT_VALID_CHANGED("AA bb cc", "AABBCC"),
2173 1.1 christos TEXT_INVALID("aab"),
2174 1.1 christos /*
2175 1.1 christos * Sentinel.
2176 1.1 christos */
2177 1.1 christos TEXT_SENTINEL() };
2178 1.1 christos wire_ok_t wire_ok[] = { WIRE_VALID(0x00), WIRE_VALID(0xAA, 0xBB, 0xCC),
2179 1.1 christos /*
2180 1.1 christos * Sentinel.
2181 1.1 christos */
2182 1.1 christos WIRE_SENTINEL() };
2183 1.1 christos
2184 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2185 1.1 christos dns_rdatatype_nimloc, sizeof(dns_rdata_in_nimloc_t));
2186 1.1 christos }
2187 1.1 christos
2188 1.1 christos /*
2189 1.1 christos * NSEC tests.
2190 1.1 christos *
2191 1.1 christos * RFC 4034:
2192 1.1 christos *
2193 1.1 christos * 4.1. NSEC RDATA Wire Format
2194 1.1 christos *
2195 1.1 christos * The RDATA of the NSEC RR is as shown below:
2196 1.1 christos *
2197 1.1 christos * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
2198 1.1 christos * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2199 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2200 1.1 christos * / Next Domain Name /
2201 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2202 1.1 christos * / Type Bit Maps /
2203 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2204 1.1 christos *
2205 1.1 christos * 4.1.1. The Next Domain Name Field
2206 1.1 christos *
2207 1.1 christos * The Next Domain field contains the next owner name (in the canonical
2208 1.1 christos * ordering of the zone) that has authoritative data or contains a
2209 1.1 christos * delegation point NS RRset; see Section 6.1 for an explanation of
2210 1.1 christos * canonical ordering. The value of the Next Domain Name field in the
2211 1.1 christos * last NSEC record in the zone is the name of the zone apex (the owner
2212 1.1 christos * name of the zone's SOA RR). This indicates that the owner name of
2213 1.1 christos * the NSEC RR is the last name in the canonical ordering of the zone.
2214 1.1 christos *
2215 1.1 christos * A sender MUST NOT use DNS name compression on the Next Domain Name
2216 1.1 christos * field when transmitting an NSEC RR.
2217 1.1 christos *
2218 1.1 christos * Owner names of RRsets for which the given zone is not authoritative
2219 1.1 christos * (such as glue records) MUST NOT be listed in the Next Domain Name
2220 1.1 christos * unless at least one authoritative RRset exists at the same owner
2221 1.1 christos * name.
2222 1.1 christos *
2223 1.1 christos * 4.1.2. The Type Bit Maps Field
2224 1.1 christos *
2225 1.1 christos * The Type Bit Maps field identifies the RRset types that exist at the
2226 1.1 christos * NSEC RR's owner name.
2227 1.1 christos *
2228 1.1 christos * The RR type space is split into 256 window blocks, each representing
2229 1.1 christos * the low-order 8 bits of the 16-bit RR type space. Each block that
2230 1.1 christos * has at least one active RR type is encoded using a single octet
2231 1.1 christos * window number (from 0 to 255), a single octet bitmap length (from 1
2232 1.1 christos * to 32) indicating the number of octets used for the window block's
2233 1.1 christos * bitmap, and up to 32 octets (256 bits) of bitmap.
2234 1.1 christos *
2235 1.1 christos * Blocks are present in the NSEC RR RDATA in increasing numerical
2236 1.1 christos * order.
2237 1.1 christos *
2238 1.1 christos * Type Bit Maps Field = ( Window Block # | Bitmap Length | Bitmap )+
2239 1.1 christos *
2240 1.1 christos * where "|" denotes concatenation.
2241 1.1 christos *
2242 1.1 christos * Each bitmap encodes the low-order 8 bits of RR types within the
2243 1.1 christos * window block, in network bit order. The first bit is bit 0. For
2244 1.1 christos * window block 0, bit 1 corresponds to RR type 1 (A), bit 2 corresponds
2245 1.1 christos * to RR type 2 (NS), and so forth. For window block 1, bit 1
2246 1.1 christos * corresponds to RR type 257, and bit 2 to RR type 258. If a bit is
2247 1.1 christos * set, it indicates that an RRset of that type is present for the NSEC
2248 1.1 christos * RR's owner name. If a bit is clear, it indicates that no RRset of
2249 1.1 christos * that type is present for the NSEC RR's owner name.
2250 1.1 christos *
2251 1.1 christos * Bits representing pseudo-types MUST be clear, as they do not appear
2252 1.1 christos * in zone data. If encountered, they MUST be ignored upon being read.
2253 1.1 christos */
2254 1.1 christos ISC_RUN_TEST_IMPL(nsec) {
2255 1.1 christos text_ok_t text_ok[] = { TEXT_INVALID(""), TEXT_INVALID("."),
2256 1.1 christos TEXT_VALID(". RRSIG"), TEXT_SENTINEL() };
2257 1.1 christos wire_ok_t wire_ok[] = { WIRE_INVALID(0x00), WIRE_INVALID(0x00, 0x00),
2258 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00),
2259 1.1 christos WIRE_VALID(0x00, 0x00, 0x01, 0x02),
2260 1.1 christos WIRE_SENTINEL() };
2261 1.1 christos
2262 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2263 1.1 christos dns_rdatatype_nsec, sizeof(dns_rdata_nsec_t));
2264 1.1 christos }
2265 1.1 christos
2266 1.1 christos /*
2267 1.1 christos * NSEC3 tests.
2268 1.1 christos *
2269 1.1 christos * RFC 5155.
2270 1.1 christos */
2271 1.1 christos ISC_RUN_TEST_IMPL(nsec3) {
2272 1.1 christos text_ok_t text_ok[] = { TEXT_INVALID(""),
2273 1.1 christos TEXT_INVALID("."),
2274 1.1 christos TEXT_INVALID(". RRSIG"),
2275 1.1 christos TEXT_INVALID("1 0 10 76931F"),
2276 1.1 christos TEXT_INVALID("1 0 10 76931F "
2277 1.1 christos "IMQ912BREQP1POLAH3RMONG&"
2278 1.1 christos "UED541AS"),
2279 1.1 christos TEXT_INVALID("1 0 10 76931F "
2280 1.1 christos "IMQ912BREQP1POLAH3RMONGAUED541AS "
2281 1.1 christos "A RRSIG BADTYPE"),
2282 1.1 christos TEXT_VALID("1 0 10 76931F "
2283 1.1 christos "AJHVGTICN6K0VDA53GCHFMT219SRRQLM A "
2284 1.1 christos "RRSIG"),
2285 1.1 christos TEXT_VALID("1 0 10 76931F "
2286 1.1 christos "AJHVGTICN6K0VDA53GCHFMT219SRRQLM"),
2287 1.1 christos TEXT_VALID("1 0 10 - "
2288 1.1 christos "AJHVGTICN6K0VDA53GCHFMT219SRRQLM"),
2289 1.1 christos TEXT_SENTINEL() };
2290 1.1 christos
2291 1.1 christos check_rdata(text_ok, NULL, NULL, false, dns_rdataclass_in,
2292 1.1 christos dns_rdatatype_nsec3, sizeof(dns_rdata_nsec3_t));
2293 1.1 christos }
2294 1.1 christos
2295 1.1 christos /* NXT RDATA manipulations */
2296 1.1 christos ISC_RUN_TEST_IMPL(nxt) {
2297 1.1 christos compare_ok_t compare_ok[] = {
2298 1.1 christos COMPARE("a. A SIG", "a. A SIG", 0),
2299 1.1 christos /*
2300 1.1 christos * Records that differ only in the case of the next
2301 1.1 christos * name should be equal.
2302 1.1 christos */
2303 1.1 christos COMPARE("A. A SIG", "a. A SIG", 0),
2304 1.1 christos /*
2305 1.1 christos * Sorting on name field.
2306 1.1 christos */
2307 1.1 christos COMPARE("A. A SIG", "b. A SIG", -1),
2308 1.1 christos COMPARE("b. A SIG", "A. A SIG", 1),
2309 1.1 christos /* bit map differs */
2310 1.1 christos COMPARE("b. A SIG", "b. A AAAA SIG", -1),
2311 1.1 christos /* order of bit map does not matter */
2312 1.1 christos COMPARE("b. A SIG AAAA", "b. A AAAA SIG", 0), COMPARE_SENTINEL()
2313 1.1 christos };
2314 1.1 christos
2315 1.1 christos check_rdata(NULL, NULL, compare_ok, false, dns_rdataclass_in,
2316 1.1 christos dns_rdatatype_nxt, sizeof(dns_rdata_nxt_t));
2317 1.1 christos }
2318 1.1 christos
2319 1.1 christos ISC_RUN_TEST_IMPL(rkey) {
2320 1.1 christos text_ok_t text_ok[] = { /*
2321 1.1 christos * Valid, flags set to 0 and a key is present.
2322 1.1 christos */
2323 1.1 christos TEXT_VALID("0 0 0 aaaa"),
2324 1.1 christos /*
2325 1.1 christos * Invalid, non-zero flags.
2326 1.1 christos */
2327 1.1 christos TEXT_INVALID("1 0 0 aaaa"),
2328 1.1 christos TEXT_INVALID("65535 0 0 aaaa"),
2329 1.1 christos /*
2330 1.1 christos * Sentinel.
2331 1.1 christos */
2332 1.1 christos TEXT_SENTINEL()
2333 1.1 christos };
2334 1.1 christos wire_ok_t wire_ok[] = { /*
2335 1.1 christos * Valid, flags set to 0 and a key is present.
2336 1.1 christos */
2337 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00),
2338 1.1 christos /*
2339 1.1 christos * Invalid, non-zero flags.
2340 1.1 christos */
2341 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x00),
2342 1.1 christos WIRE_INVALID(0xff, 0xff, 0x00, 0x00, 0x00),
2343 1.1 christos /*
2344 1.1 christos * Sentinel.
2345 1.1 christos */
2346 1.1 christos WIRE_SENTINEL()
2347 1.1 christos };
2348 1.1 christos key_required(state, dns_rdatatype_rkey, sizeof(dns_rdata_rkey_t));
2349 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2350 1.1 christos dns_rdatatype_rkey, sizeof(dns_rdata_rkey_t));
2351 1.1 christos }
2352 1.1 christos
2353 1.3 christos ISC_RUN_TEST_IMPL(resinfo) {
2354 1.3 christos text_ok_t text_ok[] = {
2355 1.3 christos TEXT_VALID_CHANGED("qnamemin exterr=15,16,17 "
2356 1.3 christos "infourl=https://resolver.example.com/guide",
2357 1.3 christos "\"qnamemin\" \"exterr=15,16,17\" "
2358 1.3 christos "\"infourl=https://resolver.example.com/"
2359 1.3 christos "guide\""),
2360 1.3 christos /*
2361 1.3 christos * Sentinel.
2362 1.3 christos */
2363 1.3 christos TEXT_SENTINEL()
2364 1.3 christos };
2365 1.3 christos check_rdata(text_ok, NULL, NULL, false, dns_rdataclass_in,
2366 1.3 christos dns_rdatatype_resinfo, sizeof(dns_rdata_rkey_t));
2367 1.3 christos }
2368 1.3 christos
2369 1.1 christos /* SSHFP RDATA manipulations */
2370 1.1 christos ISC_RUN_TEST_IMPL(sshfp) {
2371 1.1 christos text_ok_t text_ok[] = { TEXT_INVALID(""), /* too short */
2372 1.1 christos TEXT_INVALID("0"), /* reserved, too short */
2373 1.1 christos TEXT_VALID("0 0"), /* no finger print */
2374 1.1 christos TEXT_VALID("0 0 AA"), /* reserved */
2375 1.1 christos TEXT_INVALID("0 1 AA"), /* too short SHA 1
2376 1.1 christos * digest */
2377 1.1 christos TEXT_INVALID("0 2 AA"), /* too short SHA 256
2378 1.1 christos * digest */
2379 1.1 christos TEXT_VALID("0 3 AA"), /* unknown finger print
2380 1.1 christos * type */
2381 1.1 christos /* good length SHA 1 digest */
2382 1.1 christos TEXT_VALID("1 1 "
2383 1.1 christos "00112233445566778899AABBCCDDEEFF171"
2384 1.1 christos "81920"),
2385 1.1 christos /* good length SHA 256 digest */
2386 1.1 christos TEXT_VALID("4 2 "
2387 1.1 christos "A87F1B687AC0E57D2A081A2F282672334D9"
2388 1.1 christos "0ED316D2B818CA9580EA3 84D92401"),
2389 1.1 christos /*
2390 1.1 christos * totext splits the fingerprint into chunks and
2391 1.1 christos * emits uppercase hex.
2392 1.1 christos */
2393 1.1 christos TEXT_VALID_CHANGED("1 2 "
2394 1.1 christos "00112233445566778899aabbccd"
2395 1.1 christos "deeff "
2396 1.1 christos "00112233445566778899AABBCCD"
2397 1.1 christos "DEEFF",
2398 1.1 christos "1 2 "
2399 1.1 christos "00112233445566778899AABBCCD"
2400 1.1 christos "DEEFF"
2401 1.1 christos "00112233445566778899AABB "
2402 1.1 christos "CCDDEEFF"),
2403 1.1 christos TEXT_SENTINEL() };
2404 1.1 christos wire_ok_t wire_ok[] = {
2405 1.1 christos WIRE_INVALID(0x00), /* reserved too short */
2406 1.1 christos WIRE_VALID(0x00, 0x00), /* reserved no finger print */
2407 1.1 christos WIRE_VALID(0x00, 0x00, 0x00), /* reserved */
2408 1.1 christos
2409 1.1 christos /* too short SHA 1 digests */
2410 1.1 christos WIRE_INVALID(0x00, 0x01), WIRE_INVALID(0x00, 0x01, 0x00),
2411 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
2412 1.1 christos 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD,
2413 1.1 christos 0xEE, 0xFF, 0x17, 0x18, 0x19),
2414 1.1 christos /* good length SHA 1 digest */
2415 1.1 christos WIRE_VALID(0x00, 0x01, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
2416 1.1 christos 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
2417 1.1 christos 0x17, 0x18, 0x19, 0x20),
2418 1.1 christos /* too long SHA 1 digest */
2419 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
2420 1.1 christos 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD,
2421 1.1 christos 0xEE, 0xFF, 0x17, 0x18, 0x19, 0x20, 0x21),
2422 1.1 christos /* too short SHA 256 digests */
2423 1.1 christos WIRE_INVALID(0x00, 0x02), WIRE_INVALID(0x00, 0x02, 0x00),
2424 1.1 christos WIRE_INVALID(0x00, 0x02, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
2425 1.1 christos 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD,
2426 1.1 christos 0xEE, 0xFF, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22,
2427 1.1 christos 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30,
2428 1.1 christos 0x31),
2429 1.1 christos /* good length SHA 256 digest */
2430 1.1 christos WIRE_VALID(0x00, 0x02, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
2431 1.1 christos 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
2432 1.1 christos 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
2433 1.1 christos 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x32),
2434 1.1 christos /* too long SHA 256 digest */
2435 1.1 christos WIRE_INVALID(0x00, 0x02, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
2436 1.1 christos 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD,
2437 1.1 christos 0xEE, 0xFF, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22,
2438 1.1 christos 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30,
2439 1.1 christos 0x31, 0x32, 0x33),
2440 1.1 christos /* unknown digest, * no fingerprint */
2441 1.1 christos WIRE_VALID(0x00, 0x03), WIRE_VALID(0x00, 0x03, 0x00), /* unknown
2442 1.1 christos * digest
2443 1.1 christos */
2444 1.1 christos WIRE_SENTINEL()
2445 1.1 christos };
2446 1.1 christos
2447 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2448 1.1 christos dns_rdatatype_sshfp, sizeof(dns_rdata_sshfp_t));
2449 1.1 christos }
2450 1.1 christos
2451 1.4 christos ISC_RUN_TEST_IMPL(wallet) {
2452 1.4 christos text_ok_t text_ok[] = { TEXT_VALID_CHANGED("cid-example wid-example",
2453 1.4 christos "\"cid-example\" "
2454 1.4 christos "\"wid-example\""),
2455 1.4 christos /*
2456 1.4 christos * Sentinel.
2457 1.4 christos */
2458 1.4 christos TEXT_SENTINEL() };
2459 1.4 christos check_rdata(text_ok, NULL, NULL, false, dns_rdataclass_in,
2460 1.4 christos dns_rdatatype_wallet, sizeof(dns_rdata_rkey_t));
2461 1.4 christos }
2462 1.4 christos
2463 1.1 christos /*
2464 1.1 christos * WKS tests.
2465 1.1 christos *
2466 1.1 christos * RFC 1035:
2467 1.1 christos *
2468 1.1 christos * 3.4.2. WKS RDATA format
2469 1.1 christos *
2470 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
2471 1.1 christos * | ADDRESS |
2472 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
2473 1.1 christos * | PROTOCOL | |
2474 1.1 christos * +--+--+--+--+--+--+--+--+ |
2475 1.1 christos * | |
2476 1.1 christos * / <BIT MAP> /
2477 1.1 christos * / /
2478 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
2479 1.1 christos *
2480 1.1 christos * where:
2481 1.1 christos *
2482 1.1 christos * ADDRESS An 32 bit Internet address
2483 1.1 christos *
2484 1.1 christos * PROTOCOL An 8 bit IP protocol number
2485 1.1 christos *
2486 1.1 christos * <BIT MAP> A variable length bit map. The bit map must be a
2487 1.1 christos * multiple of 8 bits long.
2488 1.1 christos *
2489 1.1 christos * The WKS record is used to describe the well known services supported by
2490 1.1 christos * a particular protocol on a particular internet address. The PROTOCOL
2491 1.1 christos * field specifies an IP protocol number, and the bit map has one bit per
2492 1.1 christos * port of the specified protocol. The first bit corresponds to port 0,
2493 1.1 christos * the second to port 1, etc. If the bit map does not include a bit for a
2494 1.1 christos * protocol of interest, that bit is assumed zero. The appropriate values
2495 1.1 christos * and mnemonics for ports and protocols are specified in [RFC-1010].
2496 1.1 christos *
2497 1.1 christos * For example, if PROTOCOL=TCP (6), the 26th bit corresponds to TCP port
2498 1.1 christos * 25 (SMTP). If this bit is set, a SMTP server should be listening on TCP
2499 1.1 christos * port 25; if zero, SMTP service is not supported on the specified
2500 1.1 christos * address.
2501 1.1 christos */
2502 1.1 christos ISC_RUN_TEST_IMPL(wks) {
2503 1.1 christos text_ok_t text_ok[] = { /*
2504 1.1 christos * Valid, IPv4 address in dotted-quad form.
2505 1.1 christos */
2506 1.1 christos TEXT_VALID("127.0.0.1 6"),
2507 1.1 christos /*
2508 1.1 christos * Invalid, IPv4 address not in dotted-quad
2509 1.1 christos * form.
2510 1.1 christos */
2511 1.1 christos TEXT_INVALID("127.1 6"),
2512 1.1 christos /*
2513 1.1 christos * Sentinel.
2514 1.1 christos */
2515 1.1 christos TEXT_SENTINEL()
2516 1.1 christos };
2517 1.1 christos wire_ok_t wire_ok[] = { /*
2518 1.1 christos * Too short.
2519 1.1 christos */
2520 1.1 christos WIRE_INVALID(0x00, 0x08, 0x00, 0x00),
2521 1.1 christos /*
2522 1.1 christos * Minimal TCP.
2523 1.1 christos */
2524 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 0x00, 6),
2525 1.1 christos /*
2526 1.1 christos * Minimal UDP.
2527 1.1 christos */
2528 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 0x00, 17),
2529 1.1 christos /*
2530 1.1 christos * Minimal other.
2531 1.1 christos */
2532 1.1 christos WIRE_VALID(0x00, 0x08, 0x00, 0x00, 1),
2533 1.1 christos /*
2534 1.1 christos * Sentinel.
2535 1.1 christos */
2536 1.1 christos WIRE_SENTINEL()
2537 1.1 christos };
2538 1.1 christos
2539 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2540 1.1 christos dns_rdatatype_wks, sizeof(dns_rdata_in_wks_t));
2541 1.1 christos }
2542 1.1 christos
2543 1.1 christos ISC_RUN_TEST_IMPL(https_svcb) {
2544 1.1 christos /*
2545 1.1 christos * Known keys: mandatory, apln, no-default-alpn, port,
2546 1.1 christos * ipv4hint, port, ipv6hint, dohpath.
2547 1.1 christos */
2548 1.1 christos text_ok_t text_ok[] = {
2549 1.1 christos /* unknown key invalid */
2550 1.1 christos TEXT_INVALID("1 . unknown="),
2551 1.1 christos /* no domain */
2552 1.1 christos TEXT_INVALID("0"),
2553 1.1 christos /* minimal record */
2554 1.1 christos TEXT_VALID_LOOP(0, "0 ."),
2555 1.3 christos /* Alias form possible future extension */
2556 1.3 christos TEXT_VALID_LOOP(1, "0 . alpn=\"h2\""),
2557 1.1 christos /* no "key" prefix */
2558 1.1 christos TEXT_INVALID("2 svc.example.net. 0=\"2222\""),
2559 1.1 christos /* no key value */
2560 1.1 christos TEXT_INVALID("2 svc.example.net. key"),
2561 1.1 christos /* no key value */
2562 1.1 christos TEXT_INVALID("2 svc.example.net. key=\"2222\""),
2563 1.1 christos /* zero pad invalid */
2564 1.1 christos TEXT_INVALID("2 svc.example.net. key07=\"2222\""),
2565 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. key8=\"2222\""),
2566 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. key8=2222",
2567 1.1 christos "2 svc.example.net. key8=\"2222\""),
2568 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. alpn=h2",
2569 1.1 christos "2 svc.example.net. alpn=\"h2\""),
2570 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. alpn=h3",
2571 1.1 christos "2 svc.example.net. alpn=\"h3\""),
2572 1.1 christos /* alpn has 2 sub field "h2" and "h3" */
2573 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. alpn=h2,h3",
2574 1.1 christos "2 svc.example.net. alpn=\"h2,h3\""),
2575 1.1 christos /* apln has 2 sub fields "h1,h2" and "h3" (comma escaped) */
2576 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. alpn=h1\\\\,h2,h3",
2577 1.1 christos "2 svc.example.net. alpn=\"h1\\\\,h2,h3\""),
2578 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. port=50"),
2579 1.1 christos /* no-default-alpn, alpn is required */
2580 1.1 christos TEXT_INVALID("2 svc.example.net. no-default-alpn"),
2581 1.1 christos /* no-default-alpn with alpn present */
2582 1.1 christos TEXT_VALID_LOOPCHG(
2583 1.1 christos 2, "2 svc.example.net. no-default-alpn alpn=h2",
2584 1.1 christos "2 svc.example.net. alpn=\"h2\" no-default-alpn"),
2585 1.1 christos /* empty hint */
2586 1.1 christos TEXT_INVALID("2 svc.example.net. ipv4hint="),
2587 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. "
2588 1.1 christos "ipv4hint=10.50.0.1,10.50.0.2"),
2589 1.1 christos /* empty hint */
2590 1.1 christos TEXT_INVALID("2 svc.example.net. ipv6hint="),
2591 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. ipv6hint=::1,2002::1"),
2592 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. ech=abcdefghijkl"),
2593 1.1 christos /* bad base64 */
2594 1.1 christos TEXT_INVALID("2 svc.example.net. ech=abcdefghijklm"),
2595 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. key8=\"2222\""),
2596 1.1 christos /* Out of key order on input (alpn == key1). */
2597 1.1 christos TEXT_VALID_LOOPCHG(2,
2598 1.1 christos "2 svc.example.net. key8=\"2222\" alpn=h2",
2599 1.1 christos "2 svc.example.net. alpn=\"h2\" "
2600 1.1 christos "key8=\"2222\""),
2601 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. key65535=\"2222\""),
2602 1.1 christos TEXT_INVALID("2 svc.example.net. key65536=\"2222\""),
2603 1.1 christos TEXT_VALID_LOOP(1, "2 svc.example.net. key10"),
2604 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. key11=",
2605 1.1 christos "2 svc.example.net. key11"),
2606 1.1 christos TEXT_VALID_LOOPCHG(1, "2 svc.example.net. key12=\"\"",
2607 1.1 christos "2 svc.example.net. key12"),
2608 1.1 christos /* empty alpn-id sub fields */
2609 1.1 christos TEXT_INVALID("2 svc.example.net. alpn"),
2610 1.1 christos TEXT_INVALID("2 svc.example.net. alpn="),
2611 1.1 christos TEXT_INVALID("2 svc.example.net. alpn=,h1"),
2612 1.1 christos TEXT_INVALID("2 svc.example.net. alpn=h1,"),
2613 1.1 christos TEXT_INVALID("2 svc.example.net. alpn=h1,,h2"),
2614 1.3 christos /* empty alpn-id sub fields - RFC 1035 escaped commas */
2615 1.3 christos TEXT_INVALID("2 svc.example.net. alpn=\\,abc"),
2616 1.3 christos TEXT_INVALID("2 svc.example.net. alpn=abc\\,"),
2617 1.3 christos TEXT_INVALID("2 svc.example.net. alpn=a\\,\\,abc"),
2618 1.1 christos /* mandatory */
2619 1.1 christos TEXT_VALID_LOOP(2, "2 svc.example.net. mandatory=alpn "
2620 1.1 christos "alpn=\"h2\""),
2621 1.1 christos TEXT_VALID_LOOP(3, "2 svc.example.net. mandatory=alpn,port "
2622 1.1 christos "alpn=\"h2\" port=443"),
2623 1.1 christos TEXT_VALID_LOOPCHG(3,
2624 1.1 christos "2 svc.example.net. mandatory=port,alpn "
2625 1.1 christos "alpn=\"h2\" port=443",
2626 1.1 christos "2 svc.example.net. mandatory=alpn,port "
2627 1.1 christos "alpn=\"h2\" port=443"),
2628 1.1 christos TEXT_INVALID("2 svc.example.net. mandatory=mandatory"),
2629 1.1 christos TEXT_INVALID("2 svc.example.net. mandatory=port"),
2630 1.1 christos TEXT_INVALID("2 svc.example.net. mandatory=,port port=433"),
2631 1.1 christos TEXT_INVALID("2 svc.example.net. mandatory=port, port=433"),
2632 1.1 christos TEXT_INVALID("2 svc.example.net. "
2633 1.1 christos "mandatory=alpn,,port alpn=h2 port=433"),
2634 1.1 christos /* mandatory w/ unknown key values */
2635 1.1 christos TEXT_VALID_LOOP(2, "2 svc.example.net. mandatory=key8 key8"),
2636 1.1 christos TEXT_VALID_LOOP(3, "2 svc.example.net. mandatory=key8,key9 "
2637 1.1 christos "key8 key9"),
2638 1.1 christos TEXT_VALID_LOOPCHG(
2639 1.1 christos 3, "2 svc.example.net. mandatory=key9,key8 key8 key9",
2640 1.1 christos "2 svc.example.net. mandatory=key8,key9 key8 key9"),
2641 1.1 christos TEXT_INVALID("2 svc.example.net. "
2642 1.1 christos "mandatory=key8,key8"),
2643 1.1 christos TEXT_INVALID("2 svc.example.net. mandatory=,key8"),
2644 1.1 christos TEXT_INVALID("2 svc.example.net. mandatory=key8,"),
2645 1.1 christos TEXT_INVALID("2 svc.example.net. "
2646 1.1 christos "mandatory=key8,,key8"),
2647 1.1 christos /* Invalid test vectors */
2648 1.1 christos TEXT_INVALID("1 foo.example.com. ( key123=abc key123=def )"),
2649 1.1 christos TEXT_INVALID("1 foo.example.com. mandatory"),
2650 1.1 christos TEXT_INVALID("1 foo.example.com. alpn"),
2651 1.1 christos TEXT_INVALID("1 foo.example.com. port"),
2652 1.1 christos TEXT_INVALID("1 foo.example.com. ipv4hint"),
2653 1.1 christos TEXT_INVALID("1 foo.example.com. ipv6hint"),
2654 1.1 christos TEXT_INVALID("1 foo.example.com. no-default-alpn=abc"),
2655 1.1 christos TEXT_INVALID("1 foo.example.com. mandatory=key123"),
2656 1.1 christos TEXT_INVALID("1 foo.example.com. mandatory=mandatory"),
2657 1.1 christos TEXT_INVALID("1 foo.example.com. ( mandatory=key123,key123 "
2658 1.1 christos "key123=abc)"),
2659 1.1 christos /* dohpath tests */
2660 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{dns}",
2661 1.4 christos "1 example.net. key7=\"/{dns}\""),
2662 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{+dns}",
2663 1.4 christos "1 example.net. key7=\"/{+dns}\""),
2664 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{#dns}",
2665 1.4 christos "1 example.net. key7=\"/{#dns}\""),
2666 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{.dns}",
2667 1.4 christos "1 example.net. key7=\"/{.dns}\""),
2668 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=\"/{;dns}\"",
2669 1.4 christos "1 example.net. key7=\"/{;dns}\""),
2670 1.1 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{?dns}",
2671 1.1 christos "1 example.net. key7=\"/{?dns}\""),
2672 1.1 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/some/path{?dns}",
2673 1.1 christos "1 example.net. key7=\"/some/path{?dns}\""),
2674 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{dns:9999}",
2675 1.4 christos "1 example.net. key7=\"/{dns:9999}\""),
2676 1.4 christos TEXT_VALID_LOOPCHG(1, "1 example.net. dohpath=/{dns*}",
2677 1.4 christos "1 example.net. key7=\"/{dns*}\""),
2678 1.4 christos TEXT_VALID_LOOPCHG(
2679 1.4 christos 1, "1 example.net. dohpath=/some/path?key=value{&dns}",
2680 1.4 christos "1 example.net. key7=\"/some/path?key=value{&dns}\""),
2681 1.4 christos TEXT_VALID_LOOPCHG(1,
2682 1.4 christos "1 example.net. "
2683 1.4 christos "dohpath=/some/path?key=value{&dns,x*}",
2684 1.4 christos "1 example.net. "
2685 1.4 christos "key7=\"/some/path?key=value{&dns,x*}\""),
2686 1.4 christos TEXT_INVALID("1 example.com. dohpath=not-relative"),
2687 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?no_dns_variable}"),
2688 1.4 christos TEXT_INVALID("1 example.com. dohpath=/novariable"),
2689 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?dnsx}"),
2690 1.4 christos /* index too big > 9999 */
2691 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?dns:10000}"),
2692 1.4 christos /* index not postive */
2693 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?dns:0}"),
2694 1.4 christos /* index leading zero */
2695 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?dns:01}"),
2696 1.4 christos /* two operators */
2697 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{??dns}"),
2698 1.4 christos /* invalid % encoding */
2699 1.4 christos TEXT_INVALID("1 example.com. dohpath=/%a{?dns}"),
2700 1.4 christos /* invalid % encoding */
2701 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?dns,%a}"),
2702 1.4 christos /* incomplete macro */
2703 1.4 christos TEXT_INVALID("1 example.com. dohpath=/{?dns" /*}*/),
2704 1.1 christos TEXT_SENTINEL()
2705 1.1 christos
2706 1.1 christos };
2707 1.1 christos wire_ok_t wire_ok[] = {
2708 1.1 christos /*
2709 1.1 christos * Too short
2710 1.1 christos */
2711 1.1 christos WIRE_INVALID(0x00, 0x00),
2712 1.1 christos /*
2713 1.1 christos * Minimal length record.
2714 1.1 christos */
2715 1.1 christos WIRE_VALID(0x00, 0x00, 0x00),
2716 1.1 christos /*
2717 1.3 christos * Alias with invalid dohpath.
2718 1.1 christos */
2719 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00),
2720 1.1 christos /*
2721 1.1 christos * Bad key7= length (longer than rdata).
2722 1.1 christos */
2723 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x01),
2724 1.1 christos /*
2725 1.1 christos * Port (0x03) too small (zero and one octets).
2726 1.1 christos */
2727 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00),
2728 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00),
2729 1.1 christos /* Valid port */
2730 1.1 christos WIRE_VALID_LOOP(1, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x02,
2731 1.1 christos 0x00, 0x00),
2732 1.1 christos /*
2733 1.1 christos * Port (0x03) too big (three octets).
2734 1.1 christos */
2735 1.1 christos WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00,
2736 1.1 christos 0x00, 0x00),
2737 1.1 christos /*
2738 1.1 christos * Duplicate keys.
2739 1.1 christos */
2740 1.1 christos WIRE_INVALID(0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
2741 1.1 christos 0x80, 0x00, 0x00),
2742 1.1 christos /*
2743 1.1 christos * Out of order keys.
2744 1.1 christos */
2745 1.1 christos WIRE_INVALID(0x01, 0x01, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00,
2746 1.1 christos 0x80, 0x00, 0x00),
2747 1.1 christos /*
2748 1.1 christos * Empty of mandatory key list.
2749 1.1 christos */
2750 1.1 christos WIRE_INVALID(0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00),
2751 1.1 christos /*
2752 1.1 christos * "mandatory=mandatory" is invalid
2753 1.1 christos */
2754 1.1 christos WIRE_INVALID(0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
2755 1.1 christos 0x00),
2756 1.1 christos /*
2757 1.1 christos * Out of order mandatory key list.
2758 1.1 christos */
2759 1.1 christos WIRE_INVALID(0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
2760 1.1 christos 0x80, 0x00, 0x71, 0x00, 0x71, 0x00, 0x00, 0x00,
2761 1.1 christos 0x80, 0x00, 0x00),
2762 1.1 christos /*
2763 1.1 christos * Alpn(0x00 0x01) (length 0x00 0x09) "h1,h2" + "h3"
2764 1.1 christos */
2765 1.1 christos WIRE_VALID_LOOP(0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x09,
2766 1.1 christos 5, 'h', '1', ',', 'h', '2', 2, 'h', '3'),
2767 1.1 christos /*
2768 1.1 christos * Alpn(0x00 0x01) (length 0x00 0x09) "h1\h2" + "h3"
2769 1.1 christos */
2770 1.1 christos WIRE_VALID_LOOP(0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x09,
2771 1.1 christos 5, 'h', '1', '\\', 'h', '2', 2, 'h', '3'),
2772 1.1 christos /*
2773 1.1 christos * no-default-alpn (0x00 0x02) without alpn, alpn is required.
2774 1.1 christos */
2775 1.1 christos WIRE_INVALID(0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00),
2776 1.1 christos /*
2777 1.1 christos * Alpn(0x00 0x01) with zero length elements is invalid
2778 1.1 christos */
2779 1.1 christos WIRE_INVALID(0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x05,
2780 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00),
2781 1.1 christos WIRE_SENTINEL()
2782 1.1 christos };
2783 1.1 christos /* Test vectors from RFCXXXX */
2784 1.1 christos textvsunknown_t textvsunknown[] = {
2785 1.1 christos /* AliasForm */
2786 1.1 christos { "0 foo.example.com", "\\# 19 ( 00 00 03 66 6f 6f 07 65 78 61 "
2787 1.1 christos "6d 70 6c 65 03 63 6f 6d 00)" },
2788 1.1 christos /* ServiceForm */
2789 1.1 christos { "1 .", "\\# 3 ( 00 01 00)" },
2790 1.1 christos /* Port example */
2791 1.1 christos { "16 foo.example.com port=53",
2792 1.1 christos "\\# 25 ( 00 10 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f "
2793 1.1 christos "6d 00 00 03 00 02 00 35 )" },
2794 1.1 christos /* Unregistered keys with unquoted value. */
2795 1.1 christos { "1 foo.example.com key667=hello",
2796 1.1 christos "\\# 28 ( 00 01 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f "
2797 1.1 christos "6d 00 02 9b 00 05 68 65 6c 6c 6f )" },
2798 1.1 christos /*
2799 1.1 christos * Quoted decimal-escaped character.
2800 1.1 christos * 1 foo.example.com key667="hello\210qoo"
2801 1.1 christos */
2802 1.1 christos { "1 foo.example.com key667=\"hello\\210qoo\"",
2803 1.1 christos "\\# 32 ( 00 01 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f "
2804 1.1 christos "6d 00 02 9b 00 09 68 65 6c 6c 6f d2 71 6f 6f )" },
2805 1.1 christos /*
2806 1.1 christos * IPv6 hints example, quoted.
2807 1.1 christos * 1 foo.example.com ipv6hint="2001:db8::1,2001:db8::53:1"
2808 1.1 christos */
2809 1.1 christos { "1 foo.example.com ipv6hint=\"2001:db8::1,2001:db8::53:1\"",
2810 1.1 christos "\\# 55 ( 00 01 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f "
2811 1.1 christos "6d 00 00 06 00 20 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 "
2812 1.1 christos "00 01 20 01 0d b8 00 00 00 00 00 00 00 00 00 53 00 01 )" },
2813 1.1 christos /* SvcParamValues and mandatory out of order. */
2814 1.1 christos { "16 foo.example.org alpn=h2,h3-19 mandatory=ipv4hint,alpn "
2815 1.1 christos "ipv4hint=192.0.2.1",
2816 1.1 christos "\\# 48 ( 00 10 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 "
2817 1.1 christos "67 00 00 00 00 04 00 01 00 04 00 01 00 09 02 68 32 05 68 33 "
2818 1.1 christos "2d 31 39 00 04 00 04 c0 00 02 01 )" },
2819 1.1 christos /*
2820 1.1 christos * Quoted ALPN with escaped comma and backslash.
2821 1.1 christos * 16 foo.example.org alpn="f\\\\oo\\,bar,h2"
2822 1.1 christos */
2823 1.1 christos { "16 foo.example.org alpn=\"f\\\\\\\\oo\\\\,bar,h2\"",
2824 1.1 christos "\\# 35 ( 00 10 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 "
2825 1.1 christos "67 00 00 01 00 0c 08 66 5c 6f 6f 2c 62 61 72 02 68 32 )" },
2826 1.1 christos /*
2827 1.1 christos * Unquoted ALPN with escaped comma and backslash.
2828 1.1 christos * 16 foo.example.org alpn=f\\\092oo\092,bar,h2
2829 1.1 christos */
2830 1.1 christos { "16 foo.example.org alpn=f\\\\\\092oo\\092,bar,h2",
2831 1.1 christos "\\# 35 ( 00 10 03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 "
2832 1.1 christos "67 00 00 01 00 0c 08 66 5c 6f 6f 2c 62 61 72 02 68 32 )" },
2833 1.1 christos { NULL, NULL }
2834 1.1 christos };
2835 1.1 christos
2836 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2837 1.1 christos dns_rdatatype_svcb, sizeof(dns_rdata_in_svcb_t));
2838 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
2839 1.1 christos dns_rdatatype_https, sizeof(dns_rdata_in_https_t));
2840 1.1 christos
2841 1.1 christos check_textvsunknown(textvsunknown, dns_rdataclass_in,
2842 1.1 christos dns_rdatatype_svcb);
2843 1.1 christos check_textvsunknown(textvsunknown, dns_rdataclass_in,
2844 1.1 christos dns_rdatatype_https);
2845 1.1 christos }
2846 1.1 christos
2847 1.1 christos /*
2848 1.1 christos * ZONEMD tests.
2849 1.1 christos *
2850 1.1 christos * Excerpted from RFC 8976:
2851 1.1 christos *
2852 1.1 christos * The ZONEMD RDATA wire format is encoded as follows:
2853 1.1 christos *
2854 1.1 christos * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
2855 1.1 christos * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2856 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2857 1.1 christos * | Serial |
2858 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2859 1.1 christos * | Scheme |Hash Algorithm | |
2860 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
2861 1.1 christos * | Digest |
2862 1.1 christos * / /
2863 1.1 christos * / /
2864 1.1 christos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2865 1.1 christos *
2866 1.1 christos * 2.2.1. The Serial Field
2867 1.1 christos *
2868 1.1 christos * The Serial field is a 32-bit unsigned integer in network byte order.
2869 1.1 christos * It is the serial number from the zone's SOA record ([RFC1035],
2870 1.1 christos * Section 3.3.13) for which the zone digest was generated.
2871 1.1 christos *
2872 1.1 christos * It is included here to clearly bind the ZONEMD RR to a particular
2873 1.1 christos * version of the zone's content. Without the serial number, a stand-
2874 1.1 christos * alone ZONEMD digest has no obvious association to any particular
2875 1.1 christos * instance of a zone.
2876 1.1 christos *
2877 1.1 christos * 2.2.2. The Scheme Field
2878 1.1 christos *
2879 1.1 christos * The Scheme field is an 8-bit unsigned integer that identifies the
2880 1.1 christos * methods by which data is collated and presented as input to the
2881 1.1 christos * hashing function.
2882 1.1 christos *
2883 1.1 christos * Herein, SIMPLE, with Scheme value 1, is the only standardized Scheme
2884 1.1 christos * defined for ZONEMD records and it MUST be supported by
2885 1.1 christos * implementations. The "ZONEMD Schemes" registry is further described
2886 1.1 christos * in Section 5.
2887 1.1 christos *
2888 1.1 christos * Scheme values 240-254 are allocated for Private Use.
2889 1.1 christos *
2890 1.1 christos * 2.2.3. The Hash Algorithm Field
2891 1.1 christos *
2892 1.1 christos * The Hash Algorithm field is an 8-bit unsigned integer that identifies
2893 1.1 christos * the cryptographic hash algorithm used to construct the digest.
2894 1.1 christos *
2895 1.1 christos * Herein, SHA384 ([RFC6234]), with Hash Algorithm value 1, is the only
2896 1.1 christos * standardized Hash Algorithm defined for ZONEMD records that MUST be
2897 1.1 christos * supported by implementations. When SHA384 is used, the size of the
2898 1.1 christos * Digest field is 48 octets. The result of the SHA384 digest algorithm
2899 1.1 christos * MUST NOT be truncated, and the entire 48-octet digest is published in
2900 1.1 christos * the ZONEMD record.
2901 1.1 christos *
2902 1.1 christos * SHA512 ([RFC6234]), with Hash Algorithm value 2, is also defined for
2903 1.1 christos * ZONEMD records and SHOULD be supported by implementations. When
2904 1.1 christos * SHA512 is used, the size of the Digest field is 64 octets. The
2905 1.1 christos * result of the SHA512 digest algorithm MUST NOT be truncated, and the
2906 1.1 christos * entire 64-octet digest is published in the ZONEMD record.
2907 1.1 christos *
2908 1.1 christos * Hash Algorithm values 240-254 are allocated for Private Use.
2909 1.1 christos *
2910 1.1 christos * The "ZONEMD Hash Algorithms" registry is further described in
2911 1.1 christos * Section 5.
2912 1.1 christos *
2913 1.1 christos * 2.2.4. The Digest Field
2914 1.1 christos *
2915 1.1 christos * The Digest field is a variable-length sequence of octets containing
2916 1.1 christos * the output of the hash algorithm. The length of the Digest field is
2917 1.1 christos * determined by deducting the fixed size of the Serial, Scheme, and
2918 1.1 christos * Hash Algorithm fields from the RDATA size in the ZONEMD RR header.
2919 1.1 christos *
2920 1.1 christos * The Digest field MUST NOT be shorter than 12 octets. Digests for the
2921 1.1 christos * SHA384 and SHA512 hash algorithms specified herein are never
2922 1.1 christos * truncated. Digests for future hash algorithms MAY be truncated but
2923 1.1 christos * MUST NOT be truncated to a length that results in less than 96 bits
2924 1.1 christos * (12 octets) of equivalent strength.
2925 1.1 christos *
2926 1.1 christos * Section 3 describes how to calculate the digest for a zone.
2927 1.1 christos * Section 4 describes how to use the digest to verify the contents of a
2928 1.1 christos * zone.
2929 1.1 christos *
2930 1.1 christos */
2931 1.1 christos
2932 1.1 christos ISC_RUN_TEST_IMPL(zonemd) {
2933 1.1 christos text_ok_t text_ok[] = {
2934 1.1 christos TEXT_INVALID(""),
2935 1.1 christos /* No digest scheme or digest type*/
2936 1.1 christos TEXT_INVALID("0"),
2937 1.1 christos /* No digest type */
2938 1.1 christos TEXT_INVALID("0 0"),
2939 1.1 christos /* No digest */
2940 1.1 christos TEXT_INVALID("0 0 0"),
2941 1.1 christos /* No digest */
2942 1.1 christos TEXT_INVALID("99999999 0 0"),
2943 1.1 christos /* No digest */
2944 1.1 christos TEXT_INVALID("2019020700 0 0"),
2945 1.1 christos /* Digest too short */
2946 1.1 christos TEXT_INVALID("2019020700 1 1 DEADBEEF"),
2947 1.1 christos /* Digest too short */
2948 1.1 christos TEXT_INVALID("2019020700 1 2 DEADBEEF"),
2949 1.1 christos /* Digest too short */
2950 1.1 christos TEXT_INVALID("2019020700 1 3 DEADBEEFDEADBEEFDEADBE"),
2951 1.1 christos /* Digest type unknown */
2952 1.1 christos TEXT_VALID("2019020700 1 3 DEADBEEFDEADBEEFDEADBEEF"),
2953 1.1 christos /* Digest type max */
2954 1.1 christos TEXT_VALID("2019020700 1 255 DEADBEEFDEADBEEFDEADBEEF"),
2955 1.1 christos /* Digest type too big */
2956 1.1 christos TEXT_INVALID("2019020700 0 256 DEADBEEFDEADBEEFDEADBEEF"),
2957 1.1 christos /* Scheme max */
2958 1.1 christos TEXT_VALID("2019020700 255 3 DEADBEEFDEADBEEFDEADBEEF"),
2959 1.1 christos /* Scheme too big */
2960 1.1 christos TEXT_INVALID("2019020700 256 3 DEADBEEFDEADBEEFDEADBEEF"),
2961 1.1 christos /* SHA384 */
2962 1.1 christos TEXT_VALID("2019020700 1 1 "
2963 1.1 christos "7162D2BB75C047A53DE98767C9192BEB"
2964 1.1 christos "14DB01E7E2267135DAF0230A 19BA4A31"
2965 1.1 christos "6AF6BF64AA5C7BAE24B2992850300509"),
2966 1.1 christos /* SHA512 */
2967 1.1 christos TEXT_VALID("2019020700 1 2 "
2968 1.1 christos "08CFA1115C7B948C4163A901270395EA"
2969 1.1 christos "226A930CD2CBCF2FA9A5E6EB 85F37C8A"
2970 1.1 christos "4E114D884E66F176EAB121CB02DB7D65"
2971 1.1 christos "2E0CC4827E7A3204 F166B47E5613FD27"),
2972 1.1 christos /* SHA384 too short and with private scheme */
2973 1.1 christos TEXT_INVALID("2021042801 0 1 "
2974 1.1 christos "7162D2BB75C047A53DE98767C9192BEB"
2975 1.1 christos "6AF6BF64AA5C7BAE24B2992850300509"),
2976 1.1 christos /* SHA512 too short and with private scheme */
2977 1.1 christos TEXT_INVALID("2021042802 5 2 "
2978 1.1 christos "A897B40072ECAE9E4CA3F1F227DE8F5E"
2979 1.1 christos "480CDEBB16DFC64C1C349A7B5F6C71AB"
2980 1.1 christos "E8A88B76EF0BA1604EC25752E946BF98"),
2981 1.1 christos TEXT_SENTINEL()
2982 1.1 christos };
2983 1.1 christos wire_ok_t wire_ok[] = {
2984 1.1 christos /*
2985 1.1 christos * Short.
2986 1.1 christos */
2987 1.1 christos WIRE_INVALID(0x00),
2988 1.1 christos /*
2989 1.1 christos * Short.
2990 1.1 christos */
2991 1.1 christos WIRE_INVALID(0x00, 0x00),
2992 1.1 christos /*
2993 1.1 christos * Short.
2994 1.1 christos */
2995 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00),
2996 1.1 christos /*
2997 1.1 christos * Short.
2998 1.1 christos */
2999 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00),
3000 1.1 christos /*
3001 1.1 christos * Short.
3002 1.1 christos */
3003 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00),
3004 1.1 christos /*
3005 1.1 christos * Short.
3006 1.1 christos */
3007 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
3008 1.1 christos /*
3009 1.1 christos * Short 11-octet digest.
3010 1.1 christos */
3011 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3012 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3013 1.1 christos 0x00),
3014 1.1 christos /*
3015 1.1 christos * Minimal, 12-octet hash for an undefined digest type.
3016 1.1 christos */
3017 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3018 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3019 1.1 christos 0x00),
3020 1.1 christos /*
3021 1.1 christos * SHA-384 is defined, so we insist there be a digest of
3022 1.1 christos * the expected length.
3023 1.1 christos */
3024 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
3025 1.1 christos 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3026 1.1 christos 0x00, 0x00),
3027 1.1 christos /*
3028 1.1 christos * 48-octet digest, valid for SHA-384.
3029 1.1 christos */
3030 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xde, 0xad, 0xbe,
3031 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3032 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3033 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3034 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3035 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa,
3036 1.1 christos 0xce),
3037 1.1 christos /*
3038 1.1 christos * 56-octet digest, too long for SHA-384.
3039 1.1 christos */
3040 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0xde, 0xad,
3041 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3042 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3043 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
3044 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3045 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3046 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
3047 1.1 christos 0xbe, 0xef, 0xfa, 0xce),
3048 1.1 christos /*
3049 1.1 christos * 56-octet digest, too short for SHA-512
3050 1.1 christos */
3051 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xde, 0xad,
3052 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3053 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3054 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
3055 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3056 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3057 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
3058 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad),
3059 1.1 christos /*
3060 1.1 christos * 64-octet digest, just right for SHA-512
3061 1.1 christos */
3062 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xde, 0xad, 0xbe,
3063 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3064 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3065 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3066 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3067 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3068 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3069 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef),
3070 1.1 christos /*
3071 1.1 christos * 72-octet digest, too long for SHA-512
3072 1.1 christos */
3073 1.1 christos WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xde, 0xad,
3074 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3075 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3076 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
3077 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3078 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3079 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
3080 1.1 christos 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3081 1.1 christos 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3082 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce),
3083 1.1 christos /*
3084 1.1 christos * 56-octet digest, valid for an undefined digest type.
3085 1.1 christos */
3086 1.1 christos WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xde, 0xad, 0xbe,
3087 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3088 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3089 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3090 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
3091 1.1 christos 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
3092 1.1 christos 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce),
3093 1.1 christos /*
3094 1.1 christos * Sentinel.
3095 1.1 christos */
3096 1.1 christos WIRE_SENTINEL()
3097 1.1 christos };
3098 1.1 christos
3099 1.1 christos check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
3100 1.1 christos dns_rdatatype_zonemd, sizeof(dns_rdata_zonemd_t));
3101 1.1 christos }
3102 1.1 christos
3103 1.1 christos ISC_RUN_TEST_IMPL(atcname) {
3104 1.1 christos unsigned int i;
3105 1.1 christos
3106 1.1 christos #define UNR "# Unexpected result from dns_rdatatype_atcname for type %u\n"
3107 1.1 christos for (i = 0; i < 0xffffU; i++) {
3108 1.1 christos bool tf = dns_rdatatype_atcname((dns_rdatatype_t)i);
3109 1.1 christos switch (i) {
3110 1.1 christos case dns_rdatatype_nsec:
3111 1.1 christos case dns_rdatatype_key:
3112 1.1 christos case dns_rdatatype_rrsig:
3113 1.1 christos if (!tf) {
3114 1.1 christos print_message(UNR, i);
3115 1.1 christos }
3116 1.1 christos assert_true(tf);
3117 1.1 christos break;
3118 1.1 christos default:
3119 1.1 christos if (tf) {
3120 1.1 christos print_message(UNR, i);
3121 1.1 christos }
3122 1.1 christos assert_false(tf);
3123 1.1 christos break;
3124 1.1 christos }
3125 1.1 christos }
3126 1.1 christos #undef UNR
3127 1.1 christos }
3128 1.1 christos
3129 1.1 christos ISC_RUN_TEST_IMPL(atparent) {
3130 1.1 christos unsigned int i;
3131 1.1 christos
3132 1.1 christos #define UNR "# Unexpected result from dns_rdatatype_atparent for type %u\n"
3133 1.1 christos for (i = 0; i < 0xffffU; i++) {
3134 1.1 christos bool tf = dns_rdatatype_atparent((dns_rdatatype_t)i);
3135 1.1 christos switch (i) {
3136 1.1 christos case dns_rdatatype_ds:
3137 1.1 christos if (!tf) {
3138 1.1 christos print_message(UNR, i);
3139 1.1 christos }
3140 1.1 christos assert_true(tf);
3141 1.1 christos break;
3142 1.1 christos default:
3143 1.1 christos if (tf) {
3144 1.1 christos print_message(UNR, i);
3145 1.1 christos }
3146 1.1 christos assert_false(tf);
3147 1.1 christos break;
3148 1.1 christos }
3149 1.1 christos }
3150 1.1 christos #undef UNR
3151 1.1 christos }
3152 1.1 christos
3153 1.1 christos ISC_RUN_TEST_IMPL(iszonecutauth) {
3154 1.1 christos unsigned int i;
3155 1.1 christos #define UNR "# Unexpected result from dns_rdatatype_iszonecutauth for type %u\n"
3156 1.1 christos for (i = 0; i < 0xffffU; i++) {
3157 1.1 christos bool tf = dns_rdatatype_iszonecutauth((dns_rdatatype_t)i);
3158 1.1 christos switch (i) {
3159 1.1 christos case dns_rdatatype_ns:
3160 1.1 christos case dns_rdatatype_ds:
3161 1.1 christos case dns_rdatatype_nsec:
3162 1.1 christos case dns_rdatatype_key:
3163 1.1 christos case dns_rdatatype_rrsig:
3164 1.1 christos if (!tf) {
3165 1.1 christos print_message(UNR, i);
3166 1.1 christos }
3167 1.1 christos assert_true(tf);
3168 1.1 christos break;
3169 1.1 christos default:
3170 1.1 christos if (tf) {
3171 1.1 christos print_message(UNR, i);
3172 1.1 christos }
3173 1.1 christos assert_false(tf);
3174 1.1 christos break;
3175 1.1 christos }
3176 1.1 christos }
3177 1.1 christos #undef UNR
3178 1.1 christos }
3179 1.1 christos
3180 1.1 christos ISC_TEST_LIST_START
3181 1.1 christos
3182 1.1 christos /* types */
3183 1.1 christos ISC_TEST_ENTRY(amtrelay)
3184 1.1 christos ISC_TEST_ENTRY(apl)
3185 1.1 christos ISC_TEST_ENTRY(atma)
3186 1.1 christos ISC_TEST_ENTRY(cdnskey)
3187 1.1 christos ISC_TEST_ENTRY(csync)
3188 1.1 christos ISC_TEST_ENTRY(dnskey)
3189 1.1 christos ISC_TEST_ENTRY(doa)
3190 1.1 christos ISC_TEST_ENTRY(ds)
3191 1.1 christos ISC_TEST_ENTRY(eid)
3192 1.1 christos ISC_TEST_ENTRY(hip)
3193 1.1 christos ISC_TEST_ENTRY(https_svcb)
3194 1.1 christos ISC_TEST_ENTRY(isdn)
3195 1.1 christos ISC_TEST_ENTRY(key)
3196 1.1 christos ISC_TEST_ENTRY(loc)
3197 1.1 christos ISC_TEST_ENTRY(nimloc)
3198 1.1 christos ISC_TEST_ENTRY(nsec)
3199 1.1 christos ISC_TEST_ENTRY(nsec3)
3200 1.1 christos ISC_TEST_ENTRY(nxt)
3201 1.1 christos ISC_TEST_ENTRY(rkey)
3202 1.3 christos ISC_TEST_ENTRY(resinfo)
3203 1.1 christos ISC_TEST_ENTRY(sshfp)
3204 1.4 christos ISC_TEST_ENTRY(wallet)
3205 1.1 christos ISC_TEST_ENTRY(wks)
3206 1.1 christos ISC_TEST_ENTRY(zonemd)
3207 1.1 christos
3208 1.1 christos /* other tests */
3209 1.1 christos ISC_TEST_ENTRY(edns_client_subnet)
3210 1.1 christos ISC_TEST_ENTRY(atcname)
3211 1.1 christos ISC_TEST_ENTRY(atparent)
3212 1.1 christos ISC_TEST_ENTRY(iszonecutauth)
3213 1.1 christos ISC_TEST_LIST_END
3214 1.1 christos
3215 1.1 christos ISC_TEST_MAIN
3216