IAIK ECC
version 2.18

iaik.security.ecc.ecdsa
Class ECPrivateKey

java.lang.Object
  extended byiaik.pkcs.pkcs8.PrivateKeyInfo
      extended byiaik.security.ecc.ecdsa.ECPrivateKey
All Implemented Interfaces:
iaik.asn1.ASN1Type, java.lang.Cloneable, ECDSAKey, ECDSAPrivateKey, java.security.Key, java.security.PrivateKey, java.io.Serializable

public class ECPrivateKey
extends iaik.pkcs.pkcs8.PrivateKeyInfo
implements ECDSAPrivateKey

Representation of a private key for the ECDSA algorithm and implementation of the PrivateKey Interface

See Also:
Serialized Form

Field Summary
protected static java.lang.String ALGORITHM
          the name of the algorithm
static iaik.asn1.INTEGER EC_PRIVATE_KEY_VERSION
          the version field in the ASN.1 encoding
static iaik.asn1.ObjectID OID
          object identifier for the ASN.1 structure
 
Fields inherited from class iaik.pkcs.pkcs8.PrivateKeyInfo
private_key_algorithm
 
Fields inherited from interface java.security.PrivateKey
serialVersionUID
 
Constructor Summary
ECPrivateKey(byte[] key)
          Creates a private key from an DER encoded PKCS8 key.
ECPrivateKey(ECDSAParameter p, java.math.BigInteger s, ECPoint w)
          Creates a new private key with the specified parameters.
ECPrivateKey(ECDSAPrivateKeySpec spec)
          Create a new private key from the key spec.
ECPrivateKey(java.io.InputStream is)
          Reads an DER encoded PKCS#8 private key from an input stream.
 
Method Summary
 void decode(byte[] privateKey)
          Decodes the DER encoded private key.
protected  byte[] encode()
           
 java.lang.String getAlgorithm()
          Implementation of the interface method.
 ECDSAParams getParameter()
           
 ECDSAPublicKey getPublicKey()
           
 java.math.BigInteger getS()
           
 java.lang.String toString()
          Overwrites this method to provide detailled Information.
 
Methods inherited from class iaik.pkcs.pkcs8.PrivateKeyInfo
clone, createPrivateKeyInfo, decode, equals, getEncoded, getFormat, getPrivateKey, getPrivateKey, hashCode, 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
 

Field Detail

EC_PRIVATE_KEY_VERSION

public static final iaik.asn1.INTEGER EC_PRIVATE_KEY_VERSION
the version field in the ASN.1 encoding


OID

public static final iaik.asn1.ObjectID OID
object identifier for the ASN.1 structure


ALGORITHM

protected static final java.lang.String ALGORITHM
the name of the algorithm

See Also:
getAlgorithm(), Constant Field Values
Constructor Detail

ECPrivateKey

public ECPrivateKey(byte[] key)
             throws java.security.InvalidKeyException
Creates a private key from an DER encoded PKCS8 key.

Parameters:
key - the DER byte array.
Throws:
java.security.InvalidKeyException - if the encoded key is invalid.

ECPrivateKey

public ECPrivateKey(ECDSAParameter p,
                    java.math.BigInteger s,
                    ECPoint w)
Creates a new private key with the specified parameters.

Parameters:
p - the domain parameters
s - the private key
w - the corresponding public key (may be null)

ECPrivateKey

public ECPrivateKey(ECDSAPrivateKeySpec spec)
Create a new private key from the key spec. The corresponding public key will be null !

Parameters:
spec - the key material

ECPrivateKey

public ECPrivateKey(java.io.InputStream is)
             throws java.security.InvalidKeyException,
                    java.io.IOException
Reads an DER encoded PKCS#8 private key from an input stream.

Parameters:
is - the input stream providing the data
Throws:
java.security.InvalidKeyException - if the provided key data is invalid.
java.io.IOException
Method Detail

decode

public void decode(byte[] privateKey)
            throws java.security.InvalidKeyException
Decodes the DER encoded private key.

Parameters:
privateKey - the DER byte array.
Throws:
java.security.InvalidKeyException - if the provided key data is invalid.

getAlgorithm

public java.lang.String getAlgorithm()
Implementation of the interface method.

Specified by:
getAlgorithm in interface java.security.Key
Returns:
"ECDSA"

getParameter

public ECDSAParams getParameter()
Specified by:
getParameter in interface ECDSAKey
Returns:
the elliptic curve domain parameters.

getPublicKey

public ECDSAPublicKey getPublicKey()
Returns:
the corresponding public key, if known (null otherwise)

getS

public java.math.BigInteger getS()
Specified by:
getS in interface ECDSAPrivateKey
Returns:
the private key s.

toString

public java.lang.String toString()
Overwrites this method to provide detailled Information.

Returns:
the private key, the domain parameters, and if available the corresponding public key.

encode

protected byte[] encode()
Returns:
the DER encoded private key

IAIK ECC
version 2.18

IAIK-ECC 2.18, (c) 2002 IAIK, (c) 2003 SIC