From f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:15:43 +0200 Subject: Adding upstream version 2.4.1. Signed-off-by: Daniel Baumann --- src/lib/dns/rdata/any_255/tsig_250.cc | 567 +++++++++++++++++++ src/lib/dns/rdata/any_255/tsig_250.h | 148 +++++ src/lib/dns/rdata/ch_3/a_1.cc | 64 +++ src/lib/dns/rdata/ch_3/a_1.h | 32 ++ src/lib/dns/rdata/generic/afsdb_18.cc | 201 +++++++ src/lib/dns/rdata/generic/afsdb_18.h | 68 +++ src/lib/dns/rdata/generic/caa_257.cc | 298 ++++++++++ src/lib/dns/rdata/generic/caa_257.h | 64 +++ src/lib/dns/rdata/generic/cname_5.cc | 125 +++++ src/lib/dns/rdata/generic/cname_5.h | 39 ++ src/lib/dns/rdata/generic/detail/char_string.cc | 264 +++++++++ src/lib/dns/rdata/generic/detail/char_string.h | 140 +++++ src/lib/dns/rdata/generic/detail/ds_like.h | 277 ++++++++++ src/lib/dns/rdata/generic/detail/lexer_util.h | 62 +++ .../dns/rdata/generic/detail/nsec3param_common.cc | 115 ++++ .../dns/rdata/generic/detail/nsec3param_common.h | 123 +++++ src/lib/dns/rdata/generic/detail/nsec_bitmap.cc | 169 ++++++ src/lib/dns/rdata/generic/detail/nsec_bitmap.h | 103 ++++ src/lib/dns/rdata/generic/detail/txt_like.h | 237 ++++++++ src/lib/dns/rdata/generic/dlv_32769.cc | 120 ++++ src/lib/dns/rdata/generic/dlv_32769.h | 69 +++ src/lib/dns/rdata/generic/dname_39.cc | 127 +++++ src/lib/dns/rdata/generic/dname_39.h | 39 ++ src/lib/dns/rdata/generic/dnskey_48.cc | 316 +++++++++++ src/lib/dns/rdata/generic/dnskey_48.h | 60 ++ src/lib/dns/rdata/generic/ds_43.cc | 90 +++ src/lib/dns/rdata/generic/ds_43.h | 69 +++ src/lib/dns/rdata/generic/hinfo_13.cc | 151 +++++ src/lib/dns/rdata/generic/hinfo_13.h | 64 +++ src/lib/dns/rdata/generic/minfo_14.cc | 173 ++++++ src/lib/dns/rdata/generic/minfo_14.h | 74 +++ src/lib/dns/rdata/generic/mx_15.cc | 160 ++++++ src/lib/dns/rdata/generic/mx_15.h | 52 ++ src/lib/dns/rdata/generic/naptr_35.cc | 256 +++++++++ src/lib/dns/rdata/generic/naptr_35.h | 64 +++ src/lib/dns/rdata/generic/ns_2.cc | 121 ++++ src/lib/dns/rdata/generic/ns_2.h | 43 ++ src/lib/dns/rdata/generic/nsec3_50.cc | 343 ++++++++++++ src/lib/dns/rdata/generic/nsec3_50.h | 54 ++ src/lib/dns/rdata/generic/nsec3param_51.cc | 232 ++++++++ src/lib/dns/rdata/generic/nsec3param_51.h | 56 ++ src/lib/dns/rdata/generic/nsec_47.cc | 216 ++++++++ src/lib/dns/rdata/generic/nsec_47.h | 53 ++ src/lib/dns/rdata/generic/opt_41.cc | 219 ++++++++ src/lib/dns/rdata/generic/opt_41.h | 90 +++ src/lib/dns/rdata/generic/ptr_12.cc | 123 +++++ src/lib/dns/rdata/generic/ptr_12.h | 44 ++ src/lib/dns/rdata/generic/rp_17.cc | 160 ++++++ src/lib/dns/rdata/generic/rp_17.h | 78 +++ src/lib/dns/rdata/generic/rrsig_46.cc | 334 +++++++++++ src/lib/dns/rdata/generic/rrsig_46.h | 54 ++ src/lib/dns/rdata/generic/soa_6.cc | 210 +++++++ src/lib/dns/rdata/generic/soa_6.h | 51 ++ src/lib/dns/rdata/generic/spf_99.cc | 139 +++++ src/lib/dns/rdata/generic/spf_99.h | 72 +++ src/lib/dns/rdata/generic/sshfp_44.cc | 298 ++++++++++ src/lib/dns/rdata/generic/sshfp_44.h | 56 ++ src/lib/dns/rdata/generic/tkey_249.cc | 613 +++++++++++++++++++++ src/lib/dns/rdata/generic/tkey_249.h | 142 +++++ src/lib/dns/rdata/generic/tlsa_52.cc | 342 ++++++++++++ src/lib/dns/rdata/generic/tlsa_52.h | 57 ++ src/lib/dns/rdata/generic/txt_16.cc | 95 ++++ src/lib/dns/rdata/generic/txt_16.h | 46 ++ src/lib/dns/rdata/hs_4/a_1.cc | 64 +++ src/lib/dns/rdata/hs_4/a_1.h | 32 ++ src/lib/dns/rdata/in_1/a_1.cc | 174 ++++++ src/lib/dns/rdata/in_1/a_1.h | 38 ++ src/lib/dns/rdata/in_1/aaaa_28.cc | 153 +++++ src/lib/dns/rdata/in_1/aaaa_28.h | 38 ++ src/lib/dns/rdata/in_1/dhcid_49.cc | 161 ++++++ src/lib/dns/rdata/in_1/dhcid_49.h | 53 ++ src/lib/dns/rdata/in_1/srv_33.cc | 298 ++++++++++ src/lib/dns/rdata/in_1/srv_33.h | 85 +++ src/lib/dns/rdata/template.cc | 67 +++ src/lib/dns/rdata/template.h | 54 ++ 75 files changed, 10538 insertions(+) create mode 100644 src/lib/dns/rdata/any_255/tsig_250.cc create mode 100644 src/lib/dns/rdata/any_255/tsig_250.h create mode 100644 src/lib/dns/rdata/ch_3/a_1.cc create mode 100644 src/lib/dns/rdata/ch_3/a_1.h create mode 100644 src/lib/dns/rdata/generic/afsdb_18.cc create mode 100644 src/lib/dns/rdata/generic/afsdb_18.h create mode 100644 src/lib/dns/rdata/generic/caa_257.cc create mode 100644 src/lib/dns/rdata/generic/caa_257.h create mode 100644 src/lib/dns/rdata/generic/cname_5.cc create mode 100644 src/lib/dns/rdata/generic/cname_5.h create mode 100644 src/lib/dns/rdata/generic/detail/char_string.cc create mode 100644 src/lib/dns/rdata/generic/detail/char_string.h create mode 100644 src/lib/dns/rdata/generic/detail/ds_like.h create mode 100644 src/lib/dns/rdata/generic/detail/lexer_util.h create mode 100644 src/lib/dns/rdata/generic/detail/nsec3param_common.cc create mode 100644 src/lib/dns/rdata/generic/detail/nsec3param_common.h create mode 100644 src/lib/dns/rdata/generic/detail/nsec_bitmap.cc create mode 100644 src/lib/dns/rdata/generic/detail/nsec_bitmap.h create mode 100644 src/lib/dns/rdata/generic/detail/txt_like.h create mode 100644 src/lib/dns/rdata/generic/dlv_32769.cc create mode 100644 src/lib/dns/rdata/generic/dlv_32769.h create mode 100644 src/lib/dns/rdata/generic/dname_39.cc create mode 100644 src/lib/dns/rdata/generic/dname_39.h create mode 100644 src/lib/dns/rdata/generic/dnskey_48.cc create mode 100644 src/lib/dns/rdata/generic/dnskey_48.h create mode 100644 src/lib/dns/rdata/generic/ds_43.cc create mode 100644 src/lib/dns/rdata/generic/ds_43.h create mode 100644 src/lib/dns/rdata/generic/hinfo_13.cc create mode 100644 src/lib/dns/rdata/generic/hinfo_13.h create mode 100644 src/lib/dns/rdata/generic/minfo_14.cc create mode 100644 src/lib/dns/rdata/generic/minfo_14.h create mode 100644 src/lib/dns/rdata/generic/mx_15.cc create mode 100644 src/lib/dns/rdata/generic/mx_15.h create mode 100644 src/lib/dns/rdata/generic/naptr_35.cc create mode 100644 src/lib/dns/rdata/generic/naptr_35.h create mode 100644 src/lib/dns/rdata/generic/ns_2.cc create mode 100644 src/lib/dns/rdata/generic/ns_2.h create mode 100644 src/lib/dns/rdata/generic/nsec3_50.cc create mode 100644 src/lib/dns/rdata/generic/nsec3_50.h create mode 100644 src/lib/dns/rdata/generic/nsec3param_51.cc create mode 100644 src/lib/dns/rdata/generic/nsec3param_51.h create mode 100644 src/lib/dns/rdata/generic/nsec_47.cc create mode 100644 src/lib/dns/rdata/generic/nsec_47.h create mode 100644 src/lib/dns/rdata/generic/opt_41.cc create mode 100644 src/lib/dns/rdata/generic/opt_41.h create mode 100644 src/lib/dns/rdata/generic/ptr_12.cc create mode 100644 src/lib/dns/rdata/generic/ptr_12.h create mode 100644 src/lib/dns/rdata/generic/rp_17.cc create mode 100644 src/lib/dns/rdata/generic/rp_17.h create mode 100644 src/lib/dns/rdata/generic/rrsig_46.cc create mode 100644 src/lib/dns/rdata/generic/rrsig_46.h create mode 100644 src/lib/dns/rdata/generic/soa_6.cc create mode 100644 src/lib/dns/rdata/generic/soa_6.h create mode 100644 src/lib/dns/rdata/generic/spf_99.cc create mode 100644 src/lib/dns/rdata/generic/spf_99.h create mode 100644 src/lib/dns/rdata/generic/sshfp_44.cc create mode 100644 src/lib/dns/rdata/generic/sshfp_44.h create mode 100644 src/lib/dns/rdata/generic/tkey_249.cc create mode 100644 src/lib/dns/rdata/generic/tkey_249.h create mode 100644 src/lib/dns/rdata/generic/tlsa_52.cc create mode 100644 src/lib/dns/rdata/generic/tlsa_52.h create mode 100644 src/lib/dns/rdata/generic/txt_16.cc create mode 100644 src/lib/dns/rdata/generic/txt_16.h create mode 100644 src/lib/dns/rdata/hs_4/a_1.cc create mode 100644 src/lib/dns/rdata/hs_4/a_1.h create mode 100644 src/lib/dns/rdata/in_1/a_1.cc create mode 100644 src/lib/dns/rdata/in_1/a_1.h create mode 100644 src/lib/dns/rdata/in_1/aaaa_28.cc create mode 100644 src/lib/dns/rdata/in_1/aaaa_28.h create mode 100644 src/lib/dns/rdata/in_1/dhcid_49.cc create mode 100644 src/lib/dns/rdata/in_1/dhcid_49.h create mode 100644 src/lib/dns/rdata/in_1/srv_33.cc create mode 100644 src/lib/dns/rdata/in_1/srv_33.h create mode 100644 src/lib/dns/rdata/template.cc create mode 100644 src/lib/dns/rdata/template.h (limited to 'src/lib/dns/rdata') diff --git a/src/lib/dns/rdata/any_255/tsig_250.cc b/src/lib/dns/rdata/any_255/tsig_250.cc new file mode 100644 index 0000000..a80d742 --- /dev/null +++ b/src/lib/dns/rdata/any_255/tsig_250.cc @@ -0,0 +1,567 @@ +// Copyright (C) 2010-2016 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using boost::lexical_cast; +using namespace isc::util; +using namespace isc::util::encode; +using namespace isc::dns; +using isc::dns::rdata::generic::detail::createNameFromLexer; + +// BEGIN_ISC_NAMESPACE +// BEGIN_RDATA_NAMESPACE + +// straightforward representation of TSIG RDATA fields +struct TSIGImpl { + TSIGImpl(const Name& algorithm, uint64_t time_signed, uint16_t fudge, + vector& mac, uint16_t original_id, uint16_t error, + vector& other_data) : + algorithm_(algorithm), time_signed_(time_signed), fudge_(fudge), + mac_(mac), original_id_(original_id), error_(error), + other_data_(other_data) + {} + TSIGImpl(const Name& algorithm, uint64_t time_signed, uint16_t fudge, + size_t macsize, const void* mac, uint16_t original_id, + uint16_t error, size_t other_len, const void* other_data) : + algorithm_(algorithm), time_signed_(time_signed), fudge_(fudge), + mac_(static_cast(mac), + static_cast(mac) + macsize), + original_id_(original_id), error_(error), + other_data_(static_cast(other_data), + static_cast(other_data) + other_len) + {} + template + void toWireCommon(Output& output) const; + + const Name algorithm_; + const uint64_t time_signed_; + const uint16_t fudge_; + const vector mac_; + const uint16_t original_id_; + const uint16_t error_; + const vector other_data_; +}; + +// helper function for string and lexer constructors +TSIGImpl* +TSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { + const Name& algorithm = + createNameFromLexer(lexer, origin ? origin : &Name::ROOT_NAME()); + const Name& canonical_algorithm_name = + (algorithm == TSIGKey::HMACMD5_SHORT_NAME()) ? + TSIGKey::HMACMD5_NAME() : algorithm; + + const string& time_txt = + lexer.getNextToken(MasterToken::STRING).getString(); + uint64_t time_signed; + try { + time_signed = boost::lexical_cast(time_txt); + } catch (const boost::bad_lexical_cast&) { + isc_throw(InvalidRdataText, "Invalid TSIG Time"); + } + if ((time_signed >> 48) != 0) { + isc_throw(InvalidRdataText, "TSIG Time out of range"); + } + + const uint32_t fudge = lexer.getNextToken(MasterToken::NUMBER).getNumber(); + if (fudge > 0xffff) { + isc_throw(InvalidRdataText, "TSIG Fudge out of range"); + } + const uint32_t macsize = + lexer.getNextToken(MasterToken::NUMBER).getNumber(); + if (macsize > 0xffff) { + isc_throw(InvalidRdataText, "TSIG MAC Size out of range"); + } + + const string& mac_txt = (macsize > 0) ? + lexer.getNextToken(MasterToken::STRING).getString() : ""; + vector mac; + decodeBase64(mac_txt, mac); + if (mac.size() != macsize) { + isc_throw(InvalidRdataText, "TSIG MAC Size and data are inconsistent"); + } + + const uint32_t orig_id = + lexer.getNextToken(MasterToken::NUMBER).getNumber(); + if (orig_id > 0xffff) { + isc_throw(InvalidRdataText, "TSIG Original ID out of range"); + } + + const string& error_txt = + lexer.getNextToken(MasterToken::STRING).getString(); + uint32_t error = 0; + // XXX: In the initial implementation we hardcode the mnemonics. + // We'll soon generalize this. + if (error_txt == "NOERROR") { + error = Rcode::NOERROR_CODE; + } else if (error_txt == "BADSIG") { + error = TSIGError::BAD_SIG_CODE; + } else if (error_txt == "BADKEY") { + error = TSIGError::BAD_KEY_CODE; + } else if (error_txt == "BADTIME") { + error = TSIGError::BAD_TIME_CODE; + } else if (error_txt == "BADMODE") { + error = TSIGError::BAD_MODE_CODE; + } else if (error_txt == "BADNAME") { + error = TSIGError::BAD_NAME_CODE; + } else if (error_txt == "BADALG") { + error = TSIGError::BAD_ALG_CODE; + } else if (error_txt == "BADTRUNC") { + error = TSIGError::BAD_TRUNC_CODE; + } else { + /// we cast to uint32_t and range-check, because casting directly to + /// uint16_t will convert negative numbers to large positive numbers + try { + error = boost::lexical_cast(error_txt); + } catch (const boost::bad_lexical_cast&) { + isc_throw(InvalidRdataText, "Invalid TSIG Error"); + } + if (error > 0xffff) { + isc_throw(InvalidRdataText, "TSIG Error out of range"); + } + } + + const uint32_t otherlen = + lexer.getNextToken(MasterToken::NUMBER).getNumber(); + if (otherlen > 0xffff) { + isc_throw(InvalidRdataText, "TSIG Other Len out of range"); + } + const string otherdata_txt = (otherlen > 0) ? + lexer.getNextToken(MasterToken::STRING).getString() : ""; + vector other_data; + decodeBase64(otherdata_txt, other_data); + if (other_data.size() != otherlen) { + isc_throw(InvalidRdataText, + "TSIG Other Data length does not match Other Len"); + } + // RFC2845 says Other Data is "empty unless Error == BADTIME". + // However, we don't enforce that. + + return (new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac, + orig_id, error, other_data)); +} + +/// \brief Constructor from string. +/// +/// The given string must represent a valid TSIG RDATA. There can be extra +/// space characters at the beginning or end of the text (which are simply +/// ignored), but other extra text, including a new line, will make the +/// construction fail with an exception. +/// +/// \c tsig_str must be formatted as follows: +/// \code