iaik.security.dh
Class ESDHPublicKey

java.lang.Object
  |
  +--iaik.x509.PublicKeyInfo
        |
        +--iaik.security.dh.ESDHPublicKey
All Implemented Interfaces:
ASN1Type, Cloneable, DHKey, DHPublicKey, Key, PublicKey, Serializable

public class ESDHPublicKey
extends PublicKeyInfo
implements DHPublicKey, Serializable

This class implements an Ephemeral Static Diffie Hellman public key.

This class extends iaik.x509.PublicKeyInfo for supporting ESDH public keys to be used within X.509 certificates . An ESDH Hellman public 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();
 ESDHPublicKey dh_priv_key = (ESDHPublicKey)esdh_key_pair.getPublic();
 

Version:
File Revision 17
See Also:
KeyPairGenerator, KeyPair, KeyAgreement, ESDHPublicKeySpec, ESDHPrivateKey, ESDHKeyPairGenerator, ESDHKeyFactory, ESDHParameters, ESDHParameterGenerator, ESDHKeyAgreement, PublicKeyInfo, Serialized Form

Fields inherited from class iaik.x509.PublicKeyInfo
public_key_algorithm
 
Fields inherited from interface java.security.PublicKey
serialVersionUID
 
Constructor Summary
ESDHPublicKey(ASN1Object obj)
          Creates a new ESDHPublicKey from the given ASN.1 object.
ESDHPublicKey(BigInteger y, ESDHParameterSpec parameters)
          Creates a new ESDHPublicKey from public key value and ESDH parameter specification
ESDHPublicKey(byte[] pk)
          Creates a new ESDHPublicKey from the given DER encoded byte array.
ESDHPublicKey(ESDHPublicKeySpec keySpec)
          Creates a new ESDHPublicKey from the given ESDHPublicKeySpec representing the ESDH public key value y, and the values p, g, q, j (if available) and seed and pgenCounter (if available).
ESDHPublicKey(InputStream is)
          Creates a new ESDHPublicKey from an InputStream.
 
Method Summary
protected  void decode(byte[] publicKey)
          Decodes an ESDHPublicKey, encoded in DER format.
protected  byte[] encode()
          Returns this ESDH public key as DER encoded ASN.1 object.
 String getAlgorithm()
          Returns the name of the appertaining algorithm.
 byte[] getFingerprint()
          Returns the fingerprint of this ESDH public key.
 DHParameterSpec getParams()
          Returns the key parameters.
 BigInteger getY()
          Returns the public value y as BigInteger.
 int hashCode()
          Returns a hash code for this object.
 String toString()
          Returns a string that represents the contents of this public key.
static void validatePublicKey(ESDHPublicKey esdhPublicKey)
          Validates an ESDH public key.
 
Methods inherited from class iaik.x509.PublicKeyInfo
clone, createPublicKeyInfo, decode, equals, getEncoded, getFormat, getPublicKey, getPublicKey, 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

ESDHPublicKey

public ESDHPublicKey(BigInteger y,
                     ESDHParameterSpec parameters)
Creates a new ESDHPublicKey from public key value and ESDH parameter specification

Parameters:
y - the BigInteger value representing the ESDH public key value y
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

ESDHPublicKey

public ESDHPublicKey(ESDHPublicKeySpec keySpec)
Creates a new ESDHPublicKey from the given ESDHPublicKeySpec representing the ESDH public key value y, and the values p, g, q, j (if available) and seed and pgenCounter (if available).

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

ESDHPublicKey

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

This constructor may be used for parsing an already exisiting ESDH public key, wrapped into a X.509 PublicKeyInfo that is supplied as DER encoded byte array.

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

ESDHPublicKey

public ESDHPublicKey(ASN1Object obj)
              throws InvalidKeyException
Creates a new ESDHPublicKey from the given ASN.1 object. The supplied ASN1Object represents a X.509 PublicKeyInfo holding the ESDH public key.

Parameters:
obj - the public key ASN.1 data structure
Throws:
InvalidKeyException - if something is wrong with the key encoding

ESDHPublicKey

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

This constructor may be used for parsing an already exisiting ESDH public key, wrapped into a X.509 PublicKeyInfo that is supplied as DER encoded byte array.

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

validatePublicKey

public static void validatePublicKey(ESDHPublicKey esdhPublicKey)
                              throws InvalidKeyException
Validates an ESDH public key. Note that this procedure may be subject to pending patents (see RFC 2631). For that reason and for performance reasons public keys are not validated automatically. An application itself may decide to do so.
Parameters:
esdhPublicKey - the public key to be validated
Throws:
InvalidKeyException - if validation fails

decode

protected void decode(byte[] publicKey)
               throws InvalidKeyException
Decodes an ESDHPublicKey, encoded in DER format.

From the given DER encoded byte array an ASN.1 object is created and parsed for the public key value y 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 X.509 PublicKeyInfo class for decoding the inherent ESDH public key.

Overrides:
decode in class PublicKeyInfo
Parameters:
publicKey - the public key as DER encoded ASN.1 object
Throws:
InvalidKeyException - if the given key is not a ESDH public key

encode

protected byte[] encode()
Returns this ESDH public 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 X.509 PublicKeyInfo class for encoding the inherent ESDH public key.

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

getAlgorithm

public String getAlgorithm()
Returns the name of the appertaining algorithm.

Specified by:
getAlgorithm in interface Key
Overrides:
getAlgorithm in class PublicKeyInfo
Returns:
the string "ESDH"

getY

public BigInteger getY()
Returns the public value y as BigInteger.

Specified by:
getY in interface DHPublicKey
Returns:
the public value y as BigInteger

getParams

public DHParameterSpec getParams()
Returns the key parameters.

Specified by:
getParams in interface DHKey
Returns:
the key parameters as ESDHParameterSpec

getFingerprint

public byte[] getFingerprint()
Returns the fingerprint of this ESDH public key. This is a MD5 hash of the DER encoded SubjectPublicKey.

Overrides:
getFingerprint in class PublicKeyInfo
Returns:
the fingerprint of this ESDH public key

hashCode

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

toString

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

Overrides:
toString in class PublicKeyInfo
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