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