|
||||||||||
| 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
edu.vt.middleware.crypt.signature.DSASignature
public class DSASignature
Implements the DSA signature algorithm.
| Field Summary |
|---|
| Fields inherited from class edu.vt.middleware.crypt.signature.SignatureAlgorithm |
|---|
digest, signKey, verifyKey |
| Fields inherited from class edu.vt.middleware.crypt.AbstractAlgorithm |
|---|
algorithm, logger, randomByteSize, randomProvider |
| Constructor Summary | |
|---|---|
DSASignature()
Creates a new DSA signature class that uses a SHA-1 for message digest computation. |
|
DSASignature(DigestAlgorithm d)
Creates a new DSA signature class that uses the given digest algorithm for message digest computation. |
|
| Method Summary | |
|---|---|
protected BigInteger[] |
decode(byte[] in)
Produces the r,s integer pair of a DSA signature from a DER-encoded byte representation. |
protected byte[] |
encode(BigInteger r,
BigInteger s)
Produces DER-encoded byte array output from the raw DSA signature output parameters, r and s. |
protected void |
init(boolean forSigning,
org.bouncycastle.crypto.CipherParameters params)
Initialize the signer. |
void |
initSign()
Initialize the signature for the SignatureAlgorithm.sign(byte[]) operation. |
void |
initVerify()
Initialize the signature for the SignatureAlgorithm.verify(byte[], byte[]) operation. |
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. |
byte[] |
sign(InputStream in)
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(InputStream in,
byte[] signature)
Verifies the signature of the given data matches the given signature. |
| Methods inherited from class edu.vt.middleware.crypt.signature.SignatureAlgorithm |
|---|
newInstance, newInstance, sign, sign, verify, verify |
| Methods inherited from class edu.vt.middleware.crypt.AbstractAlgorithm |
|---|
getAlgorithm, getRandomData, setRandomProvider, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DSASignature()
public DSASignature(DigestAlgorithm d)
d - Message digest algorithm.| Method Detail |
|---|
public void setSignKey(PrivateKey key)
setSignKey in class SignatureAlgorithmkey - Private key.public void setVerifyKey(PublicKey key)
setVerifyKey in class SignatureAlgorithmkey - Public key.public void initSign()
SignatureAlgorithm.sign(byte[]) operation.
initSign in class SignatureAlgorithmpublic void initVerify()
SignatureAlgorithm.verify(byte[], byte[]) operation.
initVerify in class SignatureAlgorithm
public byte[] sign(byte[] data)
throws CryptException
sign in class SignatureAlgorithmdata - Data to be signed.
CryptException - On signature failure.
public byte[] sign(InputStream in)
throws CryptException,
IOException
sign in class SignatureAlgorithmin - Input stream containing data to be signed.
CryptException - On signature failure.
IOException - On input stream read errors.
public boolean verify(byte[] data,
byte[] signature)
throws CryptException
verify in class SignatureAlgorithmdata - Data to be verified.signature - Signature to be used for comparison.
CryptException - On verification failure.
public boolean verify(InputStream in,
byte[] signature)
throws CryptException,
IOException
verify in class SignatureAlgorithmin - Input stream containing data to be verified.signature - Signature to be used for comparison.
CryptException - On verification failure.
IOException - On input stream read errors.
protected void init(boolean forSigning,
org.bouncycastle.crypto.CipherParameters params)
forSigning - Whether to initialize signer for the sign operation.params - BC cipher parameters.
protected byte[] encode(BigInteger r,
BigInteger s)
throws CryptException
r - DSA signature output integer r.s - DSA signature output integer s.
CryptException - On cryptographic errors.
protected BigInteger[] decode(byte[] in)
throws CryptException
in - DER-encoded concatenation of byte representation of r and s.
CryptException - On cryptographic errors.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||