Important!

Blog moved to https://blog.apdu.fr/

I moved my blog from https://ludovicrousseau.blogspot.com/ to https://blog.apdu.fr/ . Why? I wanted to move away from Blogger (owne...

Tuesday, January 1, 2019

Happy new year 2019

Dear readers,

I wish you a happy new year for 2019.

In 2018 I published 24 articles on this blog (34 in 2017 and 49 in 2016 and 51 in 2015). It is, again, decreasing.

Audience

The number of readers in 2018 is also decreasing by 20% compared to 2017.


A large part of readers came from the USA, France is 2nd, followed by Germany.

The first cities from USA are from California: San Francisco, San Diego, Los Angeles, San Jose, Palo Alto, etc. The second state from USA is Oregon with 94% of Oregon readers from Boardman. Is there a high smart card activity in Bordman/Oregon?

In France 33% of readers comes from Paris. The distribution is more homogeneous in Germany.



Most read articles

Title#%
PCSC sample in C15.71 %
Blog homepage25.50 %
PC/SC sample in different languages34.82 %
PCSC sample in C# 44.15 %
PCSC sample in Python 53.16 %
PCSC sample in Java 62.45 %
pcscd auto start using systemd 72.44 %
Level 1 smart card support on Mac OS X 82.25 %
PCSC sample in JavaScript (Node.js) 91.83 %
Linux NFC driver conflicts with CCID driver for ACS ACR122U 101.68 %

PC/SC sample articles are always successful. I wrote them in 2010.
The first article from those I wrote in 2018 is at position 17 and is "How to use SCardGetStatusChange()?".

Thank you

Thank you to you, readers.

This blog has no advertising. If you want to support it you can send me some bitcoins. If you want to send $ or € instead of bitcoins then contact me.

Monday, December 17, 2018

macOS Mojave and smart card source code

Apple released the source code of the open source components they use in Mojave (macOS 10.14, released in September 2018). The components are available at macOS X 10.14 Source.


Many smart card components are now closed source and maintained by Apple for its different OSes. I can cite:

CCID driver

Apple provides my Free Software CCID driver. The source code from Apple is available at:
Version 55017 corresponds to CCID version 1.4.27 and was already present in macOS High Sierra as noted in "macOS High Sierra and smart cards status".

    Tokend

    Apple still provides "support" of the tokend technology even if it is deprecated since OS X Lion (2011). The source code is provided at:
    The version 55111 has not changed since macOS Sierra. see "macOS Sierra and smart card source code".

    Conclusion

    No change in the free software component binaries so also no change in the corresponding component source codes.

    Wednesday, December 12, 2018

    New version of pcsc-tools: 1.5.4

    I just released a new version of pcsc-tools, a suite of tools for PC/SC.

    A big thank you to Lionel Victor, original author of gscriptor, for the port of gscriptor to Gtk+3. My level of Perl programming has diminished since I do not use this language any more.

    Changes:
    1.5.4 - 12 December 2018, Ludovic ROUSSEAU
    • 213 new ATRs
    • pcsc_scan: display the number of events
    • gscriptor: port from Gtk+2 to Gtk+3

    Friday, October 12, 2018

    New PyKCS11 1.5.3 available

    I just released a new version of PyKCS11, a Python wrapper above the PKCS#11 API.
    See "PyKCS11 introduction" or "PyKCS11’s documentation".

    Changes:

    1.5.3 - October 2018, Ludovic Rousseau
    • Do not fail when converting a UTF-8 string
    • Documentation: convert from Epydoc to Sphinx
    • some minor improvements

    New version of pcsc-lite: 1.8.24

    I just released a new version of pcsc-lite 1.8.24.
    pcsc-lite is a Free Software implementation of the PC/SC (or WinSCard) API for Unix systems.

    Changes
    1.8.24: Ludovic Rousseau
    12 October 2018
    • the project moved to https://pcsclite.apdu.fr/
    • SCardGetStatusChange(): Fix a rare race condition
    • SCardReleaseContext(): do not release a lock owned by another context
    • SCardReconnect(): suspend card auto power off
    • Allow "=" in serial driver filenames
    • Add the thread id in the pcscd log lines
    • pcsc-spy: correctly handle incomplete log file
    • Simclist: avoid to divide by zero in list_findpos()
    • Some other minor improvements

    Tuesday, September 25, 2018

    macOS Mojave and smart cards status

    macOS Mojave (macOS 10.14) is now available since 24th September, 2018.


    API Differences between 10.13 and 10.14

    The differences should be listed in the developer page macOS Mojave 10.14.
    The changes for Mojave are not yet available.

    PC/SC

    Since Yosemite (10.10) the PC/SC layer is no more a fork of pcsc-lite. So comparing versions with pcsc-lite is useless.

    $ cat /System/Library/Frameworks/PCSC.framework/Versions/A/Resources/version.plist
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
     <key>BuildAliasOf</key>
     <string>CryptoTokenKit</string>
     <key>BuildVersion</key>
     <string>163</string>
     <key>CFBundleShortVersionString</key>
     <string>8.0</string>
     <key>CFBundleVersion</key>
     <string>1</string>
     <key>ProjectName</key>
     <string>SmartCardServices</string>
     <key>SourceVersion</key>
     <string>281200021000000</string>
    </dict>
    </plist>
    

    The BuildVersion moved from 10 in Sierra 10.13.6 to 163 in Mojave 10.14.0. Maybe Apple made 163 - 10 = 153 internal/alpha/beta releases?

    The SourceVersion moved from 281050022000000 in High Sierra 10.13.6 to 281200021000000 in Mojave 10.14.0. I have no idea how to parse or use this information.

    PC/SC Bugs fixed

    These bugs were found in High Sierra are now fixed in Mojave:
    • Typo in error message from PC/SC call pcsc_stringify_error(), bug #40995115.
      pcsc_stringify_error() returned "Unkown error" instead of ""UnkNown error" for unknown error codes.
    Maybe some other PC/SC bugs (unknown by me) have been fixed.

    CryptoTokenKit

    CryptoTokenKit is the native smart card API since the complete rewrite in macOS Yosemite 10.10 (OS X Yosemite BETA and smart cards status).

    $ strings /System/Library/Frameworks/CryptoTokenKit.framework/CryptoTokenKit | grep BuildRoot
    /BuildRoot/Library/Caches/com.apple.xbs/Sources/CryptoTokenKit/CryptoTokenKit-281.200.21/CryptoTokenKit/TKToken.m
    /BuildRoot/Library/Caches/com.apple.xbs/Sources/CryptoTokenKit/CryptoTokenKit-281.200.21/CryptoTokenKit/TKSmartCard.m
    /BuildRoot/Library/Caches/com.apple.xbs/Sources/CryptoTokenKit/CryptoTokenKit-281.200.21/CryptoTokenKit/TKTokenSession.m

    In Mojave CryptoTokenKit source code is at version 281.200.21. It was at version 281.1.1 in High Sierra 10.13.0 and 281.50.22 in High Sierra 10.13.6.
    Since the source code is not available I can't write much more than that.

    CCID driver

    Driver version: 1.4.27.

    $ grep -A 1 CFBundleShortVersionString /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
     <key>CFBundleShortVersionString</key>
     <string>1.4.27</string>
    

    This is the exact same version as in Hight Sierra 10.13.0.

    Note that the CCID version 1.4.28 was released in October 2017 and version 1.4.29 in February 2018. Apple had plenty of time to upgrade the CCID driver. This is surprising.

    The current version of the CCID driver is 1.4.30. This version was released 5 days before Mojave so I was not expecting to see this version included in Mojave.

    Conclusion

    No much visible changes in the smart card layer in macOS Mojave.

    It is surprising Apple has not upgraded the CCID driver since the previous major version of macOS. I understand this major version of macOS is not a revolution but more a stabilisation of macOS.

    Saturday, September 22, 2018

    Better CCID suport in FreeBSD

    My CCID driver had some problems when used on a FreeBSD system. I used FreeBSD 10.4 (stable) but the problem should also be present in more recent or older versions of FreeBSD.

    The problem

    The problem was that the removal a USB reader was not reported to the PC/SC application. The removal was detected by the PC/SC daemon (pcscd) but something failed in the removal process.

    The same problem also prevented the PC/SC daemon to exit correctly when stopped using the keyboard combination Control+C.

    After some debugging the cause of the problem was identified. When the CCID driver is stopped (because a reader is removed or pcscd is exited) the driver tries to cancel all the unfinished USB transfers. When the reader provides an interrupt end point to notify card events the CCID driver initiates a USB transfer reading from this end point with a long timeout (10 minutes).

    libUSB issues

    I reported the problem using the FreeBSD bug report tool: https://bugs.freebsd.org/

    I worked with Hans Petter Selasky (libUSB co-maintainer) to fix the problems. I would like to thank Hans Petter for his availability. That is great to have problems fixed in just a few days.

    libusb_cancel_transfer() does NOT cancel a transfer after the USB device is removed

    Bug reported at: libusb_cancel_transfer() does NOT cancel a transfer after the USB device is removed

    Patch applied in FreeBSD: Revision 338616

    Debug is not working correctly

    Use of DPRINTF() to print debug message was not working in some functions.

    Bug reported at: libusb DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done"); does not work in libusb10_do_transfer_cb()

    Patch applied in FreeBSD: Revision 338679

    Bogus management after a device removal

    Bug reported at: libusb_bulk_transfer() does not fail (with LIBUSB_ERROR_NO_DEVICE) if the device is not more present

    This bug is solved by the patch also solving the libusb_cancel_transfer() problem.

    Fixed in FreeBSD stable versions

    The problems have also been fixed in FreeBSD stable versions 9, 10, 11.

    Conclusion

    My CCID driver should now work better on FreeBSD.