Skip to main content

UserDeviceCredential

Struct UserDeviceCredential 

Source
pub struct UserDeviceCredential {
    pub user: PortableUserId,
    pub device_key: DevicePublicKey,
    pub serial: u64,
    pub issued_at: i64,
    pub expires_at: i64,
    pub signature: RootSignature,
    pub root: Option<RootKey>,
    pub genesis: Option<Box<IdentityGenesis>>,
}
Expand description

A user’s root’s word that a device key may act as them (§45), until expires_at. The server checks it alone, with no account server: the root signed it, it is in date, the device holds its key (verify_device_proof) and no state the server has seen revokes the key (PortableIdentityState::revokes).

Times are Unix seconds. Renewal is a new credential for the same key, with a larger serial.

Fields§

§user: PortableUserId§device_key: DevicePublicKey§serial: u64

Larger for a later credential from one holder of the root, so two for one key differ. Only the signature reads it; the SDK gives the issue time in milliseconds, or one past its last if that is larger.

§issued_at: i64§expires_at: i64

Required: every credential expires (§45 allowed none; P7-02 does not).

§signature: RootSignature

The root’s, over Self::message: Ed25519 from a phrase root, written as P7-02 wrote it; a CTAP2 assertion from a security key (P7-08).

§root: Option<RootKey>

The root that signed it (P7-08); absent, the phrase root the user’s id is, as every credential before P7-08. Whether it is one of the user’s roots is the verifier’s to check, against the identity’s RootSet.

§genesis: Option<Box<IdentityGenesis>>

The identity’s genesis, carried for a verifier that has not seen it: an identity with a security key root cannot be checked without it. Not signed: it proves itself, its hash being the id.

Implementations§

Source§

impl UserDeviceCredential

Source

pub fn new( user: PortableUserId, device_key: DevicePublicKey, serial: u64, issued_at: i64, expires_at: i64, sign: impl FnOnce(&[u8]) -> Signature, ) -> Self

A credential sign signs with user’s phrase root: the client SDK’s root, which this crate never holds.

Source

pub fn signed_by( user: PortableUserId, root: RootKey, device_key: DevicePublicKey, serial: u64, issued_at: i64, expires_at: i64, sign: impl FnOnce(&[u8]) -> RootSignature, ) -> Self

A credential root signs with sign (P7-08), any kind of root. A phrase identity’s own phrase root is left unnamed, as before.

Source

pub fn signer(&self) -> RootKey

The root it says signed it: the one it names, or the phrase root its user’s id is.

Source

pub fn message( user: &PortableUserId, device_key: &DevicePublicKey, serial: u64, issued_at: i64, expires_at: i64, ) -> Vec<u8> ⓘ

What the root signs: CREDENTIAL_DOMAIN, then user (32 bytes), device key (32), serial (u64), issued_at (i64), expires_at (i64), the integers big-endian. Fixed width throughout, so there is one encoding of each credential and nothing to canonicalise.

Source

pub fn verify(&self, now: i64) -> Result<(), CredentialError>

Whether it is good at now (Unix seconds): signed by the root it names (Self::signer), issued no later than now + CLOCK_SKEW, not yet expired, and good for no longer than MAX_CREDENTIAL_VALIDITY. Says nothing of whether that root is one of the user’s (RootSet) nor of revocation, which are the verifier’s, from the states it holds.

Trait Implementations§

Source§

impl Clone for UserDeviceCredential

Source§

fn clone(&self) -> Self

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 UserDeviceCredential

Source§

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

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

impl<'de> Deserialize<'de> for UserDeviceCredential

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 Eq for UserDeviceCredential

Source§

impl PartialEq for UserDeviceCredential

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for UserDeviceCredential

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 StructuralPartialEq for UserDeviceCredential

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.