edu.vt.middleware.crypt.signature
Class AbstractDSASignature

java.lang.Object
  extended by edu.vt.middleware.crypt.AbstractAlgorithm
      extended by edu.vt.middleware.crypt.signature.SignatureAlgorithm
          extended by edu.vt.middleware.crypt.signature.AbstractDSASignature
All Implemented Interfaces:
Algorithm
Direct Known Subclasses:
DSASignature, ECDSASignature

public abstract class AbstractDSASignature
extends SignatureAlgorithm

Base class for all signatures that implement the DSA scheme.

Version:
$Revision: 2744 $
Author:
Middleware Services

Field Summary
protected  org.bouncycastle.crypto.DSA signer
          Signer that implements DSA algorithm.
 
Fields inherited from class edu.vt.middleware.crypt.signature.SignatureAlgorithm
digest, signKey, verifyKey
 
Fields inherited from class edu.vt.middleware.crypt.AbstractAlgorithm
algorithm, logger, randomByteSize, randomProvider
 
Constructor Summary
protected AbstractDSASignature(String alg)
          Creates a new instance of a the given signature algorithm.
 
Method Summary
protected  void init(boolean forSigning, org.bouncycastle.crypto.CipherParameters params)
          Initialize the signer.
 byte[] sign(byte[] data)
          Signs the given data and returns the signature as a byte array.
 byte[] sign(InputStream in)
          Computes the signature of the data in the given input stream by processing in chunks.
 boolean verify(byte[] data, byte[] signature)
          Verifies the signature of the given data matches the given signature.
 boolean verify(InputStream in, byte[] signature)
          Verifies the signature of the given data matches the given signature.
 
Methods inherited from class edu.vt.middleware.crypt.signature.SignatureAlgorithm
clone, initSign, initVerify, newInstance, newInstance, setSignKey, setVerifyKey, sign, sign, verify, verify
 
Methods inherited from class edu.vt.middleware.crypt.AbstractAlgorithm
getAlgorithm, getRandomData, setRandomProvider, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

signer

protected org.bouncycastle.crypto.DSA signer
Signer that implements DSA algorithm.

Constructor Detail

AbstractDSASignature

protected AbstractDSASignature(String alg)
Creates a new instance of a the given signature algorithm.

Parameters:
alg - Signature algorithm name, e.g. DSA, RSA.
Method Detail

sign

public byte[] sign(byte[] data)
            throws CryptException
Signs the given data and returns the signature as a byte array.

Overrides:
sign in class SignatureAlgorithm
Parameters:
data - Data to be signed.
Returns:
Signature of given data as byte array.
Throws:
CryptException - On signature failure.

sign

public byte[] sign(InputStream in)
            throws CryptException,
                   IOException
Computes the signature of the data in the given input stream by processing in chunks.

Overrides:
sign in class SignatureAlgorithm
Parameters:
in - Input stream containing data to be signed.
Returns:
Signature of given data as byte array.
Throws:
CryptException - On signature failure.
IOException - On input stream read errors.

verify

public boolean verify(byte[] data,
                      byte[] signature)
               throws CryptException
Verifies the signature of the given data matches the given signature.

Overrides:
verify in class SignatureAlgorithm
Parameters:
data - Data to be verified.
signature - Signature to be used for comparison.
Returns:
True if the signed data matches the given signature, false otherwise.
Throws:
CryptException - On verification failure.

verify

public boolean verify(InputStream in,
                      byte[] signature)
               throws CryptException,
                      IOException
Verifies the signature of the given data matches the given signature.

Overrides:
verify in class SignatureAlgorithm
Parameters:
in - Input stream containing data to be verified.
signature - Signature to be used for comparison.
Returns:
True if the signed data matches the given signature, false otherwise.
Throws:
CryptException - On verification failure.
IOException - On input stream read errors.

init

protected void init(boolean forSigning,
                    org.bouncycastle.crypto.CipherParameters params)
Initialize the signer.

Parameters:
forSigning - Whether to initialize signer for the sign operation.
params - BC cipher parameters.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.