"""DNS TSIG support."""
+import hashlib
import hmac
import struct
import dns.exception
import dns.rdataclass
import dns.name
-import dns.dnssec
from ._compat import long, string_types, text_type
class BadTime(dns.exception.DNSException):
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',
+ HMAC_SHA224: hashlib.sha224,
+ HMAC_SHA256: hashlib.sha256,
+ HMAC_SHA384: hashlib.sha384,
+ HMAC_SHA512: hashlib.sha512,
+ HMAC_SHA1: hashlib.sha1,
+ HMAC_MD5: hashlib.md5,
}
default_algorithm = HMAC_MD5
algorithm = dns.name.from_text(algorithm)
try:
- return (algorithm.to_digestable(), dns.dnssec._make_hash(algorithm))
+ return (algorithm.to_digestable(), _hashes[algorithm])
except KeyError:
raise NotImplementedError("TSIG algorithm " + str(algorithm) +
" is not supported")