pub struct RsaPublicKey { /* private fields */ }Expand description
Represents the public part of an RSA key.
Implementations§
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub fn encrypt<R: CryptoRng + ?Sized, P: PaddingScheme>(
&self,
rng: &mut R,
padding: P,
msg: &[u8],
) -> Result<Vec<u8>>
pub fn encrypt<R: CryptoRng + ?Sized, P: PaddingScheme>( &self, rng: &mut R, padding: P, msg: &[u8], ) -> Result<Vec<u8>>
Encrypt the given message.
Sourcepub fn verify<S: SignatureScheme>(
&self,
scheme: S,
hashed: &[u8],
sig: &[u8],
) -> Result<()>
pub fn verify<S: SignatureScheme>( &self, scheme: S, hashed: &[u8], sig: &[u8], ) -> Result<()>
Verify a signed message.
hashed must be the result of hashing the input using the hashing function
passed in through hash.
If the message is valid Ok(()) is returned, otherwise an Err indicating failure.
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub const MIN_PUB_EXPONENT: u64 = 2
pub const MIN_PUB_EXPONENT: u64 = 2
Minimum value of the public exponent e.
Sourcepub const MAX_PUB_EXPONENT: u64
pub const MAX_PUB_EXPONENT: u64
Maximum value of the public exponent e.
Sourcepub fn new(n: BoxedUint, e: BoxedUint) -> Result<Self>
pub fn new(n: BoxedUint, e: BoxedUint) -> Result<Self>
Create a new public key from its components.
This function accepts public keys with a modulus size up to 4096-bits,
i.e. RsaPublicKey::MAX_SIZE.
Sourcepub fn new_with_max_size(
n: BoxedUint,
e: BoxedUint,
max_size: usize,
) -> Result<Self>
pub fn new_with_max_size( n: BoxedUint, e: BoxedUint, max_size: usize, ) -> Result<Self>
Create a new public key from its components.
Sourcepub fn new_unchecked(n: BoxedUint, e: BoxedUint) -> Self
pub fn new_unchecked(n: BoxedUint, e: BoxedUint) -> Self
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.
Trait Implementations§
Source§impl AsRef<RsaPublicKey> for RsaPrivateKey
impl AsRef<RsaPublicKey> for RsaPrivateKey
Source§fn as_ref(&self) -> &RsaPublicKey
fn as_ref(&self) -> &RsaPublicKey
Source§impl<D> AsRef<RsaPublicKey> for VerifyingKey<D>where
D: Digest,
impl<D> AsRef<RsaPublicKey> for VerifyingKey<D>where
D: Digest,
Source§fn as_ref(&self) -> &RsaPublicKey
fn as_ref(&self) -> &RsaPublicKey
Source§impl<D> AsRef<RsaPublicKey> for VerifyingKey<D>where
D: Digest,
impl<D> AsRef<RsaPublicKey> for VerifyingKey<D>where
D: Digest,
Source§fn as_ref(&self) -> &RsaPublicKey
fn as_ref(&self) -> &RsaPublicKey
Source§impl Clone for RsaPublicKey
impl Clone for RsaPublicKey
Source§fn clone(&self) -> RsaPublicKey
fn clone(&self) -> RsaPublicKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RsaPublicKey
impl Debug for RsaPublicKey
Source§impl DecodeRsaPublicKey for RsaPublicKey
Available on crate feature encoding only.
impl DecodeRsaPublicKey for RsaPublicKey
encoding only.Source§fn from_pkcs1_der(bytes: &[u8]) -> Result<Self>
fn from_pkcs1_der(bytes: &[u8]) -> Result<Self>
RsaPublicKey
(binary format).Source§fn from_pkcs1_pem(s: &str) -> Result<Self, Error>
fn from_pkcs1_pem(s: &str) -> Result<Self, Error>
pem only.RsaPublicKey. Read moreSource§fn read_pkcs1_der_file(path: impl AsRef<Path>) -> Result<Self, Error>
fn read_pkcs1_der_file(path: impl AsRef<Path>) -> Result<Self, Error>
std only.RsaPublicKey from an ASN.1 DER-encoded file on the local
filesystem (binary format).Source§fn read_pkcs1_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>
fn read_pkcs1_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>
pem and std only.RsaPublicKey from a PEM-encoded file on the local filesystem.Source§impl<'de> Deserialize<'de> for RsaPublicKey
Available on crate feature serde only.
impl<'de> Deserialize<'de> for RsaPublicKey
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl EncodePublicKey for RsaPublicKey
Available on crate feature encoding only.
impl EncodePublicKey for RsaPublicKey
encoding only.Source§fn to_public_key_der(&self) -> Result<Document>
fn to_public_key_der(&self) -> Result<Document>
Document containing a SPKI-encoded public key.Source§fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
pem only.LineEnding.Source§fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
std only.Source§fn write_public_key_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_public_key_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
pem and std only.Source§impl EncodeRsaPublicKey for RsaPublicKey
Available on crate feature encoding only.
impl EncodeRsaPublicKey for RsaPublicKey
encoding only.Source§fn to_pkcs1_der(&self) -> Result<Document>
fn to_pkcs1_der(&self) -> Result<Document>
Document containing a PKCS#1-encoded public key.Source§fn to_pkcs1_pem(&self, line_ending: LineEnding) -> Result<String, Error>
fn to_pkcs1_pem(&self, line_ending: LineEnding) -> Result<String, Error>
pem only.Source§fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
std only.Source§fn write_pkcs1_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_pkcs1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
pem and std only.Source§impl From<&RsaPrivateKey> for RsaPublicKey
impl From<&RsaPrivateKey> for RsaPublicKey
Source§fn from(private_key: &RsaPrivateKey) -> Self
fn from(private_key: &RsaPrivateKey) -> Self
Source§impl From<RsaPrivateKey> for RsaPublicKey
impl From<RsaPrivateKey> for RsaPublicKey
Source§fn from(private_key: RsaPrivateKey) -> Self
fn from(private_key: RsaPrivateKey) -> Self
Source§impl<D> From<RsaPublicKey> for VerifyingKey<D>where
D: Digest + AssociatedOid,
impl<D> From<RsaPublicKey> for VerifyingKey<D>where
D: Digest + AssociatedOid,
Source§fn from(key: RsaPublicKey) -> Self
fn from(key: RsaPublicKey) -> Self
Source§impl<D> From<RsaPublicKey> for VerifyingKey<D>where
D: Digest,
impl<D> From<RsaPublicKey> for VerifyingKey<D>where
D: Digest,
Source§fn from(key: RsaPublicKey) -> Self
fn from(key: RsaPublicKey) -> Self
Source§impl<D> From<VerifyingKey<D>> for RsaPublicKeywhere
D: Digest,
impl<D> From<VerifyingKey<D>> for RsaPublicKeywhere
D: Digest,
Source§fn from(key: VerifyingKey<D>) -> Self
fn from(key: VerifyingKey<D>) -> Self
Source§impl<D> From<VerifyingKey<D>> for RsaPublicKeywhere
D: Digest,
impl<D> From<VerifyingKey<D>> for RsaPublicKeywhere
D: Digest,
Source§fn from(key: VerifyingKey<D>) -> Self
fn from(key: VerifyingKey<D>) -> Self
Source§impl Hash for RsaPublicKey
impl Hash for RsaPublicKey
Source§impl PartialEq for RsaPublicKey
impl PartialEq for RsaPublicKey
Source§impl PublicKeyParts for RsaPublicKey
impl PublicKeyParts for RsaPublicKey
Source§fn n_params(&self) -> &BoxedMontyParams
fn n_params(&self) -> &BoxedMontyParams
Source§fn size(&self) -> usize
fn size(&self) -> usize
Source§fn n_bits_precision(&self) -> u32
fn n_bits_precision(&self) -> u32
n.Source§impl Serialize for RsaPublicKey
Available on crate feature serde only.
impl Serialize for RsaPublicKey
serde only.Source§impl TryFrom<RsaPublicKey<'_>> for RsaPublicKey
Available on crate feature encoding only.
impl TryFrom<RsaPublicKey<'_>> for RsaPublicKey
encoding only.Source§impl TryFrom<SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>>> for RsaPublicKey
Available on crate feature encoding only.
impl TryFrom<SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>>> for RsaPublicKey
encoding only.impl Eq for RsaPublicKey
Auto Trait Implementations§
impl Freeze for RsaPublicKey
impl RefUnwindSafe for RsaPublicKey
impl Send for RsaPublicKey
impl Sync for RsaPublicKey
impl Unpin for RsaPublicKey
impl UnwindSafe for RsaPublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DecodePublicKey for T
impl<T> DecodePublicKey for T
Source§fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
SubjectPublicKeyInfo]
(binary format).Source§fn from_public_key_pem(s: &str) -> Result<Self, Error>
fn from_public_key_pem(s: &str) -> Result<Self, Error>
pem only.SubjectPublicKeyInfo]. Read more