jcrespec09api.html
来自「JAVA CARD 开发包规格说明,版本为2.2.2」· HTML 代码 · 共 391 行 · 第 1/3 页
HTML
391 行
<HR NOSHADE SIZE=1><TABLE CLASS="TipNote" DIR="LTR" WIDTH="100%" SUMMARY="TipNote"><COLGROUP SPAN="1" WIDTH="100%"><TR ALIGN="left" VALIGN="top"><TD ROWSPAN="1" COLSPAN="1" ABBR="TipNoteText"><P CLASS="TipNote"><B CLASS="TipNote">Note - </B><A NAME="pgfId-407371"></A>The <KBD CLASS="Filename-Command">waitExtension</KBD> method may be invoked by the applet at any time. The <KBD CLASS="Filename-Command">waitExtension</KBD> method shall request an additional work waiting time (ISO/IEC 7816-3:2004) using the 0x60 procedure byte.</P></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><H4 CLASS="Head3"><A NAME="pgfId-407373"></A>9.4.1.3 Additional T=0 Requirements</H4><P CLASS="Paragraph"><A NAME="pgfId-407375"></A>At any time, when the T=0 output transfer protocol is in use, and the <KBD CLASS="Filename-Command">APDU</KBD> class is awaiting a GET RESPONSE command from the CAD in reaction to a response status of <0x61, xx> from the card, if the CAD sends in a different command on the same origin logical channel, or a command on a different origin logical channel, the <KBD CLASS="Filename-Command">sendBytes</KBD> or the <KBD CLASS="Filename-Command">sendBytesLong</KBD> methods shall throw an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">NO_T0_GETRESPONSE</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-411964"></A>At any time, when the T=0 output transfer protocol is in use, and the <KBD CLASS="Filename-Command">APDU</KBD> class is awaiting a command reissue from the CAD in reaction to a response status of <0x6C, xx> from the card, if the CAD sends in a different command on the same origin logical channel, or a command on a different origin logical channel, the <KBD CLASS="Filename-Command">sendBytes</KBD> or the <KBD CLASS="Filename-Command">sendBytesLong</KBD> methods shall throw an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">NO_T0_REISSUE</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-407377"></A>Calls to <KBD CLASS="Filename-Command">sendBytes</KBD> or <KBD CLASS="Filename-Command">sendBytesLong</KBD> methods after the <KBD CLASS="Filename-Command">NO_T0_GETRESPONSE</KBD> exception or the <KBD CLASS="Filename-Command">NO_T0_REISSUE</KBD> exception is thrown, shall result in an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">ILLEGAL_USE</KBD>. If an <KBD CLASS="Filename-Command">ISOException</KBD> is thrown by the applet after the <KBD CLASS="Filename-Command">NO_T0_GETRESPONSE</KBD> exception or the <KBD CLASS="Filename-Command">NO_T0_REISSUE</KBD> exception is thrown, the Java Card RE shall discard the response status in its reason code. The Java Card RE shall restart APDU processing with the newly received command and resume APDU dispatching. </P><H3 CLASS="Head2"><A NAME="pgfId-407385"></A>9.4.2 <A NAME="marker-414006"></A>T=1 Specifics for Outgoing Data Transfers</H3><P CLASS="Paragraph"><A NAME="pgfId-411905"></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 (Le) 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><PRE CLASS="Codeline"><A NAME="pgfId-418899"></A>ISO 7816-4 CASE 1: 0</PRE><PRE CLASS="Codeline"><A NAME="pgfId-418900"></A>ISO 7816-4 CASE 2: Le (If Le<KBD CLASS="Filename-Command">=0, 256</KBD>)</PRE><PRE CLASS="Codeline"><A NAME="pgfId-418901"></A>ISO 7816-4 CASE 3: 0</PRE><PRE CLASS="Codeline"><A NAME="pgfId-411910"></A>ISO 7816-4 CASE 4: Le (If Le<KBD CLASS="Filename-Command">=0, 256</KBD>)</PRE><H4 CLASS="Head3"><A NAME="pgfId-407387"></A>9.4.2.1 Constrained Transfers With No Chaining</H4><P CLASS="Paragraph"><A NAME="pgfId-407389"></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 specifics shall be followed:</P><H5 CLASS="Head4"><A NAME="pgfId-407391"></A>Notation</H5><P CLASS="ParaIndent1"><A NAME="pgfId-407393"></A>Le = CAD expected length.</P><P CLASS="ParaIndent1"><A NAME="pgfId-407395"></A>Lr = Applet response length set via <KBD CLASS="Filename-Command">setOutgoingLength</KBD> method.</P><P CLASS="Paragraph"><A NAME="pgfId-407397"></A>The transport protocol sequence shall not use block chaining. Specifically, the M-bit (more data bit) shall not be set in the PCB of the I-blocks during the transfers (ISO/IEC 7816-3:2004). The entire outgoing data (Lr bytes) shall be transferred in one I-block. </P><P CLASS="Paragraph"><A NAME="pgfId-407399"></A>If the applet aborts early and sends less than Lr bytes, zeros shall be sent instead to complete the remaining length of the block.</P><BR><HR NOSHADE SIZE=1><TABLE CLASS="TipNote" DIR="LTR" WIDTH="100%" SUMMARY="TipNote"><COLGROUP SPAN="1" WIDTH="100%"><TR ALIGN="left" VALIGN="top"><TD ROWSPAN="1" COLSPAN="1" ABBR="TipNoteText"><P CLASS="TipNote"><B CLASS="TipNote">Note - </B><A NAME="pgfId-407401"></A>When the no chaining mode is used (meaning, 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></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><H4 CLASS="Head3"><A NAME="pgfId-407403"></A>9.4.2.2 Regular Output Transfers</H4><P CLASS="Paragraph"><A NAME="pgfId-416737"></A>When the no chaining mode of output transfer is not requested by the applet (meaning, the <KBD CLASS="Filename-Command">setOutgoing</KBD> method is used) any ISO/IEC 7816-3/4 compliant T=1 protocol transfer sequence may be used.</P><BR><HR NOSHADE SIZE=1><TABLE CLASS="TipNote" DIR="LTR" WIDTH="100%" SUMMARY="TipNote"><COLGROUP SPAN="1" WIDTH="100%"><TR ALIGN="left" VALIGN="top"><TD ROWSPAN="1" COLSPAN="1" ABBR="TipNoteText"><P CLASS="TipNote"><B CLASS="TipNote">Note - </B><A NAME="pgfId-407407"></A>The <KBD CLASS="Filename-Command">waitExtension</KBD> method may be invoked by the applet at any time. The <KBD CLASS="Filename-Command">waitExtension</KBD> method shall send an S-block command with WTX request of INF units, which is equivalent to a request of 1 additional work waiting time in T=0 mode. See ISO/IEC 7816-3:2004.</P></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><H5 CLASS="Head4"><A NAME="pgfId-407409"></A>Chain Abortion by the CAD</H5><P CLASS="Paragraph"><A NAME="pgfId-407411"></A>If the CAD aborts a chained outbound transfer using an S-block ABORT request (see ISO/IEC 7816-3:2004), the <KBD CLASS="Filename-Command">sendBytes</KBD> or <KBD CLASS="Filename-Command">sendBytesLong</KBD> method shall throw an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">T1_IFD_ABORT</KBD>. </P><P CLASS="Paragraph"><A NAME="pgfId-407413"></A>Calls to <KBD CLASS="Filename-Command">sendBytes</KBD> or <KBD CLASS="Filename-Command">sendBytesLong</KBD> methods from this point on shall result in an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">ILLEGAL_USE</KBD>. If an <KBD CLASS="Filename-Command">ISOException</KBD> is thrown by the applet after the <KBD CLASS="Filename-Command">T1_IFD_ABORT</KBD> exception is thrown, the Java Card RE shall discard the response status in its reason code. The Java Card RE shall restart APDU processing with the newly received command, and resume APDU dispatching.</P><H3 CLASS="Head2"><A NAME="pgfId-407421"></A>9.4.3 <A NAME="marker-414007"></A>T=1 Specifics for Incoming Data Transfers</H3><H4 CLASS="Head3"><A NAME="pgfId-407423"></A>9.4.3.1 Incoming Transfers Using Chaining</H4><H5 CLASS="Head4"><A NAME="pgfId-407425"></A>Chain Abortion by the CAD</H5><P CLASS="Paragraph"><A NAME="pgfId-407427"></A>If the CAD aborts a chained inbound transfer using an S-block ABORT request (see ISO/IEC 7816-3:2004), the <KBD CLASS="Filename-Command">setIncomingAndReceive</KBD> or <KBD CLASS="Filename-Command">receiveBytes</KBD> method shall throw an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">T1_IFD_ABORT</KBD>. </P><P CLASS="Paragraph"><A NAME="pgfId-407429"></A>Calls to <KBD CLASS="Filename-Command">receiveBytes</KBD>, <KBD CLASS="Filename-Command">sendBytes</KBD> or <KBD CLASS="Filename-Command">sendBytesLong</KBD> methods from this point on shall result in an <KBD CLASS="Filename-Command">APDUException</KBD> with reason code <KBD CLASS="Filename-Command">ILLEGAL_USE</KBD>. If an <KBD CLASS="Filename-Command">ISOException</KBD> is thrown by the applet after the <KBD CLASS="Filename-Command">T1_IFD_ABORT</KBD> exception is thrown, the Java Card RE shall discard the response status in its reason code. The Java Card RE shall restart APDU processing with the newly received command, and resume APDU dispatching.</P><H3 CLASS="Head2"><A NAME="pgfId-416968"></A>9.4.4 <A NAME="97305"></A>Extended Length APDU Specifics</H3><P CLASS="Paragraph"><A NAME="pgfId-417593"></A>The card may support extended length APDU exchanges with the CAD as described in the <EM CLASS="Emphasis">ISO 7816-3 Specification</EM>. If the implementation does not support extended length APDU formats and an APDU with extended length is received by the card or an APDU with extended length value greater than 32767 is requested, the Java Card RE shall respond to the CAD with the error response status <KBD CLASS="Filename-Command">SW_WRONG_LENGTH</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-417594"></A>If the implementation supports extended length APDU formats, extended length semantics shall be enabled at the APDU class methods only if the currently selected applet implements the <KBD CLASS="Filename-Command">javacardx.apdu.ExtendedLength</KBD> interface. If an APDU is received by the card that requires extended length semantics at the APDU class methods, but the currently selected applet does not the implement the tagging interface, the Java Card RE shall respond to the CAD with the error response status <KBD CLASS="Filename-Command">SW_WRONG_LENGTH</KBD>.</P><H4 CLASS="Head3"><A NAME="pgfId-416980"></A>9.4.4.1 <A NAME="39925"></A>Extended Length API Semantics</H4><P CLASS="Paragraph"><A NAME="pgfId-416981"></A>The following sections describe the semantics of the applet-visible API, which is enabled when the applet implements the <KBD CLASS="Filename-Command">javacardx.apdu.ExtendedLength</KBD> interface. These semantics are presented at the API level to the extended length capable applet, only when the APDU received supports extended length format. Note that the maximum length that can be supported using extended length semantics by the Java Card technology API is 32767.</P><H5 CLASS="Head4"><A NAME="pgfId-417866"></A>Applet.process(APDU) Method</H5><P CLASS="Paragraph"><A NAME="pgfId-417867"></A>When the APDU received is a Case 3E or 4E, and contains an Lc encoding of extended length, the APDU buffer contained in the APDU object upon entry into the <KBD CLASS="Filename-Command">Applet.process(APDU)</KBD> method shall encode the header data format as described in <EM CLASS="Emphasis">ISO 7816-3 Specification</EM> in its first seven bytes, as shown in the <A HREF="JCRESpec09api.html#80226" CLASS="XRef">TABLE 9-1</A>.</P><P CLASS="Paragraph"><A NAME="pgfId-417920"></A>When the T=0 transfer protocol is in use, a Case 3E and 4E APDU is enclosed within an ENVELOPE (ISO Inter-industry CLA, INS=<KBD CLASS="Filename-Command">0xC2</KBD>) command as described in <EM CLASS="Emphasis">ISO 7816-4:2005 Specification</EM>. The ENVELOPE command header is processed by the Java Card RE and only the enclosed Case 3E or Case 4E APDU command is placed in the APDU buffer using the format shown in <A HREF="JCRESpec09api.html#80226" CLASS="XRef">TABLE 9-1</A>.</P><P CLASS="Paragraph"><A NAME="pgfId-417302"></A> </P><CAPTION CLASS="TableCaption"><A NAME="pgfId-417123"> </A> TABLE 9-1 <A NAME="80226"> </A> APDU Buffer Format for Extended Length </CAPTION><BR><TABLE CLASS="Untitled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><THEAD><TR><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417130"></A>offset=0</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417132"></A>offset=1</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417134"></A>offset=2</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417136"></A>offset=3</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417138"></A>offset=4</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417140"></A>offset=5</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417880"></A>offset=6</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-417142"></A>offset=7..</P></TH></TR></THEAD><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-417144"></A>CLA</P></TD><TD ROWSPAN="1" COLSPAN="1">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?