“GET OPTIONS” is always 6700 (wrong Lc or Le)

I am trying to read a smart card through my LG P710 Optimus L7 2.
I am following this tutorial

I can select the directory "1PAY.SYS.DDF01"
I can select the application

But I can’t execute the “GET OPTIONS”, This always leads to error 6700 (Lc or Le wrong)

here is my code

NfcAdapter mNFCAdapter;
Intent intent;
PendingIntent pendingIntent;
private TextView mTextView;
String[][] techList;
IntentFilter[] filters = new IntentFilter[3];

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mTextView = (TextView) findViewById(R.id.title);

    mNFCAdapter = NfcAdapter.getDefaultAdapter(this);

    intent = new Intent(getApplicationContext(), getClass());
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);


    techList = new String[][]{
            new String[]
                    { MifareClassic.class.getName() },
            new String[]
                    { IsoDep.class.getName() }
            };

    filters[0] = new IntentFilter();
    filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
    filters[0].addCategory(Intent.CATEGORY_DEFAULT);
    // add type of tag data you want to have - here ndef -> plain text
    try {
        filters[0].addDataType(MIME_TEXT_PLAIN);
    } catch (MalformedMimeTypeException e) {
        e.printStackTrace();
    }

    filters[1] = new IntentFilter();
    filters[1].addAction(NfcAdapter.ACTION_TAG_DISCOVERED);
    filters[1].addCategory(Intent.CATEGORY_DEFAULT);

    filters[2] = new IntentFilter();
    filters[2].addAction(NfcAdapter.ACTION_TECH_DISCOVERED);
    filters[2].addCategory(Intent.CATEGORY_DEFAULT);

}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    String action = intent.getAction();
    mTextView.setText(action);
    Toast.makeText(getApplicationContext(), action, Toast.LENGTH_SHORT).show();

    Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    IsoDep tagIsoDep;

    if((tagIsoDep = IsoDep.get(tagFromIntent)) != null)
        if(handleIsoDep(tagIsoDep))
            return;

}
     private boolean handleIsoDep(IsoDep tag){
    try{ 
        tag.connect(); 
        tag.setTimeout(20); 
        byte[] responseAPDU;


        //2PAY.SYS.DDF01
        byte[] select_Dir = new byte[]{ 
                (byte)0x00, (byte)0xa4, (byte)0x04, (byte)0x00, (byte)0x0e,
                (byte)0x32, (byte)0x50, (byte)0x41, (byte)0x59, (byte)0x2e,
                (byte)0x53, (byte)0x59, (byte)0x53, (byte)0x2e, (byte)0x44, 
                (byte)0x44, (byte)0x46, (byte)0x30, (byte)0x31
        };

        //Select CC Applet
        byte[] select_Applet = new byte[]{ 
                (byte)0x00, (byte)0xa4, (byte)0x04, (byte)0x00, (byte)7, 
                (byte)0xa0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04,
                (byte)0x30, (byte)0x60
        };

        //Send GET PROCESSING OPTIONS command
        byte[] Send_Get = new byte[]{ 
                (byte)0x80,(byte)0xA8,(byte)0x00,(byte)0x00,(byte)0x02,
                (byte)0x83,(byte)0x00,
                (byte)0x00
        };


        responseAPDU = tag.transceive(select_Dir); 
        mTextView.setText(mTextView.getText() + handleResponse(responseAPDU));

this returns APDU-Statusword 9000 -> success

        responseAPDU = tag.transceive(select_Applet); 
        mTextView.setText(mTextView.getText() + handleResponse(responseAPDU));

this returns APDU-Statusword 9000 -> success

        responseAPDU = tag.transceive(Send_Get); 
        mTextView.setText(mTextView.getText() + handleResponse(responseAPDU));

and this question creates problems: it returns 6700 -> invalid Lc or Le

        mTextView.setText(mTextView.getText() + "\n\nDone");
        tag.close();

     } catch (IOException e) {
            e.printStackTrace();
            return false;
    }
    return true;
}

The handleResponse function simply parses the "responseAPDU" from binary to hexadecimal, highlighting the Statusword

Can someone tell me what is going wrong? or just help me?

PS sry for bad english;)


As an answer to my select application, I get:

6f298407a0000000043060a51e50074d41455354524f5f2d046465656e9f38039f5c08bf0c059f4d020b0a9000

6F -> FCI Template 29  
84 -> DF Name 07 A0 00 00 00 04 30 60  
A5 -> FCI Properietary Template 1E  
50 -> Application Lable 07 4D 41 45 53 54 52 4F 5F 2D 04 64 65 6E  
9F38 -> PDOL 03 9F 5C 08  
BF0C -> FCI Issuer Data 05  
9F4D -> Log Entry 02 0B  
0A Additional Issuer Data

, ive Data fild .
Iv'e red EMV Book 3, "5.4 (DOL)".
83 03 9F 5C 08
Lc = 5?

+1
1

, ADPU (/).

: hardcoding select_Dir select_Applet , GET PROCESSING OPTIONS, (ICC) select_Applet.

EMV 4.3 Book 1, " 45: SELECT (FCI) ", , SELECT " " (PDOL, 9F38). , (: ,...). ( ) GET PROCESSING OPTIONS ( 83), EMV 4.3 book 3, "6.5.8.3 , ":

, PDOL, ICC, 5.4, "83". ICC, . , ICC.

, :

  • AID (A0 00 00 00 04 30 60) Mastercard Maestro, PDOL
  • GET PROCESSING OPTIONS
  • , GET PROCESSING OPTIONS , PDOL, , 6700, (EMV Book 1, " 33: " ).

PDOL, , : 9F38 → 03 9F 5C 08. 03 , PDOL 3 . 9F5C - , 08 - , .

9F5C EMV 2.3 2 2, "A.1.59 DS Requested Operator ID" . DS

, . OPTIONS.

, , . , GET PROCESSING OPTIONS, , DS 01 02 03 04 05 06 07 08 EMV Book 3, "5.4 (DOL)":

83 08 01 02 03 04 05 06 07 08

Lc = 10

+7

Source: https://habr.com/ru/post/1620737/


All Articles