DHParameterSpec
Stay organized with collections
Save and categorize content based on your preferences.
This class specifies the set of parameters used with the Diffie-Hellman
algorithm, as specified in PKCS #3: Diffie-Hellman Key-Agreement
Standard.
A central authority generates parameters and gives them to the two
entities seeking to generate a secret key. The parameters are a prime
p
, a base g
, and optionally the length
in bits of the private value, l
.
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.
Note that this class does not perform any validation on specified
parameters. Thus, the specified values are returned directly even
if they are null.
Public Constructor Summary
|
DHParameterSpec(BigInteger p, BigInteger g)
Constructs a parameter set for Diffie-Hellman, using a prime modulus
p and a base generator g .
|
|
DHParameterSpec(BigInteger p, BigInteger g, int l)
Constructs a parameter set for Diffie-Hellman, using a prime modulus
p , a base generator g ,
and the size in bits, l , of the random exponent
(private value).
|
Public Method Summary
BigInteger
|
getG()
Returns the base generator g .
|
int
|
getL()
Returns the size in bits, l , of the random exponent
(private value).
|
BigInteger
|
getP()
Returns the prime modulus p .
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Public Constructors
public
DHParameterSpec
(BigInteger p, BigInteger g)
Constructs a parameter set for Diffie-Hellman, using a prime modulus
p
and a base generator g
.
Parameters
p |
the prime modulus |
g |
the base generator
|
public
DHParameterSpec
(BigInteger p, BigInteger g, int l)
Constructs a parameter set for Diffie-Hellman, using a prime modulus
p
, a base generator g
,
and the size in bits, l
, of the random exponent
(private value).
Parameters
p |
the prime modulus |
g |
the base generator |
l |
the size in bits of the random exponent (private value)
|
Public Methods
public
BigInteger
getG
()
Returns the base generator g
.
public
int
getL
()
Returns the size in bits, l
, of the random exponent
(private value).
Returns
- the size in bits,
l
, of the random exponent
(private value), or 0 if this size has not been set
public
BigInteger
getP
()
Returns the prime modulus p
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eDHParameterSpec\u003c/code\u003e defines parameters (prime modulus \u003ccode\u003ep\u003c/code\u003e, base generator \u003ccode\u003eg\u003c/code\u003e, and optional private value size \u003ccode\u003el\u003c/code\u003e) for the Diffie-Hellman key agreement algorithm.\u003c/p\u003e\n"],["\u003cp\u003eThese parameters are generated by a central authority and shared between entities for secure key exchange.\u003c/p\u003e\n"],["\u003cp\u003eInstances of \u003ccode\u003eDHParameterSpec\u003c/code\u003e do not inherently validate the provided parameters.\u003c/p\u003e\n"],["\u003cp\u003eIt includes constructors to create parameter sets and methods to retrieve individual parameter values (\u003ccode\u003ep\u003c/code\u003e, \u003ccode\u003eg\u003c/code\u003e, \u003ccode\u003el\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThe class is crucial for establishing secure communication channels using Diffie-Hellman key agreement.\u003c/p\u003e\n"]]],["The `DHParameterSpec` class defines parameters for the Diffie-Hellman algorithm, including a prime modulus `p`, a base generator `g`, and optionally the private value's bit length `l`. These parameters are used by two entities to generate a shared secret key. The class provides constructors to set `p`, `g` or `p`, `g`, and `l`, and getter methods `getG()`, `getL()`, and `getP()` to retrieve these values. No parameter validation is performed by this class.\n"],null,["# DHParameterSpec\n\npublic class **DHParameterSpec** extends [Object](../../../../reference/java/lang/Object.html) \nimplements [AlgorithmParameterSpec](../../../../reference/java/security/spec/AlgorithmParameterSpec.html) \nThis class specifies the set of parameters used with the Diffie-Hellman\nalgorithm, as specified in PKCS #3: *Diffie-Hellman Key-Agreement\nStandard*.\n\nA central authority generates parameters and gives them to the two\nentities seeking to generate a secret key. The parameters are a prime\n`p`, a base `g`, and optionally the length\nin bits of the private value, `l`.\n\nIt is possible that more than one instance of parameters may be\ngenerated by a given central authority, and that there may be more than\none central authority. Indeed, each individual may be its own central\nauthority, with different entities having different parameters.\n\nNote that this class does not perform any validation on specified\nparameters. Thus, the specified values are returned directly even\nif they are null. \n\n##### See Also\n\n- [KeyAgreement](../../../../reference/javax/crypto/KeyAgreement.html) \n\n### Public Constructor Summary\n\n|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [DHParameterSpec](../../../../reference/javax/crypto/spec/DHParameterSpec.html#DHParameterSpec(java.math.BigInteger,%20java.math.BigInteger))(BigInteger p, BigInteger g) Constructs a parameter set for Diffie-Hellman, using a prime modulus `p` and a base generator `g`. |\n| | [DHParameterSpec](../../../../reference/javax/crypto/spec/DHParameterSpec.html#DHParameterSpec(java.math.BigInteger,%20java.math.BigInteger,%20int))(BigInteger p, BigInteger g, int l) Constructs a parameter set for Diffie-Hellman, using a prime modulus `p`, a base generator `g`, and the size in bits, `l`, of the random exponent (private value). |\n\n### Public Method Summary\n\n|------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| BigInteger | [getG](../../../../reference/javax/crypto/spec/DHParameterSpec.html#getG())() Returns the base generator `g`. |\n| int | [getL](../../../../reference/javax/crypto/spec/DHParameterSpec.html#getL())() Returns the size in bits, `l`, of the random exponent (private value). |\n| BigInteger | [getP](../../../../reference/javax/crypto/spec/DHParameterSpec.html#getP())() Returns the prime modulus `p`. |\n\n### Inherited Method Summary\n\nFrom class [java.lang.Object](../../../../reference/java/lang/Object.html) \n\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../reference/java/lang/Object.html) | [clone](../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| final void | [notifyAll](../../../../reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| [String](../../../../reference/java/lang/String.html) | [toString](../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nPublic Constructors\n-------------------\n\n#### public\n**DHParameterSpec**\n(BigInteger p, BigInteger g)\n\nConstructs a parameter set for Diffie-Hellman, using a prime modulus\n`p` and a base generator `g`. \n\n##### Parameters\n\n| p | the prime modulus |\n| g | the base generator |\n|---|--------------------|\n\n#### public\n**DHParameterSpec**\n(BigInteger p, BigInteger g, int l)\n\nConstructs a parameter set for Diffie-Hellman, using a prime modulus\n`p`, a base generator `g`,\nand the size in bits, `l`, of the random exponent\n(private value). \n\n##### Parameters\n\n| p | the prime modulus |\n| g | the base generator |\n| l | the size in bits of the random exponent (private value) |\n|---|---------------------------------------------------------|\n\nPublic Methods\n--------------\n\n#### public BigInteger\n**getG**\n()\n\nReturns the base generator `g`. \n\n##### Returns\n\n- the base generator `g` \n\n#### public int\n**getL**\n()\n\nReturns the size in bits, `l`, of the random exponent\n(private value). \n\n##### Returns\n\n- the size in bits, `l`, of the random exponent (private value), or 0 if this size has not been set \n\n#### public BigInteger\n**getP**\n()\n\nReturns the prime modulus `p`. \n\n##### Returns\n\n- the prime modulus `p`"]]