For the latest news and information visit
The GNU Crypto project

gnu.crypto.sig
Class BaseSignature

java.lang.Object
  extended bygnu.crypto.sig.BaseSignature
All Implemented Interfaces:
java.lang.Cloneable, ISignature
Direct Known Subclasses:
DSSSignature, RSAPKCS1V1_5Signature, RSAPSSSignature

public abstract class BaseSignature
extends java.lang.Object
implements ISignature

A base abstract class to facilitate implementations of concrete Signatures.

Version:
$Revision: 1.2 $

Field Summary
protected  IMessageDigest md
          The underlying message digest instance for this signature scheme.
protected  java.security.PrivateKey privateKey
          The private key to use when generating signatures (signing).
protected  java.security.PublicKey publicKey
          The public key to use when verifying signatures.
protected  java.lang.String schemeName
          The canonical name of this signature scheme.
 
Fields inherited from interface gnu.crypto.sig.ISignature
SIGNER_KEY, SOURCE_OF_RANDOMNESS, VERIFIER_KEY
 
Constructor Summary
protected BaseSignature(java.lang.String schemeName, IMessageDigest md)
          Trivial constructor.
 
Method Summary
abstract  java.lang.Object clone()
          Returns a clone copy of this instance.
protected abstract  java.lang.Object generateSignature()
           
protected  void init()
          Initialises the internal fields of this instance.
 java.lang.String name()
          Returns the canonical name of this signature scheme.
protected  void nextRandomBytes(byte[] buffer)
          Fills the designated byte array with random data.
protected abstract  void setupForSigning(java.security.PrivateKey key)
           
protected abstract  void setupForVerification(java.security.PublicKey key)
           
 void setupSign(java.util.Map attributes)
          Initialises this instance for signature generation.
 void setupVerify(java.util.Map attributes)
          Initialises this instance for signature verification.
 java.lang.Object sign()
          Terminates a signature generation phase by digesting and processing the context of the underlying message digest algorithm instance.
 void update(byte b)
          Digests one byte of a message for signing or verification purposes.
 void update(byte[] b, int off, int len)
          Digests a sequence of bytes from a message for signing or verification purposes.
 boolean verify(java.lang.Object sig)
          Terminates a signature verification phase by digesting and processing the context of the underlying message digest algorithm instance.
protected abstract  boolean verifySignature(java.lang.Object signature)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemeName

protected java.lang.String schemeName
The canonical name of this signature scheme.


md

protected IMessageDigest md
The underlying message digest instance for this signature scheme.


publicKey

protected java.security.PublicKey publicKey
The public key to use when verifying signatures.


privateKey

protected java.security.PrivateKey privateKey
The private key to use when generating signatures (signing).

Constructor Detail

BaseSignature

protected BaseSignature(java.lang.String schemeName,
                        IMessageDigest md)

Trivial constructor.

Parameters:
schemeName - the name of this signature scheme.
md - the underlying instance of the message digest algorithm.
Method Detail

name

public java.lang.String name()
Description copied from interface: ISignature

Returns the canonical name of this signature scheme.

Specified by:
name in interface ISignature
Returns:
the canonical name of this instance.

setupVerify

public void setupVerify(java.util.Map attributes)
                 throws java.lang.IllegalArgumentException
Description copied from interface: ISignature

Initialises this instance for signature verification.

Specified by:
setupVerify in interface ISignature
Parameters:
attributes - the attributes to use for setting up this instance.
Throws:
java.lang.IllegalArgumentException - if the designated public key is not appropriate for this signature scheme.
See Also:
ISignature.SOURCE_OF_RANDOMNESS, ISignature.VERIFIER_KEY

setupSign

public void setupSign(java.util.Map attributes)
               throws java.lang.IllegalArgumentException
Description copied from interface: ISignature

Initialises this instance for signature generation.

Specified by:
setupSign in interface ISignature
Parameters:
attributes - the attributes to use for setting up this instance.
Throws:
java.lang.IllegalArgumentException - if the designated private key is not appropriate for this signature scheme.
See Also:
ISignature.SOURCE_OF_RANDOMNESS, ISignature.SIGNER_KEY

update

public void update(byte b)
Description copied from interface: ISignature

Digests one byte of a message for signing or verification purposes.

Specified by:
update in interface ISignature
Parameters:
b - the message byte to digest.

update

public void update(byte[] b,
                   int off,
                   int len)
Description copied from interface: ISignature

Digests a sequence of bytes from a message for signing or verification purposes.

Specified by:
update in interface ISignature
Parameters:
b - the byte sequence to consider.
off - the byte poisition in buffer of the first byte to consider.
len - the number of bytes in buffer starting from the byte at index offset to digest.

sign

public java.lang.Object sign()
Description copied from interface: ISignature

Terminates a signature generation phase by digesting and processing the context of the underlying message digest algorithm instance.

Specified by:
sign in interface ISignature
Returns:
a Object representing the native output of the signature scheme implementation.

verify

public boolean verify(java.lang.Object sig)
Description copied from interface: ISignature

Terminates a signature verification phase by digesting and processing the context of the underlying message digest algorithm instance.

Specified by:
verify in interface ISignature
Parameters:
sig - a native signature object previously generated by an invocation of the sign() method.
Returns:
true iff the outpout of the verification phase confirms that the designated signature object has been generated using the corresponding public key of the recepient.

clone

public abstract java.lang.Object clone()
Description copied from interface: ISignature

Returns a clone copy of this instance.

Specified by:
clone in interface ISignature

setupForVerification

protected abstract void setupForVerification(java.security.PublicKey key)
                                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

setupForSigning

protected abstract void setupForSigning(java.security.PrivateKey key)
                                 throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

generateSignature

protected abstract java.lang.Object generateSignature()
                                               throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

verifySignature

protected abstract boolean verifySignature(java.lang.Object signature)
                                    throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

init

protected void init()
Initialises the internal fields of this instance.


nextRandomBytes

protected void nextRandomBytes(byte[] buffer)

Fills the designated byte array with random data.

Parameters:
buffer - the byte array to fill with random data.

For the latest news and information visit
The GNU Crypto project

Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.