Skip to content

Commit 0a509e6

Browse files
authored
Merge pull request #71 from baloo/baloo/key_storage/try_from
key_storage: use `ssh_key`'s `TryFrom` implementation
2 parents 845c218 + c5ff46d commit 0a509e6

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
5050
sha1 = { version = "0.10.5", default-features = false, features = ["oid"] }
5151
testresult = "0.4.0"
5252
hex-literal = "0.4.1"
53-
ssh-key = { version = "0.6.6", features = ["p256"] }
53+
ssh-key = { version = "0.6.6", features = ["p256", "rsa"] }
5454
p256 = { version = "0.13.2" }
5555
const-str = "0.5.7"
5656
rstest = "0.18.2"

examples/key_storage.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use log::info;
55
use rsa::pkcs1v15::SigningKey;
66
use rsa::sha2::{Sha256, Sha512};
77
use rsa::signature::{RandomizedSigner, SignatureEncoding};
8-
use rsa::BigUint;
98
use sha1::Sha1;
109
#[cfg(windows)]
1110
use ssh_agent_lib::agent::NamedPipeListener as Listener;
@@ -82,13 +81,8 @@ impl Session for KeyStorage {
8281
KeypairData::Rsa(ref key) => {
8382
let algorithm;
8483

85-
let private_key = rsa::RsaPrivateKey::from_components(
86-
BigUint::from_bytes_be(key.public.n.as_bytes()),
87-
BigUint::from_bytes_be(key.public.e.as_bytes()),
88-
BigUint::from_bytes_be(key.private.d.as_bytes()),
89-
vec![],
90-
)
91-
.map_err(AgentError::other)?;
84+
let private_key: rsa::RsaPrivateKey =
85+
key.try_into().map_err(AgentError::other)?;
9286
let mut rng = rand::thread_rng();
9387
let data = &sign_request.data;
9488

0 commit comments

Comments
 (0)