scard2

来源:互联网 发布:java字符串replaceall 编辑:程序博客网 时间:2024/06/07 06:42
10月20日

ISO 7816(1-3) Smart Card Standard(二)

ISO7816 3.2.c - Deactivation of the contacts

When informations exchange is terminated or aborted (unresponsive card or detection of card removal), the electrical contacts shall be desactivated.

The deactivation by the interface device shall consist of the consecutive operations:

- State L on RST;
- State L on CLK;
- Vpp inactive;
- State A on I/O;
- VCC inactive;

ISO7816 3.3 Answer to Reset

Two types of transmissions are considered:

* Asynchronous transmission:
In this type of transmission, characters are transmitted on the I/O line in an asynchronous half duplex mode. Each character includes an 8bit byte.


* Synchronous transmission:
In this type of transmission, a series of bits is transmitted on the I/O line in half duplex mode in synchronisation with the clock signal on CLK.

ISO7816 3.1.a - Answer to Reset in asynchronous transmission

* Bit duration
""""""""""""
The nominal bit duration used on I/O is defined as one Elementary Time Unit (etu).

For cards having internal clock, the initial etu is 1/9600 s.

For cards using the external clock, there is a linear relationship between the Elementary Time Unit used on I/O and the period provided by the interface device on CLK.

The initial etu is 372/fi s where fi is in Hertz.

The initial frequency fi is provided by the interface device on CLK during the Answer to Reset.

In order to read the initial character (TS), all cards shall initially be operated with fi in the range of 1 MHz to 5 MHz.

* Character frame during answer to reset
""""""""""""""""""""""""""""""""""""""
Prior to the transmission of a character, I/O shall be in state Z.

A character consists of ten consecutive bits:

- a start bit in state A;
- eight bits of information, designated ba to bh and conveying a data byte;
- a tenth bit bi used for even parity checking.

A data byte consists of 8 bits designated b1 to b8, from the least significant bit (lsb, b1) to the most significant bit (msb, b8).

Conventions (level coding, connecting levels Z/A to digits 1 or 0: and a bit significance, connecting ba...bh to b1...b8) are specified in the initial character, call TS, which is transmitted by the card in response to reset.

Parity is correct when the number of ONES is even in the sequence from ba to bi.

Whithin a character, the time from the leading edge of the start bit to the trailing edge of the nth bit shall equal (n+/-0.2) etu.

When searching for a start, the receiver samples I/O periodically. The time origin being the mean between last observation of level Z and first observation of level A, the start shall be verified before 0.7 etu, and then ba is received at (1.5 +/-0.2) etu. Parity is checked on the fly.

NOTE : When searching for a start, the sampling time shall be less than 0.2 etu so that all the test zones are distinct from the transition zones.

The delay between two consecutives characters (between start leading edges) is at least 12 etu, including a character duration (10+/-0.2) etu plus a guardtime, the interface device and the card reamain both in reception, so that I/O is in state Z.

            Start                          Parity             Next             bit <----- 8 data bits -----> bit              Start bit     Z   ____     ________________________________......______     __             |   |  |  |  |  |  |  |  |  |  |                 |   |     I/O     |   |ba|bb|bc|bd|be|bf|bg|bh|bi|     Guardtime   |   |             |___|__|__|__|__|__|__|__|__|__|                 |___|_     A       :   :                    :     :             0   t1                   :    t10             :                        :             :<---- (n+/-0.2) etu --->:                          Figure 3: Character frame                          

During the Answer to Reset, the delay between the start leading edges of two consecutives characters from the card shall not exeed 9600 etu. This maximum is named initial waiting time.

* Error detection and character repetition
""""""""""""""""""""""""""""""""""""""""
During the answer to reset, the following characters repetition procedure depends on the protocol type. This procedure is mandatory for cards using the protocol type T=0; it is optional for the interface device and for the other cards.

The transmitter tests I/O (11+/-0.2) etu after the start leading edge:
- If I/O is in state Z, the correct reception is assumed.
- If I/O is in state A, the transmission is assumed to have been incorrect. The disputed character shall be repeated after a delay of at least 2 etu after detection of the error signal.

When parity is incorrect, from (10.5+/-0.2) etu, the receiver transmits an error signal at state A for 1 etu minimum and 2 etu maximum. The receiver then shall expect a repetition of the disputed character (see figure 8).

If no character repetition is provided by the card, - The card ignores and shall not suffer damage from the error signal coming from the interface device.
- The interface device shall be able to initiate the reception and the whole Answer to Reset response sequence.

* Structures and content
""""""""""""""""""""""
A reset operation results in the answer from the card consisting of the initial character TS followed by at most 32 characters in the following order:

         - T0 ................... Format character     (Mandatory)         - TAi, TBi, TCi, TDi ... Interface characters  (Optional)         - T1, T2, ... ,TK ...... Historical characters (Optional)         - TCK .................. Check character    (Conditional)Reset | |    _________________________________________         _______   _________ |   |   |   |   |   |   |   |   |   |   |   |           |   |     |   |   | '-->| TS| T0|TA1|TB1|TC1|TD1|TA2|TB2|TC2|TD2| ......... | T1| ... | TK|TCK|     |___|___|___|___|___|___|___|___|___|___|_         _|___|_   _|__ |___|     TS  : Initial character     TO  : Format character     TAi : Interface character [ codes FI,DI ]     TBi : Interface character [ codes II,PI1 ]     TCi : Interface character [ codes N ]     TDi : Interface character [ codes Yi+1, T ]     T1, ... , TK : Historical characters (max,15)     TCK : Check character         Figure 4 : General configuration of the Answer to Reset


The interface characters specify physical parameters of the integrated circuit in the card and logical characteristics of the subsequent exchange protocol.

The historical characters designate general information, for example, the card manufacturer, the chip inserted in the card, the masked ROM in the chip, the state of the life of the card. The specification of the historical characters falls outside the scope of this part of ISO/IEC7816.

For national simplicity, T0, TAi, ... ,TCK will designate the bytes as well as the characters in which they are contained.

Structure of TS, the initial character
--------------------------------------
The initial character TS provides a bit shynchronisation sequence and defines the conventions to code data bytes in all subsequent characters. These conventions refer to ISO1177.

I/O is initially in state Z. A bit synchronisation sequence (Z)AZZA is defined for the start bit and bits ba bb bc (see figure 5).

The last 3 bits bg bh bi shall be AAZ for checking parity.

NOTE : This allows the interface device to determinate the etu initially used by the card. An alternate measurement of etu is a third of the delay between the first two falling edges in TS. Transmission and reception mechanisms in the card shall be consistent with the alternate
definition of etu.

The two possible values of TS (ten consecutive bits from start to bi and corresponding hexadecimal value) are

- Inverse convention : (Z)ZZAAAAAZ
where logic level ONE is A, ba is b8 (msb is first), equal to $3F when decoded by inverse convention.

- Direct convention : (Z)ZZAZZZAAZ
where logic level ONE is Z, ba is b1 (lsb first), equal to $3B when decoded by direct convention.

                 Start  ba  bb  bc  bd  be  bf  bg  bh  bi          Z   ____     _______     ___________         ______                  |   |   |   |   | Z   Z   Z |       |       |   |               (Z)| A | Z   Z | A |     or    |       | Z  (Z)          A       |___|       |___|_A___A___A_|___|___|                    Figure 5 : Initial character TS                    --------

Structure of the subsequent characters in the Answer to Reset
-------------------------------------------------------------
The initial character TS is followed by a variable number of subsequent characters in the following order: The format character T0 and, optionally the interface characters TAi, TBi, TCi, TDi and the
historical characters T1, T2, ... , TK and conditionally, the check character TCK.

The presence of the interface characters is indicated by a bit map technique explained below.

The presence of the historical characters is indicated by the number of bytes as specified in the format character defined below.

The presence of the check character TCK depends on the protocol type(s) as defined as below.

- Format character T0
-------------------
The T0 character contains two parts:

- The most significant half byte (b5, b6, b7, b8) is named Y1 and indicates with a logic level ONE the presence of subsequent characters TA1, TB1, TC1, TD1 respectively.

- The least significant half byte (b4 to b1) is named K and indicates the number (0 to 15) of historical characters.

         ,----,----,----,----,----,----,----,----,         | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |         '----'----'----'----'----'----'----'----'         :<------- Y1 ------>:<-------- K ------>:         Y1 : indicator for the presence of the interface characters                TA1 is transmitted when b5=1                TB1 is transmitted when b6=1                TC1 is transmitted when b7=1                TD1 is transmitted when b8=1         K : number of hitorical characters                    Figure 6 : Informations provided by T0                    --------


- Interface characters TAi, TBi, TCi, TDi
---------------------------------------

TAi, TBi, TCi (i=1, 2, 3, ... ) indicate the protocol parameters.
TDi indicates the protocol type T and the presence of subsequent
characters.

Bits b5, b6, b7, b8 of the byte containing Yi (T0 contains Y1; TDi contains Yi+1) state whelther character TAi for b5, character TBi for b6, character TCi for b7, character TDi for b8 are or are not (depending on whether the relevant bit is 1 or 0) transmitted subsequently in this
order after the character containing Yi.

When needed, the interface device shall attribute a default value to information corresponding to a non transmitted interface character.

When TDi is not transmitted, the default value of Yi+1 is null, indicating that no further interface characters TAi+j, TBi+j, TCi+j, TDi+j will be transmitted.

         ,----,----,----,----,----,----,----,----,         | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |         '----'----'----'----'----'----'----'----'         :<------ Yi+1 ----->:<------- T ------->:         Yi+1 : indicator for the presence of the interface characters                TAi+1 is transmitted when b5=1                TBi+1 is transmitted when b6=1                TCi+1 is transmitted when b7=1                TDi+1 is transmitted when b8=1         T : Protocol type for subsequent transmission.                    Figure 7 : Informations provided by TDi                    --------


- Historical characters T1, T2, ... ,TK
-------------------------------------

When K is not null, the answer to reset is continued by transmitting K historical characters T1, T2, ... , TK.

- Check character TCK
-------------------

The value of TCK shall be such that the exclusive-oring of all bytes from T0 to TCK included is null.

The answer to reset is complete 12 etu after the leading edge of the last character.


Protocol type T
---------------
The four least significant bits of any interface character TDi indicate a protocol type T, specifying rules to be used to process transmission protocols. When TDi is not transmitted, T=0 is used.

T=0 is the asynchronous half duplex character transmission protocol.
T=1 is the asynchronous half duplex block transmission protocol.
T=2 and T=3 are reserved for future full duplex operations.
T=4 is reserved for an enhanced asynchronous half duplex character
transmission protocol.
T=5 to T=13 are reserved for future use.
T=14 is reserved for protocols standardized by ISO.
T=15 is reserved for future extension.

NOTE : If only T=0 is indicated, TCK shall not be sent. In all other cases TCK shall be sent.

Specifications of the global interface bytes
--------------------------------------------
Among the interface bytes possibly transmitted by the card in answering to reset, this subclaus defines only the global interface bytes TA1,TB1, TC1, TD1.

These global interface bytes convey information to determine parameters which the interface device shall take into account.

- Parameters F, D, I, P, N
------------------------

This initial etu is used during answer to reset is replaced by the work etu during subsequent transmission. F is the clock rate conversion factor and D is the bit rate adjustment factor to determine the work etu in subsequent transmissions.

For internal clock cards:

initial etu = 1/9600 s work etu = (1/D)*(1/9600) s

For external clock cards:

initial etu = 372/fi s work etu = (1/D)*(F/fs) s

The minimum value of fs shall be 1MHz.
The maximum value of fs is given by table 6.

I and P define the active state at VPP.
- Maximum programming current : Ipp = 1mA
- Programming voltage : Vpp = P.V

N is an extra guardtime requested by the card. Before receiving the next character, the card requires a delay of at least (12+N) etu from the start leading edge of the previous character. No extra guardtme is used to send characters from the card to the interface device.

The default values of these parameters are:
F = 372 ; D = 1 ; I = 50 ; P = 5 ; N = 0


- Integer values in global interface bytes
----------------------------------------

The global interface bytes, TA1, TB1, TC1, TB2 code integer values FI, DI II, PI1, N, PI2 which are either equal to or used to compute the values of the parameters F, D, I, P, N presented above.

TA1 codes FI over the most significant half byte (b8 to b5) and DI over the least significant half byte (b4 to b1).

TB1 codes II over the bits b7 and b6, and PI1 over the 5 least significant bits b5 to b1. The most significant bit b8 equals to 0.

NOTE : The interface device may ignore the bit b8 of TB1.

TC1 codes N over the eight bits (b8 to b1).

TB2 codes PI2 over the eight bits (b8 to b1).


Table 6: Clock rate conversion factor F     -------     ----------------------------------------------------------------------            FI     |     0000      0001  0010  0011  0100  0101  0110  0111     --------------+-------------------------------------------------------            F      | Internal clk   372   558   744  1116  1488  1860  RFU     --------------+-------------------------------------------------------      fs (max) MHz |      -           5     6     8    12    16    20   -     ----------------------------------------------------------------------     ---------------------------------------------------------------            FI     | 1000  1001  1010  1011  1100  1101  1110  1111     --------------+------------------------------------------------            F      |  RFU   512   768  1024  1536  2048   RFU  RFU     --------------+------------------------------------------------      fs (max) MHz |  -       5   7.5    10    15    20    -    -     ---------------------------------------------------------------      RFU : Reserved for Future Use     Table 7: Bit rate afjustment factor D     -------     -------------------------------------------------------        DI | 0000  0001  0010  0011  0100  0101  0110  0111     ------+------------------------------------------------        D  |  RFU     1     2     4     8    16   RFU   RFU     -------------------------------------------------------     -------------------------------------------------------        DI | 1000  1001  1010  1011  1100  1101  1110  1111     ------+------------------------------------------------        D  |  RFU   RFU   1/2   1/4   1/8  1/16  1/32  1/64     -------------------------------------------------------      RFU : Reserved for Future Use

- Programming voltage factor P
----------------------------

PI1 from 5 to 25 gives the value of P in volts. PI1=0 indicates that VPP is connected in the card which generates an internal programming voltage from VCC. Other values of PI1 are reserved for future use.

When PI2 is present, the indication of PI1 should be ignores. PI2 from 50 to 250 gives the value of P in 0.1V. Other values of PI2 are reserved for future use.

Table 8 : Maximum programming current factor I     -------     -------------------------------      II  |   00    01    10    11     -----+-------------------------      I   |   25    50   100   RFU     -------------------------------

- Extra guardtime N
-----------------

N codes directly the extra guard time, from 0 to 254 etu. N=255 indicates that the minimum delay between the start edges of two consecutives characters is reduced to 11 etu.

ISO 7816(1-3) Smart Card Standard(一)

Part1: Physical Charcteristics of Integrated Circuit Cards
 

This part describes the physical charcteristics of integrated circuit cards. It includes accomodation of exposure limits for a number of electromagnetic phenomena such as X-rays, UV light, elacromagnetic fields, static electrical fields, and ambient temperature of the card.

Furthermore ISO7816-1 defines the characteristics of a card when it is bent or flexed. This is to make sure that plastic cards with embedded chips are manufactured in a way that guarantees flawless operation over the expected life time of a card. Connections beween the surface connectors and the I/O pins of the embedded silicon die must be maintaned and withstand mechanical stress. Bending and flexing procedures are standardised in ISO 7816.

This part of ISO7816 is important for card manufacturers. They are the ones that choose the materials and establish a process that embeds the integrated circuit into the card.

Part 2: Dimensions and Location of the Contacts

ISO 7816 part 2 defines the dimensions and location of the contacts. This part includes standards about number, function and position of the electrical contacts.

The integrated circuit card (ICC) has 8 electrical contacts . They are referred to as C1 through C8. However, not all 8 contacts are electrically connected to the embedded microprocessor chip and therefore unused at the present time.

The following table contains the contact definition according to ISO7816-2

Contact Designation Use C1 Vcc Power connection through which operating power is supplied to the microprocessor chip in the card C2 RST Reset line through which the IFD can signal to the smart card's microprocessor chip to initiate its reset sequence of instructions C3 CLK Clock signal line t hrough which a clock signal can be provided to the microprocessor chip. This line controls the operation speed and provides a common framework for data communication between the IFD and the ICC C4 RFU Reserved for future use C5 GND Ground line providing common electrical ground between the IFD and the ICC C6 Vpp Programming power connection used to program EEPROM of first generation ICCs. C7 I/O Input/output line that provides a half-duplex communication channel between the reader and the smart card C8 RFU Reserved for future use

Remark:

Some smart cards issued before 1990 were adherent to a different standard for the contact location and therefore can't be used with today's ISO7816-2 compliant smart card readers. These cards were deployed primarily in Europe.

 

Part 3: Electronic Signals and Transmission Protocols (1)

This part describes electronic signals and transmission protocols of integrated circuit cards. We copied it from a version that is available on the Internet. If you need the official version of this part, please contact ISO in switzerland.. If you have suggestions or material to include (tables, graphs etc) please contact us. The document will stay at this location for anyone that wants a direct link to this part of the standard. We will edit this document shortly, bring it up to date and add comments.

Most of ISO7816 3 is important for reader manufacturers or developers who want to establish a communication with a smart card on a very low level, the signal level. Going through ISO 7816-3 you will see what's involved in writing your own I/O software. This can be either to communicate from a microcontroller or a PC's serial/parallel/USB/PCMCIA port. Even if you don't go that far, it is quite interesting to read about what you can get out of an Answer to Reset (ATR).

There are many tools out there to read an ATR. Even on this site we put a remote version of a free ATR probing tool that reads and interprets an ATR over the Internet. All you need is a PCSC compliant smart card reader attached to a PC with an Internet connection.

Electrical Signals Description

