01: /*
02: * @(#)AlgorithmParameterGeneratorSpi.java 1.17 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package java.security;
29:
30: import java.security.spec.AlgorithmParameterSpec;
31:
32: /**
33: * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
34: * for the <code>AlgorithmParameterGenerator</code> class, which
35: * is used to generate a set of parameters to be used with a certain algorithm.
36: *
37: * <p> All the abstract methods in this class must be implemented by each
38: * cryptographic service provider who wishes to supply the implementation
39: * of a parameter generator for a particular algorithm.
40: *
41: * <p> In case the client does not explicitly initialize the
42: * AlgorithmParameterGenerator (via a call to an <code>engineInit</code>
43: * method), each provider must supply (and document) a default initialization.
44: * For example, the Sun provider uses a default modulus prime size of 1024
45: * bits for the generation of DSA parameters.
46: *
47: * @author Jan Luehe
48: *
49: * @version 1.11, 02/02/00
50: *
51: * @see AlgorithmParameterGenerator
52: * @see AlgorithmParameters
53: * @see java.security.spec.AlgorithmParameterSpec
54: *
55: * @since 1.2
56: */
57:
58: public abstract class AlgorithmParameterGeneratorSpi {
59:
60: /**
61: * Initializes this parameter generator for a certain size
62: * and source of randomness.
63: *
64: * @param size the size (number of bits).
65: * @param random the source of randomness.
66: */
67: protected abstract void engineInit(int size, SecureRandom random);
68:
69: /**
70: * Initializes this parameter generator with a set of
71: * algorithm-specific parameter generation values.
72: *
73: * @param genParamSpec the set of algorithm-specific parameter generation values.
74: * @param random the source of randomness.
75: *
76: * @exception InvalidAlgorithmParameterException if the given parameter
77: * generation values are inappropriate for this parameter generator.
78: */
79: protected abstract void engineInit(
80: AlgorithmParameterSpec genParamSpec, SecureRandom random)
81: throws InvalidAlgorithmParameterException;
82:
83: /**
84: * Generates the parameters.
85: *
86: * @return the new AlgorithmParameters object.
87: */
88: protected abstract AlgorithmParameters engineGenerateParameters();
89: }
|