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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
From: Jonas Smedegaard <dr@jones.dk>
Date: Mon, 17 Jul 2023 13:26:20 +0200
Subject: Use Python module pycryptodome (not crypto)
Last-Update: 2020-05-20
This is a workaround for <https://bugs.debian.org/886291>.
Last-Update: 2020-05-20
---
src/nio/crypto/async_attachments.py | 8 ++++----
src/nio/crypto/attachments.py | 8 ++++----
src/nio/crypto/key_export.py | 10 +++++-----
tests/async_attachment_test.py | 2 +-
tests/attachment_test.py | 2 +-
5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/nio/crypto/async_attachments.py b/src/nio/crypto/async_attachments.py
index 564ec18..49a626c 100644
--- a/src/nio/crypto/async_attachments.py
+++ b/src/nio/crypto/async_attachments.py
@@ -23,10 +23,10 @@ from typing import Any, AsyncGenerator, AsyncIterable, Dict, Iterable, Union
import aiofiles
from aiofiles.threadpool.binary import AsyncBufferedReader
-from Crypto import Random # nosec
-from Crypto.Cipher import AES # nosec
-from Crypto.Hash import SHA256 # nosec
-from Crypto.Util import Counter # nosec
+from Cryptodome import Random # nosec
+from Cryptodome.Cipher import AES # nosec
+from Cryptodome.Hash import SHA256 # nosec
+from Cryptodome.Util import Counter # nosec
from .attachments import _get_decryption_info_dict
diff --git a/src/nio/crypto/attachments.py b/src/nio/crypto/attachments.py
index 31ca240..61b7ba6 100644
--- a/src/nio/crypto/attachments.py
+++ b/src/nio/crypto/attachments.py
@@ -19,10 +19,10 @@ from binascii import Error as BinAsciiError
from typing import Any, Dict, Generator, Iterable, Tuple, Union
import unpaddedbase64
-from Crypto import Random
-from Crypto.Cipher import AES
-from Crypto.Hash import SHA256
-from Crypto.Util import Counter
+from Cryptodome import Random
+from Cryptodome.Cipher import AES
+from Cryptodome.Hash import SHA256
+from Cryptodome.Util import Counter
from ..exceptions import EncryptionError
diff --git a/src/nio/crypto/key_export.py b/src/nio/crypto/key_export.py
index 2e2d552..703f017 100644
--- a/src/nio/crypto/key_export.py
+++ b/src/nio/crypto/key_export.py
@@ -12,11 +12,11 @@ import sys
from pathlib import Path
from atomicwrites import atomic_write
-from Crypto import Random
-from Crypto.Cipher import AES
-from Crypto.Hash import HMAC, SHA256, SHA512
-from Crypto.Protocol.KDF import PBKDF2
-from Crypto.Util import Counter
+from Cryptodome import Random
+from Cryptodome.Cipher import AES
+from Cryptodome.Hash import HMAC, SHA256, SHA512
+from Cryptodome.Protocol.KDF import PBKDF2
+from Cryptodome.Util import Counter
from unpaddedbase64 import decode_base64, encode_base64
HEADER = "-----BEGIN MEGOLM SESSION DATA-----"
diff --git a/tests/async_attachment_test.py b/tests/async_attachment_test.py
index 68e3bf3..540a54e 100644
--- a/tests/async_attachment_test.py
+++ b/tests/async_attachment_test.py
@@ -3,7 +3,7 @@ from pathlib import Path
import aiofiles
import pytest
import unpaddedbase64
-from Crypto import Random # nosec
+from Cryptodome import Random # nosec
from nio import EncryptionError
from nio.crypto import async_encrypt_attachment, decrypt_attachment
diff --git a/tests/attachment_test.py b/tests/attachment_test.py
index 4215006..22c5d3a 100644
--- a/tests/attachment_test.py
+++ b/tests/attachment_test.py
@@ -1,6 +1,6 @@
import pytest
import unpaddedbase64
-from Crypto import Random
+from Cryptodome import Random
from nio import EncryptionError
from nio.crypto import decrypt_attachment, encrypt_attachment
|