Smart Card Hardware

The hardware of the smart card includes contacts located on the surface of the plastic base, an integrated central processor and various types of memory. Some smart cards also have a coprocessor for mathematical calculations.

Smart Card Contacts

There are eight contacts on the surface of the smart card. Their functional purpose is shown in Figure 2.2. The dimensions and location of the contacts are regulated in section 2 of the ISO 7816 standard.

The voltage on this contact can be 3 V or 5 V. The maximum deviation is 10%. The supply voltage of smart cards for mobile phones is usually 3 V.
The RST contact is designed to provide a reset signal for the microprocessor, or for a “hot” reboot. A “cold” reboot is performed by turning off the power and then turning it on. To do this, remove the card from the reader and insert it again.

Eight smart card contacts

Smart card processors do not contain a built-in clock generator. The CLK pin is designed to supply an external clock signal, which is used for internal synchronization.
The GND contact is used to supply the reference voltage. Its value is assumed to be 0 V.
The Vpp contact is optional. It is used only in cards of outdated models. If this contact is used, it allows you to select one of two levels of programming voltage. A low level is called an unoccupied state. The reader must maintain this voltage level on pin V until it is necessary to switch to the active state. The voltage change is necessary for programming the EEPROM memory of some outdated smart card models.
· The “Input/Output” contact is designed to transmit data and commands in half-duplex mode between the smart card and the reader. Data or commands in this mode can be transmitted simultaneously in only one direction.
· RFU contacts are reserved for future use.

The central processor of the smart card

The central processor, which is available in most smart card models, is an 8-bit microcontroller with a clock frequency of up to 5 MHz. The Motorola 6805 or Intel 8051 instruction sets are commonly used. The cards of older models often have a clock frequency multiplier (2, 4 or 8 times). Such cards can operate at frequencies up to 40 MHz (which is 8 times more than 5 MHz).
Modern cards can be equipped with 16-bit or 32-bit microcontrollers. Cards with RISC architecture (architecture with a reduced set of commands) are also available. It is expected that 16-bit and 32-bit cards will become more widespread in the future.

Smart Card Coprocessors

Smart cards designed for security applications often contain a built-in coprocessor. A cryptographic coprocessor is a special integrated circuit designed to speed up calculations, primarily arithmetic operations on absolute values of numbers and calculations with large integers. Such calculations are necessary to perform cryptographic operations, such as the RSA encoding algorithm.
The cost of cards with a coprocessor is usually higher.

Smart Card Memory System

Smart cards typically use three types of memory: permanent memory, programmable permanent memory, and RAM for reading and writing data. These three types of memory are most often implemented on ROM, EEPROM and RAM chips, respectively:

ROM (permanent storage device) is used in cards to store fixed programs. No power supply is required to store data in this type of memory. However, as the name implies, the contents of such memory cannot be changed after the card is released. ROM-type memory is used in smart cards to store operating system modules, as well as persistent data and client applications. The process of writing binary images (representing programs or data) to a ROM chip is called burning. Burning is performed at the production stage of the chip.

EEPROM (electrically erasable programmable permanent storage device). As in ROM-type memory, data in such memory is stored after power is turned off. The difference between these types is that the contents of the EEPROM memory can be changed during the operation of the card. Therefore, such memory is used for long-term data storage. In this regard, EEPROM memory in smart cards is similar to PC hard drives. Client applications can also be written to the EEPROM memory after the card is released. Important electrical characteristics of EEPROM memory are the number of write cycles over the life of the card, data storage time and access time. Most of the EEPROM chips used in smart cards are designed for at least 100,000 write cycles, and the data storage period is at least 10 years. The speed of reading from EEPROM is comparable to the speed of reading from RAM, but writing to EEPROM is 1000 times slower than to RAM.
· RAM (random access memory) is used as a working space for temporary storage and modification of data. RAM memory is not permanent. When the power is turned off, its contents are lost. The number of write/read cycles to RAM is unlimited. There are also no other limitations inherent in EEPROM memory.

Of all three types of memory, ROM has the lowest cost. EEPROM memory is more expensive than ROM, because the size of one cell is four times larger than the size of a ROM cell, and the cell device is more complicated. The amount of RAM in smart cards is very limited. The size of a single RAM cell is approximately eight times the size of an EEPROM cell.
Today, smart cards are increasingly using memory based on alternative technologies. For example, the popularity of flash memory is growing. Flash memory is a type of permanent mutable memory. It is more compact compared to EEPROM and consumes less electricity. Bitwise reading from flash memory is allowed, but writing is possible only in blocks. Therefore, flash memory is usually used to store additional programs or large arrays of data that are updated entirely.

Card readers and host applications

The smart card is inserted into a card reader (CAD) that can be connected to another computer. Card readers can be divided into two types: readers and terminals.

The reader is connected to a serial, parallel or USB port of the computer. The connection to the smart card is controlled by a computer. There is a slot in the reader into which the smart card is inserted. It can be equipped with a transmitter and receiver of electromagnetic radiation to work with contactless cards. In addition to the power supply of the smart card, the reader provides a backbone for data exchange between the card and the computer to which it is connected. Despite the fact that readers usually do not have internal logic for data processing, many of them have error detection and correction functions that are used in cases when the transmitted data does not correspond to the parameters of the main transport layer protocol.

Unlike the reader, the terminal includes a computer. The smart card reader is one of the components of the terminal. Terminals are most often seen at gas stations and in stores. They are designed to pay and perform other actions using credit cards. Another example of terminals are ATMs. In addition to performing the functions of a smart card reader, the terminal can process the data that it exchanges with the smart card. For example, if an ATM has accepted a card, it can withdraw money from the card account or add money to the account by interacting with the application
“electronic wallet” that works on the card.
For simplicity, in this book we will not pay attention to the differences between the reader and the terminal. We will call both types of systems card readers, or CAD. Applications that interact with smart cards, regardless of where they work – on the computer to which the reader is connected, or in the terminal – are called host applications. Host applications control the process of data exchange with the card. More details about this will be described in section 2.4.2.

The model of interaction with smart cards

The communication channel between the smart card and the host system is half-duplex. This means that at any given time, data can be transmitted either from the card to the host system, or from the host system to the card, but not in two directions simultaneously.
Data exchange between two computing systems takes place in the form of packets. The format of the data packet is determined by the protocol used, for example TCP/IP. For data exchange between smart cards and other computing devices, packets or data blocks of a special format are also used, which are called application protocol data unit (APDU) data blocks. The APDU block contains either a command or a response message.

Interaction with smart cards

In the world of smart cards, the “master – subordinate” interaction model is used. A smart card always performs a passive role (a subordinate device). It is waiting for the APDU command to arrive from the host application. Then it executes the instruction contained in the command and sends the host application an APDU block with a response message. The exchange of APDU commands and responses between the card and the host application is performed sequentially, as shown in Figure 2.3.