de.flexiprovider.ec.keys
Class ECPublicKeySpec

java.lang.Object
  |
  +--de.flexiprovider.ec.keys.ECPublicKeySpec
All Implemented Interfaces:
KeySpec, java.security.spec.KeySpec

public final class ECPublicKeySpec
extends java.lang.Object
implements KeySpec

This class specifies a EC public key with its associated parameters.

Author:
Birgit Henhapl, Michele Boivin
See Also:
KeySpec, KeyFactory, X509EncodedKeySpec, ECPrivateKeySpec, Point, CurveParams

Constructor Summary
ECPublicKeySpec(byte[] encodedW, CurveParams params)
          Generate an EC key specification based on an encoded point and optionally the parameters of the curve.
ECPublicKeySpec(ECPublicKeySpec other)
          Copy constructor.
ECPublicKeySpec(Point W, CurveParams params)
          Constructs a new public key specification.
 
Method Summary
 byte[] getEncodedW()
           
 CurveParams getParams()
           
 Point getW()
          Returns the public key W.
 void setParams(CurveParams params)
          Set the EC domain parameters for this public key.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ECPublicKeySpec

public ECPublicKeySpec(Point W,
                       CurveParams params)
                throws InvalidParameterException
Constructs a new public key specification. The parameters are the public key W and an EC domain parameters specification params (see ECParameterSpec).
Parameters:
W - public key represented by a Point
params - ECParameterSpec, characteristic of underlying field
Throws:
InvalidParameterException - if params == null or params does not match parameters specified by W.

ECPublicKeySpec

public ECPublicKeySpec(byte[] encodedW,
                       CurveParams params)
                throws InvalidParameterSpecException
Generate an EC key specification based on an encoded point and optionally the parameters of the curve. If curve parameters are presented, the point is decoded (which may lead to the Exceptions named below). Otherwise, the point is internally represented as byte array. Uncompressed encoding must be chosen for the point.
Parameters:
encodedW - the point in its uncompressed encoding
params - EC domain parameters
Throws:
InvalidParameterSpecException - if the point cannot be decoded with the given parameters.

ECPublicKeySpec

public ECPublicKeySpec(ECPublicKeySpec other)
Copy constructor.
Parameters:
other - another ECPublicKeySpec
Method Detail

getW

public Point getW()
           throws InvalidKeySpecException
Returns the public key W. W = sG, s is private key, G generator of the subgroup.
Returns:
the public key W
Throws:
InvalidKeySpecException - if no EC domain parameters have been defined for this public key yet.
See Also:
Point

getEncodedW

public byte[] getEncodedW()
Returns:
the public key in its uncompressed encoding

getParams

public CurveParams getParams()
Returns:
the EC domain parameters

setParams

public void setParams(CurveParams params)
               throws InvalidParameterSpecException
Set the EC domain parameters for this public key.
Parameters:
params - the domain parameters
Throws:
InvalidParameterSpecException - if the domain parameters are already set and params is not equal to the set parameters or if the encoded point cannot be decoded with the given parameters.