This discussion is archived
1 Reply Latest reply: Jul 7, 2012 7:05 AM by Lyolik RSS

JZSystem.readWriteMifare() and NXP JCOP v2.4.1 card

Lyolik Newbie
Currently Being Moderated
Hi,

I try to execute the "standard" code to access to Mifare block at NXP JCOP J3A (JCOP v2.4.1) card:

byte [] buf = apdu.getBuffer();
buf[7] = (byte) 0xE7;
buf[6] = (byte) 0x3A;
buf[5] = (byte) 0xFE;
buf[4] = (byte) 0x45;
buf[3] = (byte) 0x07;
buf[2] = (byte) 0x57;
buf[1] = (byte) 0x54;
buf[0] = (byte) 0x0B;
JZSystem.readWriteMifare(JZSystem.MIFARE_PASSWORD_READ, buf, (short)0, (short) 2);
apdu.setOutgoingAndSend((short)8, (short) 16);

Unfortunately during call JZSystem.readWriteMifare() the NullPointerException is being occured.

Does somebody know how to resolve this problem?
  • 1. Re: JZSystem.readWriteMifare() and NXP JCOP v2.4.1 card
    Lyolik Newbie
    Currently Being Moderated
    It is a selfanswered question. :)

    You should use a javacardx.external package to access to Mifare block at NXP JCOP J3A (JCOP v2.4.1) card.
    The source code to read a Mifare block 2 is something like this:

    byte [] buf = apdu.getBuffer();
    buf[7] = (byte) 0xE7; /* Mifare Sector KEY_A = KEY_B = FFFFFFFFFFFF (Transport Configuration)*/
    buf[6] = (byte) 0x3A;
    buf[5] = (byte) 0xFE;
    buf[4] = (byte) 0x45;
    buf[3] = (byte) 0x07;
    buf[2] = (byte) 0x57;
    buf[1] = (byte) 0x54;
    buf[0] = (byte) 0x0B;
    MemoryAccess ma = Memory.getMemoryAccessInstance((byte)1, null, (short)0);
    ma.readData(buf, (short)8, buf, (short)0, (short)8, (short)0, (short)2, (short)16);
    apdu.setOutgoingAndSend((short)8, (short) 16);

    The javacardx.external package is a part of Java Card v2.2.2 API. Notice, the JCOP Tools 3.1.2 or earlier have only Java Card v2.2.1 API (file jc221.jar). If you want access to Mifare block at NXP JCOP J3A (JCOP v2.4.1) card with JCOP Tools 3.1.2 plugin, you should download JCDK v2.2.2, extract from and add package javacardx.external to a file jc221.jar of JCOP Tools 3.1.2 plugin.

    Edited by: Lyolik on 07.07.2012 7:03

    Edited by: Lyolik on 07.07.2012 7:04

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points