I just released new version of pcsc-lite 1.8.1.
This version fixes a stupid mistake I made: I forgot to include some files in the source code archive.
Changes:
pcsc-lite-1.8.1: Ludovic Rousseau
25 November 2011
- Distribute missing files from src/spy/
I moved my blog from https://ludovicrousseau.blogspot.com/ to https://blog.apdu.fr/ . Why? I wanted to move away from Blogger (owne...
SCardGetStatusChange()
: check all the readers are already known and return SCARD_E_UNKNOWN_READER
if a reader name is not present. Windows XP has this behavior.SCardEstablishContext()
: Invalidate all the handles in the son after a forkFEATURE_EXECUTE_PACE
from PCSC v2 Part 10 Amendment 1 2011-06-03log_line()
: correctly calculate delta time when no color is used The update of last_time was only done in case of colorization (LogDoColor). So on unsupported consoles the time was wrong.log_xxd_always()
: Use a variable-length array The debug message buffer is no more with a fixed size (around 600[UPDATE from 2022]: see also "PCSC API spy, update".
I already blogged about how to spy the PCSC API in PCSC API spy for GNU systems and PCSC API spy, another way. But I am still not happy with the limitations and side effects.
libpcsclite.so.1
). But one major limitation is that it does not work if the library is not linked to the executable. It does not work when:dlopen()
as is done by OpenSC+------------------+ | PC/SC client | +------------------+ | +------------------+ +-------------+ | libpcscspy.so.0 | -> | pcsc-spy.py | +------------------+ +-------------+ | +------------------+ | libpcsclite.so.1 | +------------------+
LD_PRELOAD
loader option to load our spying library.LD_PRELOAD=/usr/lib/libpcscspy.so opensc-tool -a
LD_PRELOAD
mechanism can't be used. Instead we replace the libpcsclite.so.1
library by the spying one.install_spy.sh
and uninstall_spy.sh
to install and uninstall the spying library.pcsc-spy.py
is not a problem but has side effects:$ pcsc-spy.py
~/pcsc-spy
FIFO file. It is then possible to record an execution log and use pcsc-spy.py
multiple times on the same log.$ mkfifo ~/pcsc-spy $ cat ~/pcsc-spy > logfile
logfile
. It is displayed using:$ pcsc-spy.py logfile
$ LD_PRELOAD=/usr/lib/libpcscspy.so opensc-tool -a Using reader with a card: Gemalto GemPC Twin 00 00 3b:9f:95:81:31:fe:9f:00:65:46:53:05:30:06:71:df:00:00:00:81:61:0f:d9
$ pcsc-spy.py SCardEstablishContext i dwScope: SCARD_SCOPE_USER (0x00000000) o hContext: 0x0103E68C => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000219919] SCardListReaders i hContext: 0x0103E68C i mszGroups: (null) o pcchReaders: 0x0000001A o mszReaders: NULL => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000128] SCardListReaders i hContext: 0x0103E68C i mszGroups: (null) o pcchReaders: 0x0000001A o mszReaders: Gemalto GemPC Twin 00 00 o mszReaders: => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000101] SCardGetStatusChange i hContext: 0x0103E68C i dwTimeout: 0x00000000 (0) i cReaders: 1 i szReader: Gemalto GemPC Twin 00 00 i dwCurrentState: (0x00000000) i dwEventState: (0x00000000) i Atr length: 0x00000000 (0) i Atr: o szReader: Gemalto GemPC Twin 00 00 o dwCurrentState: (0x00000000) o dwEventState: SCARD_STATE_CHANGED, SCARD_STATE_PRESENT (0x00000022) o Atr length: 0x00000017 (23) o Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000184] SCardConnect i hContext: 0x0103E68C i szReader Gemalto GemPC Twin 00 00 i dwShareMode: SCARD_SHARE_SHARED (0x00000002) i dwPreferredProtocols: 0x00000003 (T=0, T=1) i phCard 0x02432010 (37953552) i pdwActiveProtocol 0x00000020 (32) o phCard 0x00015425 (87077) o dwActiveProtocol: T=1 (0x00000002) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000020242] SCarControl i hCard: 0x00015425 i dwControlCode: CM_IOCTL_GET_FEATURE_REQUEST (0x42000D48) i bSendLength 0x00000000 (0) i bSendBuffer i NULL o bRecvLength 0x00000012 (18) o bRecvBuffer o 0000 0A 04 42 33 00 0A 12 04 42 33 00 12 13 04 42 00 ..B3....B3....B. o 0010 00 01 .. parsing CM_IOCTL_GET_FEATURE_REQUEST results: Tag FEATURE_IFD_PIN_PROPERTIES is 0x4233000A Tag FEATURE_GET_TLV_PROPERTIES is 0x42330012 Tag FEATURE_CCID_ESC_COMMAND is 0x42000001 => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000130] SCarControl i bSendBuffer i NULL o bRecvLength 0x00000004 (4) o bRecvBuffer o 0000 00 00 07 00 .... parsing FEATURE_IFD_PIN_PROPERTIES results: wLcdLayout: 0 0 bEntryValidationCondition: 7 bTimeOut2: 0 => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000334] SCardDisconnect i hCard: 0x00015425 i dwDisposition: SCARD_LEAVE_CARD (0x00000000) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000362] SCardGetStatusChange i hContext: 0x0103E68C i dwTimeout: 0x00000000 (0) i cReaders: 1 i szReader: Gemalto GemPC Twin 00 00 i dwCurrentState: SCARD_STATE_CHANGED, SCARD_STATE_PRESENT (0x00000022) i dwEventState: SCARD_STATE_CHANGED, SCARD_STATE_PRESENT (0x00000022) i Atr length: 0x00000017 (23) i Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 o szReader: Gemalto GemPC Twin 00 00 o dwCurrentState: SCARD_STATE_CHANGED, SCARD_STATE_PRESENT (0x00000022) o dwEventState: SCARD_STATE_PRESENT (0x00000020) o Atr length: 0x00000017 (23) o Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 => Command timeout. (SCARD_E_TIMEOUT [0x8010000A]) [0.000000352] SCardGetStatusChange i hContext: 0x0103E68C i dwTimeout: 0x00000000 (0) i cReaders: 1 i szReader: Gemalto GemPC Twin 00 00 i dwCurrentState: SCARD_STATE_PRESENT (0x00000020) i dwEventState: SCARD_STATE_PRESENT (0x00000020) i Atr length: 0x00000017 (23) i Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 o szReader: Gemalto GemPC Twin 00 00 o dwCurrentState: SCARD_STATE_PRESENT (0x00000020) o dwEventState: SCARD_STATE_PRESENT (0x00000020) o Atr length: 0x00000017 (23) o Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 => Command timeout. (SCARD_E_TIMEOUT [0x8010000A]) [0.000000303] SCardGetStatusChange i hContext: 0x0103E68C i dwTimeout: 0x00000000 (0) i cReaders: 1 i szReader: Gemalto GemPC Twin 00 00 i dwCurrentState: SCARD_STATE_PRESENT (0x00000020) i dwEventState: SCARD_STATE_PRESENT (0x00000020) i Atr length: 0x00000017 (23) i Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 o szReader: Gemalto GemPC Twin 00 00 o dwCurrentState: SCARD_STATE_PRESENT (0x00000020) o dwEventState: SCARD_STATE_PRESENT (0x00000020) o Atr length: 0x00000017 (23) o Atr: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 0F D9 => Command timeout. (SCARD_E_TIMEOUT [0x8010000A]) [0.000000215] SCardConnect i hContext: 0x0103E68C i szReader Gemalto GemPC Twin 00 00 i dwShareMode: SCARD_SHARE_SHARED (0x00000002) i dwPreferredProtocols: 0x00000003 (T=0, T=1) i phCard 0x0243EA80 (38005376) i pdwActiveProtocol 0x7FFEE90B2420 (140732808242208) o phCard 0x000104C4 (66756) o dwActiveProtocol: T=1 (0x00000002) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000142] SCardBeginTransaction i hCard: 0x000104C4 => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000070] SCardEndTransaction i hCard: 0x000104C4 i dwDisposition: SCARD_LEAVE_CARD (0x00000000) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000002802] SCardDisconnect i hCard: 0x000104C4 i dwDisposition: SCARD_RESET_CARD (0x00000001) => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000058724] SCardReleaseContext i hContext: 0x0103E68C => Command successful. (SCARD_S_SUCCESS [0x00000000]) [0.000000204] Results sorted by total execution time total time: 0.304753 sec 0.219919 sec ( 1 calls) 72.16% SCardEstablishContext 0.059086 sec ( 2 calls) 19.39% SCardDisconnect 0.020384 sec ( 2 calls) 6.69% SCardConnect 0.002802 sec ( 1 calls) 0.92% SCardEndTransaction 0.001054 sec ( 4 calls) 0.35% SCardGetStatusChange 0.000464 sec ( 2 calls) 0.15% SCardControl 0.000229 sec ( 2 calls) 0.08% SCardListReaders 0.000204 sec ( 1 calls) 0.07% SCardReleaseContext 0.000070 sec ( 1 calls) 0.02% SCardBeginTransaction
SCardEstablishContext()
and SCardReleaseContext()
calls.pcsc-spy.py
) is written in Python. It should be easy to extend and make it do some complex tasks.
pcscd
daemon only when an application called SCardstablishContext()
to get a PC/SC context. Read "Configuring your system for pcscd auto-start" for more information.pcscd
is then started as the user running the application. The pcscd process has to be setgid to get special privileges to get access to the USB devices (the smart card readers). Some people (and I understand) do not like files with special access right (like setgid).pcscd.service
and pcscd.socket
pcscd.service
:[Unit] Description=PC/SC Smart Card Daemon Requires=pcscd.socket [Service] ExecStart=/usr/sbin/pcscd --foreground --auto-exit ExecReload=/usr/sbin/pcscd --hotplug StandardOutput=syslog [Install] Also=pcscd.socket
pcscd.socket
:[Unit] Description=PC/SC Smart Card Daemon Activation Socket [Socket] ListenStream=/var/run/pcscd/pcscd.comm [Install] WantedBy=sockets.target
/lib/systemd/system/
on my Debian (testing) system.$ systemctl status pcscd.service pcscd.service - PC/SC Smart Card Daemon Loaded: loaded (/lib/systemd/system/pcscd.service) Active: inactive (dead) since Mon, 14 Nov 2011 16:33:40 +0100; 17h ago Process: 15489 ExecStart=/usr/sbin/pcscd --foreground --auto-exit (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/pcscd.service
$ systemctl status pcscd.socket
pcscd.socket - PC/SC Smart Card Daemon Activation Socket
Loaded: loaded (/lib/systemd/system/pcscd.socket)
Active: active (listening) since Mon, 14 Nov 2011 14:49:45 +0100; 19h ago
CGroup: name=systemd:/system/pcscd.socket
$ systemctl status pcscd.service
pcscd.service - PC/SC Smart Card Daemon
Loaded: loaded (/lib/systemd/system/pcscd.service)
Active: active (running) since Tue, 15 Nov 2011 10:27:39 +0100; 9s ago
Main PID: 26929 (pcscd)
CGroup: name=systemd:/system/pcscd.service
└ 26929 /usr/sbin/pcscd --foreground --auto-exit
$ sudo systemctl stop pcscd.service $ systemctl status pcscd.service pcscd.service - PC/SC Smart Card Daemon Loaded: loaded (/lib/systemd/system/pcscd.service) Active: failed since Tue, 15 Nov 2011 10:30:13 +0100; 1s ago Process: 26965 ExecStart=/usr/sbin/pcscd --foreground --auto-exit (code=exited, status=1/FAILURE) CGroup: name=systemd:/system/pcscd.service
pcscd
by hand, for example in debug and foreground mode, the daemon will remove the socket /var/run/pcscd/pcscd.comm
on exit. This socket is not recreated automatically by systemd. You need to stop and start the pcscd.socket, using just start is not enough.$ ls /var/run/pcscd/pcscd.comm ls: cannot access /var/run/pcscd/pcscd.comm: No such file or directory $ sudo systemctl stop pcscd.socket $ sudo systemctl start pcscd.socket $ ls /var/run/pcscd/pcscd.comm /var/run/pcscd/pcscd.comm
Authors: | Ludovic ROUSSEAU XXX, Xiring XXX, Gemalto |
---|---|
Version: | 1.0, October 2011 |
#! /usr/bin/env python from smartcard.System import readers from smartcard.pcsc.PCSCPart10 import (getFeatureRequest, hasFeature, getTlvProperties, FEATURE_CCID_ESC_COMMAND) # use the first reader card_connection = readers()[0].createConnection() card_connection.connect() # get CCID Escape control code feature_list = getFeatureRequest(card_connection) ccid_esc_command = hasFeature(feature_list, FEATURE_CCID_ESC_COMMAND) if ccid_esc_command is None: raise Exception("The reader does not support FEATURE_CCID_ESC_COMMAND") # get the TLV PROPERTIES tlv = getTlvProperties(card_connection) # check we are using a Xiring Leo reader if tlv['PCSCv2_PART10_PROPERTY_idVendor'] == 0x0F14 \ and tlv['PCSCv2_PART10_PROPERTY_idProduct'] == 0x0037: # proprietary commands for Xiring readers version = [ord(c) for c in "VERSION"] res = card_connection.control(ccid_esc_command, version) print res print ''.join([chr(x) for x in res]) else: print "Xiring Leo reader not found"Execution with a Xiring Leo reader:
[86, 69, 82, 32, 32, 80, 75, 48, 50, 46, 49, 49, 0] VER PK02.11Execution with a non Xiring Leo reader:
Xiring Leo reader not found
Nb | iManufacturer value |
1 | |
1 | |
6 | ACS |
1 | ASK-RFID |
6 | ATMEL |
1 | ActivCard |
2 | ActivIdentity |
2 | Aktiv |
1 | Aktiv Co., ProgramPark |
1 | Aladdin |
1 | Athena |
2 | Athena |
2 | Atmel |
1 | Axalto |
2 | BIFIT |
1 | BLUTRONICS |
5 | Broadcom Corp |
6 | C3PO |
3 | COVADIS |
7 | Cherry GmbH |
1 | Dell |
6 | Eutron |
1 | FS |
1 | FT SCR301 |
1 | Feitian Technologies |
1 | Free Software Initiative of Japan |
2 | Fujitsu Siemens Computers |
1 | GEMPLUS |
8 | Gemalto |
2 | Gemalto |
1 | Gemalto* |
12 | Gemplus |
7 | Generic |
1 | German Privacy Foundation |
2 | Giesecke & Devrient GmbH |
1 | GoldKey Security |
1 | HDZB |
1 | Hewlett Packard |
2 | Hewlett-Packard Company |
1 | KEBTechnology |
3 | KOBIL |
9 | KOBIL Systems |
1 | Kingtrust |
1 | Lenovo |
1 | MYSMART |
4 | Neowave |
2 | O2 |
1 | OBERTHUR TECHNOLOGIES |
2 | OCS ID-One Cosmo Card |
4 | OMNIKEY |
9 | OMNIKEY AG |
1 | Panasonic |
2 | Philips Semiconductors |
2 | Precise Biometrics |
1 | REINER SCT |
1 | RSA |
1 | Raritan |
1 | Reiner-SCT |
18 | SCM Microsystems Inc. |
1 | SMART |
1 | SYNNIX |
1 | Samsung ElectronicsCo., Ltd |
1 | SchlumbergerSema |
1 | Secure Device Solutions |
1 | Sitecom |
7 | SpringCard |
1 | THRC |
1 | TianYu CCID Key |
1 | Tianyu |
3 | Todos |
1 | USB |
8 | VASCO |
1 | VMware |
1 | Validy |
1 | Winbond |
4 | XIRING |
1 | charismathics |
3 | id3 Semiconductors |
1 | jNet Technology inc. |
1 | ubisys |
Nb | Name |
13 | Smart Card Reader USB |
5 | mIDentity 4smart |
5 | 5880 |
4 | Weneo |
4 | CCID USB Reader |
3 | USB SmartCard Reader |
3 | USB Smart Card Reader |
3 | USB SMART CARD READER |
3 | Contactless Reader |
2 | XI-SIGN USB V2 |
2 | USB2.0-CRW |
2 | USB Smart Chip Device |
2 | USB SMART CARD KEYBOARD |
2 | USB GemPCPinpad SmartCard Reader |
2 | Smart Enterprise Guardian Secure USB Device |
2 | Smart Card Reader |
2 | SCR33x USB Smart Card Reader |
2 | SCR3310 USB Smart Card Reader |
2 | SCR331-DI USB Smart Card Reader |
2 | SCL01x Contactless Reader |
2 | Prox SU USB PC LinkReader |
2 | Prox Dual USB PC LinkReader |
2 | PCSC Smartcard Reader |
2 | O2Micro CCID SC Reader |
2 | ICCD Smartcard |
2 | Ezio Shield |
2 | EMV Smartcard Reader |
2 | DIGIPASS KEY 860 |
2 | DIGIPASS KEY 200 |
2 | CryptoIdentity CCID |
2 | Connectable |
2 | Card Reader |
2 | CCID Smart Card Reader |
2 | ASEDrive CCID |
1 | uKeyCI800-K18 |
1 | plug'n'crypt CCID token |
1 | mIDentity XL |
1 | mIDentity M |
1 | jToken s1 |
1 | iBank2Key |
1 | cyberJack pinpad(a) |
1 | cyberJack RFID basis |
1 | Virtual USB CCID |
1 | VaultIC460 |
1 | VaultIC440 |
1 | VaultIC420 Smart Object |
1 | VEGA-ALPHA |
1 | USB-Token iBank2key |
1 | USB Token |
1 | USB Reader V3 |
1 | TokenA sl vt |
1 | Token JC |
1 | Token GEM USB COMBI-M |
1 | Token GEM USB COMBI |
1 | TianYu CCID SmartKey |
1 | SmartTerminal XX7X |
1 | SmartTerminal XX44 |
1 | SmartTerminal XX1X |
1 | SmartTerminal ST-2xxx |
1 | SmartMX Sample |
1 | SmartCard USB 2A |
1 | SmartCard Keyboard USB 2A |
1 | SmartBoard XX44 |
1 | SmartBoard XX33 |
1 | SmartBoard XX1X |
1 | Smart Token |
1 | Smart Card Reader Interface |
1 | Sitecom USB simcard reader MD-010 |
1 | SchlumbergerSema Cyberflex Access |
1 | STD200 |
1 | SPRx32 USB Smart Card Reader |
1 | SIM Reader |
1 | SDI010 Smart Card Reader |
1 | SCRx31 USB Smart Card Reader |
1 | SCR35xx v2.0 USB SC Reader |
1 | SCR35xx USB Smart Card Reader |
1 | SCR3340 - ExpressCard54 Smart Card Reader |
1 | SCR3320 - Smart Card Reader |
1 | SCR3311 USB Smart Card Reader |
1 | SCL010 Contactless Reader |
1 | SBV280 |
1 | SA .NET Dual |
1 | S3FC9UB USB Smart Card II |
1 | Rutoken lite |
1 | Rutoken Magistra |
1 | Rutoken ECP |
1 | Reflex USB v3 |
1 | RSA SecurID (R) Authenticator |
1 | Prox'N'Roll |
1 | Precise 250 MC |
1 | Precise 200 MC |
1 | Panasonic USB Smart Card Reader 7A-Smart |
1 | PIV Token |
1 | PDT |
1 | MySMART PAD V2.0 |
1 | Multi-Reader |
1 | MFP Smart Card Reader |
1 | LTC3x USB |
1 | KONA USB SmartCard |
1 | KOBIL Class 3 Reader |
1 | KAAN SIM III |
1 | KAAN Base |
1 | KAAN Advanced |
1 | JCOP41V221 |
1 | Integrated Smart Card Reader |
1 | IDProtect Key v2 |
1 | ID-ONE TOKEN SLIM v2 |
1 | Hybrid Smartcard Reader |
1 | HP USB Smartcard Reader |
1 | HP USB Smart Card Keyboard |
1 | HP USB CCID Smartcard Keyboard |
1 | Gemplus USB SmartCard Reader 433-Swap |
1 | GemPC Express |
1 | GemCore SIM Pro Smart Card Reader |
1 | GemCore POS Pro Smart Card Reader |
1 | Gem e-Seal Pro USB Token |
1 | GEN5XX CCID |
1 | FT SCR310 |
1 | FSIJ USB Token |
1 | EasyFinger Ultimate |
1 | EasyFinger Standard |
1 | EZIO CB+ |
1 | Digipass 860 |
1 | Dell USB Smartcard Keyboard |
1 | Dell Smart Card Reader Keyboard |
1 | DP905 |
1 | DP865 |
1 | DP855 |
1 | DOMINO-Key TWIN |
1 | DIGIPASS 920 |
1 | D2CIM-DVUSB VM/CCID |
1 | Crypto Stick v1.2 |
1 | CrazyWriter |
1 | CSB6 Ultimate |
1 | CSB6 Secure |
1 | CSB6 Basic |
1 | CCID SmartCard Controller |
1 | CCID Smart Card 301 |
1 | BLUDRIVE II CCID |
1 | Auriga |
1 | Activkey Sim |
1 | ActivCard USB Reader V2 |
1 1 | AT98SC032CT-USB AT91SO CCID Smart Card Reader |
1 | AT91SC192192CT-USB ICCD reader |
1 | APG8201 USB Reader |
1 | ALYA |
1 | AGM2 CCID |
1 | ACR38 USB Reader |
1 | ACR122U PICC Interface |
1 | 13.56MHz RFID (CCID) |
Authors: | Ludovic ROUSSEAU XXX, Xiring |
---|---|
Version: | 1.0, October 2011 |
Information Class | Data Element | Tag | Max Length | Data Encoding |
---|---|---|---|---|
Communications | Max APDU data size | 0x0111 | 4 bytes | DWORD |
#define SCARD_ATTR_MAX_APDU_DATA_SIZE SCARD_ATTR_VALUE(SCARD_CLASS_COMMUNICATIONS, 0x0111)XXX from YYY commented this idea with, November 11 2010:
I fully agree that we should find this information in part 3.
However, it is not so nice to do this on Windows as the driver would have to intercept the IOCTL_SMARTCARD_GET_ATTRIBUTE request and treat it locally instead of forward it to SMCLIB via SmartcardDeviceControl (see http://msdn.microsoft.com/en-us/library/ff548899%28v=VS.85%29.aspx). Note that the driver cannot rely on error code returned by SmartcardDeviceControl to process the request as the IRP has already been completed.
That's why I would prefer using a PC/SC V2 feature for that. PC/SC V2 features such as IFD_PIN_PROPERTIES and IFD_DISPLAY_PROPERTIES are also reader capabilities and should be returned via part 3 but PC/SC structures are restricted in Windows to known fields without possibility to extend them easily.
So we have 2 choices:
What is Microsoft point of view on that?
- Add this information in part 3 (and be quite inconsistent with IFD_PIN_PROPERTIES and IFD_DISPLAY_PROPERTIES) and do not strictly respect MS rules on PC/SC drivers
- Add this information to part 10 as a PC/SC V2 feature
if (get dwMaxAPDUDataSize failed) { /* we don't know if extended APDU is supported */ Shall we continue or abort? Maybe it is safer to continue (as before). } else { if (dwMaxAPDUDataSize == 0) { error("your reader does not support extended APDU.") return } if (dwMaxAPDUDataSize < needed_size) { error("your reader supports too short extended APDU.") error("We need at least %d bytes", dwMaxAPDUDataSize) return } } continue execution