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

Showing posts with label ATR. Show all posts
Showing posts with label ATR. Show all posts

Friday, May 20, 2022

ATR parsing in JSON

I updated my ATR parsing web site at https://smartcard-atr.apdu.fr/ to add the option to get the result not in an HTML page but as a JSON document.

If you do not yet know this service you can read "Parsing an ATR: new web site URL" to get some history. 


JSON

The URL for the JSON service is https://smartcard-atr.apdu.fr/V1/parse2json?ATR=3BFF9700008131FE4380318065B0846160FB120FFD8290000D.

It is the same as for the HTML output https://smartcard-atr.apdu.fr/parse?ATR=3BFF9700008131FE4380318065B0846160FB120FFD8290000D except you replace "parse" by "V1/parse2json" in the URL.

Of course you update the ATR parameter value to use the ATR value you want to parse.

Examples

You can use it to get the description of a particular field by piping the result in the jq command.

jq is a lightweight and flexible command-line JSON processor.

For example to get the meaning of the TA1 byte you can use:

$ curl -s https://smartcard-atr.apdu.fr/V1/parse2json?ATR=3B12953606 | jq '.TA."1"'
{
  "description": "Fi=512, Di=16, 32 cycles/ETU (125000 bits/s at 4.00 MHz, 156250 bits/s for fMax=5 MHz)",
  "value": 149
}

Or for just the TA1 description:

$ curl -s https://smartcard-atr.apdu.fr/V1/parse2json?ATR=3B90160187 | jq '.TA."1".description'
"Fi=372, Di=32, 11.625 cycles/ETU (344086 bits/s at 4.00 MHz, 430107 bits/s for fMax=5 MHz)"

 

Card matching

I also added the possibility to get the cards matching a given ATR.

For example: https://smartcard-atr.apdu.fr/V1/match?ATR=3B8F800180318065B0850300EF120FFE82900072

$ curl -s https://smartcard-atr.apdu.fr/V1/match?ATR=3B8F800180318065B0850300EF120FFE82900072 | jq
{
  "3B 8F 80 01 80 31 80 65 B0 .. .. .. .. 12 0F FE 82 90 00 ..": [
    "IDPrime MD 3810 T=Contactless (Prox DU)"
  ],
  "3B 8F 80 01 80 31 80 65 B0 85 03 00 EF 12 0F FE 82 90 00 72": [
    "Gemalto IDPrime MD 3840",
    "http://www.gemalto.com/dwnld/6891_IDPrimeMD3840_Product_Datasheet_May14.pdf"
  ]
}

Because of the joker mechanism using the character '.' it is possible that one ATR matches more than one "card".


Conclusion

If you have ideas how to improve the service just tell me.

Sunday, March 22, 2020

ATR statistics: ATR list growth (part 2)

In January 2016 I started a study of each byte contained in a smart card ATR. See "ATR list study".

My goal was to publish one new article every week. So with 19 bytes that was a job for 5 months. But it took me more than 4 years! I imagine it is because of some lack of time and/or motivation.

My first article was about the ATR list growth. In January 2016 I had 2098 ATRs in the list. Now I have 3316 ATRs in the list and the number is still growing.

Graph


The red line indicates the position in January 2016.

New ATRs only

In 2016 the linear regression for the graph was y = 6.308x10-6 x - 940.4.
For the last 4 years it is y = 9.381x10-6 x - 2409.7

The growth is now 48% faster than before. Woah!

I guess that is because it is very simple to submit a new ATR using the web interface at https://smartcard-atr.apdu.fr/. Before I create this service, in 2010, you had to send me a new ATR by email. Now you just (mostly) click on a button.

No, I will not re-compute all the statistics with the new, more complete, ATR list.

Thank you

to all of you who submit new ATRs.

ATR statistics: TCK - Check byte TCK (conditional)

Article from the series "ATR statistics".

TCK - Check byte TCK (conditional)

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.
The ChecK byte (if present) allows a check of the integrity of the data in the ATR. If present, TCK is the Exclusive OR of the bytes in the ATR from T0 (included) to TCK (excluded).
TCK shall be present if and only if any of the TDi present in the ATR encodes a value of T other than 0.

TCK#%
110353.23 %
0x001235.94 %
0x1290.43 %
0x2890.43 %
0x0580.39 %
0x8980.39 %
0x9980.39 %
0xC180.39 %
0x0370.34 %
0x0970.34 %
0x0E70.34 %
0x1670.34 %
0x1C70.34 %
0x3870.34 %
0x4370.34 %
0x6570.34 %
0x8870.34 %
0x8C70.34 %
0xA570.34 %
0xB770.34 %
0x0660.29 %
0x0D60.29 %
0x1560.29 %
0x1B60.29 %
0x4A60.29 %
0x5260.29 %
0x5960.29 %
0x5A60.29 %
0x6260.29 %
0x6A60.29 %
0x6D60.29 %
0x7660.29 %
0x7760.29 %
0x7A60.29 %
0x7F60.29 %
0x8360.29 %
0x9060.29 %
0x9C60.29 %
0xA160.29 %
0xA960.29 %
0xF360.29 %
0xFF60.29 %
0x-150.24 %
0x0A50.24 %
0x0F50.24 %
0x1450.24 %
0x1850.24 %
0x1E50.24 %
0x3150.24 %
0x3A50.24 %
0x3C50.24 %
0x4550.24 %
0x5850.24 %
0x6B50.24 %
0x7550.24 %
0x7E50.24 %
0x8050.24 %
0x8450.24 %
0x8F50.24 %
0x9850.24 %
0xB650.24 %
0xBD50.24 %
0xC450.24 %
0xCC50.24 %
0xD250.24 %
0xDA50.24 %
0xFE50.24 %
0x0740.19 %
0x1740.19 %
0x1940.19 %
0x1A40.19 %
0x1D40.19 %
0x2140.19 %
0x2440.19 %
0x3240.19 %
0x3940.19 %
0x3F40.19 %
0x4940.19 %
0x4C40.19 %
0x5C40.19 %
0x5E40.19 %
0x6040.19 %
0x6340.19 %
0x6840.19 %
0x6C40.19 %
0x7040.19 %
0x7140.19 %
0x7440.19 %
0x7940.19 %
0x8640.19 %
0x8A40.19 %
0x9140.19 %
0x9540.19 %
0x9B40.19 %
0x9D40.19 %
0x9F40.19 %
0xA040.19 %
0xA240.19 %
0xA640.19 %
0xB040.19 %
0xB440.19 %
0xBE40.19 %
0xC940.19 %
0xD040.19 %
0xD640.19 %
0xE040.19 %
0xE140.19 %
0xE940.19 %
0xEC40.19 %
0xF840.19 %
0x0130.14 %
0x0230.14 %
0x0830.14 %
0x0C30.14 %
0x1F30.14 %
0x2A30.14 %
0x3030.14 %
0x3330.14 %
0x3D30.14 %
0x4730.14 %
0x4D30.14 %
0x4E30.14 %
0x4F30.14 %
0x5330.14 %
0x5530.14 %
0x5730.14 %
0x5B30.14 %
0x6F30.14 %
0x7230.14 %
0x7830.14 %
0x7B30.14 %
0x7D30.14 %
0x8230.14 %
0x9230.14 %
0x9430.14 %
0x9730.14 %
0x9A30.14 %
0x9E30.14 %
0xA830.14 %
0xAA30.14 %
0xAB30.14 %
0xAD30.14 %
0xB130.14 %
0xB930.14 %
0xBC30.14 %
0xC230.14 %
0xC530.14 %
0xCF30.14 %
0xD330.14 %
0xD430.14 %
0xD730.14 %
0xDF30.14 %
0xEF30.14 %
0xF230.14 %
0xF430.14 %
0xF730.14 %
0xFA30.14 %
0x1020.10 %
0x1120.10 %
0x1320.10 %
0x2220.10 %
0x2520.10 %
0x2620.10 %
0x2720.10 %
0x2920.10 %
0x2B20.10 %
0x2D20.10 %
0x2E20.10 %
0x3520.10 %
0x3620.10 %
0x3B20.10 %
0x4020.10 %
0x4120.10 %
0x4820.10 %
0x5020.10 %
0x5120.10 %
0x5420.10 %
0x5D20.10 %
0x5F20.10 %
0x6420.10 %
0x6620.10 %
0x6720.10 %
0x6920.10 %
0x7320.10 %
0x7C20.10 %
0x8520.10 %
0x8720.10 %
0x8B20.10 %
0x8D20.10 %
0x8E20.10 %
0xAC20.10 %
0xAF20.10 %
0xBA20.10 %
0xBB20.10 %
0xC320.10 %
0xC720.10 %
0xC820.10 %
0xD520.10 %
0xD820.10 %
0xDC20.10 %
0xDD20.10 %
0xDE20.10 %
0xE420.10 %
0xE520.10 %
0xE820.10 %
0xEA20.10 %
0xEB20.10 %
0xF020.10 %
0xF620.10 %
0xFB20.10 %
0xFC20.10 %
0xFD20.10 %
0x0410.05 %
0x0B10.05 %
0x2310.05 %
0x2C10.05 %
0x2F10.05 %
0x3E10.05 %
0x4210.05 %
0x4610.05 %
0x5610.05 %
0x6110.05 %
0x8110.05 %
0x9310.05 %
0x9610.05 %
0xA310.05 %
0xA710.05 %
0xAE10.05 %
0xB210.05 %
0xB310.05 %
0xB510.05 %
0xC610.05 %
0xCA10.05 %
0xCB10.05 %
0xCE10.05 %
0xD110.05 %
0xD910.05 %
0xDB10.05 %
0xE210.05 %
0xE310.05 %
0xEE10.05 %
0xF110.05 %
0xF510.05 %
0xF910.05 %


A large part (53%) or ATR do not have a TCK. These cards are T=0 only.

Some ATR have a TCK of 0 but this value is invalid. For example with 3B 88 80 01 00 00 00 00 77 83 95 00 00.
In most cases the TCK has a value of 0 but that is because a pattern is used in the ATR matching. For example with 3B 8C 80 01 04 43 FD 00 00 00 00 00 00 00 00 00 00. The pattern used to match the ATR is "3B 8C 80 01 04 43 FD .. .. .. .. .. .. .. .. .. .." to accept any value for the "." but my program replaced any "." by a "0".

Some ATR should have an ATR but do NOT contain it. For example with 3B 9E 96 80 1F C7 80 31 E0 73 FE 21 1B 66 D0 01 77 97 0D 00. My parsing program indicates TCK = 0x-1 in this case but that is only a way to indicate a missing TCK. Only 4 ATRs are in this category.

Since the TCK is a checksum no special value is expected. So it is not surprising that the values from 1 to 255 have a mostly equal distribution.

ATR statistics: Historical bytes - Historical bytes Ti (optional)

Article from the series "ATR statistics"

Historical bytes Ti (optional)

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

From Wikipedia https://en.wikipedia.org/wiki/Answer_to_reset#Historical_bytes_Ti:
Historical Characters Ti for i≥1, if present (as defined by K coded in T0), typically hold Information about the Card Builder, Type of Card (Size etc.), Version number and the State of the Card.

You can read the previous article about the T0 byte at ATR statistics: T0 - Format byte.

Regarding the T0 high nibble values we have:

hbn#%
0x0F74335.86 %
0x0E21210.23 %
0x0D1507.24 %
0x071366.56 %
0x051286.18 %
0x081165.60 %
0x0B1155.55 %
0x0A1075.16 %
0x09904.34 %
0x06864.15 %
0x0C723.47 %
0x04462.22 %
0x02401.93 %
0x03150.72 %
0x00130.63 %
0x0130.14 %




A large part (38%) of the ATR have 15 (0x0F) historical bytes, i.e. the maximum size.

The bytes can contain application information like for 3B 6F 00 FF 00 56 72 75 54 6F 6B 6E 73 30 20 00 00 90 00
Historical bytes00 56 72 75 54 6F 6B 6E 73 30 20 00 00 90 00
Category indicator byte: 0x00 (compact TLV data object)
Tag: 5, Len: 6 (card issuer's data)
Card issuer data: 72 75 54 6F 6B 6E "ruTokn"
Tag: 7, Len: 3 (card capabilities)
Selection methods: 48
- DF selection by file identifier
- DF selection by path
Data coding byte: 32
- Behaviour of write functions: proprietary
- Value 'FF' for the first byte of BER-TLV tag fields: valid
- Data unit in quartets: 0
Command chaining, length fields and logical channels: 0
- Logical channel number assignment: No logical channel
- Maximum number of logical channels: 1
Mandatory status indicator (3 last bytes)
LCS (life card cycle): 0 (No information given)
SW: 90 00 ()
or contain only the card name like for 3B 6F 00 FF 52 53 41 53 65 63 75 72 49 44 28 52 29 31 30
Historical bytes52 53 41 53 65 63 75 72 49 44 28 52 29 31 30
Category indicator byte: 0x52(proprietary format) "SASecurID(R)10"

I do not think it is important to detail all the possible information contained in the historical bytes.

For those who are interested you can read the ISO 7816-4 (note: not the 7816-3) chapter "8.1.1 Historical bytes".

Saturday, March 21, 2020

ATR statistics: TC4

Article from the series "ATR statistics".

TC4

TC4 should have the same meaning as TC3.

For T = 1: type of error detection code used

Bit 1 of the first TC for T=1 indicates the error detection code to be used:
  • CRC if bit 1 is set to 1;
  • LRC (default value) if bit 1 is set to 0.
Bits 8 to 2 of the first TC for T=1 are reserved for future use and shall be set to 0.

TC4#%
2072100.00 %

In my list of ATR none of them defines an TC4.

Sunday, February 2, 2020

User eXperience fixes for "Smart card ATR parsing"

Smart card ATR parsing

My web site/service "Smart card ATR parsing" is used to parse smart card ATR. You can read the previous article "Parsing an ATR: new web site URL" to get some background history.

If you have an ATR I do not already have in my database you can submit it with a description of the corresponding smart card.

Problem

I sometimes receive strange ATR to be added the list. For example I just received these 2 ATRs:
What is strange with these 2 ATRs is that:
  1. I already have a shorter version in my list
  2. they have 4 extra bytes at the end
  3. these 4 extra bytes "3B 02 14 50" look like another ATR
At first I thought of a corrupted ATR or a bogus reader or driver that mixes 2 ATRs.
But then I realised that the value "3B 02 14 50" is the default value I use for the ATR input field. So if you copy & paste a new ATR value without removing the default value then the default value is appended to your ATR.


Solution

The solution is now obvious. The problem is with my web site.
The value "3B 02 14 50" is now a placeholder= and not a value=. You can copy & paste a new ATR in the input field and the "3B 02 14 50" will disappear.

Conclusion

I was aware of this problem. I used to first select the default value "3B 02 14 50" to replace it with the real ATR. I thought every body would do the same as me. I was wrong and the User eXperience was bad.

The web site should now be more useful to my users and also easier to use.
Do not hesitate to complain if you find a bug or want to suggest a UX improvement.

Wednesday, October 9, 2019

Parsing an ATR: old site decommisionned

I modified the web site at https://smartcard-atr.appspot.com/ to automatically redirect to https://smartcard-atr.apdu.fr/ (after 10 seconds so you have some time to read the message).

The idea is to tell people that the service has moved. You should use only the new site now. See also "Parsing an ATR: new web site URL".

I do not want to use Google App Engine (GAE) any more and do not plan to maintain the old web site (hosted at GAE). So instead of giving access to an unmaintained code I redirect to the new and maintained web site.

Please update your bookmarks.

Friday, September 6, 2019

Parsing an ATR: new web site URL

History

Since the beginning (in 2009) the Smart card ATR parsing service was hosted on Google App Engine. This is because the Google service is/was free of charge and was a new technology to discover.

You can see the GUI evolution of the ATR parsing service in time from my previous blog articles:

Then I received an email from Google:
We’re writing to you to let you know that the legacy standalone App Engine SDK (appcfg) will be deprecated as of July 30, 2019, in favor of the Generally Available Google Cloud SDK (Cloud SDK).

You will need to migrate your projects off the legacy standalone SDK (appcfg) before the shutdown date of July 30, 2020. Projects included in this email will be whitelisted to use the legacy standalone SDK (appcfg) until July 30, 2020, but any new projects will not be able to use the legacy standalone SDK (appcfg) from July 30, 2019.

Migration

In the migration to the Google Cloud SDK I wanted to also migrate from Python 2 to Python 3, and from Bootstrap 3 to Bootstrap 4.  But then I discovered that I would have to migrate from webapp to Flask (not a bad idea) and that some Google API I used were not available for Python 3:
  • user identification
  • sending email
I also discovered that it is not possible to deploy an application using the new SDK without creating a billing account. I had to give my credit card number to Google. Google offers US $300 for 1 year but I do not plan to play extra money for this free service.

Note: if you want to help me see "How to help my projects? Send me bitcoins!" or contact me directly.

Problem

The problem is that I use mail service to send me an email when a new ATR is submitted, and I use the user identification service to get the user login so I can contact him/her in case the card description is incorrect.

Backup plan

I tried to use the smtplib Python module to send emails. The code works fine in local/debug mode but not when deployed in Google cloud. I have no idea why it failed.
Problem: I deployed the non-working solution over the normal service (yes, bad idea). So the service was broken and I needed a solution (very) quickly.

Self hosting

Since no Google services I used was available any more, the new solution was using only free software dependencies. And the smtplib solution was not working on Google cloud.

The solution was to host the ATR parsing service myself.

New service

The service is now available at https://smartcard-atr.apdu.fr/.

The old URL https://smartcard-atr.appspot.com/ is still available for now. I plan to change the main page with a redirection to the new URL at some point.

Contact me if you find a problem or want to discuss an evolution of the service.

Conclusion

Google forced me to migrate.
I don't think it was in their plans to force me to migrate outside of their cloud services 😉.

Thursday, May 30, 2019

Surprising request from a law firm

A few weeks ago I received this email:

From: legal@axur.com
To: Ludovic.Rousseau@gmail.com
Subject: [high priority] [19444663] Content Removal - SENSITIVE DATA

Dear Sir/Madam,

Our company, AXUR, represents C.......R in issues involving the violation of intellectual property and fraud on the Internet.

C.......R is the only company authorized to use the trademark and owns or licenses numerous trademark registrations worldwide, including, but not limited to the following registration number 825503736.

The trademarks, logos, words and phrases registered by C.......R shall be exclusively used by C.......R and any other use by a third party constitutes a trademark infringement.

It has come to our attention that the reported content provides related content (see attached) to the trademark without having obtained prior written authorization from C.......R . More specifically, this content disclosures SENSITIVE DATA from our client or its customer, creating a Likelihood of Confusion between the trademark and the reported content.

Furthermore, by misusing the trademark on your website, you are also diluting its use, because it weakens the ability of brand identification as a single source of research and may lead consumers to believe that there is some association between C.......R and your website.

Official Website: https://www.c.......rsolucoes.com.br/

Considering the violation of intellectual property rights of C.......R on your website, we kindly request that you remove all content available on the attached URL(s) which use the above mentioned trademark without having obtained prior authorization.

In order to avoid a lawsuit from a federal court, please, send confirmation that this email was received along with your guarantee to comply with the requests reported above.

Under penalty of perjury, we affirm that AXUR is authorized to act on behalf of the C.......R and this notification is in accordance with International Regulations of Internet and Intellectual Property Offices.

Should you require further information or should you prefer to discuss this issue, please do not hesitate to contact us through the e-mail address listed on the signature of this message.

Sincerely,

AXUR
Legal Team
legal@axur.com

ATTACHMENT:
https://raw.githubusercontent.com/LudovicRousseau/pcsc-tools/master/smartcard_list.txt

I replaced the real trademark by "C.......R" to avoid receiving a new email asking to remove this blog article :-)

