de.flexiprovider.core.dsa
Class DSASignature

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

public abstract class DSASignature
extends DSASignature


Inner Class Summary
static class DSASignature.Raw
          Inner class providing DSA without message digest
static class DSASignature.SHA1
          DSA with SHA1.
static class DSASignature.SHA224
          DSA with SHA224.
static class DSASignature.SHA256
          DSA with SHA256.
static class DSASignature.SHA384
          DSA with SHA384.
static class DSASignature.SHA512
          DSA with SHA512.
 
Fields inherited from class java.security.SignatureSpi
appRandom
 
Constructor Summary
protected DSASignature(MessageDigest md)
          Constructor.
 
Method Summary
 void initSign(PrivateKey privKey, SecureRandom random)
          Initialize the signature algorithm for signing a message.
 void initVerify(PublicKey pubKey)
          Initialize the signature algorithm for verifying a signature.
 void setParameters(AlgorithmParameterSpec params)
          Initialize this signature engine with the specified parameter set.
 byte[] sign()
          Signs a message.
 void update(byte b)
          Pass a message byte to the message digest.
 void update(byte[] b, int offset, int length)
          Pass message bytes to the message digest.
 boolean verify(byte[] sigBytes)
          Verifies a signature.
 
Methods inherited from class de.flexiprovider.core.dsa.interfaces.DSASignature
engineSetParameter
 
Methods inherited from class de.flexiprovider.api.Signature
engineGetParameter, engineInitSign, engineInitSign, engineInitVerify, 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

DSASignature

protected DSASignature(MessageDigest md)
Constructor.
Parameters:
md - the message digest to use
Method Detail

initSign

public void initSign(PrivateKey privKey,
                     SecureRandom random)
              throws InvalidKeyException
Initialize the signature algorithm for signing a message.
Overrides:
initSign in class Signature
Parameters:
privKey - the private key of the signer
random - the source of randomness
Throws:
InvalidKeyException - if the key is not an instance of DSAPrivKey.

initVerify

public void initVerify(PublicKey pubKey)
                throws InvalidKeyException
Initialize the signature algorithm for verifying a signature.
Overrides:
initVerify in class Signature
Parameters:
pubKey - the public key of the signer.
Throws:
InvalidKeyException - if the public key is not an instance of DSAPubKey.

setParameters

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

update

public void update(byte b)
Pass a message byte to the message digest.
Overrides:
update in class Signature
Parameters:
b - the message byte

update

public void update(byte[] b,
                   int offset,
                   int length)
Pass message bytes to the message digest.
Overrides:
update in class Signature
Parameters:
b - the message byte
offset - the index where the message bytes starts
length - the number of message bytes

sign

public byte[] sign()
            throws SignatureException
Signs a message. The result is an ASN1 Sequence containing the Integers r and s. With r = (gk mod p) mod q and s = (k-1 (SHA(M) + x*r)) mod q.
Overrides:
sign in class Signature
Returns:
the signature (an ASN1 Sequence containing the Integers r and s).
Throws:
SignatureException - if the signature is not initialized properly.

verify

public boolean verify(byte[] sigBytes)
Verifies a signature.
Overrides:
verify in class Signature
Parameters:
sigBytes - the signature to be verified
Returns:
true if the signature is correct, false otherwise