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...

Friday, October 26, 2012

cardpeek: A tool to read the contents of smartcards

A few days ago I discovered a nice tool: cardpeek.






Project

The project is hosted at http://code.google.com/p/cardpeek/.
It is Free Software and uses the GNU GPL v3 licence.

From the project web site:
Cardpeek is a Linux/Windows tool to read the contents of ISO7816 smartcards. It features a GTK GUI to represent card data is a tree view, and is extendable with a scripting language (LUA).

The goal of this project is to allow smartcard owners to be better informed about what type of personal information is stored in these devices.

The tool currently reads the contents of :
  • EMV cards, including NFC ones.
  • Navigo public transport cards (partially supports MOBIB as well)
  • The French health card "Vitale 2"
  • Electronic/Biometric passports in BAC security mode.

It can also read the following cards with limited interpretation of data:
  • Some Mifare cards (such as the Thalys card);
  • Moneo, the French electronic purse;
  • GSM SIM cards.

More info on the Wiki here: http://code.google.com/p/cardpeek/wiki/Main

Installation

It is easy to install under Debian GNU/Linux. You may need to install some dependencies related to the lua language. The program is written in C and lua. The parts sending smart card commands are lua scripts. I do not yet have lua in my list of languages for PC/SC.

You may be unable to run the ./configure script. I already reported this problem. run autoreconf -vis to get correct symlinks.

Examples

EMV

I tried with an EMV card.

The application gives a lot of information. For example you have access to the card transaction records.
In this example I payed 48.11€ on the August 30th of 2012. This transaction was to fil the tank with gasoline but the card do not store information about the merchant.

Navigo Pass

I do not have a Navigo Pass myself so I reused the screen copy from the cardpeek project navigo page.

From the project:
The "calypso" script included in cardpeek can read the content of Navigo cards used in Paris. It provides enhanced "event log" analysis notably with subway/train station names, as illustrated in the screenshot above. It has been successfully tested on Navigo Découverte, Navigo and Navigo Intégrale cards.

SIM

The support is SIM card is indicated as beta but does work quiet well.

For example you can dump the phone book stored in your SIM card.

I guess it is in beta mode because not all the fields are parsed and displayed in a human readable format.

Conclusion

Cardpeek is a very nice tool to explore many common kinds of smart cards. It is tech savvy oriented.

Sunday, October 7, 2012

New version of libccid: 1.4.8

I just released a version 1.4.8 of libccid the free software CCID class smart card reader driver.

1.4.8 - 22 June 2012, Ludovic Rousseau
  • Add support of
    • SCR3310-NTTCom USB (was removed in version 1.4.6)
    • Inside Secure VaultIC 420 Smart Object
    • Inside Secure VaultIC 440 Smart Object
  • Wait up to 3 seconds for reader start up
  • Add support of new PC/SC V2 part 10 properties:
    • dwMaxAPDUDataSize
    • wIdVendor
    • wIdProduct
  • Use helper functions from libPCSCv2part10 to parse the PC/SC v2 part 10 features

Monday, October 1, 2012

Parsing an ATR: now in color

Since 2010 I provide a way to parse an ATR online using a web page. I also provide a Python script to do the same using a command line tool.

I am not a user interface design expert. But I like to have important elements in color. Syntax colorization is a great invention. So I decided to add color to the ATR parsing results.

Web page

Available at http://smartcard-atr.appspot.com/

Before

Parsing ATR: 3B FA 13 00 FF 81 31 80 45 00 31 C1 73 C0 01 00 00 90 00 B1

