From d5487dcda66b9ba31d2847a5427655bf059332ec Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 19 Feb 2021 01:05:54 +0000 Subject: [PATCH] Call in --- rsa/key.py | 2 ++ tests/test_load_save_keys.py | 5 +++++ 2 files changed, 7 insertions(+) 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 @@ def __getstate__(self) -> typing.Tuple[int, int]: 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 @@ def __getstate__(self) -> typing.Tuple[int, int, int, int, int, int, int, int]: 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 @@ def test_private_key(self): 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 @@ def test_public_key(self): unpickled = pickle.loads(pickled) self.assertEqual(pk, unpickled) + for attr in rsa.key.AbstractKey.__slots__: + self.assertTrue(hasattr(unpickled, attr))