Logo Search packages:      
Sourcecode: libgnucrypto-java version File versions  Download package

DHParameterSpec.java

/*
 * Copyright (c) 2000 The Legion Of The Bouncy Castle
 * (http://www.bouncycastle.org)
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 */

package javax.crypto.spec;

import java.math.BigInteger;
import java.security.spec.AlgorithmParameterSpec;

/**
 * This class specifies the set of parameters used with the Diffie-Hellman
 * algorithm, as specified in PKCS #3: <i>Diffie-Hellman Key-Agreement
 * Standard</i>.
 * <p>
 * A central authority generates parameters and gives them to the two
 * entities seeking to generate a secret key. The parameters are a prime
 * <code>p</code>, a base <code>g</code>, and optionally the length
 * in bits of the private value, <code>l</code>.
 * <p>
 * It is possible that more than one instance of parameters may be
 * generated by a given central authority, and that there may be more than
 * one central authority. Indeed, each individual may be its own central
 * authority, with different entities having different parameters.
 * 
 * @see javax.crypto.KeyAgreement
 */
00049 public class DHParameterSpec
    implements AlgorithmParameterSpec
{
    private BigInteger  p;
    private BigInteger  g;
    private int         l;

    /**
     * Constructs a parameter set for Diffie-Hellman, using a prime modulus
     * <code>p</code> and a base generator <code>g</code>.
     * 
     * @param p the prime modulus
     * @param g the base generator
     */
00063     public DHParameterSpec(
        BigInteger  p,
        BigInteger  g)
    {
        this.p = p;
        this.g = g;
    }

    /**
     * Constructs a parameter set for Diffie-Hellman, using a prime modulus
     * <code>p</code>, a base generator <code>g</code>, and the size in bits,
     * <code>l</code>, of the random exponent (private value).
     * 
     * @param p the prime modulus
     * @param g the base generator
     * @param l the size in bits of the random exponent (private value)
     */
00080     public DHParameterSpec(
        BigInteger  p,
        BigInteger  g,
        int         l)
    {
        this.p = p;
        this.g = g;
        this.l = l;
    }

    /**
     * Returns the prime modulus <code>p</code>.
     *
     * @return the prime modulus <code>p</code>
     */
00095     public BigInteger getP()
    {
        return p;
    }

    /**
     * Returns the base generator <code>g</code>.
     *
     * @return the base generator <code>g</code>
     */
00105     public BigInteger getG()
    {
        return g;
    }

    /**
     * Returns the size in bits, <code>l</code>, of the random exponent
     * (private value).
     *
     * @return the size in bits, <code>l</code>, of the random exponent
     * (private value), or 0 if this size has not been set
     */
00117     public int getL()
    {
        return l;
    }
}

Generated by  Doxygen 1.6.0   Back to index