Browse Source

dnssec: fix compat with dnspython 1.16

bip39-recovery
SomberNight 5 years ago
parent
commit
6d2aee18d0
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      contrib/requirements/requirements.txt
  2. 14
      electrum/dnssec.py

2
contrib/requirements/requirements.txt

@ -2,7 +2,7 @@ pyaes>=0.1a1
ecdsa>=0.14
qrcode
protobuf>=3.12
dnspython
dnspython<2.0
qdarkstyle<2.9
aiorpcx>=0.18,<0.19
aiohttp>=3.3.0,<4.0.0

14
electrum/dnssec.py

@ -35,6 +35,7 @@
# import sys
import time
import struct
import hashlib
import dns.name
@ -166,10 +167,23 @@ def python_validate_rrsig(rrset, rrsig, keys, origin=None, now=None):
raise ValidationFailure('verify failure')
class PyCryptodomexHashAlike:
def __init__(self, hashlib_func):
self._hash = hashlib_func
def new(self):
return self._hash()
# replace validate_rrsig
dns.dnssec._validate_rrsig = python_validate_rrsig
dns.dnssec.validate_rrsig = python_validate_rrsig
dns.dnssec.validate = dns.dnssec._validate
dns.dnssec._have_ecdsa = True
dns.dnssec.MD5 = PyCryptodomexHashAlike(hashlib.md5)
dns.dnssec.SHA1 = PyCryptodomexHashAlike(hashlib.sha1)
dns.dnssec.SHA256 = PyCryptodomexHashAlike(hashlib.sha256)
dns.dnssec.SHA384 = PyCryptodomexHashAlike(hashlib.sha384)
dns.dnssec.SHA512 = PyCryptodomexHashAlike(hashlib.sha512)

Loading…
Cancel
Save