Skip to content

Commit

Permalink
Call in
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 committed Feb 19, 2021
1 parent 758562f commit d5487dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rsa/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_load_save_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ 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)

pickled = pickle.dumps(pk)
unpickled = pickle.loads(pickled)

self.assertEqual(pk, unpickled)
for attr in rsa.key.AbstractKey.__slots__:
self.assertTrue(hasattr(unpickled, attr))

0 comments on commit d5487dc

Please sign in to comment.