dnspython  1.16.0
About: dnspython is a DNS toolkit (for Python 2.x) that supports almost all record types.
  Fossies Dox: dnspython-1.16.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

dns.tsig Namespace Reference

Classes

class  BadSignature
 
class  BadTime
 
class  PeerBadKey
 
class  PeerBadSignature
 
class  PeerBadTime
 
class  PeerBadTruncation
 
class  PeerError
 

Functions

def sign (wire, keyname, secret, time, fudge, original_id, error, other_data, request_mac, ctx=None, multi=False, first=True, algorithm=default_algorithm)
 
def hmac_md5 (wire, keyname, secret, time, fudge, original_id, error, other_data, request_mac, ctx=None, multi=False, first=True, algorithm=default_algorithm)
 
def validate (wire, keyname, secret, now, request_mac, tsig_start, tsig_rdata, tsig_rdlen, ctx=None, multi=False, first=True)
 
def get_algorithm (algorithm)
 
def get_algorithm_and_mac (wire, tsig_rdata, tsig_rdlen)
 

Variables

 HMAC_MD5 = dns.name.from_text("HMAC-MD5.SIG-ALG.REG.INT")
 
 HMAC_SHA1 = dns.name.from_text("hmac-sha1")
 
 HMAC_SHA224 = dns.name.from_text("hmac-sha224")
 
 HMAC_SHA256 = dns.name.from_text("hmac-sha256")
 
 HMAC_SHA384 = dns.name.from_text("hmac-sha384")
 
 HMAC_SHA512 = dns.name.from_text("hmac-sha512")
 
dictionary _hashes
 
 default_algorithm = HMAC_MD5
 
int BADSIG = 16
 
int BADKEY = 17
 
int BADTIME = 18
 
int BADTRUNC = 22
 

Function Documentation

◆ get_algorithm()

def dns.tsig.get_algorithm (   algorithm)
Returns the wire format string and the hash module to use for the
specified TSIG algorithm

@rtype: (string, hash constructor)
@raises NotImplementedError: I{algorithm} is not supported

Definition at line 204 of file tsig.py.

References dns.name.from_text().

Referenced by dns.tsig.sign().

◆ get_algorithm_and_mac()

def dns.tsig.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.

Definition at line 222 of file tsig.py.

References dns.name.from_wire().

Referenced by dns.message._WireReader._get_section().

◆ hmac_md5()

def dns.tsig.hmac_md5 (   wire,
  keyname,
  secret,
  time,
  fudge,
  original_id,
  error,
  other_data,
  request_mac,
  ctx = None,
  multi = False,
  first = True,
  algorithm = default_algorithm 
)

Definition at line 143 of file tsig.py.

References dns.tsig.sign().

◆ sign()

def dns.tsig.sign (   wire,
  keyname,
  secret,
  time,
  fudge,
  original_id,
  error,
  other_data,
  request_mac,
  ctx = None,
  multi = False,
  first = True,
  algorithm = default_algorithm 
)
Return a (tsig_rdata, mac, ctx) tuple containing the HMAC TSIG rdata
for the input parameters, the HMAC MAC calculated by applying the
TSIG signature algorithm, and the TSIG digest context.
@rtype: (string, string, hmac.HMAC object)
@raises ValueError: I{other_data} is too long
@raises NotImplementedError: I{algorithm} is not supported

Definition at line 89 of file tsig.py.

References dns.tsig.get_algorithm(), and dns._compat.long.

Referenced by dns.renderer.Renderer.add_multi_tsig(), dns.renderer.Renderer.add_tsig(), dns.tsig.hmac_md5(), and dns.tsig.validate().

◆ validate()

def dns.tsig.validate (   wire,
  keyname,
  secret,
  now,
  request_mac,
  tsig_start,
  tsig_rdata,
  tsig_rdlen,
  ctx = None,
  multi = False,
  first = True 
)
Validate the specified TSIG rdata against the other input parameters.

@raises FormError: The TSIG is badly formed.
@raises BadTime: There is too much time skew between the client and the
server.
@raises BadSignature: The TSIG signature did not validate
@rtype: hmac.HMAC object

Definition at line 150 of file tsig.py.

References dns.name.from_wire(), dns._compat.long, and dns.tsig.sign().

Referenced by dns.message._WireReader._get_section().

Variable Documentation

◆ _hashes

dictionary dns.tsig._hashes
private
Initial value:
1 = {
2  HMAC_SHA224: hashlib.sha224,
3  HMAC_SHA256: hashlib.sha256,
4  HMAC_SHA384: hashlib.sha384,
5  HMAC_SHA512: hashlib.sha512,
6  HMAC_SHA1: hashlib.sha1,
7  HMAC_MD5: hashlib.md5,
8 }

Definition at line 72 of file tsig.py.

◆ BADKEY

int dns.tsig.BADKEY = 17

Definition at line 84 of file tsig.py.

◆ BADSIG

int dns.tsig.BADSIG = 16

Definition at line 83 of file tsig.py.

◆ BADTIME

int dns.tsig.BADTIME = 18

Definition at line 85 of file tsig.py.

◆ BADTRUNC

int dns.tsig.BADTRUNC = 22

Definition at line 86 of file tsig.py.

◆ default_algorithm

dns.tsig.default_algorithm = HMAC_MD5

Definition at line 81 of file tsig.py.

◆ HMAC_MD5

dns.tsig.HMAC_MD5 = dns.name.from_text("HMAC-MD5.SIG-ALG.REG.INT")

Definition at line 65 of file tsig.py.

◆ HMAC_SHA1

dns.tsig.HMAC_SHA1 = dns.name.from_text("hmac-sha1")

Definition at line 66 of file tsig.py.

◆ HMAC_SHA224

dns.tsig.HMAC_SHA224 = dns.name.from_text("hmac-sha224")

Definition at line 67 of file tsig.py.

◆ HMAC_SHA256

dns.tsig.HMAC_SHA256 = dns.name.from_text("hmac-sha256")

Definition at line 68 of file tsig.py.

◆ HMAC_SHA384

dns.tsig.HMAC_SHA384 = dns.name.from_text("hmac-sha384")

Definition at line 69 of file tsig.py.

◆ HMAC_SHA512

dns.tsig.HMAC_SHA512 = dns.name.from_text("hmac-sha512")

Definition at line 70 of file tsig.py.