X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=contrib%2Fencodelib.py;h=b9d159e2a781bae54dfedb6e988e68d0828e101b;hb=24da181a01ecd851757549afd20978e0bfac445b;hp=196c4677cb02c5142f4b76ef3ff8f48b4c8df981;hpb=12d5b00d62240d1875be4ac0a6c5d29240696c89;p=PuTTY.git diff --git a/contrib/encodelib.py b/contrib/encodelib.py index 196c4677..b9d159e2 100644 --- a/contrib/encodelib.py +++ b/contrib/encodelib.py @@ -65,10 +65,11 @@ SSH2_MSG_KEXINIT = 20 SSH2_MSG_NEWKEYS = 21 SSH2_MSG_KEXDH_INIT = 30 SSH2_MSG_KEXDH_REPLY = 31 -SSH2_MSG_KEX_DH_GEX_REQUEST = 30 +SSH2_MSG_KEX_DH_GEX_REQUEST_OLD = 30 SSH2_MSG_KEX_DH_GEX_GROUP = 31 SSH2_MSG_KEX_DH_GEX_INIT = 32 SSH2_MSG_KEX_DH_GEX_REPLY = 33 +SSH2_MSG_KEX_DH_GEX_REQUEST = 34 SSH2_MSG_KEXRSA_PUBKEY = 30 SSH2_MSG_KEXRSA_SECRET = 31 SSH2_MSG_KEXRSA_DONE = 32 @@ -113,3 +114,16 @@ def clearpkt(msgtype, *stuff): s += byte(random.randint(0,255)) s = byte(padlen) + s return string(s) + +def decode_uint32(s): + assert len(s) == 4 + return struct.unpack(">I", s)[0] + +def read_clearpkt(fh): + length_field = fh.read(4) + s = fh.read(decode_uint32(length_field)) + import sys + padlen = ord(s[0]) + s = s[1:-padlen] + msgtype = ord(s[0]) + return msgtype, s[1:]