From: Bob Halley Date: Tue, 10 Apr 2012 12:07:31 +0000 (+0100) Subject: Fix python3 port issues with RSA validation X-Git-Tag: v1.11.0-py3~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=790cfe8283cfad38a21ee22d31b36ece173f266d;p=thirdparty%2Fdnspython.git Fix python3 port issues with RSA validation --- diff --git a/ChangeLog b/ChangeLog index 81650fed..46609f5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-04-10 Bob Halley + + * dns/dnssec.py (_validate_rrsig): Fix python3 port issues with + RSA validation. + 2012-04-08 Bob Halley * (Version 1.10.0 released) diff --git a/dns/dnssec.py b/dns/dnssec.py index 61f2410a..bf3d9a3c 100644 --- a/dns/dnssec.py +++ b/dns/dnssec.py @@ -241,13 +241,13 @@ def _validate_rrsig(rrset, rrsig, keys, origin=None, now=None): if _is_rsa(rrsig.algorithm): keyptr = key.key - (bytes,) = struct.unpack('!B', keyptr[0:1]) + (count,) = struct.unpack('!B', keyptr[0:1]) keyptr = keyptr[1:] - if bytes == 0: - (bytes,) = struct.unpack('!H', keyptr[0:2]) + if count == 0: + (count,) = struct.unpack('!H', keyptr[0:2]) keyptr = keyptr[2:] - rsa_e = keyptr[0:bytes] - rsa_n = keyptr[bytes:] + rsa_e = keyptr[0:count] + rsa_n = keyptr[count:] keylen = len(rsa_n) * 8 pubkey = Crypto.PublicKey.RSA.construct( (Crypto.Util.number.bytes_to_long(rsa_n), @@ -300,8 +300,8 @@ def _validate_rrsig(rrset, rrsig, keys, origin=None, now=None): # PKCS1 algorithm identifier goop digest = _make_algorithm_id(rrsig.algorithm) + digest padlen = keylen // 8 - len(digest) - 3 - digest = bytes(0) + bytes(1) + bytes(0xFF) * padlen + bytes(0) + \ - digest + digest = bytes([0]) + bytes([1]) + bytes([0xFF]) * padlen + \ + bytes([0]) + digest elif _is_dsa(rrsig.algorithm): pass else: