commit 6d2aee18d0bc5b68bff4123855f2b77b7efa1f3b
parent 9fa666f1792b82bdd93d01752d1912076541f1f3
Author: SomberNight <somber.night@protonmail.com>
Date: Thu, 2 Jul 2020 11:12:38 +0200
dnssec: fix compat with dnspython 1.16
Diffstat:
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/contrib/requirements/requirements.txt b/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
diff --git a/electrum/dnssec.py b/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)