How to make apdu.getBuffer() return buf that is greater than 133 bytes.

    public void process(APDU apdu) {
      byte[] buf = new byte[256];
        buf = apdu.getBuffer();
        // GOOD PRACTICE: RETURN 9000 ON SELECT
        if (selectingApplet()) {
            return;
        apdu.setIncomingAndReceive();
        switch (buf[ISO7816.OFFSET_INS]) {
            case (byte) 0x01:
This is my process method. I have a command APDU of length 200 bytes that I want the buffer to read and store into a local byte array. However, apdu.getBuffer() is only grabbing the first 133 bytes of data.
According to javadocs:
"The APDU object is owned by the Java Card runtime environment. The APDU class maintains a byte array buffer which is used to transfer incoming APDU header and data bytes as well as outgoing data. The buffer length must be at least 133 bytes ( 5 bytes of header and 128 bytes of data ). The Java Card runtime environment must zero out the APDU buffer before each new message received from the CAD."
Since the buffer length is larger than 133 bytes, why does it not accept the remaining bytes?
I am using jCardSim on NetBeans IDE, java card version 2.2.2.
Also, could someone explain to me what exactly apdu.setIncomingAndReceive() does? My code is able to build/run both with and without it.
Thanks

I tried using that in my code, but it's still not working, I must be placing it in the wrong spot. I put it in the process method right before my switch cases. Do I actually put all of the code in the while loop? Perhaps you could explain the code to me, why do you only want the last two bytes of LC, and why 55? This is what it looks like currently:
    public void process(APDU apdu) {
        byte[] buf = apdu.getBuffer();
        // GOOD PRACTICE: RETURN 9000 ON SELECT
        if (selectingApplet()) {
            return;
       short bytesLeft = (short) (buf[ISO7816.OFFSET_LC] & 0x00FF);
        if (bytesLeft < (short) 55) {
            ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        short readCount = apdu.setIncomingAndReceive();
        while (bytesLeft > 0) {
            // process bytes in buffer[5] to buffer[readCount+4]; 
            bytesLeft -= readCount;
            readCount = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
        // HARDCODED PARAMETERS TO PASS INTO FUNCTIONS
        byte[] O = new byte[6];
        byte[] U = new byte[3];
        byte[] N = new byte[5];
        byte[] A = new byte[4];
        Util.arrayCopy(buf, (short) (ISO7816.OFFSET_EXT_CDATA), O, (short) 0, (short) 6);
        Util.arrayCopy(buf, (short) (ISO7816.OFFSET_EXT_CDATA + 7), U, (short) 0, (short) 3);
        Util.arrayCopy(buf, (short) (ISO7816.OFFSET_EXT_CDATA + 11), N, (short) 0, (short) 5);
        Util.arrayCopy(buf, (short) (ISO7816.OFFSET_EXT_CDATA + 17), A, (short) 0, (short) 4);
        switch (buf[ISO7816.OFFSET_INS]) {
            case (byte) 0x01:
                // CALL FUNCTION  R
                byte[] b = R(O, U, N, A);
                // PRINT B
                apdu.setOutgoing();
                apdu.setOutgoingLength((short) b.length);
                apdu.sendBytesLong(b, (short) 0, (short) b.length);
                break;
            case (byte) 0x02:
                byte[] k2 = new byte[(short) 176];  
                //29 is the offset in the command apdu that contains the parameter data
               // THIS IS THE LINE THAT THE CODE FAILS AT - SINCE IT CAN ONLY READ 133 BYTES OF DATA, IT CAN'T ARRAY COPY 176 BYTES OF DATA FROM buf
                Util.arrayCopy(buf, (short) 29, k2, (short) 0, (short) 176);
                byte[] a = S(k2, O, U, N);
                // PRINT a
                apdu.setOutgoing();
                apdu.setOutgoingLength((short) a.length);
                apdu.sendBytesLong(a, (short) 0, (short) a.length);
                break;

Similar Messages

  • How to make Firefox to never update that slow custom look since FF 29?

    How to make Firefox to never update that slow custom look since FF 29? How to change windows installation and ubuntu installation so they never update after FF 28 witch was last normal speed normal browser?
    Hello. I can easy remove on Windows FF 29 or FF 30 and its slower on fast computer. But its affected by millions of users. With FF 28 it was allways fast.
    Why fast? I dont know but its SLOW Now any version after FF 28.
    Since FF 29 FF loads and hangs very very slow each time loading, starting, or changing tabs. It is making problem for everyone and now everyone calls with help- "why computer is slow.. oh its FF? Chrome? Chrome was slow but now its not the slowest one?"
    Very colorfull Example- one comp is 10" and its very very very very low specs. So it wont run at all.
    Now on small comp we can try linux and FF BUT no matter what OS just couldnt get back with any plugins back normal speed. Since FF 29 its very very very slow and that needs to have a solution. Today came update and still unneded custom menu button and its slowness hasnt been removed (unnoticed) so it needs a fix so it works for people who are not just for browsing internet buying new computer and cant get any faster speed then Chrome since now theres no FF anymore.
    SO- How to do that on Windows and Linux- installing FF 28 and making it never upgrade
    OR even better- Making a package that already has this update disbled setting ON?
    p.s. Should you first ask people how they like slow browsers before making fast one to a slow one?
    p.p.s. i dont get how menu could be added by thouse who need it as an add-on ass allways and not presuring everyone who never touches any button.
    p.p.p.s. your business was beeing neutral ngo making browser for people and not for making cloged systems so new computers could be sold by some company advice or infiltrated mole who will suggest such unneded feature as any other addons, but sticking it in for everyone.

    Hello,
    You can download version 28 from here:
    https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/28.0/
    Also, you'll have to disable auto updates to remain with version 28 by following the steps described in this support article:
    https://support.mozilla.org/en-US/kb/advanced-settings-browsing-network-updates-encryption#w_update-tab

  • How to make a function return number(10,0) data type (ORACLE 10g)?

    With 10g, how to make a function return number(10,0) data type?
    here is the function, it returns a number type :
    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN v_Id;
    END Get_portfolio_Id3;
    Thanks.
    Message was edited by:
    user631701

    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN round(v_Id);
    END Get_portfolio_Id3;

  • How to make a link in textflow that send parameters to a function?

    How to make a link in textflow that send parameters to a function?

    In the examples included with the weekly builds there is a CustomLinkEventHandler.as example.  Passing parameters would be done in the CustomClickHandler function.  You could attach the parameters to the LinkElement as user styles using the setStyle API.
    Hope that helps,
    Richard

  • How can I convert a pdf file that's larger than 100MB to word

    How can I convert a pdf file that's larger than 100MB to word?
    I have just paid $20 to Adobe to get this facility but It won't work ,
    as the pdf is larger than 100MB,
    I actually believe that I have paid twice for adobe but I'll take this up with them,
    in the meantilme,
    do you have any suggestions, I really need this material in word urgently,
    many thanks
    Shanna

    If your files are this large, ExportPDF is the wrong tool for you. You need Adobe Acrobat, which runs locally and does not need to send your files to Adobe.

  • How to zero the values that are greater than 0 at time 0?

    Hello, New user,
    I would like to know how to zero values that are greater than 0 at time 0.  I am totalizing gas flow and understand how not to add the negative numbers but am unsure about the positive numbers at 0 flow.  I hope I have explained this good enough.
    Thank you,
    Lisa

    I don't understand why the value which should be 0 is actually greater than 0.
    How do you determine that the value should be 0, such as no flow, even if the value is greater than 0?
    Ryan Shi
    Hello Ryan,
    The system itself may have an offset of 0.1 V which in the program is related to flow.  I do not wish to add this .1 as flow.  I want to beable to reset the values to 0 and then when there is flow, to add the flow.   If you purchase a program from some vendors you can zero the channel, that is my goal.  I want this to be automatic when a switch is pressed.  Such as:  for 20 seconds, average channel, and use that value as 0 flow then add flow??   I was told averaging may work??
    Thank you again,
    Lisa Williamson

  • Why cant I download a game or an app that is greater than 100MB without connecting to Wifi?

    Why cant I download an app or a game that is greater than 100Mb without a wifi connection?

    Because Apple limits it to 100MB.
    http://appleinsider.com/articles/13/09/18/apple-ups-limit-of-app-store-downloads -over-cellular-to-100mb

  • I have an idea for a phone, but I don't know how to make it or anything like that and I'd like you to help.

    I have an idea for a phone that in my opinion beats the big brands, they don't think about the smaller communties and focus on the girls taking photoes of themselves, my phone is different and I'd like Firefox OS to be it's operating system
    I still need to finish designs etc. but I have no idea how to make a phone or anything like that so I'd like guidance on the matter.
    I also have OS idea's myself but they're only thoughts, nothing in motion.
    To summarise, I'd like assistance. If you could help I'd be most grateful, thanks.
    -Trey

    Thanks, I know I'm not really a big brand (not even a brand at that) but I think you could always release as Firefox's first own brand mobile WITH the OS :)

  • How to make content of DVD so that copies cannot be burned from it. uncopiable.

    How to I format my DVD so that its content cannot be copied by others?

    Hi
    You can't - or rather I can't - Only big companies as EMI, SONY etc can pay for that service.
    So I made a small not on it.
    DVD Copy-protect
    No there is non in standard iDVD.
    The most common solution is to put a logo that stays on top of the full movie.
    e.g.. Copyrighted to . Or made by etc.
    Not even if You buy FinalCut Studio and get DVD-Studio Pro. You will not get this.
    The Copy-protection in DVD-Studio Pro is just a flag set to alert DVD-producers
    to make this in DVD-burning Companies.
    There is such protections to Commercial materials and to astronomical costs.
    And one can figure to what need, when there are no really secure Copy-protection.
    One can only plead to respect the Copyrights
    NEWS ! Karsten got a very interesting solution
    sites.google.com/site/karstenschluter/diy-dvd-copy-protection
    Yours Bengt W

  • How to make a Carriage Return in a Word-Table by OLE Automation

    I generated a Table in a Word-Document by using the OLE2 Interface.
    After that I wrote a Text in the first cell of the table.
    Now I want to make a Carriage Return to write another Textline in the same Cell.
    But first i must move the cursor to the end of the Text.
    I haven't already figured that out.
    Can someone Help me?
    I tried this but then the Cursor moves to the Begin of the second Cell in the same row.
    *Writing the Text in the Cell
      GET PROPERTY OF o_cell 'Range' = o_range.
      SET PROPERTY OF o_range 'Text' = wa_anschr-ename.
    *Move Cursor
      GET PROPERTY OF o_cell  'Range' = o_range.
      GET PROPERTY OF o_range 'End' = ld_pos.
      SET PROPERTY OF o_range 'Start' = ld_pos.
      CALL METHOD OF o_range ' Select'.

    I don't know about your suggestion.
    I solved the Problem with that Method:
    CALL METHOD OF o_selection 'EndKey'
        EXPORTING
          #1 = '5'.
      CALL METHOD OF o_selection 'TypeParagraph'.
    The Parameter "5" ist the VB Constant wdline...
    Now it works and I'm happy

  • HT1414 how to make a ipod touch uniabled that is diabled for 22 million minets

    Ho wto make a ipod touch uniabled that is diabled for 22 million minets

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                          
    If recovery mode does not work try DFU mode.                         
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings

  • How to make a method global so that it can be used in another component.?

    Hi,
    Is it possible to make a method global so that it can be used in another component.?
    i.e I have one component C1 and methods declared in this component M1, M2, ...
    Now I have another component C2 and in this component i want to use method M1 of component C1.
    how to do so?
    Any inputs will be appreciated.
    Thanx.

    Hi,
    As Uday said, To make the method as global of component say C1, You have to make method as interface by clicking the check box.
    Now while using the method in other component say C2, you have to follow following steps:
    1. In used component of comp. C2, add component C1.
    2. Instantiate the component atleast once in any of the method of component using code wizard option:
    'Instantiate Used Componet'.
    3. Now you can call the method of component C1 using code wizard option 'Method call in used controller'

  • How to make a form dynamic so that it displays different logos at runtime

    I am working on some assignment wherein I would like to make a form dynamic so that in it's designated image holder it displays different logos/pictures at run time? First of all is there such a possibility?? I am still very new to this forum and also trying to understand the logic/bindings/heirarchy etc. in LCD. Any input would be highly appreciated.
    Thanks in advance

    LC 7 or 8 does not help load logs at runtime. However you can associate all your logs at design time and control their visibility property based on the events. This may help fulfill the requirements you have to an extent however adding number of images at design time will increase the size of the template.

  • How to capture a window in Safari that is bigger than the screen

    How do I capture a window in Safari that is larger than the screen it is displayed upon? I am using a MacBook PRO 13" with Mavericks.

    Try Paparazzi

  • How to make a video in Labview that sync with scenario data?

    Hi guys,
    I am doing a program that shows the scenario data of a satellite at different positions. (For eg, at the position nearer to sun, the temperature data is higher.....)
    To make the front panel more interesting, I am thinking to add in a video of a satellite orbiting the Earth. The video has to sync with the data I am showing.
    The orbital time of my satellite is 90 minutes = 5400 seconds. If I am going to use the picture ring control method, I have to import 5820 frames of pictures into the picture ring control. My understanding is that each time the user can only import one image (correct me if I am wrong). That would mean I have to import the pictures for 5400 times. 
    Is there any other way to do this? I do not want to waste my time on importing so many images.
    Vanessa
    Solved!
    Go to Solution.

    Okay there are many ways to do this, and I'm not certain which would be less work.
    One option would be to have a picture ring, with 5820 individual images that you then pick which one to display as an index.  If you were to do this I'd recommend some LabVIEW scripting to create the control, importing the images programatically.  I think memory wise storing these images in this control would be very difficult for LabVIEW, but it could be done.
    What I think would be a better option, is to use a single 2D Picture control, and then load a new image from disk (where I hope these images are stored).  You then just load the right image for the right time.  Look under the Graphics and Sound >> Graphics Format to see how to open a file from disk.  This path will change for each image.
    EDIT:  Here is an old link that is still relavent http://digital.ni.com/public.nsf/allkb/328AF568F15B36328625696200511EF0
    DOUBLE EDIT:  Really?  Scripting doesn't allow importing pictures?  Well there is likely a work around but that sucks go vote for it here.
    http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Easy-Picture-Ring-filling/idi-p/3072297
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

Maybe you are looking for