KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > crypto > KeyGeneratorSpi


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 /*
7  * @(#)KeyGeneratorSpi.java 1.4 03/12/19
8  */

9   
10 /*
11  * NOTE:
12  * Because of various external restrictions (i.e. US export
13  * regulations, etc.), the actual source code can not be provided
14  * at this time. This file represents the skeleton of the source
15  * file, so that javadocs of the API can be created.
16  */

17
18 package javax.crypto;
19
20 import java.security.*;
21 import java.security.spec.*;
22
23 /**
24  * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
25  * for the <code>KeyGenerator</code> class.
26  * All the abstract methods in this class must be implemented by each
27  * cryptographic service provider who wishes to supply the implementation
28  * of a key generator for a particular algorithm.
29  *
30  * @author Jan Luehe
31  *
32  * @version 1.4, 12/19/03
33  *
34  * @see SecretKey
35  * @since 1.4
36  */

37 public abstract class KeyGeneratorSpi
38 {
39
40     public KeyGeneratorSpi() { }
41
42     /**
43      * Initializes the key generator.
44      *
45      * @param random the source of randomness for this generator
46      */

47     protected abstract void engineInit(SecureRandom random);
48
49     /**
50      * Initializes the key generator with the specified parameter
51      * set and a user-provided source of randomness.
52      *
53      * @param params the key generation parameters
54      * @param random the source of randomness for this key generator
55      *
56      * @exception InvalidAlgorithmParameterException if <code>params</code> is
57      * inappropriate for this key generator
58      */

59     protected abstract void engineInit(AlgorithmParameterSpec params,
60         SecureRandom random) throws InvalidAlgorithmParameterException;
61
62     /**
63      * Initializes this key generator for a certain keysize, using the given
64      * source of randomness.
65      *
66      * @param keysize the keysize. This is an algorithm-specific metric,
67      * specified in number of bits.
68      * @param random the source of randomness for this key generator
69      *
70      * @exception InvalidParameterException if the keysize is wrong or not
71      * supported.
72      */

73     protected abstract void engineInit(int keysize, SecureRandom random);
74
75     /**
76      * Generates a secret key.
77      *
78      * @return the new key
79      */

80     protected abstract SecretKey engineGenerateKey();
81 }
82
Popular Tags