http://java.inf.elte.hu/java-1.3/javacard/iso7816.txt

  1. =============================================================================
  2. ISO7816 (part 1-3) asynchronous smartcard information
  3. =============================================================================
  4.  
  5. - Contents -
  6. ------------
  7.  
  8. I ) Introduction of the ISO7816 standard
  9.  
  10. II ) Summary of the ISO7816 standard
  11.  
  12. 2.1 - ISO7816-1 Standard
  13.  
  14. 2.2.1) Minimal Contact Size
  15. 2.2.2) Pin's position
  16.  
  17. 2.2 - ISO7816-2 Standard
  18.  
  19. 2.2.3) Pin Assignement
  20. 2.2.4) Contact Location
  21.  
  22. 2.3 - ISO7816-3 Standard
  23.  
  24. 2.3.1) Electrical Signals Description:
  25. 2.3.2) Voltage and current values:
  26. 2.3.3) Operating procedure for integrated circuit(s) cards:
  27. 2.3.4) Answer to Reset:
  28.  
  29. -----------------------------------------------------------------------------
  30.  
  31. I ) Introduction of the ISO7816 standard:
  32. ====================================
  33.  
  34. II ) Summary of the ISO7816 standard:
  35. ===============================
  36.  
  37. The ISO7816 standard are separated in 3 different parts
  38.  
  39. - ISO7816-1 which define the physical characteristics of the card.
  40. - ISO7816-2 which define dimension and contact position of the card.
  41. - ISO7816-3 which define the electical signals and transmission
  42. protocols.
  43.  
  44. The following organisations should be contacted for more details:
  45.  
  46. - CEN (Comit Eurpen de Normalisation)
  47. rue Brderote 2
  48. B-1000 Brussels
  49. Belgium
  50.  
  51. - ISO (International Standard Institute)
  52. Case postale 56
  53. CH-1211 Genve 20
  54. Switzerland
  55.  
  56. 2.1 - ISO7816-1 Standard
  57. ------------------
  58. The ISO7816 Standard define many physical features, but here we are only
  59. going to describe the more intesting features.
  60.  
  61. * Ultra violet light :
  62. Any protection beyond the ambiant UV light level shall be to the
  63. responsability of the card manufacturer.
  64.  
  65. * X-rays :
  66. Exposure of either side of the card to a dose of 0.1 Gy relative to a
  67. medium-energy X radiation of 70 to 140 Kv (cumulative dose per year)
  68. shall not cause malfunction of the card.
  69.  
  70. * Surface profile of the contacts :
  71. The difference in level between all contacts and the adjacent card
  72. surface shall be less than 0.1 mm.
  73.  
  74. * Mecanical strenght (of the card and contact)
  75.  
  76. The card shall resist damage to its surface and any components contained
  77. in it and shall remain intact during normal use, storage and handling.
  78.  
  79. surface (with pins) must not be damaged by a pression caused by a steel
  80. ball of 1.5 mm diameter on which is applied a strenght of 1.5 N.
  81.  
  82. * Electrical resistance : All the resistances measured between any two
  83. points of the pins must not be over 0.5 Ohm, with any current value
  84. from 50 uA to 300 mA.
  85.  
  86. * Magnetic field : The chip of the card must not be damaged by a static
  87. magnetic field of 79500 A.tr/m
  88.  
  89. * Static electricity : The card must not be damaged by a electrical
  90. discharge of 1500 V of a 100 pF capacitor trought a 1500 Ohm resistance.
  91.  
  92. * card maximal bending :
  93.  
  94. __________
  95. ___,---' '---,___ ^
  96. _,--' '--,_ | f
  97. ,' ', v
  98.  
  99. a - large side of the card
  100. - deformation (f) : 2 cm
  101. - periodicity : 30 bendings a minute
  102.  
  103. b - short side of the card
  104. - deformation (f) : 1 cm
  105. - periodicity : 30 bendings a minute
  106.  
  107. Acceptance: The card must work correctly and must not have any
  108. crackings after 1000 bendings.
  109.  
  110. 2.2 - ISO7816-2 Standard
  111. ------------------
  112. 2.2.1) Minimal Contact Size :
  113.  
  114. ,-------------, ^
  115. | | |
  116. | | | 1.7mm
  117. | | |
  118. '-------------' v
  119. :<----------->:
  120. 2mm
  121.  
  122. 2.2.2) Pin's position :
  123.  
  124. ,-----------------------------------------------------------------
  125. | : :
  126. | : C
  127. | D :
  128. | : ---- ,----, ,----,
  129. | : | C8 | | C4 | -,
  130. | ------- '----' '----' |
  131. | ,----, ,----, |
  132. | | C7 | | C3 | |
  133. | '----' '----' |
  134. | ,----, ,----, | AFNOR position
  135. | | C6 | | C2 | |
  136. | '----' '----' |
  137. | ,----, ,----, |
  138. | | C5 | | C1 | -'
  139. | '----' '----'
  140. | ,----, ,----,
  141. | | C1 | | C5 | -,
  142. | '----' '----' |
  143. | ,----, ,----, |
  144. | | C2 | | C6 | |
  145. | '----' '----' | ISO7816 position
  146. | ,----, ,----, |
  147. | | C3 | | C7 | |
  148. | '----' '----' |
  149. | ,----, ,----, |
  150. | | C4 | | C8 | -'
  151. | '----' '----'
  152. | : :
  153. | A : :
  154. |<------------------------------>: :
  155. | :
  156. | B :
  157. |<----------------------------------->:
  158. |
  159.  
  160. 2.2.3) Pin Assignement: C1 : Vcc = 5V C5 : Gnd
  161. --------------- C2 : Reset C6 : Vpp
  162. C3 : Clock C7 : I/O
  163. C4 : RFU C8 : RFU
  164.  
  165. 2.2.4) Contact Location:
  166. -----------------
  167.  
  168. All the sizes are in milimeters
  169.  
  170. | A B C D | A B C D
  171. ----+------------------------------- ----+-------------------------------
  172. C1 | 10.25 12.25 19.23 20.93 C1 | 17.87 19.87 16.69 18.39
  173. C2 | 10.25 12.25 21.77 23.47 C2 | 17.87 19.87 14.15 15.85
  174. C3 | 10.25 12.25 24.31 26.01 C3 | 17.87 19.87 11.61 13.31
  175. C4 | 10.25 12.25 26.85 28.55 C4 | 17.87 19.87 9.07 10.77
  176. C5 | 17.87 19.87 19.23 20.93 C5 | 10.25 12.25 16.69 18.39
  177. C6 | 17.87 19.87 21.77 23.47 C6 | 10.25 12.25 14.15 15.85
  178. C7 | 17.87 19.87 24.31 26.01 C7 | 10.25 12.25 11.61 13.31
  179. C8 | 17.87 19.87 28.85 28.55 C8 | 10.25 12.25 9.07 10.77
  180. ----+------------------------------- ----+-------------------------------
  181. ISO7816 location AFNOR location
  182.  
  183. NB: The AFNOR location is transitional, and has been used for
  184. compatibility reasons with existing magnetic stripe cards.
  185.  
  186. 2.3 - ISO7816-3 Standard
  187. ------------------
  188.  
  189. 2.3.1) Electrical Signals Description:
  190. ------------------------------
  191.  
  192. I/O : Input or Output for serial data to the integrated circuit inside
  193. the card.
  194.  
  195. VPP : Programing voltage input (optional use by the card).
  196.  
  197. GND : Ground (reference voltage).
  198.  
  199. CLK : Clocking or timing signal (optional use by the card).
  200.  
  201. RST : Either used itself (reset signal supplied from the interface device)
  202. or in combination with an interal reset control circuit (optional
  203. use by the card). If internal reset is implemented, the voltage
  204. supply on Vcc is mandatory.
  205.  
  206. VCC : Power supply input (optional use by the card).
  207.  
  208. NOTE - The use of the two remaining contacts will be defined in the
  209. appropriate application standards.
  210.  
  211. 2.3.2) Voltage and current values:
  212. --------------------------
  213.  
  214. Abbreviations:
  215.  
  216. Vih : High level input voltage
  217. Vil : Low level input voltage
  218. Vcc : Power supply voltage at VCC
  219. Vpp : Programming voltage at VPP
  220. Voh : High level output voltage
  221. Vol : Low level output voltage
  222. tr : Rise time between 10% and 90% of signal amplitude
  223. tf : Fall time between 90% and 10% of signal amplitude
  224. Iih : High level input current
  225. Iil : Low level input current
  226. Icc : Supply current at VCC
  227. Ipp : Programming current at VPP
  228. Ioh : High level output current
  229. Iol : Low level output current
  230. Cin : Input capacitance
  231. Cout: Output capacitance
  232.  
  233. * I/O
  234.  
  235. This contact is used as input (reception mode) or output (transmission
  236. mode) for data exchange. Two possible states exist for I/O:
  237.  
  238. - mark or high state (State Z), if the card and the interface device are
  239. in reception mode or if the state is imposed by the transmitter.
  240. - space or low state (State A), if this state is imposed by the
  241. transmitter.
  242.  
  243. When the two ends of the line are in reception mode, the line shall be
  244. maintained in state Z. When the two ends are in non-matced transmit
  245. mode, the logic state of the line may be indeterminate. During
  246. operations, the interface device and the card shall not both be in
  247. transmit mode.
  248.  
  249. Table 1 - Electrical characteristics of I/O under normal
  250. ------- operation conditions.
  251.  
  252. ,--------+--------------------------------+---------+---------+------,
  253. | Symbol | Conditions | Minimum | Maximum | Unit |
  254. +--------+--------+-----------------------+---------+---------+------+
  255. | | Either | Iih max = +/- 500uA | 2 | VCC | V |
  256. | Vih | (1) +-----------------------+---------+---------+------+
  257. | | or | Iih max = +/- 50uA | 0.7 VCC | VCC (3) | V |
  258. +--------+--------+-----------------------+---------+---------+------+
  259. | Vil | Iil max = 1mA | 0 | 0.8 | V |
  260. +--------+--------------------------------+---------+---------+------+
  261. | | Either | Iol max = +/- 100uA | 2.4 | VCC | V |
  262. | Voh | +-----------------------+---------+---------+------+
  263. | (2) | or | Iol max = +/- 20uA | 3.8 | VCC | V |
  264. +--------+--------+-----------------------+---------+---------+------+
  265. | Vol | Iol max = 1mA | 0 | 0.4 | V |
  266. +--------+--------------------------------+---------+---------+------+
  267. | tr, tf | Cin = 30pF; Cout = 30pF | | 1 | us |
  268. +--------+--------------------------------+---------+---------+------+
  269. | (1) For the interface device, take into account both conditions. |
  270. | (2) It is assumed that a pull up resistor is used in the interface |
  271. | device (recommended value 20k Ohm. |
  272. | (3) The voltage on I/O shall remain between 0.3V and VCC+0.3V. |
  273. '--------------------------------------------------------------------'
  274.  
  275. * VPP
  276.  
  277. This contact may be to supply the voltage required to program or to
  278. erase the internal non-volatile memory. Two possible states exists for
  279. VPP: Idle state and active state, as defined in table 2. The idle state
  280. shall be maintained by the interface device unless the active state is
  281. required.
  282.  
  283. Table 2 : Electrical characteristics of VPP under normal
  284. -------- operation conditions.
  285.  
  286. ,--------+--------------------------------+---------+---------+------,
  287. | Symbol | Conditions | Minimum | Maximum | Unit |
  288. +--------+--------------------------------+---------+---------+------+
  289. | Vpp | Idle State | 0.95*Vcc| 1.05*Vcc| V |
  290. | Ipp | (programming non active) | | 20 | mA |
  291. +--------+--------------------------------+---------+---------+------+
  292. | Vpp | Active State | 0.975*P | 1.025*P | V |
  293. | Ipp | (programming the card) | | I | mA |
  294. +--------+--------------------------------+---------+---------+------+
  295. | The card provides the interface with the values of P and I |
  296. | (default values: P=5 and I=50) |
  297. '--------------------------------------------------------------------'
  298.  
  299. Rise of fall time : 200 us maximum. The rate of change of Vpp shall not
  300. exceed 2V/us.
  301. The maximum power Vpp*Ipp shall not exceed 1.5W when averaged over any
  302. period of 1s.
  303.  
  304. * CLK
  305.  
  306. The actual frequency, delivered by the interface device on CLK, is
  307. designated either by fi the initial frequency during the answer to
  308. reset, or by fs the subsequent frequency during subsequent transmission.
  309.  
  310. Duty cycle for asynchronous operations shall be between 45% and 55% of
  311. the period during stable operation. Care shall be taken when switching
  312. frequencies (from fi to fs) to ensure that no pulse is shorter than 45%
  313. of the shorter period.
  314.  
  315. Table 3 - Electrical characteristics of CLK under normal
  316. ------- operation conditions.
  317.  
  318. ,--------+--------------------------------+---------+---------+------,
  319. | Symbol | Conditions | Minimum | Maximum | Unit |
  320. +--------+--------+-----------------------+---------+---------+------+
  321. | | Either | Iih max = +/- 200uA | 2.4 | VCC (2) | V |
  322. | | (1) +-----------------------+---------+---------+------+
  323. | Vih | or | Iih max = +/- 20uA | 0.7*VCC | VCC (2) | V |
  324. | | (1) +-----------------------+---------+---------+------+
  325. | | or | Iih max = +/- 10uA | VCC-0.7 | VCC (2) | V |
  326. +--------+--------+-----------------------+---------+---------+------+
  327. | Vil | Iil max = +/-200 uA | 0 (2) | 0.5 | V |
  328. +--------+--------------------------------+---------+---------+------+
  329. | tr, tf | Cin = 30pF | |9% of the period|
  330. | | | |with a max:0.5us|
  331. +--------+--------------------------------+---------+---------+------+
  332. | (1) For the interface device, take into account three conditions. |
  333. | (2) The voltage on CLK shall remain between 0.3V and Vcc+0.3V. |
  334. '--------------------------------------------------------------------'
  335.  
  336. * RST
  337.  
  338. Table 4 - Electrical characteristics of RST under normal
  339. ------- operation conditions.
  340.  
  341. ,--------+--------------------------------+---------+---------+------,
  342. | Symbol | Conditions | Minimum | Maximum | Unit |
  343. +--------+--------+-----------------------+---------+---------+------+
  344. | | Either | Iih max = +/- 200uA | 4 | VCC (2) | V |
  345. | Vih | (1) +-----------------------+---------+---------+------+
  346. | | or | Iih max = +/- 10uA | VCC-0.7 | VCC (2) | V |
  347. +--------+--------+-----------------------+---------+---------+------+
  348. | Vil | Iil max = +/- 200uA | 0 (2) | 0.6 | V |
  349. +--------+--------------------------------+---------+---------+------+
  350. | (1) For the interface device, take into account both conditions. |
  351. | (2) The voltage on RST shall remain between 0.3V and VCC+0.3V. |
  352. '--------------------------------------------------------------------'
  353.  
  354. * VCC
  355.  
  356. This contact is used to supply the power voltage Vcc.
  357.  
  358. Table 5 - Electrical characteristics of VCC under normal
  359. ------- operation conditions.
  360.  
  361. ,--------+---------+---------+-------,
  362. | Symbol | Minimum | Maximum | Unit |
  363. +--------+---------+---------+-------+
  364. | Vcc | 4.75 | 5.25 | V |
  365. | Icc | | 200 | mA |
  366. '--------+---------+---------+-------'
  367.  
  368. 2.3.3) Operating procedure for integrated circuit(s) cards:
  369. ---------------------------------------------------
  370. This operating procedure applies to every integrated circuit(s) card with
  371. contacts:
  372.  
  373. The dialogue between the interface device and the the card shall be
  374. conducted through the consecutive operations:
  375.  
  376. - connection and activation of the contacts by the interface device.
  377. - reset of the card.
  378. - answer to reset by the card.
  379. - subsequent information exchange between the card and the interface
  380. device.
  381. - desactivation of the contacts by the interface device.
  382.  
  383. These operations are specified in the following subclauses.
  384.  
  385. NOTE : An active state on VPP should not only be provided and maintained
  386. when requested by the card.
  387.  
  388. a - Connection and activation of the contacts:
  389. -----------------------------------------
  390.  
  391. The electrical circuits shall not be activated until the contacts are
  392. connected to the interface device so as to avoid possible damage to any
  393. card meeting these standards.
  394.  
  395. The activation of the contacts by the interface device shall consist of
  396. the consecutive operations:
  397.  
  398. - RST is in state L;
  399. - VCC shall be powered;
  400. - I/O in the interface device shall be put in reception mode;
  401. - VPP shall be raised to idle state;
  402. - CLK shallbe provided with a suitable and stable clock.
  403.  
  404. b - Reset of the card:
  405. -----------------
  406. A card reset is initiated by the interface device, whereupon the card
  407. shall respond with an Answer to Reset as describe in 2.4.
  408.  
  409. By the end of the activation of the contacts (RST is in L, VCC powered and
  410. stable, I/O in reception mode in the interface device, VPP stable at idle
  411. level, CLK provided with a suitable and stable clock), the card answering
  412. asynchronously is ready for reset.
  413.  
  414. The clock signal is applied to CLK at time T0. The I/O line shall be set
  415. to state Z within 200 clcok cycles of the clock signal (t2) being applied
  416. to CLK (time t2 after T0).
  417.  
  418. An internally reset card reset after a few cycles of clock signal. The
  419. Answer to Reset on I/O shall begin between 400 and 40 000 clock cycles
  420. (t1) after the clock signal is applied to CLK (time t1 after T0).
  421.  
  422. A card with an active low reset is reset by maintaining RST in state L for
  423. at least 40 000 clock cycles (t3) after the clock signal is applied on CLK
  424. (time t3 after T0). Thus if no Answer to Reset begind within 40 000 clock
  425. cycles (t3) with RST in state L, RST is put to state H (at time T1). The
  426. Answer to Reset on I/O shall begin between 400 and 40 000 clock cycles
  427. (t1) after the rising edge of the signal on RST (time t1 after T1).
  428.  
  429. If the Anwser to Reset does not begin within 40 000 clock cycles (t3) with
  430. RST in state H (t3 after T1), the signal on RST shall be returned to state
  431. L (at time T2) and the contacts shall be desactivated by the interface
  432. device.
  433.  
  434. GND ________________________________________________________________________
  435. __________________________________________________________________
  436. VCC _| : :|___
  437. :_______________________________________________________________:
  438. VPP __|: |____
  439. : t3 t3 :
  440. :<--------------------------->:<------------------------------->:
  441. : :_________________________________:
  442. RST ___:_____________________________| |____
  443. : : :
  444. CLK ___|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||____
  445. : t1 : :
  446. :<-------------->: : :
  447. : __________:____________:_________________________________:
  448. I/O __XXXXXXXX |____________:_______Answer____________________:XXXX
  449. (IR) : : : :
  450. : t2 : : t1 :
  451. :<---->: :<---------->: :
  452. : _______________________:_________________________________:
  453. I/O __XXXXXXXX : |______Answer________:XXXX
  454. (AL) : t2 : : :
  455. :<---->: : :
  456. : :_________________________________:
  457. I/O __XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: :XXXXX
  458. (SH) : : :
  459. T0 T1 T2
  460. IR : Internal Reset t2 <= 200/fi
  461. AL : Asynchronous Reset 400/fi <= t1 <= 40000/fi
  462. SH : Syncronous Reset 40000/fi <= t3
  463.  
  464. Figure1 : Reset of the card
  465. -------
  466.  
  467. With a card answering synchonously, the interface device sets all the
  468. lines to state L (See figure 2). VCC is the powered, VPP is set to idle
  469. state, CLK and RST remain in L state, I/O is put in reception mode in the
  470. interface device, RST shall be maintained in state H for at least 50 us
  471. (t12), before returning to state L again.
  472.  
  473. The clock pulse is applied after an interval (t10) from the rising edge of
  474. the reset signal. The duration of the state H of the clock pulse can be
  475. any value between 10 us and 50 us ; no more than one clock pulse during
  476. reset high is allowed. The time interval between the falling edges on CLK
  477. and RST is t11.
  478.  
  479. The first data bit is obtained as an answer to reset on I/O while CLK is
  480. in state L and is valid after an interval t13 from the falling edge on RST.
  481.  
  482. ______________________________________________________________________
  483. VCC__/
  484.  
  485. _____________________________________________________________________
  486. VPP___/
  487. t12
  488. :<---------------->:
  489. :__________________:
  490. RST_____/: \_______________________________________________
  491. : :
  492. : t10 t11 : t15 t16
  493. :<---->: :<---->: t14 :<---->: :<---->:
  494. : ____ : :<---->: :______: : : _______
  495. CLK_____________:/ 1 \:______:______:/ 2 \:______:/ 3 \_______
  496. : :
  497. : t13 : t17
  498. :<---->: :<---->:
  499. _____________________________ :______________ :______________ ___
  500. I/O___//////////////////////////////\:_______1______X-X_______2_______X-X___
  501.  
  502. 5us <= t10 10us <= t14 <= 100us Clock low after RST
  503. 5us <= t11 10us <= t15 <= 50us Clock High
  504. 50us <= t12 ........ Reset High 10us <= t16 <= 100us Clock Low
  505. t13 <= 10us Propagation delay t17 <= 10us Propagation delay
  506.  
  507. Figure2 : Reset of the card when a synchronous answer is expected.
  508. -------
  509.  
  510. NOTES:
  511.  
  512. 1 - The internal state of the card is assumed not to be defined before
  513. reset. Therefore the design of the card has to avoid inproper operation.
  514.  
  515. 2 - In order to continue the dialogue with the card, RST shall be
  516. maintained in the state where an answer occurs on I/O.
  517.  
  518. 3 - Reset of a card can be initiated by the interface device at its
  519. discetion at any time.
  520.  
  521. 4 - Interface devices may support one or more of these types of reset
  522. behaviour. The priority of testing for asynchronous or synchronous cards
  523. is not defined in this standard.
  524.  
  525. c - Deactivation of the contacts
  526. ----------------------------
  527. When informations exchange is terminated or aborted (unresponsive card or
  528. detection of card removal), the electrical contacts shall be desactivated.
  529.  
  530. The deactivation by the interface device shall consist of the consecutive
  531. operations:
  532.  
  533. - State L on RST;
  534. - State L on CLK;
  535. - Vpp inactive;
  536. - State A on I/O;
  537. - VCC inactive;
  538.  
  539. 2.3.4) Answer to Reset:
  540. ---------------
  541. Two types of transmissions are considered:
  542.  
  543. * Asynchronous transmission:
  544. In this type of transmission, characters are transmitted on the I/O line
  545. in an asynchronous half duplex mode. Each character includes an 8bit
  546. byte.
  547.  
  548. * Synchronous transmission:
  549. In this type of transmission, a series of bits is transmitted on the I/O
  550. line in half duplex mode in synchronisation with the clock signal on CLK.
  551.  
  552. a - Answer to Reset in asynchronous transmission
  553. --------------------------------------------
  554.  
  555. * Bit duration
  556. """"""""""""
  557. The nominal bit duration used on I/O is defined as one Elementary Time
  558. Unit (etu).
  559.  
  560. For cards having internal clock, the initial etu is 1/9600 s.
  561.  
  562. For cards using the external clock, there is a linear relationship
  563. between the Elementary Time Unit used on I/O and the period provided
  564. by the interface device on CLK.
  565.  
  566. The initial etu is 372/fi s where fi is in Hertz.
  567.  
  568. The initial frequency fi is provided by the interface device on CLK
  569. during the Answer to Reset.
  570.  
  571. In order to read the initial character (TS), all cards shall initially
  572. be operated with fi in the range of 1 MHz to 5 MHz.
  573.  
  574. * Character frame during answer to reset
  575. """"""""""""""""""""""""""""""""""""""
  576. Prior to the transmission of a character, I/O shall be in state Z.
  577.  
  578. A character consists of ten consecutive bits:
  579.  
  580. - a start bit in state A;
  581. - eight bits of information, designated ba to bh and conveying a
  582. data byte;
  583. - a tenth bit bi used for even parity checking.
  584.  
  585. A data byte consists of 8 bits designated b1 to b8, from the least
  586. significant bit (lsb, b1) to the most significant bit (msb, b8).
  587.  
  588. Conventions (level coding, connecting levels Z/A to digits 1 or 0: and a
  589. bit significance, connecting ba...bh to b1...b8) are specified in the
  590. initial character, call TS, which is transmitted by the card in response
  591. to reset.
  592.  
  593. Parity is correct when the number of ONES is even in the sequence from
  594. ba to bi.
  595.  
  596. Whithin a character, the time from the leading edge of the start bit to
  597. the trailing edge of the nth bit shall equal (n+/-0.2) etu.
  598.  
  599. When searching for a start, the receiver samples I/O periodically. The
  600. time origin being the mean between last observation of level Z and first
  601. observation of level A, the start shall be verified before 0.7 etu, and
  602. then ba is received at (1.5 +/-0.2) etu. Parity is checked on the fly.
  603.  
  604. NOTE : When searching for a start, the sampling time shall be less than
  605. 0.2 etu so that all the test zones are distinct from the transition
  606. zones.
  607.  
  608. The delay between two consecutives characters (between start leading
  609. edges) is at least 12 etu, including a character duration (10+/-0.2) etu
  610. plus a guardtime, the interface device and the card reamain both in
  611. reception, so that I/O is in state Z.
  612.  
  613. Start Parity Next
  614. bit <----- 8 data bits -----> bit Start bit
  615. Z ____ ________________________________......______ __
  616. | | | | | | | | | | | | |
  617. I/O | |ba|bb|bc|bd|be|bf|bg|bh|bi| Guardtime | |
  618. |___|__|__|__|__|__|__|__|__|__| |___|_
  619. A : : : :
  620. 0 t1 : t10
  621. : :
  622. :<---- (n+/-0.2) etu --->:
  623.  
  624. Figure 3: Character frame
  625. --------
  626.  
  627. During the Answer to Reset, the delay between the start leading edges of
  628. two consecutives characters from the card shall not exeed 9600 etu. This
  629. maximum is named initial waiting time.
  630.  
  631. * Error detection and character repetition
  632. """"""""""""""""""""""""""""""""""""""""
  633. During the answer to reset, the following characters repetition
  634. procedure depends on the protocol type. This procedure is mandatory for
  635. cards using the protocol type T=0; it is optional for the interface
  636. device and for the other cards.
  637.  
  638. The transmitter tests I/O (11+/-0.2) etu after the start leading edge:
  639. - If I/O is in state Z, the correct reception is assumed.
  640. - If I/O is in state A, the transmission is assumed to have been
  641. incorrect. The disputed character shall be repeated after a delay
  642. of at least 2 etu after detection of the error signal.
  643.  
  644. When parity is incorrect, from (10.5+/-0.2) etu, the receiver transmits
  645. an error signal at state A for 1 etu minimum and 2 etu maximum. The
  646. receiver then shall expect a repetition of the disputed character (see
  647. figure 8).
  648.  
  649. If no character repetition is provided by the card,
  650. - The card ignores and shall not suffer damage from the error signal
  651. coming from the interface device.
  652. - The interface device shall be able to initiate the reception and
  653. the whole Answer to Reset response sequence.
  654.  
  655. * Structures and content
  656. """"""""""""""""""""""
  657. A reset operation results in the answer from the card consisting of the
  658. initial character TS followed by at most 32 characters in the following
  659. order:
  660.  
  661. - T0 ................... Format character (Mandatory)
  662. - TAi, TBi, TCi, TDi ... Interface characters (Optional)
  663. - T1, T2, ... ,TK ...... Historical characters (Optional)
  664. - TCK .................. Check character (Conditional)
  665.  
  666. Reset
  667. |
  668. | _________________________________________ _______ _________
  669. | | | | | | | | | | | | | | | | |
  670. '-->| TS| T0|TA1|TB1|TC1|TD1|TA2|TB2|TC2|TD2| ......... | T1| ... | TK|TCK|
  671. |___|___|___|___|___|___|___|___|___|___|_ _|___|_ _|__ |___|
  672.  
  673. TS : Initial character
  674. TO : Format character
  675. TAi : Interface character [ codes FI,DI ]
  676. TBi : Interface character [ codes II,PI1 ]
  677. TCi : Interface character [ codes N ]
  678. TDi : Interface character [ codes Yi+1, T ]
  679. T1, ... , TK : Historical characters (max,15)
  680. TCK : Check character
  681.  
  682. Figure 4 : General configuration of the Answer to Reset
  683. --------
  684.  
  685. The interface characters specify physical parameters of the integrated
  686. circuit in the card and logical characteristics of the subsequent
  687. exchange protocol.
  688.  
  689. The historical characters designate general information, for exemple,
  690. the card manufacturer, the chip inserted in the card, the masked ROM
  691. in the chip, the state of the life of the card. The specification of
  692. the historical characters falls outside the scope of this part of
  693. ISO/IEC7816.
  694.  
  695. For national simplicity, T0, TAi, ... ,TCK will designate the bytes as
  696. well as the characters in which they are contained.
  697.  
  698. Structure of TS, the initial character
  699. --------------------------------------
  700. The initial character TS provides a bit shynchronisation sequence and
  701. defines the conventions to code data bytes in all subsequent characters.
  702. These conventions refer to ISO1177.
  703.  
  704. I/O is initially in state Z. A bit synchronisation sequence (Z)AZZA is
  705. defined for the start bit and bits ba bb bc (see figure 5).
  706.  
  707. The last 3 bits bg bh bi shall be AAZ for checking parity.
  708.  
  709. NOTE : This allows the interface device to determinate the etu initially
  710. used by the card. An alternate measurement of etu is a third of the
  711. delay between the first two falling edges in TS. Transmission and
  712. reception mechanisms in the card shall be consistent with the alternate
  713. definition of etu.
  714.  
  715. The two possible values of TS (ten consecutive bits from start to bi and
  716. corresponding hexadecimal value) are
  717.  
  718. - Inverse convention : (Z)ZZAAAAAZ
  719. where logic level ONE is A, ba is b8 (msb is first), equal to $3F
  720. when decoded by inverse convention.
  721.  
  722. - Direct convention : (Z)ZZAZZZAAZ
  723. where logic level ONE is Z, ba is b1 (lsb first), equal to $3B
  724. when decoded by direct convention.
  725.  
  726. Start ba bb bc bd be bf bg bh bi
  727. Z ____ _______ ___________ ______
  728. | | | | | Z Z Z | | | |
  729. (Z)| A | Z Z | A | or | | Z (Z)
  730. A |___| |___|_A___A___A_|___|___|
  731.  
  732. Figure 5 : Initial character TS
  733. --------
  734.  
  735. Structure of the subsequent characters in the Answer to Reset
  736. -------------------------------------------------------------
  737. The initial character TS is followed by a variable number of subsequent
  738. characters in the following order: The format character T0 and,
  739. optionally the interface characters TAi, TBi, TCi, TDi and the
  740. historical characters T1, T2, ... , TK and conditionally, the check
  741. character TCK.
  742.  
  743. The presence of the interface characters is indicated by a bit map
  744. technique explained below.
  745.  
  746. The presence of the historical characters is indicated by the number of
  747. bytes as specified in the format character defined below.
  748.  
  749. The presence of the check character TCK depends on the protocol type(s)
  750. as defined as below.
  751.  
  752. - Format character T0
  753. -------------------
  754. The T0 character contains two parts:
  755.  
  756. - The most significant half byte (b5, b6, b7, b8) is named Y1 and
  757. indicates with a logic level ONE the presence of subsequent
  758. characters TA1, TB1, TC1, TD1 respectively.
  759.  
  760. - The least significant half byte (b4 to b1) is named K and
  761. indicates the number (0 to 15) of historical characters.
  762.  
  763. ,----,----,----,----,----,----,----,----,
  764. | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |
  765. '----'----'----'----'----'----'----'----'
  766. :<------- Y1 ------>:<-------- K ------>:
  767.  
  768. Y1 : indicator for the presence of the interface characters
  769. TA1 is transmitted when b5=1
  770. TB1 is transmitted when b6=1
  771. TC1 is transmitted when b7=1
  772. TD1 is transmitted when b8=1
  773.  
  774. K : number of hitorical characters
  775.  
  776. Figure 6 : Informations provided by T0
  777. --------
  778.  
  779. - Interface characters TAi, TBi, TCi, TDi
  780. ---------------------------------------
  781.  
  782. TAi, TBi, TCi (i=1, 2, 3, ... ) indicate the protocol parameters.
  783. TDi indicates the protocol type T and the presence of subsequent
  784. characters.
  785.  
  786. Bits b5, b6, b7, b8 of the byte containing Yi (T0 contains Y1; TDi
  787. contains Yi+1) state whelther character TAi for b5, character TBi for
  788. b6, character TCi for b7, character TDi for b8 are or are not (depending
  789. on whether the relevant bit is 1 or 0) transmitted subsequently in this
  790. order after the character containing Yi.
  791.  
  792. When needed, the interface device shall attribute a default value to
  793. information corresponding to a non transmitted interface character.
  794.  
  795. When TDi is not transmitted, the default value of Yi+1 is null,
  796. indicating that no further interface characters TAi+j, TBi+j,
  797. TCi+j, TDi+j will be transmitted.
  798.  
  799. ,----,----,----,----,----,----,----,----,
  800. | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |
  801. '----'----'----'----'----'----'----'----'
  802. :<------ Yi+1 ----->:<------- T ------->:
  803.  
  804. Yi+1 : indicator for the presence of the interface characters
  805. TAi+1 is transmitted when b5=1
  806. TBi+1 is transmitted when b6=1
  807. TCi+1 is transmitted when b7=1
  808. TDi+1 is transmitted when b8=1
  809.  
  810. T : Protocol type for subsequent transmission.
  811.  
  812. Figure 7 : Informations provided by TDi
  813. --------
  814.  
  815. - Historical characters T1, T2, ... ,TK
  816. -------------------------------------
  817.  
  818. When K is not null, the answer to reset is continued by transmitting
  819. K historical characters T1, T2, ... , TK.
  820.  
  821. - Check character TCK
  822. -------------------
  823.  
  824. The value of TCK shall be such that the exclusive-oring of all bytes
  825. from T0 to TCK included is null.
  826.  
  827. The answer to reset is complete 12 etu after the leading edge of the
  828. last character.
  829.  
  830. Protocol type T
  831. ---------------
  832. The four least significant bits of any interface character TDi indicate
  833. a protocol type T, specifying rules to be used to process transmission
  834. protocols. When TDi is not transmitted, T=0 is used.
  835.  
  836. T=0 is the asynchronous half duplex character transmission protocol.
  837. T=1 is the asynchronous half duplex block transmission protocol.
  838. T=2 and T=3 are reserved for future full duplex operations.
  839. T=4 is reserved for an enhanced asynchronous half duplex character
  840. transmission protocol.
  841. T=5 to T=13 are reserved for future use.
  842. T=14 is reserved for protocols standardized by ISO.
  843. T=15 is reserved for future extension.
  844.  
  845. NOTE : If only T=0 is indicated, TCK shall not be sent. In all other
  846. cases TCK shall be sent.
  847.  
  848. Specifications of the global interface bytes
  849. --------------------------------------------
  850. Among the interface bytes possibly transmitted by the card in answering
  851. to reset, this subclaus defines only the global interface bytes TA1,
  852. TB1, TC1, TD1.
  853.  
  854. These global interface bytes convey information to determine parameters
  855. which the interface device shall take into account.
  856.  
  857. - Parameters F, D, I, P, N
  858. ------------------------
  859.  
  860. This initial etu is used during answer to reset is replaced by the work
  861. etu during subsequent transmission. F is the clock rate conversion
  862. factor and D is the bit rate adjustment factor to determine the work etu
  863. in subsequent transmissions.
  864.  
  865. For internal clock cards:
  866.  
  867. initial etu = 1/9600 s work etu = (1/D)*(1/9600) s
  868.  
  869. For external clock cards:
  870.  
  871. initial etu = 372/fi s work etu = (1/D)*(F/fs) s
  872.  
  873. The minimum value of fs shall be 1MHz.
  874. The maximum value of fs is given by table 6.
  875.  
  876. I and P define the active state at VPP.
  877. - Maximum programming current : Ipp = 1mA
  878. - Programming voltage : Vpp = P.V
  879.  
  880. N is an extra guardtime requested by the card. Before receiving the next
  881. character, the card requires a delay of at least (12+N) etu from the
  882. start leading edge of the previous character. No extra guardtme is used
  883. to send characters from the card to the interface device.
  884.  
  885. The default values of these parameters are:
  886. F = 372 ; D = 1 ; I = 50 ; P = 5 ; N = 0
  887.  
  888. - Integer values in global interface bytes
  889. ----------------------------------------
  890.  
  891. The global interface bytes, TA1, TB1, TC1, TB2 code integer values FI,
  892. DI II, PI1, N, PI2 which are either equal to or used to compute the
  893. values of the parameters F, D, I, P, N presented above.
  894.  
  895. TA1 codes FI over the most significant half byte (b8 to b5) and DI over
  896. the least significant half byte (b4 to b1).
  897.  
  898. TB1 codes II over the bits b7 and b6, and PI1 over the 5 least
  899. significant bits b5 to b1. The most significant bit b8 equals to 0.
  900.  
  901. NOTE : The interface device may ignore the bit b8 of TB1.
  902.  
  903. TC1 codes N over the eight bits (b8 to b1).
  904.  
  905. TB2 codes PI2 over the eight bits (b8 to b1).
  906.  
  907. Table 6: Clock rate conversion factor F
  908. -------
  909.  
  910. ----------------------------------------------------------------------
  911. FI | 0000 0001 0010 0011 0100 0101 0110 0111
  912. --------------+-------------------------------------------------------
  913. F | Internal clk 372 558 744 1116 1488 1860 RFU
  914. --------------+-------------------------------------------------------
  915. fs (max) MHz | - 5 6 8 12 16 20 -
  916. ----------------------------------------------------------------------
  917.  
  918. ---------------------------------------------------------------
  919. FI | 1000 1001 1010 1011 1100 1101 1110 1111
  920. --------------+------------------------------------------------
  921. F | RFU 512 768 1024 1536 2048 RFU RFU
  922. --------------+------------------------------------------------
  923. fs (max) MHz | - 5 7.5 10 15 20 - -
  924. ---------------------------------------------------------------
  925. RFU : Reserved for Future Use
  926.  
  927. Table 7: Bit rate afjustment factor D
  928. -------
  929.  
  930. -------------------------------------------------------
  931. DI | 0000 0001 0010 0011 0100 0101 0110 0111
  932. ------+------------------------------------------------
  933. D | RFU 1 2 4 8 16 RFU RFU
  934. -------------------------------------------------------
  935.  
  936. -------------------------------------------------------
  937. DI | 1000 1001 1010 1011 1100 1101 1110 1111
  938. ------+------------------------------------------------
  939. D | RFU RFU 1/2 1/4 1/8 1/16 1/32 1/64
  940. -------------------------------------------------------
  941. RFU : Reserved for Future Use
  942.  
  943. - Programming voltage factor P
  944. ----------------------------
  945.  
  946. PI1 from 5 to 25 gives the value of P in volts. PI1=0 indicates that VPP
  947. is connected in the card which generates an internal programming voltage
  948. from VCC. Other values of PI1 are reserved for future use.
  949.  
  950. When PI2 is present, the indication of PI1 should be ignores. PI2 from
  951. 50 to 250 gives the value of P in 0.1V. Other values of PI2 are reserved
  952. for future use.
  953.  
  954. Table 8 : Maximum programming current factor I
  955. -------
  956. -------------------------------
  957. II | 00 01 10 11
  958. -----+-------------------------
  959. I | 25 50 100 RFU
  960. -------------------------------
  961.  
  962. - Extra guardtime N
  963. -----------------
  964.  
  965. N codes directly the extra guard time, from 0 to 254 etu. N=255
  966. indicates that the minimum delay between the start edges of two
  967. consecutives characters is reduced to 11 etu.
  968.  
  969. b - Answer to Reset in synchronous transmission
  970. -------------------------------------------
  971. * Clock frequency and bit rate
  972. """"""""""""""""""""""""""""
  973. There is a linear relationship between the bit rate on the I/O line and
  974. the clock frequency provided by the clock interface device on CLK.
  975.  
  976. Any clock frequency between 7kHz and 50kHz may be chosen for the reset
  977. sequence. A clock frequency of 7kHz corresponds to 7kbit/s, and values
  978. of the clock frequency up to 50kHz cause corresponding bit rates to be
  979. transmitted.
  980.  
  981. * Structure of the header of the Answer to Reset
  982. """"""""""""""""""""""""""""""""""""""""""""""
  983. The reset operation results in an answer from the card containing a
  984. header transmitted from the card to the interface. The header has a
  985. fixed length of 32 bits and begins with two mandatory fields of 8 bits,
  986. H1 and H2.
  987.  
  988. The chronological order of transmission of information bits shall
  989. correcpond to bit identification b1 to b32 with the least significant
  990. bit transmitted first. The numerical meaning corresponding to each
  991. information bit considered in isolation is that of the digit.
  992.  
  993. - 0 for a unit corresponding to state A (space)
  994. - 1 for a unit corresponding to state Z (mark)
  995.  
  996. * Timing of the haeder
  997. """"""""""""""""""""
  998. After the reset procedure, the output information is controlled by clock
  999. pulses. The first clock pulse is applied between 10us and 100us (t14)
  1000. after the falling edge on RST to read the data bits from the card. State
  1001. H of the clock pulses can be varied between 10us and 50us (t15) and
  1002. state L between 10us and 100us (t16).
  1003.  
  1004. The first data bit is obtained on I/O while the clock is low and is
  1005. valid 10us (t13) at least after the falling edge on RST. The following
  1006. data bits are valid 10us (t17) at least after the falling edge on CLK.
  1007. Each data bit is valid until the next falling edge the following clock
  1008. pulse on CLK. The data bits can therefore be sampled at the rising edge
  1009. of the following clock pulses.
  1010.  
  1011. * Data content of the header
  1012. """"""""""""""""""""""""""
  1013. The header allows a quick determination of whelther the card and the
  1014. interface device are compatible. If there is no compatibility, the
  1015. contacts shall be desactivated.
  1016.  
  1017. The first field H1 codes the protocol type. The values of the codes and
  1018. the corresponding protocol type are
  1019.  
  1020. Hexadecimal value protocol type
  1021. -----------------------------------
  1022. 00 and ff not to be used
  1023. 01 to FE each value is assigned
  1024. by ISO/IEC JTC1/SC17 to
  1025. one protocol type
  1026.  
  1027. The second field H2 codes parameters for the protocol type coded in
  1028. field H1. The values of H2 are to be assigned by ISO/IEC JTC1/SC17.
  1029.  
  1030. 2.3.5) Protocol type selection (PTS)
  1031. -----------------------------
  1032. If only one protocol type and FI=D=1 (default value of TA1) and N smaller
  1033. than 255 is indicated in the answer to reset. The transmission protocol
  1034. associated to the protocol type may be started immediately after the
  1035. transmission of answer to reset.
  1036.  
  1037. If more than one protocol type and/or TA1 parameter values other than the
  1038. default values and/or N equeal to 255 is/are indicated in the answer to
  1039. reset, the card shall know unambiguously, after having sent the answer to
  1040. reset, which protocol type or/and transmission parameter values (FI, D, N)
  1041. will be used. Consequently a selection of the protocol type and/or the
  1042. transmission parameters values shall be specified.
  1043.  
  1044. If the card is able to process more than one protocol type and if one of
  1045. those protocol types is indicated as T=0, then the protocol type T=0 shall
  1046. indicated in TD1 as the first offered protocol, and is assumed if no PTS
  1047. is performed.
  1048.  
  1049. If a card offers more than one protocol and if the interface device
  1050. supports only one of these protocols which is not T=0 and does not support
  1051. PTS, the interface should reject or reset the card.
  1052.  
  1053. 2.3.5.a - PTS protocol
  1054. ------------
  1055. Only the interface device is permitted to start a PTS procedure:
  1056.  
  1057. - The interface device sends a PTS request to the card.
  1058. - If the card receives a correct PTS request, it answers by sending a
  1059. PTS confirm, if implemented or the initial waiting time will be
  1060. exceeded.
  1061. - After the succesfull exchange of PTS request and PTS confirm, data
  1062. shall be transmitted from the interface device using the selected
  1063. protocol type and/or transmission parameters.
  1064. - If the card receives an erronous PTS request, it will not send a PTS
  1065. confirm.
  1066. - If the initial waiting time is exceeded, the interface device should
  1067. resetor reject the card.
  1068. - If the interface device receives an erroneous PTS confirm, it should
  1069. reset or reject the card.
  1070.  
  1071. The parameters for the transmission of the PTS request and PTS confirm
  1072. shall correspond to those used within the Answer to Reset regarding the
  1073. bit rate and the convention detected by TS and possibly modified by TC1.
  1074.  
  1075. 2.3.5.b - Structure and content of PTS request and PTS confirm
  1076. ----------------------------------------------------
  1077. The PTS request and PTS response each consist of one initial character
  1078. PTSS, followed by a format character PTS0, three optional parameter
  1079. characters PTS1 PTS2 PTS3, and a character check PCK at the last byte.
  1080.  
  1081. PTSS identifies the PTS request or PTS confirm and is coded FF.
  1082.  
  1083. PTS0 indicates by the bits b5, b6, b7 set to 1 the presence of the
  1084. subsequently sent optional characters PTS1, PTS2, PTS3 respectively. It
  1085. codes over the least significant bits b4 to b1 the selected protocol type
  1086. T as coded in TD bytes. The most significant bit b8 (default b8=0) is
  1087. reserved for future use.
  1088.  
  1089. PTS1 codes the parameter values FI and D as coded in TA1. The interface
  1090. device may send PTS1 in order to indicate the selection FI and/or D values
  1091. to the card. If PTS1 is not sent, FI=1 and D=1 are assumed as defaults.
  1092. The card either acknowledges both the FI and D values by echoing PTS1 or
  1093. does not send PTS1 indicating the use of the default values.
  1094.  
  1095. PTS2 indicates the support of N=255, when bit b1 is set to 1. Bit b1 set
  1096. to 0 is the default and indicates that the 11 etu period is not used. If
  1097. bit b2 is set to 1, the card shall use an extra guardtime of 12 etu for
  1098. its transmssion of characters to the interface device. Bit b2 set to 0 is
  1099. the default and indicates that no extra guardtime is required. Bit b3 to
  1100. b8 are reserved for future use.
  1101.  
  1102. If PTS2 is sent by the interface device and is not echoed by the card, the
  1103. interface device should reject or reset the card.
  1104.  
  1105. The coding and use of PTS3 is not defined.
  1106.  
  1107. The value of PCK shall be such that the exclusive-oring of all charcters
  1108. from PTSS to PCK included is null.
  1109.  
  1110. 2.3.6) Protocol type T=0, asynchronous half duplex character transmission
  1111. protocol----------------------------------------------------------
  1112. --------
  1113. This clause defines the structure and processing of commands initiated by
  1114. an interface device for transmission control and for card specific control
  1115. in an asynchronous half duplex character transmission protocol.
  1116.  
  1117. This protocol uses the parameters indicated by the answer to reset, unless
  1118. modified by the protocol type selection.
  1119.  
  1120. 2.3.6.a - Specific interface parameters: the work waiting time
  1121. ----------------------------------------------------
  1122. In an answer to reset, the interface character TC2 codes the integer value
  1123. WI over eight bits b8 to b1. When no TC2 appears in the answer to reset,
  1124. the default value of WI is 10.
  1125.  
  1126. The interval between the start leading edge of any character sent by the
  1127. card and the start leading edge of the previous character (sent either by
  1128. the card or by the interface device) shall not exceed 960*OWI work etu.
  1129. This maximum delay is named the work waiting time.
  1130.  
  1131. 2.3.6.b - Structure and processing of commands
  1132. ------------------------------------
  1133. A command is always initiated by the interface device. It tells the card
  1134. what to do in a 5-byte header, and allow a transfer of data bytes under
  1135. control of procedure bytes sent by the card.
  1136.  
  1137. It is assumed that the card and the interface device know a priori the
  1138. direction of data, in order to ditinguish between instructions for
  1139. incoming data transfer (where data enter the card during execution) and
  1140. instructions for outgoing data transfers (where data leave the card during
  1141. execution).
  1142.  
  1143. without parity error
  1144. --------------------
  1145.  
  1146. Start Start
  1147. _____ _____________________________________ ___________
  1148. | | | | Byte i | | |P | | | Byte i+1
  1149. |__|__|__|__|__|__|__|__|__|__| guartime |__|___________
  1150.  
  1151. Even
  1152. with a parity error parity
  1153. ------------------- bit
  1154. Start Start
  1155. _____ ______________________________ Error __ ___________
  1156. | | | | Byte i | | |P | | signal | | | Byte i+1
  1157. |__|__|__|__|__|__|__|__|__|__| |________| |__|___________
  1158.  
  1159. Figure 8 : Byte transmission diagram
  1160. --------
  1161.  
  1162. * Command header sent by the interface device
  1163. """""""""""""""""""""""""""""""""""""""""""
  1164. The interface device transmits a header over five successive bytes
  1165. designated CLA, INS, A1, A2, L.
  1166.  
  1167. - CLA is an instruction class. The value FF is reserved for PTS.
  1168.  
  1169. - INS is an instruction code in the instruction class. The instruction
  1170. code is valid only if the least significant bit is 0, and the most
  1171. significant half byte is neither 6 nor 9.
  1172.  
  1173. - P1, P2 are a reference (e.g. an address) completing the instruction
  1174. code
  1175.  
  1176. - P3 codes the number n of data bytes (D1, ... , Dn) which are to be
  1177. transmitted during the command. The direction of movement of these
  1178. data is a function of the instruction. In an outgoing data transfer
  1179. command, P3=0 introduces a 256 byte data transfer from the card. In an
  1180. incoming data transfer command, P3=0 introduces no transfer of data.
  1181.  
  1182. All remaining encoding possibilities for the header are specified in
  1183. subsequent parts of ISO7816.
  1184.  
  1185. After transmission of such 5 byte header, the interface device waits for
  1186. a procedure byte.
  1187.  
  1188. * Procedure bytes sent by the card
  1189. """"""""""""""""""""""""""""""""
  1190. The value of the procedure bytes shall indicate the action requested by
  1191. the interface device. Three types of procedure bytes are specified:
  1192.  
  1193. - ACK : (The seven most significant bits in an ACK byte are all equal or
  1194. complementary to those in the INS byte, apart from the values 6x and
  1195. 9x) The interface device control VPP state and exchanges data
  1196. depending on ACK values.
  1197.  
  1198. - NULL : (=$60) This byte is sent by the card to restart the working
  1199. time, end to anticipate a subsequent procedure byte. It requests no
  1200. further action neither on VPP nor on Data.
  1201.  
  1202. - SW1 (= $6x or $9x, expect $60); The interface device maintains or sets
  1203. VPP at idle and waits for a SW2 byte to complete the command.
  1204.  
  1205. Any transition of VPP state (active/idle) must occur within the
  1206. guardtime of the procedure byte, or on the work waiting time overflow.
  1207.  
  1208. At each procedure byte, the card can proceed with the command by an ACK
  1209. or NULL byte, or show its disaproval by becoming unresponsive, or
  1210. conclude by an end sequence SW1-SW2.
  1211.  
  1212. Byte | Value | Result
  1213. -----+-------+------------------------------------------------------------
  1214. | INS | VPP is idle. All remaining data bytes are transferred
  1215. | | subsequently.
  1216. | |
  1217. | INS+1 | VPP is active. All remaining data bytes are transferred
  1218. | | subsequently.
  1219. ACK | ___ |
  1220. | INS | VPP is idle. Next data byte is transferred subsequently.
  1221. | _____ |
  1222. | INS+1 | VPP is active. Newt data byte is transferred subsequently.
  1223. -----+-------+------------------------------------------------------------
  1224. NULL | $60 | No futher action on VPP. The interface device waits for a
  1225. | | new procedure byte
  1226. -----+-------+------------------------------------------------------------
  1227. SW1 | SW1 | VPP is idle. The interface device waits for a SW2 byte
  1228.  
  1229. Acknoledge bytes
  1230. ----------------
  1231. The ACK bytes are used to control VPP state and data transfer.
  1232.  
  1233. - When exclusive-oring the ACK byte with the INS byte gives $00 or
  1234. $FF, the interface device maintains or sets VPP as idle.
  1235.  
  1236. - When exclusive-oring the ACK byte with the INS byte gives $01 or
  1237. $FE, the interface device maintains or sets VPP as active.
  1238.  
  1239. - When the seven most significant bits in the ACK byte have the same
  1240. value as those in the INS byte, all remaining data bytes (Di, ...,
  1241. Dn) if any remain, are transferred subsequently.
  1242.  
  1243. - When the seven most significant bits in the ACK byte are
  1244. complementary to those in the INS byte, only the next data byte
  1245. (Di), if one remains is transferred.
  1246.  
  1247. After these actions, the interface device waits for a new procedure.
  1248.  
  1249. Null byte (= $60)
  1250. -----------------
  1251. This byte is sent by the card to reset the workwaiting time and to
  1252. anticipate a subsequent procedure byte.
  1253.  
  1254. Status bytes (SW1=$6x or $9x, expect $60; SW2 any value)
  1255. --------------------------------------------------------
  1256. The end sequence SW1-SW2 gives the card status at the end of the command.
  1257.  
  1258. The normal ending is indicated by SW1-SW2 = $90-$00.
  1259.  
  1260. When the most significant half byte SW1 is $6, the meaning of SW1 is
  1261. independant of the application. The following five values are defined:
  1262.  
  1263. $6E The card does not support the instruction class.
  1264. $6D The instruction code is not programmed or is invalid.
  1265. $6B The reference is incorrect.
  1266. $67 The length is incorrect.
  1267. $6F No precise diagnostic is given.
  1268.  
  1269. Other values are reserved for future use by ISO7816.
  1270. When SW1 is neither $6E nor $6D, the card support the instruction.
  1271. This part of ISO7816 does not interprets neither $9X SW1 bytes, nor SW2
  1272. bytes; Their meaning relates to the application itself.
  1273.  
  1274. Supplement (were seen sometimes):
  1275. ---------------------------------
  1276. SW1 SW2 Meaning
  1277.  
  1278. 62 81 Returned data may be corrupted.
  1279. 62 82 The end of the file has been reached before the end of reading.
  1280. 62 84 Selected file is not valid.
  1281. 65 01 Memory failure. There have been problems in writing or reading
  1282. the EEPROM. Other hardware problems may also bring this error.
  1283. 68 00 The request function is not supported by the card.
  1284. 6A 00 Bytes P1 and/or P2 are incorrect.
  1285. 6A 80 The parameters in the data field are incorrect.
  1286. 6A 82 File not found.
  1287. 6A 83 Record not found.
  1288. 6A 84 There is insufficient memory space in record or file.
  1289. 6A 87 The P3 value is not consistent with the P1 and P2 values.
  1290. 6A 88 Referenced data not found.
  1291. 6C XX Incorrect P3 length.

