Multiple calls of sendBytes+cipher.update are "very slowly"

Hi all,
My applet encrypts own data and returns them within the APDU response. For encryption Im using the AES 128bit CBC without padding. Because my data stored in EEPROM are too large I encrypt them in parts to APDU buffer and then send these parts by sendBytes method.
I found very interesting thing:
I call multiple cipher.update followed by sendBytes method in the loop until all data are encrypted and sent. My response is very very late.
Here are single cases and time duration for them. Please dont think about these unused cases.
They was written to simulate my problem and for time measurement.
byte[] data = new byte[4096];//created in applet constructor
*1.test case*
cipher.update(data, (short) 0, (short) 1440, apdu.getBuffer(), (short) 0);
apdu.sendBytes((short) 0, (short) 1440);
cipher.update(data, (short) 1440, (short) 1440, apdu.getBuffer(), (short) 0);
apdu.sendBytes((short) 0, (short) 1440);
cipher.update(data, (short) 2880, (short) 1200, apdu.getBuffer(), (short) 0);
apdu.sendBytes((short) 0, (short) 1200);
cipher.update(data, (short) 4080, (short) 16, apdu.getBuffer(), (short) 0);
apdu.sendBytes((short) 0, (short) 16);
Time duration: 5.126s
*2.test case*
cipher.update(data, (short) 0, (short) 1440, apdu.getBuffer(), (short) 0);          
cipher.update(data, (short) 1440, (short) 1440, apdu.getBuffer(), (short) 0);
cipher.update(data, (short) 2880, (short) 1200, apdu.getBuffer(), (short) 0);          
cipher.update(data, (short) 4080, (short) 16, apdu.getBuffer(), (short) 0);
apdu.sendBytes((short) 0, (short) 1440);
apdu.sendBytes((short) 0, (short) 1440);
apdu.sendBytes((short) 0, (short) 1200);
apdu.sendBytes((short) 0, (short) 16);
Time duration: 1.278s
*3.test case (just encryption)*
cipher.update(data, (short) 0, (short) 1440, apdu.getBuffer(), (short) 0);          
cipher.update(data, (short) 1440, (short) 1440, apdu.getBuffer(), (short) 0);
cipher.update(data, (short) 2880, (short) 1200, apdu.getBuffer(), (short) 0);          
cipher.update(data, (short) 4080, (short) 16, apdu.getBuffer(), (short) 0);
Time duration: 1.132s
*4.test case (just send dummy data from APDU buffer)*
apdu.sendBytes((short) 0, (short) 1440);
apdu.sendBytes((short) 0, (short) 1440);
apdu.sendBytes((short) 0, (short) 1200);
apdu.sendBytes((short) 0, (short) 16);
Time duration: 0.224s
Can somebody explain me what could rapidly reduce a speed of operation in case 1? Any ideas?
thanks

