SSH2 算法协商数据包负载中的名称列表如何分离?
How name-lists are separated in SSH2 algorithm negotiation packet payload?
我在 RFC4253 中发现:
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.
但我在 RFC 中找不到关于如何在有效负载中分隔名称列表的任何内容..
编辑:
全部用 DataInputStream
解决,使用它的便捷方法 readByte(byte[] b, int off, int len)
、readInt()
和 readBoolean()
.
如 RFC 所述,SSH-ARCH
中有更多信息,即 RFC 4251。以下是 name-list
定义的部分摘录:
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.
因此,在您读取密钥交换数据包的前 17 个字节后,您将需要读取 4 个字节,这将告诉您需要读取多少字节(它是 ASCII 编码的,因此每个字符 1 个字节)消耗掉剩下的 name-list
。然后对每个后续列表重复此过程。
我在 RFC4253 中发现:
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.
但我在 RFC 中找不到关于如何在有效负载中分隔名称列表的任何内容..
编辑:
全部用 DataInputStream
解决,使用它的便捷方法 readByte(byte[] b, int off, int len)
、readInt()
和 readBoolean()
.
如 RFC 所述,SSH-ARCH
中有更多信息,即 RFC 4251。以下是 name-list
定义的部分摘录:
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.
因此,在您读取密钥交换数据包的前 17 个字节后,您将需要读取 4 个字节,这将告诉您需要读取多少字节(它是 ASCII 编码的,因此每个字符 1 个字节)消耗掉剩下的 name-list
。然后对每个后续列表重复此过程。