Skip to content

Unknown error in get_status() (error code 0x6c0c) #8

@thotheolh

Description

@thotheolh

Electrum Satochip Version: electrum-satochip-v4.1.5
SatopchipApplet Version: SatoChip-0.12-05.cap
Card Type: THD-89 (Proprietary JCOS)

Issue:
Getting 'Failed to create a client for this device. Make sure it is in the correct state.' error message when trying to create a new hardware wallet with Satochip applet and Electrum client.

Trace Log:

20211204T095959.036948Z |     INFO | plugin.DeviceMgr | Registering <SatochipClient TODO>
20211204T095959.169798Z |     INFO | pysatochip.CardConnector | +Inserted: 3B 1B 96 50 6F 6C 61 72 69 73 20 21 01 11
20211204T100000.446336Z |    DEBUG | pysatochip.CardConnector | In card_select
20211204T100000.446336Z |    DEBUG | pysatochip.CardConnector | In card_transmit
20211204T100000.446336Z |    DEBUG | pysatochip.CardConnector | > 00 A4 04 00 08 53 61 74 6F 43 68 69 70
20211204T100000.460175Z |    DEBUG | pysatochip.CardConnector | < [] 90 00
20211204T100000.460582Z |    DEBUG | pysatochip.CardConnector | Found a Satochip!
20211204T100000.460582Z |    DEBUG | pysatochip.CardConnector | In card_get_status
20211204T100000.460582Z |    DEBUG | pysatochip.CardConnector | In card_transmit
20211204T100000.460582Z |    DEBUG | pysatochip.CardConnector | > B0 3C 00 00
20211204T100000.466263Z |    DEBUG | pysatochip.CardConnector | < [] 6C 0C
20211204T100000.466263Z |  WARNING | pysatochip.CardConnector | Unknown error in get_status() (error code 0x6c0c)
20211204T100000.467263Z |    DEBUG | pysatochip.CardConnector | In card_disconnect()
20211204T100000.467263Z |     INFO | pysatochip.CardConnector | disconnecting from'ExcelSecu Contact_Rd 0'
20211204T100000.510724Z |     INFO | plugins.satochip.satochip | [SatochipClient] client request: update_status
20211204T100000.510724Z |     INFO | plugins.satochip.satochip | [SatochipClient] self.handler is None! 
20211204T100001.944041Z |     INFO | plugins.satochip.satochip | [SatochipPlugin] setup_device()
20211204T100001.944041Z |     INFO | plugin.DeviceMgr | scanning devices...
20211204T100001.959304Z |     INFO | plugins.satochip.satochip | [SatochipPlugin] detect_smartcard_reader
20211204T100012.066339Z |     INFO | plugins.satochip.satochip | has_usable_connection_with_device()
20211204T100012.066339Z |    DEBUG | pysatochip.CardConnector | In card_get_ATR()
20211204T100012.066339Z |    ERROR | plugins.satochip.satochip | Exception in has_usable_connection_with_device: 'NoneType' object has no attribute 'connection'
Traceback (most recent call last):

Comments:
It seems that the GET_STATUS instruction is returning SW 0x6C0C. I am wondering if some card types are sensitive to Le being used and the current CardConnector does not issue a Le in the APDU.

A suggestion is to issue Le with 255 for all APDU commands which may help to accommodate more types of cards to run Electrum-Satochip by default.

Here's a GP.EXE execution with APDU with Le enabled:

