Java card returns data that is required but with 6D00 in SW field

Hi all,
I am new in smart card programming, so I need help.
I am running Eclipse with JCWDE. Trying a simple applet that should return a certain value. I get the value! And I get an 6D00 error code in SW fields. 6D00 means that instruction code is not supported or invalid. My question is how is it possible that instruction code is invalid, but the applet return the data anyway?
You can find the part of the code below:
public void process(APDU apdu) throws ISOException {
        byte[] buffer = apdu.getBuffer();
        // check SELECT APDU command
        if (apdu.isISOInterindustryCLA()) {
            if (buffer[ISO7816.OFFSET_INS] == (byte)(0xA4)) {
                return;
            } else {
                ISOException.throwIt (ISO7816.SW_CLA_NOT_SUPPORTED);
        // verify the reset of commands have the
        // correct CLA byte, which specifies the
        // command structure
        if (buffer[ISO7816.OFFSET_CLA] != Applet_CLA)
            ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
        switch (buffer[ISO7816.OFFSET_INS]) {
        case 0x04:
             sendData(apdu);
        default:
            ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
        }the method sendData(APDU apdu) is shown below
private void sendData(APDU apdu){
           byte[] buffer = apdu.getBuffer();
           short le = apdu.setOutgoing();
          if ( le < 4 )
                ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
          apdu.setOutgoingLength((byte) 4);
          // move the balance data into the APDU buffer
          // starting at the offset 0
          buffer[0] = dataBack[0];
          buffer[1] = dataBack[1];
          buffer[2] = dataBack[2];
          buffer[3] = dataBack[3];
          // send the 2-byte balance at the offset
          // 0 in the apdu buffer
          apdu.sendBytes((short)0, (short)4);
     }the script I run is:
powerup;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
// create FirstStep applet
0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x02 0x00 0x7F;
// select FirstStep applet
0x00 0xA4 0x04 0x00 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x02 0x7F;
// apdu get data
0xB0 0x04 0x00 0x00 0x00 0x04;
powerdown;
the answer I get is:
Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 02, 00, Le: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 02, SW1: 90, SW2: 00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 02, Le: 00, SW1: 90, SW2: 00
CLA: b0, INS: 04, P1: 00, P2: 00, Lc: 00, Le: 04, 9e, 37, 79, b9, SW1: 6d, SW2: 00
Does this error code (6D00) means something else as well?
Edited by: Lyudmila on 2012-jul-09 03:40
Edited by: Lyudmila on 2012-jul-09 03:49

>
Does this error code (6D00) means something else as well?
>Hi Lyudmila,
This error code means you should fix a mistake in your source code:
         switch (buffer[ISO7816.OFFSET_INS]) {
         case 0x04:
              sendData(apdu);
                return;
         default:
             ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
         }

Similar Messages

  • Clean-up all data that did not match with the selection.

    Hi Everyone,
    In my requirement I need to  Clean-up all data that did not match with the selection from my internal table lt_cdpos.....in this case wat can i use like.'Refresh' or ' Clear' or 'DELETE ADJACENT DUPLICATES FROM lt_cdpos'.
    Pls suggest me...

    Hi Meenakshi
    Try  delete lt_cdpos where kunnr  NE KUNNR (from selection screen) .
    Before Checking <condition> make sure both comparing field type match with each other.
    You can use FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' for append leading zeros in compare condition before comparing kunnr from selection screen
    Regards
    Parveen

  • Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?

    Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?

    The link is to a discussion started on 12/18 in the FiOS Internet forum.  Here's the link I get now, however it is different than the link I pulled a few hours ago.  If this system changes the link again, it may not work.
    http://forums.verizon.com/t5/FiOS-Internet/Frustration-and-just-confused-with-internet-help-please/t...
    You can also look for the topic, "frustration and just confused" in the FiOS Internet forum.
    Here's a link that is in the thread that gives more detail.
    https://secure.dslreports.com/faq/15984
    Good Luck!
    P.S.  "Copper Contributor" is my "rank."  gs0b is my user name.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • Payment Card Industry Data Security Standards Requirement

    We store credit card numbers in our CRM and ERP systems for billing
    purposes. We use Delego software for credit card security. We also mask
    the credit card numbers during display.
    According to our interpretation of section 3 of the Payment Card
    Industry (PCI) Data Security Standards, we understand that we can
    retain cardholder data only as long as needed for business, legal,
    and/or regulatory purposes. According to our compliance policy that
    period is 3 years.
    Hence we wish to replace all card numbers older than 3 years with dummy
    card numbers. Since this requirement is mandated by the PCI-DSS, we
    believe SAP should be supplying us means to accomplish this. Are there any programs delivered by SAP to modify card numbers? Has anybody come across such a requirement?

    Hi Gina,
    Did you find good information about PCI-DSS compliance topics with SAP from this forum?  In particular we are looking at options to comply with requirement 11, File Integrity Monitoring.
    We would appreciate any guidance.
    Thank you, TMM

  • How can I insert a required subVI that is required but Labview won't accept it?

    I am trying to use a VI named Termperature Monitor that was provided in
    the Labview 7  library included on the CD but it seems to be
    missing subVIs. I located the subVIs on the cd and attempted to insert
    them into the block diagram where the question marks are. Despite the
    fact that the names of the subVIs match what Labview expects, the app
    won't accept them. Is there a way to force them to accept the subVI
    that I picked?

    Have you installed LabVIEW? and if yes, aren't the example vi's on your harddrive now? How are you "attempting to insert them"? When LabVIEW starts loading a vi and hits a sub-vi that it can't find it will eventually pop up a message with a file search box. If you then navigate to where the vi (with exactly the same name ) resides it should then use that vi. If it, for whatever reason, doesn't match (different connections in particular instance), it should still place it on the diagram, but with broken wires. Alternately you can right click on the blank icon with ?, scoll down to "replace" and navigate to the correct one. This way doesn't require the new vi to have the same name. I'm not sure what happens if the vi you are looking for is on a CD though.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • MDD will not boot with 9200 agp card in it....but with a 16mb pci card

    I just got the MDD today and noticed an extra tab on the card....is this an on/off switch so you have to use this card?
    So Ieft it in and put in the ole trusty 16 mb rage card and booted.
    My 9200 agp works in my sawtooth but not this one and I suspect its that extra tab on there....or I could be wrong.
    Any way I guess I will use the dvi -d output *and was wondering a good place to buy the dvi to vga adapter for my crt.*
    Thanks for any input...
    Tony B.
    null

    I did read that earlier today but wasn't sure if it would work on that card.....I will try that for sure....thanks !!!!
    Tony

  • Running total required but with different timing

    Hi All:
    I am using Oracle9i Enterprise Edition Release 9.2.0.6.0
    I want to write a query to display the statistics report with running total.
    I have written following query that return last 60 minutes activities.
    SELECT se.tserv_id,
    sum(decode(eu.category,'I',1,0)) Imp,
    sum(decode(eu.category,'E',1,0)) Exp,
    count(*) Total
    FROM service_events se, equipment_uses eu
    WHERE se.performed BETWEEN trunc(sysdate-60/1440,'mi')
    AND trunc(sysdate,'mi')
    AND se.tserv_id IN ('EXM','GROUNDED')
    AND eu.gkey = se.equse_gkey
    AND eu.category IN ('I','E')
    GROUP BY se.tserv_id;
    now I want to write a query that shows me the result of above query and running total as well
    But the different between current activity and running total is as follows
    Current Activity = Last 60 minutes activity
    Running Total = Total activities from the 08:00 am till sysdate.
    for example if this query executed on 11:00 am then the current activity values must be from 10:00 am to 11:00 am and the running total values must be from 08:00 am to 11:00 am
    The reason for running total starts at 08:00 am is that the shift starts from 08:00 am to next day 07:59 am.
    Can I write one single query for this?
    Similarly running total values must be start from last day 08:00 am to current date and time when I executed this query from 00:00 to 08:00 (12 midnight to 8am)
    if difficult then plz let me know that how can I find that if the time is from 00 hrs to 08 hrs then start time must be the last date 08:00 am to the current date and time.
    Thanks
    Hassan

    Dear Frnak
    Thanks for your reply and help
    Its really did what I want
    I mean to say that the result format is correct but the value of Total_day column is not correct.
    Following is the sample data from 19-Jun-2008 08:00 AM to 20-JUN-2008 08:00 AM
    TSERV_ID  EQUSE_GKEY     PERFORMED
    ===============================================
    EXM       5188958     19-Jun-2008 8:00:32 AM
    EXM       5185586     19-Jun-2008 9:03:34 AM
    EXM       5181960     19-Jun-2008 9:03:35 AM
    EXM       5173333     19-Jun-2008 9:03:35 AM
    EXM       5188263     19-Jun-2008 9:08:49 AM
    GROUNDED  5174055     19-Jun-2008 9:10:29 AM
    GROUNDED  5152887     19-Jun-2008 9:10:29 AM
    GROUNDED  5187512     19-Jun-2008 9:10:29 AM
    GROUNDED  5196303     19-Jun-2008 9:27:41 AM
    EXM       5196370     19-Jun-2008 9:29:50 AM
    EXM       5172045     19-Jun-2008 10:01:23 AM
    GROUNDED  5196269     19-Jun-2008 11:11:29 AM
    GROUNDED  5200219     19-Jun-2008 11:24:39 AM
    GROUNDED  5185246     19-Jun-2008 12:06:30 PM
    GROUNDED  5190134     19-Jun-2008 12:09:27 PM
    GROUNDED  5190475     19-Jun-2008 12:09:27 PM
    GROUNDED  5156065     19-Jun-2008 12:26:49 PM
    GROUNDED  5132287     19-Jun-2008 1:56:44 PM
    EXM       5189203     19-Jun-2008 2:29:17 PM
    EXM       5180158     19-Jun-2008 3:27:03 PM
    EXM       5149310     19-Jun-2008 3:37:31 PM
    EXM       5196303     19-Jun-2008 3:42:48 PM
    EXM       5192768     19-Jun-2008 4:03:51 PM
    EXM       5174055     19-Jun-2008 4:14:23 PM
    EXM       5200231     19-Jun-2008 4:45:51 PM
    EXM       5157151     19-Jun-2008 4:51:06 PM
    EXM       5159930     19-Jun-2008 5:01:36 PM
    EXM       5185237     19-Jun-2008 5:01:37 PM
    EXM       5195434     19-Jun-2008 5:01:37 PM
    EXM       5152887     19-Jun-2008 5:06:49 PM
    EXM       5196269     19-Jun-2008 5:06:49 PM
    EXM       5187512     19-Jun-2008 5:17:26 PM
    EXM       5190134     19-Jun-2008 5:59:24 PM
    GROUNDED  5101919     19-Jun-2008 6:44:36 PM
    GROUNDED  5101918     19-Jun-2008 6:44:37 PM
    GROUNDED  5101913     19-Jun-2008 6:44:37 PM
    EXM       5185735     19-Jun-2008 6:46:38 PM
    GROUNDED  5195475     19-Jun-2008 6:47:11 PM
    GROUNDED  5195361     19-Jun-2008 6:47:12 PM
    EXM       5132608     19-Jun-2008 7:02:23 PM
    GROUNDED  5195334     19-Jun-2008 7:10:32 PM
    GROUNDED  5190558     19-Jun-2008 7:10:32 PM
    EXM       5183029     19-Jun-2008 7:33:53 PM
    EXM       5183480     19-Jun-2008 7:39:12 PM
    EXM       5189566     19-Jun-2008 8:00:11 PM
    EXM       5181825     19-Jun-2008 8:15:57 PM
    EXM       5183537     19-Jun-2008 8:15:57 PM
    EXM       5180210     19-Jun-2008 9:08:27 PM
    GROUNDED  5193136     19-Jun-2008 9:58:23 PM
    EXM       5171510     19-Jun-2008 10:21:59 PM
    EXM       5185615     19-Jun-2008 10:48:14 PM
    EXM       5184737     19-Jun-2008 10:53:29 PM
    EXM       5195475     19-Jun-2008 11:51:16 PM
    EXM       5195476     20-Jun-2008 12:01:46 AM
    EXM       5190558     20-Jun-2008 12:12:17 AM
    EXM       5196473     20-Jun-2008 12:54:19 AM
    EXM       5183204     20-Jun-2008 1:20:34 AM
    GROUNDED  5192844     20-Jun-2008 1:28:24 AM
    GROUNDED  5174238     20-Jun-2008 1:28:24 AM
    GROUNDED  5193127     20-Jun-2008 1:28:24 AM
    GROUNDED  5185794     20-Jun-2008 1:29:09 AM
    GROUNDED  5192895     20-Jun-2008 3:04:23 AM
    GROUNDED  5193039     20-Jun-2008 3:04:23 AM
    GROUNDED  5195447     20-Jun-2008 3:04:23 AM
    GROUNDED  5190228     20-Jun-2008 3:04:24 AM
    GROUNDED  5179370     20-Jun-2008 3:04:24 AM
    GROUNDED  5190289     20-Jun-2008 3:04:24 AM
    GROUNDED  5174065     20-Jun-2008 3:04:24 AM
    GROUNDED  5192862     20-Jun-2008 5:04:42 AM
    GROUNDED  5199903     20-Jun-2008 5:04:42 AM
    EXM       5178176     20-Jun-2008 6:30:29 AM
    EXM       5185161     20-Jun-2008 6:46:14 AM
    EXM       5180226     20-Jun-2008 6:46:14 AM
    GROUNDED  5202026     20-Jun-2008 7:03:14 AM
    EXM       5101912     20-Jun-2008 7:07:14 AM
    GROUNDED  5176763     20-Jun-2008 7:25:27 AM
    GROUNDED  5185494     20-Jun-2008 7:25:27 AM
    EXM       5185295     20-Jun-2008 7:38:46 AM
    EXM       5173837     20-Jun-2008 7:49:15 AM
    GKEY     CATEGORY
    =================
    5101912     I
    5101913     I
    5101918     I
    5101919     I
    5132287     I
    5132608     I
    5149310     I
    5152887     I
    5156065     I
    5157151     I
    5159930     I
    5171510     I
    5172045     I
    5173333     I
    5173837     I
    5174055     I
    5174065     I
    5174238     I
    5176763     I
    5178176     I
    5179370     I
    5180158     I
    5180210     I
    5180226     I
    5181825     I
    5181960     I
    5183029     I
    5183204     I
    5183480     I
    5183537     I
    5184737     I
    5185161     I
    5185237     I
    5185246     I
    5185295     I
    5185494     I
    5185586     I
    5185615     I
    5185735     I
    5185794     I
    5187512     I
    5188263     I
    5188958     I
    5189203     I
    5189566     I
    5190134     I
    5190228     I
    5190289     I
    5190475     I
    5190558     I
    5192768     I
    5192844     I
    5192862     I
    5192895     I
    5193039     I
    5193127     I
    5193136     I
    5195334     I
    5195361     I
    5195434     I
    5195447     I
    5195475     I
    5195476     I
    5196269     I
    5196303     I
    5196370     I
    5196473     I
    5199903     I
    5200219     E
    5200231     E
    5202026     EAnd I used the same query suggested by you.
    WITH     s     AS(     
    SELECT     se.tserv_id     ,     eu.category     ,
               CASE
                 WHEN     se.performed     BETWEEN     
                                    to_date('&target_dt','DD-MON-RRRR HH24:MI') - (1/24)
                                  AND     to_date('&target_dt','DD-MON-RRRR HH24:MI')
                          THEN     1
              ELSE     0
              END     AS in_hour     ,
            CASE
              WHEN     TRUNC (se.performed - (8/24)) =     TRUNC (to_date('&target_dt','DD-MON-RRRR HH24:MI')
                                                     - (8/24))
                THEN     1
              ELSE     0
              END     AS in_day
    FROM     service_events     se     ,     equipment_uses     eu
    WHERE     eu.gkey          = se.equse_gkey
         AND     eu.category     IN ('I', 'E')
      AND se.tserv_id in ('EXM','GROUNDED')
    SELECT     tserv_id,     
            SUM (DECODE (category, 'I', in_hour))     AS imp_hour,     
            SUM (DECODE (category, 'E', in_hour))     AS exp_hour,
            SUM (in_hour)     AS total_hour,
            SUM (in_day)     AS total_day
    FROM     s
    GROUP BY     tserv_idNow you have the sample data for almost 24 hours
    Let me clear it again
    When I executed this query at 20-JUN-2008 09:00 AM it gives me following result (that is accurate)
    TSERV_ID  IMP_HOUR  EXP_HOUR  TOTAL_HOUR  TOTAL_DAY
    EXM        2         0           2               3
    GROUNDED   1         0           1               8When I executed this query between 20-JUN-2008 00:00 to 20-JUN-2008 08:00
    then system must show the Total_Day value from 19-JUN-2008 08:00 to current date and time. e.g
    I executed this query at 20-JUN-2008 06:00 AM it gives me following result:
    TSERV_ID  IMP_HOUR  EXP_HOUR  TOTAL_HOUR  TOTAL_DAY
    EXM             0     0     0        44
    GROUNDED     2     0     2        35Now here you can see that the value of Total_Day is not as accurate as I required:
    EXM = 44 and GROUNDED = 35
    these values are between 19-JUN-2008 00:00 to 20-JUN-2008 06:00 (that is wrong in my case)
    The values of total_day should be as follows as 8 hours from 00:00 to 07:59 AM fall in the shift of 18-JUN-2008 not in 19-JUN-2008
    From 19-JUN-2008 08:00 to 20-JUN-2008 06:00
    EXM: 38
    GROUNDED: 32
    Plz note that this result is required because in our company the shift starts from 08:00 AM and ends 07:59 AM next day
    I hope you will be more clear now and there is no confusion anymore.
    Plz let me know if you still confused.
    Brgs,

  • I bought a used Cisco 9865HD PVR Nextbox that I require help with to unlock?

    I would very much appreciate help with this from someone with knowledge and patience (technoob)..lol. I am very new to this site so not sure if I am doing this properly but crossing my fingers I meet someone nice who is willing to assist me. =)

    This may help with the problem if the iPod not appearing in Windows:
    http://support.apple.com/kb/TS1538
    You may need to put the iPod into Recovery or DFU mode as well:
    http://support.apple.com/kb/ht1808
    http://www.iclarified.com/entry/index.php?enid=1034
    If none of that works, you may have been sold a broken iPod.
    Regards.

  • Apps that say free but with a subscription price added?

    When you have an App such as a magazine, or news like The New York Times with a monthly subscription. When you download the app for free are you getting charged for that monthly fee without knowing it? I ask because the app says free download but is not so clear on if you subscribed on a monthly subscription. So is the buyer being fooled or is it really free?

    That's referred to as an "In-App" purchase...
    Help here ...
    iTunes Store: About In-App Purchases 
    iTunes Store: Purchasing and managing auto-renewing subscriptions
    The app to read the content is free but not the subscription.

  • Novice in Java Card

    Hi! I'm a novice in Java Card and I'm trying to study with the examples that I find in the Internet. I get this code, that I compile with successful. But, now, what I have to do? how can I debbug and test?
    Thanks.
    package bank;
    import javacard.framework.*;
    //import javacardx.framework.*;
    public class Wallet extends Applet {
    /* constants declaration */
    // code of CLA byte in the command APDU header
    final static byte Wallet_CLA =(byte)0xB0;
    // codes of INS byte in the command APDU header
    final static byte VERIFY = (byte) 0x20;
    final static byte CREDIT = (byte) 0x30;
    final static byte DEBIT = (byte) 0x40;
    final static byte GET_BALANCE = (byte) 0x50;
    // maximum balance
    final static short MAX_BALANCE = 0x7FFF;
    // maximum transaction amount
    final static byte MAX_TRANSACTION_AMOUNT = 127;
    // maximum number of incorrect tries before the
    // PIN is blocked
    final static byte PIN_TRY_LIMIT =(byte)0x03;
    // maximum size PIN
    final static byte MAX_PIN_SIZE =(byte)0x08;
    // signal that the PIN verification failed
    final static short SW_VERIFICATION_FAILED = 0x6300;
    // signal the PIN validation is required
    // for a credit or a debit transaction
    final static short SW_PIN_VERIFICATION_REQUIRED = 0x6301;
    // signal invalid transaction amount
    // amount > MAX_TRANSACTION_MAOUNT or amount < 0
    final static short SW_INVALID_TRANSACTION_AMOUNT = 0x6A83;
    // signal that the balance exceed the maximum
    final static short SW_EXCEED_MAXIMUM_BALANCE = 0x6A84;
    // signal the balance becomes negative
    final static short SW_NEGATIVE_BALANCE = 0x6A85;
    /* instance variables declaration */
    OwnerPIN pin;
    short balance;
    private Wallet(byte[] bArray, short bOffset, byte bLength){
    // It is good programming practice to allocate
    // all the memory that an applet needs during
    // its lifetime inside the constructor
    pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
    // The installation parameters contain the PIN
    // initialization value
    pin.update(bArray, bOffset, bLength);
    register();
    public static void install(byte[] bArray, short bOffset, byte bLength) {
    // create a Wallet applet instance
    new Wallet(bArray, bOffset, bLength);
    public boolean select() {
    // The applet declines to be selected
    // if the pin is blocked.
    if (pin.getTriesRemaining() == 0) return false;
    return true;
    public void deselect() {
    // reset the pin value
    pin.reset();
    public void process(APDU apdu) {
    // APDU object carries a byte array (buffer) to
    // transfer incoming and outgoing APDU header
    // and data bytes between card and CAD
    // At this point, only the first header bytes
    // [CLA, INS, P1, P2, P3] are available in
    // the APDU buffer.
    // The interface javacard.framework.ISO7816
    // declares constants to denote the offset of
    // these bytes in the APDU buffer
    byte[] buffer = apdu.getBuffer();
    // check SELECT APDU command
    if ((buffer[ISO7816.OFFSET_CLA] == 0) &&
    (buffer[ISO7816.OFFSET_INS] == (byte)(0xA4))) return;
    // verify the reset of commands have the
    // correct CLA byte, which specifies the
    // command structure
    if (buffer[ISO7816.OFFSET_CLA] != Wallet_CLA)
    ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
    switch (buffer[ISO7816.OFFSET_INS]) {
    case GET_BALANCE: getBalance(apdu);
    return;
    case DEBIT: debit(apdu);
    return;
    case CREDIT: credit(apdu);
    return;
    case VERIFY: verify(apdu);
    return;
    default: ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
    } // end of process method
    private void credit(APDU apdu) {
    // access authentication
    if ( !pin.isValidated()) ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
    byte[] buffer = apdu.getBuffer();
    byte Lc; //denotes the number of bytes in the
    // data field of the command APDU
    byte numBytes = buffer[ISO7816.OFFSET_LC];
    // indicate that this APDU has incoming data
    // and receive data starting at the offset
    // ISO7816.OFFSET_CDATA following the 5 header
    // bytes.
    byte byteRead = (byte)(apdu.setIncomingAndReceive());
    // it is an error if the number of data bytes
    // read does not match the number in Lc byte
    if (byteRead != 1) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    // get the credit amount
    byte creditAmount = buffer[ISO7816.OFFSET_CDATA];
    // check the credit amount
    if ( ( creditAmount > MAX_TRANSACTION_AMOUNT) || ( creditAmount < 0 ) )
    ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
    // check the new balance
    if ( ( balance + creditAmount) > MAX_BALANCE ) ISOException.throwIt(SW_EXCEED_MAXIMUM_BALANCE);
    // credit the amount
    balance = (short)(balance + creditAmount);
    } // end of deposit method
    private void debit(APDU apdu) {
    // access authentication
    if ( ! pin.isValidated()) ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
    byte[] buffer = apdu.getBuffer();
    byte numBytes = (byte)(buffer[ISO7816.OFFSET_LC]);
    byte byteRead = (byte)(apdu.setIncomingAndReceive());
    if (byteRead != 1) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    // get debit amount
    byte debitAmount = buffer[ISO7816.OFFSET_CDATA];
    // check debit amount
    if ((debitAmount > MAX_TRANSACTION_AMOUNT) || (debitAmount < 0 ) )
    ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
    // check the new balance
    if ((balance - debitAmount) < 0) ISOException.throwIt(SW_NEGATIVE_BALANCE);
    balance = (short) (balance - debitAmount);
    } // end of debit method
    private void getBalance(APDU apdu) {
    byte[] buffer = apdu.getBuffer();
    // inform system that the applet has finished
    // processing the command and the system should
    // now prepare to construct a response APDU
    // which contains data field
    short le = apdu.setOutgoing();
    if ( le < 2 ) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    //informs the CAD the actual number of bytes
    //returned
    apdu.setOutgoingLength((byte)2);
    // move the balance data into the APDU buffer
    // starting at the offset 0
    buffer[0] = (byte)(balance >> 8);
    buffer[1] = (byte)(balance & 0xFF);
    // send the 2-balance byte at the offset
    // 0 in the apdu buffer
    apdu.sendBytes((short)0, (short)2);
    } // end of getBalance method
    private void verify(APDU apdu) {
    byte[] buffer = apdu.getBuffer();
    // retrieve the PIN data for validation.
    byte byteRead = (byte)(apdu.setIncomingAndReceive());
    // check pin
    // the PIN data is read into the APDU buffer
    // at the offset ISO7816.OFFSET_CDATA
    // the PIN data length = byteRead
    if ( pin.check(buffer, ISO7816.OFFSET_CDATA,byteRead) == false )
    ISOException.throwIt(SW_VERIFICATION_FAILED);
    }

    Win nt 4 and Win 2000 are the only supported windows platforms at this time.

  • What Java compiler for Java Card development ?

    What Java compiler and options should be used for Java Card development with the goal of generating correct, and (secondarily) small or/and fast code after conversion to Java Card bytecode using converter ?
    In particular
    - Is use of JDK 7 approved by Oracle for Java Card development? That would solve security problems associated with (the web components of the JRE of) some earlier JDK, including the latest JDK6. The JCDK 3.0.4 release notes states "+the commercial version of Java Development Kit (JDK software) version 6 Update 10 (JDK 6 Update 10) or later is required+, but that does not answer that question.
    - Anyone had _bad_ experience (like incorrect or disastrous code) with the Java compiler bundled with Eclipse ? I have seen at least one case where org.eclipse.jdt.core_3.7.3.v20120119-1537.jar produced slightly more compact code than javac.
    - Anyone had _bad_ experience with javac in jdk1.3 ? In an applet involving a "finally" clause, I've seen it generating more compact code than later javac (which in my test triplicated the code for the finally clause).

    What Java compiler and options should be used for Java Card development with the goal of generating correct, and (secondarily) small or/and fast code after conversion to Java Card bytecode using converter ?-target -source may be required to generate compatible byte code. Depending on the CAP file converter being used debug information may also help. Remember that Java Card is a subset of the Java language (also there are short opcodes that Java doesn't have etc) so a lot of the work for optimisation is done by the converter or the JCRE. You can look at the JCA code generated to determine what works best for your applets. There are also some ways of stripping out dead code etc from JCA files (return statements after a throw etc) to reduce your code size. Most of the speed optimisations come from your code (avoiding context switches and unnecessary security/access checks).
    The compactness of your Java Card binary may not be directly related to the size of your compiled Java code. It can depend on the converter you use and any optimisaitons the JCRE might try to do when the code is loaded.
    - Is use of JDK 7 approved by Oracle for Java Card development? That would solve security problems associated with (the web components of the JRE of) some earlier JDK, including the latest JDK6. Java Card does not use any of the libraries from the JDK/JRE. All of the libraries are provided by the JCRE on the smartcard.
    The JCDK 3.0.4 release notes states "+the commercial version of Java Development Kit (JDK software) version 6 Update 10 (JDK 6 Update 10) or later is required+, but that does not answer that question.Anything above JDK6u10 is supported. If you use Java 7 you may need to add a -source and -target flag when compiling.
    - Anyone had _bad_ experience (like incorrect or disastrous code) with the Java compiler bundled with Eclipse ? I have seen at least one case where org.eclipse.jdt.core_3.7.3.v20120119-1537.jar produced slightly more compact code than javac.We generally use the Eclipse compiler as we find that we get more deterministic builds. When CAP files are sent for security review it is helpful to have the reviewer able to generate a CAP file that matches the one you sent to confirm the binary is what you say it is.
    - Anyone had _bad_ experience with javac in jdk1.3 ? In an applet involving a "finally" clause, I've seen it generating more compact code than later javac (which in my test triplicated the code for the finally clause).We do not use anything less than Java 6 for compilation.
    - Shane

  • Java Card Memory Managament: How do you free-up allocated memory?

    I have a problem with java card memory management, that causes the applet to hang. I think the java card runs out of RAM when my applet runs for several iterations or process() calls. My program requires significant size of bytes for each APDU command to be sent. (around 100-250 bytes, for each apdu.sendBytes() call).
    I use a temporary byte array buffer that will contain the APDU command to be sent, declared as:
    private byte [] tmpBuff;Before each process() call, the tmBuff is initialized and contains a new byte array containing the APDU command to be sent. (array size around 100-250 bytes).
    tmpBuff = new byte[] {0x00, ... } On the process() call, the tmpBuff is copied to APDU and sendBytes() function is called. The tmpBuff byte array is reinitialized after every process() call to contain the next command. After about 20 successful commands by the process() call, the applet seems to ran out of RAM and hangs.
    I suspect, that when tmpBuff is reinitialized before each process() call, the Java Card garbage collector does now free-up the memory that was used for the previous tmpBuff byte array initialization.
    Is there a way to reclaim the memory allocated for tmpBuff after it has been initialized?
    Or maybe call the Java card garbage collector?

    Cenon,
    Generally speaking, the new keywork is a bad idea outside the install method or constructors as the JCRE is not guarenteed to have a garbage collector (and if it does, has to be called explicitly by JCSystem.requestObjectDeletion(); This however is slow.
    A better option may be to use memory more efficiently than to rely on garbage collection. A way of doing this would be to have an instance variable that is initialised once and reused. This allows you to use either a transient or persistent array.
    public class TestApplet extends Applet {
        private final static short BUFFER_SIZE = (short) 300;
        private final byte[] buffer;
        private TestApplet() {
            // only have one of the following not commented out
            /* persistent buffer */
            // buffer = new byte[BUFFER_SIZE];
            /* transient buffer (much faster) */
            buffer = JCSystem.makeTransientByteArray(BUFFER_SIZE, JCSystem.CLEAR_ON_DESELECT);
        public static void install(byte[] bArray, short bOffset, byte bLength) {
            // GP-compliant JavaCard applet registration
            new TestApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
        public void process(APDU apdu) {
            // Good practice: Return 9000 on SELECT
            if (selectingApplet()) {
                return;
            // do some work here with buffer
    }In the above code you would be able to use the buffer to build the command and you will not have a memory leak.
    Cheers,
    Shane
    Edited by: safarmer on Jul 8, 2008 12:25 PM

  • Apex 4.0 - Can see view data in SQL*Plus but no data in Object Browser

    Hi There,
    I have just started using Apex 4.o and migrated some apps. I have an issue with a report, but see the same issue with Object browser, which is easier to describe.
    I have a view:
    create or replace view V_PLJ_USERDEF_CODES (
             CODE_SET_ID,
             CODE_SET_CODE,
             CODE_SET_DESC,
             CODE_ID,
             CODE_SYS_CODE,
             CODE_VALUE,
             CODE_DESC,
             DISPLAY_SEQ,
             DISPLAY_FLAG,
             LANGUAGE_CODE) as
      select CS.CODE_SET_ID,
             CS.CODE_SET_CODE,
             CS.CODE_SET_DESC,
             C.CODE_ID,
             C.CODE_SYS_CODE,
             C.CODE_VALUE,
             C.CODE_DESC,
             C.DISPLAY_SEQ,
             C.DISPLAY_FLAG,
             C.LANGUAGE_CODE
        from PLJ_CODES C,
             PLJ_CODE_SETS CS
       where C.CODE_SET_ID         = CS.CODE_SET_ID
         and CS.CODE_SET_TYPE_CODE = SYS_CONTEXT('PLJUMPSTART','C_USERDEF_CODE_SET');This returns data in SQL*Plus, but no data in Object Browser OR report region based on this view.
    Workspace parses in the same schema as tested in SQL*Plus.
    If, in report, I swap out view, and use underlying table - no problem.
    Any ideas -
    thanks
    P

    Hi all,
    Thanks for getting back so promptly.
    It just seems weird to me, as tables are just fine, but not views.
    In the underlying schema:
    SQL> sho user
    USER is "ICSREPORTING"
    SQL> select count(*) from plj_codes;
      COUNT(*)
           107
    SQL> select count(*) from v_plj_userdef_codes;
      COUNT(*)
            29And in the APEX schema
    SQL> sho user
    USER is "APEX_040000"
    SQL> select count(*) from icsreporting.plj_codes;
    select count(*) from icsreporting.plj_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> select count(*) from icsreporting.v_plj_userdef_codes;
    select count(*) from icsreporting.v_plj_userdef_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL>However, in SQL browser, I can see the data in PLJ_CODES but in V_PLJ_USERDEF_CODES, just the message "This view has no data". Indeed, it is like this for all views.
    I even explicitly granted access to APEX_040000 but no good.
    In fact, I would like to know more about how Apex gets access to do DML against the underlying parsing schema(s).
    This is a little frustrating though. It worked just fine in lots of apps in version 2.1 to 3.2
    Am I missing something
    paul
    p.s I knew there would be a question about the context, but I had already checked that. :)
    Edited by: PJ on Nov 19, 2010 4:09 AM

  • The (maximum) expected data length is 6, while the returned data length is

    I would like to connect the view via the OraOLEDB.Oracle' from linked server of the MSSQL and the following column couldn't be selected.
    Msg 7347, Level 16, State 1, Line 2
    OLE DB provider 'OraOLEDB.Oracle' for linked server 'PROD' returned data that does not match expected data length for column salary.LATEST_HIRE_DATE_STATUS'. The (maximum) expected data length is 6, while the returned data length is 4.
    So I would like to change the following code from case method to decode method ? due to the view can be selected by decode method .
    CASE
    WHEN TRUNC (latest_hire_date) >= SYSDATE - 90
    AND type_of_post = 'Temp'
    THEN 'YES'
    ELSE 'NO'
    END
    AS latest_hire_date_status,
    CASE
    WHEN last_day_of_duty IS NOT NULL THEN 'REJECTED'
    ELSE 'PASSED'
    END
    AS last_day_of_duyty_status,
    Edited by: user10605622 on 2012/2/8 上午 8:01

    user10605622 wrote:
    I would like to connect the view via the OraOLEDB.Oracle' from linked server of the MSSQL and the following column couldn't be selected.
    Msg 7347, Level 16, State 1, Line 2
    OLE DB provider 'OraOLEDB.Oracle' for linked server 'PROD' returned data that does not match expected data length for column salary.LATEST_HIRE_DATE_STATUS'. The (maximum) expected data length is 6, while the returned data length is 4.
    So I would like to change the following code from case method to decode method ? due to the view can be selected by decode method .
    CASE
    WHEN TRUNC (latest_hire_date) >= SYSDATE - 90
    AND type_of_post = 'Temp'
    THEN 'YES'
    ELSE 'NO'
    END
    AS latest_hire_date_status,
    CASE
    WHEN last_day_of_duty IS NOT NULL THEN 'REJECTED'
    ELSE 'PASSED'
    END
    AS last_day_of_duyty_status,Not quiet sure what your problem is or what you are asking for?
    There's no need to use a DECODE statement when a CASE will do the same, and more, certainly if you want to check for range values rather than equality values as in your ">= SYSDATE - 90".
    Not quite sure what your error message means either. Seems to be nonesense as it says the maximum is 6 and it's getting 4, but 4 is not greater than 6 so it shouldn't be a problem.

  • "GemSafeXpresso Card returns "6D 00" for most of APDU commands"

    Hi everyone,
    I am confused with GemSafeXpresso smart card, GemSafeXpresso card can be authenticate with CardManager but I can not delete the instance of applet with GlobalPlatform Delete APDU command,it returns "6D 00"
    In following you can find what was happend on my card:
    At first,I installed GemSafe V2.04 applet that is placed on Rom of the card,I mean I created an instance of GemSafe applet with "A0 00 00 00 18 0A 00 00 01 63 42 00" ID successfully, after that I selectd GemSafe applet and Root and then I created some EFs under root ,but now I can not delete the instance of applet that I have created,The card returns "6D 00" ,I can authenticate with CardManager but I can not delete , create or install ,...
    I should say ,at first I installed and deleted the instance some times but I can not do now ,I would like to know what is the reason of this problem.
    I appreciate for any help,
    Yours sincerely,
    Orchid

    Dear lexdabear,
    Thanks a lot for your reply,
    Gemalto has written GemSafe applet and has loaded on Rom of GemSafeXpresso card but I can just install it and make an instance of it on the card ,So I don not have source of applet.
    In following you can find the APDU command for install ,delete ,...
    Authenticate
    key file: C:\GemXpressoJCardManager\keyfiles\jc2.2.1 - gp2.1.1\default.keys
    key set 0 (Card Defined)
    Select the CardManager
    -> 00 A4 04 00 08 A0 00 00 00 18 43 4D 00
    <- 61 1B [Normal ending of the command with <27> bytes of extra information.]
    Initialize Update
    80 50 00 01 08 00 01 02 03 04 05 06 07 (00)
    4D 00 72 38 02 04 7D 89 0C 77 FF 01 D2 89 12 21 AA 07 FE 36 07 F0 51 9F 2D D1 88 10, 90 00 [Normal ending of the command.]
    Card info KeySet=-1
    (SCP 01,implementation i05)
    External Authenticate
    84 82 00 00 10 01 93 6B 90 77 1F 72 F7 A4 6F 6D 63 B5 D3 0D AF
    90 00 [Normal ending of the command.]
    *1)Install for Install*
    80 E6 04 00 44 10 A0 00 00 00 18 30 08 01 00 00 00 00 00 00 00 FF 10 A0 00 00 00 18 30 08 01 00 00 00 00 00 00 00 00 0C A0 00 00 00 18 0A 00 00 01 63 42 00 01 00 11 C9 0F DF 0A 06 02 0F 00 01 0C 01 DF 0B 03 06 E1 E1 00 (00)
    00, 90 00 [Normal ending of the command.]
    2) Install for Make Selectable
    80 E6 08 00 13 00 00 0C A0 00 00 00 18 0A 00 00 01 63 42 00 01 00 00 00 (00)
    00, 90 00 [Normal ending of the command.]
    3)*Select Applet*
    00 A4 04 00 0C A0 00 00 00 18 0A 00 00 01 63 42 00 (10)
    90 00 [Normal ending of the command.]
    4) Select Root
    00 A4 00 00 02 3F 00 (30)
    6F 17 83 02 3F 00 8C 03 06 E1 E1 84 0C A0 00 00 00 18 0C 00 00 01 63 42 00, 90 00 [Normal ending of the command.]
    5)*Create EF SN-0001*
    00 E0 00 00 15 62 13 81 02 00 08 82 01 01 83 02 00 01 8A 01 01 8C 03 03 FF 00
    90 00 [Normal ending of the command.]
    6) Authenticate
    key file: C:\GemXpressoJCardManager\keyfiles\jc2.2.1 - gp2.1.1\default.keys
    Select the CardManager
    -> 00 A4 04 00 08 A0 00 00 00 18 43 4D 00
    <- 61 1B [Normal ending of the command with <27> bytes of extra information.]
    key set 0 (Card Defined)
    Initialize Update
    -> 80 50 00 01 08 00 01 02 03 04 05 06 07 (00)
    <- 4D 00 72 38 02 04 7C 89 0C 77 FF 01 6A E1 C6 FD AB 43 12 E1 18 CC 97 8C 3A B2 25 29, 90 00 [Normal ending of the command.]
    Card info KeySet=-1
    (SCP 01,implementation i05)
    External Authenticate
    -> 84 82 00 00 10 6B AD 05 2C 70 42 67 01 C5 53 31 90 1B 50 15 10
    <- 90 00 [Normal ending of the command.]
    7)*Delete instance of applet*
    -> 80 E4 00 00 0E 4F 0C A0 00 00 00 18 0A 00 00 01 63 42 00 (00)
    [ERROR  ] <- 6D 00
    [ERROR  ] <- Invalid instruction.
    Thanks in advance for your help.
    yours sincerely,
    Orchid
    Edited by: NewOrchid on May 8, 2008 7:40 AM

Maybe you are looking for