BIND: update vendor tree to 9.5.2-P2
[dragonfly.git] / contrib / bind / lib / dns / zonekey.c
1 /*
2  * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2001, 2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: zonekey.c,v 1.9 2007/06/19 23:47:16 tbox Exp $ */
19
20 /*! \file */
21
22 #include <config.h>
23
24 #include <isc/result.h>
25 #include <isc/types.h>
26 #include <isc/util.h>
27
28 #include <dns/keyvalues.h>
29 #include <dns/rdata.h>
30 #include <dns/rdatastruct.h>
31 #include <dns/types.h>
32 #include <dns/zonekey.h>
33
34 isc_boolean_t
35 dns_zonekey_iszonekey(dns_rdata_t *keyrdata) {
36         isc_result_t result;
37         dns_rdata_dnskey_t key;
38         isc_boolean_t iszonekey = ISC_TRUE;
39
40         REQUIRE(keyrdata != NULL);
41
42         result = dns_rdata_tostruct(keyrdata, &key, NULL);
43         if (result != ISC_R_SUCCESS)
44                 return (ISC_FALSE);
45
46         if ((key.flags & DNS_KEYTYPE_NOAUTH) != 0)
47                 iszonekey = ISC_FALSE;
48         if ((key.flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE)
49                 iszonekey = ISC_FALSE;
50         if (key.protocol != DNS_KEYPROTO_DNSSEC &&
51         key.protocol != DNS_KEYPROTO_ANY)
52                 iszonekey = ISC_FALSE;
53         
54         return (iszonekey);
55 }