From: Bob Halley Date: Thu, 12 May 2016 21:15:34 +0000 (-0700) Subject: Fix TSIG algorithm to hash mapping X-Git-Tag: v1.14.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c1a60f269db2ed7356314079253ca06ada758f7;p=thirdparty%2Fdnspython.git Fix TSIG algorithm to hash mapping --- diff --git a/dns/tsig.py b/dns/tsig.py index 55348528..931d27d0 100644 --- a/dns/tsig.py +++ b/dns/tsig.py @@ -25,7 +25,6 @@ import dns.rdataclass import dns.name from ._compat import long, string_types - class BadTime(dns.exception.DNSException): """The current time is not within the TSIG's validity time.""" @@ -69,6 +68,15 @@ HMAC_SHA256 = dns.name.from_text("hmac-sha256") HMAC_SHA384 = dns.name.from_text("hmac-sha384") HMAC_SHA512 = dns.name.from_text("hmac-sha512") +_hashes = { + HMAC_SHA224: 'SHA224', + HMAC_SHA256: 'SHA256', + HMAC_SHA384: 'SHA384', + HMAC_SHA512: 'SHA512', + HMAC_SHA1: 'SHA1', + HMAC_MD5: 'MD5', +} + default_algorithm = HMAC_MD5 BADSIG = 16 @@ -202,7 +210,7 @@ def get_algorithm(algorithm): algorithm = dns.name.from_text(algorithm) try: - return (algorithm.to_digestable(), dns.hash.hashes[algorithm]) + return (algorithm.to_digestable(), _hashes[algorithm]) except KeyError: raise NotImplementedError("TSIG algorithm " + str(algorithm) + " is not supported")