diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/dsa.py | 9 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/ec.py | 6 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/rsa.py | 6 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/dsa.py b/src/cryptography/hazmat/primitives/asymmetric/dsa.py index 03e49ba5..9b06f3e6 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/dsa.py +++ b/src/cryptography/hazmat/primitives/asymmetric/dsa.py @@ -60,6 +60,9 @@ class DSAParameterNumbers(object): return backend.load_dsa_parameter_numbers(self) def __eq__(self, other): + if not isinstance(other, DSAParameterNumbers): + return NotImplemented + return self.p == other.p and self.q == other.q and self.g == other.g def __ne__(self, other): @@ -86,6 +89,9 @@ class DSAPublicNumbers(object): return backend.load_dsa_public_numbers(self) def __eq__(self, other): + if not isinstance(other, DSAPublicNumbers): + return NotImplemented + return ( self.y == other.y and self.parameter_numbers == other.parameter_numbers @@ -114,6 +120,9 @@ class DSAPrivateNumbers(object): return backend.load_dsa_private_numbers(self) def __eq__(self, other): + if not isinstance(other, DSAPrivateNumbers): + return NotImplemented + return ( self.x == other.x and self.public_numbers == other.public_numbers ) diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index cebd351c..202f1c97 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -162,6 +162,9 @@ class EllipticCurvePublicNumbers(object): y = utils.read_only_property("_y") def __eq__(self, other): + if not isinstance(other, EllipticCurvePublicNumbers): + return NotImplemented + return ( self.x == other.x and self.y == other.y and @@ -197,6 +200,9 @@ class EllipticCurvePrivateNumbers(object): public_numbers = utils.read_only_property("_public_numbers") def __eq__(self, other): + if not isinstance(other, EllipticCurvePrivateNumbers): + return NotImplemented + return ( self.private_value == other.private_value and self.public_numbers == other.public_numbers diff --git a/src/cryptography/hazmat/primitives/asymmetric/rsa.py b/src/cryptography/hazmat/primitives/asymmetric/rsa.py index ff397225..0cc6b22b 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/src/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -161,6 +161,9 @@ class RSAPrivateNumbers(object): return backend.load_rsa_private_numbers(self) def __eq__(self, other): + if not isinstance(other, RSAPrivateNumbers): + return NotImplemented + return ( self.p == other.p and self.q == other.q and @@ -196,6 +199,9 @@ class RSAPublicNumbers(object): return "<RSAPublicNumbers(e={0}, n={1})>".format(self._e, self._n) def __eq__(self, other): + if not isinstance(other, RSAPublicNumbers): + return NotImplemented + return self.e == other.e and self.n == other.n def __ne__(self, other): |