1 package javax.crypto.spec; 2 3 import java.security.spec.AlgorithmParameterSpec; 4 5 /** 6 * This class specifies the set of parameters used for generating 7 * Diffie-Hellman (system) parameters for use in Diffie-Hellman key 8 * agreement. This is typically done by a central 9 * authority. 10 * <p> 11 * The central authority, after computing the parameters, must send this 12 * information to the parties looking to agree on a secret key. 13 */ 14 public class DHGenParameterSpec 15 implements AlgorithmParameterSpec 16 { 17 private int primeSize; 18 private int exponentSize; 19 20 /** 21 * Constructs a parameter set for the generation of Diffie-Hellman 22 * (system) parameters. The constructed parameter set can be used to 23 * initialize an <a href="http://java.sun.com/products/jdk/1.2/docs/api/java.security.AlgorithmParameterGenerator.html"><code>AlgorithmParameterGenerator</code></a> 24 * object for the generation of Diffie-Hellman parameters. 25 * 26 * @param primeSize the size (in bits) of the prime modulus. 27 * @param exponentSize the size (in bits) of the random exponent. 28 */ DHGenParameterSpec( int primeSize, int exponentSize)29 public DHGenParameterSpec( 30 int primeSize, 31 int exponentSize) 32 { 33 this.primeSize = primeSize; 34 this.exponentSize = exponentSize; 35 } 36 37 /** 38 * Returns the size in bits of the prime modulus. 39 * 40 * @return the size in bits of the prime modulus 41 */ getPrimeSize()42 public int getPrimeSize() 43 { 44 return primeSize; 45 } 46 47 /** 48 * Returns the size in bits of the random exponent (private value). 49 * 50 * @return the size in bits of the random exponent (private value) 51 */ getExponentSize()52 public int getExponentSize() 53 { 54 return exponentSize; 55 } 56 } 57