KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > interfaces > DSAKeyPairGenerator


1 /*
2  * @(#)DSAKeyPairGenerator.java 1.13 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7  
8 package java.security.interfaces;
9
10 import java.security.*;
11
12 /**
13  * An interface to an object capable of generating DSA key pairs.
14  *
15  * <p>The <code>initialize</code> methods may each be called any number
16  * of times. If no <code>initialize</code> method is called on a
17  * DSAKeyPairGenerator, the default is to generate 1024-bit keys, using
18  * precomputed p, q and g parameters and an instance of SecureRandom as
19  * the random bit source.
20  *
21  * <p>Users wishing to indicate DSA-specific parameters, and to generate a key
22  * pair suitable for use with the DSA algorithm typically
23  *
24  * <ol>
25  *
26  * <li>Get a key pair generator for the DSA algorithm by calling the
27  * KeyPairGenerator <code>getInstance</code> method with "DSA"
28  * as its argument.<p>
29  *
30  * <li>Initialize the generator by casting the result to a DSAKeyPairGenerator
31  * and calling one of the
32  * <code>initialize</code> methods from this DSAKeyPairGenerator interface.<p>
33  *
34  * <li>Generate a key pair by calling the <code>generateKeyPair</code>
35  * method from the KeyPairGenerator class.
36  *
37  * </ol>
38  *
39  * <p>Note: it is not always necessary to do do algorithm-specific
40  * initialization for a DSA key pair generator. That is, it is not always
41  * necessary to call an <code>initialize</code> method in this interface.
42  * Algorithm-independent initialization using the <code>initialize</code> method
43  * in the KeyPairGenerator
44  * interface is all that is needed when you accept defaults for algorithm-specific
45  * parameters.
46  *
47  * @see java.security.KeyPairGenerator
48  */

49 public interface DSAKeyPairGenerator {
50
51     /**
52      * Initializes the key pair generator using p, q and g, the DSA
53      * family parameters.
54      *
55      * @param params the parameters to use to generate the keys.
56      *
57      * @param random the random bit source to use to generate
58      * key bits.
59      *
60      * @exception InvalidParameterException if the parameters passed are
61      * invalid or null.
62      */

63    public void initialize(DSAParams JavaDoc params, SecureRandom random)
64    throws InvalidParameterException;
65
66     /**
67      * Initializes the key pair generator for a given modulus length,
68      * without parameters.
69      *
70      * <p>If <code>genParams</code> is true, this method will generate new
71      * p, q and g parameters. If it is false, the method will use precomputed
72      * parameters for the modulus length requested. If there are no
73      * precomputed parameters for that modulus length, an exception will be
74      * thrown. It is guaranteed that there will always be
75      * default parameters for modulus lengths of 512 and 1024 bits.
76      *
77      * @param modlen the modulus length, in bits. Valid values are any
78      * multiple of 8 between 512 and 1024, inclusive.
79      *
80      * @param random the random bit source to use to generate
81      * key bits.
82      *
83      * @param genParams whether or not to generate new parameters for
84      * the modulus length requested.
85      *
86      * @exception InvalidParameterException if the modulus length is not
87      * between 512 and 1024, or if genParams is false and there are
88      * not precomputed parameters for the modulus length requested.
89      */

90     public void initialize(int modlen, boolean genParams, SecureRandom random)
91     throws InvalidParameterException;
92 }
93
Popular Tags