# Signature

public abstract class **Signature** extends [SignatureSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html)  
The 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.

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
   - a public key, which initializes the signature for verification (see `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initVerify(java.security.PublicKey)`), or
   - a private key (and optionally a Secure Random Number Generator), which initializes the signature for signing (see `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initSign(java.security.PrivateKey)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initSign(java.security.PrivateKey,%20java.security.SecureRandom)`).
2. Updating Depending on the type of initialization, this will update the
   bytes to be signed or verified. See the
   `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#update(byte)` methods.

3. Signing or Verifying a signature on all updated bytes. See the `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#sign()` methods and the `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#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.

Android provides the following `Signature` algorithms:

| Algorithm | Supported API Levels |
|---|---|
| DSA | 1+ |
| DSAwithSHA1 | 1+ |
| DSS | 1-19 |
| ECDSA | 11+ |
| ECDSAwithSHA1 | 11+ |
| MD2withRSA | 1-3 |
| MD4withRSA | 1-8 |
| MD5withRSA | 1+ |
| MD5withRSA/ISO9796-2 | 1-8 |
| NONEwithDSA | 1+ |
| NONEwithECDSA | 11+ |
| NONEwithRSA | 17+ |
| RSASSA-PSS | 1-8 |
| SHA1withDSA | 1+ |
| SHA1withECDSA | 11+ |
| SHA1withRSA | 1+ |
| SHA1withRSA/ISO9796-2 | 1-8 |
| SHA1withRSA/PSS | 23+ |
| SHA224withDSA | 20+ |
| SHA224withECDSA | 20+ |
| SHA224withRSA | 20+ |
| SHA224withRSA/PSS | 23+ |
| SHA256withDSA | 1+ |
| SHA256withECDSA | 11+ |
| SHA256withRSA | 1+ |
| SHA256withRSA/PSS | 23+ |
| SHA384withECDSA | 11+ |
| SHA384withRSA | 1+ |
| SHA384withRSA/PSS | 23+ |
| SHA512withECDSA | 11+ |
| SHA512withRSA | 1+ |
| SHA512withRSA/PSS | 23+ |

These algorithms are described in the [Signature section](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html#Signature) of the Java Cryptography Architecture Standard Algorithm Name Documentation.

<br />

### Constant Summary

|---|---|---|
| int | [SIGN](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#SIGN) | Possible `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state` value, signifying that this signature object has been initialized for signing. |
| int | [UNINITIALIZED](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#UNINITIALIZED) | Possible `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state` value, signifying that this signature object has not yet been initialized. |
| int | [VERIFY](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#VERIFY) | Possible `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state` value, signifying that this signature object has been initialized for verification. |

### Field Summary

|---|---|---|
| protected int | [state](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state) | Current state of this signature object. |

### Inherited Field Summary

From class [java.security.SignatureSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html)

|---|---|---|
| protected [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) | [appRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#appRandom) | Application-specified source of randomness. |

### Protected Constructor Summary

|---|---|
|   | [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#Signature(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm) Creates a Signature object for the specified algorithm. |

### Public Method Summary

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#clone())() Returns a clone if the implementation is cloneable. |
| final [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getAlgorithm](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getAlgorithm())() Returns the name of the algorithm for this signature object. |
| static [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html) | [getInstance](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getInstance(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm) Returns a Signature object that implements the specified signature algorithm. |
| static [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html) | [getInstance](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getInstance(java.lang.String,%20java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) provider) Returns a Signature object that implements the specified signature algorithm. |
| static [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html) | [getInstance](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getInstance(java.lang.String,%20java.security.Provider))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [Provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html) provider) Returns a Signature object that implements the specified signature algorithm. |
| final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getParameter(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) param) *This method is deprecated. Deprecated.* |
| final [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) | [getParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getParameters())() Returns the parameters used with this signature object. |
| final [Provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html) | [getProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getProvider())() Returns the provider of this signature object. |
| final void | [initSign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initSign(java.security.PrivateKey,%20java.security.SecureRandom))([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random) Initialize this object for signing. |
| final void | [initSign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initSign(java.security.PrivateKey))([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey) Initialize this object for signing. |
| final void | [initVerify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initVerify(java.security.PublicKey))([PublicKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PublicKey.html) publicKey) Initializes this object for verification. |
| final void | [initVerify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#initVerify(java.security.cert.Certificate))([Certificate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) certificate) Initializes this object for verification, using the public key from the given certificate. |
| final void | [setParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#setParameter(java.security.spec.AlgorithmParameterSpec))([AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) params) Initializes this signature engine with the specified parameter set. |
| final void | [setParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#setParameter(java.lang.String,%20java.lang.Object))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) param, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) value) *This method is deprecated. Use `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#setParameter(java.security.spec.AlgorithmParameterSpec)`.* |
| final int | [sign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#sign(byte[],%20int,%20int))(byte\[\] outbuf, int offset, int len) Finishes the signature operation and stores the resulting signature bytes in the provided buffer `outbuf`, starting at `offset`. |
| final byte\[\] | [sign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#sign())() Returns the signature bytes of all the data updated. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#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. |
| final void | [update](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#update(byte[]))(byte\[\] data) Updates the data to be signed or verified, using the specified array of bytes. |
| final void | [update](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#update(byte[],%20int,%20int))(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. |
| final void | [update](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#update(java.nio.ByteBuffer))([ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html) data) Updates the data to be signed or verified using the specified ByteBuffer. |
| final void | [update](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#update(byte))(byte b) Updates the data to be signed or verified by a byte. |
| final boolean | [verify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#verify(byte[],%20int,%20int))(byte\[\] signature, int offset, int length) Verifies the passed-in signature in the specified array of bytes, starting at the specified offset. |
| final boolean | [verify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#verify(byte[]))(byte\[\] signature) Verifies the passed-in signature. |

### Inherited Method Summary

From class [java.security.SignatureSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#clone())() Returns a clone if the implementation is cloneable. |
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [engineGetParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineGetParameter(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) param) *This method is deprecated. Deprecated.* |
| [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) | [engineGetParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineGetParameters())() This method is overridden by providers to return the parameters used with this signature engine, or null if this signature engine does not use any parameters. |
| void | [engineInitSign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineInitSign(java.security.PrivateKey,%20java.security.SecureRandom))([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random) Initializes this signature object with the specified private key and source of randomness for signing operations. |
| abstract void | [engineInitSign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineInitSign(java.security.PrivateKey))([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey) Initializes this signature object with the specified private key for signing operations. |
| abstract void | [engineInitVerify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineInitVerify(java.security.PublicKey))([PublicKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PublicKey.html) publicKey) Initializes this signature object with the specified public key for verification operations. |
| abstract void | [engineSetParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineSetParameter(java.lang.String,%20java.lang.Object))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) param, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) value) *This method is deprecated. Replaced by `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineSetParameter(java.security.spec.AlgorithmParameterSpec)`.* |
| void | [engineSetParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineSetParameter(java.security.spec.AlgorithmParameterSpec))([AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) params) This method is overridden by providers to initialize this signature engine with the specified parameter set. |
| abstract byte\[\] | [engineSign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineSign())() Returns the signature bytes of all the data updated so far. |
| int | [engineSign](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineSign(byte[],%20int,%20int))(byte\[\] outbuf, int offset, int len) Finishes this signature operation and stores the resulting signature bytes in the provided buffer `outbuf`, starting at `offset`. |
| abstract void | [engineUpdate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineUpdate(byte[],%20int,%20int))(byte\[\] b, int off, int len) Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset. |
| void | [engineUpdate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineUpdate(java.nio.ByteBuffer))([ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html) input) Updates the data to be signed or verified using the specified ByteBuffer. |
| abstract void | [engineUpdate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineUpdate(byte))(byte b) Updates the data to be signed or verified using the specified byte. |
| boolean | [engineVerify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineVerify(byte[],%20int,%20int))(byte\[\] sigBytes, int offset, int length) Verifies the passed-in signature in the specified array of bytes, starting at the specified offset. |
| abstract boolean | [engineVerify](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html#engineVerify(byte[]))(byte\[\] sigBytes) Verifies the passed-in signature. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Constants

#### protected static final int
**SIGN**

Possible `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state` value, signifying that
this signature object has been initialized for signing.
Constant Value: 2

#### protected static final int
**UNINITIALIZED**

Possible `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state` value, signifying that
this signature object has not yet been initialized.
Constant Value: 0

#### protected static final int
**VERIFY**

Possible `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#state` value, signifying that
this signature object has been initialized for verification.
Constant Value: 3

## Fields

#### protected int
**state**

Current state of this signature object.

## Protected Constructors

#### protected
**Signature**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm)

Creates a Signature object for the specified algorithm.

##### Parameters

| algorithm | the standard string name of the algorithm. See the Signature section in the [Java Cryptography Architecture Standard Algorithm Name Documentation](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html#Signature) for information about standard algorithm names. |
|---|---|

## Public Methods

#### public [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**clone**
()

Returns a clone if the implementation is cloneable.

##### Returns

- a clone if the implementation is cloneable.

##### Throws

| [CloneNotSupportedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CloneNotSupportedException.html) | if this is called on an implementation that does not support `Cloneable`. |
|---|---|

#### public final [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getAlgorithm**
()

Returns the name of the algorithm for this signature object.

##### Returns

- the name of the algorithm for this signature object.

#### public static [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html)
**getInstance**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm)

Returns a Signature object that implements the specified signature
algorithm.

This method traverses the list of registered security Providers,
starting with the most preferred Provider.
A new Signature object encapsulating the
SignatureSpi implementation from the first
Provider that supports the specified algorithm is returned.

Note that the list of registered providers may be retrieved via
the `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Security.html#getProviders()` method.

##### Parameters

| algorithm | the standard name of the algorithm requested. See the Signature section in the [Java Cryptography Architecture Standard Algorithm Name Documentation](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html#Signature) for information about standard algorithm names. |
|---|---|

##### Returns

- the new Signature object.

##### Throws

| [NoSuchAlgorithmException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/NoSuchAlgorithmException.html) | if no Provider supports a Signature implementation for the specified algorithm. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html`

#### public static [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html)
**getInstance**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) provider)

Returns a Signature object that implements the specified signature
algorithm.

A new Signature object encapsulating the
SignatureSpi implementation from the specified provider
is returned. The specified provider must be registered
in the security provider list.

Note that the list of registered providers may be retrieved via
the `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Security.html#getProviders()` method.

##### Parameters

| algorithm | the name of the algorithm requested. See the Signature section in the [Java Cryptography Architecture Standard Algorithm Name Documentation](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html#Signature) for information about standard algorithm names. |
| provider | the name of the provider. |
|---|---|

##### Returns

- the new Signature object.

##### Throws

| [NoSuchAlgorithmException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/NoSuchAlgorithmException.html) | if a SignatureSpi implementation for the specified algorithm is not available from the specified provider. |
| [NoSuchProviderException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/NoSuchProviderException.html) | if the specified provider is not registered in the security provider list. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the provider name is null or empty. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html`

#### public static [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html)
**getInstance**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [Provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html) provider)

Returns a Signature object that implements the specified
signature algorithm.

A new Signature object encapsulating the
SignatureSpi implementation from the specified Provider
object is returned. Note that the specified Provider object
does not have to be registered in the provider list.

##### Parameters

| algorithm | the name of the algorithm requested. See the Signature section in the [Java Cryptography Architecture Standard Algorithm Name Documentation](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html#Signature) for information about standard algorithm names. |
| provider | the provider. |
|---|---|

##### Returns

- the new Signature object.

##### Throws

| [NoSuchAlgorithmException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/NoSuchAlgorithmException.html) | if a SignatureSpi implementation for the specified algorithm is not available from the specified Provider object. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the provider is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html`

#### public final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**getParameter**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) param)


**This method is deprecated.**   
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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidParameterException.html) | if `param` is an invalid parameter for this engine, or another exception occurs while trying to get this parameter. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#setParameter(java.lang.String,%20java.lang.Object)`

#### public final [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html)
**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

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#setParameter(java.security.spec.AlgorithmParameterSpec)`

#### public final [Provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html)
**getProvider**
()

Returns the provider of this signature object.

##### Returns

- the provider of this signature object

#### public final void
**initSign**
([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | if the key is invalid. |
|---|---|

#### public final void
**initSign**
([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | if the key is invalid. |
|---|---|

#### public final void
**initVerify**
([PublicKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PublicKey.html) publicKey)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | if the key is invalid. |
|---|---|

#### public final void
**initVerify**
([Certificate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) certificate)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | 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. |
|---|---|

#### public final void
**setParameter**
([AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) params)

Initializes this signature engine with the specified parameter set.

##### Parameters

| params | the parameters |
|---|---|

##### Throws

| [InvalidAlgorithmParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidAlgorithmParameterException.html) | if the given parameters are inappropriate for this signature engine |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getParameters()`

#### public final void
**setParameter**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) param, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) value)


**This method is deprecated.**   
Use
`https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidParameterException.html) | 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

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html#getParameter(java.lang.String)`

#### public final int
**sign**
(byte\[\] outbuf, int offset, int len)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | 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. |
|---|---|

#### public final byte\[\]
**sign**
()

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided. |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**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.

##### Returns

- a string representation of this signature object.

#### public final void
**update**
(byte\[\] data)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | if this signature object is not initialized properly. |
|---|---|

#### public final void
**update**
(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.

##### 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | if this signature object is not initialized properly. |
|---|---|

#### public final void
**update**
([ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html) data)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | if this signature object is not initialized properly. |
|---|---|

#### public final void
**update**
(byte b)

Updates the data to be signed or verified by a byte.

##### Parameters

| b | the byte to use for the update. |
|---|---|

##### Throws

| [SignatureException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | if this signature object is not initialized properly. |
|---|---|

#### public final boolean
**verify**
(byte\[\] signature, int offset, int length)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | 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. |
|---|---|

#### public final boolean
**verify**
(byte\[\] signature)

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](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | 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. |
|---|---|