From e52e64e7cd6b35ab4fa66bde71db09daea0c45bc Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 16 Oct 2008 14:26:28 +0000 Subject: [PATCH] allow multiple chunks in DS RR Base64 --- dns/rdtypes/ANY/DS.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dns/rdtypes/ANY/DS.py b/dns/rdtypes/ANY/DS.py index 035ac300..e3ccf596 100644 --- a/dns/rdtypes/ANY/DS.py +++ b/dns/rdtypes/ANY/DS.py @@ -32,7 +32,7 @@ class DS(dns.rdata.Rdata): @see: draft-ietf-dnsext-delegation-signer-14.txt""" __slots__ = ['key_tag', 'algorithm', 'digest_type', 'digest'] - + def __init__(self, rdclass, rdtype, key_tag, algorithm, digest_type, digest): super(DS, self).__init__(rdclass, rdtype) @@ -46,17 +46,24 @@ class DS(dns.rdata.Rdata): self.digest_type, dns.rdata._hexify(self.digest, chunksize=128)) - + def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): key_tag = tok.get_uint16() algorithm = tok.get_uint8() digest_type = tok.get_uint8() - digest = tok.get_string() + chunks = [] + while 1: + t = tok.get() + if t[0] == dns.tokenizer.EOL or t[0] == dns.tokenizer.EOF: + break + if t[0] != dns.tokenizer.IDENTIFIER: + raise dns.exception.SyntaxError + chunks.append(t[1]) + digest = ''.join(chunks) digest = digest.decode('hex_codec') - tok.get_eol() return cls(rdclass, rdtype, key_tag, algorithm, digest_type, digest) - + from_text = classmethod(from_text) def to_wire(self, file, compress = None, origin = None): @@ -64,7 +71,7 @@ class DS(dns.rdata.Rdata): self.digest_type) file.write(header) file.write(self.digest) - + def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None): header = struct.unpack("!HBB", wire[current : current + 4]) current += 4 -- 2.47.3