python-SecretStorage/0001-fix-int_from_bytes-is-deprecated.patch

57 lines
1.8 KiB
Diff

From b53448bb9ad17f8eadb47be3b5a8fb40492a1cb0 Mon Sep 17 00:00:00 2001
From: wu-leilei <wu18740459704@163.com>
Date: Wed, 8 Dec 2021 10:15:44 +0800
Subject: [PATCH] fix int_from_bytes is deprecated
---
secretstorage/dhcrypto.py | 6 +++++-
secretstorage/util.py | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/secretstorage/dhcrypto.py b/secretstorage/dhcrypto.py
index 90de2d8..4e4e9f0 100644
--- a/secretstorage/dhcrypto.py
+++ b/secretstorage/dhcrypto.py
@@ -10,9 +10,13 @@ algorithm.'''
import hmac
import math
import os
+import sys
from hashlib import sha256
-from cryptography.utils import int_from_bytes
+if sys.version_info.major == 2:
+ from cryptography.utils import int_from_bytes
+else:
+ int_from_bytes = int.from_bytes
# A standard 1024 bits (128 bytes) prime number for use in Diffie-Hellman exchange
DH_PRIME_1024_BYTES = (
diff --git a/secretstorage/util.py b/secretstorage/util.py
index 44db909..546cb91 100644
--- a/secretstorage/util.py
+++ b/secretstorage/util.py
@@ -8,6 +8,7 @@ normally be used by external applications."""
import dbus
import os
+import sys
from secretstorage.defines import DBUS_UNKNOWN_METHOD, DBUS_NO_SUCH_OBJECT, \
DBUS_SERVICE_UNKNOWN, DBUS_NO_REPLY, DBUS_NOT_SUPPORTED, DBUS_EXEC_FAILED, \
SS_PATH, SS_PREFIX, ALGORITHM_DH, ALGORITHM_PLAIN
@@ -16,7 +17,10 @@ from secretstorage.exceptions import ItemNotFoundException, \
SecretServiceNotAvailableException
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
-from cryptography.utils import int_from_bytes
+if sys.version_info.major == 2:
+ from cryptography.utils import int_from_bytes
+else:
+ int_from_bytes = int.from_bytes
BUS_NAME = 'org.freedesktop.secrets'
SERVICE_IFACE = SS_PREFIX + 'Service'
--
2.23.0