pub struct PublicKey(_);
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
sourceimpl 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 RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more