Struct tor_llcrypto::pk::rsa::PublicKey
source · pub struct PublicKey(/* private fields */);
Expand description
An RSA public key.
This implementation is a simple wrapper so that we can define new methods and traits on the type.
Implementations§
source§impl PublicKey
impl PublicKey
sourcepub fn exponent_is(&self, e: u32) -> bool
pub fn exponent_is(&self, e: u32) -> bool
Return true iff the exponent for this key is the same number as ‘e’.
sourcepub fn verify(&self, hashed: &[u8], sig: &[u8]) -> Result<(), Error>
pub fn verify(&self, hashed: &[u8], sig: &[u8]) -> Result<(), Error>
Try to check a signature (as used in Tor.) The signed hash should be in ‘hashed’, and the alleged signature in ‘sig’.
Tor uses RSA-PKCSv1 signatures, with hash algorithm OIDs omitted.
sourcepub fn from_der(der: &[u8]) -> Option<Self>
pub fn from_der(der: &[u8]) -> Option<Self>
Decode an alleged DER byte string into a PublicKey.
Return None if the DER string does not have a valid PublicKey.
(This function expects an RsaPublicKey, as used by Tor. It does not expect or accept a PublicKeyInfo.)
sourcepub fn to_der(&self) -> Vec<u8>
pub fn to_der(&self) -> Vec<u8>
Encode this public key into the DER format as used by Tor.
The result is an RsaPublicKey, not a PublicKeyInfo.
sourcepub fn to_rsa_identity(&self) -> RsaIdentity
pub fn to_rsa_identity(&self) -> RsaIdentity
Compute the RsaIdentity for this public key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
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
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more