|
For the latest news and information visit The GNU Crypto project |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.crypto.sig.BaseSignature
A base abstract class to facilitate implementations of concrete Signatures.
Field Summary | |
---|---|
protected IMessageDigest |
md
The underlying message digest instance for this signature scheme. |
protected PrivateKey |
privateKey
The private key to use when generating signatures (signing). |
protected PublicKey |
publicKey
The public key to use when verifying signatures. |
protected 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(String schemeName,
IMessageDigest md)
Trivial constructor. |
Method Summary | |
---|---|
abstract Object |
clone()
Returns a clone copy of this instance. |
protected abstract Object |
generateSignature()
|
protected void |
init()
Initialises the internal fields of this instance. |
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(PrivateKey key)
|
protected abstract void |
setupForVerification(PublicKey key)
|
void |
setupSign(Map attributes)
Initialises this instance for signature generation. |
void |
setupVerify(Map attributes)
Initialises this instance for signature verification. |
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(Object sig)
Terminates a signature verification phase by digesting and processing the context of the underlying message digest algorithm instance. |
protected abstract boolean |
verifySignature(Object signature)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected String schemeName
protected IMessageDigest md
protected PublicKey publicKey
protected PrivateKey privateKey
Constructor Detail |
protected BaseSignature(String schemeName, IMessageDigest md)
Trivial constructor.
schemeName
- the name of this signature scheme.md
- the underlying instance of the message digest algorithm.Method Detail |
public String name()
ISignature
Returns the canonical name of this signature scheme.
name
in interface ISignature
public void setupVerify(Map attributes) throws IllegalArgumentException
ISignature
Initialises this instance for signature verification.
setupVerify
in interface ISignature
attributes
- the attributes to use for setting up this instance.
IllegalArgumentException
- if the designated public key is not
appropriate for this signature scheme.ISignature.SOURCE_OF_RANDOMNESS
,
ISignature.VERIFIER_KEY
public void setupSign(Map attributes) throws IllegalArgumentException
ISignature
Initialises this instance for signature generation.
setupSign
in interface ISignature
attributes
- the attributes to use for setting up this instance.
IllegalArgumentException
- if the designated private key is not
appropriate for this signature scheme.ISignature.SOURCE_OF_RANDOMNESS
,
ISignature.SIGNER_KEY
public void update(byte b)
ISignature
Digests one byte of a message for signing or verification purposes.
update
in interface ISignature
b
- the message byte to digest.public void update(byte[] b, int off, int len)
ISignature
Digests a sequence of bytes from a message for signing or verification purposes.
update
in interface ISignature
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.public Object sign()
ISignature
Terminates a signature generation phase by digesting and processing the context of the underlying message digest algorithm instance.
sign
in interface ISignature
Object
representing the native output of the signature
scheme implementation.public boolean verify(Object sig)
ISignature
Terminates a signature verification phase by digesting and processing the context of the underlying message digest algorithm instance.
verify
in interface ISignature
sig
- a native signature object previously generated by an
invocation of the sign()
method.
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.public abstract Object clone()
ISignature
Returns a clone copy of this instance.
clone
in interface ISignature
protected abstract void setupForVerification(PublicKey key) throws IllegalArgumentException
IllegalArgumentException
protected abstract void setupForSigning(PrivateKey key) throws IllegalArgumentException
IllegalArgumentException
protected abstract Object generateSignature() throws IllegalStateException
IllegalStateException
protected abstract boolean verifySignature(Object signature) throws IllegalStateException
IllegalStateException
protected void init()
protected void nextRandomBytes(byte[] buffer)
Fills the designated byte array with random data.
buffer
- the byte array to fill with random data.
|
For the latest news and information visit The GNU Crypto project |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |