Skip to content

ux: make sure parsing errors are caught and reported accordingly. #392

@Teeed

Description

@Teeed

Hi,

It looks like after bad install I got some invalid AID in the app list. Unfortunately, that makes gp tool to do not want to do anything more with the card. It always exists with the message Invalid argument: AID must be between 5 and 16 bytes: 0

Expected behavior

Should list and/or allow deletion of invalid entries.

Full log

Re-run your command with -d -v -i switches and:

# gp -l -d -v -i
# GlobalPlatformPro v24.10.15-22-gd9620f9
# Running on Linux 6.16.1-arch1-1 amd64, Java 21.0.8 by Arch Linux
[DEBUG] TerminalManager - Processing 1 readers with null as preferred and null as ignored
# SCardConnect("OMNIKEY AG 3121 USB 00 00", T=*) -> T=1, 3B9495810146545601C4
# SCardBeginTransaction("OMNIKEY AG 3121 USB 00 00")
A>> T=1 (4+0000) 00A40400 00 
A<< (0018+2) (30ms) 6F108408A000000003000000A5049F6501FF 9000
[DEBUG] GPSession - Auto-detected ISD: A000000003000000
A>> T=1 (4+0000) 80CA9F7F 00 
A<< (0045+2) (18ms) 9F7F2A4790050382116351030283190472820745664E3050383436454456313034373238321600012346500745 9000
[WARN] GPData - Invalid CPLC date: 4544
CPLC: ICFabricator=4790
      ICType=0503
      OperatingSystemID=8211
      OperatingSystemReleaseDate=6351 (2016-12-16)
      OperatingSystemReleaseLevel=0302
      ICFabricationDate=8319 (2018-11-15)
      ICSerialNumber=04728207
      ICBatchIdentifier=4566
      ICModuleFabricator=4E30
      ICModulePackagingDate=5038 (2025-02-07)
      ICCManufacturer=3436
      ICEmbeddingDate=4544 (invalid date format)
      ICPrePersonalizer=5631
      ICPrePersonalizationEquipmentDate=3034 (2023-02-03)
      ICPrePersonalizationEquipmentID=37323832
      ICPersonalizer=1600
      ICPersonalizationDate=0123 (2020-05-02)
      ICPersonalizationEquipmentID=46500745

A>> T=1 (4+0000) 80CA0042 00 
A<< (0003+2) (14ms) 420100 9000
IIN: 420100
A>> T=1 (4+0000) 80CA0045 00 
A<< (0010+2) (15ms) 45080000000000000000 9000
CIN: 45080000000000000000
A>> T=1 (4+0000) 80CA00CF 00 
A<< (0012+2) (16ms) CF0A00008319047282074566 9000
KDD: CF0A00008319047282074566
A>> T=1 (4+0000) 80CA00C1 00 
A<< (0004+2) (14ms) C10200EB 9000
SSC: C10200EB
Card Data: 
A>> T=1 (4+0000) 80CA0066 00 
A<< (0065+2) (19ms) 663F733D06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864886FC6B03640B06092A864886FC6B040255660C060A2B060104012A026E0102 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<< (0060+2) (18ms) 673A6738A006800102810155A00A8001038102001082010781039EFE8082031E03008301028504010208408602040887040102084088050102030405 9000
[WARN] GPData - Bogus data detected, fixing double tag
Supports SCP02 i=55
Supports SCP03 i=00 i=10 with AES-128 AES-196 AES-256
Supported DOM privileges: SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement, TrustedPath, AuthorizedManagement, TokenVerification, GlobalDelete, GlobalLock, GlobalRegistry, FinalApplication, ReceiptGeneration
Supported APP privileges: CardLock, CardTerminate, CardReset, CVMManagement, FinalApplication, GlobalService
Supported LFDB hash: SHA-256
Supported Token Verification ciphers: RSA1024_SHA1, ECCP521_SHA512
Supported Receipt Generation ciphers: DES_MAC
Supported DAP Verification ciphers: RSA1024_SHA1, ECCP521_SHA512
Supported ECC Key Parameters: 0102030405
A>> T=1 (4+0000) 80CA00E0 00 
A<< (0020+2) (20ms) 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 key(s) with version 0 for setting up session with MAC 
A>> T=1 (4+0008) 80500000 08 D3E6212EFCFFFFD7 00
A<< (0028+2) (57ms) 00008319047282074566FF0200EB5D8EA20C5908BFAFEE329E855DA0 9000
[DEBUG] GPSession - KDD: 00008319047282074566
[DEBUG] GPSession - SSC: 00EB
[DEBUG] GPSession - Host challenge: D3E6212EFCFFFFD7
[DEBUG] GPSession - Card challenge: 00EB5D8EA20C5908
[DEBUG] GPSession - Card reports SCP02 with key version 255 (0xFF)
[INFO] GPSession - Diversified card keys: ENC=404142434445464748494A4B4C4D4E4F (KCV: 8BAF47) MAC=404142434445464748494A4B4C4D4E4F (KCV: 8BAF47) DEK=404142434445464748494A4B4C4D4E4F (KCV: 8BAF47) for SCP02
[INFO] GPSession - Session keys: ENC=1ACEDB71EC960516B0429B1FCF74674F MAC=A294E0D63568E2CFC91C600CF30A5CF1 RMAC=4A14AA1F5738AD4A835C700F1EA62C6A
[DEBUG] GPSession - Verified card cryptogram: BFAFEE329E855DA0
[DEBUG] GPSession - Calculated host cryptogram: 544ABC5E9707F261
A>> T=1 (4+0016) 84820100 10 544ABC5E9707F261A89BA13D8CFB06B9 00
A<< (0000+2) (36ms) 9000
A>> T=1 (4+0010) 84F28002 0A 4F001AF1530C05F73222 00
A<< (0037+2) (31ms) E3234F08A0000000030000009F700101C5039EFE80C400CE020000CC08A000000003000000 9000
Invalid argument: AID must be between 5 and 16 bytes: 0
# SCardEndTransaction("OMNIKEY AG 3121 USB 00 00")
# SCardDisconnect("OMNIKEY AG 3121 USB 00 00", false) tx:97/rx:326 in 418ms

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions