]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
remove obsolete entropy pool hash import logic
authorBob Halley <halley@dnspython.org>
Fri, 1 May 2020 19:13:35 +0000 (12:13 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 1 May 2020 19:13:35 +0000 (12:13 -0700)
dns/entropy.py

index 3b4194ec435b6303d9391bd2feaad45b8341ec4d..da4332c8e6ec031ad5c90ba33c2fe1fe268dc719 100644 (file)
 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 import os
+import hashlib
 import random
 import time
 try:
     import threading as _threading
 except ImportError:
-    import dummy_threading as _threading
+    import dummy_threading as _threading    # type: ignore
 
 
 class EntropyPool(object):
@@ -36,19 +37,8 @@ class EntropyPool(object):
         self.digest = None
         self.next_byte = 0
         self.lock = _threading.Lock()
-        try:
-            import hashlib
-            self.hash = hashlib.sha1()
-            self.hash_len = 20
-        except ImportError:
-            try:
-                import sha
-                self.hash = sha.new()
-                self.hash_len = 20
-            except ImportError:
-                import md5  # pylint: disable=import-error
-                self.hash = md5.new()
-                self.hash_len = 16
+        self.hash = hashlib.sha1()
+        self.hash_len = 20
         self.pool = bytearray(b'\0' * self.hash_len)
         if seed is not None:
             self.stir(bytearray(seed))