I also received the same email but with a different subject "[high priority] [19444667] Content Removal" for the same list but with a different URL: https://github.com/LudovicRousseau/pcsc-tools/blob/master/smartcard_list.txt

Actions

I updated the list of ATR to remove any mention of "C.......R".

I asked confirmation from legal@axur.com that the ATR list was OK now. I got no answer.

I also wrote them I would blog about it and got no answer as well.

Sunday, March 17, 2019

ATR statistics: TA4

Article from the series "ATR statistics"

TA4

The first TA for T=15 encodes the clock stop indicator (X) and the class indicator (Y). The default values are X = "clock stop not supported" and Y = "only class A supported".

bits 8 and 7 indicate whether the card supports clock stop (≠ 00) or not (= 00) and, when supported, which state is preferred on the electrical circuit CLK when the clock is stopped.
  • 00b: Clock stop not supported
  • 01b: State L
  • 10b: State H
  • 11b: No preference

bits 6 to 1 indicate the classes of operating conditions accepted by the card. Each bit represents a class: bit 1 for class A, bit 2 for class B and bit 3 for class C.
  • 00 0001b: A only
  • 00 0010b: B only
  • 00 0100b: C only
  • 00 0011b: A and B
  • 00 0110b: B and C
  • 00 0111b: A, B and C
  • Any other value: RFU

TA4#%
200996.96 %
0x03271.30 %
0x83150.72 %
0xC3120.58 %
0x0760.29 %
0x4320.10 %
0xC710.05 %



Clock stop#%
not supported3352.38 %
state L23.17 %
state H1523.81 %
no preference1320.63 %

The class defines the current voltage the card can use:
  • class A: 5 V
  • class B: 3 V
  • class C: 1.8 V
Some readers can't provide a tension of 5V. For example the Gemalto CT1100 reader does only provide 3 V. The default value for TA4 is "only class A supported". Some (old) cards require a voltage of 5 V to work and will not work with a CT1100. That can be surprising.

Class#%
A & B5688.89 %
A & B & C711.11 %

ATR statistics: TD3 - Structural, encodes Y4 and T

Article from the series "ATR statistics"

TD3 - Structural, encodes Y4 and T

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

Refer to TD1 - Structural, encodes Y2 and T since the definition of TD3 is identical to TD1.

TD3#%
200996.96 %
0x1F612.94 %
0x3F20.10 %



TD3 (as the other TDi bytes) is structural and indicates:
  • How to interpret the other ATR bytes
  • What communication protocol the card wants to use

For 96.96% of the ATRs no TD3 is present. So no other TA4, TB4, TC4 or TD4 is present and no new protocol is defined so the protocol(s) defined by TD1 and TD2 will be used.

For 2.94% of the ATRs TD3 = 0x1F. The high nibble is 0001b so TA4 is present and T=15 protocol is defined. One such ATR is 3B 94 18 81 B1 80 7D 1F 03 19 C8 00 50 DC.

For 0.10% of the ATRs TD3 = 0x3F. The high nibble is 0001b so TA4 and TB4 are present and T=15 protocol is defined. One such ATR is 3B DE 18 FF 81 F1 FE 43 00 3F 07 83 44 45 53 46 69 72 65 38 20 53 41 4D 2D 58 17.

ATR statistics: TC3

Article from the series "ATR statistics".

TC3

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

For T = 1: type of error detection code used

Bit 1 of the first TC for T=1 indicates the error detection code to be used:
  • CRC if bit 1 is set to 1;
  • LRC (default value) if bit 1 is set to 0.
Bits 8 to 2 of the first TC for T=1 are reserved for future use and shall be set to 0.

TC3#%
201797.35 %
0x00552.65 %

In my list of ATR the only redundancy code used if LRC. I found no card using CRC.

LRC is the default algorithm. But 55 cards explicitly set it. I have no explanation for that.

Sunday, May 13, 2018

ATR statistics: TB3 - Global after T=15 in TDi–1

Article from the series "ATR statistics".

TB3 - Global after T=15 in TDi–1


For T=1 protocol the first TBi encodes Block Waiting Integer and Character Waiting Integer. The high nibble encodes BWI. The low nibble encodes CWI.

For T=15 protocol TBi the coding is defined in the document ETSI TS 102 221 V10.0.0 (2011-12) chapter "6.3.3 Global Interface byte"

TB3#%
156575.53 %
0x4528813.90 %
0x55381.83 %
0x47231.11 %
0x5D211.01 %
0x43180.87 %
0x40170.82 %
0x75140.68 %
0x65110.53 %
0x4290.43 %
0x5890.43 %
0x7D80.39 %
0x4D70.34 %
0x9F70.34 %
0xA050.24 %
0x3540.19 %
0x1530.14 %
0x3430.14 %
0x5730.14 %
0x3720.10 %
0x4420.10 %
0x4920.10 %
0x5220.10 %
0x6720.10 %
0x2410.05 %
0x4110.05 %
0x5310.05 %
0x5910.05 %
0x6310.05 %
0x6910.05 %
0x6D10.05 %
0x7310.05 %
0x9E10.05 %

T=1 protocol

The list above is not really informative since both BWI and CWI are coded in the same byte.

BWI


BWI#%
434973,01 %
57315,27 %
7224,60 %
6163,35 %
391,88 %
961,26 %
120,42 %
210,21 %


CWI


CWI#%
5 343 72 %
1336 8 %
7 30 6 %
3 18 4 %
0 15 3 %
2 10 2 %
8 9 2 %
4 6 1 %
155 1 %
9 4 1 %
1 1 0 %
141 0 %


T=15 protocol

I my list I have only 5 cards with a TB3 for T=15. They all have the value TB3 = 0xA0 for "UICC-CLF interface supported as defined in TS 102 613".

Monday, September 25, 2017

ATR statistics: TA3 - Specific to T after T from 0 to 14 in TDi–1

Article from the series "ATR statistics".

TA3 - Specific to T after T from 0 to 14 in TDi–1

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

For T = 1: maximum block size the card can receive. Encodes IFSC.
If T = 15: supported supply voltages and low power modes

TA3#%
137966.55 %
0xFE38818.73 %
0xC71095.26 %
0xC3351.69 %
0x80241.16 %
0x20190.92 %
0x43140.68 %
0x3C90.43 %
0x4780.39 %
0x8670.34 %
0xA070.34 %
0x0060.29 %
0x0360.29 %
0x5060.29 %
0x4250.24 %
0xC650.24 %
0x4040.19 %
0x6040.19 %
0x7040.19 %
0x6630.14 %
0x9030.14 %
0xFC30.14 %
0xFF30.14 %
0x4620.10 %
0x7620.10 %
0xF020.10 %
0xFA20.10 %
0xFB20.10 %
0x0710.05 %
0x2610.05 %
0x3A10.05 %
0x3D10.05 %
0x5210.05 %
0x6410.05 %
0x7C10.05 %
0x8310.05 %
0x8710.05 %
0xC210.05 %
0xEF10.05 %



The interpretation of TA3 depends on the protocol in use.

19% of ATRs have TA3 = 0xFE :

IFSC

The IFSC repartition is as follows:
IFSC#%
25436675,78 %
128214,35 %
32193,93 %
6091,86 %
13471,45 %
16071,45 %
8061,24 %
051,04 %
6440,83 %
9640,83 %
11240,83 %
6630,62 %
10230,62 %
14430,62 %
25230,62 %
25530,62 %
7020,41 %
11820,41 %
24020,41 %
25020,41 %
25120,41 %
3810,21 %
5810,21 %
8210,21 %
10010,21 %
12410,21 %
23910,21 %



With a logarithmic scale:


75% of ATRs with a IFSC defined in TA3 (so T=1 cards only) defines IFSC = 254.

Supported supply voltages

It is also possible to get the repartition of the class:
Class#%
A 5V B 3V C 1.8V11449,57 %
A 5V B 3V10646,09 %
B 3V C 1.8V52,17 %
B 3V31,30 %
B 3V C 1.8V D RFU E RFU20,87 %



50% of ATRs defining the class supports the 3 classes: A, B and C for 5 Volts, 3 Volts and 1.8 Volt.

46% of ATRs defining the class supports the classes A and B but not C.

2 cards declare the support of classes D and E that are RFU. They are 3B D9 18 00 C0 09 10 FE 54 59 46 4F 4E 45 00 00 00 and 3B DD 96 00 80 10 FE 80 31 80 63 01 FF C0 73 B3 21 1B 81 05. It may be a bug in the parsing since the class is defined only after T=15 protocol. But in the two examples the latest defined protocol is T=0. The ATRs may not be valid.

ATR statistics: TD2 - Structural, encodes Y3 and T

Article from the series "ATR statistics"

TD2 - Structural, encodes Y3 and T

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

Refer to TD1 - Structural, encodes Y2 and T since the definition of TD2 is identical to TD1.

TD2#%
112354.20 %
0x3139318.97 %
0x0125012.07 %
0x1F1788.59 %
0x71502.41 %
0xB1482.32 %
0x91100.48 %
0x2160.29 %
0x3F50.24 %
0xF150.24 %
0x1020.10 %
0x1120.10 %



TD2 (as the other TDi bytes) is structural and indicates:
  • How to interpret the other ATR bytes
  • What communication protocol the card wants to use

For 54% of the ATRs no TD2 is present. So no other TA3, TB3, TC3 or TD3 is present and no new protocol is defined so the protocol defined by TD1 (if any) will be used.

For 19% of the ATRs TD2 = 0x31. The high nibble is 0011b so TA3, TB3 are present and T=1 protocol is defined. One such ATR is 3B 82 81 31 76 43 C0 02 C5.

For 12% of ATRs TD2 = 0x01. The high nibble is 0000b so no other TA3, TB3, TC3 or TD3 is present and T=1 protocol is defined. One such ATR is 3B 84 80 01 00 00 90 00 95.

0.10% of cards have TD2 = 0x10 and so (re)define the use of T=0. In fact what is important here is the high nibble of TD2 0001b that defines that TA3 is present. One such ATR is 3B DD 96 00 80 10 FE 80 31 80 63 01 FF C0 73 B3 21 1B 81 05.

I will not document all the other cases. I let this exercise to the reader.

Tuesday, March 14, 2017

ATR statistics: TC2 - Specific to T=0

Article from the series "ATR statistics"

TC2 - Specific to T=0

If present in the Answer-to-Reset, the interface byte TC2 encodes the waiting time integer WI over the eight bits, except the value '00' reserved for future use. If TC2 is absent, then the default value is WI = 10.

TC2#%

188991.17 %
0x0A472.27 %
0xFF200.97 %
0x10190.92 %
0x14180.87 %
0x0F140.68 %
0x96110.53 %
0x20100.48 %
0x8090.43 %
0x6050.24 %
0x1840.19 %
0x1E40.19 %
0x2A30.14 %
0x7830.14 %
0x0020.10 %
0x2320.10 %
0x3220.10 %
0x3E20.10 %
0xF020.10 %
0x0910.05 %
0x1C10.05 %
0x2810.05 %
0x6410.05 %
0xFA10.05 %
0xFE10.05 %



TC2 is only for T=0 cards.
It is surprising that 47 cards declare TC2=0x0A knowing that this is the default value.
It is also surprising that 2 cards (3B 95 15 40 00 68 01 02 00 00 and 3B A7 00 40 00 80 65 A2 08 00 00 00) are using the reserved value 0.

Wednesday, December 14, 2016

ATR statistics: TB2 - Global, deprecated

Article from the series "ATR statistics"

TB2 - Global, deprecated

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

From Wikipedia https://en.wikipedia.org/wiki/Answer_to_reset#Interface_byte_TB2
TB2, if present, is global. The usage of TB2 is deprecated since the 2006 edition of the standard, which prescribes that cards should not include TB2 in the ATR, and readers shall ignore TB2 if present.

In the 1997 edition of the standard, TB2 (8th to 1st bit) encode PI2, which when in range 50..250 (other values being RFU) encode VPP in increments of 0.1 V, and subsumes the coarser indication given by PI1 of TB1. Refer to that section for why modern Smart Cards have no use of VPP, and thus of TB2.

Historical note: Provision for TB2 did not exist in ISO/IEC 7816-3:1989, and was introduced because VPP = 12.5 V became a popular value in EEPROM technology, replacing 25 V and 21 V.

TB2#%
207099.90 %
0x3F10.05 %
0x4510.05 %


Only 2 cards use a TB2 value.
I agree these 2 ATRs are quiet unusual.

Sunday, December 11, 2016

ATR statistics: TA2 - Global, specific mode byte

Article from the series "ATR statistics"

TA2 - Global, specific mode byte

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

From Wikipedia https://en.wikipedia.org/wiki/Answer_to_reset#Interface_byte_TA2
Interface byte TA2, if present, is global, and is named the specific mode byte.

Presence of TA2 commands that the reader use specific mode as defined by TA2 and earlier global bytes, rather than negotiable mode when TA2 is absent.

TA2 encodes in its 4 low-order bits an integer T defining the protocol required by the card, in the convention used for TD1 (EMV prescribes that a card which T encoded in TA2 does not match that in TD1 shall be rejected).

The 5th bit is 0 to encodes that the required ETU duration is Fi/Di clock cycles as defined by TA1 (or its default value if absent); or 1 to indicate that the ETU duration is implicitly known (by some convention, or setting of the reader; EMV prescribes that such card shall be rejected).

The 6th and 7th bit are reserved for future use; 0 indicates not used.

The 8th bit is 1 to indicate that the card is unable to change the negotiable/specific mode (that is, does not propose other settings); or 0 to indicate that card has that ability (perhaps after a warm ATR).

Historical note: Provision for specific mode did not exist in ISO/IEC 7816-3:1989. Back then, the interface character TA2 had no particular name or function, and was specific (to the protocol introduced by TD1). ISO/IEC 7816-3:1997 introduced the specific mode and the specific mode byte, with interim note helping cards with specific mode byte TA2 in their ATR dealing with a reader that did not implement specific mode.

TA2#%
198395.70 %
0x81482.32 %
0x80311.50 %
0x00100.48 %


TA2 is used by only 4.30% of cards. 95.70% of smart cards in my list have no TA2 defined.

  • 0x81 indicates "Protocol to be used in spec mode: T=1 - Unable to change - defined by interface bytes".
    • The 4 low-order bits are set to 0001b so T=1 protocol.
    • The 8th bit set to 1 to indicate unable to change the negotiable/specific mode
  • 0x80 indicates "Protocol to be used in spec mode: T=0 - Unable to change - defined by interface bytes"
    • The 4 low-order bits are set to 0000b so T=0 protocol.
    • The 8th bit set to 1 to indicate unable to change the negotiable/specific mode
  • 0x00 indicates "Protocol to be used in spec mode: T=0 - Capable to change - defined by interface bytes"
    • The 4 low-order bits are set to 0000b so T=0 protocol.
    • The 8th bit set to 0 to indicate the card is able to change the negotiable/specific mode

Sunday, November 6, 2016

ATR statistics: TD1 - Structural, encodes Y2 and T

Article from the series "ATR statistics"

TD1 - Structural, encodes Y2 and T

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

From Wikipedia https://en.wikipedia.org/wiki/Answer_to_reset#Interface_bytes_TDi:
Interfaces bytes TDi for i≥1, if present, are structural.
TDi encodes in its 4 high-order bits the presence of at most 4 other interface bytes: TAi+1 (resp. TBi+1, TCi+1, TDi+1) follow, in that order, if the 5th (resp. 6th, 7th, 8th) bit of TDi is 1.
TDi encodes in its 4 low-order bits (4th MSbit to 1st LSbit) an integer T, in range [0..15]. T = 15 is invalid in TD1, and in other TDi qualifies the following TAi+1 TBi+1, TCi+1, TDi+1 (if present) as global interface bytes. Other values of T indicates a protocol that the card is willing to use, and that TAi+1 TBi+1, TCi+1, TDi+1 (if present) are specific interface bytes applying only to that protocol. T = 0 is a character-oriented protocol. T = 1 is a block-oriented protocol. T in the range [3..14] is RFU.
Historical note: provision for dynamically qualifying interface bytes as global using T = 15 did not exist in ISO/IEC 7816-3:1989.

TD1#%
89943.39 %
0x8045922.15 %
0x8137217.95 %
0x40954.58 %
0x00693.33 %
0x91462.22 %
0xC0452.17 %
0xC1271.30 %
0x10221.06 %
0x50160.77 %
0x0190.43 %
0x0E80.39 %
0x1120.10 %
0x1F10.05 %
0x3110.05 %
0x3F10.05 %



TD1 (as the other TDi bytes) is structural and indicates:
  • How to interpret the other ATR bytes
  • What communication protocol the card wants to use

For 43% of the ATRs no TD1 is present. So no other TA2, TB2, TC2 or TD2 is present and no protocol is defined so the default T=0 will be used.

For 22% of ATRs TD1 = 0x80 so bit 8 is set to indicate that a TD2 is present and T=0 is used. One such ATR is 3B 80 80 01 01.

For 17% of ATRs TD1 = 0x81 so, as in the previous case, TD2 is present but T=1 is used. One such ATR is 3B 82 81 31 76 43 C0 02 C5

For 5% of ATRs TD1 = 0x40 so TC2 is present and T=0 is used. One such ATR is 3B 85 40 20 68 01 01 00 00

I will not document all the other cases. I let this exercise to the reader.

One special case is TD1 = 0x?E to indicate the T=14 protocol.

From ISO 7816-3:
The type T refers to a transmission protocol and/or qualifies interface bytes.
  • T=0 refers to the half-duplex transmission of characters specified in clause 10.
  • T=1 refers to the half-duplex transmission of blocks specified in clause 11.
  • T=2 and T=3 are reserved for future full-duplex operations.
  • T=4 is reserved for an enhanced half-duplex transmission of characters.
  • T=5 to T=13 are reserved for future use by ISO/IEC JTC 1/SC 17.
  • T=14 refers to transmission protocols not standardized by ISO/IEC JTC 1/SC 17.
  • T=15 does not refer to a transmission protocol, but only qualifies global interface bytes.

As you can see in the list above "T=14 refers to transmission protocols not standardized by ISO/IEC JTC 1/SC 17." In my list T=14 is used only by pay TV cards like 3B 9F 21 0E 49 52 44 45 54 4F 20 41 43 53 03 83 95 00 80 55.

TD1 = 0x?F is also another special case to indicate T=15, which is not a protocol, and will change the interpretation of the following ATR bytes.

Saturday, September 17, 2016

ATR statistics: TC1 - Global, encodes N

Article from the series "ATR statistics"

TC1 - Global, encodes N

The ISO 7816-3 specification is not public. So I can't copy/paste part of the text. I will use Wikipedia instead.

From Wikipedia https://en.wikipedia.org/wiki/Answer_to_reset#Interface_byte_TC1 (with some edition to remove extra details):

TC1, if present, is global, and encodes the Extra Guard Time integer (N), from 0 to 255 (8th MSbit to 1st LSbit); otherwise, N = 0. N defines how much the Guard Time that the reader must apply varies from a baseline of 12 ETU (corresponding to 1 start bit, 8 data bits, 1 parity bit, and 2 stop bits; with the second stop bit possibly used for an error indication by the receiver under protocol T = 0). The Guard Time is the minimum delay between the leading edge of the previous character, and the leading edge of the next character sent.
Except when N is 255, the Guard Time is: GT = 12 ETU + R*N/f
where:
  • f is the clock frequency being generated by the reader;
  • R is some number of clock cycles, either:
    • per ETU, R = F/D, if T = 15 is absent from the ATR;
    • defined by TA1, R = Fi/Di (or its default value), if T = 15 is present in the ATR.
N = 255 has a protocol-dependent meaning: GT = 12 ETU during PPS (Protocol and Parameters Selection) and protocol T = 0, GT = 11 ETU under protocol T = 1 (corresponding to 1 start bit, 8 data bits, 1 parity bit, and 1 stop bit; with no error indication).
Except under protocol T = 1, the card transmits with a Guard Time of 12 ETU, irrespective of N. Under protocol T = 1, the Guard Time defined by N is also the Character Guard Time (CGT), and applies to card and reader for characters sent in the same direction.
Note: The reader remains bound by the Guard Time GT defined by N when other prescriptions specify another minimum delay between leading edges of characters in different directions, even when that minimum is lower than GT.

Historical note: ISO/IEC 7816-3:1989 only defined that N code the EGT as a number of ETU, the method now used when T = 15 is absent from the ATR. With this convention, cards that allow negotiation of a reduced number of clock cycles per ETU after PPS must also allow a proportionally reduced number of clock cycles for the EGT, which does not match with a common EGT motivation: account for delays before the card can receive the next character. The 1997 edition of the standard introduced that when T = 15 is present in the ATR, N code the EGT as a multiple of the number of clock cycles per ETU coded by TA1, making the EGT effectively independent of the number of clocks cycles per ETU negotiated, while maintaining compatibility with former readers at least if they did not change the number of clock cycles per ETU.

To make it short TC1 defines a time value between characters transmitted between the card and the reader. The default value correspond to a Guard Time of 12 ETU. But the card can specify a bigger value (the card is not fast enough).

TC1#%
91043.92 %
0x0079238.22 %
0xFF28713.85 %
0x02291.40 %
0x03180.87 %
0x01150.72 %
0x0860.29 %
0x0540.19 %
0x0430.14 %
0x0B20.10 %
0x0910.05 %
0x1010.05 %
0x3F10.05 %
0x6410.05 %
0x8110.05 %
0xFE10.05 %


The default value is 0. But 38.22% of cards explicitly define TC1=0.
A total of 82.14% of cards use the default value.
TC1=255 is also a special value not far from the default value of 12 ETU.

The real number of cards that are not fast enough to use the full speed is only of 4.00% (84 cards).