home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / DSAKeyPairGenerator.java < prev    next >
Text File  |  1997-05-20  |  4KB  |  108 lines

  1. /*
  2.  * @(#)DSAKeyPairGenerator.java    1.5 97/02/10
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.security.interfaces;
  24.  
  25. import java.security.*;
  26.  
  27. /**
  28.  * An interface to an object capable of generating DSA key pairs. 
  29.  *
  30.  * <p>The <code>initialize</code> methods may each be called any number 
  31.  * of times. If no <code>initialize</code> method is called on a 
  32.  * DSAKeyPairGenerator, the default is to generate 1024-bit keys, using 
  33.  * precomputed p, q and g parameters and an instance of SecureRandom as 
  34.  * the random bit source.
  35.  * 
  36.  * <p>Users wishing to indicate DSA-specific parameters, and to generate a key 
  37.  * pair suitable for use with the DSA algorithm typically
  38.  * 
  39.  * <ol>
  40.  * 
  41.  * <li>Get a key pair generator for the DSA algorithm by calling the 
  42.  * KeyPairGenerator <code>getInstance</code> method with "DSA" 
  43.  * as its argument.<p> 
  44.  * 
  45.  * <li>Initialize the generator by casting the result to a DSAKeyPairGenerator
  46.  * and calling one of the 
  47.  * <code>initialize</code> methods from this DSAKeyPairGenerator interface.<p>
  48.  * 
  49.  * <li>Generate a key pair by calling the <code>generateKeyPair</code> 
  50.  * method from the KeyPairGenerator class.
  51.  * 
  52.  * </ol> 
  53.  *
  54.  * <p>Note: it is not always necessary to do do algorithm-specific
  55.  * initialization for a DSA key pair generator. That is, it is not always
  56.  * necessary to call an <code>initialize</code> method in this interface.
  57.  * Algorithm-independent initialization using the <code>initialize</code> method
  58.  * in the KeyPairGenerator
  59.  * interface is all that is needed when you accept defaults for algorithm-specific
  60.  * parameters.
  61.  * 
  62.  * @see java.security.KeyPairGenerator
  63.  */
  64. public interface DSAKeyPairGenerator {
  65.  
  66.     /**
  67.      * Initializes the key pair generator using p, q and g, the DSA
  68.      * family parameters.
  69.      *
  70.      * @param params the parameters to use to generate the keys.
  71.      *
  72.      * @param random the random bit source to use to generate 
  73.      * key bits.
  74.      *
  75.      * @exception InvalidParameterException if the parameters passed are
  76.      * invalid or null.
  77.      */
  78.    public void initialize(DSAParams params, SecureRandom random)
  79.    throws InvalidParameterException;
  80.  
  81.     /**
  82.      * Initializes the key pair generator for a given modulus length,
  83.      * without parameters. 
  84.      *
  85.      * <p>If <code>genParams</code> is true, this method will generate new 
  86.      * p, q and g parameters. If it is false, the method will use precomputed
  87.      * parameters for the modulus length requested. If there are no
  88.      * precomputed parameters for that modulus length, an exception will be 
  89.      * thrown. It is guaranteed that there will always be
  90.      * default parameters for modulus lengths of 512 and 1024 bits.
  91.      *
  92.      * @param modlen the modulus length, in bits. Valid values are any
  93.      * multiple of 8 between 512 and 1024, inclusive.
  94.      *
  95.      * @param random the random bit source to use to generate 
  96.      * key bits.
  97.      *
  98.      * @param genParams whether or not to generate new parameters for
  99.      * the modulus length requested.
  100.      *
  101.      * @exception InvalidParameterException if the modulus length is not
  102.      * between 512 and 1024, or if genParams is false and there are
  103.      * not precomputed parameters for the modulus length requested.  
  104.      */
  105.     public void initialize(int modlen, boolean genParams, SecureRandom random)
  106.     throws InvalidParameterException;
  107. }
  108.