Error 0x643A when installing applet on ACOSJ card
Posted: 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:
General card information:
Content of the card:
Trying to install an applet:
And I get the same error with at least three other different applets.
What's the internet tells us about this error:
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:
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.
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:
- Installation of the JCAlgTest applet (with gp-pro --install)
- Deletion of JCAlgTest applet (with gp-pro --delete PACKAGE_AID)
- Again, installation of JCAlgTest
- 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.