I made some graphical design (using CSS) for my Smart card ATR parsing online application.
I am not a web designer (you may have noticed). But I tried to make the interface nicer.
The new interface looks like:
If you want to work on a better design you are welcome. Contact me.
Related articles:
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, November 23, 2012
Friday, November 2, 2012
PCSC sample in lua
To continue the list of PC/SC wrapper initiated more than two years ago with "PC/SC sample in different languages" I now present a PC/SC sample in lua.
In a previous blog article "cardpeek: A tool to read the contents of smartcards" I presented an application using the lua language to interact with smart cards.
The card functions available from lua are:
One important missing function is an equivalent of
Some work is missing in order to have a complete PC/SC wrapper for lua.
This pseudo-wrapper is the 12th wrapper for PC/SC. What will be the next language?
In a previous blog article "cardpeek: A tool to read the contents of smartcards" I presented an application using the lua language to interact with smart cards.
PC/SC access from lua
Cardpeek is a complete application and not a PC/SC wrapper. The cardpeek author implemented only what was needed for the application instead of a general PC/SC wrapper.The card functions available from lua are:
- connect
- disconnect
- warm_reset
- last_atr
- info
- send
- set_command_interval
- make_file_path
One important missing function is an equivalent of
SCardListReaders(). The list of available readers and selection of the reader to use is not available from the lua code. The reader selection is done by the cardpeek application using C code directly.Some work is missing in order to have a complete PC/SC wrapper for lua.
Source code
function hex_tostring(data)
local r = ""
local i
for i=0,#data-1 do
r = r .. string.char(data[i])
end
return r
end
if card.connect() then
card.tree_startup("ATR")
-- Select applet
select = bytes.new(8, "00 A4 04 00 0A A0 00 00 00 62 03 01 0C 06 01")
sw, resp = card.send(select)
print(string.format("SW: %X", sw))
print(resp)
-- Send command
command = bytes.new(8, "00 00 00 00")
sw, resp = card.send(command)
print(string.format("SW: %X", sw))
print(hex_tostring(resp))
card.disconnect()
end
Remarks
The output is sent to the console using the luaprint() statement. You could also send the output to cardpeek using log.print() instead.Output
In the console
SW: 9000 SW: 9000 Hello world!
In cardpeek
Conclusion
I reported some improvements for cardpeek (issues 13, 14, 15 and 16). One month after, the issues are still open and the proposed patches not applied or reviewed. A bad news concerning the state of the cardpeek project :-(.This pseudo-wrapper is the 12th wrapper for PC/SC. What will be the next language?
Friday, October 26, 2012
cardpeek: A tool to read the contents of smartcards
A few days ago I discovered a nice tool: cardpeek.

It is Free Software and uses the GNU GPL v3 licence.
From the project web site:
You may be unable to run the
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.
From the project:
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.
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
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:
dwMaxAPDUDataSizewIdVendorwIdProduct
- 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.
Possibly identified card: OpenPGP
Possibly identified card: OpenPGP
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 = 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
Parsing 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
Command line
The same software is also available as a command line tool: parseATR.pyBefore
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.
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:
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
Related post "Mac OS X Mountain Lion and smart card status".
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".
Subscribe to:
Posts (Atom)






