[Buildroot] [PATCH 3/4] package/python-pycrypto: fix python3.8 compatibility
Romain Naour
romain.naour at smile.fr
Sun Mar 8 18:35:34 UTC 2020
As reported by [1], time clock was deprecated in Python 3.3 and removed in Python 3.8.
Apply the patch from the PR [2] since there is no upstream activity.
Fixes:
>>> optee-os 3.7.0 Building
Traceback (most recent call last):
File "scripts/sign.py", line 234, in <module>
main()
File "scripts/sign.py", line 224, in main
{
File "scripts/sign.py", line 189, in sign_ta
sig = signer.sign(h)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Signature/PKCS1_v1_5.py", line 112, in sign
m = self._key.decrypt(em)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 174, in decrypt
return pubkey.pubkey.decrypt(self, ciphertext)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/PublicKey/pubkey.py", line 93, in decrypt
plaintext=self._decrypt(ciphertext)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 235, in _decrypt
r = getRandomRange(1, self.key.n-1, randfunc=self._randfunc)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Util/number.py", line 123, in getRandomRange
value = getRandomInteger(bits, randfunc)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Util/number.py", line 104, in getRandomInteger
S = randfunc(N>>3)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 202, in read
return self._singleton.read(bytes)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 178, in read
return _UserFriendlyRNG.read(self, bytes)
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 129, in read
self._ec.collect()
File "/home/naourr/buildroot/test/qemu_arm_vexpress_tz/host/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 77, in collect
t = time.clock()
AttributeError: module 'time' has no attribute 'clock'
This issue could be reproduced on the target.
[1] https://github.com/dlitz/pycrypto/issues/283
[2] https://github.com/dlitz/pycrypto/pull/296
Signed-off-by: Romain Naour <romain.naour at smile.fr>
---
...ock-with-time.process_time-time-cloc.patch | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 package/python-pycrypto/0002-replaced-time.clock-with-time.process_time-time-cloc.patch
diff --git a/package/python-pycrypto/0002-replaced-time.clock-with-time.process_time-time-cloc.patch b/package/python-pycrypto/0002-replaced-time.clock-with-time.process_time-time-cloc.patch
new file mode 100644
index 0000000000..b12b58ddf1
--- /dev/null
+++ b/package/python-pycrypto/0002-replaced-time.clock-with-time.process_time-time-cloc.patch
@@ -0,0 +1,35 @@
+From 6d76976527096cf0138d61fc25bd932d725f8436 Mon Sep 17 00:00:00 2001
+From: Fabian Topfstedt <topfstedt at schneevonmorgen.com>
+Date: Mon, 18 Nov 2019 22:19:35 +0100
+Subject: [PATCH] replaced time.clock with time.process_time (time clock was
+ flagged as deprecated in Python 3.3 and got removed in Python 3.8)
+
+Downloaded from github pull request [1].
+Related to issue [2].
+
+[1] https://github.com/dlitz/pycrypto/pull/296
+[2] https://github.com/dlitz/pycrypto/issues/283
+
+Signed-off-by: Romain Naour <romain.naour at smile.fr>
+---
+ lib/Crypto/Random/_UserFriendlyRNG.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Crypto/Random/_UserFriendlyRNG.py b/lib/Crypto/Random/_UserFriendlyRNG.py
+index 957e006..f389cfc 100644
+--- a/lib/Crypto/Random/_UserFriendlyRNG.py
++++ b/lib/Crypto/Random/_UserFriendlyRNG.py
+@@ -73,8 +73,8 @@ class _EntropyCollector(object):
+ t = time.time()
+ self._time_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))
+
+- # Add the fractional part of time.clock()
+- t = time.clock()
++ # Add the fractional part of time.process_time()
++ t = time.process_time()
+ self._clock_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))
+
+
+--
+2.24.1
+
--
2.24.1
More information about the buildroot
mailing list