An observation: in the slow case, encryption can be concurrent with data transmissionWhy are these two operations concurrent? They should be synchronized or not?In the first example, but not the second, it could conceivably be that the second <tt>cipher.update</tt> is concurrent with the first <tt>apdu.sendBytes</tt> (that is: occurs simultaneously; <tt>apdu.sendBytes</tt> schedules a transfers that could occur later, while <tt>cipher.update</tt> runs). Never seen this, but that could be, especially if there is some intelligent device (e.g. NFC mobile phone) in-between the card and reader.What I know, the JCOP version I'm using doesn't support multithreading.
What is the communication context/chain ? ISO 7816-3, T=0 or 1, f=, F/D= ? Straight ISO 14443-4, type = A or B, parameters like ATQB and ATTRIB, or analog for type A ? SWP + what ?Sorry, I'm newbie in JavaCard, so I don't know detail information about protocols I use in my case. (..)
What I know is that T=1, (..)
My reader is OmniKey 5321, last driver 1.2.9.2 for Win7. That reader is both contact and contactless. Which one is in use ?
If you use contacts, the protocol could be ISO 7816-3, T=1. If you use contactless, the protocol is most likely ISO 14443-4, even though T=1 appears in the (simulated) ATR that you obtain from the (PCSC interface of) the reader.
By "chain" I mean the various things linked between your code and the card. E.g. assuming the card is a straight contactless card (not a mobile phone) and you use Oracle's Java (1.)6 or later, most likely: card <-> OmniKey 5321 <-> it's driver <-> PCSC aka winscard <-> JVM <-> javax.smartcardio. Complications occurs with mobile phones.I use contactless mode. For connection I'm using either SSComm tool from NXP or javax.smartcardio, so your chain above is good.
Have you looked for retries ? Waiting time extension ?Maybe you mean APDU.waitExtension(). Am i right? I've tried to call this after sendBytes but without success.I was asking if you investigated if there are communication retries by the reader, and waiting time extension requests sent by the card to the reader, which are some of the likely causes of the slowdown (the answer is clearly: you so far used no tool allowing you to check that).No, I didn't check if some retries exist. Does exist some tool for such purpose?
If not, at least: is the timing in the slow case consistent from one experiment to the other ? When card/device is moved at a different position from the reader, if applicable ?I dont't understand the term consistent timing.Consistent = repeatable from one experiment to another, including moving the card at a slightly different position/height from the reader (assumed contactless). If the timing was very variable, that would suggest random errors and a retry mechanism.The time are very similar also for different height from the reader. Differences are cca +-10%.
thanks