I/O : Input or Output for serial data to the integrated circuit inside the card.

VPP : Programing voltage input (optional use by the card).

GND : Ground (reference voltage).

CLK : Clocking or timing signal (optional use by the card).

RST : Either used itself (reset signal supplied from the interface device) or in combination with an interal reset control circuit (optional use by the card). If internal reset is implemented, the voltage
supply on Vcc is mandatory.

VCC : Power supply input (optional use by the card).


NOTE - The use of th two remaining contacts will be defined in the appropriate application standards.

ISO7816 3.1 Voltage and current values

Abbreviations:

Vih : High level input voltage
Vil : Low level input voltage
Vcc : Power supply voltage at VCC
Vpp : Programming voltage at VPP
Voh : High level output voltage
Vol : Low level output voltage
tr : Rise time between 10% and 90% of signal amplitude
tf : Fall time between 90% and 10% of signal amplitude
Iih : High level input current
Iil : Low level input current
Icc : Supply current at VCC
Ipp : Programming current at VPP
Ioh : High level output current
Iol : Low level output current
Cin : Input capacitance
Cout: Output capacitance


* I/O

This contact is used as input (reception mode) or output (transmission mode) for data exchange. Two possible states exist for I/O:

- mark or high state (State Z), if the card and the interface device are in reception mode or if the state is imposed by the transmitter.

- space or low state (State A), if this state is imposed by the
transmitter.

When the two ends of the line are in reception mode, the line shall be maintained in state Z. When the two ends are in non-matced transmit mode, the logic state of the line may be indeterminate. During operations, the interface device and the card shall not both be in transmit mode.


Table 1 - Electrical characteristics of I/O under normal operation conditions.

,--------+--------------------------------+---------+---------+------,| Symbol |          Conditions            | Minimum | Maximum | Unit |+--------+--------+-----------------------+---------+---------+------+|        | Either | Iih max = +/- 500uA   |    2    |    VCC  |   V  ||  Vih   |   (1)  +-----------------------+---------+---------+------+|        |   or   | Iih max = +/- 50uA    | 0.7 VCC | VCC (3) |   V  |+--------+--------+-----------------------+---------+---------+------+|  Vil   |          Iil max = 1mA         |    0    |    0.8  |   V  |+--------+--------------------------------+---------+---------+------+|        | Either | Iol max = +/- 100uA   |   2.4   |    VCC  |   V  ||  Voh   |        +-----------------------+---------+---------+------+|    (2) |   or   | Iol max = +/- 20uA    |   3.8   |    VCC  |   V  |+--------+--------+-----------------------+---------+---------+------+|  Vol   |          Iol max = 1mA         |    0    |    0.4  |   V  |+--------+--------------------------------+---------+---------+------+| tr, tf | Cin = 30pF;   Cout = 30pF      |         |      1  |   us |+--------+--------------------------------+---------+---------+------+| (1) For the interface device, take into account both conditions.   || (2) It is assumed that a pull up resistor is used in the interface ||     device (recommended value 20k Ohm.                             || (3) The voltage on I/O shall remain between 0.3V and VCC+0.3V.     |'--------------------------------------------------------------------'


* VPP
This contact may be to supply the voltage required to program or to erase the internal non-volatile memory. Two possible states exists for VPP: Idle state and active state, as defined in table 2. The idle state shall be maintained by the interface device unless the active state is required.


Table 2 : Electrical characteristics of VPP under normal operation conditions.

,--------+--------------------------------+---------+---------+------,| Symbol |          Conditions            | Minimum | Maximum | Unit |+--------+--------------------------------+---------+---------+------+|  Vpp   |         Idle State             | 0.95*Vcc| 1.05*Vcc|   V  ||  Ipp   |   (programming non active)     |         |   20    |  mA  |+--------+--------------------------------+---------+---------+------+|  Vpp   |        Active State            | 0.975*P | 1.025*P |   V  ||  Ipp   |    (programming the card)      |         |     I   |  mA  |+--------+--------------------------------+---------+---------+------+| The card provides the interface with the values of P and I         || (default values: P=5 and I=50)                                     |'--------------------------------------------------------------------'

Rise of fall time : 200 us maximum. The rate of change of Vpp shall not exceed 2V/us.
The maximum power Vpp*Ipp shall not exceed 1.5W when averaged over any period of 1s.


* CLK

The actual frequency, delivered by the interface device on CLK, is designated either by fi the initial frequency during the answer to reset, or by fs the subsequent frequency during subsequent transmission.

Duty cycle for asynchronous operations shall be between 45% and 55% of the period during stable operation. Care shall be taken when switching frequencies (from fi to fs) to ensure that no pulse is shorter than 45% of the shorter period.


Table 3 - Electrical characteristics of CLK under normal operation conditions.

     ,--------+--------------------------------+---------+---------+------,     | Symbol |          Conditions            | Minimum | Maximum | Unit |     +--------+--------+-----------------------+---------+---------+------+     |        | Either | Iih max = +/- 200uA   |   2.4   | VCC (2) |   V  |     |        |   (1)  +-----------------------+---------+---------+------+     |  Vih   |   or   | Iih max = +/- 20uA    | 0.7*VCC | VCC (2) |   V  |     |        |   (1)  +-----------------------+---------+---------+------+     |        |   or   | Iih max = +/- 10uA    | VCC-0.7 | VCC (2) |   V  |     +--------+--------+-----------------------+---------+---------+------+     |  Vil   |          Iil max = +/-200 uA   |   0 (2) |    0.5  |   V  |     +--------+--------------------------------+---------+---------+------+     | tr, tf |          Cin = 30pF            |         |9% of the period|     |        |                                |         |with a max:0.5us|     +--------+--------------------------------+---------+---------+------+     | (1) For the interface device, take into account three conditions.  |     | (2) The voltage on CLK shall remain between 0.3V and Vcc+0.3V.     |     '--------------------------------------------------------------------'

* RST

Table 4 - Electrical characteristics of RST under normal operation conditions.

     ,--------+--------------------------------+---------+---------+------,     | Symbol |          Conditions            | Minimum | Maximum | Unit |     +--------+--------+-----------------------+---------+---------+------+     |        | Either | Iih max = +/- 200uA   |    4    | VCC (2) |   V  |     |  Vih   |   (1)  +-----------------------+---------+---------+------+     |        |   or   | Iih max = +/- 10uA    | VCC-0.7 | VCC (2) |   V  |     +--------+--------+-----------------------+---------+---------+------+     |  Vil   |          Iil max = +/- 200uA   |   0 (2) |    0.6  |   V  |     +--------+--------------------------------+---------+---------+------+     | (1) For the interface device, take into account both conditions.   |     | (2) The voltage on RST shall remain between 0.3V and VCC+0.3V.     |     '--------------------------------------------------------------------'

* VCC

This contact is used to supply the power voltage Vcc.


Table 5 - Electrical characteristics of VCC under normal operation conditions.

              ,--------+---------+---------+-------,              | Symbol | Minimum | Maximum |  Unit |              +--------+---------+---------+-------+              |  Vcc   |   4.75  |   5.25  |   V   |              |  Icc   |         |    200  |  mA   |              '--------+---------+---------+-------'

ISO7816 3.2 Operating procedure for integrated circuit(s) cards

This operating procedure applies to every integrated circuit(s) card with contacts:

The dialogue between the interface device and the the card shall be conducted through the consecutive operations:

- connection and activation of the contacts by the interface device.
- reset of the card.
- answer to reset by the card.
- subsequent information exchange between the card and the interface device.
- desactivation of the contacts by the interface device.

These operations are specified in the following subclauses.

NOTE :
An active state on VPP should not only be provided and maintained when requested by the card.

ISO7816 3.2.a - Connection and activation of the contacts

The electrical circuits shall not be activated until the contacts are connected to the interface device so as to avoid possible damage to any card meeting these standards.

The activation of the contacts by the interface device shall consist of the consecutive operations:

- RST is in state L;
- VCC shall be powered;
- I/O in the interface device shall be put in reception mode;
- VPP shall be raised to idle state;
- CLK shallbe provided with a suitable and stable clock.


ISO7816 3.2.b - Reset of the card

A card reset is initiated by the interface device, whereupon the card shall respond with an Answer to Reset as describe in 2.4.

By the end of the activation of the contacts (RST is in L, VCC powered and stable, I/O in reception mode in the interface device, VPP stable at idle level, CLK provided with a suitable and stable clock), the card answering asynchronously is ready for reset.

The clock signal is applied to CLK at time T0. The I/O line shall be set to state Z within 200 clcok cycles of the clock signal (t2) being applied to CLK (time t2 after T0).

An internally reset card reset after a few cycles of clock signal. The Answer to Reset on I/O shall begin between 400 and 40 000 clock cycles (t1) after the clock signal is applied to CLK (time t1 after T0).

A card with an active low reset is reset by maintaining RST in state L for at least 40 000 clock cycles (t3) after the clock signal is applied on CLK (time t3 after T0). Thus if no Answer to Reset begind within 40 000 clock cycles (t3) with RST in state L, RST is put to state H (at time T1). The
Answer to Reset on I/O shall begin between 400 and 40 000 clock cycles (t1) after the rising edge of the signal on RST (time t1 after T1).

If the Anwser to Reset does not begin within 40 000 clock cycles (t3) with RST in state H (t3 after T1), the signal on RST shall be returned to state L (at time T2) and the contacts shall be desactivated by the interface device.

GND ________________________________________________________________________      __________________________________________________________________VCC _| :                                                               :|___       :_______________________________________________________________:VPP __|:                                                               |____       :             t3                            t3                  :       :<--------------------------->:<------------------------------->:       :                             :_________________________________:RST ___:_____________________________|                                 |____       :                             :                                 :CLK ___|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||____       :       t1                    :                                 :       :<-------------->:            :                                 :       :      __________:____________:_________________________________:I/O __XXXXXXXX          |____________:_______Answer____________________:XXXX(IR)   :      :                      :                                 :       :  t2  :                      :      t1                         :       :<---->:                      :<---------->:                    :       :      _______________________:_________________________________:I/O __XXXXXXXX                       :            |______Answer________:XXXX(AL)   :  t2  :                      :                                 :       :<---->:                      :                                 :       :                             :_________________________________:I/O __XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:                                 :XXXXX(SH)   :                             :                                 :       T0                            T1                                T2       IR : Internal Reset                t2 <= 200/fi  AL : Asynchronous Reset            400/fi <= t1 <= 40000/fi  SH : Syncronous Reset              40000/fi <= t3                      Figure1 : Reset of the card  

With a card answering synchonously, the interface device sets all the lines to state L (See figure 2). VCC is the powered, VPP is set to idle state, CLK and RST remain in L state, I/O is put in reception mode in the interface device, RST shall be maintained in state H for at least 50 us (t12), before returning to state L again.

The clock pulse is applied after an interval (t10) from the rising edge of the reset signal. The duration of the state H of the clock pulse can be any value between 10 us and 50 us ; no more than one clock pulse during reset high is allowed. The time interval between the falling edges on CLK
and RST is t11.

The first data bit is obtained as an answer to reset on I/O while CLK is in state L and is valid after an interval t13 from the falling edge on RST.

      ______________________________________________________________________VCC__/       _____________________________________________________________________VPP___/                 t12         :<---------------->:         :__________________:RST_____/:                   /_______________________________________________         :                    :         :  t10           t11 :          t15      t16         :<---->:      :<---->:  t14   :<---->: :<---->:                : ____ :      :<---->: :______: :      : _______CLK_____________:/  1 /:______:______:/   2    /:______:/   3   /_______                              :                 :                              : t13             :  t17                              :<---->:          :<---->:       _____________________________ :______________   :______________   ___I/O___///////////////////////////////:_______1______X-X_______2_______X-X___5us  <= t10                          10us <= t14 <= 100us Clock low after RST5us  <= t11                          10us <= t15 <= 50us  Clock High50us <= t12 ........ Reset High      10us <= t16 <= 100us Clock Lowt13  <= 10us  Propagation delay      t17 <= 10us  Propagation delay           Figure2 : Reset of the card when a synchronous answer is expected.


NOTES:

1 - The internal state of the card is assumed not to be defined before reset. Therefore the design of the card has to avoid inproper operation.

2 - In order to continue the dialogue with the card, RST shall be maintained in the state where an answer occurs on I/O.

3 - Reset of a card can be initiated by the interface device at its discetion at any time.

4 - Interface devices may support one or more of these types of reset behaviour. The priority of testing for asynchronous or synchronous cards is not defined in this standard.

智能卡的操作系统——COS

智能卡的操作系统——COS
 
随着 Ic卡从简单的同步卡发展到异步卡,从简单的 EPROM卡发展到内带微处理器的智能卡(又称CPU卡),对IC卡的各种要求越来越高。而卡本身所需要的各种管理工作也越来越复杂,因此就迫切地需要有一种工具来解决这一矛盾,而内部带有微处理器的智能卡的出现,使得这种工具的实现变成了现实。人们利用它内部的微处理器芯片,开发了应用于智能卡内部的各种各样的操作系统,也就是在本节将要论述的COS。 COs的出现不仅大大地改善了智能卡的交互界面,使智能卡的管理变得容易;而且,更为重要的是使智能卡本身向着个人计算机化的方向迈出了一大步,为智能卡的发展开拓了极为广阔的前景。
 
1 COS概述
 
COS的全称是Chip Operating System(片内操作系统),它一般是紧紧围绕着它所服务的智能卡的特点而开发的。由于不可避免地受到了智能卡内微处理器芯片的性能及内存容量的影响,因此,COS在很大程度上不同于我们通常所能见到的微机上的操作系统(例如DOS、UNIX等)。首先,COS是一个专用系统而不是通用系统。即:一种COS一般都只能应用于特定的某种(或者是某些)智能卡,不同卡内的COS一般是不相同的。因为coS一般都是根据某种智能卡的特点及其应用范围而特定设计开发的,尽管它们在所实际完成的功能上可能大部分都遵循着同一个国际标准。其次,与那些常见的微机上的操作系统相比较而言,COS在本质上更加接近于监控程序、而不是一个通常所谓的真正意义上的操作系统,这一点至少在目前看来仍是如此。因为在当前阶段,COS所需要解决的主要还是对外部的命令如何进行处理、响应的问题,这其中一般并不涉及到共享、并发的管理及处理,而且就智能卡在目前的应用情况而盲,并发和共享的工作也确实是不需要曲。COS在设计时一般都是紧密结合智能卡内存储器分区的情况,按照国际标准(ISO/IEC7816系列标准)中所规定的一些功能进行设计、开发。但是由于目前智能卡的发展速度很快,而国际标准的制定周期相对比较长一些,因而造成了当前的智能卡国际标准还不太完善的情况,据此,许多厂家又各自都对自己开发的COS作了一些扩充。就目前而言,还没有任何一家公司的CoS产品能形成一种工业标准。因此本章将主要结合现有的(指1994年以前)国际标准,重点讲述CO5的基本原理以及基本功能,在其中适当地列举它们在某些产品中的实现方式作为例子。
COs的主要功能是控制智能卡和外界的信息交换,管理智能卡内的存储器并在卡内部完成各种命令的处理。其中,与外界进行信息交换是coS最基本的要求。在交换过程中,COS所遵循的信息交换协议目前包括两类:异步字符传输的 T=0协议以及异步分组传输的T=l协议。这两种信息交换协议的具体内容和实现机制在ISO/IEC7816—3和ISO/IEC7816—3A3标准中作了规定;而COS所应完成的管理和控制的基中功能则是在ISO/IEC7816—4标准中作出规定的。在该国际标准中,还对智能卡的数据结构以及COS的基本命令集作出了较为详细的说明。至于ISO/IEC7816—1和2,则是对智能卡的物理参数、外形尺寸作了规定,它们与COS的关系不是很密切。
 
2 COS的体系结构
 
依赖于上一节中所描述的智能卡的硬件环境,可以设计出各种各样的cos。但是,所有的COS都必须能够解决至少三个问题,即:文件操作、鉴别与核实、安全机制。事实上,鉴别与核实和安全机制都属于智能卡的安全体系的范畴之中,所以,智能卡的coS中最重要的两方面就是文件与安全。但再具体地分析一下,则我们实际上可以把从读写设备(即接口设备IFD)发出命令到卡给出响应的一个完整过程划分为四个阶段,也可以说是四个功能模块:传送管理器(TM)、安全管理器(SM)、应用管理器(AM)和文件管理器(FM),如图6.35中所示。其中,传送管理器用于检查信息是否被正确地传送。这一部分主要和智能卡所采用的通信协议有关;安全管理器主要是对所传送的信息进行安全性的检查或处理,防止非法的窃听或侵入;应用管理器则用于判断所接收的命令执行的可能性;文件管理器通过核实命令的操作权限,最终完成对命令的处理。对于一个具体的COS命令而言,这四个阶段并不一定都是必须具备的,有些阶段可以省略,或者是并人另一阶段中;但一般来说,具备这四个阶段的COS是比较常见的。以下我们将按照这四个阶段对COS进行较为详细的论述。
 
在这里需要提起注意的是,智能卡中的“文件”概念与我们通常所说的“文件”是有区别的。尽管智能卡中的文件内存储的也是数据单元或记录,但它们都是与智能卡的具体应用直接相关的。一般而言,一个具体的应用必然要对应于智能卡中的一个文件,因此,智能卡中的文件不存在通常所谓的文件共享的情况。而且,这种文件不仅在逻辑广必须是完整的,在物理组织上也都是连续的。此外,智能卡中的文件尽管也可以拥有文件名(FileN8me),但对文件的标识依靠的是与卡中文件—一对应的文件标识符(F3te ldentifier),而不是文件名。因为智能卡中的文件名是允许重复的,它在本质上只是文件的一种助记符,并不能完全代表莱个文件。
 
1.传送管理(Transmission Manaeer)
 
传送管理主要是依据智能卡所使用的信息传输协议,对由读写设备发出的命令进行接收。同时,把对命令的响应按照传输协汉的格式发送出去。由此可见,这一部分主要和智能卡具体使用的通信协议有关;而且,所采用的通信协议越复杂,这一部分实现起来也就越困难、越复杂。
我们在前面提到过目前智能卡采用的信息传输协议一般是T=0协议和T=1协议,如果说这两类协议的COS在实现功能上有什么不同的话,主要就是在传送管理器的实现上有不同。不过,无论是采用T=0协议还是T=1协议,智能卡在信息交换时使用的都是异步通信模式;而且由于智能卡的数据端口只有一个,此信息交换也只能采用半双工的方式,即在任一时刻,数据端口上最多只能有一方(智能卡或者读写设备)在发送数据。 T=0、T=1协议的不同之处在于它们数据传输的单位和格式不一样,T=0协汉以单字节的字符为基本单位,T=1协议则以有一定长度的数据块为传输的基本单位。传送管理器在对命令进行接收的同时,也要对命令接收的正确性作出判断。这种判断只是针对在传输过程中可能产生的错误预言的,并不涉及命令的具体内容,因此通常是利用诸如奇偶校验位、校验和等手段来实现。对分组传输协议,则还可以通过判断分组长度的正确与否来实现。当发现命令接收有错后,不同的信息交换协议可能会有不同的处理方法:有的协议是立刻向读写设备报告,并且请求重发原数据;有的则只是简单地在响应命令上作一标记,本身不进行处理,留待它后面的功能模块作出反应。这些都是由交换协议本身所规定的。
如果传送管理器认为对命令的接收是正确的,那么,它一般是只将接收到的命令的信息部分传到下—功能模块,即安全管理器,而滤掉诸如起始位、停止位之类的附加信息。相应地,当传送管理器在向读写设备发送应答的时候,则应该对每个传送单位加上信息交换协议中所规定的各种必要的附属信息。
 
2.安全体系(—SecvritySCructure)
 
智能卡的安全体系是智能卡的COs中一个极为重要的部分,它涉及到卡的鉴别与核实方式的选择,包括COS在对卡中文件进行访问时的权限控制机制,还关系列卡中信息的保密机制。可以认为,智能卡之所以能够迅速地发展并且流行起来.其中的一个重要的原因就在于它能够通过COS的安全体系给用户提供—个较高的安全性保证。安全体系在概念上包括三大部分:安全状态(Security Status),安全属性(Security Attributes)以及安全机制(Security Machanisms)。其中,安全状态是指智能卡在当前所处的一种状态,这种状态是在智能—卡进行完复位应答或者是在它处理完某命令之后得到的。事实上,我们完全可以认为智能卡在整个的工作过程中始终都是处在这样的、或是那样的一种状态之中,安全状态通常可以利用智能卡在当前已经满足的条件的集合来表示。安全属性实际上是定义了执行某个命令所需要的一些条件,只有智能卡满足了这些条件,该命令才是可以执行的。因此,如果将智能卡当前所处的安全状态与某个操作的安全属性相比较,那么根据比较的结果就可以很容易地判断出一个命令在当前状态下是否是允许执行的,从而达到了安全控制的目的。和安全状态与安全属性相联系的是安全机制。安全机制可以认为是安全状态实现转移所采用的转移方法和手段,通常包括:通行字鉴别,密码鉴别,数据鉴别及数据加密。一种安全状态经过上述的这些手段就可以转移到另一种状态,把这种状态与某个安全属性相比较,如果一致的话,就表明能够执行该属性对应的命令,这就是COS安全体系的基本工作原理。
从上面对coS安全体系的工作原理的叙述中,我们可以看到,相对于安全属性和安全状态而言,安全机制的实现是安全体系中极力重要的一个方面。没有安全机制,COS就无法进行任何操作。而从上面对安全机制的介绍中,我们可以看到,COS的安全机制所实现的就是如下三个功能:鉴别与核实,数据加密与解密,文件访问的安全控制。因此,我们将在下面对它们分别进行介绍。其中,关于文件访问的安全控制,由于它与文件管理器的联系十分紧密,因此我们把它放到文件系统中加以讨论。
 
(1)鉴别与核实:鉴别与核实其实是两个不同的概念,但是由于它们二者在所实现的功能上十分地相似,所以我们同时对它们进行讨论,这样也有利于在比较中掌握这两个概念。
通常所谓的鉴别(Authentication)指的是对智能卡(或者是读写设备)的合法性的验证,即是如何判定一张智能卡(或读写设备)不是伪造的卡(或读写设备)的问题;而核实(verify)是指对智能卡的持有者的合法性的验证,也就是如何判定一个持卡人是经过了合法的授权的问题。由此可见,二者实质都是对合法性的一种验证,就其所完成的功能而言是十分类似的。但是,在具体的实现方式上,由于二者所要验证的对象的不同,所采用的手段也就不尽相同了。
 
具体而言,在实现原理上,核实是通过由用户向智能卡出示仅有他本人才知道的通行字,并由智能卡对该通行宇的正确性进行判断来达到验证的目的的。在通行字的传送过程中,有时为了保证不被人窃听r还可以对要传送的信息进行加密/解密运算,这一过程通常也称为通行字鉴别。
鉴别则是通过智能卡和读写设备双方同时对任意一个相同的随机数进行某种相同的加密运算(目前常用 DES算法),然后判断双方运算结果的一致性来达到验证的日的的。
根据所鉴别的对象的不同,COS又把鉴别分为内部鉴别(Interna1 Authentication)和外部鉴别(External Authentication)两类。这里所说的“内部”、“外部”均以智能卡作为参照点,因此,内部鉴别就是读写设备对智能卡的合法性进行的验证;外部签别就是智能 F对读写设备的合法性进行的验证。至于它们的具体的实现方式.我们在第5章中已有详细论述,此处不再重复。
智能卡通过鉴别与核实的方法可以有效地防止伪卡的使用,防止非法用户的入侵,但还无法防止在信息交换过程中可能发生的窃听,因此,在卡与读写设备的通信过程中对重要的数据进行加密就作为反窃听的有效手段提了出来。关于数据加密的原理与方式可以参阅第5章。我们下面仅对加密中的一个重要部件——密码在COS中的管理及存储原理加以说明。
 
(2)密码管理:目前智能卡中常用的数据加密算法是DES算法。采用DES算法的原因是因为该算法已被证明是一个十分成功的加密算法,而且算法的运算复杂度相对而言也较小,比较适用于智能卡这样运算能力不是很强的情况。 DES算法的密码(或称密钥)长度是64位的。 COS把数据加密时要用到的密码组织在一起,以文件的形式储存起来,称为密码文件。最简单的密码文件就是长度为8个字节的记录的集合,其中的每个记录对应着一个DES密码;较为复杂的密码文件的记录中则可能还包含着该记录所对应的密码的各种属性和为了保证每个记录的完整性而附加的校验和信息,其结构如图6.37所示。
其中的记录头部分存储的就是密码的属性信息,例如是可以应用于所有应用文件的密码还是只对应某一应用文件可用的密码;是可以修改的还是只能读取的密码等等。但是:不论是什么样的密码文件,作为一个文件本身,COS都是通过对文件访问的安全控制机制来保证密码文件的安全性的。
当需要进行数据加密运算时,COS就从密码文件中选取密码加入运算。从密码文件中读出密码时,与读取应用数据一样,只要直接给出密码所在的地址就可以了。当然,员简单的产生密码的方法是直接从密码文件中随机读出一个密码作为加密用密码。但是这样的机制可能会多次选中同一密码,从而给窃听者提供破译的机会,安全性不太高。因此,比较好的办法是在随机抽取出一个密码后再对密码本身作一些处理,尽量减少其重复出现的机会。例如PBOS产品中,采用的办法就是对从密码文件中选出的密码首先进行一次DES加密运算,然后将运算结果作为数据加密的密码使用。其计算公式如下:
Key = DES(CTC, K(a))
式中,K是从密码文件中随机选取的一个密码;CTC是一个记录智能卡的交易次数的计数器,该计数器每完成一次交易就增一;key就是最后要提供给数据加密运算使用的密码。使用这种方法可以提高智能卡的安全性,但却降低了执行的效率。因此,具体采用什么样的方法来产生密码应当根据智能卡的应用范围及安全性要求的高低而具体决定。
 
3.应用管理器(Application Manager)
 
应用管理器的主要任务在于对智能卡接收的命令的可执行性进行判断。关于如何判断一条命令的可执行性,我们已经在安全体系一节中作了说明,所以我们可以认为,应用管理器的实现主要是智能卡中的应用软件的安全机制的实现问题。而因为智能卡的各个应用都以文件的形式存在,所以应用管理器的本质就是我们将要在下一节加以词论的文件访问的安全控制问题。正是基于这一点,我们也可以把应用管理器看作是文件管理器的一个部分。
 
4.文件管理器(File Manager)
 
与安全一样,文件也是COs中的一个极为重要的概念。所谓文件,是指关于数据单元或卡中记录的有组织的集合。 COS通过给每种应用建立一个对应文件的方法来实现它对各个应用的存储及管理。因此,COS的应用文件中存储的都是与应用程序有关的备种数据或记录。此外,对某些智能卡的CoS,可能还包含有对应用文件进行控制的应用控制文件。在COS中,所有的文件都有一个唯一的文件标识符(File ldentifier),因此通过文件标识符就可以直接查找所需的文件。此外,每个文件还可以有一个文件名作为助记符,它与文件标识符的不同之处在于它是可以重复的。COS中的各文件在智能卡的个人化过程中由发行商(Issuer)根据卡的应用而创建,对卡的用户而言通常是不能对文件进行创建或删除的。但是用户可以根据情况对文件内容进行修改,可以对文件中的记录或数据单元进行增加、删除等操作。
 
(l)文件系统:COS的文件按照其所处的逻辑层次可以分为三类;主文件(MasterFile),专用文件(Dedicated File)以及基本文件(EIementary File)。其中,主文件对任何COS都是必不可少的,它是包含有文件控制信息及可分配存储区的唯一文件,其作用相当于是COS文件系统的根文件,处于COS文件系统的最高层;基本文件也是必不可少的一个部分,它是实际用来存储备应用的数据单元或记录的文件,处于文件系统的最底层,而专用文件是可选的,它存储的主要是文件的控制信息、文件的位置、大小等数据信息。我们可以用图6.38的树状结构来形象地描述一个COS的文件系统的基本结构。
 
    主文件(MF)----------专用文件(DF)----------基本文件(EF)
        |                                   |                           |---------EF
        |                                    |-----------------DF--------EF
        |                            |-----------EF
        |----------EF
        |----------EF
                图:6.38
 
当然,对于具体的某个COS产品,很可能由于应用的不同,对文件的实际分类标陈会有所不同。但只要仔细地进行分析,都可以归结为上面的三个逻辑层次。例如前面授到过的PCOS产品。该产品的存储器分区情况在前面谈到图6.34的时候已经作了说明。它对文件的分类不是按照逻辑层次划分的,而是根据文件的用途进行的。它的文件分为三类:COS文件(COSFile)、密码文件(KeyFile)和钱夹文件(PursesFile)。其中所谓的COS文件保存有基本的应用数据;密码文件存储的是进行数据加密时要用到的密码;钱夹文件的作用有些类似于我们日常生活中的钱包。由此可见,它的这三类文件本质上其又都届今基本文件(EF)类。在PCOS中,专用文件的慨念不是很明显,但是事实上,如果大家留心的话,那么从以前的论述中,应该不难发现该产品存储器分区中FAT区内的文件捆;交器的作用就类似于专用文件;而整张PCoS卡本身的性质实际就是一个主文件。
 
cos文件有四种逻辑结构:透明结构,线性定长结构,线性变长结构,定长循环结构。它们的定义及特点可以参阅ISO/IEC7816—4协议中的有关部分,这里不再详述。不过.无论采取的是什么样的逻辑结构,cos中的文件在智能卡的存储器中都是物理上连续存放的。卡中数据的存取方式、记录的编号方法、数据单元的大小等作为文件系统的特征,在智能卡的复位应答过程中由卡给出。职过一般而言,在智能卡中最为重要的数据存取方式还是随机存取方式,也就是卡的用户在得到授权后,可以直接地任意访问文件中的某个数据单元或记录。至于COS具体对文件可以进行什么样的操作.我们将在C()3的命令系统中进行讨论。
 
(2)文件访问安全:对文件访问的安全性控制是COS系统中的一个十分重要的部分,由于目前的国际标准(ISO/IEC7816-4)在这方面基本没有作出什么实质性的规定,因此,现有的文件访问的安全控制机制的具体实现方式多种多样。我们在这里准备介绍其中比较有代表性的两种实现方式:鉴别寄存器方式以及状态机方式。其中,采用鉴别寄存貉方式的有PCOS、ME2000等产品:采用状态机方式的产品有STARCOS。
采用鉴别寄存器方式时,通常是在内存RAM中设置一个8位(或者是16位)长的区域作为鉴别用寄存器。这里的鉴别是指对安全控制密码的鉴别。鉴别用寄存器所反映的是智能卡在当前所处的安全状态。采用这种方式时,智能卡的每个文件的文件头(或者是文件描述器)中通常都存储有该文件能够被访问的条件,——般是包括读、写两个条件r分别用Cr、Cu表示),这就构成了该文件的安全属性。而用户通过向智能卡输入安全密码.就可以改变卡的安全状态,这一过程我们j至常称为出示,这就是鉴别寄存器为式的安全机制。把上面的二方面结合起来,就能够对卡中文件的读写权限加以控制了。具体的操作机制我们以 PCOS为例加以描述。
 
