<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.security.KeyPairGenerator
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.security.html">This Package</a>  <a href="java.security.KeyPair.html#_top_">Previous</a>  <a href="java.security.MessageDigest.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.security.KeyPairGenerator
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.security.KeyPairGenerator
</pre>
<hr>
<dl>
  <dt> public abstract class <b>KeyPairGenerator</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
</dl>
The KeyPairGenerator class is used to generate pairs of
 public and private keys. Key generators are constructed using the
 <code>getInstance</code> factory methods (static methods that
 return instances of a given class).
 <p>Key generation is an area that sometimes
 does not lend itself well to algorithm independence. For example,
 it is possible to generate a DSA key pair specifying key family
 parameters (p, q and g), while it is not possible to do so for
 an RSA key pair. That is, those parameters are applicable to DSA
 but not to RSA.
 <P>There are therefore 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. 
 <p>All key pair generators share the concepts of a "strength" and a
 source of randomness. The measure of strength is universally shared 
 by all algorithms,
 though it is interpreted differently for different algorithms.
 The <a href = "#initialize ">initialize</a> method in this 
 KeyPairGenerator class 
 takes these two universally shared
 types of arguments. 
 <p>Since no other parameters are specified when you call this
 algorithm-independent <code>initialize</code>
 method, all other values, such as algorithm parameters, public
 exponent, etc., are defaulted to standard values. 
 <P>
 It is sometimes desirable to initialize a key pair generator object
 using algorithm-specific semantics. For example, you may want to
 initialize a DSA key generator for a given set of parameters 
 <code>p</code>, <code>q</code> and <code>g</code>,
 or an RSA key generator for a given public exponent.
 <P>
 This is done through algorithm-specific standard interfaces. Rather than
 calling the algorithm-independent KeyPairGenerator <code>initialize</code>
 method, the key pair generator is cast to an algorithm-specific interface 
 so that one of its specialized parameter initialization methods can be
 called. An example is the DSAKeyPairGenerator interface (from
 <code>java.security.interfaces</code>).
  <p>See <a href =
 "../guide/security/CryptoSpec.html#KPG">The KeyPairGenerator Class</a> 
 in the "Java Cryptography Architecture API Specification &amp; Reference"
 for more information and examples.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.security.interfaces.DSAKeyPairGenerator.html#_top_">DSAKeyPairGenerator</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#KeyPairGenerator(java.lang.String)"><b>KeyPairGenerator</b></a>(String)
  <dd>  Creates a KeyPairGenerator object for the specified algorithm.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#generateKeyPair()"><b>generateKeyPair</b></a>()
  <dd>  Generates a key pair.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getAlgorithm()"><b>getAlgorithm</b></a>()
  <dd>  Returns the standard name of the algorithm for this key generator.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getInstance(java.lang.String)"><b>getInstance</b></a>(String)
  <dd>  Generates a KeyPairGenerator object that implements the algorithm
 requested, as available in the environment.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getInstance(java.lang.String, java.lang.String)"><b>getInstance</b></a>(String, String)
  <dd> 
 Generates a KeyPairGenerator object implementing the specified
 algorithm, as supplied from the specified provider, 
 if such an algorithm is available from the provider.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#initialize(int)"><b>initialize</b></a>(int)
  <dd>  Initializes the key pair generator for a certain strength using
 a system-provided source of randomness.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#initialize(int, java.security.SecureRandom)"><b>initialize</b></a>(int, SecureRandom)
  <dd>  Initializes the key pair generator for a certain strength.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="KeyPairGenerator"></a>
<a name="KeyPairGenerator(java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>KeyPairGenerator</b>
<pre>
 protected KeyPairGenerator(<a href="java.lang.String.html#_top_">String</a> algorithm)
</pre>
<dl>
  <dd> Creates a KeyPairGenerator object for the specified algorithm.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> algorithm - the standard string name of the algorithm.
 See Appendix A in the <a href=
 "../guide/security/CryptoSpec.html#AppA">
 Java Cryptography Architecture API Specification &amp; Reference </a> 
 for information about standard algorithm names.
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="getAlgorithm()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getAlgorithm"><b>getAlgorithm</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> getAlgorithm()
</pre>
<dl>
  <dd> Returns the standard name of the algorithm for this key generator.
 See Appendix A in the <a href=
 "../guide/security/CryptoSpec.html#AppA">
 Java Cryptography Architecture API Specification &amp; Reference </a> 
 for information about standard algorithm names.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the standard string name of the algorithm.
  </dl></dd>
