📄 signature.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:36:04 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class Signature</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Signature.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/security/SecurityPermission.html"><B>PREV CLASS</B></A> <A HREF="../../java/security/SignatureSpi.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Signature.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.security</FONT><BR>Class Signature</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../../java/security/SignatureSpi.html">java.security.SignatureSpi</A> | +--<B>java.security.Signature</B></PRE><HR><DL><DT>public abstract class <B>Signature</B><DT>extends <A HREF="../../java/security/SignatureSpi.html">SignatureSpi</A></DL><P>This Signature class is used to provide applications the functionality of a digital signature algorithm. Digital signatures are used for authentication and integrity assurance of digital data. <p> The signature algorithm can be, among others, the NIST standard DSA, using DSA and SHA-1. The DSA algorithm using the SHA-1 message digest algorithm can be specified as <tt>SHA1withDSA</tt>. In the case of RSA, there are multiple choices for the message digest algorithm, so the signing algorithm could be specified as, for example, <tt>MD2withRSA</tt>, <tt>MD5withRSA</tt>, or <tt>SHA1withRSA</tt>. The algorithm name must be specified, as there is no default. <p>Like other algorithm-based classes in Java Security, Signature provides implementation-independent algorithms, whereby a caller (application code) requests a particular signature algorithm and is handed back a properly initialized Signature object. It is also possible, if desired, to request a particular algorithm from a particular provider. See the <code>getInstance </code> methods. <p>Thus, there are two ways to request a Signature algorithm object: by specifying either just an algorithm name, or both an algorithm name and a package provider. <ul> <li>If just an algorithm name is specified, the system will determine if there is an implementation of the algorithm requested available in the environment, and if there is more than one, if there is a preferred one.<p> <li>If both an algorithm name and a package provider are specified, the system will determine if there is an implementation of the algorithm in the package requested, and throw an exception if there is not. </ul> <p>A Signature object can be used to generate and verify digital signatures. <p>There are three phases to the use of a Signature object for either signing data or verifying a signature:<ol> <li>Initialization, with either <ul> <li>a public key, which initializes the signature for verification (see <A HREF="../../java/security/Signature.html#initVerify(java.security.PublicKey)"><CODE>initVerify</CODE></A>), or <li>a private key (and optionally a Secure Random Number Generator), which initializes the signature for signing (see <A HREF="../../java/security/Signature.html#initSign(java.security.PrivateKey)"><CODE>initSign(PrivateKey)</CODE></A> and <A HREF="../../java/security/Signature.html#initSign(java.security.PrivateKey, java.security.SecureRandom)"><CODE>initSign(PrivateKey, SecureRandom)</CODE></A>). </ul><p> <li>Updating<p> <p>Depending on the type of initialization, this will update the bytes to be signed or verified. See the <A HREF="../../java/security/Signature.html#update(byte)"><CODE>update</CODE></A> methods.<p> <li>Signing or Verifying a signature on all updated bytes. See the <A HREF="../../java/security/Signature.html#sign()"><CODE>sign</CODE></A> methods and the <A HREF="../../java/security/Signature.html#verify(byte[])"><CODE>verify</CODE></A> method. </ol> <p>Note that this class is abstract and extends from <code>SignatureSpi</code> for historical reasons. Application developers should only take notice of the methods defined in this <code>Signature</code> class; all the methods in the superclass are intended for cryptographic service providers who wish to supply their own implementations of digital signature algorithms.<P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#SIGN">SIGN</A></B></CODE><BR> Possible <A HREF="../../java/security/Signature.html#state"><CODE>state</CODE></A> value, signifying that this signature object has been initialized for signing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#state">state</A></B></CODE><BR> Current state of this signature object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#UNINITIALIZED">UNINITIALIZED</A></B></CODE><BR> Possible <A HREF="../../java/security/Signature.html#state"><CODE>state</CODE></A> value, signifying that this signature object has not yet been initialized.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#VERIFY">VERIFY</A></B></CODE><BR> Possible <A HREF="../../java/security/Signature.html#state"><CODE>state</CODE></A> value, signifying that this signature object has been initialized for verification.</TD></TR></TABLE> <A NAME="fields_inherited_from_class_java.security.SignatureSpi"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from class java.security.<A HREF="../../java/security/SignatureSpi.html">SignatureSpi</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/security/SignatureSpi.html#appRandom">appRandom</A></CODE></TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected </CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#Signature(java.lang.String)">Signature</A></B>(<A HREF="../../java/lang/String.html">String</A> algorithm)</CODE><BR> Creates a Signature object for the specified algorithm.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#clone()">clone</A></B>()</CODE><BR> Returns a clone if the implementation is cloneable.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#getAlgorithm()">getAlgorithm</A></B>()</CODE><BR> Returns the name of the algorithm for this signature object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/security/Signature.html">Signature</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#getInstance(java.lang.String)">getInstance</A></B>(<A HREF="../../java/lang/String.html">String</A> algorithm)</CODE><BR> Generates a Signature object that implements the specified digest algorithm.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/security/Signature.html">Signature</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#getInstance(java.lang.String, java.lang.String)">getInstance</A></B>(<A HREF="../../java/lang/String.html">String</A> algorithm, <A HREF="../../java/lang/String.html">String</A> provider)</CODE><BR> Generates a Signature object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#getParameter(java.lang.String)">getParameter</A></B>(<A HREF="../../java/lang/String.html">String</A> param)</CODE><BR> <B>Deprecated.</B> <I></I> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/security/Provider.html">Provider</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#getProvider()">getProvider</A></B>()</CODE><BR> Returns the provider of this signature object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#initSign(java.security.PrivateKey)">initSign</A></B>(<A HREF="../../java/security/PrivateKey.html">PrivateKey</A> privateKey)</CODE><BR> Initialize this object for signing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/Signature.html#initSign(java.security.PrivateKey, java.security.SecureRandom)">initSign</A></B>(<A HREF="../../java/security/PrivateKey.html">PrivateKey</A> privateKey, <A HREF="../../java/security/SecureRandom.html">SecureRandom</A> random)</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -