本文介绍了如何获得援助的读者基于主机的卡模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的<一个href="https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CCIQFjAB&url=https%3A%2F%2Fdeveloper.android.com%2Fguide%2Ftopics%2Fconnectivity%2Fnfc%2Fhce.html&ei=j7yuVNOjOo-zuAT09oDoBQ&usg=AFQjCNHKCL7h7xqSdizIVPMpukW7l7267A&sig2=UjrJAxN_X0KirDDoZlrWmQ&bvm=bv.83339334,d.c2E"相对=nofollow>主机卡仿真的Andr​​oid设备使用此的使用的 ACR1281U NFC标签阅读器。

是我想要的那种应用程序使。

作为每机器人文档和例子也,它需要登记AID在机器人项目

 &LT;主机-APDU服务的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
           机器人:说明=@字符串/ servicedesc
           机器人:requireDeviceUnlock =假&GT;
    &LT;救援组机器人:说明=@字符串/ aiddescription
               机器人:类=其他&GT;
        &LT;辅助过滤器的Andr​​oid版本:NAME =F0010203040506/&GT;
        &LT;辅助过滤器的Andr​​oid版本:NAME =F0394148148100/&GT;
    &LT; /援助组&gt;
&LT; /主机-APDU服务&GT;
 

下面是关于同一个No支持卡终端发现ARC1281U NFC读卡器

我已经提到了以下链接:<一href="http://stackoverflow.com/questions/20173181/setting-up-host-card-emulation?answertab=votes#tab-top">Setting达主机卡仿真

To获得基于NFC识别系统应用程序ID

How不与AID基于主机卡仿真交易(应用程序ID)?

Android的HCE:在那里为援助规则

请帮忙有可用很少的资源,HCE!

谢谢!

修改该示例使用以下AID(F0010203040506)在选择援助的命令,但我的ACR128读写器无法读取HCE设备。

 私有静态最后的byte [] CLA_INS_P1_P2 = {0×00,(字节)0xA4,0×04,0×00};
    私有静态最后一个字节[] AID_ANDROID = {(字节)0XF0,0×01,0×02,0×03,0×04,0×05,0×06};

私人字节[] createSelectAidApdu(byte []的援助){
        byte []的结果=新的字节[6 + aid.length]。
        System.arraycopy(CLA_INS_P1_P2,0,结果,0,CLA_INS_P1_P2.length);
        结果[4] =(字节)aid.length;
        System.arraycopy(援助,0,因此,5,aid.length);
        导致[result.length  -  1] = 0;
        返回结果;
    }
 

然后,我改变了AID为F00000000A0101(这是我使用一些其他的示例应用程序)和AID过滤藏汉用这个。之后,切换到这种援助ACR阅读器能够检测到HCE设备。

解决方案

援助是分配给您的智能卡的应用程序,一个名(HCE中的情况:在Android应用程序,模拟卡的应用程序)。阅读器应用程序使用这个名,以解决您的卡(HCE)应用程序与SELECT(由DF名/ AID)APDU命令(见ISO / IEC 7816-4)。你可以使用你想,只要​​任何价值,因为它符合ISO / IEC 7816-4。

在特定的情况下,阅读器示例应用程序使用AID F0010203040506

 私有静态最后的byte [] AID_ANDROID = {(字节)0XF0,0×01,0×02,0×03,0×04,0×05,0×06};
 

因此​​,要互操作这个例子中,你需要注册HCE服务为AID F0010203040506

如何分配和使用的辅助工具?

通常情况下,首先要定义一个名为您HCE的应用程序:

 &LT;主机-APDU服务...&GT;
    &LT;援助团...&GT;
        &LT;辅助过滤器的Andr​​oid版本:NAME =F0010203040506/&GT;
    &LT; /援助组&gt;
&LT; /主机-APDU服务&GT;
 

