Professional Documents
Culture Documents
How A Magnetic Card Reader Works
How A Magnetic Card Reader Works
A magnetic card is a rectangular plastic object (credit/debit card) that contains either a magnetic object embedded within the card or a magnetic stripe on the cards exterior. A magnetic card can store any form of digital data. The electronic devices designed to read stored information from a magnetic card do so either when someone swipes the card through a slot in the reading device or holds the card next to a magnetic card reader. About a hundred bytes of information can be stored on a magnetic card. Because of their extensive use, most magnetic cards employ standards that describe a magnetic stripes physical and magnetic characteristics on a plastic card. These standards also define specifications for a storage format and information exchange. Before describing how a magnetic card reader works, look at how data is stored on a magnetic
card and the format of data storage collected. According to existing standards, a magnetic card stores information in three separate tracks. All three tracks possess different bit densities and encoded character sets. The average bit density of the first track is 210 bits per inch (bpi). A 64-bit character data set stores information in track 1. The characters are made up of six data bits and an odd parity bit. The encoding format grants the least significant bit to come first and the parity bit, last. So, track one can hold around 79 characters. The information density of the second and third tracks is around 75 and 210 bpi respectively. Only numeric data can be stored on the second and third track. 4-bit binary encoding is used as a decimal subset with odd parity and it is encoded with the least significant bit first and the parity bit last. The second and third tracks hold 40 and 107 characters respectively. The actual usable data stored will be minimized as the Start Sentinel, End Sentinel, and LRC characters are added. Two-Frequency, Coherent Phase Recording is used for encoding magnetic cards. It is also called F/2F sampling-encoding. By using combined data and clock bits, self-clocking is achieved.
For all 3 tracks, the data storage format is as follows: Leading zero bits are encoded to specify the presence of an encoded magnetic card and provide synchronization pulses to the read head electronics and, ultimately, to the controller. The Start Sentinel character then indicates the initiation of actual data. The coded data follows the Start Sentinel character, which the End Sentinel character follows. The End Sentinel character terminates the cards data portion, which an LRC byte (used for error detection) follows. Zero bits fill the remaining card. Now that it is understood how data is stored on a magnetic card, it is a bit easier to build on that foundation to gain an understanding of how the reader actually works. The magnetic card reader uses a specific component to read data from a magnetic card, which is referred to as the read head. The magnetic card reader is a microcontroller-based device. The read heads contain signal amplifiers and line drivers. All modern magnetic read heads contain integrated F/2F bit recovery circuitry and interface with the host controller. Using good coding techniques, interrupt driven sampling can be used to read and handle the data. Most of the head will read the first and second tracks simultaneously. Some of advanced read heads can read all three tracks simultaneously. Linear conditioning is used for noise reduction and signal conditioning. The reader also contains an oscillator section that provides the clocks for the recovery section and for the enable/disable timers. The enable/disable counters provide initialization for the recovery section. The recovery section locks onto the data rate and recovers the individual data bits from the data stream. The magnetic card reader is a microcontroller-based device and has been programmed for a specific application. That program simply reads the card in a forward direction in a simple data format or it can be complex enough to read the card in any direction with a corresponding encoding format.
y y
y y y
Classes for communicating with the reader Classes for converting data to a manufacturer-specific format
An application for testing and using the cards for an intended and specific purpose Readers come in many forms, factors, and capabilities. The easiest way to describe a reader is by the method of its interface to a PC. Smart card readers are available that interface to RS232 serial ports, USB ports, PCMCIA slots, floppy disk slots, parallel ports, infrared IRDA ports, and keyboards and keyboard wedge readers. Card readers read data from and write data to the smart card. Readers can easily be integrated into a PC utilizing Windows 98/Me, 2000, or XP platforms. However, some computer systems already come equipped with a built-in smart card reader. Some card readers come with advanced security features such as secure PIN entry, secure display and an integrated fingerprint scanners for the next-generation of multi-layer security, and three-factor authentication. Another difference in reader types is on-board intelligence and capabilities. An extensive price and performance difference exists between an industrial strength reader that supports a wide variety of card protocols and the less expensive win-card reader that only works with microprocessor cards and performs all data processing in the PC. The options in terminal choices are just as varied. Most units have their own operating systems and development tools. They typically support other functions such as magnetic-stripe reading, modem functions and transaction printing. To process a smart card, the computer has to be equipped with a smart card reader possessing the following mandatory features:
Smart Card Interface Standard ISO 7816 is an international standard that describes the interface requirements for contact-type smart cards. These standards have multiple parts. For instance, part 1, 2, and 3 are applicable to card readers. Part 1 defines the cards physical characteristics. Part 2 defines the dimension and location of smart card chip contacts. Part 3 defines the cards electronic signals and transmission protocols. Card readers may be referred to as conforming to ISO 7816 1/2/3, or in its simplified term, ISO 7816. Driver This refers to the software that a PCs operating system (OS) uses for managing a smart card and applicable card reader. To read a smart ID card, the driver of the card reader must be PC/SC compliant, which most card reader products currently available support. It should be noted that different OS would require different drivers. In acquiring card readers, the compatibility between the driver and the OS has to be determined and ensured.
It will not take long before smart card readers become an integral part of every computer, and, subsequently, of computer users lives. Computer systems with keyboards that have smart card reader/writer integration are also available. Smart card readers are also accessible as a USB dongle. USB dongles are frequently used with GSM phones, which contain a SIM smart card. Additionally, phone numbers can be edited on a PC using the USB smart card dongle.
entry to card system functions. The second approach treats the card as a secure device where, files and permissions to these files are all set by the admin. The only access to the cards is through the operating system. There is no other way to access the file structure. Data can be accessed as per the permissions set by the user. These operating systems can then run your applications. Commands can be passed to the card via the card reader and then the desired application can be accessed through the smart card. One of the most commonly used smart card operating systems is JavaCard. It provides standard API to load and run java applets directly on a standard ISO 7816 compliant card. JavaCards enable secure and chip-independent execution of various applications. The following requirement needs to be addressed before starting application development on smart cards:
y y
y y
Software to communicate with the smart card Smart cards and smart card hardware
Before we address smart card programming, we have to be able to communicate with the reader. Because there are many different cards, there are many different readers. So proper interface implementation should be used for communication. Once the above setup is complete, programming and application upload can begin utilizing the smart card. JavaCard allows applications to be loaded on demand. In the early years of smart card development, each software application representing a product on a card was written for a specific card with a specific operating system, which in turn was specific to a hardware application. Sometimes a direct application was also installed without an operating system to make the card very specific to that application. However, the evolution of multiple application operating systems brought about a new era. JavaCard is an open, multi-application operating system for smart cards. Any person can develop applications using Java programming language. The java programs can run independently on the card and can be run on any ISO 7816 compliant smart cards. This way applications from various vendors can be combined, yet remain separate from each other. The ISO 7816 standard was developed to define the mechanical and electrical characteristics along with the protocol for communication with the card. Unfortunately, the ISO group was unable to baseline a standard for communicating with the reader. So, in order to communicate with the smart card it is required to first understand the commands supported by the card. Then these commands need to be encapsulated into ISO standard commands. Now, lets take a look of the APIs which allow us to send commands from an application to a reader. The reader communicates with the card where the actual processig takes place. From a technical standpoint, the key is a smart card API. This is a layer of software that allows an application to communicate with smart cards and readers from more than one manufacturer. The API allows the programmers or users the ability to select smart cards from multiple vendors. Running an application on multiple smart cards encourages competition among card vendors and the benefits of that competition include greater quality and lower prices. The smart card programming API provides an application layer between the smart card and the application interface. The unit of exchange with a smart card is the called as Application Protocol Data Unit (APDU) packet. Communication with the card and the reader is performed using APDUs. An APDU can be considered a data packet that contains a complete instruction for the card or a complete response from a card. The following are some of the classes provided for transporting APDUs and their function: Response Command ISOCommand ISOCardReader interface ISOCardReader Sun has developed the Java Electronic Commerce Framework (JECF), an extension to the core Java platform that allows developers to easily and rapidly develop electronic commerce applications. JECF provides several classes that easily support communication with smart cards. It can be downloaded free of charge from Suns website and can be used easily by a smart card programmer. The smart card application development process includes following steps:
y y y y y
y y y y y y y
Software requirements: Map user requirements to software requirements. Architectural design: Design the architecture of the solution. Code Generation: Create code as per the architecture. Emulation: Use emulators to test the code on virtual card. In-card Emulation: Run the code on actual card using card reader. Verification and Validation: It involves the testing. Final testing and maintenance.