ISO7816 (part 1-3) asynchronous smartcard information的更多相关文章

  1. 《NVM-Express-1_4-2019.06.10-Ratified》学习笔记(5.2)-- Asynchronous Event Request command

    5.2 异步事件请求命令 异步事件用于当状态.错误.健康信息这些事件发生时通知主机软件.为了使能这个controller报告的异步事件,主机软件需要提交一个或多个异步事件请求命令到controller ...

  2. NSOperationQueue 和 NSOperation

    The NSOperationQueue class regulates the execution of a set of NSOperation objects. After being adde ...

  3. k64 datasheet学习笔记52---Universal Asynchronous Receiver/Transmitter (UART)

    1.前言 UART实现与外设或CPU的通信 2. UART概述 2.1基本特性 (1)Full-duplex operation (2)Standard mark/space non-return-t ...

  4. Async/Await - Best Practices in Asynchronous Programming z

    These days there’s a wealth of information about the new async and await support in the Microsoft .N ...

  5. Universal Asynchronous Receiver/Transmitter

    USART簡介與特性 NRZ標準資料格式(Mark/Space) 半雙工/全雙工 Synchronous 同步傳輸 CLOCK SKEW Asynchronous 非同步傳輸 半/全雙工.同步/非同步 ...

  6. stm32 smartcard调试--不用st8024

    关于stm32 smartcard功能调试,官方提供的例程是配合8024芯片进行控制的.程序可从地址:http://www.pudn.com/downloads420/sourcecode/embed ...

  7. win32多线程-异步过程调用(asynchronous Procedure Calls, APCs)

    使用overlapped I/O并搭配event对象-----win32多线程-异步(asynchronous) I/O事例,会产生两个基础性问题. 第一个问题是,使用WaitForMultipleO ...

  8. Asynchronous and Distributed Programming in R with the Future Package

    Every now and again someone comes along and writes an R package that I consider to be a 'game change ...

  9. [转] Linux Asynchronous I/O Explained

    Linux Asynchronous I/O Explained (Last updated: 13 Apr 2012) *************************************** ...

