Struct yubirs::piv::pkey::PublicKey

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

A public key. Note that this structure denotes just the key, not the other metadata which would be included in a full X.509 certificate.

Implementations§

source§

impl PublicKey

source

pub fn from_pem<R: Read>(r: R) -> Result<Self>

source

pub fn from_pem_file<P: AsRef<Path>>(path: P) -> Result<Self>

source

pub fn from_rsa_structure(data: &[u8]) -> Result<Self>

Construct a PublicKey from the raw RSA structure returned from the underlying hardware. The provided data should be the entire response from the device to a generate command.

source

pub fn from_ec_structure(algorithm: Algorithm, data: &[u8]) -> Result<Self>

Construct a PublicKey from the raw EC structure returned from the underlying hardware. The provided data should be the entire response from the device to a generate command.

source

pub fn get_algorithm(&self) -> Result<Algorithm>

source

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

This function returns the maximum number of bytes encrypt can encrypt using the given algorithm.

source

pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>>

Encrypt the given data using this RSA public key. In order to decipher the returned ciphertext, the caller must have access to the matching private key.

Note that only RSA is supported, because OpenSSL likewise only (easily) supports this kind of encryption with an RSA key.

Also note that this should not be used to encrypt large amounts of data. In fact, as per the docs (https://www.openssl.org/docs/manmaster/man3/RSA_public_encrypt.html), this function can only encrypt at most max_encrypt_len bytes of data.

In order to use this feature to encrypt larger amounts of data, this function should be used to wrap a key which is then used with a more normal cipher like AES.

source

pub fn format(&self, format: Format) -> Result<Vec<u8>>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more