Merge from vendor branch OPENSSH:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / dnssec.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and 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: dnssec.h,v 1.21.2.1 2004/03/09 06:11:15 marka Exp $ */
19
20 #ifndef DNS_DNSSEC_H
21 #define DNS_DNSSEC_H 1
22
23 #include <isc/lang.h>
24 #include <isc/stdtime.h>
25
26 #include <dns/types.h>
27
28 #include <dst/dst.h>
29
30 ISC_LANG_BEGINDECLS
31
32 isc_result_t
33 dns_dnssec_keyfromrdata(dns_name_t *name, dns_rdata_t *rdata, isc_mem_t *mctx,
34                         dst_key_t **key);
35 /*
36  *      Creates a DST key from a DNS record.  Basically a wrapper around
37  *      dst_key_fromdns().
38  *
39  *      Requires:
40  *              'name' is not NULL
41  *              'rdata' is not NULL
42  *              'mctx' is not NULL
43  *              'key' is not NULL
44  *              '*key' is NULL
45  *
46  *      Returns:
47  *              ISC_R_SUCCESS
48  *              ISC_R_NOMEMORY
49  *              DST_R_INVALIDPUBLICKEY
50  *              various errors from dns_name_totext
51  */
52
53 isc_result_t
54 dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
55                 isc_stdtime_t *inception, isc_stdtime_t *expire,
56                 isc_mem_t *mctx, isc_buffer_t *buffer, dns_rdata_t *sigrdata);
57 /*
58  *      Generates a SIG record covering this rdataset.  This has no effect
59  *      on existing SIG records.
60  *
61  *      Requires:
62  *              'name' (the owner name of the record) is a valid name
63  *              'set' is a valid rdataset
64  *              'key' is a valid key
65  *              'inception' is not NULL
66  *              'expire' is not NULL
67  *              'mctx' is not NULL
68  *              'buffer' is not NULL
69  *              'sigrdata' is not NULL
70  *
71  *      Returns:
72  *              ISC_R_SUCCESS
73  *              ISC_R_NOMEMORY
74  *              ISC_R_NOSPACE
75  *              DNS_R_INVALIDTIME - the expiration is before the inception
76  *              DNS_R_KEYUNAUTHORIZED - the key cannot sign this data (either
77  *                      it is not a zone key or its flags prevent
78  *                      authentication)
79  *              DST_R_*
80  */
81
82 isc_result_t
83 dns_dnssec_verify(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
84                   isc_boolean_t ignoretime, isc_mem_t *mctx,
85                   dns_rdata_t *sigrdata);
86 /*
87  *      Verifies the SIG record covering this rdataset signed by a specific
88  *      key.  This does not determine if the key's owner is authorized to
89  *      sign this record, as this requires a resolver or database.
90  *      If 'ignoretime' is ISC_TRUE, temporal validity will not be checked.
91  *
92  *      Requires:
93  *              'name' (the owner name of the record) is a valid name
94  *              'set' is a valid rdataset
95  *              'key' is a valid key
96  *              'mctx' is not NULL
97  *              'sigrdata' is a valid rdata containing a SIG record
98  *
99  *      Returns:
100  *              ISC_R_SUCCESS
101  *              ISC_R_NOMEMORY
102  *              DNS_R_SIGINVALID - the signature fails to verify
103  *              DNS_R_SIGEXPIRED - the signature has expired
104  *              DNS_R_SIGFUTURE - the signature's validity period has not begun
105  *              DNS_R_KEYUNAUTHORIZED - the key cannot sign this data (either
106  *                      it is not a zone key or its flags prevent
107  *                      authentication)
108  *              DST_R_*
109  */
110
111 isc_result_t
112 dns_dnssec_findzonekeys(dns_db_t *db, dns_dbversion_t *ver, dns_dbnode_t *node,
113                         dns_name_t *name, isc_mem_t *mctx,
114                         unsigned int maxkeys, dst_key_t **keys,
115                         unsigned int *nkeys);
116 /*
117  *      Finds a set of zone keys.
118  *      XXX temporary - this should be handled in dns_zone_t.
119  */
120
121 isc_result_t
122 dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key);
123 /*
124  *      Signs a message with a SIG(0) record.  This is implicitly called by
125  *      dns_message_renderend() if msg->sig0key is not NULL.
126  *
127  *      Requires:
128  *              'msg' is a valid message
129  *              'key' is a valid key that can be used for signing
130  *
131  *      Returns:
132  *              ISC_R_SUCCESS
133  *              ISC_R_NOMEMORY
134  *              DST_R_*
135  */
136
137 isc_result_t
138 dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
139                          dst_key_t *key);
140 /*
141  *      Verifies a message signed by a SIG(0) record.  This is not
142  *      called implicitly by dns_message_parse().  If dns_message_signer()
143  *      is called before dns_dnssec_verifymessage(), it will return
144  *      DNS_R_SIGNOTVERIFIEDYET.  dns_dnssec_verifymessage() will set
145  *      the verified_sig0 flag in msg if the verify succeeds, and
146  *      the sig0status field otherwise.
147  *
148  *      Requires:
149  *              'source' is a valid buffer containing the unparsed message
150  *              'msg' is a valid message
151  *              'key' is a valid key
152  *
153  *      Returns:
154  *              ISC_R_SUCCESS
155  *              ISC_R_NOMEMORY
156  *              ISC_R_NOTFOUND - no SIG(0) was found
157  *              DNS_R_SIGINVALID - the SIG record is not well-formed or
158  *                                 was not generated by the key.
159  *              DST_R_*
160  */
161
162 ISC_LANG_ENDDECLS
163
164 #endif /* DNS_DNSSEC_H */