Expand description
Card-response parsers — PDD §5.2 (discover) and §5.12 (get_card_status).
Pure, fuzzable (§10.5 target #2): these consume bytes a malicious or buggy
card controls, so every function is total — malformed input yields a
typed TlvError, never a panic (no unwrap on a bounded heapless
push). They sit one layer above crate::tlv: each walks the BER-TLV
template and decodes it into the public crate::model / crate::report
types.
Four templates, all decoded here:
- Card Recognition Data
'66'→ advertised SCP variants (GPCS v2.3.1 §H.2 — the'64'OID’s last two octets arescp_id/i). - Key Information Template
'00E0'→ keysets grouped by KVN (GPCS v2.3.1 §11.3.3.1). - Card Capability Information
'67'→CardCapabilities(GPCS v2.3.1 §H.4). GET STATUSGP Registry entry'E3'→CardLifeCycle(GPCS v2.3.1 §11.4, Table 11-36; life-cycle byte is'9F70').
Absent vs malformed. A missing optional element is not an error: it
yields an empty list / None / the documented default, and the discovery
workflow (§5.2) turns that into a crate::error::WarningKind, not a hard
failure. Only a structurally broken template (a real BER-TLV violation, or
more objects than the bounded model can hold) is reported as TlvError.
Unknown semantic bytes (an unrecognised key type or life-cycle byte) are
absorbed into the model’s Other / Unknown variants, never errors.
Structs§
- Card
Recognition - Advertised secure-channel capability decoded from Card Recognition Data.
scp[0]is the card’s default (first'64'listed); the discovery workflow applies the §4.3 selection rule over the full list. - KeyInformation
- Decoded Key Information Template: keysets grouped by Key Version Number.
formatisKeyTemplateFormat::Extendedif any entry used the'B9'sub-template, elseKeyTemplateFormat::Basic. - Registry
Entry - One decoded
GlobalPlatformRegistry'E3'entry — the scope-agnostic shape theget_card_inventoryworkflow (§5.12a) maps into the typedcrate::modelentries (Security Domain / Application / ELF).
Functions§
- parse_
card_ capabilities - Parse Card Capability Information (value of GET DATA
'67'; GPCS §H.4). - parse_
card_ recognition - Parse Card Recognition Data (the value of GET DATA
'66'; GPCS §H.2). - parse_
key_ information - Parse the Key Information Template (value of GET DATA
'00E0'; §11.3.3.1). - parse_
status_ e3 - Parse the single ISD
GlobalPlatformRegistry entry from aGET STATUSresponse and decode its life-cycle byte ('E3'→'9F70'; Table 11-36 / Table 11-6). - parse_
status_ registry - Parse one GET STATUS page into its
'E3'registry entries (Table 11-36 / 11-37). Total and fuzzable (§10.5): malformed input yields a typedTlvError, never a panic. Used by theget_card_inventoryworkflow (§5.12a), which calls it once per page (63 10continuation) per P1 scope and maps eachRegistryEntryinto the typed model.