From 90ed76b1cf728b4c24857ebd64a7dcac29ffc7f9 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 24 Jun 2021 10:13:11 +1000 Subject: [PATCH] Add dns_zonemd_supported --- lib/dns/include/dns/zonemd.h | 3 +++ lib/dns/zonemd.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/dns/include/dns/zonemd.h b/lib/dns/include/dns/zonemd.h index 357a23345f..a6061478ac 100644 --- a/lib/dns/include/dns/zonemd.h +++ b/lib/dns/include/dns/zonemd.h @@ -22,3 +22,6 @@ dns_zonemd_buildrdata(dns_rdata_t *rdata, dns_db_t *db, dns_dbversion_t *version, uint8_t scheme, uint8_t algorithm, isc_mem_t *mctx, unsigned char *buf, size_t size); + +bool +dns_zonemd_supported(dns_rdata_t *rdata); diff --git a/lib/dns/zonemd.c b/lib/dns/zonemd.c index a72c3c25d8..80ebe709dd 100644 --- a/lib/dns/zonemd.c +++ b/lib/dns/zonemd.c @@ -427,3 +427,23 @@ dns_zonemd_buildrdata(dns_rdata_t *rdata, dns_db_t *db, return ISC_R_NOTIMPLEMENTED; } } + +bool +dns_zonemd_supported(dns_rdata_t *rdata) { + REQUIRE(rdata != NULL); + REQUIRE(rdata->length >= 6); + REQUIRE(rdata->type == dns_rdatatype_zonemd); + + switch (rdata->data[4]) { + case DNS_ZONEMD_SCHEME_SIMPLE: + switch (rdata->data[5]) { + case DNS_ZONEMD_DIGEST_SHA384: + case DNS_ZONEMD_DIGEST_SHA512: + return true; + default: + return false; + } + default: + return false; + } +}