Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

Error 0x643A when installing applet on ACOSJ card

JavaCard Applet Development Related Questions and Answers.
User avatar
Vivinn
Posts: 4
Joined: Fri Jun 02, 2017 4:55 pm
Points :82
Location: France
Contact:

Error 0x643A when installing applet on ACOSJ card

Post by Vivinn » Tue Jun 13, 2017 6:59 am

After the successful installation (and deletion) of the same applet twice, I can't manage to install an applet anymore on my Java Card.

The setup involved:

  • Smart card: ACS ACOSJ 40KB Java Card 3.0.4 (dual interface)
  • Card reader: Cherry TC 1300 (dual interface)
  • CCID driver: HID Global OMNIKEY ifdokccid_linux_x86_64-v4.2.8
  • Software: GlobalPlatformPro latest commit

General card information:

Code: Select all

$ gp-pro --info --debug --verbose
GlobalPlatformPro v0.3.9-26-gf426164
Running on Linux 4.11.3-1-ARCH amd64, Java 1.8.0_121 by Oracle Corporation
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
# Detected readers from JNA2PCSC
[ ] Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 00
[*] Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01
SCardConnect("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01", T=*) -> T=1, 3B89800141434F534A763130311A
SCardBeginTransaction("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01")
Reader: Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01
ATR: 3B89800141434F534A763130311A
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B89800141434F534A763130311A

A>> T=1 (4+0000) 00A40400 00
A<< (0094+2) (61ms) 6F5C8408A000000151000000A550734A06072A864886FC6B01600C060A2A864886FC6B02020201630906072A864886FC6B03640B06092A864886FC6B040255650B06092A864886FC6B020103660C060A2B060104012A026E01039F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A000000151000000
[DEBUG] GlobalPlatform - Auto-detected GP version: GP22
[DEBUG] GlobalPlatform - Auto-detected block size: 255
***** Card info:
A>> T=1 (4+0000) 80CA9F7F 00
A<< (0000+2) (14ms) 6A88
[DEBUG] GlobalPlatform - GET DATA(CPLC) returned SW: 6A88
NO CPLC
***** CARD DATA
A>> T=1 (4+0000) 80CA0066 00
A<< (0078+2) (20ms) 664C734A06072A864886FC6B01600C060A2A864886FC6B02020201630906072A864886FC6B03640B06092A864886FC6B040255650B06092A864886FC6B020103660C060A2B060104012A026E0103 9000
Unknown tag: 4c
***** KEY INFO
A>> T=1 (4+0000) 80CA00E0 00
A<< (0020+2) (13ms) E012C00401208010C00402208010C00403208010 9000
VER:32 ID:1 TYPE:DES3 LEN:16
VER:32 ID:2 TYPE:DES3 LEN:16
VER:32 ID:3 TYPE:DES3 LEN:16
SCardEndTransaction()
SCardDisconnect("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01", true)


Content of the card:

Code: Select all

$ gp-pro --list --debug --verbose
GlobalPlatformPro v0.3.9-26-gf426164
Running on Linux 4.11.3-1-ARCH amd64, Java 1.8.0_121 by Oracle Corporation
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
# Detected readers from JNA2PCSC
[ ] Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 00
[*] Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01
SCardConnect("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01", T=*) -> T=1, 3B89800141434F534A763130311A
SCardBeginTransaction("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01")
Reader: Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01
ATR: 3B89800141434F534A763130311A
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B89800141434F534A763130311A

