1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 * 8 * See the COPYRIGHT file distributed with this work for additional 9 * information regarding copyright ownership. 10 */ 11 12 /*! \file */ 13 14 #include <stdbool.h> 15 16 #include <isc/result.h> 17 #include <isc/types.h> 18 #include <isc/util.h> 19 20 #include <dns/keyvalues.h> 21 #include <dns/rdata.h> 22 #include <dns/rdatastruct.h> 23 #include <dns/types.h> 24 #include <dns/zonekey.h> 25 26 bool dns_zonekey_iszonekey(dns_rdata_t * keyrdata)27dns_zonekey_iszonekey(dns_rdata_t *keyrdata) { 28 isc_result_t result; 29 dns_rdata_dnskey_t key; 30 bool iszonekey = true; 31 32 REQUIRE(keyrdata != NULL); 33 34 result = dns_rdata_tostruct(keyrdata, &key, NULL); 35 if (result != ISC_R_SUCCESS) { 36 return (false); 37 } 38 39 if ((key.flags & DNS_KEYTYPE_NOAUTH) != 0) { 40 iszonekey = false; 41 } 42 if ((key.flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE) { 43 iszonekey = false; 44 } 45 if (key.protocol != DNS_KEYPROTO_DNSSEC && 46 key.protocol != DNS_KEYPROTO_ANY) { 47 iszonekey = false; 48 } 49 50 return (iszonekey); 51 } 52