1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 * PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef RDATA_GENERIC_OPENPGPKEY_61_C 18 #define RDATA_GENERIC_OPENPGPKEY_61_C 19 20 static inline isc_result_t 21 totext_openpgpkey(ARGS_TOTEXT) { 22 isc_region_t sr; 23 24 REQUIRE(rdata->type == dns_rdatatype_openpgpkey); 25 REQUIRE(rdata->length != 0); 26 27 dns_rdata_toregion(rdata, &sr); 28 29 /* 30 * Keyring 31 */ 32 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) 33 RETERR(isc_str_tobuffer("( ", target)); 34 35 if ((tctx->flags & DNS_STYLEFLAG_NOCRYPTO) == 0) { 36 if (tctx->width == 0) /* No splitting */ 37 RETERR(isc_base64_totext(&sr, 60, "", target)); 38 else 39 RETERR(isc_base64_totext(&sr, tctx->width - 2, 40 tctx->linebreak, target)); 41 } else 42 RETERR(isc_str_tobuffer("[omitted]", target)); 43 44 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) 45 RETERR(isc_str_tobuffer(" )", target)); 46 47 return (ISC_R_SUCCESS); 48 } 49 50 static inline isc_result_t 51 fromwire_openpgpkey(ARGS_FROMWIRE) { 52 isc_region_t sr; 53 54 REQUIRE(type == dns_rdatatype_openpgpkey); 55 56 UNUSED(type); 57 UNUSED(rdclass); 58 UNUSED(dctx); 59 UNUSED(options); 60 61 /* 62 * Keyring. 63 */ 64 isc_buffer_activeregion(source, &sr); 65 if (sr.length < 1) 66 return (ISC_R_UNEXPECTEDEND); 67 isc_buffer_forward(source, sr.length); 68 return (isc_mem_tobuffer(target, sr.base, sr.length)); 69 } 70 71 static inline isc_result_t 72 towire_openpgpkey(ARGS_TOWIRE) { 73 isc_region_t sr; 74 75 REQUIRE(rdata->type == dns_rdatatype_openpgpkey); 76 REQUIRE(rdata->length != 0); 77 78 UNUSED(cctx); 79 80 dns_rdata_toregion(rdata, &sr); 81 return (isc_mem_tobuffer(target, sr.base, sr.length)); 82 } 83 84 #endif /* RDATA_GENERIC_OPENPGPKEY_61_C */ 85