>java -jar gp-old.jar -a 00A40400085361746F43686970 -a B03C000011 --debug
GlobalPlatformPro v20.01.23-0-g5ad373b
Running on Windows 10 10.0 amd64, Java 16.0.2 by Oracle Corporation
# Detected readers from JNA2PCSC
[*] ExcelSecu Contact_Rd 0
SCardConnect("ExcelSecu Contact_Rd 0", T=*) -> T=0, 3B1B96506F6C6172697320210111
SCardBeginTransaction("ExcelSecu Contact_Rd 0")
A>> T=0 (4+0008) 00A40400 08 5361746F43686970
A<< (0000+2) (15ms) 9000
A>> T=0 (4+0000) B03C0000 11
A<< (0012+2) (16ms) 000C00050000000000000001 9000
A>> T=0 (4+0000) 00A40400 00
A<< (0093+2) (32ms) 6F5B8408A000000003000000A54F734906072A864886FC6B01600B06092A864886FC6B020202630906072A864886FC6B03640B06092A864886FC6B040255650B06092A864886FC6B020101660C060A2B060104012A026E01029F6501FF 9000
[TRACE] GPSession -  [6F]
[TRACE] GPSession -      [84] A000000003000000
[TRACE] GPSession -      [A5]
[TRACE] GPSession -          [73]
[TRACE] GPSession -              [06] 2A864886FC6B01
[TRACE] GPSession -              [60]
[TRACE] GPSession -                  [06] 2A864886FC6B020202
[TRACE] GPSession -              [63]
[TRACE] GPSession -                  [06] 2A864886FC6B03
[TRACE] GPSession -              [64]
[TRACE] GPSession -                  [06] 2A864886FC6B040255
[TRACE] GPSession -              [65]
[TRACE] GPSession -                  [06] 2A864886FC6B020101
[TRACE] GPSession -              [66]
[TRACE] GPSession -                  [06] 2B060104012A026E0102
[TRACE] GPSession -          [9F65] FF
[DEBUG] GPSession - Auto-detected ISD: A000000003000000
SCardEndTransaction("ExcelSecu Contact_Rd 0")
SCardDisconnect("ExcelSecu Contact_Rd 0", true) tx:23/rx:111

Here's a GP.EXE execution with APDU with Le not enabled:

java -jar gp-old.jar -a 00A40400085361746F43686970 -a B03C0000 --debug
GlobalPlatformPro v20.01.23-0-g5ad373b
Running on Windows 10 10.0 amd64, Java 16.0.2 by Oracle Corporation
# Detected readers from JNA2PCSC
[*] ExcelSecu Contact_Rd 0
SCardConnect("ExcelSecu Contact_Rd 0", T=*) -> T=0, 3B1B96506F6C6172697320210111
SCardBeginTransaction("ExcelSecu Contact_Rd 0")
A>> T=0 (4+0008) 00A40400 08 5361746F43686970
A<< (0000+2) (15ms) 9000
A>> T=0 (4+0000) B03C0000
A<< (0000+2) (16ms) 9C11
A>> T=0 (4+0000) 00A40400 00
A<< (0093+2) (31ms) 6F5B8408A000000003000000A54F734906072A864886FC6B01600B06092A864886FC6B020202630906072A864886FC6B03640B06092A864886FC6B040255650B06092A864886FC6B020101660C060A2B060104012A026E01029F6501FF 9000
[TRACE] GPSession -  [6F]
[TRACE] GPSession -      [84] A000000003000000
[TRACE] GPSession -      [A5]
[TRACE] GPSession -          [73]
[TRACE] GPSession -              [06] 2A864886FC6B01
[TRACE] GPSession -              [60]
[TRACE] GPSession -                  [06] 2A864886FC6B020202
[TRACE] GPSession -              [63]
[TRACE] GPSession -                  [06] 2A864886FC6B03
[TRACE] GPSession -              [64]
[TRACE] GPSession -                  [06] 2A864886FC6B040255
[TRACE] GPSession -              [65]
[TRACE] GPSession -                  [06] 2A864886FC6B020101
[TRACE] GPSession -              [66]
[TRACE] GPSession -                  [06] 2B060104012A026E0102
[TRACE] GPSession -          [9F65] FF
[DEBUG] GPSession - Auto-detected ISD: A000000003000000
SCardEndTransaction("ExcelSecu Contact_Rd 0")
SCardDisconnect("ExcelSecu Contact_Rd 0", true) tx:22/rx:99

It seems the pysatochip.CardConnector getting SW 0x6C0C is abit odd since without Le, GP.EXE returns SW 0x9C11 and pysatochip.CardConnector on the other hand returns 0x6C0C.

There seems to be some differences in how GP.EXE and pysatochip.CardConnector calls the smartcards ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions