diff --git a/src/key.rs b/src/key.rs index ab3351c..b43434d 100644 --- a/src/key.rs +++ b/src/key.rs @@ -250,10 +250,20 @@ impl RsaPublicKey { /// Create a new public key from its components. pub fn new_with_max_size(n: BigUint, e: BigUint, max_size: usize) -> Result { - let k = RsaPublicKey { n, e }; + let k = Self { n, e }; check_public_with_max_size(&k, max_size)?; Ok(k) } + + /// Create a new public key, bypassing checks around the modulus and public + /// exponent size. + /// + /// This method is not recommended, and only intended for unusual use cases. + /// Most applications should use [`RsaPublicKey::new`] or + /// [`RsaPublicKey::new_with_max_size`] instead. + pub fn new_unchecked(n: BigUint, e: BigUint) -> Self { + Self { n, e } + } } impl PublicKeyParts for RsaPrivateKey {