desfire

package
v0.511.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package desfire decodes Mifare DESFire Application Identifiers (AIDs) — the 3-byte values returned by the DESFire GetApplicationIDs command that identify each application stored on the card. Pure offline parser; no transport, no hardware.

Wrap-vs-native judgement: the DESFire AID format is a public NXP specification (DESFire reference, AN10833 for the MAD extension). The walker is a 3-byte lookup with a per-function- code category table. Wrapping a FAP for this would require an SD-card install + a firmware-fork dependency for a pure lookup. Native delivers offline analysis — operators paste a DESFire AID from a Flipper / Proxmark / pcsc_scan "list applications" output and identify the application without re-presenting the card.

Pairs with the existing NFC decoders (nfc_iso14443a_identify for the card-type identification; mifare_classic_decode for the Classic emulation path; nfc_emv_decode for EMV BER-TLV inside DESFire applications).

What this package covers:

  • 3-byte AID decode (big-endian rendering matches the form printed in NXP application notes and operator tools)
  • MAD-style AID detection (high nibble 0xF — MIFARE Application Directory format)
  • Function code category lookup for MAD AIDs per NXP AN10833 / ISO 7816-5 (transit / banking / retail / loyalty / access / parking / membership / etc.)
  • Well-known AID name catalog (MIFARE Classic emulation, OV-chipkaart, HID iCLASS-SE, ePassport, etc.)
  • Special-value detection (empty 0x000000, wildcard 0xFFFFFF, MIFARE Classic emulation 0xF40000)

What this package does NOT cover (deliberately out of scope):

  • DESFire application key derivation (needs the card master key)
  • DESFire file structure decode (separate Spec when a caller materialises with file-listing output)
  • Application key file decryption (AES-128 / 3K3DES)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AID

type AID struct {
	// Raw is the 24-bit value (high byte = byte 0 = canonical
	// rendering).
	Raw int `json:"raw"`
	// Hex is the operator-facing 6-char uppercase form ("F40000").
	Hex string `json:"hex"`
	// Special is "empty" (000000), "mifare_classic" (F40000),
	// "wildcard" (FFFFFF), or "" for normal AIDs.
	Special string `json:"special,omitempty"`
	// MADFormatted reports whether the AID uses the MIFARE
	// Application Directory format (high nibble 0xF).
	MADFormatted bool `json:"mad_formatted"`
	// FunctionCode is the 12-bit MAD function code (bits 23..12
	// when MAD-formatted). 0 for non-MAD AIDs.
	FunctionCode    int    `json:"function_code,omitempty"`
	FunctionCodeHex string `json:"function_code_hex,omitempty"`
	// Category is the documented MAD category name when the
	// function code matches a known range, "" otherwise.
	Category string `json:"category,omitempty"`
	// ApplicationName is the well-known application name when
	// the full AID is in our catalog.
	ApplicationName string `json:"application_name,omitempty"`
	// VendorSubID is the 12-bit sub-identifier (bits 11..0)
	// when the AID is MAD-formatted. The MAD allocates this
	// sub-space to individual operators within a category.
	VendorSubID    int    `json:"vendor_sub_id,omitempty"`
	VendorSubIDHex string `json:"vendor_sub_id_hex,omitempty"`
}

AID is the decoded view of a 3-byte DESFire Application Identifier.

func Decode

func Decode(hexBlob string) (AID, error)

Decode parses a hex-encoded 3-byte DESFire AID. Accepts 6 hex chars with optional 0x prefix and ':' / '-' / '_' / whitespace separators.

func DecodeUint24

func DecodeUint24(raw int) AID

DecodeUint24 is the integer-input variant of Decode. Takes the bottom 24 bits of the input (high byte ignored).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL