AuthenticatorData

Struct AuthenticatorData 

Source
pub struct AuthenticatorData {
    pub flags: Flags,
    pub counter: Option<u32>,
    pub attested_credential_data: Option<AttestedCredentialData>,
    pub extensions: Option<Value>,
    /* private fields */
}
Expand description

The authenticator data structure encodes contextual bindings made by the authenticator. These bindings are controlled by the authenticator itself, and derive their trust from the WebAuthn Relying Party’s assessment of the security properties of the authenticator. In one extreme case, the authenticator may be embedded in the client, and its bindings may be no more trustworthy than the client data. At the other extreme, the authenticator may be a discrete entity with high-security hardware and software, connected to the client over a secure channel. In both cases, the Relying Party receives the authenticator data in the same format, and uses its knowledge of the authenticator to make trust decisions.

https://w3c.github.io/webauthn/#sctn-authenticator-data

Fields§

§flags: Flags

The flags representing the information of this credential. See Flags for more information.

§counter: Option<u32>

Signature counter, 32-bit unsigned big-endian integer.

§attested_credential_data: Option<AttestedCredentialData>

An optional AttestedCredentialData, if present, the Flags::AT needs to be set to true. See AttestedCredentialData for more information. Its length depends on the length of the credential ID and credential public key being attested.

§extensions: Option<Value>

Extension-defined authenticator data. This is a CBOR RFC8949 map with extension identifiers as keys, and authenticator extension outputs as values. See WebAuthn Extensions for details.

This field uses the generic Value rather than a HashMap or the internal map representation for the following reasons:

  1. Value does not implement Hash so it can’t be used as a key in a HashMap
  2. Even if Vec<(Value, Value)> is the internal representation of a map in Value, it serializes to an array rather than a map, so in order to serialize it needs to be cloned into a Value::Map.

Instead we just assert that it is a map during deserialization.

Implementations§

Source§

impl AuthenticatorData

Source

pub fn new(rp_id: &str, counter: Option<u32>) -> Self

Create a new AuthenticatorData object for an RP ID and an optional counter.

The flags will be set to their default values.

Source

pub fn set_attested_credential_data(self, acd: AttestedCredentialData) -> Self

Add an AttestedCredentialData to the authenticator data.

This sets the Flags::AT value as well.

Source

pub fn set_flags(self, flags: Flags) -> Self

Set additional Flags to the authenticator data.

Source

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

Get read access to the RP ID hash

Source

pub fn set_make_credential_extensions( self, extensions: Option<SignedExtensionOutputs>, ) -> Result<Self, Ctap2Error>

Set make credential authenticator extensions

Source

pub fn set_assertion_extensions( self, extensions: Option<SignedExtensionOutputs>, ) -> Result<Self, Ctap2Error>

Set assertion authenticator extensions

Source§

impl AuthenticatorData

Source

pub fn from_slice(v: &[u8]) -> Result<Self>

Decode an Authenticator data from a byte slice

Source

pub fn to_vec(&self) -> Vec<u8>

Encode an authenticator data to its byte representation.

Trait Implementations§

Source§

impl Debug for AuthenticatorData

Source§

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

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

impl<'de> Deserialize<'de> for AuthenticatorData

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 PartialEq for AuthenticatorData

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AuthenticatorData

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 AuthenticatorData

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<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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,