⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cipher.html

📁 JAVA CARD 开发包规格说明,版本为2.2.2
💻 HTML
📖 第 1 页 / 共 4 页
字号:
 <li><em>For optimal performance, when the <code>theKey</code> parameter is a transient key, the implementation should, whenever possible, use transient space for internal storage.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>theKey</CODE> - the key object to use for encrypting or decrypting<DD><CODE>theMode</CODE> - one of <code>MODE_DECRYPT</code> or <code>MODE_ENCRYPT</code><DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></CODE> - with the following reason codes:<ul> <li><code>CryptoException.ILLEGAL_VALUE</code> if <code>theMode</code> option is an undefined value or if the <code>Key</code> is inconsistent with the <code>Cipher</code> implementation. <li><code>CryptoException.UNINITIALIZED_KEY</code> if <code>theKey</code> instance is uninitialized. </ul></DL></DD></DL><HR><A NAME="init(javacard.security.Key, byte, byte[], short, short)"><!-- --></A><H3>init</H3><PRE>public abstract void <B>init</B>(<A HREF="../../javacard/security/Key.html" title="interface in javacard.security">Key</A>&nbsp;theKey,                          byte&nbsp;theMode,                          byte[]&nbsp;bArray,                          short&nbsp;bOff,                          short&nbsp;bLen)                   throws <A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></PRE><DL><DD>Initializes the <code>Cipher</code> object with the appropriate Key and algorithm specific parameters. <p><code>init()</code> must be used to update the <code>Cipher</code> object with a new key. If the <code>Key</code> object is modified after invoking the <code>init()</code> method, the behavior of the <code>update()</code> and <code>doFinal()</code> methods is unspecified. <p>Note:<ul> <li><em>DES and triple DES algorithms in CBC mode expect an 8-byte parameter value for the initial vector(IV) in </em><code>bArray</code><em>.</em> <li><em>AES algorithms in CBC mode expect a 16-byte parameter value for the initial vector(IV) in </em><code>bArray</code><em>.</em> <li><em>Korean SEED algorithms in CBC mode expect a 16-byte parameter value for the initial vector(IV) in </em><code>bArray</code><em>.</em> <li><em>AES algorithms in ECB mode, DES algorithms in ECB mode, Korean SEED algorithm in ECB mode, RSA and DSA algorithms throw </em><code>CryptoException.ILLEGAL_VALUE</code><em>.</em> <li><em>For optimal performance, when the <code>theKey</code> parameter is a transient key, the implementation should, whenever possible, use transient space for internal storage.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>theKey</CODE> - the key object to use for encrypting or decrypting.<DD><CODE>theMode</CODE> - one of <code>MODE_DECRYPT</code> or <code>MODE_ENCRYPT</code><DD><CODE>bArray</CODE> - byte array containing algorithm specific initialization info<DD><CODE>bOff</CODE> - offset within bArray where the algorithm specific data begins<DD><CODE>bLen</CODE> - byte length of algorithm specific parameter data<DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></CODE> - with the following reason codes:<ul> <li><code>CryptoException.ILLEGAL_VALUE</code> if <code>theMode</code> option is an undefined value or if a byte array parameter option is not supported by the algorithm or if the <code>bLen</code> is an incorrect byte length for the algorithm specific data or if the <code>Key</code> is inconsistent with the <code>Cipher</code> implementation. <li><code>CryptoException.UNINITIALIZED_KEY</code> if <code>theKey</code> instance is uninitialized. </ul></DL></DD></DL><HR><A NAME="getAlgorithm()"><!-- --></A><H3>getAlgorithm</H3><PRE>public abstract byte <B>getAlgorithm</B>()</PRE><DL><DD>Gets the Cipher algorithm.<P><DD><DL><DT><B>Returns:</B><DD>the algorithm code defined above</DL></DD></DL><HR><A NAME="doFinal(byte[], short, short, byte[], short)"><!-- --></A><H3>doFinal</H3><PRE>public abstract short <B>doFinal</B>(byte[]&nbsp;inBuff,                              short&nbsp;inOffset,                              short&nbsp;inLength,                              byte[]&nbsp;outBuff,                              short&nbsp;outOffset)                       throws <A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></PRE><DL><DD>Generates encrypted/decrypted output from all/last input data.  This method must be invoked  to complete a cipher operation.  This method processes any remaining input data buffered by one or more calls to the <code>update()</code> method as well as input data supplied in the <code>inBuff</code> parameter. <p>A call to this method also resets this <code>Cipher</code> object to the state it was in when previously initialized via a call to <code>init()</code>. That is, the object is reset and available to encrypt or decrypt (depending on the operation mode that was specified in the call to <code>init()</code>) more data. In addition, note that the initial vector(IV) used in AES, DES and Korean SEED algorithms will be reset to 0. <p>Notes:<ul> <li><em>When using block-aligned data (multiple of block size), if the input buffer, </em><code>inBuff</code><em> and the output buffer, </em><code>outBuff</code><em> are the same array, then the output data area must not partially overlap the input data area such that the input data is modified before it is used; if </em><code>inBuff==outBuff</code><em> and<br> </em><code>inOffset < outOffset < inOffset+inLength</code><em>, incorrect output may result.</em> <li><em>When non-block aligned data is presented as input data, no amount of input and output buffer data overlap is allowed; if </em><code>inBuff==outBuff</code><em> and<br> </em><code>outOffset < inOffset+inLength</code><em>, incorrect output may result.</em> <li><em>AES, DES, triple DES and Korean SEED algorithms in CBC mode reset the initial vector(IV) to 0. The initial vector(IV) can be re-initialized using the </em><code>init(Key, byte, byte[], short, short)</code><em> method.</em> <li><em>On decryption operations (except when ISO 9797 method 1 padding is used), the padding bytes are not written to </em><code>outBuff</code><em>.</em> <li><em>On encryption and decryption operations, the number of bytes output into </em><code>outBuff</code><em> may be larger or smaller than </em><code>inLength</code><em> or even 0.</em> <li><em>On decryption operations resulting in an </em><code>ArrayIndexOutOfBoundsException</code><em>, </em><code>outBuff</code><em> may be partially modified.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>inBuff</CODE> - the input buffer of data to be encrypted/decrypted<DD><CODE>inOffset</CODE> - the offset into the input buffer at which to begin encryption/decryption<DD><CODE>inLength</CODE> - the byte length to be encrypted/decrypted<DD><CODE>outBuff</CODE> - the output buffer, may be the same as the input buffer<DD><CODE>outOffset</CODE> - the offset into the output buffer where the resulting output data begins<DT><B>Returns:</B><DD>number of bytes output in <code>outBuff</code><DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></CODE> - with the following reason codes:<ul> <li><code>CryptoException.UNINITIALIZED_KEY</code> if key not initialized. <li><code>CryptoException.INVALID_INIT</code> if this <code>Cipher</code> object is not initialized. <li><code>CryptoException.ILLEGAL_USE</code> if one of the following conditions is met:<ul> <li>This <code>Cipher</code> algorithm does not pad the message and the message is not block aligned. <li>This <code>Cipher</code> algorithm does not pad the message and no input data has been provided in <code>inBuff</code> or via the <code>update()</code> method. <li>The input message length is not supported. <li>The decrypted data is not bounded by appropriate padding bytes. </ul> </ul></DL></DD></DL><HR><A NAME="update(byte[], short, short, byte[], short)"><!-- --></A><H3>update</H3><PRE>public abstract short <B>update</B>(byte[]&nbsp;inBuff,                             short&nbsp;inOffset,                             short&nbsp;inLength,                             byte[]&nbsp;outBuff,                             short&nbsp;outOffset)                      throws <A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></PRE><DL><DD>Generates encrypted/decrypted output from input data. This method is intended for multiple-part encryption/decryption operations. <p>This method requires temporary storage of  intermediate results. In addition, if the input data length is not block aligned (multiple of block size) then additional internal storage may be allocated at this time to store a partial input data block. This may result in additional resource consumption and/or slow performance. <p>This method should only be used if all the input data required for the cipher is not available in one byte array.  If all the input data required for the cipher is located in a single byte array, use of the <code>doFinal()</code> method to process all of the input data is recommended.  The <code>doFinal()</code> method must be invoked to complete processing of any remaining input data buffered by one or more calls to the <code>update()</code> method. <p>Notes:<ul> <li><em>When using block-aligned data (multiple of block size), if the input buffer, </em><code>inBuff</code><em> and the output buffer, </em><code>outBuff</code><em> are the same array, then the output data area must not partially overlap the input data area such that the input data is modified before it is used; if </em><code>inBuff==outBuff</code><em> and<br> </em><code>inOffset < outOffset < inOffset+inLength</code><em>, incorrect output may result.</em> <li><em>When non-block aligned data is presented as input data, no amount of input and output buffer data overlap is allowed; if </em><code>inBuff==outBuff</code><em> and<br> </em><code>outOffset < inOffset+inLength</code><em>, incorrect output may result.</em> <li><em>On decryption operations(except when ISO 9797 method 1 padding is used), the padding bytes are not written to </em><code>outBuff</code><em>.</em> <li><em>On encryption and decryption operations, block alignment considerations may require that the number of bytes output into </em><code>outBuff</code><em> be larger or smaller than </em><code>inLength</code><em> or even 0.</em> <li><em>If </em><code>inLength</code><em> is 0 this method does nothing.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>inBuff</CODE> - the input buffer of data to be encrypted/decrypted<DD><CODE>inOffset</CODE> - the offset into the input buffer at which to begin encryption/decryption<DD><CODE>inLength</CODE> - the byte length to be encrypted/decrypted<DD><CODE>outBuff</CODE> - the output buffer, may be the same as the input buffer<DD><CODE>outOffset</CODE> - the offset into the output buffer where the resulting ciphertext/plaintext begins<DT><B>Returns:</B><DD>number of bytes output in <code>outBuff</code><DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/security/CryptoException.html" title="class in javacard.security">CryptoException</A></CODE> - with the following reason codes:<ul> <li><code>CryptoException.UNINITIALIZED_KEY</code> if key not initialized. <li><code>CryptoException.INVALID_INIT</code> if this <code>Cipher</code> object is not initialized. <li><code>CryptoException.ILLEGAL_USE</code> if the input message length is not supported. </ul></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Cipher.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java Card </b><br><font size="-1">v2.2.2</font></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV CLASS&nbsp;&nbsp;<A HREF="../../javacardx/crypto/KeyEncryption.html" title="interface in javacardx.crypto"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html?javacardx/crypto/Cipher.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="Cipher.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><i>Copyright &#169; 1993-2005 Sun Microsystems, Inc. 4150 Network Circle,<br>Santa Clara, CA, 95054, U.S.A.  All Rights Reserved.</i></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -