From e299181a5dda25aed4879ebcbe1359604448b3ae Mon Sep 17 00:00:00 2001 From: "Jeremy T. Bouse" Date: Fri, 27 Nov 2009 16:25:55 -0500 Subject: Imported Upstream version 1.7.6 --- docs/paramiko.rsakey-pysrc.html | 110 ++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'docs/paramiko.rsakey-pysrc.html') diff --git a/docs/paramiko.rsakey-pysrc.html b/docs/paramiko.rsakey-pysrc.html index 8e1c42b..d1dd96a 100644 --- a/docs/paramiko.rsakey-pysrc.html +++ b/docs/paramiko.rsakey-pysrc.html @@ -54,24 +54,24 @@

Source Code for Module paramiko.rsakey

-  1  # Copyright (C) 2003-2007  Robey Pointer <robey@lag.net> 
-  2  # 
-  3  # This file is part of paramiko. 
-  4  # 
-  5  # Paramiko is free software; you can redistribute it and/or modify it under the 
-  6  # terms of the GNU Lesser General Public License as published by the Free 
-  7  # Software Foundation; either version 2.1 of the License, or (at your option) 
-  8  # any later version. 
-  9  # 
- 10  # Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY 
- 11  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
- 12  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
- 13  # details. 
- 14  # 
- 15  # You should have received a copy of the GNU Lesser General Public License 
- 16  # along with Paramiko; if not, write to the Free Software Foundation, Inc., 
- 17  # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. 
- 18   
+  1  # Copyright (C) 2003-2007  Robey Pointer <robeypointer@gmail.com> 
+  2  # 
+  3  # This file is part of paramiko. 
+  4  # 
+  5  # Paramiko is free software; you can redistribute it and/or modify it under the 
+  6  # terms of the GNU Lesser General Public License as published by the Free 
+  7  # Software Foundation; either version 2.1 of the License, or (at your option) 
+  8  # any later version. 
+  9  # 
+ 10  # Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY 
+ 11  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
+ 12  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
+ 13  # details. 
+ 14  # 
+ 15  # You should have received a copy of the GNU Lesser General Public License 
+ 16  # along with Paramiko; if not, write to the Free Software Foundation, Inc., 
+ 17  # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. 
+ 18   
  19  """ 
  20  L{RSAKey} 
  21  """ 
@@ -146,36 +146,36 @@ paramiko.RSAKey.get_name" class="py-name" href="#" onclick="return doclink('link
 
86 return self.d is not None
87
88 - def sign_ssh_data(self, rpool, data): -
89 digest = SHA.new(data).digest() +
89 digest = SHA.new(data).digest() 90 rsa = RSA.construct((long(self.n), long(self.e), long(self.d))) - 91 sig = util.deflate_long(rsa.sign(self._pkcs1imify(digest), '')[0], 0) - 92 m = Message() - 93 m.add_string('ssh-rsa') - 94 m.add_string(sig) + 91 sig = util.deflate_long(rsa.sign(self._pkcs1imify(digest), '')[0], 0) + 92 m = Message() + 93 m.add_string('ssh-rsa') + 94 m.add_string(sig) 95 return m
96
97 - def verify_ssh_sig(self, data, msg): -
98 if msg.get_string() != 'ssh-rsa': +
98 if msg.get_string() != 'ssh-rsa': 99 return False -100 sig = util.inflate_long(msg.get_string(), True) +100 sig = util.inflate_long(msg.get_string(), True) 101 # verify the signature by SHA'ing the data and encrypting it using the -102 # public key. some wackiness ensues where we "pkcs1imify" the 20-byte -103 # hash into a string as long as the RSA key. -104 hash_obj = util.inflate_long(self._pkcs1imify(SHA.new(data).digest()), True) +102 # public key. some wackiness ensues where we "pkcs1imify" the 20-byte +103 # hash into a string as long as the RSA key. +104 hash_obj = util.inflate_long(self._pkcs1imify(SHA.new(data).digest()), True) 105 rsa = RSA.construct((long(self.n), long(self.e))) 106 return rsa.verify(hash_obj, (sig,))
107
108 - def _encode_key(self):
109 if (self.p is None) or (self.q is None): -110 raise SSHException('Not enough key info to write private key file') +110 raise SSHException('Not enough key info to write private key file') 111 keylist = [ 0, self.n, self.e, self.d, self.p, self.q, 112 self.d % (self.p - 1), self.d % (self.q - 1), -113 util.mod_inverse(self.q, self.p) ] +113 util.mod_inverse(self.q, self.p) ] 114 try: -115 b = BER() -116 b.encode(keylist) -117 except BERException: -118 raise SSHException('Unable to create ber encoding of key') +115 b = BER() +116 b.encode(keylist) +117 except BERException: +118 raise SSHException('Unable to create ber encoding of key') 119 return str(b)
120
121 - def write_private_key_file(self, filename, password=None): @@ -197,7 +197,7 @@ paramiko.RSAKey.get_name" class="py-name" href="#" onclick="return doclink('link 137 @return: new private key 138 @rtype: L{RSAKey} 139 """ -140 140 randpool.stir() -141 rsa = RSA.generate(bits, randpool.stir() +141 rsa = RSA.generate(bits, randpool.get_bytes, progress_func) -142 key = RSAKey(vals=(rsa.e, rsa.n)) +paramiko.util.randpool" class="py-name" href="#" onclick="return doclink('link-53', 'randpool', 'link-50');">randpool.get_bytes, progress_func) +142 key = RSAKey(vals=(rsa.e, rsa.n)) 143 key.d = rsa.d 144 key.p = rsa.p 145 key.q = rsa.q 146 return key -
147 generate = staticmethod(generate) +147 generate = staticmethod(generate) 148 149 150 ### internals... -151 +151 152
153 - def _pkcs1imify(self, data):
154 """ @@ -260,7 +260,7 @@ paramiko.RSAKey.generate" class="py-name" href="#" onclick="return doclink('link 156 using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre. 157 """ 158 SHA1_DIGESTINFO = '\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14' -159 size = len(util.deflate_long(self.n, 0)) +159 size = len(util.deflate_long(self.n, 0)) 160 filler = '\xff' * (size - len(SHA1_DIGESTINFO) - len(data) - 3) 161 return '\x00\x01' + filler + '\x00' + SHA1_DIGESTINFO + data
162 @@ -274,20 +274,20 @@ paramiko.RSAKey.generate" class="py-name" href="#" onclick="return doclink('link 170
171 - def _decode_key(self, data):
172 # private key file contains: -173 # RSAPrivateKey = { version = 0, n, e, d, p, q, d mod p-1, d mod q-1, q**-1 mod p } -174 try: -175 keylist = BER(data).decode() -176 except BERException: -177 raise SSHException('Unable to parse key file') +173 # RSAPrivateKey = { version = 0, n, e, d, p, q, d mod p-1, d mod q-1, q**-1 mod p } +174 try: +175 keylist = BER(data).decode() +176 except BERException: +177 raise SSHException('Unable to parse key file') 178 if (type(keylist) is not list) or (len(keylist) < 4) or (keylist[0] != 0): -179 raise SSHException('Not a valid RSA private key file (bad ber encoding)') +179 raise SSHException('Not a valid RSA private key file (bad ber encoding)') 180 self.n = keylist[1] 181 self.e = keylist[2] 182 self.d = keylist[3] 183 # not really needed -184 self.p = keylist[4] +184 self.p = keylist[4] 185 self.q = keylist[5] -186 self.size = util.bit_length(self.n) +186 self.size = util.bit_length(self.n)
187