Skip to content

Commit

Permalink
Merge pull request #71 from baloo/baloo/key_storage/try_from
Browse files Browse the repository at this point in the history
key_storage: use `ssh_key`'s `TryFrom` implementation
  • Loading branch information
baloo authored May 18, 2024
2 parents 845c218 + c5ff46d commit 0a509e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
sha1 = { version = "0.10.5", default-features = false, features = ["oid"] }
testresult = "0.4.0"
hex-literal = "0.4.1"
ssh-key = { version = "0.6.6", features = ["p256"] }
ssh-key = { version = "0.6.6", features = ["p256", "rsa"] }
p256 = { version = "0.13.2" }
const-str = "0.5.7"
rstest = "0.18.2"
Expand Down
10 changes: 2 additions & 8 deletions examples/key_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use log::info;
use rsa::pkcs1v15::SigningKey;
use rsa::sha2::{Sha256, Sha512};
use rsa::signature::{RandomizedSigner, SignatureEncoding};
use rsa::BigUint;
use sha1::Sha1;
#[cfg(windows)]
use ssh_agent_lib::agent::NamedPipeListener as Listener;
Expand Down Expand Up @@ -82,13 +81,8 @@ impl Session for KeyStorage {
KeypairData::Rsa(ref key) => {
let algorithm;

let private_key = rsa::RsaPrivateKey::from_components(
BigUint::from_bytes_be(key.public.n.as_bytes()),
BigUint::from_bytes_be(key.public.e.as_bytes()),
BigUint::from_bytes_be(key.private.d.as_bytes()),
vec![],
)
.map_err(AgentError::other)?;
let private_key: rsa::RsaPrivateKey =
key.try_into().map_err(AgentError::other)?;
let mut rng = rand::thread_rng();
let data = &sign_request.data;

Expand Down

0 comments on commit 0a509e6

Please sign in to comment.