public class ESDHParameters extends DHParameters
The Diffie Hellman algorithm has been the first public-key algorithm. It only can be used for key-agreement, but not for data encrypting and decrypting.
PKCS#3 describes
a method for implementing the Diffie Hellman key agreement where two (or more)
entities use general Diffie Hellman parameters (an odd prime p, an
integer base g satisfying 0 < g < p,
and optionally an integer l prescribing the length of the private
value), generated from some central authority (which may an entity itself), for
creating a shared secret only known by them.
DHParamters may be generated provider independently by calling one of the
AlgorithmParameters.getInstance methods and subsequently
initialzing the new AlgorithmParamters object with proper DH parameter
specification or DER encoded byte array. If the first way is chosen, the
parameter values (prime modulus p, base generator g
and - if given - length l of the private value x) for initializing
the new AlgorithmParameters object are immediately taken from the given DH
parameter specification; if the parameters are given as DER encoded byte array,
an ASN.1 object is created from this byte array for subsequently parsing it to
get the Diffie Hellman parameters.
Alternatively DHParamerters may be created by using a proper
AlgorithmParamterGenerator. The DHParameterGenerator itself calls
AlgorithmParameters.getInstance("DH", "IAIK") for actually
generating DHEParameters in opaque representation.
For obtaining DH parameters in transparent representation from an opaque
DHParamters object, the getParameterSpec method can be used;
for obtaining the parameters as DER encoded ASN.1 object, use
getEncoded.
DHParameterGenerator,
AlgorithmParameters,
DHParameterSpec,
DHPublicKey,
DHPrivateKey,
DHKeyPairGenerator,
DHKeyFactory,
DHKeyAgreement| Constructor and Description |
|---|
ESDHParameters()
The default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
engineGetEncoded()
Returns the parameters as DER byte array.
|
protected byte[] |
engineGetEncoded(java.lang.String format)
Returns the parameters as DER byte array.
|
protected java.security.spec.AlgorithmParameterSpec |
engineGetParameterSpec(java.lang.Class paramSpec)
Returns the ESDH parameters as transparent ESDH parameter specification
of the given class type.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this ESDHParameters with prime modulus
p, base generator g,
prime factor q, the subgroup factor j (if available) and the seed
seed and pgenCounter pgenCounter (if available). |
protected void |
engineInit(byte[] params)
Initializes this ESDHParameters object from the given DER encoded byte array.
|
protected void |
engineInit(byte[] params,
java.lang.String format)
Inits the parameters from a DER encoded byte array.
|
protected java.lang.String |
engineToString()
Returns a String representation of the parameters.
|
int |
hashCode()
Returns a hash code for this object.
|
public ESDHParameters()
ESDHParameters object.
Applications shall use one of the AlgorithmParameter.getInstance
factory methods for obtaining DHParameters.protected byte[] engineGetEncoded()
throws java.io.IOException
A SEQUENCE ASN.1 object is created for holding prime modulus p,
base generator g, prime factor q, the subgroup factor
j (if available) and the seed seed and pgenCounter
pgenCounter (if available).
subsequently this SEQUENCE object is DER encoded to get the required byte array.
engineGetEncoded in class DHParametersjava.io.IOException - if an encoding error occursprotected byte[] engineGetEncoded(java.lang.String format)
throws java.io.IOException
Format is ignored. Only DER encoding is supported at this time.
Only calls engineGetEncoded()
for returning the DH paramters as DER encoded byte array, regardless of what
is specified in the format string.
engineGetEncoded in class DHParametersformat - the encoding format; ignoredjava.io.IOException - if an encoding error occursprotected java.security.spec.AlgorithmParameterSpec engineGetParameterSpec(java.lang.Class paramSpec)
throws java.security.spec.InvalidParameterSpecException
engineGetParameterSpec in class DHParametersparamSpec - the desired parameter specification classjava.security.spec.InvalidParameterSpecException - if the paramters cannot be
converted to the desired parameter specificationprotected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
throws java.security.spec.InvalidParameterSpecException
p, base generator g,
prime factor q, the subgroup factor j (if available) and the seed
seed and pgenCounter pgenCounter (if available).engineInit in class DHParametersparamSpec - the parameter specification, which has to be a ESDHParameterSpecjava.security.spec.InvalidParameterSpecException - if the given parameter specification is not a ESDHParameterSpecprotected void engineInit(byte[] params)
throws java.io.IOException
From the given byte array an ASN.1 object is created to be parsed for the
required prime modulus p, base generator g, prime
factor q, the subgroup factor j (if available) and
the seed seed and pgenCounter pgenCounter (if available).
engineInit in class DHParametersparams - the DER encoded byte arrayjava.io.IOException - if an error occurs when decoding the given byte arrayprotected void engineInit(byte[] params,
java.lang.String format)
throws java.io.IOException
Only calls engineInit(params) for initializing this
ESDHParamters object from the given DER encoded byte array, regardless
of what is specified in the format string.
engineInit in class DHParametersparams - the DER encoded byte arrayformat - the encoding format; ignoredjava.io.IOException - if an error occurs when decoding the given byte arraypublic int hashCode()
hashCode in class DHParametersprotected java.lang.String engineToString()
engineToString in class DHParameters