Save This Page
Home » openjdk-7 » javax » crypto » [javadoc | source]
    1   /*
    2    * Copyright (c) 1997, 2007, Oracle and/or its affiliates. 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.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package javax.crypto;
   27   
   28   import java.security;
   29   import java.security.spec;
   30   
   31   /**
   32    * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
   33    * for the <code>KeyGenerator</code> class.
   34    * All the abstract methods in this class must be implemented by each
   35    * cryptographic service provider who wishes to supply the implementation
   36    * of a key generator for a particular algorithm.
   37    *
   38    * @author Jan Luehe
   39    *
   40    * @see SecretKey
   41    * @since 1.4
   42    */
   43   
   44   public abstract class KeyGeneratorSpi {
   45   
   46       /**
   47        * Initializes the key generator.
   48        *
   49        * @param random the source of randomness for this generator
   50        */
   51       protected abstract void engineInit(SecureRandom random);
   52   
   53       /**
   54        * Initializes the key generator with the specified parameter
   55        * set and a user-provided source of randomness.
   56        *
   57        * @param params the key generation parameters
   58        * @param random the source of randomness for this key generator
   59        *
   60        * @exception InvalidAlgorithmParameterException if <code>params</code> is
   61        * inappropriate for this key generator
   62        */
   63       protected abstract void engineInit(AlgorithmParameterSpec params,
   64                                          SecureRandom random)
   65           throws InvalidAlgorithmParameterException;
   66   
   67       /**
   68        * Initializes this key generator for a certain keysize, using the given
   69        * source of randomness.
   70        *
   71        * @param keysize the keysize. This is an algorithm-specific metric,
   72        * specified in number of bits.
   73        * @param random the source of randomness for this key generator
   74        *
   75        * @exception InvalidParameterException if the keysize is wrong or not
   76        * supported.
   77        */
   78       protected abstract void engineInit(int keysize, SecureRandom random);
   79   
   80       /**
   81        * Generates a secret key.
   82        *
   83        * @return the new key
   84        */
   85       protected abstract SecretKey engineGenerateKey();
   86   }

Save This Page
Home » openjdk-7 » javax » crypto » [javadoc | source]