1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package java.security.interfaces;
19
20import java.security.InvalidParameterException;
21import java.security.SecureRandom;
22
23/**
24 * The interface for key generators that can generate DSA key pairs.
25 */
26public interface DSAKeyPairGenerator {
27
28    /**
29     * Initializes this generator with the prime ({@code p}), subprime ({@code
30     * q}), and base ({@code g}) values from the specified parameters.
31     *
32     * @param params
33     *            the parameter values.
34     * @param random
35     *            the source of randomness.
36     * @throws InvalidParameterException
37     *             if the specified parameter values are {@code null} or
38     *             invalid.
39     */
40    public void initialize(DSAParams params, SecureRandom random)
41            throws InvalidParameterException;
42
43    /**
44     * Initializes this generator for the specified modulus length. Valid values
45     * for the modulus length are the multiples of 8 between 512 and 1024.
46     * <p>
47     * The parameter {@code genParams} specifies whether this method should
48     * generate new prime ({@code p}), subprime ({@code q}), and base ({@code g})
49     * values or whether
50     * it will use the pre-calculated values for the specified modulus
51     * length. Default parameters are available for modulus lengths of 512 and 1024
52     * bits.
53     *
54     * @param modlen
55     *            the length of the modulus in bits.
56     * @param genParams
57     *            whether new values should be generated.
58     * @param random
59     *            the source of randomness.
60     * @throws InvalidParameterException
61     *             if the specified modulus length is not valid, or if there are
62     *             no pre-calculated values and {@code genParams} is {@code
63     *             false}.
64     */
65    public void initialize(int modlen, boolean genParams, SecureRandom random)
66            throws InvalidParameterException;
67}
68