Save This Page
Home » openjdk-7 » java » security » interfaces » [javadoc | source]
    1   /*
    2    * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package java.security.interfaces;
   27   
   28   import java.security;
   29   
   30   /**
   31    * An interface to an object capable of generating DSA key pairs.
   32    *
   33    * <p>The <code>initialize</code> methods may each be called any number
   34    * of times. If no <code>initialize</code> method is called on a
   35    * DSAKeyPairGenerator, the default is to generate 1024-bit keys, using
   36    * precomputed p, q and g parameters and an instance of SecureRandom as
   37    * the random bit source.
   38    *
   39    * <p>Users wishing to indicate DSA-specific parameters, and to generate a key
   40    * pair suitable for use with the DSA algorithm typically
   41    *
   42    * <ol>
   43    *
   44    * <li>Get a key pair generator for the DSA algorithm by calling the
   45    * KeyPairGenerator <code>getInstance</code> method with "DSA"
   46    * as its argument.<p>
   47    *
   48    * <li>Initialize the generator by casting the result to a DSAKeyPairGenerator
   49    * and calling one of the
   50    * <code>initialize</code> methods from this DSAKeyPairGenerator interface.<p>
   51    *
   52    * <li>Generate a key pair by calling the <code>generateKeyPair</code>
   53    * method from the KeyPairGenerator class.
   54    *
   55    * </ol>
   56    *
   57    * <p>Note: it is not always necessary to do do algorithm-specific
   58    * initialization for a DSA key pair generator. That is, it is not always
   59    * necessary to call an <code>initialize</code> method in this interface.
   60    * Algorithm-independent initialization using the <code>initialize</code> method
   61    * in the KeyPairGenerator
   62    * interface is all that is needed when you accept defaults for algorithm-specific
   63    * parameters.
   64    *
   65    * @see java.security.KeyPairGenerator
   66    */
   67   public interface DSAKeyPairGenerator {
   68   
   69       /**
   70        * Initializes the key pair generator using the DSA family parameters
   71        * (p,q and g) and an optional SecureRandom bit source. If a
   72        * SecureRandom bit source is needed but not supplied, i.e. null, a
   73        * default SecureRandom instance will be used.
   74        *
   75        * @param params the parameters to use to generate the keys.
   76        *
   77        * @param random the random bit source to use to generate key bits;
   78        * can be null.
   79        *
   80        * @exception InvalidParameterException if the <code>params</code>
   81        * value is invalid or null.
   82        */
   83      public void initialize(DSAParams params, SecureRandom random)
   84      throws InvalidParameterException;
   85   
   86       /**
   87        * Initializes the key pair generator for a given modulus length
   88        * (instead of parameters), and an optional SecureRandom bit source.
   89        * If a SecureRandom bit source is needed but not supplied, i.e.
   90        * null, a default SecureRandom instance will be used.
   91        *
   92        * <p>If <code>genParams</code> is true, this method generates new
   93        * p, q and g parameters. If it is false, the method uses precomputed
   94        * parameters for the modulus length requested. If there are no
   95        * precomputed parameters for that modulus length, an exception will be
   96        * thrown. It is guaranteed that there will always be
   97        * default parameters for modulus lengths of 512 and 1024 bits.
   98        *
   99        * @param modlen the modulus length in bits. Valid values are any
  100        * multiple of 8 between 512 and 1024, inclusive.
  101        *
  102        * @param random the random bit source to use to generate key bits;
  103        * can be null.
  104        *
  105        * @param genParams whether or not to generate new parameters for
  106        * the modulus length requested.
  107        *
  108        * @exception InvalidParameterException if <code>modlen</code> is not
  109        * between 512 and 1024, or if <code>genParams</code> is false and
  110        * there are no precomputed parameters for the requested modulus
  111        * length.
  112        */
  113       public void initialize(int modlen, boolean genParams, SecureRandom random)
  114       throws InvalidParameterException;
  115   }

Save This Page
Home » openjdk-7 » java » security » interfaces » [javadoc | source]