随机推荐

  1. Go 命令行总结

    go build:已当前目录作为package进行编译,将当前目录下的所有文件编译成package文件,文件名与所在的目录同名. go install: 分两步操作:1.先执行go build进行编译 ...

  2. Merkle Tree(默克尔树)算法解析

    Merkle Tree概念 Merkle Tree,通常也被称作Hash Tree,顾名思义,就是存储hash值的一棵树.Merkle树的叶子是数据块(例如,文件或者文件的集合)的hash值.非叶节点 ...

  3. CVE-2013-3346Adobe Reader和Acrobat 内存损坏漏洞分析

    [CNNVD]Adobe Reader和Acrobat 内存损坏漏洞(CNNVD-201308-479) Adobe Reader和Acrobat都是美国奥多比(Adobe)公司的产品.Adobe R ...

  4. JQuery中Table标签页和无缝滚动

    HTML代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...

  5. Struts 2 - Hello World Example

    As you learnt from the Struts 2 architecture, when you click on a hyperlink or submit an HTML form i ...

  6. jsonrpc.js -- 原生js实现 JSON-RPC 协议

    很早以前就涉及到多端远程调用 api的设计,那时候自己设计了个消息传递回调过程.最近了解了JSON-RPC协议,更正规,就可以自己实现下.逻辑也不复杂,没有限制底层消息传递的方式,可以应用到更多的场景 ...

  7. iOS模块器截屏闪退

    最近不知道什么原因,iOS模块器截屏命令点击模拟器就闪退,在此记录下在命令行截屏操作: 第一步:打开对应的模拟器 第二步:模拟器缩放比为100% 第三步:输入以下命令,001.jpg为要保存的文件名  ...

  8. linux系统host修改

    有时候我们需要修改主机的host主机名,方便管理和识别自己的服务器,修改步骤如下: 第一步: vi  /etc/hosts 正常情况下,修改了第一步就可以了,如果通过hostname命令查看还是修改以 ...

  9. ansible安装过程遇到的问题

    1.出现Error: ansible requires a json module, none found! SSH password: 192.168.24.15 | FAILED >> ...

  10. 如何使用django显示一张图片

    django显示图片对新手来说真的算是一个坑.. 这里记录下小白爬坑的历程. 首先,你需要一个可以运行的django服务器,能显示正常的html文本,无法显示图片 这是html的文本,可以显示文字,无 ...