Infineon / BlockchainSecurity2Go-Python-Library

Python library for the Blockchain Security 2Go starter kit
https://infineon.com/blockchain
MIT License
16 stars 8 forks source link

Traceback from blocksec2go get_card_info with ACS / ACR122U #27

Open oberstet opened 3 years ago

oberstet commented 3 years ago

With the ACS / ACR122U reader (still waiting for a uTrust 4701 F), and the following on a fresh CPython 3.9 venv on Ubuntu 20.04.2 LTS

blocksec2go>=1.2
nfcpy>=1.0.3

I'm running into the following:

(cpy392_1) oberstet@intel-nuci7:~$ python -V
Python 3.9.2
(cpy392_1) oberstet@intel-nuci7:~$ sudo nfc-list -v
nfc-list uses libnfc 1.7.0-rc7
NFC device: ACS / ACR122U PICC Interface opened
1 ISO14443A passive target(s) found:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  84  
* UID size: triple
* bit frame anticollision supported
       UID (NFCID1): 01  23  45  67  89  ab  cd  ef  aa  55  
      SAK (SEL_RES): 20  
* Compliant with ISO/IEC 14443-4
* Not compliant with ISO/IEC 18092
                ATS: 78  77  d0  03  66  49  46  58  42  53  32  47  6f  
* Max Frame Size accepted by PICC: 256 bytes
* Bit Rate Capability:
  * PICC to PCD, DS=2, bitrate 212 kbits/s supported
  * PICC to PCD, DS=4, bitrate 424 kbits/s supported
  * PICC to PCD, DS=8, bitrate 847 kbits/s supported
  * PCD to PICC, DR=2, bitrate 212 kbits/s supported
  * PCD to PICC, DR=4, bitrate 424 kbits/s supported
  * PCD to PICC, DR=8, bitrate 847 kbits/s supported
* Frame Waiting Time: 2475 ms
* No Start-up Frame Guard Time required
* Node Address supported
* Card IDentifier supported
* Historical bytes Tk: 66  49  46  58  42  53  32  47  6f  
  * Proprietary format

Fingerprinting based on MIFARE type Identification Procedure:
Other possible matches based on ATQA & SAK values:
* Unknown card, sorry

0 Felica (212 kbps) passive target(s) found.

0 Felica (424 kbps) passive target(s) found.

0 ISO14443B passive target(s) found.

0 ISO14443B' passive target(s) found.

0 ISO14443B-2 ST SRx passive target(s) found.

0 ISO14443B-2 ASK CTx passive target(s) found.

0 Jewel passive target(s) found.

(cpy392_1) oberstet@intel-nuci7:~$ blocksec2go get_card_info
Traceback (most recent call last):
  File "/home/oberstet/cpy392_1/bin/blocksec2go", line 8, in <module>
    sys.exit(main())
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/blocksec2go/cli/main.py", line 60, in main
    raise e
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/blocksec2go/cli/main.py", line 47, in main
    args.func(args)
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/blocksec2go/cli/get_card_info.py", line 11, in _get_card_info
    (pin_active, card_id, version) = select_app(reader)
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/blocksec2go/commands.py", line 82, in select_app
    r = reader.transceive(b'\x00\xA4\x04\x00', aid).check()
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/blocksec2go/comm/pyscard.py", line 21, in transceive
    resp = self._transceive(bytes(apdu))
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/blocksec2go/comm/pyscard.py", line 26, in _transceive
    resp, sw1, sw2 = self.connection.transmit(array.array('b', data).tolist())
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/smartcard/CardConnectionDecorator.py", line 82, in transmit
    return self.component.transmit(bytes, protocol)
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/smartcard/CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "/home/oberstet/cpy392_1/lib/python3.9/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 205, in doTransmit
    sw1 = (response[-2] + 256) % 256
IndexError: list index out of range
(cpy392_1) oberstet@intel-nuci7:~$ 
oberstet commented 3 years ago

the reader itself seems to work at least "somewhat" - is there any tweaking/config I could try to make it work?

Bildschirmfoto von 2021-04-28 00-44-59

(cpy392_1) oberstet@intel-nuci7:~/scm/crossbario/crossbar-binaries/app/src$ python crossbarstarter/_smartcard.py 
['ACS ACR122U 00 00']
<blocksec2go.comm.pyscard.PySCardReader object at 0x7f255f8f5ca0>
(cpy392_1) oberstet@intel-nuci7:~/scm/crossbario/crossbar-binaries/app/src$ cat crossbarstarter/_smartcard.py
import smartcard.System
from blocksec2go import open_pyscard, CardError
from blocksec2go import select_app

readers = smartcard.System.readers()
print(readers)

reader = open_pyscard(readers[0])
print(reader)

# traceback "IndexError: list index out of range" in
# site-packages/smartcard/pcsc/PCSCCardConnection.py", line 205, in doTransmit
#
# (pin_active, card_id, version) = select_app(reader)
# print(pin_active, card_id, version)