FAQ Database Discussion Community


JavaCard applet emulating DESFireEV1

smartcard,javacard,mifare,emulation
My question is simple: is there any existing opensource JavaCard applet emulating the functionality of Mifare DESFireEV1? (the API would have to be a little modified, of course, Select Application 112233 would be for example 80 5A 00 00 03 33 22 11 00 instead of native DESFire command 5A...

What does this default applets do?

smartcard,javacard,globalplatform
This is output of gp tool, when I tell it to list installed applets : gp >> gp -l AID: A000000151000000 (|....Q...|) ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management AID: A0000001515350 (|....QSP|) ExM LOADED: (none) A000000151535041 (|....QSPA|) gp >> Q1: Which one of this...

What is the reaction of JCRE to uploading an applet with promiscuous AID?

smartcard,javacard,globalplatform
As we know the AID of applets mus have a length between 5 and 16 bytes. And in case of applet that they have a promiscuous length (greater than 16 byte or less than 5 bytes), the Converter doesn't works. But this is the Off-Card verifier. I want to see...

-debug flag for converter

debugging,netbeans,javacard
I'm using NetBeans with JavaCard plugin installed to write and test my applets. The problem is that I need to have a debug component to be included into the resulting .cap file. I know that there is a converter option -debug, which does exactly what I need, but I cant...

An applet without any package, and a package without any applet

smartcard,javacard,globalplatform
This is contents of my smart card : C:\Users\ghasemi.IT\Downloads>gp -list AID: A000000003000000 (|........|) ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management AID: 6D797061636B616731 (|mypackag1|) Exe LOADED: (none) Q1: Why the package with AID: 6D797061636B616731 doesn't have any applet? Can I conclude that it is a...

Object Deletion Management in javacards

javacard
Below, You see a part of Application Programming Notes Java Card 3 Platform Classic Edition about object deletion management : void updateBuffer(byte requiredSize) { try { if(buffer != null && buffer.length == requiredSize) { //we already have a buffer of required size return; } JCSystem.beginTransaction(); byte[] oldBuffer = buffer; buffer...

Trying Java Card Application On real smart card

javacard,apdu
I will write an application for smart card with using Java Card Framework.When I finished my application I want to set up to a real smart card and try it.Which equipment I must have?How can I run my codes on a real smart card?I have to provide a connector between...

How to send “install” method arguments to the card reader using “process” method?

java,javacard
I wrote an applet for my java card and I want to send the arguments of install method to the CAD. so I defined two static variables named theArray and arrayLength in my applet. And after that I made a copy of the install method arguments inside the body of...

Why am I unable to find my desired environment variable functionality on Win7?

javacard
And, in the path section I have: C:\ProgramData\Oracle\Java\javapath; C:\Program Files (x86)\Intel\iCLS Client\; C:\Program Files\Intel\iCLS Client\; %SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem; C:\Program Files\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files\Intel\Intel(R) Management Engine Components\IPT; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT; C:\Program Files (x86)\Skype\Phone\; C:\Program...

How much memory does this card really have? (EEPROM and ObjectDeletion game!)

javacard,jcop
I wrote a simple program to check requestObjectDeletion() method functionality and my card's available memory. My applet respond to five different kind of APDU commands as follow : SELECT APDU command : Response : 0X9000 Command : XX 00 XX XX XX [...] Response : Return available memory in byte....

SELECT APDU doesn't work fine

java,javacard
I create a package(AID=0102030405) with two applets inside. This is the program of first applet (AID=01020304050202020202) that store contents of bArray to a static filed and returns it in process method : package processMethodArguments; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISOException; import javacard.framework.Util; public class ArgumentReturner extends Applet { //this is...

Two OwnerPIN object in Java Card

security,smartcard,javacard,apdu,pin-code
I am working on a Java Card application where our requirement is to keep some static data and balance in the card. For security I was thinking to make 2 object of OwnerPIN. One object is for terminal authentication (i.e. the terminal needs to send 8 bytes of data to...

Extended APDUs and T=0/1 communication protocols

smartcard,javacard,smartcard-reader,globalplatform,pyscard
I have a JCOP V2.4.2 R3 java card that it is mentioned in its datasheet "The card support both T=1 and T=0 communication protocols" I have also an ACR38 smart card reader that it support both T=0 and T=1 protocols. (I have T=0 communication with one card successfully and T=1...

Encode publicKey on Java Card

java,encoding,javacard,ecdsa,pkcs#8
How to encode an ECDSA PublicKey on Java Card so that after I can decode it on another platform (e.g. sending the encoded key in a response APDU and processing it in a standard Java application)? keyPair.getPublic().getEncoded() on Java would do the trick with PKCS#8 encoding, but as far as...

Java Card memory leak in for loop?

for-loop,memory-leaks,javacard
I know that Java Card VM's doesn't have have a garbage collector, but what happens with a for loop: for(short x=0;x<10;x++) {} Does the x variable get utilized after the for loop, or it turns into garbage? Just in case I have a transient byte array called index from size...

RSA key pair generator applet, generate fixed almost zero private and public keys

java,rsa,javacard
I wrote the below JavaCard applet to generate 512 bit RSA public and private key pairs on the card and transfer them through the APDU responses to the outside: public class CryptoRSA extends Applet { //Abbreviations private static final boolean NO_EXTERNAL_ACCESS = false; //arrays for generated keys in byte. (I...

Performance measures : Java vs JavaCard [closed]

java,performance,time,smartcard,javacard
I implemented two algorithms in Java. To compare their effectiveness, I call each function 1000 times and compare the execution time (using System.currentTimeMillis()). It needs 2500 ms to execute the first one and 1300 ms for the second one. With these results, I thought have a significative difference (in term...

Converting decimal to hexadecimal byte in Java Card

hex,javacard,pkcs7,pkcs#5
I would like to convert a decimal (integer or short types) in Java to hexadecimal byte in a Java Card environment (only supports byte and short types and possibly int types). Example: int num = 254 Print out result: 0xFD My current method of using switches and if-else to handle...

Send APDU commands to USIM/SIM card in android

android,smartcard,at-command,javacard,sim-card
I was already worked with smart cards and I am familiar with APDU commands (that are defined in ISO/IEC 7816 and Global Platform specifications). Now I want to know if is there any way to send an APDU command to my USIM/SIM card that is inserted to my mobile phone?...

Programming for Java Card 3 platform in Eclipse

eclipse,javacard
I've wrote programs for Java Card 2.2.2 in Eclipse using EclipseJCDE plugin and Java Card 2.2.2 Development Kit. Now I want to write programs for my smart card that is a Java Card 3.0.1 Classic Edition, but I don't have any idea how I can do it! Can I wrote...

resources to make java card application similiar like RB 5.0

java,resources,javacard,jcop
I am making java app which main function is to write data on java card 36k, so I need resources ,tutorials about java cards,stuff like that.? I have no experience making java card apps, so please give me any helpful resources.. I am making application like RB 5.0 , if...

Javacard - power loss during garbage collection

transactions,garbage-collection,smartcard,javacard
I noticed some very strange behaviour on my smartcards (NXP J2E145, J3A081, J3C145 with an Omnikey 5121 reader): A power loss right after calling JavaCard method JCSystem.requestObjectDeletion() can damage the card: after about 10% of such power cuts the ATR command is very slow (1000ms) and I get no response...

How to write a cross-card Java Card applet?

javacard
Normally, when we write an applet containing a feature that our card not support it, the on-card verifier prevents installing its CAP file. I want to know if is there any way to write an applet that can install on all cards, but returns an already defined error during run-time...

JavaCard - pure software implementation of ECC over GF(2^n)

security,cryptography,smartcard,javacard
I have smartcards by NXP that support ECC over GF(p) and that do not support ECC over GF(2^n). In my project I need to use this particular type of smartcard (thousands of instances are used already). However, I need to add verification of EC signature over sect193r1, which is a...

Recovering an ECPublicKey from JavaCard to Java

java,bouncycastle,javacard,apdu,elliptic-curve
I am trying to implement ECDH between a terminal (simulated by my computer) and a smart card (Java Card). I fixed the elliptic curve that I want to use, and on the card side I have the following code to run the first part of the protocol : ECPublicKey pubKey...

Interpreting a java card HelloWorld applet

java,javacard
Below, you see a java card program that returns "Hello Word" when it receive APDU Command =8000000000 (its source) package helloWorldPackage; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISO7816; import javacard.framework.ISOException; import javacard.framework.Util; public class HelloWorldApplet extends Applet { private static final byte[] helloWorld = {(byte)'H',(byte)'e',(byte)'l',(byte)'l',(byte)'o',(byte)' ',(byte)'W',(byte)'o',(byte)'r',(byte)'l',(byte)'d',}; private static final byte HW_CLA...

Why I receive `6C0B` instead of data that I expected?

javacard,globalplatform
I now have a Hello World project according this link and I made its .cap file successfully. I have "DE-ABCM_TB" reader and a SAM card also. My applet AID is 01 02 03 04 05 06 07 08 09 00 00 I could select my applet on the card.( I...

Recovering an ECPublicKey from Java to JavaCard

java,cryptography,javacard,apdu,elliptic-curve
This question is related to the one I asked yesterday : Recovering an ECPublicKey from JavaCard to Java I have the same problem but in the opposite way : After sending the public key from my card to my computer (the point is represented as an octet string in uncompressed...

How to transfer RSA public[/private] key outside the card?

javacard
I wrote the below simple program to generate a RSA key pair and transfer the public key to outside the card in the APDU response: public class CryptoRSA extends Applet { //Abbreviations private static final boolean NO_EXTERNAL_ACCESS = false; //Switch case parameters for selecting instruction = INS in apdu command...

How to try using Native Methods in Java card applets?

smartcard,javacard,globalplatform
This is a simple Hello World applet for Javacards : package helloWorldPackage; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISO7816; import javacard.framework.ISOException; import javacard.framework.Util; public class HelloWorldApplet extends Applet { private static final byte[] helloWorld = {(byte)'H',(byte)'e',(byte)'l',(byte)'l',(byte)'o',(byte)' ',(byte)'W',(byte)'o',(byte)'r',(byte)'l',(byte)'d',}; private static final byte HW_CLA = (byte)0x80; private static final byte HW_INS = (byte)0x00;...

Getting PCSC Exception 0x8010002f

javacard,globalplatform,jcop
/** * */ package testing; import javacard.framework.APDU; import javacard.framework.ISO7816; import javacard.framework.Applet; import javacard.framework.ISOException; import javacard.framework.OwnerPIN; import javacard.framework.Util; /** * @author amitp * */ public class Testing extends Applet { final static byte CLASS_ONE = (byte) 0x00; final static byte CLASS_TWO = (byte) 0xA0; final static byte INS_VERIFY = (byte) 0x20;...

How to do a DAP verification in .cap files loading?

javacard,globalplatform,jcop
I want to install a .cap file. But I want the Card Manager to do a DAP verification during uploading my file. What shall I do? Does it check the DAP by default or I must use some parameters in the installation process? My smart card is a Java Card...

Why should I use “setSeed()” in my java card program?

java,random,javacard,random-seed
I wrote the below program to generate a 16 byte random number in my java card. I used the apdu buffer as the seed : public class RandomNumber extends Applet { private RandomData rngRandom; public static byte[] testArray1=new byte[16]; private RandomNumber() { } public static void install(byte bArray[], short bOffset,...

Sturdiness of an applet in Java Card

java,exception,applet,javacard
I developed an applet in Java Card and it works fine. Now I am working on the sturdiness of this applet and more precisely, what happens if the card is deplugged during the applet execution for example. I am wondering if there is an Exception which handle this kind of...

lib directory could not be found in jcdk home

javacard
I will start a project about Java card on Eclipse IDE.I follow the instructions here and when I set the home location of JCDK , I am getting "lib directory could not be found in JCDK home." error.What can be reason?

What is the efficient way in writing a java card applet?

java,javacard
With regard to absence of the Garbage Collector, I'm confused that what is the best way to define fields and variables? We know that in Java Card technology those objects that allocated with with new keyword, became unreachable when go out of the scope, but the storage space they occupy...

Make 2 cardlet Java Card communicate

applet,smartcard,channel,javacard
I have 2 cardlets Java Card on the same smart card that I want to make communicate. I could select an applet then send the corresponding APDU and then deselect it and select the other one and etc... I am wondering if it is possible to do it more properly...

ISO7816 - Odd INS codes?

smartcard,javacard,apdu
I found these mysterious lines in ISO 7816, (http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#chap5_4): 5.4.2 Instruction byte The instruction byte INS of a command shall be coded to allow transmission with any of the protocols defined in part 3 of ISO/IEC 7816. Table 10 shows the INS codes that are consequently invalid. Table 10 -...

What is the meaning of out put of GP -I command?

smartcard,javacard,globalplatform
Below, you see the output of gp -i command : gp :gp -i Reader: ACS ACR122 0 ATR: 3B8980014A434F5032343252334B More information about your card: http://smartcard-atr.appspot.com/parse?ATR=3B8980014 ***** Card info: ***** Card CPLC: IC Fabricator: 4790 IC Type: 5075 Operating System ID: 4791 Operating System release date: 2347 Operating System release level:...

Fast bit shift of a byte array - CMAC subkeys

performance,cryptography,bit-manipulation,bit-shift,javacard
I need to implement as fast as possible left bit shift of a 16-byte array in JavaCard. I tried this code: private static final void rotateLeft(final byte[] output, final byte[] input) { short carry = 0; short i = (short) 16; do { --i; carry = (short)((input[i] << 1) |...

Smart cards and their files

smartcard,javacard
As far as you know, we can list the applets that reside in a java card using tools such as GlobalPlafromPro as follow: GP: gp -list AID: A000000003000000 (|........|) ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected CVM (PIN) management AID: 010203040506 (|......|) App SELECTABLE: (none) AID: 0102030405...

Why all applets of a package are not installed? And why I can't delete them?

smartcard,javacard
This is contents of my JavaCard : GP::: gp -list AID: A000000151000000 (|....Q...|) ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management AID: A0000001515350 (|....QSP|) ExM LOADED: (none) A000000151535041 (|....QSPA|) In Eclipse I add 3 applets to a single package as below : Pack AID =...

Classic JavaCard 3.0 Applet Using HTTPS functions

javacard
I noticed that JavaCard 3.0 may have the ability to use HTTPS from the Oracle website (oracle.com/technetwork/articles/javase/javacard3-142122.html). Are there any ways to create HTTPS connections to a normal Internet website ?...

Is it possible to program a “Java Card” - enabled smart card in any other language than Java?

c,embedded,smartcard,javacard
I have a Java Card enabled smart card and a card reader that was given by my Lab-instructor. I am supposed to do a project using Java Card 2.1.1 API. I don't like the Java Card API. Is it possible to program my given smart card using any other language...

When I must use the “throws” word in declaration of a method?

java,javacard
I know it is simple, but as a newbie in java, I have problem with it! This is a simple Java Card applet that returns SW=0xEE 0xFF on reception of any command : package secondStep; import javacard.framework.*; public class BadRepeater extends Applet { public static void install(byte bArray[], short bOffset,...

Sending signature data in response APDU - Java Card

digital-signature,smartcard,javacard,apdu,ecdsa
I would like to sign some data (the MESSAGE byte array) on my Java Card and then return the signature in a response APDU. My code works fine (or at least I think it does and it returns 9000) without the line apdu.sendBytes(BAS, sSignLen), but when I uncomment it I...

Javacard applet beginner

java,applet,smartcard,javacard
I am new to javacard applet development.How many development tools are there now? Which is the simplest for beginners? As simple as possible... Thanks in advance

Why Javacard prevent uploading different in AID .cap files of a single javacard program?

smartcard,javacard,globalplatform
This is a simple javacard program (It do nothing!) : package testAID; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISOException; public class TestAID extends Applet { private TestAID() { } public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException { new TestAID().register(); } public void process(APDU arg0) throws ISOException {...

Javacard KeyAgreement differs from BouncyCastle KeyAgreement

bouncycastle,javacard,elliptic-curve,diffie-hellman
My problem looks like this. I have generated keys on the card and the terminal sides. I have on the terminal side the card public and private keys and the terminals public and private keys, and the same on the card side (i'm doing tests so thats why i have...

How to send a data array to my Applet and manipulation it by Applet and return new data in response apdu?

arrays,applet,javacard,apdu
I want to send a random byte array including for example 24 elements to my JavaCard applet and then my applet is supposed to change that array using a specific method. For example that method XOR each elements with 0x05 and returns the result array in APDU response. To aim...

Java Card DES generator applet output is different from online-tools output

java,cryptography,javacard
The below applet is written to do a DES encryption/Decryption on the APDU data field : package cryptoPack; 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.CryptoException; import javacard.security.DESKey; import javacard.security.KeyBuilder; import javacardx.crypto.Cipher; public class CryptoDES extends Applet { // Array for the encryption/decryption key...

Is there any alternative to GlobalPlatform Shell for Java Cards?

javacard
I know that GP Shell is a tool for testing I/O to Java Cards. But, it is very cumbersome to work with. Is there any alternative to GP Shell which doesn't need written scripts?...

DES Crypto applet returns errror on reception of any command

java,cryptography,javacard
In the below you see a simple Java Card applet that is written to encrypt and decrypt data with different DES and 3DES algorithms. These are supported commands : 00 C0 00 00 | KeyLength | KeyValue : To set the DES/3DES Key. (8 byte for DES, 16/24 bytes for...

what is diference between Security Domain with Delegated Management privilege and Authorized management?

smartcard,javacard,globalplatform
I want to know difference between Security Domain with Authorized Management privilege and Security Domain with delegated Management privilege. And what we do operation in two state(like loading, installing,...). I read Global platform 2.2.1 about this subject, But I understand meaning and different yet, And I want know for which...

Memory Access Performance in Java Card

performance,memory,smartcard,javacard
Supposing that I instanced a persisant byte array in Java Card with a length of 30 000 (byte[] array = new byte[(short) 0x7530];) that I run through everytime I use my applet. I also instanced an index i that I set everytime I run through my array to 'remember' at...

Secure Box in JCOP card

smartcard,javacard,globalplatform,jcop,nxp-microcontroller
JCOP V2.4.2 Revision 3 Security Target: Page 11-12 A Secure Box concept is implemented within JCOP 2.4.2 R3. The Secure Box is a construct which allows to run non certified third party native code and ensures that this code cannot harm, influence or manipulate the JCOP 2.4.2 R3 operating system...

NFC SWP applet selection returns 6999

android,nfc,smartcard,javacard,sim-card
I have a simple JavaCard applet installed on my SIM card. I try to communicate with my applet using Omnikey 5121 CL reader and NFC-enabled Sony Xperia L through NFC/SWP (single wire protocol). The problem is I cannot select the applet - as a status word I get 6999. The...

Hash generator applet doesn't work fine

hash,md5,javacard
Below, you see an applet that generate hash value of input data based on MD5, RIPEMD160, SHA, SHA224, SHA256, SHA384 and SHA512 : package hashPack; import javacard.framework.*; import javacard.security.CryptoException; import javacard.security.MessageDigest; public class HashMachine extends Applet { //outputArray byte[] hashedValue = new byte[64]; //output Length short OLength = 0x0000; //Defining...

Random data generator applet returns `0x6F00`

javacard
I wrote the below program to generate random numbers of different lengths, using two different algorithms (ALG_SECURE_RANDOM and ALG_PSEUDO_RANDOM). P1 and P2 in the APDU command specify the algorithm and the random length in order. P1 = 0X01 : ALG_SECURE_RANDOM P1 = 0X02 : ALG_PSEUDO_RANDOM P2 = Random number length...

Receiving SW=`“6999”, “6422”, “6444” and “6D00” in the simulating procedure with NetBeans , CREF and JCWDE?

netbeans,javacard
A simple 8 byte random number generator program is written in NetBeans for Java Card. This is the program : public class RandGen extends Applet { byte[] generatedArray; RandomData randData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM); private RandGen() { generatedArray = JCSystem.makeTransientByteArray((short)8, JCSystem.CLEAR_ON_DESELECT); } public static void install(byte bArray[], short bOffset, byte bLength) throws...

Why my smart card accepts two different keys as its MAC key?

smartcard,javacard,3des,parity,globalplatform
As you see below, I tried to list installed applets on my card using gp -list. I specify some different key: GP: gp -mac 404142434445464748494A4B4C4D4E4F -list AID: A000000151000000 (|....Q...|) ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management AID: A0000001515350 (|....QSP|) ExM LOADED: (none) A000000151535041 (|....QSPA|)...

Is this a bug in Transaction mechanism in javacards?

transactions,smartcard,javacard
I wrote the below program and upload it on my card : package transactionMechanismBugCheck; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISOException; import javacard.framework.JCSystem; public class TransactionMechanismBugCheck extends Applet { short[] arrayS; byte[] arrayB; private TransactionMechanismBugCheck() { } public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException { new TransactionMechanismBugCheck().register();...

Why Eclipse returns an error when trying to convert an applet, while NetBeans not?

java,eclipse,javacard
Below, you see a Java Card program that acts as a 8 byte random number generator : package randGen; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISOException; import javacard.framework.JCSystem; import javacard.framework.Util; import javacard.security.RandomData; public class RandGen extends Applet { byte[] generatedArray; RandomData randData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM); private RandGen() { generatedArray = JCSystem.makeTransientByteArray((short)8,...