Build 1.1_r1 (from source)

java.security
Class SignatureSpi

java.lang.Object
  extended by java.security.SignatureSpi
Direct Known Subclasses:
Signature

public abstract class SignatureSpi
extends Object

SignatureSpi is the Service Provider Interface (SPI) definition for Signature.

Since:
Android 1.0
See Also:
Signature

Field Summary
protected  SecureRandom appRandom
          Implementation specific source of randomness.
 
Constructor Summary
SignatureSpi()
           
 
Method Summary
 Object clone()
          Creates and returns a copy of this Object.
protected abstract  Object engineGetParameter(String param)
          Deprecated. There is no generally accepted parameter naming convention.
protected  AlgorithmParameters engineGetParameters()
          Returns the AlgorithmParameters of this SignatureSpi instance.
protected abstract  void engineInitSign(PrivateKey privateKey)
          Initializes this SignatureSpi instance for signing, using the private key of the identity whose signature is going to be generated.
protected  void engineInitSign(PrivateKey privateKey, SecureRandom random)
          Initializes this SignatureSpi instance for signing, using the private key of the identity whose signature is going to be generated and the specified source of randomness.
protected abstract  void engineInitVerify(PublicKey publicKey)
          Initializes this SignatureSpi instance for signature verification, using the public key of the identity whose signature is going to be verified.
protected  void engineSetParameter(AlgorithmParameterSpec params)
          Sets the specified AlgorithmParameterSpec.
protected abstract  void engineSetParameter(String param, Object value)
          Deprecated. Use engineSetParameter(AlgorithmParameterSpec)
protected abstract  byte[] engineSign()
          Generates and returns the signature of all updated data.
protected  int engineSign(byte[] outbuf, int offset, int len)
          Generates and stores the signature of all updated data in the provided byte[] at the specified position with the specified length.
protected abstract  void engineUpdate(byte b)
          Updates the data to be verified or to be signed, using the specified byte.
protected abstract  void engineUpdate(byte[] b, int off, int len)
          Updates the data to be verified or to be signed, using the given byte[], starting form the specified index for the specified length.
protected  void engineUpdate(ByteBuffer input)
          Updates the data to be verified or to be signed, using the specified ByteBuffer.
protected abstract  boolean engineVerify(byte[] sigBytes)
          Indicates whether the given sigBytes can be verified using the public key or a certificate of the signer.
protected  boolean engineVerify(byte[] sigBytes, int offset, int length)
          Indicates whether the given sigBytes starting at index offset with length bytes can be verified using the public key or a certificate of the signer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appRandom

protected SecureRandom appRandom
Implementation specific source of randomness.

Since:
Android 1.0
Constructor Detail

SignatureSpi

public SignatureSpi()
Method Detail

engineInitVerify

protected abstract void engineInitVerify(PublicKey publicKey)
                                  throws InvalidKeyException
Initializes this SignatureSpi instance for signature verification, using the public key of the identity whose signature is going to be verified.

Parameters:
publicKey - the public key.
Throws:
InvalidKeyException - if publicKey is not valid.
Since:
Android 1.0

engineInitSign

protected abstract void engineInitSign(PrivateKey privateKey)
                                throws InvalidKeyException
Initializes this SignatureSpi instance for signing, using the private key of the identity whose signature is going to be generated.

Parameters:
privateKey - the private key.
Throws:
InvalidKeyException - if privateKey is not valid.
Since:
Android 1.0

engineInitSign

protected void engineInitSign(PrivateKey privateKey,
                              SecureRandom random)
                       throws InvalidKeyException
Initializes this SignatureSpi instance for signing, using the private key of the identity whose signature is going to be generated and the specified source of randomness.

Parameters:
privateKey - the private key.
random - the SecureRandom to use.
Throws:
InvalidKeyException - if privateKey is not valid.
Since:
Android 1.0

engineUpdate

protected abstract void engineUpdate(byte b)
                              throws SignatureException
Updates the data to be verified or to be signed, using the specified byte.

Parameters:
b - the byte to update with.
Throws:
SignatureException - if this SignatureSpi instance is not initialized properly.
Since:
Android 1.0

engineUpdate

protected abstract void engineUpdate(byte[] b,
                                     int off,
                                     int len)
                              throws SignatureException
Updates the data to be verified or to be signed, using the given byte[], starting form the specified index for the specified length.

Parameters:
b - the byte array to update with.
off - the start index in b of the data.
len - the number of bytes to use.
Throws:
SignatureException - if this SignatureSpi instance is not initialized properly.
Since:
Android 1.0

