martinpaljak / GlobalPlatformPro

šŸŒ šŸ” Manage applets and keys on JavaCard-s like a pro (via command line or from your Java project)
https://javacard.pro/globalplatform
GNU Lesser General Public License v3.0
679 stars 210 forks source link

gp fails with Error: null #281

Open eugmes opened 2 years ago

eugmes commented 2 years ago

Describe the bug

I'm trying to use gp with a JavaCOS A22 card, but all operations but -l fail with Error: null.

Information about your card

As much information as you have:

  1. Feitian
  2. JavaCOS A22 dual interface Java card - 150K

Expected behavior

Some commands work or show some better error message.

Full log

Output of gp -ldvi:

# gp -ldvi
# GlobalPlatformPro v21.12.31-2-g86ebbda
# Running on Linux 5.15.0-2-amd64 amd64, Java 11.0.13 by Debian
[DEBUG] TerminalManager - Processing 3 readers with null as preferred and null as ignored
[DEBUG] TerminalManager - Preferred reader: Optional.empty
SCardConnect("Elatec TWN4/B1.06/CPF3.05/S1SC1.32/P (Beta 3) 02 00", T=*) -> T=1, 3B8F800100664653051000FF71DF000000000039
A>> T=1 (4+0000) 00A40400 00 
A<< (0094+2) (30ms) 6F5C8408A000000003000000A550734A06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864886FC6B03640B06092A864886FC6B040255650B06092B8510864864020103660C060A2B060104012A026E01029F6501FF 9000
[DEBUG] GPSession - Auto-detected ISD: A000000003000000
A>> T=1 (4+0000) 80CA9F7F 00 
A<< (0045+2) (17ms) 9F7F2A4090789286AA0197000103680102306D09794090126986AA126986AA1269000000000000000000000000 9000
[WARN] GPData - Invalid CPLC date: 0368
[DEBUG] GPData - 0x0000/0xFFFF does not represent a valid date
CPLC: ICFabricator=4090
      ICType=7892
      OperatingSystemID=86AA
      OperatingSystemReleaseDate=0197 (2020-07-15)
      OperatingSystemReleaseLevel=0001
      ICFabricationDate=0368 (invalid date format)
      ICSerialNumber=0102306D
      ICBatchIdentifier=0979
      ICModuleFabricator=4090
      ICModulePackagingDate=1269 (2021-09-26)
      ICCManufacturer=86AA
      ICEmbeddingDate=1269 (2021-09-26)
      ICPrePersonalizer=86AA
      ICPrePersonalizationEquipmentDate=1269 (2021-09-26)
      ICPrePersonalizationEquipmentID=00000000
      ICPersonalizer=0000
      ICPersonalizationDate=0000 (invalid date format)
      ICPersonalizationEquipmentID=00000000

A>> T=1 (4+0000) 80CA0042 00 
A<< (0000+2) (17ms) 6A88
[DEBUG] GPData - GET DATA(IIN): N/A
A>> T=1 (4+0000) 80CA0045 00 
A<< (0000+2) (17ms) 6A88
[DEBUG] GPData - GET DATA(CIN): N/A
A>> T=1 (4+0000) 80CA00CF 00 
A<< (0012+2) (13ms) CF0A000001970102306D0979 9000
KDD: CF0A000001970102306D0979
A>> T=1 (4+0000) 80CA00C1 00 
A<< (0004+2) (16ms) C1020003 9000
SSC: C1020003
Card Data: 
A>> T=1 (4+0000) 80CA0066 00 
A<< (0078+2) (25ms) 664C734A06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864886FC6B03640B06092A864886FC6B040255650B06092B8510864864020103660C060A2B060104012A026E0102 9000
Tag 6: 1.2.840.114283.1
-> Global Platform card
Tag 60: 1.2.840.114283.2.2.1.1
-> GP Version: 2.1.1
Tag 63: 1.2.840.114283.3
-> GP card is uniquely identified by the Issuer Identification Number (IIN) and Card Image Number (CIN)
Tag 6: 1.2.840.114283.4.2.85
-> GP SCP02 i=55
Tag 66: 1.3.6.1.4.1.42.2.110.1.2
-> JavaCard v2
Card Capabilities: 
A>> T=1 (4+0000) 80CA0067 00 
A<< (0000+2) (18ms) 6A88
[DEBUG] GPData - GET DATA(Card Capabilities): N/A
A>> T=1 (4+0000) 80CA00E0 00 
A<< (0020+2) (24ms) E012C00401FF8010C00402FF8010C00403FF8010 9000
Version: 255 (0xFF) ID:   1 (0x01) type: DES3         length:  16 (factory key)
Version: 255 (0xFF) ID:   2 (0x02) type: DES3         length:  16 (factory key)
Version: 255 (0xFF) ID:   3 (0x03) type: DES3         length:  16 (factory key)

# Warning: no keys given, defaulting to 404142434445464748494A4B4C4D4E4F
[INFO] GPSession - Using card master keys with version 0 for setting up session with MAC 
Error: null
SCardDisconnect("Elatec TWN4/B1.06/CPF3.05/S1SC1.32/P (Beta 3) 02 00", true) tx:45/rx:271 in 238ms

Additional context

I've tried using gp with multiple readers, both wired and wireless and the result is always the same.

martinpaljak commented 2 years ago

Yep, the release turned out to be buggy, please refrain from using it.

eugmes commented 2 years ago

@martinpaljak Ah, I've tried the previous release now v20.08.12 and it works. Thanks.

martinpaljak commented 2 years ago

I'll try to fix the annoyances ASAP, but there's some structural consolidation happening in build infrastructure that I'd like to get fixed first....

gwachob commented 2 years ago

FWIW, we've been forced to upgrade to something newer than 20.08.12 because we have folks using M1 Macs, and the issue https://github.com/martinpaljak/apdu4j/issues/51 is fixed for M1s only in https://github.com/martinpaljak/apdu4j/releases/v21.04.01 (unless its a joke :P ) . So, not sure what the right answer is in the near term.

It appears that the specific issue mention in this bug report was introduced with https://github.com/martinpaljak/GlobalPlatformPro/commit/f5eed37bf3ab53cc7cbcc72341fbbdd491beedef, and building gp.jar from the previous commit (https://github.com/martinpaljak/GlobalPlatformPro/commit/a07c58e4e689dd4190a57ddc151bd9ddddebf1ab) may be a workaround for now.