Permalink
Browse files

basic ssh-agent message unpacking

  • Loading branch information...
1 parent 6002a59 commit a7d819bb0845b0f5aefbb0e95a500c78ec1b7fdb @atl committed Apr 30, 2012
Showing with 16 additions and 1 deletion.
  1. +3 −1 http_signature/sign.py
  2. +13 −0 http_signature/utils.py
View
@@ -8,13 +8,15 @@
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
+from .utils import sig
+
ALGORITHMS = frozenset(['rsa-sha1', 'rsa-sha256', 'rsa-sha512', 'hmac-sha1', 'hmac-sha256', 'hmac-sha512'])
HASHES = {'sha256': SHA256,
'sha1': SHA,
'sha512': SHA512}
class Signer(object):
- def __init__(self, secret='', algorithm='rsa-sha256'):
+ def __init__(self, secret='', algorithm='rsa-sha256', allow_agent=True):
assert algorithm in ALGORITHMS, "Unknown algorithm"
self.sign_algorithm, self.hash_algorithm = algorithm.split('-')
if self.sign_algorithm == 'rsa':
View
@@ -0,0 +1,13 @@
+import struct
+
+def lkv(d):
+ parts = []
+ while d:
+ len = struct.unpack('>I', d[:4])[0]
+ bits = d[4:len+4]
+ parts.append(bits)
+ d = d[len+4:]
+ return parts
+
+def sig(d):
+ return lkv[1]

0 comments on commit a7d819b

Please sign in to comment.