?? 073-076.html
字號(hào):
<!-- Edit EirGrabber 3.01 -->
<HTML>
<HEAD>
<TITLE>Smart Card Developer's Kit:Smart Card Commands</TITLE>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="071-073.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="076-078.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>Elementary File Characteristics</B></FONT></P>
<P>An EF is a leaf node of the file hierarchy. It is a file that actually contains data. There are two variants of EFs: an internal EF, which is to be used by applications on the card, and a working EF, which is used as a storage mechanism for information used by an off-card application.
</P>
<P>Within a specific DF, an EF may be identified by a short (5-bit) identifier. There are four variants of working EFs:</P>
<DL>
<DD><B>•</B> A transparent file
<DD><B>•</B> A linear, fixed-length record file
<DD><B>•</B> A linear, variable-length record file
<DD><B>•</B> A cyclic, fixed-length record file
</DL>
<P>A transparent file can be viewed as a string of bytes. When a command is used to read or write information from a transparent file, it is necessary to provide a byte offset (from the start of the file) to the specific byte (within the transparent file) where reading or writing should begin. A command to read or write information from/to a transparent file will also contain a counter or length of the byte string to be read or written to the file.
</P>
<P>Fixed- or variable-length record files are, as their name suggests, files that comprise subdivisions called <I>records</I>. Records (within a file) are identified by a sequence number. In a fixed-length record file, all the records contain the same number of bytes. In a variable-length record file, each record in the file can contain a different number of bytes. As might be suspected, a variable-length record file generally has a significantly higher overhead in read/write access time and in the amount of administrative (data storage) overhead required by the file system.</P>
<P>A cyclic file is a rather unique (to smart card file systems) structure. It allows applications to access a record in a consistent, transparent fashion and yet have the file system itself map this access into a variety of different physical records. This allows the limits of erase and rewrite cycles on EEPROM memory to be somewhat mitigated.</P>
<P>A cyclic file is best thought of as a ring of records. Each successive write to the file performs the operation on the next physical record in the ring. Read operations are performed on the last physical record to which it was actually written.</P>
<P>To manipulate the smart card file system, an application level protocol is defined in the form of a collection of functions for selecting, reading, and writing files. These functions are discussed qualitatively in the following sections. In Appendix A, these commands are presented in a more quantitative fashion, including the specific CLA and INS designations, along with the error and status codes generally returned by the various commands.</P>
<P><FONT SIZE="+1"><B>The Select File Command</B></FONT></P>
<P>The <TT>Select File</TT> command is used to establish what may be thought of as a logical pointer to a specific file in the smart card’s file system. Once a file is selected by this command, any subsequent file manipulation commands, such as those to read or write information, will operate on the file pointed to by this logical pointer. Access to the smart card’s file system is not multithreaded (from the card’s viewpoint), but it is possible to have multiple such logical pointers in play at any point in time. This is done by using the <TT>Manage Channel</TT> command to establish multiple logical channels between the reader-side application and the card. Commands to access different files can then be multiplexed (by the reader-side application), allowing different files on the card to be in various states of access by the reader-side application at the same time.</P>
<P>The primary piece of information the <TT>Select</TT> command must convey (from the reader-side application to the smart cards APDU processor) is the identification of the file that this logical pointer must point to. This identification can be provided in three ways (with the specific addressing mechanism being indicated in the data field of the <TT>Select File</TT> command APDU):</P>
<DL>
<DD><B>•</B> By file identifier (2-byte value)
<DD><B>•</B> By DF name (string of bytes identifying the DF)
<DD><B>•</B> By path (concatenation of file identifiers)
<DD><B>•</B> By short ID
</DL>
<P>Not all smart cards support all four naming mechanisms. For example, the 3K Multiflex card included with this book supports only the first mechanism.
</P>
<P><FONT SIZE="+1"><B>The Read Binary Command</B></FONT></P>
<P>The <TT>Read Binary</TT> command is used by a reader-side application to retrieve some segment of an EF on the card. The EF being accessed must be a transparent file; that is, it cannot be a record-oriented file. If a <TT>Read Binary</TT> command is attempted on a record-oriented EF, the command will abort with an error indicator being returned by the card to the reader-side application.</P>
<P>Two parameters are passed from the reader-side application to the card for this command: an offset pointer from the start of the file to initial byte to be read, and the number of bytes to be read and returned to the reader-side application.</P>
<P><FONT SIZE="+1"><B>The Write Binary Command</B></FONT></P>
<P>The <TT>Write Binary</TT> command is used by a reader-side application to put information into a segment of an EF on the card. The file being accessed must be a transparent file; that is, it cannot be a record-oriented file. If a <TT>Write Binary</TT> command is attempted on a record-oriented EF, the command will abort with an error indicator being returned by the card to the reader-side application.</P>
<P>Depending on the attributes passed from the reader-side application to the card in the <TT>Write Binary</TT> command, the command can be used to either set a series of bytes in the EF (that is, set selected bits within the designated bytes to a value of <TT>1</TT>), clear a series of bytes in the EF (that is, set selected bits within the designated bytes to a value of <TT>0</TT>), or do a one-time write of a series of bytes in the EF.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="071-073.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="076-078.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</BODY></HTML>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -