Struct Pubkey

Source
pub struct Pubkey { /* private fields */ }
Expand description

A public key object

Implementations§

Source§

impl Pubkey

Source

pub fn load_der(der: &[u8]) -> Result<Pubkey>

Load a DER encoded public key

Source

pub fn load_pem(pem: &str) -> Result<Pubkey>

Load a PEM encoded public key

Source

pub fn load_rsa(n: &MPI, e: &MPI) -> Result<Pubkey>

Load an RSA public key (n,e)

Source

pub fn load_dh(p: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>

Load an DH public key (p,g,y)

Source

pub fn load_dsa(p: &MPI, q: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>

Load an DSA public key (p,q,g,y)

Source

pub fn load_elgamal(p: &MPI, g: &MPI, y: &MPI) -> Result<Pubkey>

Load an ElGamal public key (p,g,y)

Source

pub fn load_ecdsa(pub_x: &MPI, pub_y: &MPI, curve_name: &str) -> Result<Pubkey>

Load an ECDSA public key (x,y) for the specified curve

Source

pub fn load_ecdh(pub_x: &MPI, pub_y: &MPI, curve_name: &str) -> Result<Pubkey>

Load an ECDH public key (x,y) for the specified curve

Source

pub fn load_ed25519(key: &[u8]) -> Result<Pubkey>

Load an Ed25519 public key

Source

pub fn load_x25519(key: &[u8]) -> Result<Pubkey>

Load an X25519 key

Source

pub fn estimated_strength(&self) -> Result<usize>

Return estimated bit strength of this key

Source

pub fn check_key(&self, rng: &mut RandomNumberGenerator) -> Result<bool>

Check key for problems

Source

pub fn fingerprint(&self, hash: &str) -> Result<Vec<u8>>

Return hash of the public key data

Source

pub fn der_encode(&self) -> Result<Vec<u8>>

DER encode this public key

Source

pub fn pem_encode(&self) -> Result<String>

PEM encode this public key

Source

pub fn algo_name(&self) -> Result<String>

Return the name of the algorithm

Source

pub fn get_field(&self, which: &str) -> Result<MPI>

Get a value for the public key The which parameter selects a field which is algorithm specific

Source

pub fn get_ed25519_key(&self) -> Result<Vec<u8>>

Return the 32-byte Ed25519 public key

Source

pub fn get_x25519_key(&self) -> Result<Vec<u8>>

Get the X25519 public key

Source

pub fn encrypt( &self, message: &[u8], padding: &str, rng: &mut RandomNumberGenerator, ) -> Result<Vec<u8>>

Encrypt a message using the specified padding method

Source

pub fn verify( &self, message: &[u8], signature: &[u8], padding: &str, ) -> Result<bool>

Verify a message that was signed using the specified padding method

Trait Implementations§

Source§

impl Debug for Pubkey

Source§

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

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

impl Drop for Pubkey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Pubkey

Source§

impl Sync for Pubkey

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.