I found in RFC4253 that:
7.1. Algorithm Negotiation
Key exchange begins by each side sending the following packet:
byte SSH_MSG_KEXINIT byte[16] cookie (random bytes) name-list kex_algorithms name-list server_host_key_algorithms name-list encryption_algorithms_client_to_server name-list encryption_algorithms_server_to_client name-list mac_algorithms_client_to_server name-list mac_algorithms_server_to_client name-list compression_algorithms_client_to_server name-list compression_algorithms_server_to_client name-list languages_client_to_server name-list languages_server_to_client boolean first_kex_packet_follows uint32 0 (reserved for future extension)
Each of the algorithm name-lists MUST be a comma-separated list of algorithm names (see Algorithm Naming in [SSH-ARCH] and additional
information in [SSH-NUMBERS]). Each supported (allowed) algorithm
MUST be listed in order of preference, from most to least.
But I can not find in RFC nothing about how to separate name-lists in payload..
EDIT: All solved with DataInputStream
, using it's convenient methods readByte(byte[] b, int off, int len)
, readInt()
and readBoolean()
.
As the RFC states, there is more information in SSH-ARCH
which is RFC 4251. Here is a partial excerpt of how name-list
is defined:
A string containing a comma-separated list of names. A name-list is represented as a uint32 containing its length (number of bytes that follow) followed by a comma-separated list of zero or more names.
So after you have read the first 17 bytes of the key exchange packet, you will want to read 4 bytes which will tell you how many bytes (it's ASCII encoded so 1 byte per character) you will need to read to consume the rest of that name-list
. Then you repeat this process for each subsequent list.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments