1 /*
2 * Copyright 1997-2007 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package javax.crypto.spec;
27
28 import java.math.BigInteger;
29 import java.security.spec.AlgorithmParameterSpec;
30
31 /**
32 * This class specifies the set of parameters used for generating
33 * Diffie-Hellman (system) parameters for use in Diffie-Hellman key
34 * agreement. This is typically done by a central
35 * authority.
36 *
37 * <p> The central authority, after computing the parameters, must send this
38 * information to the parties looking to agree on a secret key.
39 *
40 * @author Jan Luehe
41 *
42 * @see DHParameterSpec
43 * @since 1.4
44 */
45 public class DHGenParameterSpec implements AlgorithmParameterSpec {
46
47 // The size in bits of the prime modulus
48 private int primeSize;
49
50 // The size in bits of the random exponent (private value)
51 private int exponentSize;
52
53 /**
54 * Constructs a parameter set for the generation of Diffie-Hellman
55 * (system) parameters. The constructed parameter set can be used to
56 * initialize an
57 * {@link java.security.AlgorithmParameterGenerator AlgorithmParameterGenerator}
58 * object for the generation of Diffie-Hellman parameters.
59 *
60 * @param primeSize the size (in bits) of the prime modulus.
61 * @param exponentSize the size (in bits) of the random exponent.
62 */
63 public DHGenParameterSpec(int primeSize, int exponentSize) {
64 this.primeSize = primeSize;
65 this.exponentSize = exponentSize;
66 }
67
68 /**
69 * Returns the size in bits of the prime modulus.
70 *
71 * @return the size in bits of the prime modulus
72 */
73 public int getPrimeSize() {
74 return this.primeSize;
75 }
76
77 /**
78 * Returns the size in bits of the random exponent (private value).
79 *
80 * @return the size in bits of the random exponent (private value)
81 */
82 public int getExponentSize() {
83 return this.exponentSize;
84 }
85 }