[Cryptech-Commits] [sw/libhal] branch python3 updated: Work around PyCrypto being EOL and therefore not tracking Python 3.8

git at cryptech.is git at cryptech.is
Tue Sep 1 22:40:22 UTC 2020


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch python3
in repository sw/libhal.

The following commit(s) were added to refs/heads/python3 by this push:
     new 9733c5e  Work around PyCrypto being EOL and therefore not tracking Python 3.8
9733c5e is described below

commit 9733c5e7faf9aee874c1176381abcda98deb48f9
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Tue Sep 1 18:42:56 2020 -0400

    Work around PyCrypto being EOL and therefore not tracking Python 3.8
    
    This is a short term kludge to let the old unit test code continue to
    work under Python 3.8.
    
    Medium term, we should replace all use of PyCrypto with PyCryptodome
    (API-compatible successor package).
    
    Long term we might want a newer API, but that can wait.
---
 unit-tests.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/unit-tests.py b/unit-tests.py
index c2f7171..526379c 100644
--- a/unit-tests.py
+++ b/unit-tests.py
@@ -41,6 +41,7 @@ import unittest
 import datetime
 import binascii
 import logging
+import time
 import sys
 
 from struct import pack, unpack
@@ -76,6 +77,20 @@ except ImportError:
     ecdsa_loaded = False
 
 
+# PyCrypto has been deprecated, at some point we should move on to
+# pycryptodome, cryptography.io, or some other modern thing.  For the
+# moment, an awful kludge to let PyCrypto hobble a little further with
+# Python 3.8.
+#
+# Given that PyCrypto is using this as input to its random number
+# generator, you should not use any keys generated by PyCrypto with
+# this hack in place for any serious purpose: they're fine as
+# throwaway test keys, but not for securing any data you care about.
+
+if pycrypto_loaded and not hasattr(time, "clock") and hasattr(time, "process_time"):
+    time.clock = time.process_time
+
+
 logger = logging.getLogger("unit-tests")
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list