TS = 0x3BDirect Convention
T0 = 0xFAY(1): b1111, K: 10 (historical bytes)
TA(1) = 0x13Fi=372, Di=4, 93 cycles/ETU (43010 bits/s at 4.00 MHz, 53763 bits/s for fMax=5 MHz)
TB(1) = 0x00VPP is not electrically connected
TC(1) = 0xFFExtra guard time: 255 (special value)
TD(1) = 0x81Y(i+1) = b1000, Protocol T=1
----
TD(2) = 0x31Y(i+1) = b0011, Protocol T=1
----
TA(3) = 0x80IFSC: 128
TB(3) = 0x45Block Waiting Integer: 4 - Character Waiting Integer: 5
----
Historical bytes00 31 C1 73 C0 01 00 00 90 00
Category indicator byte: 0x00
(compact TLV data object)
    Tag: 3, Len: 1 (card service data byte)
      Card service data byte: 193
        - Application selection: by full DF name
        - Application selection: by partial DF name
        - EF.DIR and EF.ATR access services: by GET RECORD(s) command
        - Card without MF
    Tag: 7, Len: 3 (card capabilities)
      Selection methods: 192
        - DF selection by partial DF name
        - DF selection by full DF name
      Data coding byte: 1
        - Behaviour of write functions: one-time write
        - Value 'FF' for the first byte of BER-TLV tag fields: valid
        - Data unit in quartets: 1
     Command chaining, length fields and logical channels: 0
        - Logical channel number assignment: No logical channel
        - Maximum number of logical channels: 0
    Mandatory status indicator (3 last bytes)
      LCS (life card cycle): 0 (No information given)
      SW: 9000 ()
TCK = 0xB1 (correct checksum)

Possibly identified card: OpenPGP

After

Parsing ATR: 3B FA 13 00 FF 81 31 80 45 00 31 C1 73 C0 01 00 00 90 00 B1

TS = 0x3BDirect Convention
T0 = 0xFAY(1): b1111, K: 10 (historical bytes)
TA(1) = 0x13Fi=372, Di=4, 93 cycles/ETU (43010 bits/s at 4.00 MHz, 53763 bits/s for fMax=5 MHz)
TB(1) = 0x00VPP is not electrically connected
TC(1) = 0xFFExtra guard time: 255 (special value)
TD(1) = 0x81Y(i+1) = b1000, Protocol T=1
----
TD(2) = 0x31Y(i+1) = b0011, Protocol T=1
----
TA(3) = 0x80IFSC: 128
TB(3) = 0x45Block Waiting Integer: 4 - Character Waiting Integer: 5
----
Historical bytes00 31 C1 73 C0 01 00 00 90 00
Category indicator byte: 0x00
(compact TLV data object)
    Tag: 3, Len: 1 (card service data byte)
      Card service data byte: 193
        - Application selection: by full DF name
        - Application selection: by partial DF name
        - EF.DIR and EF.ATR access services: by GET RECORD(s) command
        - Card without MF
    Tag: 7, Len: 3 (card capabilities)
      Selection methods: 192
        - DF selection by partial DF name
        - DF selection by full DF name
      Data coding byte: 1
        - Behaviour of write functions: one-time write
        - Value 'FF' for the first byte of BER-TLV tag fields: valid
        - Data unit in quartets: 1
      Command chaining, length fields and logical channels: 0
        - Logical channel number assignment: No logical channel
        - Maximum number of logical channels: 0
    Mandatory status indicator (3 last bytes)
      LCS (life card cycle): 0 (No information given)
      SW: 90 00 ()
TCK = 0xB1 correct checksum

Possibly identified card: OpenPGP

Command line

The same software is also available as a command line tool: parseATR.py

Before

ATR: 3B FA 13 00 FF 81 31 80 45 00 31 C1 73 C0 01 00 00 90 00 B1
TS = 0x3B --> Direct Convention
T0 = 0xFA --> Y(1): b1111, K: 10 (historical bytes)
 TA(1) = 0x13 --> Fi=372, Di=4, 93 cycles/ETU (43010 bits/s at 4.00 MHz, 53763 bits/s for fMax=5 MHz)
 TB(1) = 0x00 --> VPP is not electrically connected
 TC(1) = 0xFF --> Extra guard time: 255 (special value)
 TD(1) = 0x81 --> Y(i+1) = b1000, Protocol T=1
