diff --git a/ssh-key/src/private/rsa.rs b/ssh-key/src/private/rsa.rs index a1d5989..378cf17 100644 --- a/ssh-key/src/private/rsa.rs +++ b/ssh-key/src/private/rsa.rs @@ -10,10 +10,7 @@ use zeroize::Zeroize; use { encoding::Uint, rand_core::CryptoRng, - rsa::{ - pkcs1v15, - traits::{PrivateKeyParts, PublicKeyParts}, - }, + rsa::{pkcs1v15, traits::PrivateKeyParts}, sha2::{Digest, digest::const_oid::AssociatedOid}, }; @@ -138,18 +135,10 @@ pub struct RsaKeypair { } impl RsaKeypair { - /// Minimum allowed RSA key size. - #[cfg(feature = "rsa")] - pub(crate) const MIN_KEY_SIZE: usize = 2048; - /// Generate a random RSA keypair of the given size. #[cfg(feature = "rsa")] pub fn random(rng: &mut R, bit_size: usize) -> Result { - if bit_size >= Self::MIN_KEY_SIZE { - rsa::RsaPrivateKey::new(rng, bit_size)?.try_into() - } else { - Err(Error::Crypto) - } + rsa::RsaPrivateKey::new(rng, bit_size)?.try_into() } /// Create a new keypair from the given `public` and `private` key components. @@ -261,11 +250,7 @@ impl TryFrom<&RsaKeypair> for rsa::RsaPrivateKey { ], )?; - if ret.size().saturating_mul(8) >= RsaKeypair::MIN_KEY_SIZE { - Ok(ret) - } else { - Err(Error::Crypto) - } + Ok(ret) } } diff --git a/ssh-key/src/public/rsa.rs b/ssh-key/src/public/rsa.rs index cb5739f..5d43471 100644 --- a/ssh-key/src/public/rsa.rs +++ b/ssh-key/src/public/rsa.rs @@ -6,7 +6,6 @@ use encoding::{CheckedSum, Decode, Encode, Reader, Writer}; #[cfg(feature = "rsa")] use { - crate::private::RsaKeypair, encoding::Uint, rsa::{pkcs1v15, traits::PublicKeyParts}, sha2::{Digest, digest::const_oid::AssociatedOid}, @@ -28,10 +27,6 @@ pub struct RsaPublicKey { } impl RsaPublicKey { - /// Minimum allowed RSA key size. - #[cfg(feature = "rsa")] - pub(crate) const MIN_KEY_SIZE: usize = RsaKeypair::MIN_KEY_SIZE; - /// Create a new [`RsaPublicKey`] with the given components: /// /// - `e`: RSA public exponent. @@ -116,11 +111,7 @@ impl TryFrom<&RsaPublicKey> for rsa::RsaPublicKey { let e = Uint::try_from(&key.e)?; let ret = rsa::RsaPublicKey::new(n, e).map_err(|_| Error::Crypto)?; - if ret.size().saturating_mul(8) >= RsaPublicKey::MIN_KEY_SIZE { - Ok(ret) - } else { - Err(Error::Crypto) - } + Ok(ret) } }