📄 keypairgenerator.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:35:59 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class KeyPairGenerator</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/KeyPairGenerator.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/KeyPair.html"><B>PREV CLASS</B></A> <A HREF="../../java/security/KeyPairGeneratorSpi.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="KeyPairGenerator.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <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 KeyPairGenerator</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../../java/security/KeyPairGeneratorSpi.html">java.security.KeyPairGeneratorSpi</A> | +--<B>java.security.KeyPairGenerator</B></PRE><HR><DL><DT>public abstract class <B>KeyPairGenerator</B><DT>extends <A HREF="../../java/security/KeyPairGeneratorSpi.html">KeyPairGeneratorSpi</A></DL><P>The KeyPairGenerator class is used to generate pairs of public and private keys. Key pair generators are constructed using the <code>getInstance</code> factory methods (static methods that return instances of a given class). <p>A Key pair generator for a particular algorithm creates a public/private key pair that can be used with this algorithm. It also associates algorithm-specific parameters with each of the generated keys. <p>There are two ways to generate a key pair: in an algorithm-independent manner, and in an algorithm-specific manner. The only difference between the two is the initialization of the object: <ul> <li><b>Algorithm-Independent Initialization</b> <p>All key pair generators share the concepts of a keysize and a source of randomness. The keysize is interpreted differently for different algorithms (e.g., in the case of the <i>DSA</i> algorithm, the keysize corresponds to the length of the modulus). There is an <A HREF="../../java/security/KeyPairGenerator.html#initialize(int, java.security.SecureRandom)"><CODE>initialize</CODE></A> method in this KeyPairGenerator class that takes these two universally shared types of arguments. There is also one that takes just a <code>keysize</code> argument, and uses the <code>SecureRandom</code> implementation of the highest-priority installed provider as the source of randomness. (If none of the installed providers supply an implementation of <code>SecureRandom</code>, a system-provided source of randomness is used.) <p>Since no other parameters are specified when you call the above algorithm-independent <code>initialize</code> methods, it is up to the provider what to do about the algorithm-specific parameters (if any) to be associated with each of the keys. <p>If the algorithm is the <i>DSA</i> algorithm, and the keysize (modulus size) is 512, 768, or 1024, then the <i>Sun</i> provider uses a set of precomputed values for the <code>p</code>, <code>q</code>, and <code>g</code> parameters. If the modulus size is not one of the above values, the <i>Sun</i> provider creates a new set of parameters. Other providers might have precomputed parameter sets for more than just the three modulus sizes mentioned above. Still others might not have a list of precomputed parameters at all and instead always create new parameter sets. <p> <li><b>Algorithm-Specific Initialization</b> <p>For situations where a set of algorithm-specific parameters already exists (e.g., so-called <i>community parameters</i> in DSA), there are two <A HREF="../../java/security/KeyPairGenerator.html#initialize(java.security.spec.AlgorithmParameterSpec)"><CODE>initialize</CODE></A> methods that have an <code>AlgorithmParameterSpec</code> argument. One also has a <code>SecureRandom</code> argument, while the the other uses the <code>SecureRandom</code> implementation of the highest-priority installed provider as the source of randomness. (If none of the installed providers supply an implementation of <code>SecureRandom</code>, a system-provided source of randomness is used.) </ul> <p>In case the client does not explicitly initialize the KeyPairGenerator (via a call to an <code>initialize</code> method), each provider must supply (and document) a default initialization. For example, the <i>Sun</i> provider uses a default modulus size (keysize) of 1024 bits. <p>Note that this class is abstract and extends from <code>KeyPairGeneratorSpi</code> for historical reasons. Application developers should only take notice of the methods defined in this <code>KeyPairGenerator</code> class; all the methods in the superclass are intended for cryptographic service providers who wish to supply their own implementations of key pair generators.<P><DL><DT><B>See Also: </B><DD><A HREF="../../java/security/spec/AlgorithmParameterSpec.html"><CODE>AlgorithmParameterSpec</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== 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/KeyPairGenerator.html#KeyPairGenerator(java.lang.String)">KeyPairGenerator</A></B>(<A HREF="../../java/lang/String.html">String</A> algorithm)</CODE><BR> Creates a KeyPairGenerator 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/security/KeyPair.html">KeyPair</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyPairGenerator.html#generateKeyPair()">generateKeyPair</A></B>()</CODE><BR> Generates a key pair.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/security/KeyPair.html">KeyPair</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyPairGenerator.html#genKeyPair()">genKeyPair</A></B>()</CODE><BR> Generates a key pair.</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/KeyPairGenerator.html#getAlgorithm()">getAlgorithm</A></B>()</CODE><BR> Returns the standard name of the algorithm for this key pair generator.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/security/KeyPairGenerator.html">KeyPairGenerator</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyPairGenerator.html#getInstance(java.lang.String)">getInstance</A></B>(<A HREF="../../java/lang/String.html">String</A> algorithm)</CODE><BR> Generates a KeyPairGenerator 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/KeyPairGenerator.html">KeyPairGenerator</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyPairGenerator.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 KeyPairGenerator 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/security/Provider.html">Provider</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyPairGenerator.html#getProvider()">getProvider</A></B>()</CODE><BR> Returns the provider of this key pair generator 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/KeyPairGenerator.html#initialize(java.security.spec.AlgorithmParameterSpec)">initialize</A></B>(<A HREF="../../java/security/spec/AlgorithmParameterSpec.html">AlgorithmParameterSpec</A> params)</CODE><BR> Initializes the key pair generator using the specified parameter set and the <code>SecureRandom</code> implementation of the highest-priority installed provider as the source of randomness.</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/KeyPairGenerator.html#initialize(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)">initialize</A></B>(<A HREF="../../java/security/spec/AlgorithmParameterSpec.html">AlgorithmParameterSpec</A> params, <A HREF="../../java/security/SecureRandom.html">SecureRandom</A> random)</CODE><BR> Initializes the key pair generator with the given parameter set and source of randomness.</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/KeyPairGenerator.html#initialize(int)">initialize</A></B>(int keysize)</CODE><BR> Initializes the key pair generator for a certain keysize using a default parameter set and the <code>SecureRandom</code> implementation of the highest-priority installed provider as the source of randomness.</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/KeyPairGenerator.html#initialize(int, java.security.SecureRandom)">initialize</A></B>(int keysize, <A HREF="../../java/security/SecureRandom.html">SecureRandom</A> random)</CODE><BR> Initializes the key pair generator for a certain keysize with the given source of randomness (and a default parameter set).</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -