Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / openpgpkey_61.c
blobac4b10af88f23ec72a17ee0e879b31dc88bfe039
1 /* $NetBSD: openpgpkey_61.c,v 1.1.1.2 2015/09/03 07:21:39 christos Exp $ */
3 /*
4 * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
19 #ifndef RDATA_GENERIC_OPENPGPKEY_61_C
20 #define RDATA_GENERIC_OPENPGPKEY_61_C
22 #define RRTYPE_OPENPGPKEY_ATTRIBUTES 0
24 static inline isc_result_t
25 fromtext_openpgpkey(ARGS_FROMTEXT) {
27 REQUIRE(type == 61);
29 UNUSED(type);
30 UNUSED(rdclass);
31 UNUSED(callbacks);
32 UNUSED(options);
33 UNUSED(origin);
36 * Keyring.
38 return (isc_base64_tobuffer(lexer, target, -1));
41 static inline isc_result_t
42 totext_openpgpkey(ARGS_TOTEXT) {
43 isc_region_t sr;
45 REQUIRE(rdata->type == 61);
46 REQUIRE(rdata->length != 0);
48 dns_rdata_toregion(rdata, &sr);
51 * Keyring
53 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
54 RETERR(str_totext("( ", target));
56 if ((tctx->flags & DNS_STYLEFLAG_NOCRYPTO) == 0) {
57 if (tctx->width == 0) /* No splitting */
58 RETERR(isc_base64_totext(&sr, 60, "", target));
59 else
60 RETERR(isc_base64_totext(&sr, tctx->width - 2,
61 tctx->linebreak, target));
62 } else
63 RETERR(str_totext("[omitted]", target));
65 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
66 RETERR(str_totext(" )", target));
68 return (ISC_R_SUCCESS);
71 static inline isc_result_t
72 fromwire_openpgpkey(ARGS_FROMWIRE) {
73 isc_region_t sr;
75 REQUIRE(type == 61);
77 UNUSED(type);
78 UNUSED(rdclass);
79 UNUSED(dctx);
80 UNUSED(options);
83 * Keyring.
85 isc_buffer_activeregion(source, &sr);
86 if (sr.length < 1)
87 return (ISC_R_UNEXPECTEDEND);
88 isc_buffer_forward(source, sr.length);
89 return (mem_tobuffer(target, sr.base, sr.length));
92 static inline isc_result_t
93 towire_openpgpkey(ARGS_TOWIRE) {
94 isc_region_t sr;
96 REQUIRE(rdata->type == 61);
97 REQUIRE(rdata->length != 0);
99 UNUSED(cctx);
101 dns_rdata_toregion(rdata, &sr);
102 return (mem_tobuffer(target, sr.base, sr.length));
105 static inline int
106 compare_openpgpkey(ARGS_COMPARE) {
107 isc_region_t r1;
108 isc_region_t r2;
110 REQUIRE(rdata1->type == rdata2->type);
111 REQUIRE(rdata1->rdclass == rdata2->rdclass);
112 REQUIRE(rdata1->type == 61);
113 REQUIRE(rdata1->length != 0);
114 REQUIRE(rdata2->length != 0);
116 dns_rdata_toregion(rdata1, &r1);
117 dns_rdata_toregion(rdata2, &r2);
118 return (isc_region_compare(&r1, &r2));
121 static inline isc_result_t
122 fromstruct_openpgpkey(ARGS_FROMSTRUCT) {
123 dns_rdata_openpgpkey_t *sig = source;
125 REQUIRE(type == 61);
126 REQUIRE(source != NULL);
127 REQUIRE(sig->common.rdtype == type);
128 REQUIRE(sig->common.rdclass == rdclass);
129 REQUIRE(sig->keyring != NULL && sig->length != 0);
131 UNUSED(type);
132 UNUSED(rdclass);
135 * Keyring.
137 return (mem_tobuffer(target, sig->keyring, sig->length));
140 static inline isc_result_t
141 tostruct_openpgpkey(ARGS_TOSTRUCT) {
142 isc_region_t sr;
143 dns_rdata_openpgpkey_t *sig = target;
145 REQUIRE(rdata->type == 61);
146 REQUIRE(target != NULL);
147 REQUIRE(rdata->length != 0);
149 sig->common.rdclass = rdata->rdclass;
150 sig->common.rdtype = rdata->type;
151 ISC_LINK_INIT(&sig->common, link);
153 dns_rdata_toregion(rdata, &sr);
156 * Keyring.
158 sig->length = sr.length;
159 sig->keyring = mem_maybedup(mctx, sr.base, sig->length);
160 if (sig->keyring == NULL)
161 goto cleanup;
163 sig->mctx = mctx;
164 return (ISC_R_SUCCESS);
166 cleanup:
167 return (ISC_R_NOMEMORY);
170 static inline void
171 freestruct_openpgpkey(ARGS_FREESTRUCT) {
172 dns_rdata_openpgpkey_t *sig = (dns_rdata_openpgpkey_t *) source;
174 REQUIRE(source != NULL);
175 REQUIRE(sig->common.rdtype == 61);
177 if (sig->mctx == NULL)
178 return;
180 if (sig->keyring != NULL)
181 isc_mem_free(sig->mctx, sig->keyring);
182 sig->mctx = NULL;
185 static inline isc_result_t
186 additionaldata_openpgpkey(ARGS_ADDLDATA) {
187 REQUIRE(rdata->type == 61);
189 UNUSED(rdata);
190 UNUSED(add);
191 UNUSED(arg);
193 return (ISC_R_SUCCESS);
196 static inline isc_result_t
197 digest_openpgpkey(ARGS_DIGEST) {
198 isc_region_t r;
200 REQUIRE(rdata->type == 61);
202 dns_rdata_toregion(rdata, &r);
204 return ((digest)(arg, &r));
207 static inline isc_boolean_t
208 checkowner_openpgpkey(ARGS_CHECKOWNER) {
210 REQUIRE(type == 61);
212 UNUSED(name);
213 UNUSED(type);
214 UNUSED(rdclass);
215 UNUSED(wildcard);
217 return (ISC_TRUE);
220 static inline isc_boolean_t
221 checknames_openpgpkey(ARGS_CHECKNAMES) {
223 REQUIRE(rdata->type == 61);
225 UNUSED(rdata);
226 UNUSED(owner);
227 UNUSED(bad);
229 return (ISC_TRUE);
232 static inline int
233 casecompare_openpgpkey(ARGS_COMPARE) {
234 isc_region_t r1;
235 isc_region_t r2;
237 REQUIRE(rdata1->type == rdata2->type);
238 REQUIRE(rdata1->rdclass == rdata2->rdclass);
239 REQUIRE(rdata1->type == 61);
240 REQUIRE(rdata1->length != 0);
241 REQUIRE(rdata2->length != 0);
243 dns_rdata_toregion(rdata1, &r1);
244 dns_rdata_toregion(rdata2, &r2);
246 return (isc_region_compare(&r1, &r2));
249 #endif /* RDATA_GENERIC_OPENPGPKEY_61_C */