2003-09-30 06:00:40 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2003-09-30 06:00:40 +00:00
|
|
|
*
|
2021-06-03 08:37:05 +02:00
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2020-09-14 16:20:40 -07:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2003-09-30 06:00:40 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/* RFC2535 */
|
2003-09-30 06:00:40 +00:00
|
|
|
|
|
|
|
#ifndef RDATA_GENERIC_DNSKEY_48_C
|
|
|
|
#define RDATA_GENERIC_DNSKEY_48_C
|
|
|
|
|
|
|
|
#include <dst/dst.h>
|
|
|
|
|
|
|
|
#define RRTYPE_DNSKEY_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC)
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromtext_dnskey(ARGS_FROMTEXT) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
2020-07-17 12:23:19 +10:00
|
|
|
return (generic_fromtext_key(CALL_FROMTEXT));
|
2003-09-30 06:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
totext_dnskey(ARGS_TOTEXT) {
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(rdata != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
2020-07-17 12:23:19 +10:00
|
|
|
return (generic_totext_key(CALL_TOTEXT));
|
2003-09-30 06:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromwire_dnskey(ARGS_FROMWIRE) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
2020-07-17 12:23:19 +10:00
|
|
|
return (generic_fromwire_key(CALL_FROMWIRE));
|
2003-09-30 06:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
towire_dnskey(ARGS_TOWIRE) {
|
2003-09-30 06:00:40 +00:00
|
|
|
isc_region_t sr;
|
|
|
|
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(rdata != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
|
|
|
|
|
|
|
UNUSED(cctx);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
compare_dnskey(ARGS_COMPARE) {
|
2003-09-30 06:00:40 +00:00
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
|
|
|
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(rdata1 != NULL);
|
|
|
|
REQUIRE(rdata2 != NULL);
|
2003-09-30 06:00:40 +00:00
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata1->type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
return (isc_region_compare(&r1, &r2));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromstruct_dnskey(ARGS_FROMSTRUCT) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
2020-07-17 12:23:19 +10:00
|
|
|
return (generic_fromstruct_key(CALL_FROMSTRUCT));
|
2003-09-30 06:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
tostruct_dnskey(ARGS_TOSTRUCT) {
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_rdata_dnskey_t *dnskey = target;
|
|
|
|
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(dnskey != NULL);
|
|
|
|
REQUIRE(rdata != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
|
|
|
dnskey->common.rdclass = rdata->rdclass;
|
|
|
|
dnskey->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&dnskey->common, link);
|
|
|
|
|
2020-07-17 12:23:19 +10:00
|
|
|
return (generic_tostruct_key(CALL_TOSTRUCT));
|
2003-09-30 06:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
freestruct_dnskey(ARGS_FREESTRUCT) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdata_dnskey_t *dnskey = (dns_rdata_dnskey_t *)source;
|
2003-09-30 06:00:40 +00:00
|
|
|
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(dnskey != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(dnskey->common.rdtype == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
2015-09-10 14:50:20 +10:00
|
|
|
generic_freestruct_key(source);
|
2003-09-30 06:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
additionaldata_dnskey(ARGS_ADDLDATA) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(owner);
|
2003-09-30 06:00:40 +00:00
|
|
|
UNUSED(add);
|
|
|
|
UNUSED(arg);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
digest_dnskey(ARGS_DIGEST) {
|
2003-09-30 06:00:40 +00:00
|
|
|
isc_region_t r;
|
|
|
|
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(rdata != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_dnskey);
|
2003-09-30 06:00:40 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
|
|
|
|
return ((digest)(arg, &r));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checkowner_dnskey(ARGS_CHECKOWNER) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_dnskey);
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
UNUSED(name);
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(wildcard);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checknames_dnskey(ARGS_CHECKNAMES) {
|
2015-09-10 14:50:20 +10:00
|
|
|
REQUIRE(rdata != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_dnskey);
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
|
|
|
UNUSED(owner);
|
|
|
|
UNUSED(bad);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
casecompare_dnskey(ARGS_COMPARE) {
|
2009-12-04 21:09:34 +00:00
|
|
|
/*
|
2020-02-20 14:49:36 -08:00
|
|
|
* Treat ALG 253 (private DNS) subtype name case sensitively.
|
2009-12-04 21:09:34 +00:00
|
|
|
*/
|
|
|
|
return (compare_dnskey(rdata1, rdata2));
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#endif /* RDATA_GENERIC_DNSKEY_48_C */
|