原始ssh连接(低级)

作为一个小型(大型)业余爱好项目,我打算在C#中创建一个(非常原始的)ssh-2.0客户端。 这是为了探索和更好地理解DH,并帮助我的加密熟悉:)

根据RFC 4253,我已经开始了这样的初始连接:

(省略不相关的变量预设等)

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和加密。我的问题完全基于迄今为止的初始接触)。

任何帮助或评论都受到欢迎和赞赏,

PS:我知道库存在,但这与我的项目无关。

好吧,正如RFC 4251第9页所述:

绝不能使用终止空字符,既不能用于单个名称,也不能用于整个列表。

在命名的RFC中也有例子。