public class Signature extends Object
| Modifier and Type | Field and Description |
|---|---|
int |
length
This is the length of the document being signed.
|
byte[] |
signature
This is the fully encoded signature bytes for transmission or storage along with the document.
|
EncryptionKey |
signersKey
This is the signer's public key (for verifying signatures) or private key (for creating signatures).
|
Time |
time
This is an optional timestamp to be embedded in the signature.
|
| Constructor and Description |
|---|
Signature(byte[] signature,
EncryptionKey signersPublicKey)
This is used on a signature that has already been generated.
|
Signature(EncryptionKey signersPrivateKey,
Time signatureTime)
Create a Signature object in preparation for signing.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
sign(byte[] data,
int offset,
int length,
SHA1 digest)
Produce a signature for a document.
|
boolean |
verify(byte[] data,
int offset,
int length,
SHA1 digest)
Verify that a document is the same as the one that was signed with this signature.
|
boolean |
verify(int dataLength,
byte[] digest)
Verify that a document with a particular data length and with a particular digest
bytes is the same as the one that was signed with this signature.
|
public EncryptionKey signersKey
public Time time
public int length
public byte[] signature
public Signature(byte[] signature,
EncryptionKey signersPublicKey)
throws StreamCorruptedException
After calling this constructor you can call the verify() methods to verify if a document is the one that was signed.
signature - the recieved or stored encoded signature bytes.signersPublicKey - the public key of the signer.StreamCorruptedException - if the data is invalid in any way.public Signature(EncryptionKey signersPrivateKey, Time signatureTime)
signersKey - the private key of the entity that will be signing the data.signatureTime - an optional timestamp to include in the signature.public byte[] sign(byte[] data,
int offset,
int length,
SHA1 digest)
throws IOException
data - the data bytes to sign.offset - the start of the data bytes in the data parameter.length - the number of bytes in the data.digest - an optional pre-created SHA1 object to create the document digest.IOException - if an encryption of data processing error occurs.public boolean verify(int dataLength,
byte[] digest)
dataLength - the length of the data.digest - the SHA1 digest of the data.public boolean verify(byte[] data,
int offset,
int length,
SHA1 digest)
data - the data to verify.offset - the start of the data.length - the number of bytes in the data.digest - an optional pre-created SHA1 object to digest the data.