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: u64Larger 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: i64Required: every credential expires (§45 allowed none; P7-02 does not).
signature: RootSignatureThe 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
impl UserDeviceCredential
Sourcepub fn new(
user: PortableUserId,
device_key: DevicePublicKey,
serial: u64,
issued_at: i64,
expires_at: i64,
sign: impl FnOnce(&[u8]) -> Signature,
) -> Self
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.
Sourcepub fn signed_by(
user: PortableUserId,
root: RootKey,
device_key: DevicePublicKey,
serial: u64,
issued_at: i64,
expires_at: i64,
sign: impl FnOnce(&[u8]) -> RootSignature,
) -> Self
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.
Sourcepub fn signer(&self) -> RootKey
pub fn signer(&self) -> RootKey
The root it says signed it: the one it names, or the phrase root its user’s id is.
Sourcepub fn message(
user: &PortableUserId,
device_key: &DevicePublicKey,
serial: u64,
issued_at: i64,
expires_at: i64,
) -> Vec<u8> ⓘ
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.
Sourcepub fn verify(&self, now: i64) -> Result<(), CredentialError>
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.