This discussion is archived
10 Replies Latest reply: Jan 16, 2013 2:44 AM by johnnybravo RSS

Example: Java Purse

johnnybravo Newbie
Currently Being Moderated
I'd like to test the example - not with the simulation but directly "on card"

after selecting the application (which works just fine) I try the commands just as they are stated in demo1.scr
// Initialize Parameter Update
0x80 0x24 0x00 0x00 0x00 0x7F; 
//00 00 00 00 0c 1f 63 00 01 90 00 = Purse ID : 0x00000000; ExpDate 12/31/99; PUN 1
//For the second and consecutive runs it can be 69 82

// Complete Parameter Update: CAD ID 0x11223344; Set Master PIN 12345678
0x80 0x26 0x00 0x00 0x1A 0x11 0x22 0x33 0x44 0x00 0x00 0x00 0x00 0xC1 0x08 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x7F;
// 00 00 00 00 00 00 00 00 90 00 
// For second and consecutive runs it can be 91 04

// Verify PIN : Master PIN
0x00 0x20 0x00 0x81 0x08 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x7F;
// 90 00;
but (for the initialize parameter update)
/send 8024000000
it returns
6D 00                                             
Status: INS value not supported
same thing happens with the other initializations - had anyone similar problems or knows what I am doing wrong here?
I didn't change anything in the code, so 0x24 is still "INITIALIZE_UPDATE"
  • 1. Re: Example: Java Purse
    Umer Journeyer
    Currently Being Moderated
    Can you share the applet code plz ?
  • 2. Re: Example: Java Purse
    johnnybravo Newbie
    Currently Being Moderated
    it consits of 4 files: JavaPurse - http://jcs.mobile-utopia.com/jcs/36380_JavaPurse.java , Record - https://anon.inf.tu-dresden.de/svn/JavaCardStudents/ANONCard/trunk/java_card_kit-2_2_1/samples/src/com/sun/javacard/samples/JavaPurse/Record.java , CyclicFile - https://anon.inf.tu-dresden.de/svn/JavaCardStudents/ANONCard/trunk/java_card_kit-2_2_2/java_card_kit-2_2_2-rr-bin-linux-do/samples/src/com/sun/javacard/samples/JavaPurse/CyclicFile.java and JavaLoyaltyInterface - https://anon.inf.tu-dresden.de/svn/JavaCardStudents/ANONCard/trunk/java_card_kit-2_2_1/samples/src/com/sun/javacard/samples/SampleLibrary/JavaLoyaltyInterface.java

    all I did was creating a new JavaProject with a new AID in an own package!

    Edited by: brennsuppa on 17.12.2012 11:35
  • 3. Re: Example: Java Purse
    975608 Newbie
    Currently Being Moderated
    You should probably place space between hex
    /send 0x80 0x24 0x00 0x00 0x00 0x00 0x7f
    Edited by: andirady on Dec 18, 2012 10:10 PM
  • 4. Re: Example: Java Purse
    johnnybravo Newbie
    Currently Being Moderated
    that ain't it...

    neither spaces nor hex-numbers are accepted so I suppose the apdu itself should be right
    /send 8024000000
  • 5. Re: Example: Java Purse
    HanaBizhani Newbie
    Currently Being Moderated
    Hi,

    Are you selecting the applet first?
    Try using another class byte, 80 is a reserved class byte?

    would you please paste all APDUs you send to cards step by step?
    what shell do you use for sending APDU?

    Regards,
    Hana
  • 6. Re: Example: Java Purse
    johnnybravo Newbie
    Currently Being Moderated
    Hana Bizhani wrote:
    Hi,

    Are you selecting the applet first?
    Try using another class byte, 80 is a reserved class byte?

    would you please paste all APDUs you send to cards step by step?
    what shell do you use for sending APDU?

    Regards,
    Hana
    hey, thx for your response!

    @CLA:
    in the code it does check this:
           if (!apdu.isISOInterindustryCLA()) {
               switch (buffer[ISO7816.OFFSET_INS])     {
                         case INITIALIZE_TRANSACTION:
                              processInitializeTransaction(apdu); break;
                         case COMPLETE_TRANSACTION:
                              processCompleteTransaction(apdu); break;
                         case INITIALIZE_UPDATE:
                              processInitializeUpdate(apdu);     break;
                         case COMPLETE_UPDATE:
                              processCompleteUpdate(apdu); break;
                         default:
                              ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
               }
           } else {
               if (buffer[ISO7816.OFFSET_INS] == VERIFY) {
                   processVerifyPIN(apdu);
               } else if (buffer[ISO7816.OFFSET_INS] == ISO7816.INS_SELECT) {
                   if (selectingApplet())
                       processSelectPurse(apdu);
                   else 
                       processSelectFile(apdu);
                 } else if (buffer[ISO7816.OFFSET_INS] == READ) {
                     processReadRecord(apdu);
                 } else 
                     ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
             }
    this is what happens when I select the app and send the first apdu:
        Load File  :      LOADED (--------) "purse"         
         Module    :                        "purseapp"
    cm>  /select |purseapp
     => 00 A4 04 00 08 70 75 72 73 65 61 70 70 00          .....purseapp.
     (8646 usec)
     <= 6F 0D 84 08 70 75 72 73 65 61 70 03 A5 01 42 90    o...purseap...B.
        00                                                 .
    Status: No Error
    cm>  /send 8024000000
     => 80 24 00 00 00                                     .$...
     (5724 usec)
     <= 6D 00                                              m.
    Status: INS value not supported
    cm>  /send 8224000000
     => 82 24 00 00 00                                     .$...
     (3443 usec)
     <= 68 81                                              h.
    Status: 0x6881
    cm>  /send 9024000000
     => 90 24 00 00 00                                     .$...
     (4528 usec)
     <= 6D 00                                              m.
    Status: INS value not supported
    I am using eclipse with the JCOP shell with am omnikey cl card reader!

    Edited by: brennsuppa on 14.01.2013 23:01
  • 7. Re: Example: Java Purse
    HanaBizhani Newbie
    Currently Being Moderated
    Hi,

    Please change the question status as an answered question,
    Thanks

    Regards,
    Hana
  • 8. Re: Example: Java Purse
    johnnybravo Newbie
    Currently Being Moderated
    anyone able to tell me if/what I am doing wrong here?
  • 9. Re: Example: Java Purse
    HanaBizhani Newbie
    Currently Being Moderated
    Hi, I really don't know why I thought You solved your problem :)

    I test your applet in simulator (of course a simple applet with only one instruction as INITIALIZE_UPDATE) and it works fine,
    Please try to write a simple applet like the code below and test it on your card
    final static byte  INITIALIZE_UPDATE = (byte)0x24; //INS byte for Initialize Parameter Update
    final static byte SW_ALERT1 = (byte) 0x9101;
    final static byte SW_ALERT2 = (byte) 0x9102;
     
    -----------------------------------------------------------------------------------------------
    
    public void process(APDU apdu) {
         
             byte[] buf = apdu.getBuffer();
    
             if (!apdu.isISOInterindustryCLA()) {
                       switch (buf[ISO7816.OFFSET_INS])     {
                             case INITIALIZE_UPDATE:
                                               processInitializeUpdate(apdu);     break;
                             default:
                                               ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
                          }
              }
              else {
                     ISOException.throwIt(SW_ALERT1); }
    }
    
    -----------------------------------------------------------------------------------------------
    
    private void processInitializeUpdate(APDU apdu) {
            ISOException.throwIt(ISW_ALERT2);
     }
    Regards,
    Hana
  • 10. Re: Example: Java Purse
    johnnybravo Newbie
    Currently Being Moderated
    so what happens ist that "alert 1" is thrown meaning the isISOInterinddustryCLA is not right (CLA like 80, 90, 10, 7f,...) or it throws a 6881 (CLA like 82, a6 and some others)

    should I catch the CLA manually then?

    Edited by: brennsuppa on 16.01.2013 11:44

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points