You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenSSH private keys contain a comment field in the binary serialization
encoded as an RFC4251 `string` type, which is described as follows:
Arbitrary length binary string. Strings are allowed to contain
arbitrary binary data, including null characters and 8-bit
characters
Previously this field was stored using Rust's `String` type which
constrains the allowed encoding of the comments to UTF-8, leading to a
failure to parse keys containing such comments.
This has been changed to store a `Vec<u8>`, with helper methods
`comment_str` and `comment_str_lossy` to obtain `&str` references, and
`comment` bytes to get the raw value. The original `comment` methods
have been deprecated.
The lossy algorithm decodes as much of the string as possible as UTF-8.
The public key serialization, which encodes the key as a one-line
string, uses the lossy encoding of the comment so as to still remain
`String`-compatible. If there's desire to correct this, it will require
more substantial changes to the entire public key decoder/encoder.
Fixes#331
assert_eq!(authorized_keys[4].public_key().to_string(),"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBN76zuqnjypL54/w4763l7q1Sn3IBYHptJ5wcYfEWkzeNTvpexr05Z18m2yPT2SWRd1JJ8Aj5TYidG9MdSS5J78= hello world this is a long comment");
0 commit comments