Mifare Authentication on Omnikey 3x21 CL
843851Oct 8 2007 — edited Feb 4 2008I am having trouble authenticating to block 52 (or any block) of my mifare 1k card using Omnikey 5x21 Contactless Interface.
Here is my code it is a bit much but I wish for other people to have a clear understanding on what I am doing. Also newbies can see the whole process.
Please scroll down to the point where I construct the Authenticate APDU Command.
I am using key A (sector 26 or hex: 0x1A) Transmission protocol T=0 or 0x60, on block 52 (0x34)
The signed applet simply hangs when I uncomment:
byte[] baAuth = new byte[]{(byte)0xFF,(byte)0x88,(byte)0x00,(byte)0x34,(byte)0x60,(byte)0x1A};
//CommandAPDU auth = new CommandAPDU(baAuth);
msg += "Authenticate Apdu Command: " + convertBytesToHexString(baAuth) + "\n";
//resp = channel.transmit(auth);
//msg += "Authenticate Response: " + convertBytesToHexString(resp.getBytes()) + "\n";
The applet is meant to take the information from a mifare card and display it on screen.
What is going on with this whole authentication process, it looks completely normal to me, am i missing something?
I would love it if someone could help me with this problem!
I simply wish to read the information from the card and print it on screen.
Kind regards
Stewart
public String DoCard() {
String msg = "";
String smsg = ""; //screen message;
String fileName = System.getProperty("user.home") +
System.getProperty("file.separator") +
"InterSign_assignment";
smsg += msg += "Applet output\n";
String s ;
TerminalFactory factory = TerminalFactory.getDefault();
try {
List<CardTerminal> terminals = factory.terminals().list();
msg += "Terminals: " + terminals + "\n";
CardTerminal terminal = terminals.get(1);
Card card = terminal.connect("T=0");
CardChannel channel = card.getBasicChannel();
msg += "Card Present: " + terminal.isCardPresent() + "\n" ;
ResponseAPDU resp;
//UID
byte[] uid = new byte[]{(byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00};
CommandAPDU com = new CommandAPDU(uid);
msg += "GetUID Command: " + convertBytesToHexString(com.getBytes()) + "\n";
resp = channel.transmit(com);
msg += "GetUID Response: " + convertBytesToHexString(resp.getBytes()) + "\n";
//Load Key
byte[] baLoadkey = new byte[]{(byte)0xFF,(byte)0x82,(byte)0x20,(byte)0x1A,(byte)0x06,(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};
CommandAPDU loadkey = new CommandAPDU(baLoadkey);
msg += "LoadKey Loaded Apdu Command: " + convertBytesToHexString(loadkey.getBytes()) + "\n";
resp = channel.transmit(loadkey);
msg += "LoadKey Response: " + convertBytesToHexString(resp.getBytes()) + "\n";
//Authenticate
byte[] baAuth = new byte[]{(byte)0xFF,(byte)0x88,(byte)0x00,(byte)0x34,(byte)0x60,(byte)0x1A};
CommandAPDU auth = new CommandAPDU(baAuth);
msg += "Authenticate Apdu Command: " + convertBytesToHexString(baAuth) + "\n";
resp = channel.transmit(auth);
msg += "Authenticate Response: " + convertBytesToHexString(resp.getBytes()) + "\n";
//Read
byte[] baRead = new byte[]{(byte)0xFF, (byte)0xB0, (byte)0x00, (byte)0x34, (byte)0x10};
CommandAPDU read = new CommandAPDU(baRead);
msg += "Read APDU Command: " + convertBytesToHexString(read.getBytes()) + "\n";
resp = channel.transmit(read);
msg += "Read Response: " + convertBytesToHexString(resp.getBytes()) + "\n";
card.disconnect(false);
} catch (CardException e) {
msg += e;
}
//log it
try {
FileWriter fos = new FileWriter(fileName);
fos.write(msg, 0, msg.length());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
return msg;
}
Edited by: Setori on Oct 8, 2007 2:21 AM