Android HCE: are there rules for AID?

后端 未结 2 542
心在旅途
心在旅途 2020-12-15 13:49

I\'m trying to use an ACR122 NFC reader to select an application emulated in one Nexus 5 using Android Host Card Emulation. However, small AIDs are not recognized.

M

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 14:30

    The rules for smartcard application identifiers (AIDs) are defined in ISO/IEC 7816-4. An AID may consist of up to 16 bytes. Based on the first 4 bits, AIDs are divided into different groups. The most relevant groups defined in ISO/IEC 7816-4 are:

    • AIDs starting with 'A': internationally registered AIDs
    • AIDs starting with 'D': nationally registered AIDs
    • AIDs starting with 'F': proprietary AIDs (no registration)

    For (inter)nationally registered AIDs, the AID is split into two parts, a 5-byte mandatory RID (registered application provider identifier), and an optional PIX (proprietary application identifier extension) of up to 11 bytes.

    For proprietary AIDs (F...) ISO/IEC 7816-4 does not clearly mandate any minimum length requirements.

    In addition to this, when it comes to HCE and routing of card emulation communication from the NFC controller to secure elements or the application processor, there is the NFC Forum NCI specification. This specification mandates an AID (used in AID-based routing entries) to be between 5 and 16 bytes. Btw. the same limitation applies to smartcards following the Java Card specifications.

    When it comes to Android, there is a hard-coded requirement that AIDs received in a SELECT command consist of at least 5 bytes:

    • In method resolveAid() in RegisteredAidCache.java on line 142
    • In method findSelectAid() in HostEmulationManager.java on line 390 (which actually causes the odd behavior that the 4 byte AID is rejected with a "File or application not found" (6A82) status word as the check does not properly account for the Le byte)

提交回复
热议问题