engineUpdate

protected void engineUpdate(ByteBuffer input)
Updates the data to be verified or to be signed, using the specified ByteBuffer.

Parameters:
input - the ByteBuffer to update with.
Throws:
RuntimeException - since SignatureException is not specified for this method it throws a RuntimeException if underlying engineUpdate(byte[], int, int) throws SignatureException.
Since:
Android 1.0

engineSign

protected abstract byte[] engineSign()
                              throws SignatureException
Generates and returns the signature of all updated data.

This SignatureSpi instance is reset to the state of its last initialization for signing and thus can be used for another signature from the same identity.

Returns:
the signature of all updated data.
Throws:
SignatureException - if this SignatureSpi instance is not initialized properly.
Since:
Android 1.0

engineSign

protected int engineSign(byte[] outbuf,
                         int offset,
                         int len)
                  throws SignatureException
Generates and stores the signature of all updated data in the provided byte[] at the specified position with the specified length.

This SignatureSpi instance is reset to the state of its last initialization for signing and thus can be used for another signature from the same identity.

Parameters:
outbuf - the buffer to store the signature.
offset - the index of the first byte in outbuf to store.
len - the number of bytes allocated for the signature.
Returns:
the number of bytes stored in outbuf.
Throws:
SignatureException - if this SignatureSpi instance is not initialized properly.
IllegalArgumentException - if offset or len are not valid in respect to outbuf.
Since:
Android 1.0

engineVerify

protected abstract boolean engineVerify(byte[] sigBytes)
                                 throws SignatureException
Indicates whether the given sigBytes can be verified using the public key or a certificate of the signer.

This SignatureSpi instance is reset to the state of its last initialization for verifying and thus can be used to verify another signature of the same signer.

Parameters:
sigBytes - the signature to verify.
Returns:
true if the signature was verified, false otherwise.
Throws:
SignatureException - if this SignatureSpi instance is not initialized properly.
Since:
Android 1.0

engineVerify

protected boolean engineVerify(byte[] sigBytes,
                               int offset,
                               int length)
                        throws SignatureException
Indicates whether the given sigBytes starting at index offset with length bytes can be verified using the public key or a certificate of the signer.

This SignatureSpi instance is reset to the state of its last initialization for verifying and thus can be used to verify another signature of the same signer.

Parameters:
sigBytes - the byte[] containing the signature to verify.
offset - the start index in sigBytes of the signature
length - the number of bytes allocated for the signature.
Returns:
true if the signature was verified, false otherwise.
Throws:
SignatureException - if this SignatureSpi instance is not initialized properly.
IllegalArgumentException - if offset or length are not valid in respect to sigBytes.
Since:
Android 1.0

engineSetParameter

@Deprecated
protected abstract void engineSetParameter(String param,
                                                      Object value)
                                    throws InvalidParameterException
Deprecated. Use engineSetParameter(AlgorithmParameterSpec)

Sets the specified parameter to the given value.

Parameters:
param - the name of the parameter.
value - the parameter value.
Throws:
InvalidParameterException - if the parameter is invalid, already set or is not allowed to be changed.
Since:
Android 1.0

engineSetParameter

protected void engineSetParameter(AlgorithmParameterSpec params)
                           throws InvalidAlgorithmParameterException
Sets the specified AlgorithmParameterSpec.

Parameters:
params - the parameter to set.
Throws:
InvalidAlgorithmParameterException - if the parameter is invalid, already set or is not allowed to be changed.
Since:
Android 1.0

engineGetParameters

protected AlgorithmParameters engineGetParameters()
Returns the AlgorithmParameters of this SignatureSpi instance.

Returns:
the AlgorithmParameters of this SignatureSpi instance, maybe null.
Since:
Android 1.0

engineGetParameter

@Deprecated
protected abstract Object engineGetParameter(String param)
                                      throws InvalidParameterException
Deprecated. There is no generally accepted parameter naming convention.

Returns the value of the parameter with the specified name.

Parameters:
param - the name of the requested parameter value.
Returns:
the value of the parameter with the specified name, maybe null.
Throws:
InvalidParameterException - if param is not a valid parameter for this SignatureSpi or an other error occurs.
Since:
Android 1.0

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: Object
Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Overrides:
clone in class Object
Returns:
a copy of this object.
Throws:
CloneNotSupportedException - if this object's class does not implement the Cloneable interface.

Build 1.1_r1 (from source)

Please submit a feedback, bug or feature