Algorithm
public class RSASignature extends SignatureAlgorithm
algorithm, randomByteSize, randomProvider
digest, signKey, verifyKey
Constructor | Description |
---|---|
RSASignature() |
Creates a new RSA signature class that uses a SHA-1 for message digest
computation.
|
RSASignature(DigestAlgorithm d) |
Creates a new RSA signature class that uses the given digest algorithm
for message digest computation.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
chunkUpdate(InputStream in) |
Update the signer in chunks with data read from the input stream.
|
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.
|
getAlgorithm, getRandomData, setRandomProvider, toString
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clone, newInstance, newInstance, sign, sign, verify, verify
public RSASignature()
public RSASignature(DigestAlgorithm d)
d
- Message digest algorithm.public void setSignKey(PrivateKey key)
setSignKey
in class SignatureAlgorithm
key
- Private key.public void setVerifyKey(PublicKey key)
setVerifyKey
in class SignatureAlgorithm
key
- Public key.public void initSign()
SignatureAlgorithm.sign(byte[])
operation.initSign
in class SignatureAlgorithm
public void initVerify()
SignatureAlgorithm.verify(byte[], byte[])
operation.initVerify
in class SignatureAlgorithm
public byte[] sign(byte[] data) throws CryptException
sign
in class SignatureAlgorithm
data
- Data to be signed.CryptException
- On signature failure.public byte[] sign(InputStream in) throws CryptException, IOException
sign
in class SignatureAlgorithm
in
- 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 SignatureAlgorithm
data
- 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 SignatureAlgorithm
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.protected void init(boolean forSigning, org.bouncycastle.crypto.CipherParameters params)
forSigning
- Whether to initialize signer for the sign operation.params
- BC cipher parameters.protected void chunkUpdate(InputStream in) throws IOException
in
- Input stream to read from.IOException
- On IO errors.Copyright © 2021. All rights reserved.