0N/A/*
2362N/A * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.crypto.spec;
0N/A
0N/Aimport java.math.BigInteger;
0N/Aimport java.security.spec.AlgorithmParameterSpec;
0N/A
0N/A/**
0N/A * This class specifies the set of parameters used with the Diffie-Hellman
0N/A * algorithm, as specified in PKCS #3: <i>Diffie-Hellman Key-Agreement
0N/A * Standard</i>.
0N/A *
0N/A * <p>A central authority generates parameters and gives them to the two
0N/A * entities seeking to generate a secret key. The parameters are a prime
0N/A * <code>p</code>, a base <code>g</code>, and optionally the length
0N/A * in bits of the private value, <code>l</code>.
0N/A *
0N/A * <p>It is possible that more than one instance of parameters may be
0N/A * generated by a given central authority, and that there may be more than
0N/A * one central authority. Indeed, each individual may be its own central
0N/A * authority, with different entities having different parameters.
0N/A *
0N/A * <p>Note that this class does not perform any validation on specified
0N/A * parameters. Thus, the specified values are returned directly even
0N/A * if they are null.
0N/A *
0N/A * @author Jan Luehe
0N/A *
0N/A * @see javax.crypto.KeyAgreement
0N/A * @since 1.4
0N/A */
0N/Apublic class DHParameterSpec implements AlgorithmParameterSpec {
0N/A
0N/A // The prime modulus
0N/A private BigInteger p;
0N/A
0N/A // The base generator
0N/A private BigInteger g;
0N/A
0N/A // The size in bits of the random exponent (private value) (optional)
0N/A private int l;
0N/A
0N/A /**
0N/A * Constructs a parameter set for Diffie-Hellman, using a prime modulus
0N/A * <code>p</code> and a base generator <code>g</code>.
0N/A *
0N/A * @param p the prime modulus
0N/A * @param g the base generator
0N/A */
0N/A public DHParameterSpec(BigInteger p, BigInteger g) {
0N/A this.p = p;
0N/A this.g = g;
0N/A this.l = 0;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a parameter set for Diffie-Hellman, using a prime modulus
0N/A * <code>p</code>, a base generator <code>g</code>,
0N/A * and the size in bits, <code>l</code>, of the random exponent
0N/A * (private value).
0N/A *
0N/A * @param p the prime modulus
0N/A * @param g the base generator
0N/A * @param l the size in bits of the random exponent (private value)
0N/A */
0N/A public DHParameterSpec(BigInteger p, BigInteger g, int l) {
0N/A this.p = p;
0N/A this.g = g;
0N/A this.l = l;
0N/A }
0N/A
0N/A /**
0N/A * Returns the prime modulus <code>p</code>.
0N/A *
0N/A * @return the prime modulus <code>p</code>
0N/A */
0N/A public BigInteger getP() {
0N/A return this.p;
0N/A }
0N/A
0N/A /**
0N/A * Returns the base generator <code>g</code>.
0N/A *
0N/A * @return the base generator <code>g</code>
0N/A */
0N/A public BigInteger getG() {
0N/A return this.g;
0N/A }
0N/A
0N/A /**
0N/A * Returns the size in bits, <code>l</code>, of the random exponent
0N/A * (private value).
0N/A *
0N/A * @return the size in bits, <code>l</code>, of the random exponent
0N/A * (private value), or 0 if this size has not been set
0N/A */
0N/A public int getL() {
0N/A return this.l;
0N/A }
0N/A}