Add RsaPublicKey::new_unchecked
(#206)
Constructor for `RsaPublicKey` which bypasses all checks around the modulus and public exponent size.
This commit is contained in:
parent
9066931701
commit
8a1026b379
12
src/key.rs
12
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<Self> {
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user