java.security
Class Signature

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.SignatureSpi sample code for java.security.SignatureSpi definition code for java.security.SignatureSpi 
      extended by java.security.Signature

public abstract class Signature
extends SignatureSpi sample code for java.security.SignatureSpi definition code for java.security.SignatureSpi

This Signature class is used to provide applications the functionality of a digital signature algorithm. Digital signatures are used for authentication and integrity assurance of digital data.

The signature algorithm can be, among others, the NIST standard DSA, using DSA and SHA-1. The DSA algorithm using the SHA-1 message digest algorithm can be specified as SHA1withDSA. In the case of RSA, there are multiple choices for the message digest algorithm, so the signing algorithm could be specified as, for example, MD2withRSA, MD5withRSA, or SHA1withRSA. The algorithm name must be specified, as there is no default.

Like other algorithm-based classes in Java Security, Signature provides implementation-independent algorithms, whereby a caller (application code) requests a particular signature algorithm and is handed back a properly initialized Signature object. It is also possible, if desired, to request a particular algorithm from a particular provider. See the getInstance methods.

Thus, there are two ways to request a Signature algorithm object: by specifying either just an algorithm name, or both an algorithm name and a package provider.

A Signature object can be used to generate and verify digital signatures.

There are three phases to the use of a Signature object for either signing data or verifying a signature:

  1. Initialization, with either

  2. Updating

    Depending on the type of initialization, this will update the bytes to be signed or verified. See the update sample code for java.security.Signature.update(byte) definition code for java.security.Signature.update(byte) methods.

  3. Signing or Verifying a signature on all updated bytes. See the sign sample code for java.security.Signature.sign() definition code for java.security.Signature.sign() methods and the verify sample code for java.security.Signature.verify(byte[]) definition code for java.security.Signature.verify(byte[]) method.

Note that this class is abstract and extends from SignatureSpi for historical reasons. Application developers should only take notice of the methods defined in this Signature class; all the methods in the superclass are intended for cryptographic service providers who wish to supply their own implementations of digital signature algorithms.


Field Summary
protected static int SIGN sample code for java.security.Signature.SIGN definition code for java.security.Signature.SIGN
          Possible state sample code for java.security.Signature.state definition code for java.security.Signature.state value, signifying that this signature object has been initialized for signing.
protected  int state sample code for java.security.Signature.state definition code for java.security.Signature.state
          Current state of this signature object.
protected static int UNINITIALIZED sample code for java.security.Signature.UNINITIALIZED definition code for java.security.Signature.UNINITIALIZED
          Possible state sample code for java.security.Signature.state definition code for java.security.Signature.state value, signifying that this signature object has not yet been initialized.
protected static int VERIFY sample code for java.security.Signature.VERIFY definition code for java.security.Signature.VERIFY
          Possible state sample code for java.security.Signature.state definition code for java.security.Signature.state value, signifying that this signature object has been initialized for verification.
 
Fields inherited from class java.security.SignatureSpi sample code for java.security.SignatureSpi definition code for java.security.SignatureSpi
appRandom sample code for java.security.SignatureSpi.appRandom definition code for java.security.SignatureSpi.appRandom
 
Constructor Summary
protected Signature sample code for java.security.Signature.Signature(java.lang.String) definition code for java.security.Signature.Signature(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  algorithm)
          Creates a Signature object for the specified algorithm.
 
Method Summary
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for java.security.Signature.clone() definition code for java.security.Signature.clone() ()
          Returns a clone if the implementation is cloneable.
 String sample code for java.lang.String definition code for java.lang.String getAlgorithm sample code for java.security.Signature.getAlgorithm() definition code for java.security.Signature.getAlgorithm() ()
          Returns the name of the algorithm for this signature object.
static Signature sample code for java.security.Signature definition code for java.security.Signature getInstance sample code for java.security.Signature.getInstance(java.lang.String) definition code for java.security.Signature.getInstance(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  algorithm)
          Generates a Signature object that implements the specified digest algorithm.
static Signature sample code for java.security.Signature definition code for java.security.Signature getInstance sample code for java.security.Signature.getInstance(java.lang.String, java.security.Provider) definition code for java.security.Signature.getInstance(java.lang.String, java.security.Provider) (String sample code for java.lang.String definition code for java.lang.String  algorithm, Provider sample code for java.security.Provider definition code for java.security.Provider  provider)
          Generates a Signature object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.
static Signature sample code for java.security.Signature definition code for java.security.Signature getInstance sample code for java.security.Signature.getInstance(java.lang.String, java.lang.String) definition code for java.security.Signature.getInstance(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  algorithm, String sample code for java.lang.String definition code for java.lang.String  provider)
          Generates a Signature object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.
 Object sample code for java.lang.Object definition code for java.lang.Object getParameter sample code for java.security.Signature.getParameter(java.lang.String) definition code for java.security.Signature.getParameter(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  param)
          Deprecated.  
 AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters getParameters sample code for java.security.Signature.getParameters() definition code for java.security.Signature.getParameters() ()
          Returns the parameters used with this signature object.
 Provider sample code for java.security.Provider definition code for java.security.Provider getProvider sample code for java.security.Signature.getProvider() definition code for java.security.Signature.getProvider() ()
          Returns the provider of this signature object.
 void initSign sample code for java.security.Signature.initSign(java.security.PrivateKey) definition code for java.security.Signature.initSign(java.security.PrivateKey) (PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  privateKey)
          Initialize this object for signing.
 void initSign sample code for java.security.Signature.initSign(java.security.PrivateKey, java.security.SecureRandom) definition code for java.security.Signature.initSign(java.security.PrivateKey, java.security.SecureRandom) (PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  privateKey, SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  random)
          Initialize this object for signing.
 void initVerify sample code for java.security.Signature.initVerify(java.security.cert.Certificate) definition code for java.security.Signature.initVerify(java.security.cert.Certificate) (Certificate sample code for java.security.cert.Certificate definition code for java.security.cert.Certificate  certificate)
          Initializes this object for verification, using the public key from the given certificate.
 void initVerify sample code for java.security.Signature.initVerify(java.security.PublicKey) definition code for java.security.Signature.initVerify(java.security.PublicKey) (PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  publicKey)
          Initializes this object for verification.
 void setParameter sample code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) (AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  params)
          Initializes this signature engine with the specified parameter set.
 void setParameter sample code for java.security.Signature.setParameter(java.lang.String, java.lang.Object) definition code for java.security.Signature.setParameter(java.lang.String, java.lang.Object) (String sample code for java.lang.String definition code for java.lang.String  param, Object sample code for java.lang.Object definition code for java.lang.Object  value)
          Deprecated. Use setParameter sample code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) .
 byte[] sign sample code for java.security.Signature.sign() definition code for java.security.Signature.sign() ()
          Returns the signature bytes of all the data updated.
 int sign sample code for java.security.Signature.sign(byte[], int, int) definition code for java.security.Signature.sign(byte[], int, int) (byte[] outbuf, int offset, int len)
          Finishes the signature operation and stores the resulting signature bytes in the provided buffer outbuf, starting at offset.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.security.Signature.toString() definition code for java.security.Signature.toString() ()
          Returns a string representation of this signature object, providing information that includes the state of the object and the name of the algorithm used.
 void update sample code for java.security.Signature.update(byte) definition code for java.security.Signature.update(byte) (byte b)
          Updates the data to be signed or verified by a byte.
 void update sample code for java.security.Signature.update(byte[]) definition code for java.security.Signature.update(byte[]) (byte[] data)
          Updates the data to be signed or verified, using the specified array of bytes.
 void update sample code for java.security.Signature.update(byte[], int, int) definition code for java.security.Signature.update(byte[], int, int) (byte[] data, int off, int len)
          Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
 void update sample code for java.security.Signature.update(java.nio.ByteBuffer) definition code for java.security.Signature.update(java.nio.ByteBuffer) (ByteBuffer sample code for java.nio.ByteBuffer definition code for java.nio.ByteBuffer  data)
          Updates the data to be signed or verified using the specified ByteBuffer.
 boolean verify sample code for java.security.Signature.verify(byte[]) definition code for java.security.Signature.verify(byte[]) (byte[] signature)
          Verifies the passed-in signature.
 boolean verify sample code for java.security.Signature.verify(byte[], int, int) definition code for java.security.Signature.verify(byte[], int, int) (byte[] signature, int offset, int length)
          Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.
 
Methods inherited from class java.security.SignatureSpi sample code for java.security.SignatureSpi definition code for java.security.SignatureSpi
engineGetParameter sample code for java.security.SignatureSpi.engineGetParameter(java.lang.String) definition code for java.security.SignatureSpi.engineGetParameter(java.lang.String) , engineGetParameters sample code for java.security.SignatureSpi.engineGetParameters() definition code for java.security.SignatureSpi.engineGetParameters() , engineInitSign sample code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey) definition code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey) , engineInitSign sample code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey, java.security.SecureRandom) definition code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey, java.security.SecureRandom) , engineInitVerify sample code for java.security.SignatureSpi.engineInitVerify(java.security.PublicKey) definition code for java.security.SignatureSpi.engineInitVerify(java.security.PublicKey) , engineSetParameter sample code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) , engineSetParameter sample code for java.security.SignatureSpi.engineSetParameter(java.lang.String, java.lang.Object) definition code for java.security.SignatureSpi.engineSetParameter(java.lang.String, java.lang.Object) , engineSign sample code for java.security.SignatureSpi.engineSign() definition code for java.security.SignatureSpi.engineSign() , engineSign sample code for java.security.SignatureSpi.engineSign(byte[], int, int) definition code for java.security.SignatureSpi.engineSign(byte[], int, int) , engineUpdate sample code for java.security.SignatureSpi.engineUpdate(byte) definition code for java.security.SignatureSpi.engineUpdate(byte) , engineUpdate sample code for java.security.SignatureSpi.engineUpdate(byte[], int, int) definition code for java.security.SignatureSpi.engineUpdate(byte[], int, int) , engineUpdate sample code for java.security.SignatureSpi.engineUpdate(java.nio.ByteBuffer) definition code for java.security.SignatureSpi.engineUpdate(java.nio.ByteBuffer) , engineVerify sample code for java.security.SignatureSpi.engineVerify(byte[]) definition code for java.security.SignatureSpi.engineVerify(byte[]) , engineVerify sample code for java.security.SignatureSpi.engineVerify(byte[], int, int) definition code for java.security.SignatureSpi.engineVerify(byte[], int, int)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

UNINITIALIZED sample code for java.security.Signature.UNINITIALIZED

protected static final int UNINITIALIZED
Possible state sample code for java.security.Signature.state definition code for java.security.Signature.state value, signifying that this signature object has not yet been initialized.

See Also:
Constant Field Values

SIGN sample code for java.security.Signature.SIGN

protected static final int SIGN
Possible state sample code for java.security.Signature.state definition code for java.security.Signature.state value, signifying that this signature object has been initialized for signing.

See Also:
Constant Field Values

VERIFY sample code for java.security.Signature.VERIFY

protected static final int VERIFY
Possible state sample code for java.security.Signature.state definition code for java.security.Signature.state value, signifying that this signature object has been initialized for verification.

See Also:
Constant Field Values

state sample code for java.security.Signature.state

protected int state
Current state of this signature object.

Constructor Detail

Signature sample code for java.security.Signature(java.lang.String) definition code for java.security.Signature(java.lang.String)

protected Signature(String sample code for java.lang.String definition code for java.lang.String  algorithm)
Creates a Signature object for the specified algorithm.

Parameters:
algorithm - the standard string name of the algorithm. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names.
Method Detail

getInstance sample code for java.security.Signature.getInstance(java.lang.String) definition code for java.security.Signature.getInstance(java.lang.String)

public static Signature sample code for java.security.Signature definition code for java.security.Signature  getInstance(String sample code for java.lang.String definition code for java.lang.String  algorithm)
                             throws NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException 
Generates a Signature object that implements the specified digest algorithm. If the default provider package provides an implementation of the requested digest algorithm, an instance of Signature containing that implementation is returned. If the algorithm is not available in the default package, other packages are searched.

Parameters:
algorithm - the standard name of the algorithm requested. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names.
Returns:
the new Signature object.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

getInstance sample code for java.security.Signature.getInstance(java.lang.String, java.lang.String) definition code for java.security.Signature.getInstance(java.lang.String, java.lang.String)

public static Signature sample code for java.security.Signature definition code for java.security.Signature  getInstance(String sample code for java.lang.String definition code for java.lang.String  algorithm,
                                    String sample code for java.lang.String definition code for java.lang.String  provider)
                             throws NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException ,
                                    NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException 
Generates a Signature object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.

Parameters:
algorithm - the name of the algorithm requested. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names.
provider - the name of the provider.
Returns:
the new Signature object.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - if the algorithm is not available in the package supplied by the requested provider.
NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException - if the provider is not available in the environment.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the provider name is null or empty.
See Also:
Provider sample code for java.security.Provider definition code for java.security.Provider

getInstance sample code for java.security.Signature.getInstance(java.lang.String, java.security.Provider) definition code for java.security.Signature.getInstance(java.lang.String, java.security.Provider)

public static Signature sample code for java.security.Signature definition code for java.security.Signature  getInstance(String sample code for java.lang.String definition code for java.lang.String  algorithm,
                                    Provider sample code for java.security.Provider definition code for java.security.Provider  provider)
                             throws NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException 
Generates a Signature object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider. Note: the provider doesn't have to be registered.

Parameters:
algorithm - the name of the algorithm requested. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names.
provider - the provider.
Returns:
the new Signature object.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - if the algorithm is not available in the package supplied by the requested provider.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the provider is null.
Since:
1.4
See Also:
Provider sample code for java.security.Provider definition code for java.security.Provider

getProvider sample code for java.security.Signature.getProvider() definition code for java.security.Signature.getProvider()

public final Provider sample code for java.security.Provider definition code for java.security.Provider  getProvider()
Returns the provider of this signature object.

Returns:
the provider of this signature object

initVerify sample code for java.security.Signature.initVerify(java.security.PublicKey) definition code for java.security.Signature.initVerify(java.security.PublicKey)

public final void initVerify(PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  publicKey)
                      throws InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException 
Initializes this object for verification. If this method is called again with a different argument, it negates the effect of this call.

Parameters:
publicKey - the public key of the identity whose signature is going to be verified.
Throws:
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - if the key is invalid.

initVerify sample code for java.security.Signature.initVerify(java.security.cert.Certificate) definition code for java.security.Signature.initVerify(java.security.cert.Certificate)

public final void initVerify(Certificate sample code for java.security.cert.Certificate definition code for java.security.cert.Certificate  certificate)
                      throws InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException 
Initializes this object for verification, using the public key from the given certificate.

If the certificate is of type X.509 and has a key usage extension field marked as critical, and the value of the key usage extension field implies that the public key in the certificate and its corresponding private key are not supposed to be used for digital signatures, an InvalidKeyException is thrown.

Parameters:
certificate - the certificate of the identity whose signature is going to be verified.
Throws:
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - if the public key in the certificate is not encoded properly or does not include required parameter information or cannot be used for digital signature purposes.

initSign sample code for java.security.Signature.initSign(java.security.PrivateKey) definition code for java.security.Signature.initSign(java.security.PrivateKey)

public final void initSign(PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  privateKey)
                    throws InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException 
Initialize this object for signing. If this method is called again with a different argument, it negates the effect of this call.

Parameters:
privateKey - the private key of the identity whose signature is going to be generated.
Throws:
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - if the key is invalid.

initSign sample code for java.security.Signature.initSign(java.security.PrivateKey, java.security.SecureRandom) definition code for java.security.Signature.initSign(java.security.PrivateKey, java.security.SecureRandom)

public final void initSign(PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  privateKey,
                           SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  random)
                    throws InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException 
Initialize this object for signing. If this method is called again with a different argument, it negates the effect of this call.

Parameters:
privateKey - the private key of the identity whose signature is going to be generated.
random - the source of randomness for this signature.
Throws:
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - if the key is invalid.

sign sample code for java.security.Signature.sign() definition code for java.security.Signature.sign()

public final byte[] sign()
                  throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Returns the signature bytes of all the data updated. The format of the signature depends on the underlying signature scheme.

A call to this method resets this signature object to the state it was in when previously initialized for signing via a call to initSign(PrivateKey). That is, the object is reset and available to generate another signature from the same signer, if desired, via new calls to update and sign.

Returns:
the signature bytes of the signing operation's result.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided.

sign sample code for java.security.Signature.sign(byte[], int, int) definition code for java.security.Signature.sign(byte[], int, int)

public final int sign(byte[] outbuf,
                      int offset,
                      int len)
               throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Finishes the signature operation and stores the resulting signature bytes in the provided buffer outbuf, starting at offset. The format of the signature depends on the underlying signature scheme.

This signature object is reset to its initial state (the state it was in after a call to one of the initSign methods) and can be reused to generate further signatures with the same private key.

Parameters:
outbuf - buffer for the signature result.
offset - offset into outbuf where the signature is stored.
len - number of bytes within outbuf allotted for the signature.
Returns:
the number of bytes placed into outbuf.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly, if this signature algorithm is unable to process the input data provided, or if len is less than the actual signature length.
Since:
1.2

verify sample code for java.security.Signature.verify(byte[]) definition code for java.security.Signature.verify(byte[])

public final boolean verify(byte[] signature)
                     throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Verifies the passed-in signature.

A call to this method resets this signature object to the state it was in when previously initialized for verification via a call to initVerify(PublicKey). That is, the object is reset and available to verify another signature from the identity whose public key was specified in the call to initVerify.

Parameters:
signature - the signature bytes to be verified.
Returns:
true if the signature was verified, false if not.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly, the passed-in signature is improperly encoded or of the wrong type, if this signature algorithm is unable to process the input data provided, etc.

verify sample code for java.security.Signature.verify(byte[], int, int) definition code for java.security.Signature.verify(byte[], int, int)

public final boolean verify(byte[] signature,
                            int offset,
                            int length)
                     throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.

A call to this method resets this signature object to the state it was in when previously initialized for verification via a call to initVerify(PublicKey). That is, the object is reset and available to verify another signature from the identity whose public key was specified in the call to initVerify.

Parameters:
signature - the signature bytes to be verified.
offset - the offset to start from in the array of bytes.
length - the number of bytes to use, starting at offset.
Returns:
true if the signature was verified, false if not.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly, the passed-in signature is improperly encoded or of the wrong type, if this signature algorithm is unable to process the input data provided, etc.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the signature byte array is null, or the offset or length is less than 0, or the sum of the offset and length is greater than the length of the signature byte array.

update sample code for java.security.Signature.update(byte) definition code for java.security.Signature.update(byte)

public final void update(byte b)
                  throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Updates the data to be signed or verified by a byte.

Parameters:
b - the byte to use for the update.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly.

update sample code for java.security.Signature.update(byte[]) definition code for java.security.Signature.update(byte[])

public final void update(byte[] data)
                  throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Updates the data to be signed or verified, using the specified array of bytes.

Parameters:
data - the byte array to use for the update.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly.

update sample code for java.security.Signature.update(byte[], int, int) definition code for java.security.Signature.update(byte[], int, int)

public final void update(byte[] data,
                         int off,
                         int len)
                  throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.

Parameters:
data - the array of bytes.
off - the offset to start from in the array of bytes.
len - the number of bytes to use, starting at offset.
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly.

update sample code for java.security.Signature.update(java.nio.ByteBuffer) definition code for java.security.Signature.update(java.nio.ByteBuffer)

public final void update(ByteBuffer sample code for java.nio.ByteBuffer definition code for java.nio.ByteBuffer  data)
                  throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Updates the data to be signed or verified using the specified ByteBuffer. Processes the data.remaining() bytes starting at at data.position(). Upon return, the buffer's position will be equal to its limit; its limit will not have changed.

Parameters:
data - the ByteBuffer
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if this signature object is not initialized properly.
Since:
1.5

getAlgorithm sample code for java.security.Signature.getAlgorithm() definition code for java.security.Signature.getAlgorithm()

public final String sample code for java.lang.String definition code for java.lang.String  getAlgorithm()
Returns the name of the algorithm for this signature object.

Returns:
the name of the algorithm for this signature object.

toString sample code for java.security.Signature.toString() definition code for java.security.Signature.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string representation of this signature object, providing information that includes the state of the object and the name of the algorithm used.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this signature object.

