【发布时间】:2010-07-09 03:08:27
【问题描述】:
作为一个小型(大型)爱好项目,我已经着手用 C# 制作一个(非常原始的)ssh-2.0 客户端。 这是为了探索和更好地理解 DH,并帮助我熟悉加密技术:)
根据 RFC 4253,我已经开始这样的初始连接:
(省略不相关的 vars 预设等)
Random cookie_gen = new Random();
while ((ssh_response = unsecure_reader.ReadLine()) != null)
{
MessageBox.Show(ssh_response);
if (ssh_response.StartsWith("SSH-2.0-")
{
// you told me your name, now I'll tell you mine
ssh_writer.Write("SSH-2.0-MYSSHCLIENT\r\n");
ssh_writer.Flush();
// now I should write up my supported (which I'll keep to the required as per rfc 4253)
ssh_writer.Write(0x20); // SSH_MSG_KEXINIT
byte[] cookie = new byte[16];
for (int i = 0; i < 16; i++)
cookie[i] = Convert.ToByte(cookie_gen.Next(0, 10));
ssh_writer.Write(cookie); // cookie
// and now for the name-list
// This is where I'm troubled
// "Footer"
ssh_writer.Write(0x00); // first_kex_packet_follows
ssh_writer.Write(0x00); // 0
ssh_writer.Flush();
}
}
正如您在 RFC 4253 的第 16 页所见,我预计会提供 10 个名称列表。这些只是假设是字符串,还是我如何标记每个列表的开始/结束(只需换行 \n)?我什至在正确的轨道上吗? (请记住,我将在此之后处理 DH 和加密。我的问题仅基于到目前为止的初始接触)。
欢迎和感谢任何帮助或 cmets,
PS:我知道库存在,但这与我的项目无关。
【问题讨论】:
-
问题是如何使用 C# 发送名称列表,所以我认为这是一个 C# 问题?我收到了服务器名单,但这本身不是字符串格式,所以我问我应该如何回报我的名单(以哪种格式)。希望这可以清除它:)