JZSystem.readWriteMifare

Hi, all

I'm using JCOP31bio. I would like to read/write mifare on SmartMX. Here is my code.

byte[] m_ar = new byte[16+8];

// Key A & key B are FF FF FF FF FF FF

// MF_PASSWORD = 0B 54 57 07 45 FE 3A E7

m_ar[7] = (byte)0x0B;

m_ar[6] = (byte)0x54;

m_ar[5] = (byte)0x57;

m_ar[4] = (byte)0x07;

m_ar[3] = (byte)0x45;

m_ar[2] = (byte)0xFE;

m_ar[1] = (byte)0x3A;

m_ar[0] = (byte)0xE7;

short ret = JZSystem.readWriteMifare(JZSystem.MIFARE_PASSWORD_READ, m_ar, (short)0, (short)0);

if(retsh==0){

apdu.setOutgoing();

apdu.setOutgoingLength((short)16);

apdu.sendBytesLong(m_ar, (short)8, (short)16);

}else{

ISOException.throwIt(ISO7816.SW_DATA_INVALID );

}

The card always returns 0x6F00 (Internal problem with no additional information). I thinks the error is

JZSystem.readWriteMifare(...);

. How do I solve the problem?

Thank you.

[979 byte] By [Sakada_Chaowanuea] at [2007-10-3 3:10:14]
# 1

Hi,

My problem is that丗

byte[] pw = JCSystem.makeTransientByteArray((short) 24, JCSystem.CLEAR_ON_DESELECT);

pw[0] = (byte) 0xE7;// MF_password

pw[1] = (byte) 0x3A;

pw[2] = (byte) 0xFE;

pw[3] = (byte) 0x45;

pw[4] = (byte) 0x07;

pw[5] = (byte) 0x57;

pw[6] = (byte) 0x54;

pw[7] = (byte) 0x0B;

if (JZSystem.readWriteMifare(JZSystem.MIFARE_PASSWORD_READ, pw2, (short) 0, (short) 5) != 0)

ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);

My return values are always negative except block0.

Anyone can help solve the problem?

Thank you

trylansa at 2007-7-14 21:01:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2
Hi trylans.Your code declare pw variable and use pw2 in function call .What is type of your JCOP card?
Sakada_Chaowanuea at 2007-7-14 21:01:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 3
Hi Sakada_Chaowanue:That's fine because I copied the wrong code area. I've tried with reversed Mifare Password array.But also failed. My Card is JCOP41.
trylansa at 2007-7-14 21:01:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 4

Hi Sakada_Chaowanue:

Maybe you can try this.

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);

The return code of 0x6F00 may not come from the JZSystem.readWriteMifare() function.

Regards,

trylans

trylansa at 2007-7-14 21:01:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 5
Hi trylansI try your code and successful read data from block 0 and block 1.Thank you very much for your help.Best regards,Sakada
Sakada_Chaowanuea at 2007-7-14 21:01:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...