Is there ANYONE who have REAL knowelage with JAVA CARD OS?

It is serious problem. Same problem like this one:
http://forums.sun.com/thread.jspa?threadID=5344671&tstart=30
Anyway. Main problem is that if you want to use several times encryption using different key every time
soon or later card will BLOCK itself!!!
Well it will return code 6F00 and ONLY whole reprograming of card will help!!!
Here is simple code:
package com.cpit.javacard;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
import javacard.framework.Util;
import javacard.security.AESKey;
import javacard.security.DESKey;
import javacard.security.Key;
import javacard.security.KeyBuilder;
import javacard.security.MessageDigest;
import javacard.security.RSAPrivateCrtKey;
import javacardx.crypto.Cipher;
public class DES3a extends Applet
byte[] staticKey = {0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47};
byte[] inData ={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
byte[] outData ={(byte) 0xF1,(byte) 0xD7,(byte) 0x5E,(byte) 0x4F,(byte) 0x0D,(byte) 0x37,(byte) 0xC2,(byte) 0x2C,(byte) 0xB8,(byte) 0xD5,(byte) 0x4E,(byte) 0x62,(byte) 0x53,(byte) 0xBB,(byte) 0x40,(byte) 0xB1};
byte[] dummy = new byte[4024];
//constructor
private DES3a (byte bArray[], short bOffset, byte bLength)
register(bArray, (short) (bOffset + 1), bArray[bOffset]);
// install
public static void install(byte bArray[], short bOffset, byte bLength)
new DES3a (bArray, bOffset, bLength);
public void process(APDU apdu)
     byte[] buf = apdu.getBuffer();
     // Good practice: Return 9000 on SELECT
if (selectingApplet())
return;
if (buf[ISO7816.OFFSET_CLA] != (byte) (0xB0)) ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
if (buf[ISO7816.OFFSET_INS] != (byte) (0xAA)) ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
byte buffer[] = apdu.getBuffer();
Crypt_DES(apdu);
private void Crypt_DES(APDU apdu)
byte[] buffer = apdu.getBuffer();
for( short i = 0; i<(short)50; i++) {
generateSessionKey(inData, staticKey, buffer);
if (Util.arrayCompare(buffer,(short) 0, outData, (short)0x0, (short)16) != 0 ) break;
Util.arrayCopy(outData, (short)(0), buffer, (short)16, (short)16);
apdu.setOutgoing();
apdu.setOutgoingLength((byte) 0x30);
apdu.sendBytes((short) 0, (byte) 0x30);
     return;
     private void generateSessionKey(byte[] derivationData, byte[] staticKey,byte[] sessionKey){
          DESKey key = ( DESKey )KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_2KEY, false );
          key.setKey( staticKey, (short)0 );
          Cipher cipher = Cipher.getInstance( Cipher.ALG_DES_ECB_NOPAD, true );
          cipher.init( key, Cipher.MODE_ENCRYPT );
          cipher.doFinal(derivationData, (short)0, (short)16, sessionKey, (short)0);               
          key.clearKey();
It seems that problem is in KeyBuilder?! . Is this function allocates EEPROM??? how can be that memory
deallocated? Even worst is if it used TYPE_DES_TRANSIENT_DESELECT insead TYPE_DES!!!
In example from above in loop top value is 50. On some cards (depend on EEPROM size) it can be even
1000 ! but still it will crash on the end!
Also increasing size of "dummy" it will reduce number of DES runs.
Here is results:
cm> /select 11223344556677
=> 00 A4 04 00 07 11 22 33 44 55 66 77 00 ......"3DUfw.
(20215 usec)
<= 90 00 ..
Status: No Error
cm> send b0aa000000
=> B0 AA 00 00 00 .....
(14394373 usec)
<= F1 D7 5E 4F 0D 37 C2 2C B8 D5 4E 62 53 BB 40 B1 ..^O.7.,..NbS.@.
F1 D7 5E 4F 0D 37 C2 2C B8 D5 4E 62 53 BB 40 B1 ..^O.7.,..NbS.@.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90 00 ..
Status: No Error
cm> send b0aa000000
=> B0 AA 00 00 00 .....
(15024947 usec)
<= F1 D7 5E 4F 0D 37 C2 2C B8 D5 4E 62 53 BB 40 B1 ..^O.7.,..NbS.@.
F1 D7 5E 4F 0D 37 C2 2C B8 D5 4E 62 53 BB 40 B1 ..^O.7.,..NbS.@.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90 00 ..
Status: No Error
cm> send b0aa000000
=> B0 AA 00 00 00 .....
(15632306 usec)
<= F1 D7 5E 4F 0D 37 C2 2C B8 D5 4E 62 53 BB 40 B1 ..^O.7.,..NbS.@.
F1 D7 5E 4F 0D 37 C2 2C B8 D5 4E 62 53 BB 40 B1 ..^O.7.,..NbS.@.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90 00 ..
Status: No Error
cm> send b0aa000000
=> B0 AA 00 00 00 .....
(8572462 usec)
<= 6F 00 o.
Status: No precise diagnosis
As you can see that card (jcop41) can run correct less than 200 times!!!
On gemplus 64k it can run less than 1200 times!!!
So is there any method for dealocating EEPROM that is used by KeyBuilder?
Or to use RAM (Using TYPE_DES_TRANSIENT_DESELECT is even worst!)
That is problem with EEPROM here is proof:
On halted card when is application deleted it takes more time !!!
;HALTED CARD
cm> ext-auth plain
=> 84 82 00 00 10 B0 B9 D5 5A FC D3 BA 3F AE 85 CD ........Z...?...
9F 24 25 A5 04 .$%..
(123134 usec)
<= 90 00 ..
Status: No Error
cm> delete 11223344556677
=> 80 E4 00 00 09 4F 07 11 22 33 44 55 66 77 00 .....O.."3DUfw.
(3235735 usec)
<= 00 90 00 ...
Status: No Error
cm> delete 112233445566
=> 80 E4 00 00 08 4F 06 11 22 33 44 55 66 00 .....O.."3DUf.
(940978 usec)
<= 00 90 00 ...
Status: No Error
NORMAL CARD
cm> ext-auth plain
=> 84 82 00 00 10 96 4D 17 94 84 41 0B 03 62 BF AC ......M...A..b..
3D 72 41 E0 D4 =rA..
(67224 usec)
<= 90 00 ..
Status: No Error
cm> delete 11223344556677
=> 80 E4 00 00 09 4F 07 11 22 33 44 55 66 77 00 .....O.."3DUfw.
(930056 usec)
<= 00 90 00 ...
Status: No Error
cm> delete 112233445566
=> 80 E4 00 00 08 4F 06 11 22 33 44 55 66 00 .....O.."3DUf.
(946824 usec)
<= 00 90 00 ...
Status: No Error
As you can see 3235735 usec vs 930056 usec
Any help?
regards

Ok, thanks for hints & help, here is a tested working example:
static byte DES_flag = 0xa5;
DESKey key ;
Cipher cipher;
//constructor
// because I dont know how "install" handles functions i've use "selectingApplet"
if (selectingApplet())
if (DES_flag ==0xa5){
cipher = Cipher.getInstance( Cipher.ALG_DES_ECB_NOPAD, false );     //instead true!     
key = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES_TRANSIENT_DESELECT , KeyBuilder.LENGTH_DES3_2KEY, true );
DES_flag =0;
     return;
     private void generateSessionKey(byte[] derivationData, byte[] staticKey,byte[] sessionKey){
          key.setKey( staticKey, (short)0 );
          cipher.init( key, Cipher.MODE_ENCRYPT );
          cipher.doFinal(derivationData, (short)0, (short)16, sessionKey, (short)0);               
          key.clearKey();
Regards

Similar Messages

  • Is there anyone who has good experience with the E...

    I'm a current owner of E72 with a multitude of problems which i'm tired out talking about. Anyway, I'm thinking of upgrading to the E6, because of it's price in my country and also because i'm familiar with nokia phones' symbian platforms. Initially i did not want to buy any nokia products anymore, but I want to give it another go because of the mentioned reasons and also due to my E72 frustrating me every other day. In addition, my few other options are android touchphones and i really dislike full fleged touchphones, not to mention their battery life. My other option is the Blackberry which has no front facing camera which i need making video calls, so I'm really looking at the E6. I've read so many horror stories in this thread that i'm really worried that i'll get a lemon, so I want to read some positive stories or some judicious pros and cons, before taking the plunge! Please help thank you!
    Solved!
    Go to Solution.

    I have owned my E6 for over 3 months and after the weekends new firmware (025) the phone now is almost perfect.
    The audio quality for music is good and voice calls is the best that you can find, even in noizy environments.
    Battery endurance is very good now, perhaps 80-100 hours in moderate use.
    Also the former problem with backlight is now corrected by Nokia.
    After the firmware the phone is very fast, I mean this cincerely. Also it seems that connectivity over 3G or WLAN is 100% perfect now.
    The vibration is perhaps a little weak for men, but woman can feel it...I tested it various ways.... Nokia will solve this matter also.
    Forgotten things, that is really good is removable battery, hot-swoppable memory card and the the feeling of handling the phone.
    Not a single scratch or dust problem after 3 months...
    The RAM-memory seems to be enough for everything I am doing.
    The graphic and the 1GB ROM-memory certainly makes the Nokia E6 competent.
    The qwerty is really amazing and the screen also, after experimenting with font magnifier (using 119%) and the size in the web browsers and of course the phone settings for font size have actually made this E6 excellent. It took me some time to be satisfied with the settings, but I am now more than happy with mine.
    As said, the program RemindMe is useful for light indicators for sms/mms, emails and calls. That solve that issue to me and even if Nokia built-in will be better in the next firmware I stil wouldn´t quit the remindMe.
    Finally, the camera is also more than good, the lack of autofocus doesn´t disturb me at all. I never take photos of small documents with the camera.
    I have to say, just buy it after this latest firmware, and then add those applications that you need for productivity. The applications I use you can see here below.
    I uninstalled the F-secure firewall/antivirus that caused some strange behaviors in early august, especially when I connected to a server with the built-in filebrowser (webdav).
    PS Mine have never restarted and I can´t remember a hang. DS
    Nokia 808 again (delight Belle), Nokia E7 and X7 ( again, all on Delight Belle...after some time on Nokia Lumia 925 (retired), 1020 (not that great)and Lumia 820 (Replaced my router at home, great for internet sharing).., N9 The best device ever (use it as much as Lumia 1020), Nokia 700 (Sport Phone/My Love :-) ) Nokia 701, Nokia E6 (Should have a follow-up from Nokia among with larger screen, NFC, Autofocus), Lumia 800 (Retired After 6 weeks), -Sports Tracker-Nokia Internet Radio-Handy Safe-Skype-Bambuser-Screenshot app pro-fMobi-ComingNext-Manual TaskSwitcher-jagiTimer-Easy StopWatch-Boldbeast-Equalizer-Financial Calculator-WiMP Music-YTasks-Davi-Thumbnail Folders-BizCalendar-Tiny7-Situations-nn reeder-Sport Timer-CameraLover-CameraPro-GrabRadio-LiveScore-Poddi-Gravity-SkyFilesPro

  • Is there anyone who has wifi issues with iOS 5.01?

    Wifi is not connecting properly with its 5.01 ? Is there a solution?

    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    Also try this - Turn Off your iPad. Then turn Off the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
     Cheers, Tom

  • NOKIA 6288!! IS THERE ANYONE WHO CAN HELP ME WITH ...

    Hey, I have a Nokia 6288 phone and I just don't know why it won't let me use email and instant messaging. Is it because I am with Virgin Mobile? Or do I need some sort of settings? Please help me, I will be forever geatful if you do!
    Love,
    Vicki

    You must have a valid email as your apple user name.   Log on to iTunes on the computer and fix your information in the account info.
    Then you can fix the accounts on the device.
    http://support.apple.com/kb/HT2204
    http://support.apple.com/kb/HT5621

  • Is there anyone who can help me with my question about icloud..

    keeps asking for old password, which I can't get because the email account has been deleted, and I can't delete the icloud account, because 'find my phone is on'.....

    You must have a valid email as your apple user name.   Log on to iTunes on the computer and fix your information in the account info.
    Then you can fix the accounts on the device.
    http://support.apple.com/kb/HT2204
    http://support.apple.com/kb/HT5621

  • Is there anyone who doesn't have any problem with Z3 ?

    I'm thinking to buy this phone, so I want to know is there anyone who has no problems with it, because in this and other forums, I find a lot of discouraged people who have a wide variety of problems.
    Thanks a lot

    uliwooly wrote:
    Think about it, this is a Support forum. users who have issues come looking for help, it doesn't mean that the majority have issues. 
    I understand what you're saying, but this is my dilemma:
    I currently have sony Xperia Z1 compact which is full of small problems.
    -back panel rattle when I touch it near camera lens
    -a big gap between the panels and the frame
    -camera freeze and need to restart the phone very often
    -calendar widget does not eject notification and birthdays...
    I was looking for a solution to these problems on the forum for the Z1 compact, but so far I have not solved a single.
    Such problems I have never had on my samsung phones. Still, I'm determined to buy a Z3 because of the design and premium materials, but if I compare it with My Z1 Compact, I'm a little scared.

  • I have a problem with mail.  the spelling and grammer check box before sending the messege is no longer there.  I did everything but cannot get it back.  is ther anyone who knows how to get the box with spelling and grammer checks before sending

    i have a problem with mail.  the spelling and grammer check box before sending the messege is no longer there.  I did everything but cannot get it back.  is ther anyone who knows how to get the box with spelling and grammer checks before sending the mail.
    Also the mail is acting very funny by not getting the rules work in a proper method.  Is ther a software to repair mail.

    i did both of them, but still the while sending the mail the diolog box is not showing up and also the spelling and grammer does not do the spelling check. 
    This problem just started for about 3 to 4 days now.  earlier it was working normally.

  • Is there anyone who is not having a problem with their Fascinate?

    Just ordered the Fascinate for a penny from Amazon. Looks like that's all it's worth! LOL. Is there anyone who has not had problems with this phone! I have not received mine yet, maybe I'll be one of the lucky ones.
    Should I do the update or stick with 2.1? Do I have a choice?

    2.2.1 is Froyo. The phone originally shipped with 2.1 Eclair. What is your Build number? I'm assuming it is not the ED04 (which you should avoid at all costs) since you were prompted to update.
    Edit: Also, I don't know if it works the same way on the Fascinate, but on the Droid X (running unrooted stock software) you could only postpone the update for a certain period of time and then it would force the update without your approval. Broke a lot of people's X's that were previously running fine. Hope that doesn't happen to you but just letting you know it's possible.

  • I have installed ios7 on my iPad 4. After installation it asked me pass code which I have never set. After multiple attempts it is disabled. I don't have backup on my iCloud or iTunes. Is there anyone who can help to enable it or to reverse iPad to ios6.

    I have installed ios7 on my iPad 4. After installation it asked me a pass code which I have never set. After multiple attempts it is disabled. I don't have backup on my iCloud or iTunes. Is there anyone who can help to enable it or to reverse iPad to ios6. I asked Apple store & tech said to format it but I will lose all the data..!

    Thanks for that. Much more constructive than the last comment. It's only the restriction code I can't recall, not the access passcode. So I can currently access the device, just not age restricted content. Does that's make a difference? I also wondered if anyone knew how many attempts you get to try to get it right. Now tried 21 times and so far nothing bad has happened but I am concerned I'll eventually be completely locked out of the device. That doesn't seem in the spirit of things though. Surely it's foreseeable that a child could repeatedly try to guess the code so I can't see that it would be right to lock the device down completely in that circumstance, particularly if the access code is being typed in correctly every time.
    Thanks

  • I have a problem, i can't change my lockscreen wallpaper after i upgrade my iphone 4s to ios 5.1.1... Is there anyone who can help me?

    I have a problem, i can't change my lockscreen wallpaper? Doesnt work...is there anyone who can help me regarding this problem? Thx

    To help, we need more detailed information.
    --What steps are you trying?
    --What does the device tell you (any pop-ups or messages)?
    --Are you able to change the Home screen wallpaper, or is that affected too?
    --Are you the phone's owner/administrator, or is this a device used for work (assigned/administered by IT staff, possible on an Exchange server)?
    --Have you jailbroken the device?

  • TS2755 I have an iphone 3gs. I recently got unlimited texting added to my att plan. I can attach images to anyone who has an iPhone with os 5 (imessaging)). Why can't I attach images to people who I text non-imessage?

    I have an iphone 3gs. I recently got unlimited texting added to my att plan. I can attach images to anyone who has an iPhone with os 5 (imessaging)). Why can't I attach images to people who I text non-imessage?

    Your carrier determines what you can send in a text message, Apple has no control over it as SMS and MMS are completely carrier-based

  • Hey. I can not sync my iphone with my macbook air. It will not download my purchased music. Writes that there was an unknown error (-42408). Is there anyone who can help me.  Sincerely jimmi

    Hey. I can not sync my iphone with my macbook air. It will not download my purchased music. Writes that there was an unknown error (-42408). Is there anyone who can help me.
    Sincerely jimmi

    Hey joshuafromisr,
    If you resintall iTunes, it should fix the issue. The following document will go over how to remove iTunes fully and then reinstall. Depending on what version of Windows you're running you'll either follow the directions here:
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    http://support.apple.com/kb/HT1925
    or here:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    Best,
    David

  • How to make Internet commerce with the MacBook Pro in the program iWeb. I've made since and would like to make it possible to pick the next act with debit cards. Is there anyone who can help?

    How do I make Internet commerce with the MacBook Pro in the program iWeb. I've made the website and would like to ad a site where it possible to commerce with debit cards. Is there anyone who can help?

    Some info on this and the following two pages...
    http://www.iwebformusicians.com/Internet-Music-Sell-Distribute/Website-Buy-Page. html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • Is there anyone who has used Freescale's SimpleSUB.dll and DEMOJM board?

    Hello,
    I am trying to connect Frescale DEMOJM board over USB connection. I am adding SimpleUSB.dll to my visual instrument thorough .NET constructor node and giving an mscorlib class GUID to the GUID property, than calling OpenConnection method from an invoke node referencing the SimpleUSB reference. But there is no valid connection to the device as DeviceConnected parameter return "False". 
    I am using LabVIEW 8.6 trial, .NET Framework 3.5. So they are up to date I guess. Is there a limitation of these for using .NET dll? And also I can use the dll in Visual C# successfully.
    At first there was another problem using the .NET constructor node in LabVIEW because of Vista OS.  The vi was blocking when i added the node to the vi. I changed the "language & regional settings" to English(USA). The problem seemed to be solved. Can Vista's bug be still a problem?
    Is there anyone who  has used Freescale's SimpleUSB.dll and DEMOJM board with LabVIEW?
    I will be thankfull for your helps.
    Emre

    Hello Anna,
    Here is one of my poor vi trials.   I have also tried putting some conditionals in some other files but it didn't helped.
    http://rapidshare.com/files/176194859/EXTDLL1.rar.html
    Here is a link for the Freescale's DEMOJM board. It shows how to make a GUI for the board using SimpleUSB.dll & C#.  You can also download the dll from that web page and there is helpfull documentation for the dll.
    http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=USBJM_TRAINING&nodeId=016246fNrgVJ4Cx...
    I am trying to make the same thing with Labview instead of C#. But I am not familiar with the SW issues so am in trouble.
    Thanks,
    Emre

  • Is there anyone who can help me to design a index page

    Hi guys
    I would like to design a index page like this site :
    http://www.hostplate.com
    Is there anyone who can help me ?

    Your example site is built with WordPress (a popular open source framework).
    You'll need to have a good working knowledge of HTML, CSS and some familiarity with PHP code & the ability to set-up a MySql database on your server.  The good news is that there is a wealth of on-line information available to you.
    HTML, CSS, PHP Tutorials - http://w3schools.com/
    Getting Started with WordPress - http://codex.wordpress.org/Getting_Started_with_WordPress
    If all this is outside your comfort zone and you're prepared to hire an experienced web developer to help you,
    feel free to contact me through my web site:  http://alt-web.com
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

Maybe you are looking for

  • Discount Issue

    Hello Experts, System controls discount level based on Sales Person ID.  Each Sales Person, depending on seniority, will be allowed to offer discount up to a predetermined percentage.  Sysem will blocked any attempt to offer beyond set limit.  E.g. i

  • Waveform chart auto clear

    Hello, I am doing data acquisition with labview and showing it on a waveform chart.  I wish to generate an excel file with two columns : time and amplitude automatically after the vi finishs. But everytime I start a new acquisition, the x-axis (time-

  • Boot vol icon "movement"

    first my configuration: ibook g4, 14-inch, 1.42 ghz ppc, 1.5gb, os 10.5.8 everything runs well. the problem is that when i move the boot volume icon anywhere around the desktop (just rearrangement) it will NOT stay in the location where i put it!!! g

  • ALPHA Conversion Exit Problem

    Hi, I have an InfoObject ZPRODUCT1 with ALPHA Conversion Exit in RSD1 definition.In the Infosource and in the DataSource/Trans. Structure TAB when i check for the corresponding field it has some other Conversion exit called 'PRID1' and i couldn't cha

  • ALV  for user selection

    Hi all,           Can anyone help me  how can i get the ALV with check boxes when user selects particular records and selection process further will happen for that records. Thanks in advance,