📄 jcrespec09api.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML LANG="en"><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><META NAME="GENERATOR" CONTENT="Adobe FrameMaker 7.0/HTML Export Filter"><LINK REL="STYLESHEET" HREF="unx_unstr_styles.css" CHARSET="ISO-8859-1" TYPE="text/css"><META name="DC.TITLE" content="Runtime Environment Specification for the Java Card Platform, Version 2.2.2"><TITLE>C H A P T E R 9 - API Topics </TITLE></HEAD><BODY BGCOLOR="#ffffff"><DIV><div class="navbar" align="center"><table dir="LTR" summary="Navigation bar, includes the book title and navigation buttons" width=100% cellpadding="0" cellspacing="0" border="0"><colgroup span="2" width="100%"><col id="1" span="1" width="50%"><col id="2" span="1" width="50%"><tr bgcolor="#cccccc"><td class="navbartitle" align=left rowspan="1" colspan="1" abbr="ChapTitle"> Runtime Environment Specification for the Java Card Platform, Version 2.2.2</td><td valign="top" align="right" rowspan="1" colspan="1" abbr="NavButtons"><a href="index.html"><img src="shared/toc01.gif" title="Table Of Contents" alt="Table Of Contents" width="30" height="26" border="0"></a><a href="JCRESpec08rmi.html"><img src="shared/prev01.gif" title="Previous Chapter" alt="Previous Chapter" width="30" height="26" border="0"></a><a href="JCRESpec10vm.html"><img src="shared/next01.gif" title="Next Chapter" alt="Next Chapter" width="30" height="26" border="0"></a><a href="ix.html"><img src="shared/index01.gif" title="Book Index" alt="Book Index" width="30" height="26" border="0"></a></td></tr></table><br><br></div></DIV><TABLE DIR="LTR" SUMMARY="Chapter Number" ABBR="ChapNum" WIDTH="100%" BORDER="0"><COLGROUP SPAN="1" WIDTH="100%"><COL ID="1" SPAN="1"><TR><TD ALIGN="right" CLASS="ChapNumber"><SPAN CLASS="ChapNumPrefix"><A NAME="pgfId-409401"></A>C H A P T E R </SPAN> <SPAN CLASS="ChapNumNum">9</SPAN><A NAME="85430"></A></TD></TR></TABLE><TABLE DIR="LTR" SUMMARY="Chapter Title" ABBR="ChapTitle" WIDTH="100%" BORDER="0"><COLGROUP SPAN="1" WIDTH="100%"><COL ID="1" SPAN="1" WIDTH="100%"><TR><TD ALIGN="right" CLASS="ChapTitle"><HR SIZE=7 NOSHADE><A NAME="pgfId-416933"></A><A NAME="66388"></A><A NAME="marker-416932"></A>API Topics</TD></TR></TABLE><P CLASS="Paragraph"><A NAME="pgfId-416936"></A>The topics in this chapter complement the requirements specified in the <EM CLASS="Emphasis">Application Programming Interface, Java Card Platform, Version 2.2.2</EM>.</P><H2 CLASS="Head1"><A NAME="pgfId-407263"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.1 Resource Use Within the API</H2><P CLASS="Paragraph"><A NAME="pgfId-407265"></A>Unless specified in the <EM CLASS="Emphasis">Application Programming Interface, Java Card Platform, Version 2.2.2</EM>, the implementation shall support the invocation of API instance methods, even when the owner of the object instance is not the currently selected applet. Unless specifically called out, the implementation shall not use resources such as transient objects of <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> type.</P><H2 CLASS="Head1"><A NAME="pgfId-407273"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.2 <A NAME="marker-414003"></A>Exceptions Thrown by API Classes </H2><P CLASS="Paragraph"><A NAME="pgfId-407275"></A>All exception objects thrown by the API implementation shall be temporary Java Card RE Entry Point Objects. Temporary Java Card RE Entry Point Objects cannot be stored in class variables, instance variables, or array components (see <A HREF="JCRESpec06firewall.html#45517" CLASS="XRef">Section 6.2.1, Java Card RE Entry Point Objects</A>).</P><H2 CLASS="Head1"><A NAME="pgfId-407279"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.3 <A NAME="marker-414002"></A>Transactions Within the API</H2><P CLASS="Paragraph"><A NAME="pgfId-407281"></A>Unless explicitly called out in the API descriptions, implementation of the Java Card API methods shall not initiate or otherwise alter the state of a transaction in progress. </P><P CLASS="Paragraph"><A NAME="pgfId-411950"></A>Unless explicitly called out in the API descriptions, updates to internal implementation state within the API objects must be conditional. Internal state updates must participate in any ongoing transaction.</P><H2 CLASS="Head1"><A NAME="pgfId-407289"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.4 <A NAME="marker-414004"></A><KBD CLASS="Filename-Command">APDU</KBD> Class</H2><P CLASS="Paragraph"><A NAME="pgfId-407291"></A>The <KBD CLASS="Filename-Command">APDU</KBD> class encapsulates access to the ISO 7816-4 based I/O across the card serial line. The <KBD CLASS="Filename-Command">APDU</KBD> class is designed to be independent of the underlying I/O transport protocol.</P><P CLASS="Paragraph"><A NAME="pgfId-407293"></A>The Java Card RE may support T=0 or T=1 transport protocols or both.</P><H3 CLASS="Head2"><A NAME="pgfId-407301"></A>9.4.1 <A NAME="marker-414005"></A>T=0 Specifics for Outgoing Data Transfers</H3><P CLASS="Paragraph"><A NAME="pgfId-407303"></A>The <KBD CLASS="Filename-Command">setOutgoing</KBD> and <KBD CLASS="Filename-Command">setOutgoingNoChaining</KBD> methods in the <KBD CLASS="Filename-Command">APDU</KBD> class are used to specify that data needs to be returned to the CAD. These methods return the expected length (<KBD CLASS="Filename-Command">Le</KBD>) value as follows when extended length semantics are not enabled (see <A HREF="JCRESpec09api.html#39925" CLASS="XRef">Section 9.4.4.1, Extended Length API Semantics</A>):</P><P CLASS="Paragraph"><A NAME="pgfId-411883"></A><KBD CLASS="Filename-Command">ISO 7816-4 CASE 1</KBD>: Not applicable. Assume Case 2</P><P CLASS="Paragraph"><A NAME="pgfId-411884"></A><KBD CLASS="Filename-Command">ISO 7816-4 CASE 2</KBD>: P3 (If <KBD CLASS="Filename-Command">P3=0, 256</KBD>)</P><P CLASS="Paragraph"><A NAME="pgfId-411801"></A><KBD CLASS="Filename-Command">ISO 7816-4 CASE 3</KBD>: Not applicable. Assume Case 4</P><P CLASS="Paragraph"><A NAME="pgfId-411803"></A><KBD CLASS="Filename-Command">ISO 7816-4 CASE 4</KBD>: <KBD CLASS="Filename-Command">256</KBD></P><P CLASS="Paragraph"><A NAME="pgfId-411799"></A>For compatibility with legacy CAD/terminals that do not support block chained mechanisms, the <KBD CLASS="Filename-Command">APDU</KBD> class allows a non-chained transfer mode selection via the <KBD CLASS="Filename-Command">setOutgoingNoChaining</KBD> method. The related behaviors are discussed in the following sections.</P><H4 CLASS="Head3"><A NAME="pgfId-407305"></A>9.4.1.1 Constrained Transfers With No Chaining</H4><P CLASS="Paragraph"><A NAME="pgfId-407307"></A>When the no chaining mode of output transfer is requested by the applet by calling the <KBD CLASS="Filename-Command">setOutgoingNoChaining</KBD> method, the following protocol sequence shall be followed:</P><P CLASS="Paragraph"><A NAME="pgfId-407309"></A>When the no chaining mode is used (that is, after the invocation of the <KBD CLASS="Filename-Command">setOutgoingNoChaining</KBD> method), calls to the <KBD CLASS="Filename-Command">waitExtension</KBD> method shall throw an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">ILLEGAL_USE</KBD>.</P><H5 CLASS="Head4"><A NAME="pgfId-407311"></A>Notation</H5><P CLASS="ParaIndent1"><A NAME="pgfId-407313"></A>Le = CAD expected length.</P><P CLASS="ParaIndent1"><A NAME="pgfId-407315"></A>Lr = Applet response length set via <KBD CLASS="Filename-Command">setOutgoingLength</KBD> method.</P><P CLASS="Paragraph"><A NAME="pgfId-407317"></A><INS> = the protocol byte equal to the incoming header INS byte, which indicates that all data bytes will be transferred next.</P><P CLASS="Paragraph"><A NAME="pgfId-407319"></A><~INS> = the protocol byte that is the complement of the incoming header INS byte, which indicates that 1 data byte will be transferred next.</P><P CLASS="Paragraph"><A NAME="pgfId-407321"></A><SW1,SW2> = the response status bytes as in ISO7816-4.</P><H5 CLASS="Head4"><A NAME="pgfId-407323"></A><A NAME="68412"></A>ISO 7816-4 CASE 2</H5><H5 CLASS="Head4"><A NAME="pgfId-407325"></A>Le == Lr</H5><P CLASS="List1"><A NAME="pgfId-407327"></A>1. The card sends Lr bytes of output data using the standard T=0 <INS> or <~INS> procedure byte mechanism.</P><P CLASS="List1-"><A NAME="pgfId-407329"></A>2. The card sends <SW1,SW2> completion status on completion of the <KBD CLASS="Filename-Command">Applet.process</KBD> method.</P><H5 CLASS="Head4"><A NAME="pgfId-407331"></A>Lr < Le</H5><P CLASS="List1"><A NAME="pgfId-407333"></A>1. The card sends <0x61,Lr> completion status bytes</P><P CLASS="List1-"><A NAME="pgfId-407335"></A>2. The CAD sends GET RESPONSE command with Le = Lr.</P><P CLASS="List1-"><A NAME="pgfId-407337"></A>3. The card sends Lr bytes of output data using the standard T=0 <INS> or <~INS> procedure byte mechanism.</P><P CLASS="List1-"><A NAME="pgfId-407339"></A>4. The card sends <SW1,SW2> completion status on completion of the <KBD CLASS="Filename-Command">Applet.process</KBD> method.</P><H5 CLASS="Head4"><A NAME="pgfId-407341"></A>Lr > Le</H5><P CLASS="List1"><A NAME="pgfId-407343"></A>1. The card sends Le bytes of output data using the standard T=0 <INS> or <~INS> procedure byte mechanism.</P><P CLASS="List1-"><A NAME="pgfId-407345"></A>2. The card sends <0x61,(Lr-Le)> completion status bytes</P><P CLASS="List1-"><A NAME="pgfId-407347"></A>3. The CAD sends GET RESPONSE command with new Le <= Lr.</P><P CLASS="List1-"><A NAME="pgfId-407349"></A>4. The card sends (new) Le bytes of output data using the standard T=0 <INS> or <~INS> procedure byte mechanism.</P><P CLASS="List1-"><A NAME="pgfId-407351"></A>5. Repeat steps 2-4 as necessary to send the remaining output data bytes (Lr) as required.</P><P CLASS="List1-"><A NAME="pgfId-407353"></A>6. The card sends <SW1,SW2> completion status on completion of the <KBD CLASS="Filename-Command">Applet.process</KBD> method.</P><H5 CLASS="Head4"><A NAME="pgfId-407355"></A>ISO 7816-4 CASE 4</H5><P CLASS="Paragraph"><A NAME="pgfId-407357"></A>In Case 4, Le is determined after the following initial exchange:</P><P CLASS="List1"><A NAME="pgfId-407359"></A>1. The card sends <0x61,Lr status bytes></P><P CLASS="List1-"><A NAME="pgfId-417385"></A>2. The CAD sends GET RESPONSE command with Le <= Lr.</P><P CLASS="Paragraph"><A NAME="pgfId-417386"></A>The rest of the protocol sequence is identical to CASE 2 described above.</P><P CLASS="Paragraph"><A NAME="pgfId-417387"></A>If the applet aborts early and sends less than Le bytes, zeros shall be sent instead to fill out the length of the transfer expected by the CAD.</P><H4 CLASS="Head3"><A NAME="pgfId-407367"></A>9.4.1.2 Regular Output Transfers</H4><P CLASS="Paragraph"><A NAME="pgfId-407369"></A>When the no chaining mode of output transfer is not requested by the applet (that is, the <Alt CLASS="InlineAltText">setOutgoing</Alt> method is used), any ISO/IEC 7816-3/4 compliant T=0 protocol transfer sequence may be used. </P><BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -