keydata_65533.c revision 6fb9b25791778f69002eb72be6235e20d98ec452
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt/*
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater * Copyright (C) 2009, 2011-2013, 2015-2017 Internet Systems Consortium, Inc. ("ISC")
a6ca100924894cdd8e2b791d75a8cef32b1fba1fTinderbox User *
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater * This Source Code Form is subject to the terms of the Mozilla Public
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater * License, v. 2.0. If a copy of the MPL was not distributed with this
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater * file, You can obtain one at http://mozilla.org/MPL/2.0/.
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater */
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater#ifndef GENERIC_KEYDATA_65533_C
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater#define GENERIC_KEYDATA_65533_C 1
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater#include <isc/time.h>
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater#include <isc/stdtime.h>
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater#include <dst/dst.h>
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater
f1c89cb4f5c72c54bb67dc48cd6f2b332eab9e92Automatic Updater#define RRTYPE_KEYDATA_ATTRIBUTES (0)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntstatic inline isc_result_t
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntfromtext_keydata(ARGS_FROMTEXT) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_result_t result;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_token_t token;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_secalg_t alg;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_secproto_t proto;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_keyflags_t flags;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_uint32_t refresh, addhd, removehd;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(type == dns_rdatatype_keydata);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(type);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(rdclass);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(origin);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(options);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(callbacks);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* refresh timer */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt ISC_FALSE));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &refresh));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(uint32_tobuffer(refresh, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* add hold-down */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt ISC_FALSE));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &addhd));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(uint32_tobuffer(addhd, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* remove hold-down */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt ISC_FALSE));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &removehd));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(uint32_tobuffer(removehd, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* flags */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt ISC_FALSE));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETTOK(dns_keyflags_fromtext(&flags, &token.value.as_textregion));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(uint16_tobuffer(flags, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* protocol */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt ISC_FALSE));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETTOK(dns_secproto_fromtext(&proto, &token.value.as_textregion));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(mem_tobuffer(target, &proto, 1));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* algorithm */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt ISC_FALSE));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(mem_tobuffer(target, &alg, 1));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* No Key? */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((flags & 0xc000) == 0xc000)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (ISC_R_SUCCESS);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt result = isc_base64_tobuffer(lexer, target, -1);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if (result != ISC_R_SUCCESS)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (result);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* Ensure there's at least enough data to compute a key ID for MD5 */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 19)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (ISC_R_UNEXPECTEDEND);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (ISC_R_SUCCESS);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt}
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntstatic inline isc_result_t
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunttotext_keydata(ARGS_TOTEXT) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_t sr;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt char buf[sizeof("64000")];
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt unsigned int flags;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt unsigned char algorithm;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt unsigned long refresh, add, deltime;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt char algbuf[DNS_NAME_FORMATSIZE];
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt const char *keyinfo;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(rdata->type == dns_rdatatype_keydata);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((tctx->flags & DNS_STYLEFLAG_KEYDATA) == 0 || rdata->length < 16)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (unknown_totext(rdata, tctx, target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_rdata_toregion(rdata, &sr);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* refresh timer */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt refresh = uint32_fromregion(&sr);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_consume(&sr, 4);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(dns_time32_totext(refresh, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(" ", target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt /* add hold-down */
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt add = uint32_fromregion(&sr);
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt isc_region_consume(&sr, 4);
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(dns_time32_totext(add, target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(str_totext(" ", target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt
87002e151b8507e2deb8a72e475b77a87cb35045Automatic Updater /* remove hold-down */
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt deltime = uint32_fromregion(&sr);
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt isc_region_consume(&sr, 4);
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(dns_time32_totext(deltime, target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(str_totext(" ", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt /* flags */
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews flags = uint16_fromregion(&sr);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews isc_region_consume(&sr, 2);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews sprintf(buf, "%u", flags);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext(buf, target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(str_totext(" ", target));
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt if ((flags & DNS_KEYFLAG_KSK) != 0) {
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt if (flags & DNS_KEYFLAG_REVOKE)
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt keyinfo = "revoked KSK";
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt else
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt keyinfo = "KSK";
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt } else
03f979494f5c80e05a72f876914d9d44085fbd6aEvan Hunt keyinfo = "ZSK";
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt /* protocol */
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt sprintf(buf, "%u", sr.base[0]);
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt isc_region_consume(&sr, 1);
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(str_totext(buf, target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt RETERR(str_totext(" ", target));
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt /* algorithm */
79ce3a9e82384cc31fd6b86be8f3d1474fcfd9f4Evan Hunt algorithm = sr.base[0];
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt sprintf(buf, "%u", algorithm);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_consume(&sr, 1);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(buf, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* No Key? */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((flags & 0xc000) == 0xc000)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (ISC_R_SUCCESS);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* key */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(" (", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(tctx->linebreak, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if (tctx->width == 0) /* No splitting */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_base64_totext(&sr, 60, "", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt else
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(isc_base64_totext(&sr, tctx->width - 2,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt tctx->linebreak, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(tctx->linebreak, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(" ", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(")", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_t tmpr;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt char rbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt char abuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt char dbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_time_t t;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(" ; ", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(keyinfo, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_secalg_format((dns_secalg_t) algorithm, algbuf,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt sizeof(algbuf));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext("; alg = ", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(algbuf, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext("; key id = ", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_rdata_toregion(rdata, &tmpr);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* Skip over refresh, addhd, and removehd */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_consume(&tmpr, 12);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt sprintf(buf, "%u", dst_region_computeid(&tmpr, algorithm));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(buf, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_stdtime_t now;
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews isc_stdtime_get(&now);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext(tctx->linebreak, target));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext("; next refresh: ", target));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews isc_time_set(&t, refresh, 0);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews isc_time_formathttptimestamp(&t, rbuf, sizeof(rbuf));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext(rbuf, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if (add == 0U) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(tctx->linebreak, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext("; no trust", target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt } else {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(tctx->linebreak, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt if (add < now) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext("; trusted since: ",
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt } else {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext("; trust pending: ",
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt }
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_time_set(&t, add, 0);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_time_formathttptimestamp(&t, abuf,
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt sizeof(abuf));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(str_totext(abuf, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt }
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews if (deltime != 0U) {
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext(tctx->linebreak, target));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext("; removal pending: ",
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews target));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews isc_time_set(&t, deltime, 0);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews isc_time_formathttptimestamp(&t, dbuf,
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews sizeof(dbuf));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews RETERR(str_totext(dbuf, target));
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews }
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews }
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews }
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews return (ISC_R_SUCCESS);
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews}
c6f4972c745f8903aba6dcca41f17a44c473db66Mark Andrews
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntstatic inline isc_result_t
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntfromwire_keydata(ARGS_FROMWIRE) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_t sr;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(type == dns_rdatatype_keydata);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(type);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(rdclass);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(dctx);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(options);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_buffer_activeregion(source, &sr);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_buffer_forward(source, sr.length);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (mem_tobuffer(target, sr.base, sr.length));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt}
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntstatic inline isc_result_t
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunttowire_keydata(ARGS_TOWIRE) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_t sr;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(rdata->type == dns_rdatatype_keydata);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(cctx);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_rdata_toregion(rdata, &sr);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (mem_tobuffer(target, sr.base, sr.length));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt}
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntstatic inline int
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntcompare_keydata(ARGS_COMPARE) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_t r1;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt isc_region_t r2;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(rdata1->type == rdata2->type);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(rdata1->rdclass == rdata2->rdclass);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(rdata1->type == dns_rdatatype_keydata);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_rdata_toregion(rdata1, &r1);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_rdata_toregion(rdata2, &r2);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt return (isc_region_compare(&r1, &r2));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt}
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
2637d30fbd235fe98145f4312b10cc41a13bf7dcJeremy C. Reedstatic inline isc_result_t
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Huntfromstruct_keydata(ARGS_FROMSTRUCT) {
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt dns_rdata_keydata_t *keydata = source;
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(type == dns_rdatatype_keydata);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(source != NULL);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(keydata->common.rdtype == type);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt REQUIRE(keydata->common.rdclass == rdclass);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(type);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt UNUSED(rdclass);
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* Refresh timer */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(uint32_tobuffer(keydata->refresh, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* Add hold-down */
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt RETERR(uint32_tobuffer(keydata->addhd, target));
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt
0b24b2d3c423560a0a4cd9a4476b9a2dcafb7ea3Evan Hunt /* Remove hold-down */
RETERR(uint32_tobuffer(keydata->removehd, target));
/* Flags */
RETERR(uint16_tobuffer(keydata->flags, target));
/* Protocol */
RETERR(uint8_tobuffer(keydata->protocol, target));
/* Algorithm */
RETERR(uint8_tobuffer(keydata->algorithm, target));
/* Data */
return (mem_tobuffer(target, keydata->data, keydata->datalen));
}
static inline isc_result_t
tostruct_keydata(ARGS_TOSTRUCT) {
dns_rdata_keydata_t *keydata = target;
isc_region_t sr;
REQUIRE(rdata->type == dns_rdatatype_keydata);
REQUIRE(target != NULL);
keydata->common.rdclass = rdata->rdclass;
keydata->common.rdtype = rdata->type;
ISC_LINK_INIT(&keydata->common, link);
dns_rdata_toregion(rdata, &sr);
/* Refresh timer */
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
keydata->refresh = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/* Add hold-down */
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
keydata->addhd = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/* Remove hold-down */
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
keydata->removehd = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/* Flags */
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
keydata->flags = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/* Protocol */
if (sr.length < 1)
return (ISC_R_UNEXPECTEDEND);
keydata->protocol = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
/* Algorithm */
if (sr.length < 1)
return (ISC_R_UNEXPECTEDEND);
keydata->algorithm = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
/* Data */
keydata->datalen = sr.length;
keydata->data = mem_maybedup(mctx, sr.base, keydata->datalen);
if (keydata->data == NULL)
return (ISC_R_NOMEMORY);
keydata->mctx = mctx;
return (ISC_R_SUCCESS);
}
static inline void
freestruct_keydata(ARGS_FREESTRUCT) {
dns_rdata_keydata_t *keydata = (dns_rdata_keydata_t *) source;
REQUIRE(source != NULL);
REQUIRE(keydata->common.rdtype == dns_rdatatype_keydata);
if (keydata->mctx == NULL)
return;
if (keydata->data != NULL)
isc_mem_free(keydata->mctx, keydata->data);
keydata->mctx = NULL;
}
static inline isc_result_t
additionaldata_keydata(ARGS_ADDLDATA) {
REQUIRE(rdata->type == dns_rdatatype_keydata);
UNUSED(rdata);
UNUSED(add);
UNUSED(arg);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
digest_keydata(ARGS_DIGEST) {
isc_region_t r;
REQUIRE(rdata->type == dns_rdatatype_keydata);
dns_rdata_toregion(rdata, &r);
return ((digest)(arg, &r));
}
static inline isc_boolean_t
checkowner_keydata(ARGS_CHECKOWNER) {
REQUIRE(type == dns_rdatatype_keydata);
UNUSED(name);
UNUSED(type);
UNUSED(rdclass);
UNUSED(wildcard);
return (ISC_TRUE);
}
static inline isc_boolean_t
checknames_keydata(ARGS_CHECKNAMES) {
REQUIRE(rdata->type == dns_rdatatype_keydata);
UNUSED(rdata);
UNUSED(owner);
UNUSED(bad);
return (ISC_TRUE);
}
static inline int
casecompare_keydata(ARGS_COMPARE) {
return (compare_keydata(rdata1, rdata2));
}
#endif /* GENERIC_KEYDATA_65533_C */