-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] ssh-encoding: PEM line width detection
Uses the line width detection support added to `pem-rfc7468` in RustCrypto/formats#1464 to automatically detect the input line width and parse PEM documents accordingly, which allows support for a wider range of SSH keys which don't use the default 70 chars of line wrapping. Closes #195
- Loading branch information
Showing
6 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-----BEGIN OPENSSH PRIVATE KEY----- | ||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz | ||
c2gtZWQyNTUxOQAAACCzPq7zfqLffKoBDe/eo04kH2XxtSmk9D7RQyf1xUqrYgAA | ||
AJgAIAxdACAMXQAAAAtzc2gtZWQyNTUxOQAAACCzPq7zfqLffKoBDe/eo04kH2Xx | ||
tSmk9D7RQyf1xUqrYgAAAEC2BsIi0QwW2uFscKTUUXNHLsYX4FxlaSDSblbAj7WR | ||
7bM+rvN+ot98qgEN796jTiQfZfG1KaT0PtFDJ/XFSqtiAAAAEHVzZXJAZXhhbXBs | ||
ZS5jb20BAgMEBQ== | ||
-----END OPENSSH PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ const OPENSSH_ECDSA_P521_EXAMPLE: &str = include_str!("examples/id_ecdsa_p521"); | |
/// Ed25519 OpenSSH-formatted private key | ||
const OPENSSH_ED25519_EXAMPLE: &str = include_str!("examples/id_ed25519"); | ||
|
||
/// Ed25519 OpenSSH-formatted private key with 64-column line wrapping | ||
const OPENSSH_ED25519_64COLS_EXAMPLE: &str = include_str!("examples/id_ed25519.64cols"); | ||
|
||
/// RSA (3072-bit) OpenSSH-formatted public key | ||
#[cfg(feature = "alloc")] | ||
const OPENSSH_RSA_3072_EXAMPLE: &str = include_str!("examples/id_rsa_3072"); | ||
|
@@ -247,6 +250,14 @@ fn decode_ed25519_openssh() { | |
assert_eq!(key.comment(), "[email protected]"); | ||
} | ||
|
||
/// Test alternative PEM line wrappings (64 columns). | ||
#[test] | ||
fn decode_ed25519_openssh_64cols() { | ||
let key = PrivateKey::from_openssh(OPENSSH_ED25519_64COLS_EXAMPLE).unwrap(); | ||
let other_key = PrivateKey::from_openssh(OPENSSH_ED25519_EXAMPLE).unwrap(); | ||
assert_eq!(key, other_key); | ||
} | ||
|
||
#[cfg(feature = "alloc")] | ||
#[test] | ||
fn decode_rsa_3072_openssh() { | ||
|