summaryrefslogtreecommitdiff
path: root/dns/tsig.py
diff options
context:
space:
mode:
Diffstat (limited to 'dns/tsig.py')
-rw-r--r--dns/tsig.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/dns/tsig.py b/dns/tsig.py
index 6e97dce..2dd4b42 100644
--- a/dns/tsig.py
+++ b/dns/tsig.py
@@ -221,3 +221,19 @@ def get_algorithm(algorithm):
except KeyError:
raise NotImplementedError("TSIG algorithm " + str(algorithm) +
" is not supported")
+
+def get_algorithm_and_mac(wire, tsig_rdata, tsig_rdlen):
+ """Return the tsig algorithm for the specified tsig_rdata
+ @raises FormError: The TSIG is badly formed.
+ """
+ current = tsig_rdata
+ (aname, used) = dns.name.from_wire(wire, current)
+ current = current + used
+ (upper_time, lower_time, fudge, mac_size) = \
+ struct.unpack("!HIHH", wire[current:current + 10])
+ current += 10
+ mac = wire[current:current + mac_size]
+ current += mac_size
+ if current > tsig_rdata + tsig_rdlen:
+ raise dns.exception.FormError
+ return (aname, mac)