File: 0002-Use-of-Cryptodome-module-imports-instead-of-Crypto.patch

package info (click to toggle)
python-potr 1.0.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: python: 1,688; makefile: 8
file content (50 lines) | stat: -rw-r--r-- 1,671 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From: Emmanuel Arias <eamanu@yaerobi.com>
Date: Thu, 21 Jan 2021 10:11:24 -0300
Subject: Use of Cryptodome module imports instead of Crypto

Upstream don't support pycryptodome yet, so this patch is a workaround
to work with that module.

Patch by Sebastian Ramacher <sramacher@debian.org>.
---
 src/potr/compatcrypto/pycrypto.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/potr/compatcrypto/pycrypto.py b/src/potr/compatcrypto/pycrypto.py
index 58a8577..422c831 100644
--- a/src/potr/compatcrypto/pycrypto.py
+++ b/src/potr/compatcrypto/pycrypto.py
@@ -16,16 +16,16 @@
 #    along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
 try:
-  import Crypto
+  import Cryptodome
 except ImportError:
   import crypto as Crypto
 
-from Crypto import Cipher
-from Crypto.Hash import SHA256 as _SHA256
-from Crypto.Hash import SHA as _SHA1
-from Crypto.Hash import HMAC as _HMAC
-from Crypto.PublicKey import DSA
-import Crypto.Random.random
+from Cryptodome import Cipher
+from Cryptodome.Hash import SHA256 as _SHA256
+from Cryptodome.Hash import SHA as _SHA1
+from Cryptodome.Hash import HMAC as _HMAC
+from Cryptodome.PublicKey import DSA
+import Cryptodome.Random.random
 from numbers import Number
 
 from potr.compatcrypto import common
@@ -143,7 +143,7 @@ class DSAKey(common.PK):
         return cls((y, g, p, q), private=False), data
 
 def getrandbits(k):
-    return Crypto.Random.random.getrandbits(k)
+    return Cryptodome.Random.random.getrandbits(k)
 
 def randrange(start, stop):
-    return Crypto.Random.random.randrange(start, stop)
+    return Cryptodome.Random.random.randrange(start, stop)