From 5c1a60f269db2ed7356314079253ca06ada758f7 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 12 May 2016 14:15:34 -0700 Subject: [PATCH] Fix TSIG algorithm to hash mapping --- dns/tsig.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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") -- 2.47.3