Skip to content

Commit 2a73ff0

Browse files
committed
Remove RSA MIN_KEY_SIZE.
This will be implemented in the `rsa` crate instead of here. See: #336
1 parent 177896d commit 2a73ff0

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

ssh-key/src/private/rsa.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,10 @@ pub struct RsaKeypair {
138138
}
139139

140140
impl RsaKeypair {
141-
/// Minimum allowed RSA key size.
142-
#[cfg(feature = "rsa")]
143-
pub(crate) const MIN_KEY_SIZE: usize = 2048;
144-
145141
/// Generate a random RSA keypair of the given size.
146142
#[cfg(feature = "rsa")]
147143
pub fn random<R: CryptoRng + ?Sized>(rng: &mut R, bit_size: usize) -> Result<Self> {
148-
if bit_size >= Self::MIN_KEY_SIZE {
149-
rsa::RsaPrivateKey::new(rng, bit_size)?.try_into()
150-
} else {
151-
Err(Error::Crypto)
152-
}
144+
rsa::RsaPrivateKey::new(rng, bit_size)?.try_into()
153145
}
154146

155147
/// Create a new keypair from the given `public` and `private` key components.
@@ -261,11 +253,7 @@ impl TryFrom<&RsaKeypair> for rsa::RsaPrivateKey {
261253
],
262254
)?;
263255

264-
if ret.size().saturating_mul(8) >= RsaKeypair::MIN_KEY_SIZE {
265-
Ok(ret)
266-
} else {
267-
Err(Error::Crypto)
268-
}
256+
Ok(ret)
269257
}
270258
}
271259

ssh-key/src/public/rsa.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use encoding::{CheckedSum, Decode, Encode, Reader, Writer};
66

77
#[cfg(feature = "rsa")]
88
use {
9-
crate::private::RsaKeypair,
109
encoding::Uint,
1110
rsa::{pkcs1v15, traits::PublicKeyParts},
1211
sha2::{Digest, digest::const_oid::AssociatedOid},
@@ -28,10 +27,6 @@ pub struct RsaPublicKey {
2827
}
2928

3029
impl RsaPublicKey {
31-
/// Minimum allowed RSA key size.
32-
#[cfg(feature = "rsa")]
33-
pub(crate) const MIN_KEY_SIZE: usize = RsaKeypair::MIN_KEY_SIZE;
34-
3530
/// Create a new [`RsaPublicKey`] with the given components:
3631
///
3732
/// - `e`: RSA public exponent.
@@ -116,11 +111,7 @@ impl TryFrom<&RsaPublicKey> for rsa::RsaPublicKey {
116111
let e = Uint::try_from(&key.e)?;
117112
let ret = rsa::RsaPublicKey::new(n, e).map_err(|_| Error::Crypto)?;
118113

119-
if ret.size().saturating_mul(8) >= RsaPublicKey::MIN_KEY_SIZE {
120-
Ok(ret)
121-
} else {
122-
Err(Error::Crypto)
123-
}
114+
Ok(ret)
124115
}
125116
}
126117

0 commit comments

Comments
 (0)