summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-05-05 01:15:37 -0400
committerMike Crute <mcrute@gmail.com>2010-05-05 01:15:37 -0400
commitb897f03e9f1690c05d01e6c697d2d6917e747c48 (patch)
treeab2043697d5d52a268505f5d00c0c2989ae542b9
parent94d63f71526c8471cd6a432bc12c14ab2a2742d7 (diff)
downloadhg_sshsign-b897f03e9f1690c05d01e6c697d2d6917e747c48.tar.bz2
hg_sshsign-b897f03e9f1690c05d01e6c697d2d6917e747c48.tar.xz
hg_sshsign-b897f03e9f1690c05d01e6c697d2d6917e747c48.zip
Expanding test cases trying to figure out why key agent signatures don't match command line sigs.
-rw-r--r--keys.py2
-rw-r--r--ssh.py26
-rw-r--r--sshagent.py4
3 files changed, 27 insertions, 5 deletions
diff --git a/keys.py b/keys.py
index 9b6b837..8d3a5b2 100644
--- a/keys.py
+++ b/keys.py
@@ -24,7 +24,7 @@ def load_public_key(key):
24 24
25 if ktype == 'ssh-rsa': 25 if ktype == 'ssh-rsa':
26 e, n = get_packed_mp_ints(remainder, 2) 26 e, n = get_packed_mp_ints(remainder, 2)
27 return hawt.new_pub_key((e, n)) 27 return RSA.new_pub_key((e, n))
28 elif ktype == 'ssh-dss': 28 elif ktype == 'ssh-dss':
29 p, q, g, y = get_packed_mp_ints(remainder, 4) 29 p, q, g, y = get_packed_mp_ints(remainder, 4)
30 return DSA.set_params(p, q, g) 30 return DSA.set_params(p, q, g)
diff --git a/ssh.py b/ssh.py
index 4b7e94c..b308f5e 100644
--- a/ssh.py
+++ b/ssh.py
@@ -8,14 +8,36 @@ SSH Key Signing
8 8
9Commands to sign and verify revisions with your 9Commands to sign and verify revisions with your
10ssh key. 10ssh key.
11
12Ponder this, bitches:
13 http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/ssh-rsa.c
14 http://svn.osafoundation.org/m2crypto/trunk/SWIG/_rsa.i
11""" 15"""
12 16
17from M2Crypto.RSA import RSAError
18
13from structutils import bytes_to_int 19from structutils import bytes_to_int
14from sshagent import SSHAgent 20from sshagent import SSHAgent
21from keys import load_private_key, load_public_key
22
23test_data = "Hello world!"
24public_key = "/Users/mcrute/.ssh/id_rsa.ag.pub"
25private_key = "/Users/mcrute/.ssh/id_rsa.ag"
15 26
16key = open('/Users/mcrute/.ssh/id_rsa.ag.pub').read() 27key = open(public_key).read()
17key = key.split()[1].decode('base64') 28key = key.split()[1].decode('base64')
18 29
19agent = SSHAgent() 30agent = SSHAgent()
20signature = agent.sign("Hello world!", key) 31signature = agent.sign(test_data, key)
21print bytes_to_int(signature) 32print bytes_to_int(signature)
33
34
35try:
36 pub_key = load_public_key(open(public_key).read())
37 pub_key.verify(test_data, signature)
38 print "Signature matches"
39except RSAError:
40 print "Signature doesn't match"
41
42priv_key = load_private_key(private_key)
43print bytes_to_int(priv_key.sign(test_data))
diff --git a/sshagent.py b/sshagent.py
index 32dc2f4..8c310f4 100644
--- a/sshagent.py
+++ b/sshagent.py
@@ -75,6 +75,6 @@ class SSHAgent(object):
75 75
76 _, remainder = unpack_int(response[1:]) 76 _, remainder = unpack_int(response[1:])
77 _, remainder = unpack_string(remainder) 77 _, remainder = unpack_string(remainder)
78 response, _ = unpack_mp_int(remainder) 78 response, _ = unpack_string(remainder)
79 79
80 return int_to_bytes(response) 80 return response