Skip to main content

Crate desox

Crate desox 

Source
Expand description

DESOx is a (very basic and partial!) implementaiton of the MIFARE DESFire protocol. This protocol has a number of public implementations that I’ve studied, but the actual documentation is under NDA, which I have not signed.

This crate will (likely forever?) be partial, incomplete, and filled with nasal demons – but the only goal is to reliably do the “basics”.

Modules§

io
Underlying traits and helper functions to handle I/O with a DESFire card.

Structs§

AppPermissions
PICC-wide Key Settings. This represents what permissions are required to take card-wide destructive actions, such as creating or deleting applications, changing key permissions, or changing the PICC key.
Authenticated
Authenticated Session
Card
Handle to interact with a MiFare DESFire card.
DetailedVersionInfo
Unparsed version info for Hardware/Software versions.
FilePermissions
File permissions
KeyingState
Underlying keying state shared between the host (this library) and the card. This tracks the underlying session key and initialization vector (within the Scheme internal to this type), as well as the derived CMAC signature keys k1 and k2.
Permissions
Global (PICC-wide) and Application-specific permissions and configuration.
Unauthenticated
Unauthenticated session. Everything is plaintext.
VersionInfo
Unparsed version info struct

Enums§

Error
Errors that can be encountered when interacting with a MIFARE DESFire card. This is fairly expansive (and has a generic for an error returned by the specific I/O backend you’re using).
FileCommunication
Within DESFire, each File is marked with how communication must be done.
FileSettings
File settings
FileType
Type of file.
Instruction
Instructions are single-byte commands followed by a well-defined amount of data. These are sent as the first byte of an APDU to the DESFire card.
Key
MIFARE DESFire keys are symmetric keys that are shared by the reader and the card. These can take the form of a few different algorithms, but I have chosen to only support two for now – DES and AES. DES is only used for legacy interop (and default key authentication) – if one of the new flavors is to be used, I’m only using AES. Things like 3DES are not something I’ve implemented (yet?).
KeyCount
Number (and type) of keys. If no specific Application has been selected, this will return information about the PICC Key. If a specific Application has been selected, this will return the number and type of keys present in the current application.
KeyPermissions
Application-specific Key settings. This defines what key is required to be used when taking specific keying actions.
Session
Active (authenticated) session between the DESFire Card and this library.
StatusCode
Commands we can ask the card for

Traits§

AuthenticationState
Valid authentication state, with default(s) on how to handle communication with the card. This trait is here to limit possible states but is not generally useful.
FileIo
Trait to handle file i/o (be it authenticated or not!) – this is a trait because the specific way we talk to a file changes depending on authentication.

Type Aliases§

ApplicationId
MiFare DESFire Cards can have a number of “applications”, identified by an ApplicationId. These IDs are unique within a Card (or I guess more specifically, a Card ecosystem), used to create a logical group of Files, Keys and access control to serve the needs of the system.
AuthenticatedCard
Type alias for a card which is currently authenticated.
FileId
MIFARE DESFire Applications may contain “Files”. A File may be of a given type (‘data’, etc), from 0x00 to 0x1F (inclusive).
KeyId
MIFARE DESFire Cards have a number of key slot(s). The card itself - what I usually call the PICC in this source (‘Proximity Integrated Circuit Card’) has one PICC Key (their docs call it a ‘Master Key’) for card-wide administrative actions, as well as a number (up to 15) Application Keys.
Uid
MIFARE DESFire Cards all have a Unique ID (Uid). UIDs are 7 bytes long, and are generally only readable after authentication.
UnauthenticatedCard
Type alias for a card which is currently unauthenticated.