Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ssh-key/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ p256 = { version = "0.14", optional = true, default-features = false, features =
p384 = { version = "0.14", optional = true, default-features = false, features = ["ecdsa"] }
p521 = { version = "0.14", optional = true, default-features = false, features = ["ecdsa"] }
rand_core = { version = "0.10", optional = true, default-features = false }
rsa = { version = "0.10.0-rc.20", optional = true, default-features = false }
rsa = { version = "0.10", optional = true, default-features = false, features = ["pkcs1v15"] }
sec1 = { version = "0.8", optional = true, default-features = false, features = ["point"] }
serde = { version = "1.0.16", optional = true }
sha1 = { version = "0.11", optional = true, default-features = false, features = ["oid"] }
Expand Down
22 changes: 11 additions & 11 deletions ssh-key/src/private/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl RsaKeypair {
#[cfg(feature = "rsa")]
#[expect(clippy::missing_errors_doc, reason = "TODO")]
pub fn random<R: CryptoRng + ?Sized>(rng: &mut R, bit_size: usize) -> Result<Self> {
rsa::RsaPrivateKey::new(rng, bit_size)?.try_into()
rsa::PrivateKey::new(rng, bit_size)?.try_into()
}

/// Create a new keypair from the given `public` and `private` key components.
Expand Down Expand Up @@ -245,20 +245,20 @@ impl From<&RsaKeypair> for RsaPublicKey {
}

#[cfg(feature = "rsa")]
impl TryFrom<RsaKeypair> for rsa::RsaPrivateKey {
impl TryFrom<RsaKeypair> for rsa::PrivateKey {
type Error = Error;

fn try_from(key: RsaKeypair) -> Result<rsa::RsaPrivateKey> {
rsa::RsaPrivateKey::try_from(&key)
fn try_from(key: RsaKeypair) -> Result<rsa::PrivateKey> {
rsa::PrivateKey::try_from(&key)
}
}

#[cfg(feature = "rsa")]
impl TryFrom<&RsaKeypair> for rsa::RsaPrivateKey {
impl TryFrom<&RsaKeypair> for rsa::PrivateKey {
type Error = Error;

fn try_from(key: &RsaKeypair) -> Result<rsa::RsaPrivateKey> {
let ret = rsa::RsaPrivateKey::from_components(
fn try_from(key: &RsaKeypair) -> Result<rsa::PrivateKey> {
let ret = rsa::PrivateKey::from_components(
Uint::try_from(key.public.n())?,
Uint::try_from(key.public.e())?,
Uint::try_from(&key.private.d)?,
Expand All @@ -273,19 +273,19 @@ impl TryFrom<&RsaKeypair> for rsa::RsaPrivateKey {
}

#[cfg(feature = "rsa")]
impl TryFrom<rsa::RsaPrivateKey> for RsaKeypair {
impl TryFrom<rsa::PrivateKey> for RsaKeypair {
type Error = Error;

fn try_from(key: rsa::RsaPrivateKey) -> Result<RsaKeypair> {
fn try_from(key: rsa::PrivateKey) -> Result<RsaKeypair> {
RsaKeypair::try_from(&key)
}
}

#[cfg(feature = "rsa")]
impl TryFrom<&rsa::RsaPrivateKey> for RsaKeypair {
impl TryFrom<&rsa::PrivateKey> for RsaKeypair {
type Error = Error;

fn try_from(key: &rsa::RsaPrivateKey) -> Result<RsaKeypair> {
fn try_from(key: &rsa::PrivateKey) -> Result<RsaKeypair> {
// Multi-prime keys are not supported
if key.primes().len() > 2 {
return Err(Error::Crypto);
Expand Down
20 changes: 10 additions & 10 deletions ssh-key/src/public/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,41 @@ impl Hash for RsaPublicKey {
}

#[cfg(feature = "rsa")]
impl TryFrom<RsaPublicKey> for rsa::RsaPublicKey {
impl TryFrom<RsaPublicKey> for rsa::PublicKey {
type Error = Error;

fn try_from(key: RsaPublicKey) -> Result<rsa::RsaPublicKey> {
rsa::RsaPublicKey::try_from(&key)
fn try_from(key: RsaPublicKey) -> Result<rsa::PublicKey> {
rsa::PublicKey::try_from(&key)
}
}

#[cfg(feature = "rsa")]
impl TryFrom<&RsaPublicKey> for rsa::RsaPublicKey {
impl TryFrom<&RsaPublicKey> for rsa::PublicKey {
type Error = Error;

fn try_from(key: &RsaPublicKey) -> Result<rsa::RsaPublicKey> {
fn try_from(key: &RsaPublicKey) -> Result<rsa::PublicKey> {
let n = Uint::try_from(&key.n)?;
let e = Uint::try_from(&key.e)?;
let ret = rsa::RsaPublicKey::new(n, e).map_err(|_| Error::Crypto)?;
let ret = rsa::PublicKey::new(n, e).map_err(|_| Error::Crypto)?;

Ok(ret)
}
}

#[cfg(feature = "rsa")]
impl TryFrom<rsa::RsaPublicKey> for RsaPublicKey {
impl TryFrom<rsa::PublicKey> for RsaPublicKey {
type Error = Error;

fn try_from(key: rsa::RsaPublicKey) -> Result<RsaPublicKey> {
fn try_from(key: rsa::PublicKey) -> Result<RsaPublicKey> {
RsaPublicKey::try_from(&key)
}
}

#[cfg(feature = "rsa")]
impl TryFrom<&rsa::RsaPublicKey> for RsaPublicKey {
impl TryFrom<&rsa::PublicKey> for RsaPublicKey {
type Error = Error;

fn try_from(key: &rsa::RsaPublicKey) -> Result<RsaPublicKey> {
fn try_from(key: &rsa::PublicKey) -> Result<RsaPublicKey> {
RsaPublicKey::new(key.e().into(), key.n().as_ref().into())
}
}
Expand Down
2 changes: 1 addition & 1 deletion ssh-key/tests/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fn round_trip_rsa_3072() {
_ => unreachable!(),
};

let rsa_private_key = rsa::RsaPrivateKey::try_from(rsa_keypair).unwrap();
let rsa_private_key = rsa::PrivateKey::try_from(rsa_keypair).unwrap();
let rsa_keypair2 = ssh_key::private::RsaKeypair::try_from(&rsa_private_key).unwrap();
assert_eq!(rsa_keypair, &rsa_keypair2);
}
Expand Down
Loading