Support additional SSH key algorithms#136
Conversation
Adds an `AlgorithmName` type for additional algorithm names. The syntax for additional algorithm names is described in [section 6 of RFC4251]. Introduces a dependency on `tinystr`. Using `tinystr::TinyAsciiStr` for the representing algorithm names enables `AlgorithmName` to be `Copy`. [section 6 of RFC4261]: https://www.rfc-editor.org/rfc/rfc4251.html#section-6
Adds a new `Algorithm::Other` variant for representing additional algorithms. Breaking changes: `Algorithm::as_str`, `Algorithm::as_certificate_str` now return `&str` instead of `&static str`.
Adds the `Keypair::Other` and `KeyData::Other` variants for storing the key material of keys that use a custom algorithm. Adds the `OpaqueKeypair` and `OpaqueKeyData` types for representing keys meant to be used with an algorithm unknown to this crate (e.g. custom algorithms). They are said to be opaque, because the meaning of their underlying byte representation is not specified.
ssh-key/Cargo.toml
Outdated
| sec1 = { version = "0.7", optional = true, default-features = false, features = ["point"] } | ||
| serde = { version = "1", optional = true } | ||
| sha1 = { version = "0.10", optional = true, default-features = false } | ||
| tinystr = { version = "0.7.1", optional = true, default-features = false } |
There was a problem hiding this comment.
I'd prefer not to add additional dependencies unless absolutely necessary.
There was a problem hiding this comment.
That is understandable. I jotted down some alternatives in my other comment: #136 (comment)
|
Since the |
|
Thank you for the quick review!
I had considered this possibility, but there were a few snags:
The first option made most sense to me, and since I wanted to keep |
|
Okay, yes, that's a problem. Perhaps you can make Alternatively I guess it's fine to drop the |
This replaces the `tinystr` dependency with a hand-rolled `AsciiStr` implementation.
This ensures the size of `Error::UnsupportedAlgorithm` doesn't exceed the maximum allowed by the `result_large_err` clippy lint.
Sounds good! 8d73988 removes the I also moved Let me know if you'd like me to squash any of these changes before you re-review. |
|
My gut feeling looking at this, and The The drawback of using a stack-allocated string type is it makes |
Update `Algorithm` in preparation for the change that will make `AlgorithmName` (and thus `Algorithm`) non-`Copy`.
This reverts commit 98de060.
Good point! Thank you for bearing with me. I made I also reverted 2bd496b, which is no longer necessary. |
This introduces an additional "catch-all" key type to
ssh-keyto support additional SSH key algorithms, as described in #135.I recommend reviewing this PR commit by commit (I've split the change into 3 logical chunks to make it easier to review):
Let me know if you disagree with my approach, I'm happy to rework this if needed.
Closes #135