From f7b892905c62b94a6e54d115ee2d6d32d66af013 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 Closes: #543784 --- docs/paramiko.dsskey-pysrc.html | 118 ++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'docs/paramiko.dsskey-pysrc.html') diff --git a/docs/paramiko.dsskey-pysrc.html b/docs/paramiko.dsskey-pysrc.html index 1346b99..6a254ac 100644 --- a/docs/paramiko.dsskey-pysrc.html +++ b/docs/paramiko.dsskey-pysrc.html @@ -54,24 +54,24 @@

Source Code for Module paramiko.dsskey

-  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{DSSKey} 
  21  """ 
@@ -140,7 +140,7 @@ paramiko.RSAKey.get_name" class="py-name" href="#" onclick="return doclink('link
  80          h = h * 37 + hash(self.g) 
  81          h = h * 37 + hash(self.y) 
  82          # h might be a long by now... 
- 83          return hash(h) 
+ 83          return hash(h) 
  84   
 
85 - def get_name(self):
86 return 'ssh-dss' @@ -152,55 +152,55 @@ paramiko.RSAKey.get_name" class="py-name" href="#" onclick="return doclink('link
92 return self.x is not None
93
94 - def sign_ssh_data(self, rpool, data): -
95 digest = SHA.new(data).digest() +
95 digest = SHA.new(data).digest() 96 dss = DSA.construct((long(self.y), long(self.g), long(self.p), long(self.q), long(self.x))) 97 # generate a suitable k - 98 qsize = len(util.deflate_long(self.q, 0)) + 98 qsize = len(util.deflate_long(self.q, 0)) 99 while True: -100 k = util.inflate_long(rpool.get_bytes(qsize), 1) +100 k = util.inflate_long(rpool.get_bytes(qsize), 1) 101 if (k > 2) and (k < self.q): 102 break -103 r, s = dss.sign(util.inflate_long(digest, 1), k) -104 m = Message() -105 m.add_string('ssh-dss') +103 r, s = dss.sign(util.inflate_long(digest, 1), k) +104 m = Message() +105 m.add_string('ssh-dss') 106 # apparently, in rare cases, r or s may be shorter than 20 bytes! -107 rstr = util.deflate_long(r, 0) -108 sstr = util.deflate_long(s, 0) +107 rstr = util.deflate_long(r, 0) +108 sstr = util.deflate_long(s, 0) 109 if len(rstr) < 20: 110 rstr = '\x00' * (20 - len(rstr)) + rstr 111 if len(sstr) < 20: 112 sstr = '\x00' * (20 - len(sstr)) + sstr -113 m.add_string(rstr + sstr) +113 m.add_string(rstr + sstr) 114 return m
115
116 - def verify_ssh_sig(self, data, msg):
117 if len(str(msg)) == 40: 118 # spies.com bug: signature has no header -119 sig = str(msg) +119 sig = str(msg) 120 else: -121 kind = msg.get_string() +121 kind = msg.get_string() 122 if kind != 'ssh-dss': 123 return 0 -124 sig = msg.get_string() +124 sig = msg.get_string() 125 126 # pull out (r, s) which are NOT encoded as mpints -127 sigR = util.inflate_long(sig[:20], 1) -128 sigS = util.inflate_long(sig[20:], 1) -129 sigM = util.inflate_long(SHA.new(data).digest(), 1) +127 sigR = util.inflate_long(sig[:20], 1) +128 sigS = util.inflate_long(sig[20:], 1) +129 sigM = util.inflate_long(SHA.new(data).digest(), 1) 130 131 dss = DSA.construct((long(self.y), long(self.g), long(self.p), long(self.q))) 132 return dss.verify(sigM, (sigR, sigS))
133
134 - def _encode_key(self):
135 if self.x is None: -136 raise SSHException('Not enough key information') +136 raise SSHException('Not enough key information') 137 keylist = [ 0, self.p, self.q, self.g, self.y, self.x ] 138 try: -139 b = BER() -140 b.encode(keylist) -141 except BERException: -142 raise SSHException('Unable to create ber encoding of key') +139 b = BER() +140 b.encode(keylist) +141 except BERException: +142 raise SSHException('Unable to create ber encoding of key') 143 return str(b)
144
145 - def write_private_key_file(self, filename, password=None): @@ -222,7 +222,7 @@ paramiko.rng.StrongLockingRandomPool.get_bytes" class="py-name" href="#" onclick 161 @return: new private key 162 @rtype: L{DSSKey} 163 """ -164 164 randpool.stir() -165 dsa = DSA.generate(bits, randpool.stir() +165 dsa = DSA.generate(bits, randpool.get_bytes, progress_func) -166 key = DSSKey(vals=(dsa.p, dsa.q, dsa.g, dsa.y)) +paramiko.util.randpool" class="py-name" href="#" onclick="return doclink('link-66', 'randpool', 'link-63');">randpool.get_bytes, progress_func) +166 key = DSSKey(vals=(dsa.p, dsa.q, dsa.g, dsa.y)) 167 key.x = dsa.x 168 return key -
169 generate = staticmethod(generate) +169 generate = staticmethod(generate) 170 171 172 ### internals... -173 +173 174
175 - def _from_private_key_file(self, filename, password):
176 data = self._read_private_key_file('DSA', filename, password) @@ -287,19 +287,19 @@ paramiko.RSAKey.generate" class="py-name" href="#" onclick="return doclink('link
182
183 - def _decode_key(self, data):
184 # private key file contains: -185 # DSAPrivateKey = { version = 0, p, q, g, y, x } -186 try: -187 keylist = BER(data).decode() -188 except BERException, x: -189 raise SSHException('Unable to parse key file: ' + str(x)) +185 # DSAPrivateKey = { version = 0, p, q, g, y, x } +186 try: +187 keylist = BER(data).decode() +188 except BERException, x: +189 raise SSHException('Unable to parse key file: ' + str(x)) 190 if (type(keylist) is not list) or (len(keylist) < 6) or (keylist[0] != 0): -191 raise SSHException('not a valid DSA private key file (bad ber encoding)') +191 raise SSHException('not a valid DSA private key file (bad ber encoding)') 192 self.p = keylist[1] 193 self.q = keylist[2] 194 self.g = keylist[3] 195 self.y = keylist[4] 196 self.x = keylist[5] -197 self.size = util.bit_length(self.p) +197 self.size = util.bit_length(self.p)
198