From e9911c695ca77e0cbade74b21e51582ead1f0f57 Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Thu, 24 Nov 2022 22:59:02 +0800
Subject: [PATCH] Improve some comments

---
 src/kex.rs     | 10 ++++++++--
 src/runner.rs  |  2 ++
 src/sshwire.rs |  9 +++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/kex.rs b/src/kex.rs
index 265719b..c04770f 100644
--- a/src/kex.rs
+++ b/src/kex.rs
@@ -132,8 +132,9 @@ impl KexHash {
 
         // TODO: q_c and q_s need to be padded as mpint (extra 0x00 if high bit set)
         // for ecdsa and DH modes, but not for curve25519.
-        // Hack test for ed25519 algo
-        assert_eq!(q_c.len(), 32);
+
+        // A hacky sanity check that this is curve25519
+        debug_assert_eq!(q_c.len(), 32);
 
         self.hash_slice(q_c);
         self.hash_slice(q_s);
@@ -573,6 +574,9 @@ mod tests {
     use crate::*;
     use crate::sunsetlog::init_test_log;
 
+    // TODO:
+    // - test algo negotiation
+
     use super::SSH_NAME_CURVE25519;
 
     #[test]
@@ -594,6 +598,8 @@ mod tests {
 
     // Unknown names fail. This is easy to hit if the names of from_name()
     // match statements are mistyped or aren't imported.
+    // These are separate tests because they trigger `Error::bug()` which
+    // is an explicit panic in debug builds.
     #[test]
     #[should_panic]
     fn test_unknown_kex() {
diff --git a/src/runner.rs b/src/runner.rs
index 46d6d89..8b505ad 100644
--- a/src/runner.rs
+++ b/src/runner.rs
@@ -256,6 +256,8 @@ impl<'a> Runner<'a> {
     // Returns the maximum data that may be sent to a channel, or
     // `None` on channel closed
     pub fn ready_channel_send(&self, chan: u32, is_ext: bool) -> Option<usize> {
+        // TODO: return 0 if InKex means we can't transmit packets. 
+
         // minimum of buffer space and channel window available
         let payload_space = self.traf_out.send_allowed(&self.keys);
         let offset = if is_ext {
diff --git a/src/sshwire.rs b/src/sshwire.rs
index 93e5c18..c564bd8 100644
--- a/src/sshwire.rs
+++ b/src/sshwire.rs
@@ -285,13 +285,14 @@ impl<'de> SSHDecode<'de> for BinString<'de> {
 ///
 /// The SSH protocol defines it to be UTF-8, though
 /// in some applications it could be treated as ASCII-only.
-/// The library treats it as an opaque `&[u8]`, leaving
+/// Sunset treats it as an opaque `&[u8]`, leaving
 /// decoding to the [`Behaviour`].
 ///
-/// Note that SSH protocol identifiers in `Packet` etc
-/// are `&str` rather than `TextString`, and always defined as ASCII.
+/// Note that SSH protocol identifiers in `Packet`
+/// are `&str` rather than `TextString`, and always defined as ASCII. For
+/// example `"publickey"`, `"ssh-rsa"`.
 /// Application API
-#[derive(Clone,PartialEq,Copy)]
+#[derive(Clone,PartialEq,Copy,Default)]
 pub struct TextString<'a>(pub &'a [u8]);
 
 impl<'a> TextString<'a> {
-- 
GitLab