LudovicRousseau / pcsc-tools

Some tools to be used with smart cards and PC/SC
https://pcsc-tools.apdu.fr/
GNU General Public License v2.0
185 stars 63 forks source link

Need to send a reset after every command #50

Closed ua0lnj closed 2 years ago

ua0lnj commented 2 years ago

Hi. I have Compunicate paytv smart card. It's detected fine.

Thu Oct 28 16:14:15 2021
 Reader 0: CASTLES EZCCID Smart Card Reader 00 00
  Event number: 0
  Card state: Card inserted, Exclusive Mode,
  ATR: 3B E9 00 00 81 31 C3 45 99 63 74 69 19 99 12 56 10 EC

ATR: 3B E9 00 00 81 31 C3 45 99 63 74 69 19 99 12 56 10 EC
+ TS = 3B --> Direct Convention
+ T0 = E9, Y(1): 1110, K: 9 (historical bytes)
  TB(1) = 00 --> VPP is not electrically connected
  TC(1) = 00 --> Extra guard time: 0
  TD(1) = 81 --> Y(i+1) = 1000, Protocol T = 1
-----
  TD(2) = 31 --> Y(i+1) = 0011, Protocol T = 1
-----
  TA(3) = C3 --> IFSC: 195
  TB(3) = 45 --> Block Waiting Integer: 4 - Character Waiting Integer: 5
+ Historical bytes: 99 63 74 69 19 99 12 56 10
  Category indicator byte: 99 (proprietary format)
+ TCK = EC (correct checksum)

Possibly identified card (using /root/.cache/smartcard_list.txt):
        NONE

Updating /root/.cache/smartcard_list.txt using http://ludovic.rousseau.free.fr/softwares/pcsc-tools/smartcard_list.txt

Possibly identified card (using /root/.cache/smartcard_list.txt):
        NONE

Your card is not present in the database.
Please submit your unknown card at:
http://smartcard-atr.appspot.com/parse?ATR=3BE900008131C345996374691999125610EC

If I send commands one by one, then I get an error:

root@ua0lnjserv:/usr/src# scriptor -r "CASTLES EZCCID Smart Card Reader 00 00"
Using given card reader: CASTLES EZCCID Smart Card Reader 00 00
Using T=1 protocol
Reading commands from STDIN
81 D0 00 01 08
> 81 D0 00 01 08
< 13 E3 F5 C6 CB 27 5F 37 90 00 : Normal processing.
81 C0 00 01 0A
> 81 C0 00 01 0A
Can't get info: Transaction failed.

But if I send a reset after each command, then everything works:

root@ua0lnjserv:/usr/src# scriptor -r "CASTLES EZCCID Smart Card Reader 00 00"
Using given card reader: CASTLES EZCCID Smart Card Reader 00 00
Using T=1 protocol
Reading commands from STDIN
81 D0 00 01 08
> 81 D0 00 01 08
< 13 E3 F5 C6 CB 27 5F 37 90 00 : Normal processing.
reset
> RESET
< OK: 3B E9 00 00 81 31 C3 45 99 63 74 69 19 99 12 56 10 EC
81 C0 00 01 0A
> 81 C0 00 01 0A
< 4A B0 90 00 : Normal processing.
reset
> RESET
< OK: 3B E9 00 00 81 31 C3 45 99 63 74 69 19 99 12 56 10 EC
81 D1 00 01 10
> 81 D1 00 01 10
< 00 18 EB 61 A1 D1 FA BF 30 30 30 30 30 30 30 30
90 00 : Normal processing.
^C

Is this a pcsc-tools problem or is this normal and need to send resets from a program that works with pcscd?

LudovicRousseau commented 2 years ago

FIrst I suggest you to update pcsc_scan http://ludovic.rousseau.free.fr/softwares/pcsc-tools/

I think it is a problem with your card or reader or reader driver.

ua0lnj commented 2 years ago

I use latest git. And this problem is not mine alone. I solved it with the patch for Oscam, but it may not be correct. https://www.sat-universe.com/showthread.php?t=318592 https://board.streamboard.tv/forum/thread/47913-dgcrypt-0x4ab0/

LudovicRousseau commented 2 years ago

I am pretty sure you do NOT use a recent ATR_analysis command. The message should be different. See https://github.com/LudovicRousseau/pcsc-tools/blob/master/ATR_analysis#L289

ua0lnj commented 2 years ago

I added my cards. The log from version 1.5.5 (ubuntu 20), but the version from the git works the same way.

LudovicRousseau commented 2 years ago

Closing since you solved the problem.