A class for producing and verifying digital signatures.
Instances of this class can be obtain from CryptoToken
s.
clone
protected Object clone()
throws CloneNotSupportedException
Cloning is not supported yet
getAlgorithm
public String getAlgorithm()
Returns the name of the algorithm to be used for signing.
getAlgorithmID
public SignatureAlgorithm getAlgorithmID()
Returns the algorithm to be used for signing.
getProvider
public Provider getProvider()
This is not supported yet.
initSign
public void initSign(PrivateKey privateKey)
throws InvalidKeyException,
TokenException
Initialize the signature context for signing.
privateKey
- The private key with which to sign.
initVerify
public void initVerify(PublicKey publicKey)
throws InvalidKeyException,
TokenException
Initialize the signature context for verifying.
publicKey
- The public key with which to verify the signature.
setParameter
public void setParameter(AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException,
TokenException
Set parameters for the signing algorithm. This is currently not
supported or needed.
params
- Parameters for the signing algorithm.
sign
public byte[] sign()
throws SignatureException,
TokenException
Finish a signing operation and return the signature.
sign
public int sign(byte[] outbuf,
int offset,
int len)
throws SignatureException,
TokenException
Finish a signing operation and store the signature in the provided
buffer.
outbuf
- Buffer to hold the signatureoffset
- Offset in buffer at which to store signature.len
- Number of bytes of buffer available for signature.
- int The number of bytes placed into outbuf.
update
public void update(byte b)
throws SignatureException,
TokenException
Provide more data for a signature or verification operation.
b
- A byte to be signed or verified.
update
public void update(byte[] data)
throws SignatureException,
TokenException
Provide more data for a signature or verification operation.
data
- An array of bytes to be signed or verified.
update
public void update(byte[] data,
int off,
int len)
throws SignatureException,
TokenException
Provide more data for a signature or verification operation.
data
- An array of bytes, some of which will be signed or verified.off
- The beginning offset of the bytes to be signed/verified.len
- The number of bytes to be signed/verified.
verify
public boolean verify(byte[] signature)
throws SignatureException,
TokenException
Finish a verification operation.
signature
- The signature to be verified.
- true if the signature is valid, false if it is invalid.