Similar Messages

  • Why when I open multiple tabs in Facebook, the tabs load very slowly and most times don't load at all?

    Why when I open multiple tabs in Facebook, the tabs load very slowly and most times don't load at all?

    The default of the pref network.http.max-connections has been increased from 30 to 256 in Firefox 6+ versions.
    You can try to decrease the value of the pref <b>network.http.max-connections</b> from 255 to a more modest setting like 30 as used in Firefox 3 versions.
    *https://support.mozilla.com/kb/Firefox+never+finishes+loading+certain+websites

  • IPhoto 6.06 Update running very slowly

    I updated my iPhoto to the latest version and now it is running very slowly. Imports of 20 photos take in excess of 1/2 hour. I'm also using backup and I noticed that my iLife backup is also running very slowly since my update of iPhoto. I also noticed that when I browse my photos, the latest photos imported show up as dashed lines with titles, but no photos. If I double click the dashed outline, my photo shows up in single browse mode. Does anyone have any suggestions? Is there a way to revert back to the older version and still save my photos? Thanks in advance for any insight.

    Steve:
    The gray background with dotted lines are due to iPhoto losing the link to the large files. Try rebuilding the library as follows: launch iPhoto with the Command+Option keys depressed and follow the instructions to rebuild the library. Select the first three option.
    Also download and run BatChmod on the iPhoto Library folder with the settings shown here, putting your administartive name in the owner and group sections. You can either type in the path to the folder or just drag the folder into that field.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • When I add a while loop to the vi "niScope EX Multi-Device Configured Acquisition (TClk)" to acquire data for multiple times, it works but it runs very slowly.

    Because I want to acquire the similar data for multiple times and then take an average to increase SNR, I add a while loop to the vi "niScope EX Multi-Device Configured Acquisition (TClk)".  It works but it runs very slowly (about 1 sec for each iteration). I think I had put the while loop at a wrong position, which makes the vi run from the very beginning in each iteration. So I really want to know where should I put the while loop to improve the speed? I have attached all the vi and subvi.
    Thanks very much.
    Attachments:
    Multi-Device External Clocking (TClk).vi ‏1166 KB
    avgWfm.vi ‏15 KB

    Dear Zainykhas,
    Thank you for posting this to the discussion forums and for uploading some sample code.  I took a lok at the issue you have been having, and it is unclear to me as to why you have placed two for loops around the original while loop.  My understanding is that you want to use the original Sample.vi and want to execute this N times where N is the Max Freq divided by Interval so that you can scan for a range of frequencies.
    Why not just put Sample.vi around one for loop and use the increment counter scaled by the interval to count up towards Max Freq and insert the desired Frequency into the cluster using Bundle By Name?
    Kind Regards,
    Robert Ward
    Applications Engineer, NI
    Attachments:
    Modified - RW.vi ‏48 KB

  • Software Update Runs VERY slowly

    Hi folks
    I have several intel iMac's running 10.6.2 that take an eternity to update themselves from our local SUS server. Everything seems to be lagged quite noticeably. It takes 30 seconds or so from the time you run Software Update to get the progress bar coming up. Any updates seemingly download a chunk at the usual speeds you'd expect from a local SUS server, pause for a while, download some more, etc. The whole process can take 30+ minutes which just isn't right for a local SUS.
    Browsing the logs, I can see the following:
    2010-01-19 17:10:32.046 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enautoupdate.pkg
    2010-01-19 17:10:32.047 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enclipart.pkg
    2010-01-19 17:10:32.047 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008encore.pkg
    2010-01-19 17:10:32.048 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enequationeditor.pkg
    2010-01-19 17:10:32.049 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enerrorreporting.pkg
    2010-01-19 17:10:32.050 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enexcel.pkg
    2010-01-19 17:10:32.050 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_excel_helpstd.pkg
    2010-01-19 17:10:32.051 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enfonts.pkg
    2010-01-19 17:10:32.052 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008engraph.pkg
    2010-01-19 17:10:32.053 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enhelpviewer.pkg
    2010-01-19 17:10:32.053 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enlaunch.pkg
    2010-01-19 17:10:32.054 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enooxml.pkg
    2010-01-19 17:10:32.055 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enorgchart.pkg
    2010-01-19 17:10:32.055 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enpowerpoint.pkg
    2010-01-19 17:10:32.056 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_powerpoint_helpstd.pkg
    2010-01-19 17:10:32.057 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingbrazilian.pkg
    2010-01-19 17:10:32.058 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingdanish.pkg
    2010-01-19 17:10:32.058 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingdutch.pkg
    2010-01-19 17:10:32.059 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingenglish.pkg
    2010-01-19 17:10:32.060 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingfinnish.pkg
    2010-01-19 17:10:32.060 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingfrench.pkg
    2010-01-19 17:10:32.061 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofinggerman.pkg
    2010-01-19 17:10:32.062 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingitalian.pkg
    2010-01-19 17:10:32.063 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingjapanese.pkg
    2010-01-19 17:10:32.063 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingnorwegian.pkg
    2010-01-19 17:10:32.064 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingportuguese.pkg
    2010-01-19 17:10:32.065 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingspanish.pkg
    2010-01-19 17:10:32.066 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008en_proofingswedish.pkg
    2010-01-19 17:10:32.067 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008enrequired.pkg
    2010-01-19 17:10:32.067 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008ensilverlight.pkg
    2010-01-19 17:10:32.068 softwareupdate[293:4303] PackageKit: * Missing bundle identifier: /Library/Receipts/Office2008ensounds.pkg
    I'm told this is no big deal, but the following may be of more interest:
    Jan 19 16:44:47 hostname installd[252]: Starting
    Jan 19 16:44:47 hostname installd[252]: uid=0, euid=0
    Jan 19 16:44:53 hostname com.apple.launchd[1] (com.apple.suhelperd[232]): Exited with exit code: 2
    suhelperd sounds like something related to Software Update. What does this mean exactly and how can it be fixed?
    TIA

    Hello, see how many of these you can answer...
    See if the Disk is issuing any S.M.A.R.T errors in Disk Utility...
    http://support.apple.com/kb/PH7029
    Open Activity Monitor in Applications>Utilities, select All Processes & sort on CPU%, any indications there?
    How much RAM & free space do you have also, click on the Memory & Disk Usage Tabs.
    Open Console in Utilities & see if there are any clues or repeating messages when this happens.
    In the Memory tab of Activity Monitor, are there a lot of Pageouts?

  • Support problem. The adviser tried to diagnose the failure of an application called JOTNOT PRO to update. He said he'd phone back at 8pm. I pick up his call at 8pm. Electronic voice: thank you for calling apple. We are now closed" So now I have 2 problems

    Support problem. The adviser tried to diagnose the failure of an application called JOTNOT PRO to update. He said he'd phone back at 8pm. I pick up his call at 8pm. Electronic voice: thank you for calling apple. We are now closed" So now I have 2 problems: the adviser had got me to reset so bye bye wifi passwords and settings. And then when he phones back as we agreed he's not actually on the phone, it's just a voice saying Apple Support is now closed! What on earth is going on at apple support I wonder.
    Anyway, the original problem: an application called JotNot Pro fails to update. The error message says something like "you cannot update this cos either you bought it with a different Apple ID or somebody else bought it."
    Neither applies. Can anybody help?
    PS. This is my first approach to the support community so please bear with me!
    William

    You might have better luck contacting the app's support or developers.

  • When playing my ipod on an ipod dock the vocals are very faint. It is fine when doing through the headphones. I am trying to sync for updates and getting the message "An unknown error occured (-1)" - help

    When playing my ipod on an ipod dock the vocals are very faint. It is fine when doing through the headphones. I am trying to sync for updates and getting the message "An unknown error occured (-1)" - help

    Error -1
    Attempt to restore your iOS device two more times. If the issue is still unresolved, the device may need service.
    The "device may need service" means a hardware problem. In that case make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar
    Also see:
    -1 error
    -1 error too

  • HT1444 The update vs. upgrade paths are very confusing. I'm running OS X v10.5.8. What upgrade products do I need in order to become current?

    The update vs. upgrade paths are very confusing. I'm running OS X v10.5.8 and trying to figure out what versions I need to purchase/download in order to become current.
    Thank you!

    Phone the Apple Store, order a Mac OS X 10.6 DVD, and run Software Update. If your Mac supports it, buy 10.7 or 10.8 from the Mac App Store.
    (70024)

  • Multiple call of update function module

    Hi Everybody,
    I have made implementation to the definition MB_DOCUMENT_BADI( material Document creation).
    While executing this BADI I am getting short dum with this error  Multiple call of update function module.
    Here is the short dump--
    In the FORM routine Buchen_Ausfuehren (program SAPMM07M), an error
    message was issued by a Business Add-In (BAdI) or function module.
    This is not permitted, because it could lead to data             
    inconsistencies. For this reason, the update of the material     
    document was also terminated with a termination message (dump).  
    Note that this message (M7 372) is not the responsible error     
    message.                                                         
    Please any body suggest the way forward.
    Regards,
    Sandeep.

    Hi Kiran,
    Thanks for the reply.
    I have created one implementation to the BADI MB_DOCUMENT_BADI. This badi will hit while creation of material document.I have write the code in method MB_DOCUMENT_BEFORE_UPDATE such that it will act only for certain movement types specially for t-codeMb1a and MB31.
    What problem I am facing i have used a error message "MB_DOCUMENT_BEFORE_UPDATE" in this method.If we got the erroe message then we dont need to post the material dcoument,but here problem is that if the material document could not posted then it corrupt the material and when we performing 261/101 we got error message like " Inconsistency between MM and ML for material and plant"
    I have used following things like-
    1-while updating the customized table using " Commit Work".
    2-Call function vb_change_batch for updating the batch and not in update task.
    3. Dequeue the table after updating the table.
    Will thos things can create any inconsistency to  the MM and ML.
    Please suggest me uor thoughts.
    Thanks
    sandeep.
    Thanks ,
    sandeep.

  • How to update multiple calling hours based on business partner

    Hi All,
    please help me in this issue : how to update multiple calling hours based on business partner in SAP CRM.
    Regards,
    Siva kumar.

    Check maintainance view V_TB49, add new scheduling type.

  • How do I answer calls with the KITKAT update?  I hit the flashing button but it's still ringing?  Where are the Answer settings?

    How do I answer calls with the KITKAT update?  I hit the flashing button but it's still ringing?  Where are the Answer settings?

    Aha!  Thank you!!!  That was not obvious. Sometimes I don't get the green and red icons.  So it's slide it to the right for answering and slide to the left for voice mail.

  • After updating mini ipad to ios7 the sounds are very bad. Kind of distortion. Any idea?

    After updating mini ipad to ios7 the sounds are very bad. Kind of distortion. Any idea?

    Found it myself.
    Restore settings + restart device fixes the problem.

  • Adobe acrobat tool bar, windows and icons are very big after latest update

    im having a problem with the latest update of acrobat pro, the tool bar, windows and icons are very big after latest update. how to re size it???
    https://www.dropbox.com/sh/pbd33n1q2wirpq3/AABHjSRXo-crpYGVLaOrB2FVa

    Please check the doc : Hi DPI, Retina display support | Acrobat, Reader

  • After upgrading the iOS on my iPad2, it is running very slowly.  Screen taps are not responding very quickly and sometimes take multiple taps to initiate an action.  Should I have NOT upgraded, or is iOS 8.0 just awful?

    After upgrading to iOS 8.0 on my iPad 2, it is running very slowly and doesn't always respond to screen taps.  Is OS8 the problem?

    You aren't running a Classic operating system.    See this tip on the correct place to post:
    http://discussions.apple.com/docs/DOC-2463

  • Need to reduce no of calling same  function  in update statment

      update tab1 set
        col1  =  FN1(a),
        col2  =  FN2(a),
        col3  =  FN3( FN1(a), FN2(a) , c )
    here  FN1 and FN2 is called two time .. or only once ,, ??
    if 2 time then how to make it once call only ...
    can we change it like this
         update tab1 set
        col1  =  FN1(a),
        col2  =  FN2(a),
        col3  =  FN3( col1  , col2   , c )
    both r same or differnt ..??Edited by: user12108669 on Dec 11, 2009 4:31 AM

    Hi,
    Those are very good questions.
    Riedelme has told you who is the best person to answer thiose questions: you.
    To see how ofte a function is called, you can have it display something (using dmbs_output) or increment a sequence, package variable or SYS_CONTEXT attribute.
    CREATE TABLE tab1
    (        a      NUMBER
    ,        col1    NUMBER
    ,            col2      NUMBER
    ,      col3      NUMBER
    ,      c      NUMBER
    INSERT INTO tab1 (a) VALUES (1);
    INSERT INTO tab1 (a) VALUES (2);
    INSERT INTO tab1 (a) VALUES (3);
    CREATE SEQUENCE      fn1_seq    START WITH 1;
    CREATE SEQUENCE      fn2_seq    START WITH 1001;
    CREATE OR REPLACE FUNCTION      fn1
    (      in_num       IN        NUMBER
    RETURN NUMBER
    IS
         seq_val     NUMBER;
    BEGIN
         SELECT  fn1_seq.NEXTVAL
         INTO     seq_val
         FROM     dual;
         RETURN     seq_val;
    END     fn1;
    SHOW ERRORS
    CREATE OR REPLACE FUNCTION     fn2
    (      in_num       IN        NUMBER
    RETURN NUMBER
    IS
         seq_val     NUMBER;
    BEGIN
         SELECT  fn2_seq.NEXTVAL
         INTO     seq_val
         FROM     dual;
         RETURN     seq_val;
    END     fn2;
    SHOW ERRORS
    CREATE OR REPLACE FUNCTION     fn3
    (      in_x       NUMBER
    ,      in_y       NUMBER
    ,      in_z       NUMBER
    RETURN     NUMBER
    IS
    BEGIN
         RETURN  in_x + in_y;
    END     fn3;
    SHOW ERRORSTo avoid calling the functions repeatedly, you can use MERGE instead of UPDATE, like this:
    MERGE INTO  tab1    dst
    USING  (
           SELECT  a
           ,       fn1 (a)     AS fn1_a
           ,       fn2 (1)     AS fn2_a
           ,       c
           FROM    tab1
           )         src
    ON     (src.a         = dst.a)
    WHEN MATCHED THEN UPDATE
    SET  dst.col1       = src.fn1_a
    ,    dst.col2       = src.fn2_a
    ,    dst.col3       = fn3 (src.fn1_a, src.fn2_a, src.c)
    SELECT       *
    FROM       tab1
    ORDER BY  a;Output:
    .        A       COL1       COL2       COL3          C
             1          1       1001       1002
             2          2       1002       1004
             3          3       1003       1006

Maybe you are looking for