com.cryptware.jdigitsign
Class DigitalSignatureBase

java.lang.Object
  extended by com.cryptware.jdigitsign.DigitalSignatureBase

public class DigitalSignatureBase
extends java.lang.Object

Base class for digital signature

Author:
Ugo Chirico

Constructor Summary
DigitalSignatureBase(iaik.pkcs.pkcs11.wrapper.PKCS11 pkcs11)
          Initializes a new instance of the DigitalSignatureBase class
 
Method Summary
 byte[] sign(byte[] data, long slot, long session, long prikey, long certificate, boolean cades)
          Signs the given data.
 byte[] sign(byte[] data, long slot, long session, long prikey, long certificate, boolean cades, TSAClient tsaClient)
          Signs the given data and add a timestamp from the given TSA client
 boolean verify(byte[] cms)
          Verifies the specified signature.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigitalSignatureBase

public DigitalSignatureBase(iaik.pkcs.pkcs11.wrapper.PKCS11 pkcs11)
Initializes a new instance of the DigitalSignatureBase class

Parameters:
pkcs11 - the underlying PKCS11 implementation
Method Detail

sign

public byte[] sign(byte[] data,
                   long slot,
                   long session,
                   long prikey,
                   long certificate,
                   boolean cades)
            throws iaik.pkcs.pkcs11.wrapper.PKCS11Exception,
                   java.io.IOException,
                   TSPException
Signs the given data.

Parameters:
data - data to sign
slot - the PKCS11 slot
session - the PKCS11 session
prikey - the private
certificate - the certificate
cades - specifies if CAdES signature is needed
Returns:
the data signed in PKCS#7 or CAdES format DER encoded
Throws:
iaik.pkcs.pkcs11.wrapper.PKCS11Exception
java.io.IOException
TSPException

sign

public byte[] sign(byte[] data,
                   long slot,
                   long session,
                   long prikey,
                   long certificate,
                   boolean cades,
                   TSAClient tsaClient)
            throws iaik.pkcs.pkcs11.wrapper.PKCS11Exception,
                   java.io.IOException,
                   TSPException
Signs the given data and add a timestamp from the given TSA client

Parameters:
data - data to sign
slot - the PKCS11 slot
session - the PKCS11 session
prikey - the private
certificate - the certificate
cades - specifies if CAdES signature is needed
tsaClient - the TSA Client
Returns:
the data signed in PKCS#7 or CAdES format DER encoded
Throws:
iaik.pkcs.pkcs11.wrapper.PKCS11Exception
java.io.IOException
TSPException

verify

public boolean verify(byte[] cms)
               throws CMSException
Verifies the specified signature.

Parameters:
cms - the data to verify
Returns:
true if the verification succeeds false otherwise
Throws:
CMSException