pub enum PrivLen {
Canonical,
Jcop1Byte,
}Expand description
Encoding length for the GP Privileges field (GPCS v2.3.1 §11.1.2,
Tables 11-7..11-9). The field may legally be 1 byte (legacy / pre-2.2) or
3 bytes (the 2.2+ extended encoding); byte 1 carries the core privileges
(Security Domain 0x80, Card Lock, Card Terminate, …) and bytes 2–3 carry
the 2.2+ extended privileges (Trusted Path 0x80 in byte 2, …).
When an extended (byte 2/3) bit is actually set, the 3-byte form is mandatory and this selector is ignored. When bytes 2–3 are zero, the two forms are value-equivalent per the spec, but real implementations differ:
Canonical(3-byte) is the spec-canonical form and the safe default. The Oracle JCDK simulator requires it: given only the 1-byte form it does not treat bytes 2–3 as zero and ends up reporting an unintended privilege (e.g. Trusted Path) for the created SD.Jcop1Bytecollapses to 1 byte. NXP JCOP 4 P71 / J3R150 requires this: it rejectsLp = 03for a privilege that fits in byte 1 and accepts onlyLp = 01(e.g.01 80for an SSD).
Selection is a per-card property; discovery sets it, the workflow passes it
through. Default to Canonical unless a JCOP-P71 quirk is detected.
Variants§
Canonical
Always emit the full 3-byte Privileges field (spec-canonical; jcsim).
Jcop1Byte
Collapse to the 1-byte form when bytes 2–3 are zero (NXP JCOP 4 P71).