|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.vt.middleware.crypt.AbstractAlgorithm
edu.vt.middleware.crypt.signature.SignatureAlgorithm
public class SignatureAlgorithm
SignatureAlgorithm provides message signing and verification
operations.
| Field Summary | |
|---|---|
protected DigestAlgorithm |
digest
Message digest used to compute encoded message for signing. |
protected PrivateKey |
signKey
Private key used for signing. |
protected PublicKey |
verifyKey
Public key used for verification. |
| Fields inherited from class edu.vt.middleware.crypt.AbstractAlgorithm |
|---|
algorithm, logger, randomByteSize, randomProvider |
| Constructor Summary | |
|---|---|
protected |
SignatureAlgorithm(String alg)
Creates a new instance of a the given signature algorithm. |
| Method Summary | |
|---|---|
Object |
clone()
|
void |
initSign()
Initialize the signature for the sign(byte[]) operation. |
void |
initVerify()
Initialize the signature for the verify(byte[], byte[]) operation. |
static SignatureAlgorithm |
newInstance(String algorithm)
Creates a new instance that uses the given signature algorithm to compute and verify signatures. |
static SignatureAlgorithm |
newInstance(String algorithm,
String digestAlgorithm)
Creates a new instance that uses the given signature algorithm and digest algorithm to compute and verify signatures. |
void |
setSignKey(PrivateKey key)
Sets the private key used for signing. |
void |
setVerifyKey(PublicKey key)
Sets the public key used for verification. |
byte[] |
sign(byte[] data)
Signs the given data and returns the signature as a byte array. |
String |
sign(byte[] data,
Converter converter)
Signs the given data and returns the signature as a string using the conversion strategy provided by the given converter. |
byte[] |
sign(InputStream in)
Computes the signature of the data in the given input stream by processing in chunks. |
String |
sign(InputStream in,
Converter converter)
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(byte[] data,
String signature,
Converter converter)
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. |
boolean |
verify(InputStream in,
String signature,
Converter converter)
Verifies the signature of the data in the given input stream matches the given signature. |
| 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 |
|---|
protected PrivateKey signKey
protected PublicKey verifyKey
protected DigestAlgorithm digest
| Constructor Detail |
|---|
protected SignatureAlgorithm(String alg)
alg - Signature algorithm name, e.g. DSA, RSA.| Method Detail |
|---|
public static SignatureAlgorithm newInstance(String algorithm)
algorithm - Signature algorithm name.
public static SignatureAlgorithm newInstance(String algorithm,
String digestAlgorithm)
algorithm - Signature algorithm name.digestAlgorithm - Message digest algorithm name.
public void setSignKey(PrivateKey key)
key - Private key.public void setVerifyKey(PublicKey key)
key - Public key.
public void initSign()
throws CryptException
sign(byte[]) operation.
CryptException - On signature initialization failure.
public void initVerify()
throws CryptException
verify(byte[], byte[]) operation.
CryptException - On verification initialization failure.
public byte[] sign(byte[] data)
throws CryptException
data - Data to be signed.
CryptException - On signature failure.
public String sign(byte[] data,
Converter converter)
throws CryptException
data - Data to be signed.converter - Converts raw signature bytes to a string.
CryptException - On signature failure.
public byte[] sign(InputStream in)
throws CryptException,
IOException
in - Input stream containing data to be signed.
CryptException - On signature failure.
IOException - On input stream read errors.
public String sign(InputStream in,
Converter converter)
throws CryptException,
IOException
in - Input stream containing data to be signed.converter - Converts raw signature bytes to a string.
CryptException - On signature failure.
IOException - On input stream read errors.
public boolean verify(byte[] data,
byte[] signature)
throws CryptException
data - Data to be verified.signature - Signature to be used for comparison.
CryptException - On verification failure.
public boolean verify(byte[] data,
String signature,
Converter converter)
throws CryptException
data - Data to be verified.signature - String representation of signature to be used for
comparison.converter - Converts the signature string representation into raw
bytes required for verification.
CryptException - On verification failure.
public boolean verify(InputStream in,
byte[] signature)
throws CryptException,
IOException
in - Input stream containing data to be verified.signature - Signature to be used for comparison.
CryptException - On verification failure.
IOException - On input stream read errors.
public boolean verify(InputStream in,
String signature,
Converter converter)
throws CryptException,
IOException
in - Input stream containing data to be verified.signature - String representation of signature to be used for
comparison.converter - Converts the signature string representation into raw
bytes required for verification.
CryptException - On verification failure.
IOException - On input stream read errors.
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||