</dl>
<a name="getInstance(java.lang.String)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getInstance"><b>getInstance</b></a>
<pre>
 public static <a href="#_top_">KeyPairGenerator</a> getInstance(<a href="java.lang.String.html#_top_">String</a> algorithm) throws <a href="java.security.NoSuchAlgorithmException.html#_top_">NoSuchAlgorithmException</a>
</pre>
<dl>
  <dd> Generates a KeyPairGenerator object that implements the algorithm
 requested, as available in the environment.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> algorithm - the standard string name of the algorithm.
 See Appendix A in the <a href=
 "../guide/security/CryptoSpec.html#AppA">
 Java Cryptography Architecture API Specification &amp; Reference </a> 
 for information about standard algorithm names.
    <dt> <b>Returns:</b>
    <dd> the new KeyPairGenerator object.
    <dt> <b>Throws:</b> <a href="java.security.NoSuchAlgorithmException.html#_top_">NoSuchAlgorithmException</a>
    <dd> if the algorithm is
 not available in the environment.
  </dl></dd>
</dl>
<a name="getInstance(java.lang.String, java.lang.String)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getInstance"><b>getInstance</b></a>
<pre>
 public static <a href="#_top_">KeyPairGenerator</a> getInstance(<a href="java.lang.String.html#_top_">String</a> algorithm,
                                            <a href="java.lang.String.html#_top_">String</a> provider) throws <a href="java.security.NoSuchAlgorithmException.html#_top_">NoSuchAlgorithmException</a>, <a href="java.security.NoSuchProviderException.html#_top_">NoSuchProviderException</a>
</pre>
<dl>
  <dd> Generates a KeyPairGenerator object implementing the specified
 algorithm, as supplied from the specified provider, 
 if such an algorithm is available from the provider.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> algorithm - the standard string name of the algorithm.
 See Appendix A in the <a href=
 "../guide/security/CryptoSpec.html#AppA">
 Java Cryptography Architecture API Specification &amp; Reference </a> 
 for information about standard algorithm names.
    <dd> provider - the string name of the provider.
    <dt> <b>Returns:</b>
    <dd> the new KeyPairGenerator object.
    <dt> <b>Throws:</b> <a href="java.security.NoSuchAlgorithmException.html#_top_">NoSuchAlgorithmException</a>
    <dd> if the algorithm is
 not available from the provider.
    <dt> <b>Throws:</b> <a href="java.security.NoSuchProviderException.html#_top_">NoSuchProviderException</a>
    <dd> if the provider is not
 available in the environment.
    <dt> <b>See Also:</b>
    <dd> <a href="java.security.Provider.html#_top_">Provider</a>
  </dl></dd>
</dl>
<a name="initialize(int, java.security.SecureRandom)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="initialize"><b>initialize</b></a>
<pre>
 public abstract void initialize(int strength,
                                 <a href="java.security.SecureRandom.html#_top_">SecureRandom</a> random)
</pre>
<dl>
  <dd> Initializes the key pair generator for a certain strength.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> strength - the strength of the key. This is an
 algorithm-specific metric, such as modulus length.
    <dd> random - the source of randomness for this generator.
  </dl></dd>
</dl>
<a name="initialize(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="initialize"><b>initialize</b></a>
<pre>
 public void initialize(int strength)
</pre>
<dl>
  <dd> Initializes the key pair generator for a certain strength using
 a system-provided source of randomness.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> strength - the strength of the key. This is an
 algorithm-specific metric, such as modulus length.
  </dl></dd>
</dl>
<a name="generateKeyPair()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="generateKeyPair"><b>generateKeyPair</b></a>
<pre>
 public abstract <a href="java.security.KeyPair.html#_top_">KeyPair</a> generateKeyPair()
</pre>
<dl>
  <dd> Generates a key pair. Unless an initialization method is called
 using a KeyPairGenerator interface, algorithm-specific defaults
 will be used. This will generate a new key pair every time it
 is called.
<p>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.security.html">This Package</a>  <a href="java.security.KeyPair.html#_top_">Previous</a>  <a href="java.security.MessageDigest.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
