summaryrefslogtreecommitdiff
path: root/paramiko/dsskey.py
diff options
context:
space:
mode:
authorChris Rose <offby1@offby1.net>2014-04-14 17:38:05 -0400
committerChris Rose <offby1@offby1.net>2014-04-14 18:50:10 -0400
commit34d03ae3dc4f08657f638e85c4184fb3b1a64e64 (patch)
treef3ca30ce1dc6e69a982479b405f3f05dfa437382 /paramiko/dsskey.py
parentab08ef6651dcb61d32d228106673f00e3e47bde7 (diff)
downloadparamiko-34d03ae3dc4f08657f638e85c4184fb3b1a64e64.tar.gz
Revert a regression in DSS key generation
A change in f0017b833098 caused a random regression in DSS key signing due to moving the padding on the integers generated by DSA from the left to the right. So, for example, if signing the test case string "jerri blank", the random number might be generated as: k=703745698612177278239572677252380378525350342103 If so, the signature parts will be: r=184615963997659989901526712385095827509599268253 s=2682547683721156713440053885014828604195555319 Note the s being shorter. Prior to f0017b833098, s would be right-padded with zeros: s=268254768372115671344005388501482860419555531900 After, it would be left-padded: s=002682547683721156713440053885014828604195555319 When converting back to a long, that loses the padding. This change restores the behaviour. Fixes #308
Diffstat (limited to 'paramiko/dsskey.py')
-rw-r--r--paramiko/dsskey.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py
index c26966e8..6a46d326 100644
--- a/paramiko/dsskey.py
+++ b/paramiko/dsskey.py
@@ -111,9 +111,9 @@ class DSSKey (PKey):
rstr = util.deflate_long(r, 0)
sstr = util.deflate_long(s, 0)
if len(rstr) < 20:
- rstr += zero_byte * (20 - len(rstr))
+ rstr = zero_byte * (20 - len(rstr)) + rstr
if len(sstr) < 20:
- sstr += zero_byte * (20 - len(sstr))
+ sstr = zero_byte * (20 - len(sstr)) + sstr
m.add_string(rstr + sstr)
return m