iaik.security.dh
Class ESDHPrivateKey

java.lang.Object
  |
  +--iaik.pkcs.pkcs8.PrivateKeyInfo
        |
        +--iaik.security.dh.ESDHPrivateKey
All Implemented Interfaces:
ASN1Type, Cloneable, DHKey, DHPrivateKey, Key, PrivateKey, Serializable

public class ESDHPrivateKey
extends PrivateKeyInfo
implements DHPrivateKey, Serializable

This class implements an Ephemeral Static Diffie Hellman private key.

This class extends iaik.pkcs.pkcs8.PrivateKeyInfo for supporting the PKCS#8 Private Key Information Standard for ESDH private keys.

Hellman private key maybe generated using a proper key pair generator, e.g.:

 KeyPairGnerator esdh_key_gen = KeyPairGenerator.getInstance("ESDH");
 esdh_key_gen.initialize(1024);
 KeyPair esdh_key_pair = esdh_key_gen.generateKeyPair();
 ESDHPrivateKey esdh_priv_key = (ESDHPrivateKey)esdh_key_pair.getPrivate();
 KeyAgreement esdh_key_agreement = KeyAgreement.getInstance("ESDH");
 esdh_key_agreement.init(esdh_priv_key);
 

Version:
File Revision 15
See Also:
KeyPairGenerator, KeyPair, KeyAgreement, ESDHParameterSpec, ESDHPrivateKeySpec, ESDHPublicKeySpec, ESDHPublicKey, ESDHKeyPairGenerator, ESDHKeyFactory, ESDHParameters, ESDHParameterGenerator, ESDHKeyAgreement, PrivateKeyInfo, Serialized Form

Fields inherited from class iaik.pkcs.pkcs8.PrivateKeyInfo
private_key_algorithm
 
Fields inherited from interface java.security.PrivateKey
serialVersionUID
 
Constructor Summary
ESDHPrivateKey(ASN1Object obj)
          Creates a new ESDHPrivateKey from the given ASN.1 object.
ESDHPrivateKey(BigInteger x, ESDHParameterSpec parameters)
          Creates a new ESDHPrivateKey from given private key value x and ESDH parameter specification
ESDHPrivateKey(byte[] pk)
          Creates a new ESDHPrivateKey from the given DER encoded byte array.
ESDHPrivateKey(ESDHPrivateKeySpec keySpec)
          Creates a new ESDHPrivateKey from the given ESDHPrivateKeySpec representing the ESDH private key value x, and the values p, g, q, j (if available) and seed and pgenCounter (if available).
ESDHPrivateKey(InputStream is)
          Creates a new ESDHPrivateKey from an InputStream.
 
Method Summary
protected  void decode(byte[] privateKey)
          Decodes a DER encoded ESDH private key.
 byte[] encode()
          Returns this ESDH private key as DER encoded ASN.1 object.
 String getAlgorithm()
          Returns the name of the appertaining algorithm.
 DHParameterSpec getParams()
          Returns the key parameters.
 BigInteger getX()
          Returns the private value x as BigInteger.
 int hashCode()
          Returns a hash code for this object.
 String toString()
          Returns a string that represents the contents of this private key.
 
Methods inherited from class iaik.pkcs.pkcs8.PrivateKeyInfo
clone, createPrivateKeyInfo, decode, equals, getEncoded, getFormat, getPrivateKey, getPrivateKey, toASN1Object, writeTo
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Key
getEncoded, getFormat
 

Constructor Detail

ESDHPrivateKey

public ESDHPrivateKey(BigInteger x,
                      ESDHParameterSpec parameters)
Creates a new ESDHPrivateKey from given private key value x and ESDH parameter specification

Parameters:
x - the BigInteger value representing the ESDH private key value
parameters - the ESDH parameters p (prime modulus), g (base generator), prime factor q, the subgroup factor j (if available) and the seed seed and pgenCounter pgenCounter (if available) as ESDHParameterSpec

