background image

...the world's most energy friendly microcontrollers

2014-01-23 - an0820_Rev1.00

7

www.silabs.com

Part 4 of the 7816 standard also defines a file system API to manipulate files and a security service API
allowing smart card and reader to mutually authenticate with each other. This is not discussed further
in this application note.

2.3.1 Protocol Data Units

The data units transmitted in the link-layer protocol is called transmission protocol data units (TPDUs).
These  are  the  packets  of  data  going  between  the  reader  and  the  smart  card.  On  top  of  these  are
the  APDUs,  which  comes  directly  from  the  application  layer  of  the  protocol.  The  APDUs  are  usually
transmitted unaltered by the smart card interface device, but this depends on the level of automatism
supported by the reader. This naming convention is illustrated in Figure 2.5 (p. 7) .

Figure 2.5. Protocol Data Units and Where they Apply

Host  Applicat ion

Sm art  Card 

Reader

Applicat ion Prot ocol 

Dat a Unit s

(APDU)

Transm ission Prot ocol 

Dat a Unit s

(TPDU)

CPU

Physical/ Link-

Layer

APDU

Sm art  Card

2.3.2 T=0 Protocol Introduction

The link-layer protocol is usually one of two variants, either a byte-oriented protocol with error handling
performed on each byte by using a parity bit, or a block-oriented protocol with checksum-based error
detection. The first one, the byte-oriented protocol is called "T=0". The name comes from the indication
of this protocol in the ATR by having one of the bits in one of the T-characters equal to 0. The block-
oriented  protocol  is  called  "T=1".  In  fact  there  is  even  a  T=2  protocol  for  full-duplex  interfaces,  with
T=3-15 reserved for future protocols.

The  T=0  protocol  re-uses  the  same  byte-transmission  format  used  during  the  ATR-sequence.  The
parity error detection and retransmission at byte-level is also re-used. The TPDU-messages exchanged
between reader and smart card has two distinct structures, based on the direction of communication:

• A command, this is sent from reader to smart card. Consists of at least 5 characters named: CLA,

INS, P1, P2, P3, in addition comes a number of data bytes if writing to the smart card.
• CLA: Class designation of the command set to establish a collection of instructions.
• INS: The INS byte is used to identify a specific instruction within a class of instructions identified

by the CLA value.

• P1: Used to specify the addressing used by the [CLA, INS] instruction.
• P2: Also used to specify the addressing used by the [CLA, INS] instruction.
• P3: Specifies the number of data bytes transferred to or from the card as part of the [CLA, INS]

instruction execution.

• A response, this is sent from smart card to reader. Consists of 1 or 2 status characters named SW1

and SW2, in addition comes a number of data bytes if reading from the smart card. The SW1 byte
is also called "procedure-byte" if it is just an ACK or NULL character, indicating that the card is not
finished with the transaction.

Summary of Contents for EFM32

Page 1: ...tocol of a smart card Along with this document there is a working example of a smart card reader implemented using the EFM32 The included software example implements a USB CCID card reader device using the STK3700 Giant Gecko Starter Kit The software example is developed and tested with an ACS Advanced Card Systems Ltd ACOS 1 3 type of smart card This application note includes This PDF document So...

Page 2: ... ISO 14443 and is available in a variety of form factors including plastic cards fobs SIM cards used in GSM mobile phones and USB tokens Smart cards are used in many applications worldwide including Secure ID employee ID badges citizen ID documents electronic passports driver s licenses online authentication devices Healthcare citizen health ID cards physician ID cards portable medical records car...

Page 3: ... and establishing a process that embeds the integrated circuit into the card 7816 2 Cards with contacts Dimensions and location of the contacts The following table contains the contact definition of the electrical contacts according to ISO7816 2 Table 2 1 Smart Card Electrical Connection Contact Designation Use C1 Vcc Power connection through which operating power is supplied to the microprocessor...

Page 4: ...card this application note will mainly relate to the electrical waveforms and transportation of messages described in part 3 and 4 of the standard These parts are discussed in detail in the following sections 2 2 Part 3 Electrical Signal and Transmission Protocol Communication with the smart card takes place over a single bi directional half duplex data line The voltage levels for high low states ...

Page 5: ...eleased ATR Received Vcc Clk Reset IO ATR Data Clock Running Wait 40 000 clock cycles 40 000 clock cycles 2 2 3 Byte Transfers During the power on and reset sequence the smart card answers with its Answer to Reset The transmission of this first data packet is carried out with default communication parameters listed below Baud rate Fclock 372 Clock should be approximately 3 57 MHz resulting in 9 6 ...

Page 6: ...the default protocol used during the ATR sequence T1 T2 TK optional historical characters these characters typically hold information about the card manufacturer type of card size etc version number and the state of the card TCK a conditional check character presence of this byte is indicated by the optional interface characters if present it is exclusive OR of all the bytes in the ATR excluding T...

Page 7: ...alled T 0 The name comes from the indication of this protocol in the ATR by having one of the bits in one of the T characters equal to 0 The block oriented protocol is called T 1 In fact there is even a T 2 protocol for full duplex interfaces with T 3 15 reserved for future protocols The T 0 protocol re uses the same byte transmission format used during the ATR sequence The parity error detection ...

Page 8: ...dicating that the reader should wait for further data or the smart card needs more processing time the SW1 is called a procedure byte indicating that it should not be forwarded to the host application as a response Figure 2 6 p 8 illustrates how transmission of a data packet to the smart card looks like following the T 0 protocol In fact for the T 0 protocol the bytes of the APDU directly overlays...

Page 9: ...nts in the T 0 protocol please see the 7816 standard Reference 4 p 20 2 3 3 T 1 Protocol Introduction The T 1 protocol is more complex than the T 0 protocol The physical interface is still half duplex and uses the same configuration as T 0 T 1 is actually built on top of T 0 but it does not use the T 0 error correction functionality rather it uses a block oriented protocol The main benefits of T 1...

Page 10: ...tocol handling the transmission of APDU packets between the card reader and the USB host The EFM32 implementation also includes the T 0 interface protocol for communication with the smart card itself From here on the EFM32 card reader is referred to as the CCID Figure 3 1 Smart Card USB CCID Device Class Standard USB CCID Device Class Standard EFM32 Smart Card Reader 3 1 USB CCID Standard The CCID...

Page 11: ...standard USART1 in asynchronous mode is used and TIMER0 provides the required clock signal The clock frequency is fixed to 3 5712 MHz which is the baud rate multiplied by 372 This is the default factor of difference between baud rate and clock speed in the 7816 standard Further there is a reset pin and power pins allocated as well as a card insertion detection pin The 7816 standard defines that th...

Page 12: ...k depending on host side smart card driver and software Since the firmware on the EFM32 itself is basically only shuffling data packets back and forth between the smart card and the host computer virtually any card supporting the correct speed and T 0 protocol should be able to communicate with the host computer 3 3 2 Software Algorithm The software algorithm is based on a simple state machine fun...

Page 13: ...ly power to the smart card and it expects the ATR in response The PowerOff message from the PC requests the CCID to power off the smart card and expects only a status message in return indicating the new powered off state All actual communication with the card after the Answer to Reset happens upon XfrBlock messages from the PC Each XfrBlock message contains one APDU which the CCID must send to th...

Page 14: ...Rev1 00 14 www silabs com Figure 3 4 Function Handling Command and Data Transfer with Smart Card Send Command Header CLA INS P1 P3 Wait for Procedure Byte from Card Send Receive Data to from Card Wait for SW1 SW2 and Return Yes If P Byte INS Yes No If P Byte NULL 0x60 No ...

Page 15: ...sed CCID If the procedure byte indicates that the smart card is ready to receive data the CCID proceeds with sending the data to the smart card It then waits for a further procedure byte Note that in the case of successful transaction the procedure byte is in fact the SW1 character and therefore part of the response expected from the host The CCID fetches the SW2 character as well and sends both S...

Page 16: ...ction with the addition of insertion and removal of the card Notice that the CCID does not power up the card until it receives a PowerOn messages from the host The CCID can implement automatic power on at insertion of a card but must then also advertise this feature in the USB descriptor When the card is removed the CCID should power off the card to protect from damage It advertises that the card ...

Page 17: ...out error as this will trigger a power off of the smart card which is always safe to do upon error conditions 3 5 Use the Smart Card Reader with a PC In order to make useful communication between a PC and the smart card happening the host computer need software that can interact with the card Typically a windows PC will recognize the card reader as a smart card interface device To get further spec...

Page 18: ...reenshot above demonstrates use of the windows certutil function to read the smart card answer to reset This will verify that the USBCCID device registered correctly with the Windows USBCCID driver The errors above is likely to pop up if the inserted card is not initialized and prepared for further certificate handling in Windows 3 6 Limitations There are some limitations with this implementation ...

Page 19: ...connected to the EFM32 which might make the implementation more prone to electrical faults There exists conditioning devices that can be connected between the mcu and the smart card which handles ESD signal conditioning and the different voltage levels in a proper manner see Figure 3 10 p 19 For further protection of the interface device and also adding support for different voltage levels a level...

Page 20: ... Rev 1 1 2005 http www usb org developers devclass_docs DWG_Smart Card_CCID_Rev110 pdf 2 Online version of ISO 7816 Standard http www cardwerk com smartcards smartcard_standard_ISO7816 aspx 3 Smart Cache Windows software tool for storing data on ACOS 1 3 smart cards http www smartcache net 4 The home of the ISO 7816 standard http www iso org 5 ACOS3 Smart Cards http www acs com hk en products 19 a...

Page 21: ... the world s most energy friendly microcontrollers 2014 01 23 an0820_Rev1 00 21 www silabs com 5 Revision History 5 1 Revision 1 00 2014 01 23 Initial revision ...

Page 22: ...n or fabricate any integrated circuits The products must not be used within any Life Support System without the specific written consent of Silicon Laboratories A Life Support System is any product or system intended to support or sustain life and or health which if it fails can be reasonably expected to result in significant personal injury or death Silicon Laboratories products are generally not...

Page 23: ...00 23 www silabs com B Contact Information Silicon Laboratories Inc 400 West Cesar Chavez Austin TX 78701 Please visit the Silicon Labs Technical Support web page http www silabs com support pages contacttechnicalsupport aspx and register to submit a technical support request ...

Page 24: ...tocol 4 2 3 Part 4 Commands and Exchange of Data Packets 6 3 EFM32 USB CCID Implementation 10 3 1 USB CCID Standard 10 3 2 Connection of Smart Card to the STK 11 3 3 Software Implementation 12 3 4 Typical Transaction Sequences 15 3 5 Use the Smart Card Reader with a PC 17 3 6 Limitations 18 4 References 20 5 Revision History 21 5 1 Revision 1 00 21 A Disclaimer and Trademarks 22 A 1 Disclaimer 22 ...

Page 25: ...sion for the T 0 Protocol 9 3 1 Smart Card USB CCID Device Class Standard 10 3 2 Physical Connection of Card Socket with EFM32 Starterkit 12 3 3 Card Detection and Notification Interrupt 13 3 4 Function Handling Command and Data Transfer with Smart Card 14 3 5 Host Sends Data to Card 15 3 6 Host Requests and Receives Data from Card 16 3 7 Sequence with Card Insertion Removal and Simple Command 17 ...

Page 26: ... the world s most energy friendly microcontrollers 2014 01 23 an0820_Rev1 00 26 www silabs com List of Tables 2 1 Smart Card Electrical Connection 3 3 1 STK3700 Smart Card Pinout Description 11 ...

Page 27: ......

Reviews: