Skip to main content

CoseKey

Enum CoseKey 

Source
pub enum CoseKey {
    EC2 {
        alg: i64,
        crv: i64,
        x: Vec<u8>,
        y: Vec<u8>,
    },
    OKP {
        alg: i64,
        x: Vec<u8>,
    },
    RSA {
        alg: i64,
        n: Vec<u8>,
        e: Vec<u8>,
    },
}
Expand description

A decoded COSE_Key from the credential’s authenticator data.

Three key types are supported:

  • EC2: elliptic-curve (kty = 2). Carries crv, x, and y.
  • OKP: octet key pair (kty = 1). Carries the raw 32-byte Ed25519 key in x.
  • RSA: RSA public key (kty = 3). Carries n and e.

The alg field in each variant holds the COSE algorithm identifier; the registration ceremony validates it against the expected value.

Variants§

§

EC2

EC2 key — P-256 with ES256 (alg = -7) or P-384 with ES384 (alg = -35).

Fields

§alg: i64

Algorithm (COSE map key 3). -7 = ES256, -35 = ES384.

§crv: i64

Curve (COSE map key -1). 1 = P-256, 2 = P-384.

§x: Vec<u8>

X coordinate (COSE map key -2). 32 bytes for P-256, 48 bytes for P-384.

§y: Vec<u8>

Y coordinate (COSE map key -3). 32 bytes for P-256, 48 bytes for P-384.

§

OKP

OKP key — EdDSA with Ed25519 (alg = -8, crv = 6).

Fields

§alg: i64

Algorithm (COSE map key 3). Value -8 = EdDSA.

§x: Vec<u8>

Raw 32-byte Ed25519 public key (COSE map key -2).

§

RSA

RSA key — RS256 (alg = -257).

Fields

§alg: i64

Algorithm (COSE map key 3). Value -257 = RS256.

§n: Vec<u8>

Modulus (COSE map key -1). At least 256 bytes for a 2048-bit key.

§e: Vec<u8>

Public exponent (COSE map key -2). Typically [0x01, 0x00, 0x01].

Implementations§

Source§

impl CoseKey

Source

pub fn alg(&self) -> i64

Return the COSE algorithm identifier for this key.

Trait Implementations§

Source§

impl Clone for CoseKey

Source§

fn clone(&self) -> CoseKey

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 CoseKey

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.