summaryrefslogtreecommitdiff
path: root/dns/rdtypes/ANY/NSEC3.py
diff options
context:
space:
mode:
Diffstat (limited to 'dns/rdtypes/ANY/NSEC3.py')
-rw-r--r--dns/rdtypes/ANY/NSEC3.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/dns/rdtypes/ANY/NSEC3.py b/dns/rdtypes/ANY/NSEC3.py
index 6eae16e..fe4e71c 100644
--- a/dns/rdtypes/ANY/NSEC3.py
+++ b/dns/rdtypes/ANY/NSEC3.py
@@ -67,6 +67,7 @@ class NSEC3(dns.rdata.Rdata):
def to_text(self, origin=None, relativize=True, **kw):
next = base64.b32encode(self.next).translate(b32_normal_to_hex).lower().decode()
+ next = next.rstrip("=")
if self.salt == b"":
salt = "-"
else:
@@ -94,6 +95,10 @@ class NSEC3(dns.rdata.Rdata):
else:
salt = binascii.unhexlify(salt.encode("ascii"))
next = tok.get_string().encode("ascii").upper().translate(b32_hex_to_normal)
+ if next.endswith(b"="):
+ raise binascii.Error("Incorrect padding")
+ if len(next) % 8 != 0:
+ next += b"=" * (8 - len(next) % 8)
next = base64.b32decode(next)
bitmap = Bitmap.from_text(tok)
return cls(rdclass, rdtype, algorithm, flags, iterations, salt, next, bitmap)