pub struct Atr {
    pub protocols: HashSet<u8>,
    pub t1: Vec<u8>,
    pub storage_card: bool,
    pub card_issuers_data: Option<Vec<u8>>,
    pub command_chaining: Option<bool>,
    pub extended_lc: Option<bool>,
}
Available on crate feature nfc only.
Expand description

ISO/IEC 7816-3 Answer-to-Reset and 7816-4 Historical Bytes parser.

This intentionally incomplete, and only supports a subset of the standards needed for compatibility with FIDO tokens.

References:

Other resources:

Fields§

§protocols: HashSet<u8>

Supported protocols (T=), specified in ISO/IEC 7816-3:2006 §8.2.3.

§t1: Vec<u8>

Historical bytes (T1 .. Tk), as specified in ISO/IEC 7816-4:2005 §8.1.1.

§storage_card: bool

If true, this is a contactless storage card per [PC/SC Specification][pcsc-spec] Part 3, §3.1.3.2.3.2, and Part 3 Supplemental Document.

Further clarification is available in the historical bytes (Self::t1), but is beyond the scope of this module.

FIDO tokens should always return false.

§card_issuers_data: Option<Vec<u8>>

Card issuer’s data (ISO/IEC 7816-4:2005 §8.1.1.2.5). The structure of this value is defined by the card issuer. This sometimes contains a printable string identifying the card issuer (see Self::card_issuers_data_str()).

§command_chaining: Option<bool>

Whether the card supports command chaining (ISO/IEC 7816-4:2005 §5.1.1.1). This allows sending commands longer than 255 bytes using only short form Lc.

If this value is set to None, the card did not provide a “card capabilities” value (ISO/IEC 7816-4:2005 §8.1.1.2.7).

§extended_lc: Option<bool>

Whether the card supports extended (3 byte) Lc and Le fields (ISO/IEC 7816-4:2005 §5.1) – which allows Nc (command data length) and Ne (maximum expected response length) values from 257 to 65536 bytes.

If this value is set to None, the card did not provide a “card capabilities” value (§8.1.1.2.7), and therefore does not support extended fields (§5.1).

FIDO v2.0 requires all NFC devices support short and extended length encoding.

See: ISO7816LengthForm

Implementations§

source§

impl Atr

source

pub fn card_issuers_data_str(&self) -> Option<&str>

Converts Self::card_issuers_data to a UTF-8 encoded string.

Returns None if Self::card_issuers_data is missing, or if it contains invalid UTF-8.

Trait Implementations§

source§

impl Clone for Atr

source§

fn clone(&self) -> Atr

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Atr

source§

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

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

impl PartialEq for Atr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<&[u8]> for Atr

source§

fn try_from(atr: &[u8]) -> Result<Self, Self::Error>

Attempts to parse an ATR from a &[u8].

§

type Error = WebauthnCError

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

impl Eq for Atr

source§

impl StructuralEq for Atr

source§

impl StructuralPartialEq for Atr

Auto Trait Implementations§

§

impl RefUnwindSafe for Atr

§

impl Send for Atr

§

impl Sync for Atr

§

impl Unpin for Atr

§

impl UnwindSafe for Atr

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
§

impl<'a, T> AsTaggedExplicit<'a> for T
where T: 'a,

§

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

§

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

§

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

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

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more