Getting PCSC Exception 0x8010002f

0
/**
 * 
 */
package testing;

import javacard.framework.APDU;
import javacard.framework.ISO7816;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacard.framework.OwnerPIN;
import javacard.framework.Util;
/**
 * @author amitp
 *
 */
public class Testing extends Applet {

    final static byte CLASS_ONE                 = (byte) 0x00;
    final static byte CLASS_TWO                 = (byte) 0xA0;
    final static byte INS_VERIFY                = (byte) 0x20;  
    final static byte INS_SEL_APPLET            = (byte) 0x04;
    final static byte SELECT                    = (byte) 0xA4;


    final static byte[] PIN_NO      = { (byte) 0x11, (byte) 0x22,(byte) 0x33,(byte) 0x44};
    final static byte[] APPLET_ID      = { (byte) 0XAA,(byte)0XBB,(byte)0XCC,(byte)0XDD,(byte) 0XEE }; 

    final static short RES_FIRST_CMD      =  0x6099;
    final static short SW_AUTHENTICATION_METHOD_BLOCKED  =  0x1300;
     static OwnerPIN pin;

    public static void install(byte[] bArray, short bOffset, byte bLength) {
        // GP-compliant JavaCard applet registration
        pin = new OwnerPIN((byte) 0X03,(byte) 0x04);
        pin.update(PIN_NO, (short) 0, (byte) 0x04);
        new testing.Testing().register(bArray, (short) (bOffset + 1),
                bArray[bOffset]);
    }

    public void process(APDU apdu) {
        // Good practice: Return 9000 on SELECT
        if (selectingApplet()) {
            return;
        }

        byte[] buf = apdu.getBuffer();
        switch (buf[ISO7816.OFFSET_INS]) {
        case (byte) 0xA4:
            if(buf[ISO7816.OFFSET_CLA]!=(byte) 0xA0)
                ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
            else
            {
                short byte_read=(short)(apdu.setIncomingAndReceive());
                byte x = Util.arrayCompare(buf, ISO7816.OFFSET_CDATA, APPLET_ID, (short)0 , byte_read);
                if(x!= (byte) 0x00)
                {
                    ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
                }
                else
                {
                    ISOException.throwIt(RES_FIRST_CMD);
                }
            }

            break;
        case (byte) 0x20:
            varify(apdu);
        break;
        default:
            // good practice: If you don't know the INStruction, say so:
            ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
        }
    }
    private void varify(APDU apdu)
    {
        if(pin.getTriesRemaining()==0)
            ISOException.throwIt(SW_AUTHENTICATION_METHOD_BLOCKED);
        byte[] buffer = apdu.getBuffer();
        //short len_of_LC_byte = buffer[ISO7816.OFFSET_LC];
        //if( len_of_LC_byte !=5)
            //ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        byte byte_read=(byte)(apdu.setIncomingAndReceive());
        if(pin.check(buffer, ISO7816.OFFSET_CDATA,byte_read)== false)
            ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);


    }
}

I am using JCOP tool so load it in java card.It is successfully loaded in the card but when I am sending command on it, Select APPLET is giving 9000 but other command gives;

jcshell: Error code: -7fefffd1 (0x8010002F)
jcshell: Command failed: SCardTransmit(): 0x8010002f, PCSC failed with 0x8010002F: 0x2F (Warning,--,(SCard))

and When I am using Gpshell , I am getting error like:

send_APDU() returns 0x8010002F (A communications error with the smart card has been detected. Retry the operation. 

In debug Mode , all result is coming good. Could anybody tell me where i am doing mistake???

javacard
globalplatform
jcop
asked on Stack Overflow Mar 12, 2015 by Arjun • edited Mar 25, 2015 by Arjun

1 Answer

0

I found in ISO7816-3 , "Sw1 =60 is a NULL Byte, it request no action on data transfer" . this was the cause of communication error.. when i tried for 9000 , same code works good in simulator and real card...thanks for all

answered on Stack Overflow Mar 30, 2015 by Arjun

User contributions licensed under CC BY-SA 3.0