6fb9b25791778f69002eb72be6235e20d98ec452Tinderbox User * Copyright (C) 2009, 2011-2013, 2015-2017 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* refresh timer */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &refresh));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* add hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &addhd));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* remove hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &removehd));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETTOK(dns_keyflags_fromtext(&flags, &token.value.as_textregion));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* protocol */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETTOK(dns_secproto_fromtext(&proto, &token.value.as_textregion));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* algorithm */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* No Key? */
5f630b9417a01321f73662202e63922eccea5900Evan Hunt /* Ensure there's at least enough data to compute a key ID for MD5 */
5f630b9417a01321f73662202e63922eccea5900Evan Hunt if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 19)
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_keydata);
d6f99498d624d5c5c8ee45067df02e6a6b35a1a3Mark Andrews if ((tctx->flags & DNS_STYLEFLAG_KEYDATA) == 0 || rdata->length < 16)
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* refresh timer */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* add hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* remove hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* protocol */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* algorithm */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* No Key? */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
9a859983d7059a6eb9c877c1d2ac6a3a5b7170f7Evan Hunt if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
9a859983d7059a6eb9c877c1d2ac6a3a5b7170f7Evan Hunt dns_secalg_format((dns_secalg_t) algorithm, algbuf,
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Skip over refresh, addhd, and removehd */
591389c7d44e5ca20c357627dd179772cfefaaccEvan Hunt if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
591389c7d44e5ca20c357627dd179772cfefaaccEvan Hunt isc_time_formathttptimestamp(&t, rbuf, sizeof(rbuf));
072ce62d236a377b6ef442bd43948ceda1220026Mark Andrews if (add == 0U) {
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt return (mem_tobuffer(target, sr.base, sr.length));
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_keydata);
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt return (mem_tobuffer(target, sr.base, sr.length));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Huntstatic inline int
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata1->type == dns_rdatatype_keydata);
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Refresh timer */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(uint32_tobuffer(keydata->refresh, target));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Add hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Remove hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(uint32_tobuffer(keydata->removehd, target));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Protocol */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(uint8_tobuffer(keydata->protocol, target));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Algorithm */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt RETERR(uint8_tobuffer(keydata->algorithm, target));
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt return (mem_tobuffer(target, keydata->data, keydata->datalen));
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_keydata);
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Refresh timer */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Add hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Remove hold-down */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Protocol */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt /* Algorithm */
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt keydata->data = mem_maybedup(mctx, sr.base, keydata->datalen);
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Huntstatic inline void
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt dns_rdata_keydata_t *keydata = (dns_rdata_keydata_t *) source;
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(keydata->common.rdtype == dns_rdatatype_keydata);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_keydata);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_keydata);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_keydata);
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewsstatic inline int
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt#endif /* GENERIC_KEYDATA_65533_C */