Skip to main content

PublicKey

Enum PublicKey 

Source
pub enum PublicKey {
    ES256 {
        x: Vec<u8>,
        y: Vec<u8>,
    },
    ES384 {
        x: Vec<u8>,
        y: Vec<u8>,
    },
    EdDSA(Vec<u8>),
    RS256 {
        n: Vec<u8>,
        e: Vec<u8>,
    },
}
Expand description

The public key extracted from a COSE key structure during registration.

Four algorithms are supported:

  • ES256 — ECDSA P-256 with SHA-256 (COSE alg -7). Most common.
  • ES384 — ECDSA P-384 with SHA-384 (COSE alg -35).
  • EdDSA — Ed25519 (COSE alg -8). Used by newer FIDO2 authenticators.
  • RS256 — RSA PKCS#1 v1.5 with SHA-256 (COSE alg -257). Used by older YubiKey 4-series devices and Windows Hello.

Variants§

§

ES256

P-256 ECDSA public key (COSE alg -7, kty 2).

x and y are the 32-byte affine coordinates of the public point. To obtain the 65-byte uncompressed point for ring, prepend 0x04: 0x04 || x (32 bytes) || y (32 bytes).

Fields

§x: Vec<u8>
§y: Vec<u8>
§

ES384

P-384 ECDSA public key (COSE alg -35, kty 2).

x and y are the 48-byte affine coordinates of the public point. To obtain the 97-byte uncompressed point for ring, prepend 0x04: 0x04 || x (48 bytes) || y (48 bytes).

Fields

§x: Vec<u8>
§y: Vec<u8>
§

EdDSA(Vec<u8>)

Ed25519 EdDSA public key (COSE alg -8, kty 1 OKP).

The inner Vec<u8> is the raw 32-byte Ed25519 public key, as encoded in COSE OKP key parameter -2 (x).

§

RS256

RSA PKCS#1 v1.5 SHA-256 public key (COSE alg -257, kty 3).

n is the big-endian modulus (256 bytes for a 2048-bit key). e is the big-endian public exponent (typically [0x01, 0x00, 0x01]).

Fields

§n: Vec<u8>
§e: Vec<u8>

Implementations§

Source§

impl PublicKey

Source

pub fn algorithm(&self) -> i64

Return the COSE algorithm identifier for this key.

Source

pub fn key_type(&self) -> &'static str

Return a human-readable description of the key type.

Trait Implementations§

Source§

impl Clone for PublicKey

Source§

fn clone(&self) -> PublicKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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