diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-03-29 20:39:08 +0200 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-03-29 20:39:08 +0200 |
commit | 96eaa5e82b75b8cfc36a67ad72a768f03c285647 (patch) | |
tree | 7196a466524ccfaa2ad3eaaa901db6cd6ed9222c /rsa/key.py | |
parent | 5e08c91a122bac2e59e176928aa1b24f9aa7b0b2 (diff) | |
download | rsa-96eaa5e82b75b8cfc36a67ad72a768f03c285647.tar.gz |
Implemented __hash__ function for key objects.
Overriding __eq__ blocks inheritance of __hash__ in Python 3.
Fixes issue #55
Diffstat (limited to 'rsa/key.py')
-rw-r--r-- | rsa/key.py | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -228,6 +228,9 @@ class PublicKey(AbstractKey): def __ne__(self, other): return not (self == other) + def __hash__(self): + return hash((self.n, self.e)) + @classmethod def _load_pkcs1_der(cls, keyfile): """Loads a key in PKCS#1 DER format. @@ -430,6 +433,9 @@ class PrivateKey(AbstractKey): def __ne__(self, other): return not (self == other) + def __hash__(self): + return hash((self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef)) + def blinded_decrypt(self, encrypted): """Decrypts the message using blinding to prevent side-channel attacks. |