diff options
author | Mukund Sivaraman <muks@isc.org> | 2013-09-09 20:02:18 +0200 |
---|---|---|
committer | Mukund Sivaraman <muks@isc.org> | 2013-09-09 20:06:01 +0200 |
commit | b5fe9ef4194ec0b3c2cec527834e27e3377d903e (patch) | |
tree | 63424b565e27466211b7f96e88e26a68df4498e0 /src/lib/dns/rdata | |
parent | [2762] Allow short names for HMAC-MD5 (diff) | |
download | kea-b5fe9ef4194ec0b3c2cec527834e27e3377d903e.tar.xz kea-b5fe9ef4194ec0b3c2cec527834e27e3377d903e.zip |
[2762] Update tests and implementation (see full log)
* Fix the unittest so that it compares the correct object (tsig6)
* Store canonical long-form HMAC name in case of HMAC-MD5
+ Update TSIG RDATA class (test already present)
+ Update TSIGKey class (new tests added)
Diffstat (limited to 'src/lib/dns/rdata')
-rw-r--r-- | src/lib/dns/rdata/any_255/tsig_250.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/dns/rdata/any_255/tsig_250.cc b/src/lib/dns/rdata/any_255/tsig_250.cc index 796e3200cc..3252cfdb10 100644 --- a/src/lib/dns/rdata/any_255/tsig_250.cc +++ b/src/lib/dns/rdata/any_255/tsig_250.cc @@ -26,6 +26,7 @@ #include <dns/rdata.h> #include <dns/rdataclass.h> #include <dns/rcode.h> +#include <dns/tsigkey.h> #include <dns/tsigerror.h> #include <dns/rdata/generic/detail/lexer_util.h> @@ -75,6 +76,9 @@ 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(); @@ -154,8 +158,8 @@ TSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { // RFC2845 says Other Data is "empty unless Error == BADTIME". // However, we don't enforce that. - return (new TSIGImpl(algorithm, time_signed, fudge, mac, orig_id, - error, other_data)); + return (new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac, + orig_id, error, other_data)); } /// \brief Constructor from string. @@ -302,8 +306,11 @@ TSIG::TSIG(InputBuffer& buffer, size_t) : buffer.readData(&other_data[0], other_len); } - impl_ = new TSIGImpl(algorithm, time_signed, fudge, mac, original_id, - error, other_data); + const Name& canonical_algorithm_name = + (algorithm == TSIGKey::HMACMD5_SHORT_NAME()) ? + TSIGKey::HMACMD5_NAME() : algorithm; + impl_ = new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac, + original_id, error, other_data); } TSIG::TSIG(const Name& algorithm, uint64_t time_signed, uint16_t fudge, @@ -324,8 +331,11 @@ TSIG::TSIG(const Name& algorithm, uint64_t time_signed, uint16_t fudge, isc_throw(InvalidParameter, "TSIG Other data length and data inconsistent"); } - impl_ = new TSIGImpl(algorithm, time_signed, fudge, mac_size, mac, - original_id, error, other_len, other_data); + const Name& canonical_algorithm_name = + (algorithm == TSIGKey::HMACMD5_SHORT_NAME()) ? + TSIGKey::HMACMD5_NAME() : algorithm; + impl_ = new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac_size, + mac, original_id, error, other_len, other_data); } /// \brief The copy constructor. |