de.flexiprovider.ec
Class ECDSASignature

java.lang.Object
  |
  +--java.security.SignatureSpi
        |
        +--de.flexiprovider.api.Signature
              |
              +--de.flexiprovider.ec.ECDSASignature
Direct Known Subclasses:
ECDSASignature.Raw, ECDSASignature.SHA1, ECDSASignature.SHA224, ECDSASignature.SHA256, ECDSASignature.SHA384, ECDSASignature.SHA512

public abstract class ECDSASignature
extends Signature

This Signature class is used to provide applications the functionality of the digital signature algorithm ECDSA. Digital signatures are used for authentication and integrity assurance of digital data.

A Signature object can be used to generate and verify digital signatures. This specific signature ECDSA is based on the discrete logarithm problem in a group of points of an elliptic curve over a primefield GF(q), where q is the prime and GF is a common synonym for a galois field. For a description of the signing and verifying procedure see the documentation of this package.

Author:
Birgit Henhapl, Michele Boivin, Martin Döring
See Also:
ECPublicKey, ECPrivateKey, CurveParams

Inner Class Summary
static class ECDSASignature.Raw
          ECDSA without message digest
static class ECDSASignature.SHA1
          ECDSA with SHA1
static class ECDSASignature.SHA224
          ECDSA with SHA224
static class ECDSASignature.SHA256
          ECDSA with SHA256
static class ECDSASignature.SHA384
          ECDSA with SHA384
static class ECDSASignature.SHA512
          ECDSA with SHA512
 
Fields inherited from class java.security.SignatureSpi
appRandom
 
Constructor Summary
protected ECDSASignature(MessageDigest md)
          Constructor.
 
Method Summary
 void initSign(PrivateKey privateKey, SecureRandom random)
          Initializes this signature object with the specified private key and source of randomness for signing operations.
 void initVerify(PublicKey publicKey)
          Initializes this object for verification.
 void setParameters(AlgorithmParameterSpec params)
          Initialize this signature engine with the specified parameter set.
 byte[] sign()
          Return the signature of all the data updated so far.
 void update(byte input)
          Updates the data to be signed or verified using the specified byte.
 void update(byte[] input, int offset, int length)
          Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
 boolean verify(byte[] sigBytes)
          Verify the passed-in signature.
 
Methods inherited from class de.flexiprovider.api.Signature
engineGetParameter, engineInitSign, engineInitSign, engineInitVerify, engineSetParameter, engineSetParameter, engineSign, engineUpdate, engineUpdate, engineVerify, engineVerify, initSign, sign, update, verify, verify, verify
 
Methods inherited from class java.security.SignatureSpi
clone, engineSign
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ECDSASignature

protected ECDSASignature(MessageDigest md)
Constructor. Set the message digest.
Parameters:
md - the message digest
Method Detail

initSign

public void initSign(PrivateKey privateKey,
                     SecureRandom random)
              throws InvalidKeyException
Initializes this signature object with the specified private key and source of randomness for signing operations.
Overrides:
initSign in class Signature
Parameters:
privateKey - the private key of the identity whose signature is going to be signed.
random - the source of randomness
Throws:
InvalidKeyException - If privateKey is an invalid key (invalid encoding, wrong length, uninitialized, etc).

initVerify

public void initVerify(PublicKey publicKey)
                throws InvalidKeyException
Initializes this object for verification. If this method is called again with a different argument, it negates the effect of this call.
Overrides:
initVerify in class Signature
Parameters:
publicKey - the public key of the identity whose signature is going to be verified.
Throws:
InvalidKeyException - If publicKey is an invalid key (invalid encoding, wrong length, uninitialized, etc).

setParameters

public void setParameters(AlgorithmParameterSpec params)
                   throws InvalidParameterException
Initialize this signature engine with the specified parameter set.
Overrides:
setParameters in class Signature
Parameters:
params - the parameters
Throws:
InvalidParameterException - if the given parameters are inappropriate for this signature engine

update

public void update(byte input)
Updates the data to be signed or verified using the specified byte.
Overrides:
update in class Signature
Parameters:
input - the byte to be updated.

update

public void update(byte[] input,
                   int offset,
                   int length)
Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
Overrides:
update in class Signature
Parameters:
input - the array of bytes.
offset - the offset to start from in the array of bytes.
length - the number of bytes to use, starting at offset.

sign

public byte[] sign()
Return the signature of all the data updated so far.
Overrides:
sign in class Signature
Returns:
the signature

verify

public boolean verify(byte[] sigBytes)
               throws SignatureException
Verify the passed-in signature.
Overrides:
verify in class Signature
Parameters:
sigBytes - the signature to be verified
Returns:
true if the signature is valid, false otherwise
Throws:
SignatureException - if this signature object is not initialized properly.