pub struct PublicKey {
    pub algorithm: Algorithm,
    pub bytes: Vec<u8>,
}
Expand description

Response from command::get_public_key

Fields§

§algorithm: Algorithm

Algorithm of the public key

§bytes: Vec<u8>

The public key in raw bytes. Keys have the following structure:

  • RSA: Public modulus N (0x100 | 0x200 | 0x400 bytes)
  • ECC (non-Ed25519):
    • Public point X (0x20 | 0x30 | 0x40 | 0x42 bytes)
    • Public point Y (0x20 | 0x30 | 0x40 | 0x42 bytes)
  • Ed25519: Public point A, compressed (0x20 bytes)

In particular note that in the case of e.g. ECDSA public keys, many libraries will expect a 0x04 (DER OCTET STRING) tag byte at the beginning of the key. The YubiHSM does not return this, so you may need to add it depending on your particular application.

Implementations§

source§

impl PublicKey

source

pub fn into_vec(self) -> Vec<u8>

Unwrap inner byte vector

source

pub fn len(&self) -> usize

Get length of the key

source

pub fn as_slice(&self) -> &[u8]

Get slice of the inner byte vector

source

pub fn ecdsa<C>(&self) -> Option<EncodedPoint<C>>where C: PrimeCurve + CurveAlgorithm + PointCompression, FieldBytesSize<C>: ModulusSize,

Return the ECDSA public key of the given curve type if applicable

source

pub fn ed25519(&self) -> Option<PublicKey>

Return the Ed25519 public key if applicable

Trait Implementations§

source§

impl AsRef<[u8]> for PublicKey

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for PublicKey

source§

fn clone(&self) -> PublicKey

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 PublicKey

source§

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

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

impl<'de> Deserialize<'de> for PublicKey

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Into<Vec<u8, Global>> for PublicKey

source§

fn into(self) -> Vec<u8>

Converts this type into the (usually inferred) input type.
source§

impl PartialEq<PublicKey> for PublicKey

source§

fn eq(&self, other: &PublicKey) -> 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 Serialize for PublicKey

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for PublicKey

source§

impl StructuralEq for PublicKey

source§

impl StructuralPartialEq for PublicKey

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,