Struct rsa::RsaPublicKey

source ·
pub struct RsaPublicKey { /* private fields */ }
Expand description

Represents the public part of an RSA key.

Implementations§

source§

impl RsaPublicKey

source

pub fn new(n: BigUint, e: BigUint) -> Result<Self>

Create a new key from its components.

Trait Implementations§

source§

impl Clone for RsaPublicKey

source§

fn clone(&self) -> RsaPublicKey

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RsaPublicKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DecodePublicKey for RsaPublicKey

source§

fn from_public_key_der(bytes: &[u8]) -> Result<Self, Error>

Deserialize object from ASN.1 DER-encoded SubjectPublicKeyInfo (binary format).
source§

fn from_public_key_doc(doc: &PublicKeyDocument) -> Result<Self, Error>

Deserialize SPKI public key from a PublicKeyDocument.
source§

fn from_public_key_pem(s: &str) -> Result<Self, Error>

Deserialize PEM-encoded SubjectPublicKeyInfo. Read more
source§

fn read_public_key_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load public key object from an ASN.1 DER-encoded file on the local filesystem (binary format).
source§

fn read_public_key_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load public key object from a PEM-encoded file on the local filesystem.
source§

impl EncodePublicKey for RsaPublicKey

source§

fn to_public_key_der(&self) -> Result<PublicKeyDocument>

Serialize a PublicKeyDocument containing a SPKI-encoded public key.
source§

fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>

Serialize this public key as PEM-encoded SPKI with the given LineEnding.
source§

fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path
source§

fn write_public_key_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding ) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path
source§

impl From<&RsaPrivateKey> for RsaPublicKey

source§

fn from(private_key: &RsaPrivateKey) -> Self

Converts to this type from the input type.
source§

impl From<RsaPrivateKey> for RsaPublicKey

source§

fn from(private_key: RsaPrivateKey) -> Self

Converts to this type from the input type.
source§

impl Hash for RsaPublicKey

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for RsaPublicKey

source§

fn eq(&self, other: &RsaPublicKey) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PublicKey for &'a RsaPublicKey

source§

fn encrypt<R: RngCore + CryptoRng>( &self, rng: &mut R, padding: PaddingScheme, msg: &[u8] ) -> Result<Vec<u8>>

Encrypt the given message.
source§

fn verify( &self, padding: PaddingScheme, hashed: &[u8], sig: &[u8] ) -> Result<()>

Verify a signed message. hashedmust be the result of hashing the input using the hashing function passed in through hash. If the message is valid Ok(()) is returned, otherwiese an Err indicating failure.
source§

impl PublicKey for RsaPublicKey

source§

fn encrypt<R: RngCore + CryptoRng>( &self, rng: &mut R, padding: PaddingScheme, msg: &[u8] ) -> Result<Vec<u8>>

Encrypt the given message.
source§

fn verify( &self, padding: PaddingScheme, hashed: &[u8], sig: &[u8] ) -> Result<()>

Verify a signed message. hashedmust be the result of hashing the input using the hashing function passed in through hash. If the message is valid Ok(()) is returned, otherwiese an Err indicating failure.
source§

impl<'a> PublicKeyParts for &'a RsaPublicKey

source§

fn n(&self) -> &BigUint

Returns the modulus of the key.

source§

fn e(&self) -> &BigUint

Returns the public exponent of the key.

source§

fn size(&self) -> usize

Returns the modulus size in bytes. Raw signatures and ciphertexts for or by this public key will have the same size.
source§

impl PublicKeyParts for RsaPublicKey

source§

fn n(&self) -> &BigUint

Returns the modulus of the key.
source§

fn e(&self) -> &BigUint

Returns the public exponent of the key.
source§

fn size(&self) -> usize

Returns the modulus size in bytes. Raw signatures and ciphertexts for or by this public key will have the same size.
source§

impl TryFrom<SubjectPublicKeyInfo<'_>> for RsaPublicKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(spki: SubjectPublicKeyInfo<'_>) -> Result<Self>

Performs the conversion.
source§

impl Eq for RsaPublicKey

source§

impl StructuralEq for RsaPublicKey

source§

impl StructuralPartialEq for RsaPublicKey

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DecodeRsaPublicKey for T
where T: DecodePublicKey,

source§

fn from_pkcs1_der(public_key: &[u8]) -> Result<T, Error>

Deserialize object from ASN.1 DER-encoded [RsaPublicKey] (binary format).
source§

fn from_pkcs1_pem(s: &str) -> Result<Self, Error>

Deserialize PEM-encoded [RsaPublicKey]. Read more
source§

fn read_pkcs1_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load [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>

Load [RsaPublicKey] from a PEM-encoded file on the local filesystem.
source§

impl<T> EncodeRsaPublicKey for T
where T: EncodePublicKey,

source§

fn to_pkcs1_der(&self) -> Result<RsaPublicKeyDocument, Error>

Serialize a RsaPublicKeyDocument containing a PKCS#1-encoded public key.
source§

fn to_pkcs1_pem(&self, line_ending: LineEnding) -> Result<String, Error>

Serialize this public key as PEM-encoded PKCS#1 with the given line ending.
source§

fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path.
source§

fn write_pkcs1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding ) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V