setParameter sample code for java.security.Signature.setParameter(java.lang.String, java.lang.Object) definition code for java.security.Signature.setParameter(java.lang.String, java.lang.Object)

@Deprecated
public final void setParameter(String sample code for java.lang.String definition code for java.lang.String  param,
                                          Object sample code for java.lang.Object definition code for java.lang.Object  value)
                        throws InvalidParameterException sample code for java.security.InvalidParameterException definition code for java.security.InvalidParameterException 
Deprecated. Use setParameter sample code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) .

Sets the specified algorithm parameter to the specified value. This method supplies a general-purpose mechanism through which it is possible to set the various parameters of this object. A parameter may be any settable parameter for the algorithm, such as a parameter size, or a source of random bits for signature generation (if appropriate), or an indication of whether or not to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.

Parameters:
param - the string identifier of the parameter.
value - the parameter value.
Throws:
InvalidParameterException sample code for java.security.InvalidParameterException definition code for java.security.InvalidParameterException - if param is an invalid parameter for this signature algorithm engine, the parameter is already set and cannot be set again, a security exception occurs, and so on.
See Also:
getParameter(java.lang.String) sample code for java.security.Signature.getParameter(java.lang.String) definition code for java.security.Signature.getParameter(java.lang.String)

setParameter sample code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec)

public final void setParameter(AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  params)
                        throws InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException 
Initializes this signature engine with the specified parameter set.

Parameters:
params - the parameters
Throws:
InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException - if the given parameters are inappropriate for this signature engine
See Also:
getParameters() sample code for java.security.Signature.getParameters() definition code for java.security.Signature.getParameters()

getParameters sample code for java.security.Signature.getParameters() definition code for java.security.Signature.getParameters()

public final AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters  getParameters()
Returns the parameters used with this signature object.

The returned parameters may be the same that were used to initialize this signature, or may contain a combination of default and randomly generated parameter values used by the underlying signature implementation if this signature requires algorithm parameters but was not initialized with any.

Returns:
the parameters used with this signature, or null if this signature does not use any parameters.
See Also:
setParameter(AlgorithmParameterSpec) sample code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.Signature.setParameter(java.security.spec.AlgorithmParameterSpec)

getParameter sample code for java.security.Signature.getParameter(java.lang.String) definition code for java.security.Signature.getParameter(java.lang.String)

@Deprecated
public final Object sample code for java.lang.Object definition code for java.lang.Object  getParameter(String sample code for java.lang.String definition code for java.lang.String  param)
                          throws InvalidParameterException sample code for java.security.InvalidParameterException definition code for java.security.InvalidParameterException 
Deprecated. 

Gets the value of the specified algorithm parameter. This method supplies a general-purpose mechanism through which it is possible to get the various parameters of this object. A parameter may be any settable parameter for the algorithm, such as a parameter size, or a source of random bits for signature generation (if appropriate), or an indication of whether or not to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.

Parameters:
param - the string name of the parameter.
Returns:
the object that represents the parameter value, or null if there is none.
Throws:
InvalidParameterException sample code for java.security.InvalidParameterException definition code for java.security.InvalidParameterException - if param is an invalid parameter for this engine, or another exception occurs while trying to get this parameter.
See Also:
setParameter(String, Object) sample code for java.security.Signature.setParameter(java.lang.String, java.lang.Object) definition code for java.security.Signature.setParameter(java.lang.String, java.lang.Object)

clone sample code for java.security.Signature.clone() definition code for java.security.Signature.clone()

public Object sample code for java.lang.Object definition code for java.lang.Object  clone()
             throws CloneNotSupportedException sample code for java.lang.CloneNotSupportedException definition code for java.lang.CloneNotSupportedException 
Returns a clone if the implementation is cloneable.

Overrides:
clone sample code for java.security.SignatureSpi.clone() definition code for java.security.SignatureSpi.clone() in class SignatureSpi sample code for java.security.SignatureSpi definition code for java.security.SignatureSpi
Returns:
a clone if the implementation is cloneable.
Throws:
CloneNotSupportedException sample code for java.lang.CloneNotSupportedException definition code for java.lang.CloneNotSupportedException - if this is called on an implementation that does not support Cloneable.
See Also:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable