From eb6ddb6e3ec5cf3a512f1854adb6ed1ad318ea4e Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 19 Feb 2021 01:05:54 +0000 Subject: Fix #173: unpickling doesn't restore full object When a `PrivateKey` or `PublicKey` is unpickled `AbstractKey.__init__()` should be called so `self.mutex` and `self.blindfac` are created. --- rsa/key.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'rsa/key.py') 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: -- cgit v1.2.1