首先,PBOS中的鉴别寄存器是8位字长的,这 s位dI的假;位分别与PC()3存储器中保密宇区(参见园6.34)内的7个安全密码的序号一一对应。寄存器中每——位的初始值都被置为“0”。如果用户向智能卡出示了某一个安全密妈,并且被F判断为正确的话,系统就在鉴别寄存器的相应位上写入“1”。例如,如果处于保密宇区中的第2个安全密码被用户正确出示的话,PCOS就在寄存器的第2位上写“1”。同时,文件描述器中的读、写条件Cr、Cu保存的都是在0和7之间的一个数,它的值对应于该文件进行读(或写)操作时所需要出示的密码在保密宇区小的序号。在对某个文件进行读(或写)操作之前,系统首先判断在鉴别寄存器巾对应的第Cr(或Cu)位是否已被置为“1”(如果Cr等于0,就表示该文件可以被用户随意读取;对于Cu也是一样),只有当该位为“1”时,才表示读(或写)权限已经得到满足.才能对该文件进行读(或写)操作。这也就是说,如果用户想要对一个文件进行操作的话,就必须要首先出示对应于该文件的安全属性为正确的安全密码。系统据此就达到了对文件的访问进行安全控制的目的。
 
与鉴别寄存器方式完全不一样,状态机方式更加明显地表示出扩安全状态、安全属性以及安全机制的概念以及它们之间的关系(关于状态机的知识不属于本书的范畴,有兴趣的读者请自行查阅有关资料)。以5TARCOS为例,它采用的是‘—种确定状态机的机制,该机制通过系统内的应用控制文件(Applicatlon ControIFile,ACF)而得以实现。 ACF文件的格式如图6.39所示,已是一个线性变长结构的文件,其rh记录 01包括了该ACP所控制的应用可以允许的所有命令的指令码(INS);其余的记录分别与记录 01中的指令码一一对应,其中存储的都是对府命令的变体(Varient)纪录。所谓变体记录指的是这样的一些记录。记录中存储的是控制信息、初始状态、可能的下一状态以及某些附加的指令信富的组台,利用 ACF 中的这些变体记录就可以形成状态转移图。在变体记录中,控制信息部分是必不可少的。不同的变体记录主要在两个方面有区别:一是命令所允许的状态不同t二是以CLA宇节开始的指令信息部分不相同。这主要是由命令要操作的应用对象的不同而决定的。
利用 ACF,COS系统就可以实现对文件访问的安全控制了。当系统接收到一个应用进行操作的一条命令后,首先检验其指令码是否在相应的ACF文件的记录01中。如果不在其中,系统就认为该命令是错误的。在找到了对应的指令码后,系统把命令的其余部分与该命令对应的备变体记录中的指令信息按照该变体记录的控制信息的要求进行比较,如果比较结果一致,那么再查验变体记录中的初始状态信息。若所有这些检测都顺利通过,那么系统就进入对应变体记录中指明的下一状态;否则,继续查找下一个变体记录直到发现相应变体或是查完该命令对应的所有变体记录为止。如果没有找到相应的变体记录,说明该命令是非法的;否则就进入下一步对命令的处理,即由 COS调用实际的处理过程执行对命令的处理。当且仅当处理过程正常结束的时候,系统才进入一个新的状态,并开始等待对下一条命令的接收。
 
