home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / security / KeyPairGeneratorSpi.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.2 KB  |  92 lines

  1. /*
  2.  * @(#)KeyPairGeneratorSpi.java    1.3 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.security;
  16.  
  17. import java.security.spec.AlgorithmParameterSpec;
  18.  
  19. /**
  20.  * <p> This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
  21.  * for the <code>KeyPairGenerator</code> class, which is used to generate
  22.  * pairs of public and private keys.
  23.  *
  24.  * <p> All the abstract methods in this class must be implemented by each
  25.  * cryptographic service provider who wishes to supply the implementation
  26.  * of a key pair generator for a particular algorithm.
  27.  * 
  28.  * <p> In case the client does not explicitly initialize the KeyPairGenerator
  29.  * (via a call to an <code>initialize</code> method), each provider must
  30.  * supply (and document) a default initialization.
  31.  * For example, the <i>Sun</i> provider uses a default modulus size (strength)
  32.  * of 1024 bits.
  33.  *
  34.  * @author Benjamin Renaud
  35.  *
  36.  * @version 1.3, 98/03/18
  37.  *
  38.  * @see KeyPairGenerator
  39.  * @see java.security.spec.AlgorithmParameterSpec
  40.  */
  41.  
  42. public abstract class KeyPairGeneratorSpi {
  43.  
  44.     /**
  45.      * Initializes the key pair generator for a certain strength, using
  46.      * the default parameter set.
  47.      *
  48.      * @param strength the strength of the key. This is an
  49.      * algorithm-specific metric, such as modulus length, specified in
  50.      * number of bits.
  51.      *
  52.      * @param random the source of randomness for this generator.
  53.      */
  54.     public abstract void initialize(int strength, SecureRandom random);
  55.  
  56.     /**
  57.      * Initializes the key pair generator using the specified parameter
  58.      * set and user-provided source of randomness.
  59.      *
  60.      * <p>This concrete method has been added to this previously-defined
  61.      * abstract class. (For backwards compatibility, it cannot be abstract.)
  62.      * It may be overridden by a provider to initialize the key pair 
  63.      * generator. Such an override
  64.      * is expected to throw an InvalidAlgorithmParameterException if
  65.      * a parameter is inappropriate for this key pair generator.
  66.      * If this method is not overridden, it always throws an
  67.      * UnsupportedOperationException.
  68.      *
  69.      * @param params the parameter set used to generate the keys.
  70.      *
  71.      * @param random the source of randomness for this generator.
  72.      *
  73.      * @exception InvalidAlgorithmParameterException if the given parameters
  74.      * are inappropriate for this key pair generator.
  75.      *
  76.      * @since JDK1.2
  77.      */
  78.     public void initialize(AlgorithmParameterSpec params,
  79.                    SecureRandom random)
  80.     throws InvalidAlgorithmParameterException {
  81.         throw new UnsupportedOperationException();
  82.     }
  83.  
  84.     /**
  85.      * Generates a key pair. Unless an initialization method is called
  86.      * using a KeyPairGenerator interface, algorithm-specific defaults
  87.      * will be used. This will generate a new key pair every time it
  88.      * is called.
  89.      */
  90.     public abstract KeyPair generateKeyPair();
  91. }
  92.