From cc384f972b94119476697c6bf8cf2d08dda92d67 Mon Sep 17 00:00:00 2001 From: Tsur Devson Date: Wed, 26 Mar 2025 12:29:40 +0800 Subject: [PATCH 1/2] ssh-encoding: fix `encoded_len` for `[u8; N]` Followup to #342, which only updated the `encode` method. This aligns the `encoded_len` method with that change. --- ssh-encoding/src/encode.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ssh-encoding/src/encode.rs b/ssh-encoding/src/encode.rs index 44730ab..d26d312 100644 --- a/ssh-encoding/src/encode.rs +++ b/ssh-encoding/src/encode.rs @@ -155,7 +155,7 @@ impl Encode for [u8] { } } -/// Encodes `[u8; N]` into `byte[n]` as described in [RFC4251 § 5]: +/// Encodes `[u8; N]` into `byte[N]` as described in [RFC4251 § 5]: /// /// > A byte represents an arbitrary 8-bit value (octet). Fixed length /// > data is sometimes represented as an array of bytes, written @@ -167,7 +167,7 @@ impl Encode for [u8] { /// [RFC4251 § 5]: https://datatracker.ietf.org/doc/html/rfc4251#section-5 impl Encode for [u8; N] { fn encoded_len(&self) -> Result { - self.as_slice().encoded_len() + Ok(N) } fn encode(&self, writer: &mut impl Writer) -> Result<(), Error> { From 0900de9c6dd25ee08a0ace4b557ab60e4d31865f Mon Sep 17 00:00:00 2001 From: Tsur Devson Date: Thu, 27 Mar 2025 00:10:01 +0800 Subject: [PATCH 2/2] ssh-encoding: apply review suggestion Co-authored-by: Tony Arcieri --- ssh-encoding/src/encode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh-encoding/src/encode.rs b/ssh-encoding/src/encode.rs index d26d312..a43e52f 100644 --- a/ssh-encoding/src/encode.rs +++ b/ssh-encoding/src/encode.rs @@ -155,7 +155,7 @@ impl Encode for [u8] { } } -/// Encodes `[u8; N]` into `byte[N]` as described in [RFC4251 § 5]: +/// Encodes byte array using `byte[n]` encoding as described in [RFC4251 § 5]: /// /// > A byte represents an arbitrary 8-bit value (octet). Fixed length /// > data is sometimes represented as an array of bytes, written