📄 jcrespec09api.html
字号:
<P CLASS="TableText"><A NAME="pgfId-417146"></A>INS</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-417148"></A>P1</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-417150"></A>P2</P></TD><TD ROWSPAN="1" COLSPAN="3"><P CLASS="TableText"><A NAME="pgfId-417152"></A>3 byte Lc</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-417156"></A>undefined</P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-417890"></A>As shown in the table, the header data at offset 4, 5 and 6 of the APDU buffer contains a 3-byte Lc value as defined in ISO 7816-4. The 3-byte length may encode a number from 1to 32767. </P><H5 CLASS="Head4"><A NAME="pgfId-417240"></A>APDU.setIncomingAndReceive() Method</H5><P CLASS="Paragraph"><A NAME="pgfId-417219"></A>This method returns the number of bytes received. The returned number may be between 0 and 32767. Additionally, when the 3 byte Lc format is used, the data bytes received are placed at <KBD CLASS="Filename-Command">OFFSET_EXT_CDATA</KBD> (7) of the APDU buffer.</P><H5 CLASS="Head4"><A NAME="pgfId-417211"></A>APDU.receiveBytes(short) Method</H5><P CLASS="Paragraph"><A NAME="pgfId-417209"></A>This method returns the number of bytes received. The returned number may be between 0 and 32767.</P><H5 CLASS="Head4"><A NAME="pgfId-417184"></A>APDU.setOutgoing() Method</H5><P CLASS="Paragraph"><A NAME="pgfId-417166"></A>These methods return the number of bytes expected (Le) by the CAD. The returned number may be between 0 and 32767.</P><P CLASS="Paragraph"><A NAME="pgfId-418926"></A>When the T=0 transfer protocol is in use for a Case 2E (P3=0) or Case 4 command, this method returns 32767.</P><P CLASS="Paragraph"><A NAME="pgfId-418928"></A>When the T=1 transfer protocol is in use for a Case 2E or Case 4E command and Le is set to 0x0000, this method returns 32767.</P><H5 CLASS="Head4"><A NAME="pgfId-417182"></A>APDU.setOutgoingLength(short) Method</H5><P CLASS="Paragraph"><A NAME="pgfId-417164"></A>This method allows the caller to specify the number of bytes to send to the CAD. The number specified may be between 0 and 32767.</P><H5 CLASS="Head4"><A NAME="pgfId-417197"></A>APDU.sendBytes(short, short), APDU.sendBytesLong(byte[],short, short) Methods</H5><P CLASS="Paragraph"><A NAME="pgfId-417174"></A>These methods allow the caller to specify the number of bytes to send to the CAD. The number specified may be between 0 and 32767.</P><H2 CLASS="Head1"><A NAME="pgfId-416996"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.5 <A NAME="marker-416993"></A><KBD CLASS="Filename-Command">Security</KBD><A NAME="marker-416994"></A> and <A NAME="marker-416995"></A><KBD CLASS="Filename-Command">Crypto</KBD> Packages</H2><P CLASS="Paragraph"><A NAME="pgfId-407439"></A>The <KBD CLASS="Filename-Command">getInstance</KBD> method in the following classes returns an implementation instance in the context of the calling applet of the requested algorithm:</P><PRE CLASS="Codeline"><A NAME="pgfId-411690"></A>javacard.security.MessageDigest</PRE><PRE CLASS="Codeline"><A NAME="pgfId-417975"></A>javacard.security.InitializedMessageDigest</PRE><PRE CLASS="Codeline"><A NAME="pgfId-407443"></A>javacard.security.Signature</PRE><PRE CLASS="Codeline"><A NAME="pgfId-407445"></A>javacard.security.RandomData</PRE><PRE CLASS="Codeline"><A NAME="pgfId-415944"></A>javacard.security.KeyAgreement</PRE><PRE CLASS="Codeline"><A NAME="pgfId-415945"></A>javacard.security.Checksum</PRE><PRE CLASS="Codeline"><A NAME="pgfId-415948"></A>javacardx.crypto.Cipher</PRE><P CLASS="Paragraph"><A NAME="pgfId-416795"></A>An implementation of the Java Card RE may implement zero or more of the algorithms listed in the <EM CLASS="Emphasis">Application Programming Interface, Java Card Platform, Version 2.2.2</EM>. When an algorithm that is not implemented is requested, this method shall throw a <KBD CLASS="Filename-Command">CryptoException</KBD> with reason code <KBD CLASS="Filename-Command">NO_SUCH_ALGORITHM</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-416798"></A>Implementations of the above classes shall extend the corresponding base class and implement all the abstract methods. All data allocation associated with the implementation instance shall be performed at the time of instance construction to ensure that any lack of required resources can be flagged early during the installation of the applet.</P><P CLASS="Paragraph"><A NAME="pgfId-407453"></A>Similarly, the <KBD CLASS="Filename-Command">buildKey</KBD> method of the <KBD CLASS="Filename-Command">javacard.security.KeyBuilder</KBD> class returns an implementation instance of the requested Key type. The Java Card RE may implement zero or more types of keys. When a key type that is not implemented is requested, the method shall throw a <KBD CLASS="Filename-Command">CryptoException</KBD> with reason code <KBD CLASS="Filename-Command">NO_SUCH_ALGORITHM</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-415949"></A>In the same fashion, the constructor for the <KBD CLASS="Filename-Command">javacard.security.KeyPair</KBD> class creates a <KBD CLASS="Filename-Command">KeyPair</KBD> instance for the specified key type. The Java Card RE may implement zero or more types of keys. When a key type that is not implemented is requested, the method shall throw a <KBD CLASS="Filename-Command">CryptoException</KBD> with reason code <KBD CLASS="Filename-Command">NO_SUCH_ALGORITHM</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-407455"></A>Implementations of key types shall implement the associated interface. All data allocation associated with the key implementation instance shall be performed at the time of instance construction to ensure that any lack of required resources can be flagged early during the installation of the applet.</P><P CLASS="Paragraph"><A NAME="pgfId-407457"></A>The <KBD CLASS="Filename-Command">MessageDigest</KBD> object uses temporary storage for intermediate results when the <KBD CLASS="Filename-Command">update()</KBD> method is invoked. This intermediate state need not be preserved across power up and reset. The object is reset to the state it was in when previously initialized via a call to <KBD CLASS="Filename-Command">reset()</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-407459"></A>The <KBD CLASS="Filename-Command">Signature</KBD> and <KBD CLASS="Filename-Command">Cipher</KBD> objects use temporary storage for intermediate results when the <KBD CLASS="Filename-Command">update()</KBD> method is invoked. This intermediate state need not be preserved across power up and reset. The object is reset to the state it was in when previously initialized via a call to <KBD CLASS="Filename-Command">init()</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-416025"></A>The Checksum object uses temporary storage for intermediate results when the <KBD CLASS="Filename-Command">update()</KBD> method is invoked. This intermediate state need not be preserved across power up and reset. The object is reset to the state it was in when previously initialized upon a tear or card reset event.</P><H2 CLASS="Head1"><A NAME="pgfId-411698"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.6 <A NAME="marker-414011"></A><KBD CLASS="Filename-Command">JCSystem</KBD> Class</H2><P CLASS="Paragraph"><A NAME="pgfId-411699"></A>In the Java Card platform, version 2.2.2, the <KBD CLASS="Filename-Command">getVersion</KBD> method returns <KBD CLASS="Filename-Command">(short) 0x0202</KBD>.</P><H2 CLASS="Head1"><A NAME="pgfId-417984"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>9.7 Optional Extension Packages</H2><P CLASS="Paragraph"><A NAME="pgfId-417987"></A>Some API packages in the Java Card technology are designated as extension packages and may be optionally supported by an implementation. But, if supported, all the classes in the package and its subpackages must be implemented by the platform and reside on the card.</P><P CLASS="Paragraph"><A NAME="pgfId-417994"></A>The following are optional Java Card technology extension packages:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-418033"></A><KBD CLASS="Filename-Command">javacardx.apdu</KBD> - This package enables support for advanced APDU mechanisms. This package must be implemented if and only if the platform supports the extended length APDU protocol defined in the <EM CLASS="Emphasis">ISO 7816-4:2005 Specification</EM>.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-418131"></A><KBD CLASS="Filename-Command">javacardx.biometry</KBD> - This package contains classes and interfaces which can be used to build a biometric server application. </LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-418000"></A><KBD CLASS="Filename-Command">javacardx.crypto</KBD> - This package contains functionality, which may be subject to export controls, for implementing a security and cryptography framework.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-418060"></A><KBD CLASS="Filename-Command">javacardx.external</KBD> - This package contains functionality, for implementing mechanisms to access memory subsystems which are not directly addressable by the Java Card RE on the Java Card platform.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-418074"></A><KBD CLASS="Filename-Command">javacardx.framework</KBD> - This package contains a framework of classes and interfaces for efficiently implementing typical Java Card technology-based applets. If implemented, this package must include all the contained sub-packages - <KBD CLASS="Filename-Command">util</KBD>, <KBD CLASS="Filename-Command">math</KBD>, and <KBD CLASS="Filename-Command">tlv</KBD>.</LI><P CLASS="Linebreak"></P></UL><div class="navbar" align="center"><br><br><table dir="LTR" summary="Navigation bar, includes the book title and navigation buttons" width=100% cellpadding="0" cellspacing="0" border="0"><colgroup span="3" width="100%"><col id="1" span="1" width="45%"><col id="2" span="1" width="25%"><col id="3" span="1" width="30%"><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 class="navbartitle" align=right rowspan="1" colspan="1" abbr="PartNum">3-8-06</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><P CLASS="copyrightlink"><a href="copyright.html">Copyright</a> © 2005, Sun Microsystems, Inc. All Rights Reserved.</P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -