Wikţionar:Cum să editezi o pagină

De la Wikţionar, dicţionarul liber

Salt la: navigare, căutare

During the last decade smart cards became a widespread digital device. The increasing amount of memory enabled the evolution of operating systems having a portable and modular architecture. Advantages of such an architecture are for instance low development costs and the possibility to obtain a high degree of stability and security. In this paper we present the architectural model of a layered smart card operating system. Therefore hardware dependent functionality is abstracted by a HAL (Hardware Abstraction Layer) which provides a hardware independent interface to the above lying modules. Furthermore we provide an overview about standardised commands and protocols an operating system may support. 1 Introduction Smart cards are intelligent cards that contain a micro-controller. They are frequently used for security sensitive applications like money withdrawal or identification systems. In contrary to personal computers where Intel’s i386 architecture has been established as common standard, the architecture of micro-controllers often differs. Therefore software written for a particular smart card is typically not compatible to others. Moreover the amount of memory on smart cards is typically very limited. Despite the mentioned limitations there are good reasons for implementing special purpose operating systems for smart cards. Certainly the most important motivation for the use of OS on smart cards is the ubiquitous economic wish for reducing developing costs. Another essential reason evolves from the fact that security requirements are much easier to realise by using a well designed and tested operating system as foundation for high level applications. In this 1 2 paper we provide a proposal for the architecture of modular portable operating systems for smart cards using a multi-layered approach. In our discussion we focus on the system’s structure and functionality and will not give detailed instructions for programming a highly secure system. Issues on achieving a maximum level of security can be in found in [4] and [3]. The paper is structured as follows: Section two contains a discussion about the history of operating systems for smart cards, in section three we present our concept of a portable operating system and section four provides an overview about the ISO-7816 standard which defines commands a smart card operating system is supposed to support. 2 History of Smart Card Operating Systems The history of operating systems for smart cards is strongly related to the evolution of micro-controllers they are designed for. At the beginning, in the mid of the 1980’s, a typical smart card had 6 kByte ROM, 128 Byte RAM and 3 Kilobyte EEPROM. Thus programs written in Assembler were developed directly upon the physical layer of the card. Particularly the development of I/O routines for communicating to the terminal is a rather time intensive task. For that reason these functions were typically included into libraries to prevent programmers from writing every application from scratch. Because of the known advantages of reusing code during the years more functions were added to these libraries that were of course optimised to the properties of a special micro-controller. This library orientated approach is known as the first generation of smart card operating systems. Libraries which were stored in ROM provided the basic functionality of an operating system. Nevertheless the use of this heterogeneous model had some serious disadvantages. Module dependencies were not handled and many applications used instructions specific to a special hardware. Therefore it was generally difficult and time intensive to port high level applications to another micro-controller. Furthermore communication between terminal and card was not yet standardised and so interoperability was only achieved by terminals and cards of the same enterprise. At that time no standard for the functionality of smart card operating systems had been established yet. These operating systems were designed strictly for applications reflecting the purpose of a specific card. The second generation of smart card operating systems were monolithic systems. Monolithic systems provide an interface to hardware 3 and I/O having a more general functionality than library based systems. For this reason it was easier to achieve compatibility between different systems. That is why ISO established the ISO/IEC 7816 standards [1]. An overview about the standardised instruction set is given in section three of this paper. Monolithic operating systems, as the term ”monolithic” says, did not have the property of modularity. Thus, although it was easier to run application on different cards, porting operating systems remained a serious problem. During the 1990’s smart cards became a widespread digital device and the portability of operating systems became an important issue. Distributors of smart cards had to face the problem that due to a lack of compatibility they where highly dependent on systems of one or a few manufactures. The wish for open standards and higher compatibility and modularity led to the development of smart card operating systems of the third generation. Although the memory usage is higher than those of first or second generation systems they mostly overcome the mentioned problems. Similar to the approach we will present in section three modern operating systems often implement a modular layered architecture. The whole functionality of the target hardware is not used directly but encapsulated by a layer located directly above the physical layer. This layer provides a well specified hardware independent interface to the above lying layers. 3 Architecture of a Multi-layered Operating System The operating system’s architecture we will discuss in this section is depicted in figure 1. The architecture is similar to the one of the Open Source Smart Card Operating System SOSSE. As already mentioned in the last section the main goals of our design are mainly modularity and portability. Using a layered architecture is a common method achieve a high degree of portability. Additionally a strictly modular design basing on a well structured architecture decreases the probability of erroneous code because each module can be tested separately. The basic functionality of the micro-controller is abstracted by the HAL (Hardware Abstraction Layer) located at the bottom of this architecture. To minimise the amount of memory, routines of this layer are typically written in assembler. Fortunately libraries providing hardware dependent functions for several micro-controllers do exist. Therefore usage of these libraries can reduce the effort of porting a HAL to another architecture. Smart cards usually communicate to other digital devices. Thus the reader is connected (e.g. through a 4 Authentication Command Manager Cmd’s Other Return Code Mgr. Manager EEPROM HAL Encrypt / Decrypt Filesystem TRNG I/O Access Figure 1: Architecture of the operating system RS232 serial line) to the hardware the smart card is supposed to communicate with. Therefore the HAL must contain a module handling the correct state of the chip’s I/O registers. Every module situated above the HAL, only uses the appropriate interface functions to send or receive data. Depending on the implemented protocols (well defined protocol standards do exist) communication might be byte-wise or block-wise. Another important part of the HAL is the EEPROM manager. It provides an interface to access the EEPROM of the card. Similar to the communication functionality only basic byte-wise or block-wise read/write operations are covered by the HAL. High level applications usually write to this memory using the methods of the file system which accesses the EEPROM only through the HAL’s interface. Depending on the micro-controller’s properties the HAL may also include functions for accessing a True Random Number Generator (TRNG) provided by the hardware. However, to keep the operating system portable these functions may be substituted by a Pseudo Random Number Generator (PRNG) if the hardware does not support the TRNG ability. The command manager handles the execution of commands sent 5 to the card. Therefore it fetches data from the underlying I/O manager. Depending on the sent command the command manger calls the appropriate module(s) responsible for processing the task defined by the incoming command. The number of commands the smart card operating system supports depends on the application it is used for. For that reason the command manager should have a certain degree of extensibility. As each command may contain a certain number of parameters the command manager must implement a mechanism to check these parameters for correctness. Finally the command manager involves the return code manager to send the response of the processed command. Generally the tasks of executing a command and sending a response are closely related to one another. That is why the separation in two modules is not essential and the response manager’s functionality might be implemented within the command manger. Similar to operating systems for other devices a modern smart card operating system also contain a file system. It handles the common known file operations open, close, read, write and delete. For reasons of portability files must be logically addressable because otherwise the file system would not run correctly on architectures having a different memory space. In contrary to operating systems on personal computers files stored in the EEPROM of a smart card usually have to comply with a predefined structure. Moreover security aspects of the data stored in a file must be taken into account. Therefore each file contains a flag describing its access permission. Depending on the smart card’s purpose access handling may be implemented in several ways. The basic feature every file system on a smart card must support is the possibility of hiding internal data. The encrypt/decrypt module provides an interface to a cryptographic function. The decision which algorithm is used depends on both the level of security and the properties (memory, CPU speed) of the underlying hardware. The authentication manager implements the routines necessary for authentication of the smart card owner and the smart card itself. The owner usually authenticates himself by sending a PIN (Personal Identification Number) to the card. The operating system has to verify the received PIN by comparing it with the true value stored in an internal file. Additionally the card and the device (e.g. a terminal) it is connected with, have to authenticate mutually before other communication is allowed. A common way of achieving mutual authentication is the challenge response method. The two parties authenticate one another through a common secret, like key values. The authentication of a smart card, called internal authentication, is obtained by the following procedure. First the terminal sends a randomly chosen bit sequence and a key value to the smart 6 card. Then the smart card encrypts the bit sequence using a secret key that belongs to the sent key value and sends the encrypted bit sequence back to the terminal. The terminal knowing the secret key decrypts the bit sequence and compares it with the original sequence. The authentication of the terminal, called external authentication, is done the other way around. 4 The ISO/IEC 7816 Standard Figure 2: OSI protocol stack Depending on the application an operating system might implement different protocols and commands. In this section we give an overview about protocols and commands defined in the ISO/IEC 7816 standard. Figure 2 shows the OSI-model describing the communication between smart card and terminal. At the bottom of the OSI model is the physical layer that refers to the physical and electrical properties. Most smart card readers are connected to the terminal through a half duplex serial line. A more detailed discussion about the physical layer can be found at [4]. The second layer of the OSI model is the transmission layer. The ISO/IEC standard defines the ”T = x” protocols shown in Figure 3. There are two types of transmission protocols : synchronous and ansynchronous. At the moment most common used transmission protocols are asynchronous ones like T=0 or T=1. 7 Figure 3: Table of ”T = x” protocols The simplest, and most memory efficient, protocol is the T=0 protocol. T=0 is an byte-orientated protocol, that means the transmission of instructions is based on a single byte. Error correction is done with a parity bit. The highest layer of the OSI - model is the application layer ISO- 7816 - 4 which defines the basic communication record called APDU (application protocol unit ). Commands sent by the terminal are encapsulated in APDUs and the smart card’s response is encapsulated in response APDUs. Figure 4 shows the general structure of a command APDU that must be interpreted by the operating system’s command manger. Figure 4: Structure of a command APDU APDU’s consist of a four byte header and an optional body. The first element of the header is the class byte (CLA) specifying the application the instruction is used for. The second element of the APDU 8 header is the instruction byte which contains the instruction processed by the command manager. Due to historical reasons the instruction byte must have an even value. The third and fourth byte of the header contain the parameters P1 and P2. They are used to send additional information to the operating system’s command manger that defines different options. The optional body of an ADU contains the raw data (Data field) the command manger passes to a specific command module. Therefore the first byte of the body (LC) contains the length of the Data field. The element behind the data field contains the expected length of the response. The structure of a response APDU is depicted in figure 5. Figure 5: Structure of a response APDU The Data field located in the body of the response APDU holds the card’s response data. Depending on the implementation response APDU’s are generated by the return code manager or the command manager of the operating system. If no error occurred the data field must have the length indicated by the LC field of the command APDU. If an error occurred the Data field may have length 0. The trailer of an APDU consists of the status words SW1 and SW2. Status words hold the information about the current state, e.g. if an error occurred. For different applications exist different standards. The meaning of status Words according to ISO 7816-4 standard can be found in [1]. 5 Conclusion In this paper we proposed an architecture for a multi layered smart card operating system. Using the concept of abstracting layers and modularity increases the portability of smart card operating systems. As a matter of fact portable smartcard operating systems reduce development costs and a strictly modular design generally increases the security and quality of software. Another important issue concerning smart card applications is interoperabitlity which can be achieved by standardising the operating system’s I/O interface. However, at the 9 moment there are still several standards for different applications but in the future it is likely that ISO 7816-x will establish as common standard. References [1] The iso 7816 smart card standard. http://www.cardwerk.com/ smartcards/smartcard_standard_ISO7816.aspx. [2] Christoph Herbst. Smart cards and their dpa resistance. Master’s thesis, Graz University of Technology, April 2003. [3] Andrew S. Tanenbaum. Modern Operating Systems, volume Second Edition. Prentice Hall, Inc, 2002. [4] Wolfgang Effing Wolfgang Rankl. Handbuch der Chipkarten, volume 4. Auflage. Carl Hanser Verlag Muenchen Wien, 2002.