summaryrefslogtreecommitdiff
path: root/paramiko/rsakey.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-03-18 08:24:01 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-03-18 08:24:01 -0400
commit67254b677ddb32f86442aeaa23326c294ffd716c (patch)
tree7cea7f173ae878f876bdf4be2ab682af0cf29dc7 /paramiko/rsakey.py
parentfe2d1cd163aca811e966a0143a7d6759f90f996b (diff)
downloadparamiko-67254b677ddb32f86442aeaa23326c294ffd716c.tar.gz
fix
Diffstat (limited to 'paramiko/rsakey.py')
-rw-r--r--paramiko/rsakey.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py
index 43f9fd9b..65688c43 100644
--- a/paramiko/rsakey.py
+++ b/paramiko/rsakey.py
@@ -63,22 +63,27 @@ class RSAKey(PKey):
def size(self):
return self.key.key_size
+ @property
+ def public_numbers(self):
+ if isinstance(self.key, rsa.RSAPrivateKey):
+ return self.key.private_numbers().public_numbers
+ else:
+ return self.key.public_numbers
+
def asbytes(self):
- public_numbers = self.key.public_numbers()
m = Message()
m.add_string('ssh-rsa')
- m.add_mpint(public_numbers.e)
- m.add_mpint(public_numbers.n)
+ m.add_mpint(self.public_numbers.e)
+ m.add_mpint(self.public_numbers.n)
return m.asbytes()
def __str__(self):
return self.asbytes()
def __hash__(self):
- public_numbers = self.key.public_numbers()
h = hash(self.get_name())
- h = h * 37 + hash(public_numbers.e)
- h = h * 37 + hash(public_numbers.n)
+ h = h * 37 + hash(self.public_numbers.e)
+ h = h * 37 + hash(self.public_numbers.n)
return hash(h)
def get_name(self):