----
 TD(2) = 0x31 --> Y(i+1) = b0011, Protocol T=1
----
 TA(3) = 0x80 --> IFSC: 128
 TB(3) = 0x45 --> Block Waiting Integer: 4 - Character Waiting Integer: 5
----
Historical bytes --> 00 31 C1 73 C0 01 00 00 90 00
  Category indicator byte: 0x00 -->  (compact TLV data object)
    Tag: 3, Len: 1 (card service data byte)
      Card service data byte: 193
        - Application selection: by full DF name
        - Application selection: by partial DF name
        - EF.DIR and EF.ATR access services: by GET RECORD(s) command
        - Card without MF
    Tag: 7, Len: 3 (card capabilities)
      Selection methods: 192
        - DF selection by partial DF name
        - DF selection by full DF name
      Data coding byte: 1
        - Behaviour of write functions: one-time write
        - Value 'FF' for the first byte of BER-TLV tag fields: valid
        - Data unit in quartets: 1
      Command chaining, length fields and logical channels: 0
        - Logical channel number assignment: No logical channel
        - Maximum number of logical channels: 0
    Mandatory status indicator (3 last bytes)
      LCS (life card cycle): 0 (No information given)
      SW: 9000 ()
TCK = 0xB1  --> (correct checksum)
Possibly identified card: OpenPGP

After

ATR: 3B FA 13 00 FF 81 31 80 45 00 31 C1 73 C0 01 00 00 90 00 B1
TS = 0x3B --> Direct Convention
T0 = 0xFA --> Y(1): b1111, K: 10 (historical bytes)
 TA(1) = 0x13 --> Fi=372, Di=4, 93 cycles/ETU (43010 bits/s at 4.00 MHz, 53763 bits/s for fMax=5 MHz)
 TB(1) = 0x00 --> VPP is not electrically connected
 TC(1) = 0xFF --> Extra guard time: 255 (special value)
 TD(1) = 0x81 --> Y(i+1) = b1000, Protocol T=1
----
 TD(2) = 0x31 --> Y(i+1) = b0011, Protocol T=1
----
 TA(3) = 0x80 --> IFSC: 128
 TB(3) = 0x45 --> Block Waiting Integer: 4 - Character Waiting Integer: 5
----
Historical bytes --> 00 31 C1 73 C0 01 00 00 90 00
  Category indicator byte: 0x00 -->  (compact TLV data object)
    Tag: 3, Len: 1 (card service data byte)
      Card service data byte: 193
        - Application selection: by full DF name
        - Application selection: by partial DF name
        - EF.DIR and EF.ATR access services: by GET RECORD(s) command
        - Card without MF
    Tag: 7, Len: 3 (card capabilities)
      Selection methods: 192
        - DF selection by partial DF name
        - DF selection by full DF name
      Data coding byte: 1
        - Behaviour of write functions: one-time write
        - Value 'FF' for the first byte of BER-TLV tag fields: valid
        - Data unit in quartets: 1
      Command chaining, length fields and logical channels: 0
        - Logical channel number assignment: No logical channel
        - Maximum number of logical channels: 0
    Mandatory status indicator (3 last bytes)
      LCS (life card cycle): 0 (No information given)
      SW: 90 00 ()
TCK = 0xB1  --> correct checksum
Possibly identified card: OpenPGP

Conclusion

I like colorization.

Friday, September 28, 2012

Adobe signature system was compromised

Adobe just published an article "Inappropriate Use of Adobe Code Signing Certificate" describing the inappropriate use of their code signature private key.

Adobe uses a Hardware Security Module (HSM) to store the private key. The signature requests are sent by build servers and signed by the HSM.

Unfortunately one build server has been compromised and malicious software has been signed.

Lessons

Maybe the lesson is that automatic code signing, without human verification, is an error. Of course the human verification shall be smart enough to avoid repetitive and boring tasks.

In general smart card doing cryptographic signature with a legal value (eID or citizen cards) are configured so that the user PIN has to be entered before each signature. And the use of a pinpad reader is a big security improvement. So even if the user computer is compromised the attacker cannot sign many documents without the user noticing something wrong.
But:
  • only one signed document may be enough for the attacker
  • noticing something is wrong requests some user intelligence

Conclusion

The best security architects can do is:
  • provide systems simple to understand
  • provide some kind of detection of strange events
  • provide a way to easily revoke a compromised key

Tuesday, September 18, 2012

Tokend installer for Mac OS X Mountain Lion

2 months after the release of Mountain Lion, Apple (Shawn Gedddis) just released a new (beta) tokend package installer for Mountain Lion (10.8).

From http://smartcardservices.macosforge.org/trac/wiki/installers

« This installs the Tokend modules which no longer ship from Apple as part of Mac OS X beginning with OS X Lion (v10.7). Note that this installer will ONLY install onto OS X Mountain Lion v10.8. The Tokend modules installed are: BELPIC, CAC, CACNG, JPKI and PIV.

New to this release:
JPKI.Tokend - Build 38522 added to the update to support LASCOM in Japan.
cacloginconfig.plist - Default configuration file as optional install for those using Attribute Matching or PKINIT configurations.
SystemCACertificates.keychain - Automatically added to the Keychain Search List if not already present. »

Related post "Mac OS X Mountain Lion and smart card status".

Thursday, August 30, 2012

New version of pcsc-lite: 1.8.6

I just released a new version of pcsc-lite 1.8.6.

Changes:
pcsc-lite-1.8.6: Ludovic Rousseau
30 August 2012
  • Fix a problem when only serial drivers are used (no hotplug/USB driver)
  • increase log buffer size from 160 to 2048. Some "long" log lines where truncated.
  • Fix redirection of stdin, stdout and stderr to /dev/null when pcscd is started as a daemon (default)
  • Some other minor improvements and bug corrections

Tuesday, August 28, 2012

Comments on my blog and bug reports

I sometimes get comments on articles of my blog. I can classify them in 3 different categories:
  • spam
  • comments about the article
  • comments about something else

Spam

Spams are (manually) rejected.
I do not get many spams.

Comments about the article

I like comments about the article. I accept questions about the article or about a specific point. In general I add an answer immediately (if I know the answer).

Comments about something else

Sometimes I have to moderate comments about something not related to the article.
The blogger.com application do not allow me to reject the comment and explain why I rejected the comment to the comment author. So I reject the comment and the comment author has no idea of what happened.

Example

For example I got, for the second time, a comment on the Mac OS X Mountain Lion and smart card status article. The comment is:
" Anyone having issues with reading encrypted messages via a CAC within Mountain Lion and Outlook?

I can sign and encrypt, and people can read them, but I cannot decrypt. It is not the card or reader, it works fine on the PC.

It is very strange because if an encrypted email comes in, I briefly can read it in the window pane, but if I revisit the message or double click to open, I get an error and the message is lost forever. Everything worked fine under Lion, only appeared after ML upgrade. "
This comment is not about the article itself and is not a spam.

Problems with Mountain Lion or any other Apple components shall be reported to Apple using https://bugreport.apple.com/, or maybe the Apple CDSA mailing list in this case.

Since I cannot contact the comment author (Mike) and explain why his comment is misplaced I wrote this blog entry.

Documentation

Just above the comments text array I added a documentation:
Please, do only post comments related to the article above.

For general questions, subscribe to and use the muscle mailing list.

Your comment may be moderated and will not appear until then. No need to repost the same comment.

Maybe the documentation is not visible enough, or not clear enough. Please add your comments :-)

Conclusion

My blog is not a forum.

I do not work at Apple and do not plan to provide Apple support for free.