(转自:≡中国电子技术信息网≡ 网址:www.EC66.com)

智能卡概论

智能卡概论
1.1智能卡基础知识
1.1.1什么是智能卡
智能卡的名称来源于英文名词“Smart card”,又称集成电路卡,即 IC卡(Integrated Circuitcard)。它将一个集成电路芯片镶嵌于塑料基片中,封装成卡的形式,其外形与覆盖磁条的磁卡相似。
IC卡的概念是7O年代初提出来的,法国布尔(BULL)公司于1976年首先创造出 IC卡产品,并将这项技术应用到金融、交通、医疗、身份证明等多个行业,它将徽电子技术和计算机技术结合在一起,提高了人们生活和工作的现代化程度。
IC卡芯片具有写入数据和存储数据的能力,IC卡存储器中的内容根据需要可以有条件地供外部读取,成供内部信息处理和判定之用。根据卡中所镶嵌的集成电路的不同可以分成以下三类:
1.存储器卡 卡中的集成电路为EEPROM(可用电擦除的可编程只读存储器
2.逻辑加密卡 卡中的集成电路具有加密逻辑和ZEPROM。
3.CPU卡 卡中的集成电路包括中央处理器CPU、EEPROM、随机存储器RAM以及固化在只读存储器ROM中的片内操作系统COS(ChiPOperatingSystem)。
严格地讲,只有CPU卡才是真正的智能卡,但在本书中,为了论述全面,更为了应用的需要,我们将研究讨论上述三种IC卡。
按应用领域来分,IC卡有金融卡和非金融卡两种。
金融卡又有信用卡(credtt card)和现金卡(debit card)等。信用卡主要由银行发行和管理,持卡人用它作为消费时的支付工具,可以使用预先设定的透支限额资金。现金卡可用作电子存折和电子钱包,不允许透支。
非金融卡往往出现在各种事物管理、安全管理场所,如身份证明、健康记录和职工考勤等。
按卡与外界数据传送的形式来分,有接触型IC卡和非接触型IC卡两种。当前使用广泛的是接触型IC卡,在这种卡片上,IC芯片有8个触点可与外界接触。非接触型IC卡的集成电路不向外引出触点,因此它除了包含前述三种IC卡的电路外,还带有射频收发电路及其相关电路。
在IC卡推出之前,从世界范围来看,磁卡已得到广泛应用,为了从磁卡平稳过泼到IC卡,也是为了兼容,在IC卡上仍保留磁卡原有的功能,也就是说在IC卡上仍贴有磁条,因此IC卡也可同时作为磁卡使用,IC卡的外观:正面中左侧的小方块中有8个触点,其下面为凸型字符,背面有磁条。正面还可印刷各种图案,甚至人像。卡的尺寸、触点的位置与用途、磁条的位置及数据格式等均有相应的国际标准予以明确规定。
无论是磁卡还是IC卡,卡上都有唯一的发行人和持卡人的识别标志,这种卡有时称之为识别卡。
 
1.1.IC卡的接口设备
 
为了使用卡片,还需要有与IC卡配合工作的接口设备IFD(InterFace Device),或称为读写设备。IFD可以是一个由微处理器、键盘、显示器与I/O接口组成的独立设备,该接口设备通过IC卡上的8个触点向IC卡提供电源井与IC卡相互交换信息。IFD也可以是一个简单的接口电路,IC卡通过该电路与通用微机相连接。无论是磁卡或IC卡,在卡上能存储的信息总是有限的,因此大部分信息需要存放在接口设备或计算机中。当用信用卡购物时,如在允许透支范围内,则可以先取走商品,事后再结算;如需一笔大款,则需经银行确认,授权于商店后,才能取走商品。由于银行、发放信用卡的公司以及商店不在同一处,因此需要经过通信线路和计算机(主机)联系才能实现上述过程。
为了快速而又可靠地进行处理,计算机网络与通信线路的安全与响应时间是关键。
1.2金融卡的应用基础
IC卡主要用作金融卡,金融卡的主要功能是存储数据和处理数据。
1.2.1 IC卡提供的信息
1.印在卡上的可供人阅读的信息 用以标识卡发行人的标志、使用期限、客户姓名、帐号和签名等,这些信息是卡能作为金融交易中的支付工具的基础。
2.机器可读数据 卡上的凸出字符用于压印帐单,以便向售货商和客户提供交易凭证。卡上还可提供金融交易的帐目。
3.提供机器可读的授权和数据收集系统的标识符。
1.2.2举例:在自动柜员机上实现取款
下面以自动柜员机ATM为例进行说明。
自动柜员机是放在银行或商店大堂中供客户自动提款的机器(有的 ATM还有自动存款功能)。执行从ATM提取现金的操作仅需十几秒钟,总共只需要作出4个输入动作:
1.插入金融卡;
2.输入个人标识码(PIN);
3.选择交易类型(取款);
4.给出申请提取的金额。
当 ATM判别没有问题时,自动输出卡和现金,并打印凭证。由此可见,ATM是一种操作方便的信息处理系统,可以24小时提供服务。
ATM是安装在柜里的计算机系统,它要处理卡片、货币、收据和信封(存款用)四种介质,并能与相连接的远程计算机相互通信。它的内部有严密的可靠的物理和逻辑安全措施。它的每一笔交易通常接受正确纳授权和严格的控制,因此ATM系统既是一个操作简单的系统,又是一个构造复杂的系统。
ATM将磁条上(对磁卡)的数据,诸如发行人和客户帐号识别码(用来获取自动授权信息的基础)通过通信线路与发卡单位的计算机及其帐户数据库相连,用以检查金融卡的编号(查对黑名单),以防止他人使用已挂失的或偷窃来的金融卡,同时核对客户的帐面记录,以查明可供支用的金额,并根据交易的金额随即更新帐面记录滁金融卡下次使用。此外,为了避免某些可能发生的弊端(如已挂失但尚未列入黑名单),还要限制金融卡在一天内允许使用的次数和一天内允许提取现金的总金额。
绝大多数ATM机取款时还需输入个人标识符PIN,并将PIN送到计算机,用来核对待卡人是否是卡的主人。如在通信线路上明文传送PIN,存在被窃听的危险,为此需对PIN进行加密,这就要提供一个加密算法和“密钥”,让经过加密后的PIN在通信线路上传送,在接收端解密,因此在接收端提出了密钥的管理和保护的要求。
1.2.3 IC卡存储区的分配和功能简介
IC卡的存储量比磁卡大得多,一般分四个存储区。
1.公开的(不保密的)存储区 内含公用信息,诸如发行标识符,持卡人的帐号等。
2.外部不可读的存储区 存储的内容是供内部决策用的,如PIN值,该值是在卡片发行时进行个人化处理写入的,用户在输入正确的PIN值后,允许输入新PIN值进行修改,但在任何情况下,都不允许将存储在卡中的PIN值向外界传送。在本存储区内还可能存放密钥。
3.保密存储区 内含帐面余额、允许卡使用的服务类型及限额等。当持卡人输入正确的PIN值后,允许读取本存储区数据,并根据应用情况写入正确数据(如修改余额)。
4.记录区 内含每次交易细节,称为日志,可供查询。
除了存储器卡外,在其它IC卡中还有逻辑电路或徽处理器,提供安全可靠的服务。
1.2.4接口设备存储器内容简介
 
与智能卡配合使用的接口设备(或称为读写设备、读卡器)应该提供附加的存储器和逻辑电路,它本身可能就是一台微机。
用于商店中的接口设备的存储器中包含如下内容:
1.交易数据 内含每次交易记录,一般于每天晚上将当天交易细节汇总后传送到开户银行或发卡银行,供转帐和清算之用。银行应保证及时将应付款存入售货商帐户。
2.非法卡表(或称为黑名单、止付名单)列出所有挂失、被窃或透支超过限额的帐户清单,在每天向银行递交交易细节时,也递交此清单。同时银行经汇总后,应将修改后的黑名单提供给售货商。凡登在黑名单上的帐户或透支超额的帐户要进行交易时,须由售货商用专用电话和银行进一步授权核实后,方可受理。也可拒绝处理,甚至可根据实际情况将卡没收。
3.保密数据 密钥和授权电话号码即属于保密数据,密钥用以生成校验码以防交易日志被修改。至于授权电话,在售货商希望成交某些超额交易时,用它接通用户银行,经银行授权后方可受理,如果电话通信线路很忙,那么等待授权的时间可能很长,甚至能让客户觉得无法容忍,这就会影响到金融卡的推广应用。较先进的系统应靠计算机网络和通信线路来完成授权功能。
1.2.5使用智能卡完成一次购物的操作过程
操作顺序如下:
1.客户拿着金融卡和购买的商品来到付款处。并将金融卡插入能输入PIN的小疑盘设备中。
2.售货员通过他本人工作的键盘输入交易金额。
3.交易金额显示在小键盘设备的显示板上。
4.客户在小键盘上按—下某个指定键,表示对交易金额的认可。
5.小键盘设备的显示板上指示客户输入PIN。然后客户输入PIN。输入后自动与卡中的PIN比较,如一致,就将金融卡自身打开,准备受理交易。
6.接着接口设备内部进行一连串处理,如查对黑名单、核实资金是否够用、计算交易后的余额,将它登人交易日志记录里并计算出安全校验码加在日忘记录中以保证数据的安全。同时把这笔交易记录也写到金融卡中。最后给客户打印收据。
7.显示板指示交易结束,客户取走商品和卡。
1.2.6发展智能卡与人有关的因素
 
参与智能卡操作的相关方面有:持卡人或用户,商店,卡片的发行者及销售部门,卡片的设计者、出售商及安全维护。
1.持卡人或用户
用户要求:
·使用方便:装置的地点、使用的时间和操作的步骤等力求方便。操作一学就会。
·启用手续简易:发行和基于PIN号的卡片个人化处理手续简易。
·加快交易时间:进行一次交易或授权等待时间尽量缩短。
·安全可靠:每次交易正确无误,操作错误后的重新启动方便可靠,卡片的丢失、被窃和 PIN值的更换等容易处理。
·清焚筒单的操作提示:卡片上清楚表明接口方向,显示屏幕清楚易读,避免使用计算机术语和复杂的交互式操作。
2.商店
商店期望:
·人员培养容易,操作过程和例外处理简单。
·故障处理简单:故障处理包括出错后的重新启动,例外情况或交易被矩绝时的处理,以及在正常的解决办法失灵时,其他可供选择的措施。
·安全可靠:对丢失、被窃以及未付帐款的卡片处理办法简单且安全,对各类不安全因素易于检测。
3.卡片的发行者和销售部门
除了满足商店和用户的要求以外,应做好有关方面(银行、商店、用户)之间的信息交换工作,以及用户忘了 PIN后的处理工作等。
4.设计者、出售商及安全维护
 
设计目标应满足用户及商店的要求。电子设备应保证能够每天24小时不间断工作,并能很容易测试判断智能卡是否工作正常。机械设计要保证设备和零件工作可靠。设计好对例外情况的处理办法t并能迅速排除故障。
 
1.2.7智能卡的种类
 
1.信用卡 卡中预先建立允许透支的限额,即预先设置好可借用的资金额度,承谱到期归还并支讨利息的责仟。根据持卡人信用程度的不同,有两种信用卡:金卡和普j园长。前者的透支限额高。
2.现金卡(付款卡)供储蓄帐户使用,持卡使用的资金是窖户已经存放在银行中的存款。
3.ATM卡 只能在ATM中使用的现金卡或信用卡。
4.预付卡 按卡面价值购买,先购买后使用,例如电话和公共系统用的预付卡,电表预付卡等。
另外还有诸如大饭店内部使用的卡,客人进入饭店后,住宿、用餐、娱乐等都可凭卡记帐,离开饭店时结帐。
 
1.3智能卡的安全问题
 
智能卡的作用是替代流通领域中的现金或支票,随着智能卡的推广使用,利用它进行欺诈或作弊的行为也会不断增加,对于出现的不安全问题的解决办法需要在提供合理的效果和防护的保证与所需的成本和投资之间进行平衡,从而提出一个折衷的解决办法。
 
1.3.1影响智能卡安全的若干基本问题
 
在众多智能卡安全问题中有下列基本问题需要解决:
1.智能卡和接口设备之间的信息流j恿 这些流通的信息可以被截取分析,从而可被复制或插入假信号。
2.模拟智能卡(或伪造智能卡)模拟智能卡与接口设备之间的情息,使接口设备无法判断出是合法的还是模拟的智能卡。
3.在交易中司更换智能卡 在授权过程个使用的是合法的智能卡,而在交易数据写入之前更换成另一张卡,因此将交易数据写入替代卡中。
4.修改信用卡中控制余额更新的日期 信用卡使用时需要输入当天日期,以供卡判断是否是当天第一次使用,即是否应将有效余额项更新为最高授权余额(也即是前面讲到的,允许一天内支取的最大金额),如果修改控制余额更新的日期(郧上次使用的日期),并将它提前,则输入当天日期后,接口设备会误认为是当天第一次取款,于是将有效余额更新为最高授权余额,因此利用窃来的卡可取定最高授权的金额,其危害性还在于(在银行提出新的黑名单之前)可重复多次作弊。
5.商店雇员的作弊行为 接口设备写入卡中的数据不正确,或雇员私下将一笔交易写成两笔交易,因此接口设备不允许被借用、私自拆卸或改装。
 
1.3.2安全措施
 
为了安全防护,一般采取以下措施:
1.对持卡人、卡和接口设备的合法性的相互检验,
2.重要数据加密后传送。
3.卡和接口设备中设置安全区,在安全区中包含有逻辑电路或外部不可读的存储区,任何有害的不合规范的操作,将自动禁止卡的进一步操作。
4.有关人员明确各自的责任,并严格遵守。
5.设置止付名单(黑名单)。
 
1.3.3密钥与认证
 
1.IC卡系统中常用的两种密码算法
(1)对称密钥密码算法或秘密密钥密码算法(DES)
(2)非对称密钥密码算法或公共密钥密码算法(RSA)
对持卡人、智能卡和接口设备之间的相互认证以及数据的加密均可采用这两种密码算法中的一种。与加密有关的还有解密和密钢管理,密钥管理包括:密钥的生成、分配、保管和销毁等。对传输的信息进行加密,以防被窃取、更改,从而避免造成损失。对存储的信息进行加密保护,使得只有掌握密钥的人才能读取信息。
2.认证
为防止信息被篡改、伪造或过后否认,特别是对被传输的信息,加密认证就显得更为重要。
(1)信息验证 防止信息被篡改,保护信息的完整性,要求在接收时能发现被策改的数据,例如可采用一定的算法产生附加的校验炳,在接收点进行检验。
(2)数字签名(电子签名)要求:收方能确认发方的签名;发方签名后,不能否认自己的签名;发生矛盾时,公证人(第二方)能仲裁收发方的问题。
为实现数字签名,一般要求用公共密钥解决。
(3)身份认证:用 password或个人身份号PIN进行认证.更可靠的是利用生物特征。
1.3.4卡片的作弊问题
 
从磁卡使用情况来看,造成发卡行损失的有两种情况,
1.呆帐 持卡人到时不付帐。
2.作弊 是由于犯罪行为引起的,因此在塑料卡亡采取厂一些防范措施。例如VISA卡采取了以下措施:正面有全息飞鸽图形;精细的底版印刷;非凸形的标识号,卡片上有签字条,当签字被更改时,签字条立即显示出 VOID(作废)。
其他根据需要还可以作出照片、指纹等个人标识。
除了卡片外,磁条也是很有问题的,例如磁条上的记录具有以下特点:可读出,可更改,可伪造,可模拟,可擦掉。
为了避免由于作弊造成的损失,因此磁卡使用时(尤其是超过现额时)需经过授权验证。
读取IC卡中的信息较磁卡为难,尤其是智能卡,可通过加密验证等手段使得冒用或伪造变得困难起来,因此与磁卡比可使用在脱机情况下。但是实际上没有绝对的秘密可言,因为客观上存在着能力很强的对手,既使有加密方法,也肯定能找到解密的方法,只不过是要耗费多大代价,是否值得的问题,即便是好的设计也会存在不同程度的易被击破的弱点。
 
1.4识别卡的国际标准
 
由于信用卡可在国内备地使用,某些还能在国外使用,因此制定国际和国家标准是迫切需要的,国家标准应该尽量与国际标准一致。
识别卡是一种可识别其发行者和待有者的卡。金长支付业务中用得最多的是信用卡,它是一种识别卡。识别卡分磁卡和 IC卡两类。
 
1.4.1磁卡的国际标准
 
1.物理特性 包括卡的材料、构造、特性、标称尺寸等均应符合国际标准ISO7816:1985。
2.凸印 卡正面显著地凸起的字符称为凸印,用于数据传送,这种传送可以通过压印机,也可以用目视或机器阅读。凸印字符包含标识号,持卡人的姓名和地址。常用的ID—l型卡上凸印字符的位置应符合国际标准SO7SII—3:1985的规定。
凸印字符及其字体的选择应符合ISO tO73—I和 ISO lO73—2和 ISO7811—l附录B、附录C描述的7B字体的规定,凸印字符的字符间距、高度等符合国际标准 ISO7811—1:1985的规定。凸印字符的印刷规范符合ISO1831:1980的规定。
3.磁条 磁条上磁性材料的物理特性和性能特性、编码技术和编码字符集有相应的国际标准ISO7811—2:1985。磁条上:共有三个磁道,第一、二磁道为只读磁道,第三磁道为读写磁道,分别有国际标准ISO7811—4:1985和 ISO7811—5:1985。
 
1.4.2 IC卡(接触型)的国际标准
 
1.物理特性 符合ISO7816:1987中规定的各类识别卡的物理特性和ISO7813中规定的金融交易卡的全部尺寸要求,此外还应符合国际标准ISO7816—1:1987规定的附加特性、机械强度和静电测试方法。
2.触点尺寸与位置。
应符合国际标准ISO 7816—2:1988中的规定。
3电信号与传输协议。
IC卡与接口设备之间电源及信息交换应符合 ISO/IEC7816—3:1989的规定。
4.行业间交换用命令。
有相应的国际标准ISO/IEC7816—4:1994。但该版本尚未正式通过。
5.应用标识符的编号系统和注册过程 应符合国际标准ISO/IEC7816—5:1994中的规定。
IC卡的国际标准是本书重点之一,将在第3章和第4章中描述。
值得一提的是:国际标准是不断充实和完善的,即使是已经通过的国际标准,仍有修改的可能性,读者应注意国际标准的最新版本。
(转自:≡中国电子技术信息网≡ 网址:www.EC66.com)
 
 
原创粉丝点击