后来,阅读器应用程序可以使用该名称来选择您的HCE的应用程序,并再与它通信(使用Java智能卡的IO):

 卡卡= ...;
CardChannel C = card.getBasicChannel();

//通过AID选择(F0010203040506)
ResponseAPDU RESP = c.transmit(新CommandAPDU(
        为0x00,0xA4,0×04,0×00,新的byte [] {(字节)0XF0,(字节)为0x01,(字节)0×02,(字节)0×03,(字节)0×04,(字节)0×05,(字节)0×06})) ;
断言resp.getSW()== 0×9000;

//发送应用程序特定的命令(什么这样的命令可能看起来像取决于应用程序)
RESP = c.transmit(新CommandAPDU(
        0x80的,0x10的,为0x00,0x00时,新的字节[] {(字节)×12(字节)0x34}));
 

你怎么想出一个AID值?

这取决于你的应用场景。

  • 在您的闭环的情况下,你在哪里下的完全控制这两个行政总监方和读者的一面,你可以选择任意的(请注意,有一些规则AID)的援助,并将其分配给您的HCE应用程序。您可以在以后使用有助于您的阅读器应用程序,以解决HCE应用程序。

  • 在现实世界HCE的场景,你经常设计你的HCE的应用程序与现有的读者基础设施进行互动。因此,你的HCE的应用程序将执行一些特定的规范。在这种情况下,这样的规范将规定的AID(或AID)的,你的HCE的应用程序需要使用,以便为可发现由现有的读取器的基础设施。对于这样的规范的一个例子是EMV规范接触支付系统。

为什么注册多个艾滋病一些HCE应用?

有时是需要的应用程序通过多种寻址名(AIDS)。原因可能是:

  • 的应用提供了多个不同的接口(即具有不同的命令集或提供不同的数据)。
  • 有使用(由于某种原因)不同的艾滋病应对同一应用现有的读者。

你如何选择一个援助?

有关智能卡应用标识符规则(AIDS)在ISO / IEC 7816-4定义。一个援助至少有5个字节,最多可包含16个字节(见援助规模限制,这个答案)。基于第一4位,艾滋病被分成不同的组。在ISO / IEC 7816-4中定义的最相关的群体是:

  • 在艾滋病开始'A':国际注册的艾滋病
  • 在艾滋病开始D:国家注册艾滋病
  • 在艾滋病开始'F':专有艾滋病(无需注册)

有关(间)国家注册艾滋病,的AID被分成两部分,一个5字节的强制性的RID(注册应用提供商标识符),和一个可选的PIX(专有应用标识符扩展)达11个字节。

有关专利的艾滋病( F ... ),您可以使用任意值。

为什么做了AID F00000000A0101 工作,而 F0010203040506 没有工作?

我不知道,你没有提供足够的信息来诊断这一点。例如。那里有亚行日志,当你试图选择的任何消息 F0010203040506

不管怎么说,无论是艾滋病是有效的,应该工作。一种可能是,你已经安装了已注册为AID您的设备上的另一个HCE应用程序。在这种情况下,两个应用程序会列出的量是不可能的名称相同。

I'm trying to do Host card emulation on android device using this example using ACR1281U nfc tag reader.

This is the kind of application I want to make.

As per the android document and the example also, it is required to register AID in the android project .

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
           android:description="@string/servicedesc"
           android:requireDeviceUnlock="false">
    <aid-group android:description="@string/aiddescription"
               android:category="other">
        <aid-filter android:name="F0010203040506"/>
        <aid-filter android:name="F0394148148100"/>
    </aid-group>
</host-apdu-service>

Here is another question I posted regarding the same No supported card terminal found ARC1281U nfc card reader

I have referred to the following links:Setting up host card emulation

To get Application ID for NFC based Identification System

How does Host-based Card Emulation deal with AID (Application ID)?

Android HCE: are there rules for AID?

Please help as there is very little resources available for HCE!

Thanks!

EDITthe example uses the following AID(F0010203040506) in select AID command but my ACR128 reader was unable to read the HCE device.

private static final byte[] CLA_INS_P1_P2 = { 0x00, (byte)0xA4, 0x04, 0x00 };
    private static final byte[] AID_ANDROID = { (byte)0xF0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };

private byte[] createSelectAidApdu(byte[] aid) {
        byte[] result = new byte[6 + aid.length];
        System.arraycopy(CLA_INS_P1_P2, 0, result, 0, CLA_INS_P1_P2.length);
        result[4] = (byte)aid.length;
        System.arraycopy(aid, 0, result, 5, aid.length);
        result[result.length - 1] = 0;
        return result;
    }

Then I changed the AID to F00000000A0101(which was used my some other example app) and used this in AID filter aswell. After, changing to this AID Acr reader was able to detect the HCE device.

解决方案

The AID is a "name" that you assign to your smartcard application (in the case of HCE: the Android app that emulates the card application). A reader application uses this "name" to address your card (HCE) application with a SELECT (by DF name/AID) APDU command (see ISO/IEC 7816-4). You can use any value you want as long as it conforms to ISO/IEC 7816-4.

In your specific case, the reader example application uses the AID F0010203040506

private static final byte[] AID_ANDROID = { (byte)0xF0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };

Therefore, to be interoperable with that example, you need to register your HCE service for the AID F0010203040506.

How do you assign and use an AID?

Typically, you first define a "name" for your HCE app:

<host-apdu-service ...>
    <aid-group ...>
        <aid-filter android:name="F0010203040506"/>
    </aid-group>
</host-apdu-service>

Later, reader applications can use that name to select your HCE app and to then communicate with it (using Java Smart Card IO):

Card card = ...;
CardChannel c = card.getBasicChannel();

// SELECT by AID (F0010203040506)
ResponseAPDU  resp = c.transmit(new CommandAPDU(
        0x00, 0xA4, 0x04, 0x00, new byte[] { (byte)0xF0, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06 }));
assert resp.getSW() == 0x9000;

// Send application-specific command (what such a command could look like depends on your application)
resp = c.transmit(new CommandAPDU(
        0x80, 0x10, 0x00, 0x00, new byte[] { (byte)0x12, (byte)0x34 }));

How do you come up with a value for an AID?

This depends on your application scenario.

  • In your closed-loop scenario, where you are under full control of both the HCE side and the reader side, you can choose an arbitrary (note that there are some rules for AIDs) AID and assign it to your HCE app. You can later use that AID in your reader application to address the HCE app.

  • In real-world HCE scenarios, you often design your HCE app to interact with an existing reader infrastructure. Consequently, your HCE app will implement some given specification. In that case, such a specification will dictate the AID (or AIDs) that your HCE app needs to use in order to be discoverable by the existing reader infrastructure. An example for such a specification is the EMV specification for contactless payment systems.

Why are some HCE applications registered for multiple AIDs?

Sometimes there is the need that an application is addressable through multiple "names" (AIDs). Reasons could be:

  • An application provides multiple different interfaces (i.e. that have a different command set or provide different data).
  • There are existing readers that use (for some reason) different AIDs to address the same application.

How do you choose an AID?

The rules for smartcard application identifiers (AIDs) are defined in ISO/IEC 7816-4. An AID has at least 5 bytes and may consist of up to 16 bytes (see this answer on AID size restrictions). 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...), you can use any arbitrary value.

Why did the AID F00000000A0101 work while F0010203040506 did not work?

I don't know and you did not provide sufficient information to diagnose this. E.g. where there any messages in adb log when you tried to select F0010203040506?

Anyways, both AIDs are valid and should work. One possibility could be that you already had another HCE application installed on your device that registered for that AID. In that case, two applications would have listed for the same name which is not possible.

这篇关于如何获得援助的读者基于主机的卡模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 04:02