Path: blob/master/src/java.base/share/classes/javax/crypto/spec/DHGenParameterSpec.java
41159 views
/*1* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.crypto.spec;2627import java.math.BigInteger;28import java.security.spec.AlgorithmParameterSpec;2930/**31* This class specifies the set of parameters used for generating32* Diffie-Hellman (system) parameters for use in Diffie-Hellman key33* agreement. This is typically done by a central34* authority.35*36* <p> The central authority, after computing the parameters, must send this37* information to the parties looking to agree on a secret key.38*39* @author Jan Luehe40*41* @see DHParameterSpec42* @since 1.443*/44public class DHGenParameterSpec implements AlgorithmParameterSpec {4546// The size in bits of the prime modulus47private int primeSize;4849// The size in bits of the random exponent (private value)50private int exponentSize;5152/**53* Constructs a parameter set for the generation of Diffie-Hellman54* (system) parameters. The constructed parameter set can be used to55* initialize an56* {@link java.security.AlgorithmParameterGenerator AlgorithmParameterGenerator}57* object for the generation of Diffie-Hellman parameters.58*59* @param primeSize the size (in bits) of the prime modulus.60* @param exponentSize the size (in bits) of the random exponent.61*/62public DHGenParameterSpec(int primeSize, int exponentSize) {63this.primeSize = primeSize;64this.exponentSize = exponentSize;65}6667/**68* Returns the size in bits of the prime modulus.69*70* @return the size in bits of the prime modulus71*/72public int getPrimeSize() {73return this.primeSize;74}7576/**77* Returns the size in bits of the random exponent (private value).78*79* @return the size in bits of the random exponent (private value)80*/81public int getExponentSize() {82return this.exponentSize;83}84}858687