ESDHPrivateKey

public ESDHPrivateKey(ESDHPrivateKeySpec keySpec)
Creates a new ESDHPrivateKey from the given ESDHPrivateKeySpec representing the ESDH private key value x, and the values p, g, q, j (if available) and seed and pgenCounter (if available).

Parameters:
keySpec - the ESDHPrivateKeySpec representing the private key value x, the prime modulus p, the base generator g, the subgroup factor j (if available) and the seed seed and pgenCounter pgenCounter (if available)

ESDHPrivateKey

public ESDHPrivateKey(byte[] pk)
               throws InvalidKeyException
Creates a new ESDHPrivateKey from the given DER encoded byte array.

This constructor may be used for parsing an already exisiting ESDH private key, wrapped into a PKCS#8 PrivateKeyInfo that is supplied as DER encoded byte array.

Parameters:
the - byte array holding the DER encoded private key info
Throws:
InvalidKeyException - if something is wrong with the key encoding

ESDHPrivateKey

public ESDHPrivateKey(ASN1Object obj)
               throws InvalidKeyException
Creates a new ESDHPrivateKey from the given ASN.1 object. The supplied ASN1Object represents a PKCS#8 PrivateKeyInfo holding the ESDH private key.
Parameters:
obj - the private key ASN.1 data structure
Throws:
InvalidKeyException - if something is wrong with the key encoding

ESDHPrivateKey

public ESDHPrivateKey(InputStream is)
               throws IOException,
                      InvalidKeyException
Creates a new ESDHPrivateKey from an InputStream.

This constructor may be used for parsing an already exisiting ESDH private key, wrapped into a PKCS#8 PrivateKeyInfo that is supplied as DER encoded byte array.

Parameters:
is - the input stream with the data to be read to initialize the private key
Throws:
IOException - if an I/O error occurs
InvalidKeyException - if something is wrong with the key encoding
Method Detail

decode

protected void decode(byte[] privateKey)
               throws InvalidKeyException
Decodes a DER encoded ESDH private key.

From the given DER encoded byte array an ASN.1 object is created and parsed for the private key value x and the ESDH parameters prime p and base g, prime factor q, the subgroup factor j (if available) and the seed seed and pgenCounter pgenCounter (if available).

This method is protected and typically will not be used by an application. Rather it is used by the parent PKCS#8 PrivateKeyInfo class for decoding the inherent DH private key.

Overrides:
decode in class PrivateKeyInfo
Parameters:
privateKey - the DH private key as DER encoded ASN.1 object
Throws:
InvalidKeyException - if the given key is not a DH private key

encode

public byte[] encode()
Returns this ESDH private key as DER encoded ASN.1 object.

This method is protected and typically will not be used by an application. Rather it is used by the parent PKCS#8 PrivateKeyInfo class for encoding the inherent ESDH private key.

Overrides:
encode in class PrivateKeyInfo
Returns:
a byte array holding the ESDH private key as a DER encoded ASN.1 data structure

getX

public BigInteger getX()
Returns the private value x as BigInteger.

Specified by:
getX in interface DHPrivateKey
Returns:
the private value x as BigInteger

getParams

public DHParameterSpec getParams()
Returns the key parameters.
Specified by:
getParams in interface DHKey
Returns:
the key parameters as ESDHParameterSpec

getAlgorithm

public String getAlgorithm()
Returns the name of the appertaining algorithm.
Specified by:
getAlgorithm in interface Key
Overrides:
getAlgorithm in class PrivateKeyInfo
Returns:
the string "ESDH"

hashCode

public int hashCode()
Returns a hash code for this object.
Overrides:
hashCode in class PrivateKeyInfo
Returns:
the hash code

toString

public String toString()
Returns a string that represents the contents of this private key.

Overrides:
toString in class PrivateKeyInfo
Returns:
the string representation

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK