org.mozilla.jss.crypto

Class Signature


public class Signature
extends java.lang.Object

A class for producing and verifying digital signatures. Instances of this class can be obtain from CryptoTokens.
See Also:
CryptoToken.getSignatureContext(SignatureAlgorithm)

Field Summary

protected SignatureAlgorithm
algorithm
protected SignatureSpi
engine

Constructor Summary

Signature()

Method Summary

protected Object
clone()
Cloning is not supported yet
String
getAlgorithm()
Returns the name of the algorithm to be used for signing.
SignatureAlgorithm
getAlgorithmID()
Returns the algorithm to be used for signing.
Provider
getProvider()
This is not supported yet.
void
initSign(PrivateKey privateKey)
Initialize the signature context for signing.
void
initVerify(PublicKey publicKey)
Initialize the signature context for verifying.
void
setParameter(AlgorithmParameterSpec params)
Set parameters for the signing algorithm.
byte[]
sign()
Finish a signing operation and return the signature.
int
sign(byte[] outbuf, int offset, int len)
Finish a signing operation and store the signature in the provided buffer.
void
update(byte b)
Provide more data for a signature or verification operation.
void
update(byte[] data)
Provide more data for a signature or verification operation.
void
update(byte[] data, int off, int len)
Provide more data for a signature or verification operation.
boolean
verify(byte[] signature)
Finish a verification operation.

Field Details

algorithm

protected SignatureAlgorithm algorithm

engine

protected SignatureSpi engine

Constructor Details

Signature

protected Signature()

Method Details

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.
Parameters:
privateKey - The private key with which to sign.
Throws:
TokenException - If an error occurred on the token.

initVerify

public void initVerify(PublicKey publicKey)
            throws InvalidKeyException,
                   TokenException
Initialize the signature context for verifying.
Parameters:
publicKey - The public key with which to verify the signature.
Throws:
TokenException - If an error occurs on the token.

setParameter

public void setParameter(AlgorithmParameterSpec params)
            throws InvalidAlgorithmParameterException,
                   TokenException
Set parameters for the signing algorithm. This is currently not supported or needed.
Parameters:
params - Parameters for the signing algorithm.
Throws:
TokenException - If an error occurs on the token.

sign

public byte[] sign()
            throws SignatureException,
                   TokenException
Finish a signing operation and return the signature.
Returns:
The signature.
Throws:
TokenException - If an error occurs on the token.

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.
Parameters:
outbuf - Buffer to hold the signature
offset - Offset in buffer at which to store signature.
len - Number of bytes of buffer available for signature.
Returns:
int The number of bytes placed into outbuf.
Throws:
TokenException - If an error occurred on the token.

update

public void update(byte b)
            throws SignatureException,
                   TokenException
Provide more data for a signature or verification operation.
Parameters:
b - A byte to be signed or verified.
Throws:
TokenException - If an error occurs on the token.

update

public void update(byte[] data)
            throws SignatureException,
                   TokenException
Provide more data for a signature or verification operation.
Parameters:
data - An array of bytes to be signed or verified.
Throws:
TokenException - If an error occurs on the token.

update

public void update(byte[] data,
                   int off,
                   int len)
            throws SignatureException,
                   TokenException
Provide more data for a signature or verification operation.
Parameters:
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.
Throws:
TokenException - If an error occurs on the token.

verify

public boolean verify(byte[] signature)
            throws SignatureException,
                   TokenException
Finish a verification operation.
Parameters:
signature - The signature to be verified.
Returns:
true if the signature is valid, false if it is invalid.
Throws:
TokenException - If an error occurred on the token.