Signature Class

Definition

The Signature class is used to provide applications the functionality of a digital signature algorithm.

[Android.Runtime.Register("java/security/Signature", DoNotGenerateAcw=true)]
public abstract class Signature : Java.Security.SignatureSpi
[<Android.Runtime.Register("java/security/Signature", DoNotGenerateAcw=true)>]
type Signature = class
    inherit SignatureSpi
Inheritance
Attributes

Remarks

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:<ol>

<li>Initialization, with either

<ul>

<li>a public key, which initializes the signature for verification (see #initVerify(PublicKey) initVerify), or

<li>a private key (and optionally a Secure Random Number Generator), which initializes the signature for signing (see #initSign(PrivateKey) and #initSign(PrivateKey, SecureRandom)).

</ul>

<li>Updating

Depending on the type of initialization, this will update the bytes to be signed or verified. See the #update(byte) update methods.

<li>Signing or Verifying a signature on all updated bytes. See the #sign() sign methods and the #verify(byte[]) verify method.

</ol>

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: <table> <thead> <tr> <th>Algorithm</th> <th>Supported API Levels</th> </tr> </thead> <tbody> <tr> <td>DSA</td> <td>1+</td> </tr> <tr> <td>DSAwithSHA1</td> <td>1+</td> </tr> <tr class="deprecated"> <td>DSS</td> <td>1-19</td> </tr> <tr> <td>ECDSA</td> <td>11+</td> </tr> <tr> <td>ECDSAwithSHA1</td> <td>11+</td> </tr> <tr class="deprecated"> <td>MD2withRSA</td> <td>1-3</td> </tr> <tr class="deprecated"> <td>MD4withRSA</td> <td>1-8</td> </tr> <tr> <td>MD5withRSA</td> <td>1+</td> </tr> <tr class="deprecated"> <td>MD5withRSA/ISO9796-2</td> <td>1-8</td> </tr> <tr> <td>NONEwithDSA</td> <td>1+</td> </tr> <tr> <td>NONEwithECDSA</td> <td>11+</td> </tr> <tr> <td>NONEwithRSA</td> <td>17+</td> </tr> <tr class="deprecated"> <td>RSASSA-PSS</td> <td>1-8</td> </tr> <tr> <td>SHA1withDSA</td> <td>1+</td> </tr> <tr> <td>SHA1withECDSA</td> <td>11+</td> </tr> <tr> <td>SHA1withRSA</td> <td>1+</td> </tr> <tr class="deprecated"> <td>SHA1withRSA/ISO9796-2</td> <td>1-8</td> </tr> <tr> <td>SHA1withRSA/PSS</td> <td>23+</td> </tr> <tr> <td>SHA224withDSA</td> <td>20+</td> </tr> <tr> <td>SHA224withECDSA</td> <td>20+</td> </tr> <tr> <td>SHA224withRSA</td> <td>20+</td> </tr> <tr> <td>SHA224withRSA/PSS</td> <td>23+</td> </tr> <tr> <td>SHA256withDSA</td> <td>1+</td> </tr> <tr> <td>SHA256withECDSA</td> <td>11+</td> </tr> <tr> <td>SHA256withRSA</td> <td>1+</td> </tr> <tr> <td>SHA256withRSA/PSS</td> <td>23+</td> </tr> <tr> <td>SHA384withECDSA</td> <td>11+</td> </tr> <tr> <td>SHA384withRSA</td> <td>1+</td> </tr> <tr> <td>SHA384withRSA/PSS</td> <td>23+</td> </tr> <tr> <td>SHA512withECDSA</td> <td>11+</td> </tr> <tr> <td>SHA512withRSA</td> <td>1+</td> </tr> <tr> <td>SHA512withRSA/PSS</td> <td>23+</td> </tr> </tbody> </table>

These algorithms are described in the Signature section of the Java Cryptography Architecture Standard Algorithm Name Documentation.

Java documentation for java.security.Signature.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Signature(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Signature(String)

Creates a Signature object for the specified algorithm.

Fields

Uninitialized
Obsolete.

Possible #state value, signifying that this signature object has not yet been initialized.

Properties

Algorithm

Returns the name of the algorithm for this signature object.

AppRandom

Application-specified source of randomness.

(Inherited from SignatureSpi)
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Parameters

Returns the parameters used with this signature object.

PeerReference (Inherited from Object)
Provider

Returns the provider of this signature object.

State

Current state of this signature object.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone()

Returns a clone if the implementation is cloneable.

(Inherited from SignatureSpi)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
EngineGetParameter(String)
Obsolete.

Gets the value of the specified algorithm parameter.

(Inherited from SignatureSpi)
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.

(Inherited from SignatureSpi)
EngineInitSign(IPrivateKey, SecureRandom)

Initializes this signature object with the specified private key and source of randomness for signing operations.

(Inherited from SignatureSpi)
EngineInitSign(IPrivateKey)

Initializes this signature object with the specified private key for signing operations.

(Inherited from SignatureSpi)
EngineInitVerify(IPublicKey)

Initializes this signature object with the specified public key for verification operations.

(Inherited from SignatureSpi)
EngineSetParameter(IAlgorithmParameterSpec)

This method is overridden by providers to initialize this signature engine with the specified parameter set.

(Inherited from SignatureSpi)
EngineSetParameter(String, Object)
Obsolete.

Sets the specified algorithm parameter to the specified value.

(Inherited from SignatureSpi)
EngineSign()

Returns the signature bytes of all the data updated so far.

(Inherited from SignatureSpi)
EngineSign(Byte[], Int32, Int32)

Finishes this signature operation and stores the resulting signature bytes in the provided buffer outbuf, starting at offset.

(Inherited from SignatureSpi)
EngineUpdate(Byte[], Int32, Int32)

Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.

(Inherited from SignatureSpi)
EngineUpdate(ByteBuffer)

Updates the data to be signed or verified using the specified ByteBuffer.

(Inherited from SignatureSpi)
EngineUpdate(SByte)

Updates the data to be signed or verified using the specified byte.

(Inherited from SignatureSpi)
EngineVerify(Byte[], Int32, Int32)

Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.

(Inherited from SignatureSpi)
EngineVerify(Byte[])

Verifies the passed-in signature.

(Inherited from SignatureSpi)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetInstance(String, Provider)

Returns a Signature object that implements the specified signature algorithm.

GetInstance(String, String)

Returns a Signature object that implements the specified signature algorithm.

GetInstance(String)

Returns a Signature object that implements the specified signature algorithm.

GetParameter(String)
Obsolete.

Gets the value of the specified algorithm parameter.

InitSign(IPrivateKey, SecureRandom)

Initialize this object for signing.

InitSign(IPrivateKey)

Initialize this object for signing.

InitVerify(Certificate)

Initializes this object for verification, using the public key from the given certificate.

InitVerify(IPublicKey)

Initializes this object for verification.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetParameter(IAlgorithmParameterSpec)

Initializes this signature engine with the specified parameter set.

SetParameter(String, Object)
Obsolete.

Sets the specified algorithm parameter to the specified value.

Sign()

Returns the signature bytes of all the data updated.

Sign(Byte[], Int32, Int32)

Finishes the signature operation and stores the resulting signature bytes in the provided buffer outbuf, starting at offset.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Update(Byte[], Int32, Int32)

Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.

Update(Byte[])

Updates the data to be signed or verified, using the specified array of bytes.

Update(ByteBuffer)

Updates the data to be signed or verified using the specified ByteBuffer.

Update(SByte)

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

Verify(Byte[], Int32, Int32)

Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.

Verify(Byte[])

Verifies the passed-in signature.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to