0x000000EA error returned by SCardTransmit
Posted: Thu Feb 16, 2017 6:29 pm
I have developed a software using Smart Cards to enable the configuration mode of the system. I'm facing a strange problem with the function SCardTransmit and Java Cards, like described below:
If the system send the, I send a response with 30 bytes without any problems when using Windows 7, 8.1 or 10. But when using Windows XP SP3, the SCardTransmit returns the error code 0x000000EA. If I send a response with 0, 1 or 2 bytes it works, but when returning 3 bytes or more the error is returned. Below is the code of the software:
Using another Smart Cards (no Java) everything works. Someone has faced a problem like this before? I have tested it on Windows XP SP3 English, with all updates of the Microsoft Update Center installed. The version of the Winscard.dll used by Windows is 5.1.2600.5512.
If the system send the
Code: Select all
APDU 00 A4 04 04 08 0F FF AB CD EF AB CD EF
Code: Select all
package JavaCardOS;
import javacard.framework.*;
public class SmartCard extends Applet
{
final static byte[] FCP_Template =
{
(byte) 0x62, // File control parameters (FCP template)
(byte) 0x2C, // Length
(byte) 0x83, // File identifier
(byte) 0x02, // Length
(byte) 0x0F, (byte) 0xFF,
(byte) 0x82, // File Descriptor
(byte) 0x01, // Not shareable file, Working EF, Transparent
(byte) 0x38, // Maximum Record Length
(byte) 0x85, // Proprietary information
(byte) 0x01, // Length
(byte) 0x01,
(byte) 0x84, // DF Name
(byte) 0x0C, // Length
(byte) 0x0F, (byte) 0xFF, (byte) 0xAB, (byte) 0xCD,
(byte) 0xEF, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF,
(byte) 0xAB, (byte) 0xCD, (byte) 0xEF, (byte) 0x00,
(byte) 0x86, // Security attributes
(byte) 0x12, // Length
(byte) 0xA4, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0xFF, (byte) 0xFF, (byte) 0xEE, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xFF,
(byte) 0x60, (byte) 0x20, (byte) 0x00, (byte) 0x00,
(byte) 0xFF, (byte) 0xFF
};
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new SmartCard().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
byte[] apduBuffer = apdu.getBuffer();
if (selectingApplet())
{
if
(
(apduBuffer[ISO7816.OFFSET_P1] != (byte) 0x04)
||
(apduBuffer[ISO7816.OFFSET_P2] != (byte) 0x04)
)
{
ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
}
if((short)(apduBuffer[ISO7816.OFFSET_LC] & 0xFF) != 0x08)
{
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
if((short)(apduBuffer[ISO7816.OFFSET_LC] & 0xFF) != apdu.setIncomingAndReceive())
{
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
}
apdu.setOutgoing();
for(short currentLoop = 0; currentLoop < FCP_Template.length; ++currentLoop)
{
apduBuffer[currentLoop] = FCP_Template[currentLoop];
}
apdu.setOutgoingLength((short) FCP_Template.length);
apdu.sendBytes((short) 0, (short) FCP_Template.length);
return;
}
//
//.. Rest of the code here
//
Using another Smart Cards (no Java) everything works. Someone has faced a problem like this before? I have tested it on Windows XP SP3 English, with all updates of the Microsoft Update Center installed. The version of the Winscard.dll used by Windows is 5.1.2600.5512.