A>> T=1 (4+0000) 00A40400 00
A<< (0094+2) (60ms) 6F5C8408A000000151000000A550734A06072A864886FC6B01600C060A2A864886FC6B02020201630906072A864886FC6B03640B06092A864886FC6B040255650B06092A864886FC6B020103660C060A2B060104012A026E01039F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A000000151000000
[DEBUG] GlobalPlatform - Auto-detected GP version: GP22
[DEBUG] GlobalPlatform - Auto-detected block size: 255
A>> T=1 (4+0008) 80500000 08 997728AF7718D9D0 00
A<< (0028+2) (23ms) 000002650183039536622002009F84CEF1BFDB16D8BA6EFD53BD6121 9000
[DEBUG] GlobalPlatform - Host challenge: 997728AF7718D9D0
[DEBUG] GlobalPlatform - Card challenge: 009F84CEF1BFDB16
[DEBUG] GlobalPlatform - Card reports SCP02 with version 32 keys
[DEBUG] PlaintextKeys - session keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:A5797275765F7FF0CBE8B18C26DEFA63 KCV: D976D3
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:C33CA06593C585A676C31E185597CA2F KCV: 851D4A
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:E0DA147FCBE037600ECFB4374CDDB727 KCV: E96244
[DEBUG] GlobalPlatform - Verified card cryptogram: D8BA6EFD53BD6121
[DEBUG] GlobalPlatform - Calculated host cryptogram: DDE5E44B37C24F2B
A>> T=1 (4+0016) 84820100 10 DDE5E44B37C24F2B5B0364A17273FCBE
A<< (0000+2) (28ms) 9000
A>> T=1 (4+0010) 84F28002 0A 4F00A81FC2FCEFC4991D 00
A<< (0021+2) (20ms) E3134F08A0000001510000009F700101C5039EDE00 9000
A>> T=1 (4+0010) 84F24002 0A 4F00C91EF58ED44DAB70 00
A<< (0000+2) (22ms) 6A88
A>> T=1 (4+0010) 84F22002 0A 4F00C4D3F1DE4D39F6CE 00
A<< (0015+2) (24ms) E30D4F07A00000015153509F700101 9000
A>> T=1 (4+0010) 84F21002 0A 4F006435B654480BD772 00
A<< (0025+2) (27ms) E3174F07A00000015153509F7001018408A000000151535041 9000
# Mode: GP22
ISD: A000000151000000 (OP_READY)
        Privs:   SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement, TrustedPath, AuthorizedManagement, GlobalDelete, GlobalLock, GlobalRegistry, FinalApplication

PKG: A0000001515350 (LOADED) (|....QSP|)
        Applet:  A000000151535041 (|....QSPA|)

SCardEndTransaction()
SCardDisconnect("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01", true)


Trying to install an applet:

Code: Select all

$ gp-pro --install smartpgp.cap --debug --verbose            
GlobalPlatformPro v0.3.9-26-gf426164
Running on Linux 4.11.3-1-ARCH amd64, Java 1.8.0_121 by Oracle Corporation
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
# Detected readers from JNA2PCSC
[ ] Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 00
[*] Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01
SCardConnect("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01", T=*) -> T=1, 3B89800141434F534A763130311A
SCardBeginTransaction("Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01")
Reader: Cherry SC Reader (046A:0092) (OKCM0032209141841184149324404368) 00 01
ATR: 3B89800141434F534A763130311A
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B89800141434F534A763130311A

A>> T=1 (4+0000) 00A40400 00
A<< (0094+2) (60ms) 6F5C8408A000000151000000A550734A06072A864886FC6B01600C060A2A864886FC6B02020201630906072A864886FC6B03640B06092A864886FC6B040255650B06092A864886FC6B020103660C060A2B060104012A026E01039F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A000000151000000
[DEBUG] GlobalPlatform - Auto-detected GP version: GP22
[DEBUG] GlobalPlatform - Auto-detected block size: 255
A>> T=1 (4+0008) 80500000 08 679425CBDD4F44DC 00
A<< (0028+2) (23ms) 000002650183039536622002009CA58A6D77C4681FF9409A201BED61 9000
[DEBUG] GlobalPlatform - Host challenge: 679425CBDD4F44DC
[DEBUG] GlobalPlatform - Card challenge: 009CA58A6D77C468
[DEBUG] GlobalPlatform - Card reports SCP02 with version 32 keys
[DEBUG] PlaintextKeys - session keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:1BA6EBAD460F5396C70E2605726C2CD1 KCV: BFDA37
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:61BAA9D6003C14E7C65A8FF2A4A275A8 KCV: B7BD6F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:1AB1FA470FB34528804854E0EE9323ED KCV: 29AE49
[DEBUG] GlobalPlatform - Verified card cryptogram: 1FF9409A201BED61
[DEBUG] GlobalPlatform - Calculated host cryptogram: A2A3559D66739175
A>> T=1 (4+0016) 84820100 10 A2A3559D6673917542E6D95D954F6BCF
A<< (0000+2) (28ms) 9000
CAP file (v2.1) generated on Sun Jun 04 06:26:53 CEST 2017
By Oracle Corporation converter  [v3.0.5] with JDK 1.8.0_121 (Oracle Corporation)
Package: fr.anssi.smartpgp v1.0 with AID D27600012401
Applet: SmartPGPApplet with AID D276000124010302AFAF000000000000
Import: A0000000620001 v1.0
Import: A0000000620102 v1.6
Import: A0000000620101 v1.6
Import: A0000000620201 v1.6
Total code size: 19650 bytes (23213 with debug)
SHA256 (code): 1D5DC804F5717A5223E3781E513E0721304952DF041C9948E9812823D26D06E6
SHA1   (code): 643BEDB7BE8F31CD132148CBC8F8C437C1A19CB1
A>> T=1 (4+0010) 84F28002 0A 4F0058A916B464677333 00
A<< (0021+2) (19ms) E3134F08A0000001510000009F700101C5039EDE00 9000
A>> T=1 (4+0010) 84F24002 0A 4F0021C42E3A2F543FCC 00
A<< (0000+2) (22ms) 6A88
A>> T=1 (4+0010) 84F22002 0A 4F002B7CC7DD76018728 00
A<< (0015+2) (24ms) E30D4F07A00000015153509F700101 9000
A>> T=1 (4+0010) 84F21002 0A 4F0096EFFB8E668E98B5 00
A<< (0025+2) (27ms) E3174F07A00000015153509F7001018408A000000151535041 9000
A>> T=1 (4+0027) 84E60200 1B 06D2760001240108A0000001510000000000004BF30032D2A47207
A<< (0001+2) (91ms) 00 9000
A>> T=1 (4+0255) 84E80000 FF C4824CC2010010DECAFFED010204000106D2760001240102001F0010001F00140029052A011035B60837081400000DE800640032079704010004002904000107A0000000620001060107A0000000620102060107A0000000620101060107A00000006202010300140110D276000124010302AFAF0000000000001B83060110008000030003010300000009001300330080000500050107000000DC00F10127016C01CE01FA029B00800000FF000100000000800000FF000100000000800000FF00010000000080000100010101000004AE0080000802060102000005B905D100800001000101030000063C064906620080000803050111F0BEE357E02F7CD6
A<< (0000+2) (486ms) 643A
pro.javacard.gp.GPException: LOAD failed SW: 643A
        at pro.javacard.gp.GPException.check(GPException.java:66)
        at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:667)
        at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:625)
        at pro.javacard.gp.GPTool.main(GPTool.java:565)
LOAD failed SW: 643A


And I get the same error with at least three other different applets.

What's the internet tells us about this error:

0x643a On-card applet package max exceeded.

* Cause: Installation of an applet package failed because the number of applet packages that can be stored on the card has been exceeded.
* Solution: Remove some applet packages from the CREF.


But the card is as empty as the first time I used it. And what is this CREF anyway? A card simulator?

What I did prior to this failure:

  1. Installation of the JCAlgTest applet (with gp-pro --install)
  2. Deletion of JCAlgTest applet (with gp-pro --delete PACKAGE_AID)
  3. Again, installation of JCAlgTest
  4. And again, deletion of JCAlgTest

All these without errors. But now I can't install anything. It's like the two applets weren't really deleted, and the EEPROM if full. But no applets appears in the content of the card (with gp-pro -l). And I didn't find anything to "reset" the card or "format" the EEPROM.

What is going on with these phantom packages?

P.S. I posted the same question on Stack Overflow but to no avail.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by UNKNwYSHSA » Thu Jun 15, 2017 3:03 am

First, you got error when loading applet, not installing applet.
Second, can you write one applet only has the API called: "JCSystem.requestObjectDeletion();" or "JCSystem.getAvailableMemory();" and install the applet?

Waiting you ...
sense and simplicity

User avatar
Vivinn
Posts: 4
Joined: Fri Jun 02, 2017 4:55 pm
Points :82
Location: France
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by Vivinn » Thu Jun 15, 2017 10:25 am

I wrote and compiled this applet:

Code: Select all

package test;

import javacard.framework.*;

public class TestApplet extends Applet {
    protected TestApplet() {
        JCSystem.requestObjectDeletion();
        register();
    }

    public static void install(byte[] bArray, short bOffset, byte bLength) {
        new TestApplet();
    }

    public void process(APDU apdu) throws ISOException {
        byte buffer[] = apdu.getBuffer();
        ISOException.throwIt(Util.makeShort((byte) (ISO7816.SW_INS_NOT_SUPPORTED >> 8), buffer[1]));
    }
}


But I get the same 0x643A error when trying to install the resulting CAP file.

tay00000
Posts: 161
Joined: Tue Sep 27, 2016 10:58 am
Points :2324
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by tay00000 » Thu Jun 15, 2017 8:25 pm

Before you continue to attempt to install anymore applet, list the contents of the card first to ensure there is really nothing in the card. After you have listed and ensured that no contents are residing in the card, then you start to load the test applet you have recently created.

In order to facilitate helping you debug, please show the output from the listing of card contents and the loading of test applet after listing card contents in an orderly fashion.

User avatar
Vivinn
Posts: 4
Joined: Fri Jun 02, 2017 4:55 pm
Points :82
Location: France
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by Vivinn » Thu Jun 15, 2017 8:59 pm

I've already shown that in my first post :p
Again, but without the debug content:

Code: Select all

$ gp-pro --list
# Mode: GP22
ISD: A000000151000000 (OP_READY)
     Privs:   SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement, TrustedPath, AuthorizedManagement, GlobalDelete, GlobalLock, GlobalRegistry, FinalApplication

PKG: A0000001515350 (LOADED)
     Applet:  A000000151535041


Code: Select all

$ gp-pro --install TestApplet.cap
LOAD failed SW: 643A

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by UNKNwYSHSA » Thu Jun 15, 2017 10:45 pm

From your APDU logs. That the CAP file version is 2.1.x. You can try to generate the CAP file with JC2.2.x or JC3.0.x, and upload and install.
Reason:
1 The card os didn't support CAP version 2.1.x, but it didn't throw exception SW_WRONG_DATA when loading CAP file;
2 There are some differents between CAP file structure with version 2.1.x and version 3.0.x;

Waiting your result ...
sense and simplicity

User avatar
Vivinn
Posts: 4
Joined: Fri Jun 02, 2017 4:55 pm
Points :82
Location: France
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by Vivinn » Thu Jun 15, 2017 11:20 pm

The CAP file version is different from the JCDK version. I built the applet with JCDK version 2.2.2 and 3.0.4, and the result is the same.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: Error 0x643A when installing applet on ACOSJ card

Post by UNKNwYSHSA » Thu Jun 15, 2017 11:23 pm

Vivinn wrote:The CAP file version is different from the JCDK version. I built the applet with JCDK version 2.2.2 and 3.0.4, and the result is the same.


For this situation, you can only send this problem to the card provider.
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 69 guests

JavaCard OS : Disclaimer