summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rsa/key.py2
-rw-r--r--tests/test_load_save_keys.py5
2 files changed, 7 insertions, 0 deletions
diff --git a/rsa/key.py b/rsa/key.py
index d84ae05..e61bac1 100644
--- a/rsa/key.py
+++ b/rsa/key.py
@@ -251,6 +251,7 @@ class PublicKey(AbstractKey):
def __setstate__(self, state: typing.Tuple[int, int]) -> None:
"""Sets the key from tuple."""
self.n, self.e = state
+ AbstractKey.__init__(self, self.n, self.e)
def __eq__(self, other: typing.Any) -> bool:
if other is None:
@@ -426,6 +427,7 @@ class PrivateKey(AbstractKey):
def __setstate__(self, state: typing.Tuple[int, int, int, int, int, int, int, int]) -> None:
"""Sets the key from tuple."""
self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef = state
+ AbstractKey.__init__(self, self.n, self.e)
def __eq__(self, other: typing.Any) -> bool:
if other is None:
diff --git a/tests/test_load_save_keys.py b/tests/test_load_save_keys.py
index 7892fb3..d881d20 100644
--- a/tests/test_load_save_keys.py
+++ b/tests/test_load_save_keys.py
@@ -203,6 +203,9 @@ class PickleTest(unittest.TestCase):
unpickled = pickle.loads(pickled)
self.assertEqual(pk, unpickled)
+ for attr in rsa.key.AbstractKey.__slots__:
+ self.assertTrue(hasattr(unpickled, attr))
+
def test_public_key(self):
pk = rsa.key.PublicKey(3727264081, 65537)
@@ -210,3 +213,5 @@ class PickleTest(unittest.TestCase):
unpickled = pickle.loads(pickled)
self.assertEqual(pk, unpickled)
+ for attr in rsa.key.AbstractKey.__slots__:
+ self.assertTrue(hasattr(unpickled, attr))