java.security
Class SignatureSpi

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.SignatureSpi
Direct Known Subclasses:
Signature sample code for java.security.Signature definition code for java.security.Signature

public abstract class SignatureSpi
extends Object sample code for java.lang.Object definition code for java.lang.Object

This class defines the Service Provider Interface (SPI) for the Signature class, which is used to provide the functionality of a digital signature algorithm. Digital signatures are used for authentication and integrity assurance of digital data. .

All the abstract methods in this class must be implemented by each cryptographic service provider who wishes to supply the implementation of a particular signature algorithm.

See Also:
Signature sample code for java.security.Signature definition code for java.security.Signature

Field Summary
protected  SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom appRandom sample code for java.security.SignatureSpi.appRandom definition code for java.security.SignatureSpi.appRandom
          Application-specified source of randomness.
 
Constructor Summary
SignatureSpi sample code for java.security.SignatureSpi.SignatureSpi() definition code for java.security.SignatureSpi.SignatureSpi() ()
           
 
Method Summary
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for java.security.SignatureSpi.clone() definition code for java.security.SignatureSpi.clone() ()
          Returns a clone if the implementation is cloneable.
protected abstract  Object sample code for java.lang.Object definition code for java.lang.Object engineGetParameter sample code for java.security.SignatureSpi.engineGetParameter(java.lang.String) definition code for java.security.SignatureSpi.engineGetParameter(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  param)
          Deprecated.  
protected  AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters engineGetParameters sample code for java.security.SignatureSpi.engineGetParameters() definition code for java.security.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.
protected abstract  void engineInitSign sample code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey) definition code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey) (PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  privateKey)
          Initializes this signature object with the specified private key for signing operations.
protected  void 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) (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)
          Initializes this signature object with the specified private key and source of randomness for signing operations.
protected abstract  void engineInitVerify sample code for java.security.SignatureSpi.engineInitVerify(java.security.PublicKey) definition code for java.security.SignatureSpi.engineInitVerify(java.security.PublicKey) (PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  publicKey)
          Initializes this signature object with the specified public key for verification operations.
protected  void engineSetParameter sample code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) (AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  params)
          This method is overridden by providers to initialize this signature engine with the specified parameter set.
protected abstract  void 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) (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. Replaced by engineSetParameter sample code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) .
protected abstract  byte[] engineSign sample code for java.security.SignatureSpi.engineSign() definition code for java.security.SignatureSpi.engineSign() ()
          Returns the signature bytes of all the data updated so far.
protected  int engineSign sample code for java.security.SignatureSpi.engineSign(byte[], int, int) definition code for java.security.SignatureSpi.engineSign(byte[], int, int) (byte[] outbuf, int offset, int len)
          Finishes this signature operation and stores the resulting signature bytes in the provided buffer outbuf, starting at offset.
protected abstract  void engineUpdate sample code for java.security.SignatureSpi.engineUpdate(byte) definition code for java.security.SignatureSpi.engineUpdate(byte) (byte b)
          Updates the data to be signed or verified using the specified byte.
protected abstract  void engineUpdate sample code for java.security.SignatureSpi.engineUpdate(byte[], int, int) definition code for java.security.SignatureSpi.engineUpdate(byte[], int, int) (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.
protected  void engineUpdate sample code for java.security.SignatureSpi.engineUpdate(java.nio.ByteBuffer) definition code for java.security.SignatureSpi.engineUpdate(java.nio.ByteBuffer) (ByteBuffer sample code for java.nio.ByteBuffer definition code for java.nio.ByteBuffer  input)
          Updates the data to be signed or verified using the specified ByteBuffer.
protected abstract  boolean engineVerify sample code for java.security.SignatureSpi.engineVerify(byte[]) definition code for java.security.SignatureSpi.engineVerify(byte[]) (byte[] sigBytes)
          Verifies the passed-in signature.
protected  boolean engineVerify sample code for java.security.SignatureSpi.engineVerify(byte[], int, int) definition code for java.security.SignatureSpi.engineVerify(byte[], int, int) (byte[] sigBytes, 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.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() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , 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

appRandom sample code for java.security.SignatureSpi.appRandom

protected SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  appRandom
Application-specified source of randomness.

Constructor Detail

SignatureSpi sample code for java.security.SignatureSpi() definition code for java.security.SignatureSpi()

public SignatureSpi()
Method Detail

engineInitVerify sample code for java.security.SignatureSpi.engineInitVerify(java.security.PublicKey) definition code for java.security.SignatureSpi.engineInitVerify(java.security.PublicKey)

protected abstract void engineInitVerify(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 signature object with the specified public key for verification operations.

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 improperly encoded, parameters are missing, and so on.

engineInitSign sample code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey) definition code for java.security.SignatureSpi.engineInitSign(java.security.PrivateKey)

protected abstract void engineInitSign(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 
Initializes this signature object with the specified private key for signing operations.

Parameters:
privateKey - the private key of the identity whose signature will be generated.
Throws:
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - if the key is improperly encoded, parameters are missing, and so on.

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)

protected void engineInitSign(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 
Initializes this signature object with the specified private key and source of randomness for signing operations.

This concrete method has been added to this previously-defined abstract class. (For backwards compatibility, it cannot be abstract.)

Parameters:
privateKey - the private key of the identity whose signature will be generated.
random - the source of randomness
Throws:
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - if the key is improperly encoded, parameters are missing, and so on.

engineUpdate sample code for java.security.SignatureSpi.engineUpdate(byte) definition code for java.security.SignatureSpi.engineUpdate(byte)

protected abstract void engineUpdate(byte b)
                              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 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 the engine is not initialized properly.

engineUpdate sample code for java.security.SignatureSpi.engineUpdate(byte[], int, int) definition code for java.security.SignatureSpi.engineUpdate(byte[], int, int)

protected abstract void engineUpdate(byte[] b,
                                     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:
b - 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 the engine is not initialized properly

engineUpdate sample code for java.security.SignatureSpi.engineUpdate(java.nio.ByteBuffer) definition code for java.security.SignatureSpi.engineUpdate(java.nio.ByteBuffer)

protected void engineUpdate(ByteBuffer sample code for java.nio.ByteBuffer definition code for java.nio.ByteBuffer  input)
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:
input - the ByteBuffer
Since:
1.5

engineSign sample code for java.security.SignatureSpi.engineSign() definition code for java.security.SignatureSpi.engineSign()

protected abstract byte[] engineSign()
                              throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Returns the signature bytes of all the data updated so far. The format of the signature depends on the underlying signature scheme.

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 the engine is not initialized properly or if this signature algorithm is unable to process the input data provided.

engineSign sample code for java.security.SignatureSpi.engineSign(byte[], int, int) definition code for java.security.SignatureSpi.engineSign(byte[], int, int)

protected int engineSign(byte[] outbuf,
                         int offset,
                         int len)
                  throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Finishes this 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.

The signature implementation is reset to its initial state (the state it was in after a call to one of the engineInitSign methods) and can be reused to generate further signatures with the same private key. This method should be abstract, but we leave it concrete for binary compatibility. Knowledgeable providers should override this method.

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. Both this default implementation and the SUN provider do not return partial digests. If the value of this parameter is less than the actual signature length, this method will throw a SignatureException. This parameter is ignored if its value is greater than or equal to the actual signature length.
Returns:
the number of bytes placed into outbuf
Throws:
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - if the engine 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

engineVerify sample code for java.security.SignatureSpi.engineVerify(byte[]) definition code for java.security.SignatureSpi.engineVerify(byte[])

protected abstract boolean engineVerify(byte[] sigBytes)
                                 throws SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Verifies the passed-in signature.

Parameters:
sigBytes - 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 the engine 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.

engineVerify sample code for java.security.SignatureSpi.engineVerify(byte[], int, int) definition code for java.security.SignatureSpi.engineVerify(byte[], int, int)

protected boolean engineVerify(byte[] sigBytes,
                               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.

Note: Subclasses should overwrite the default implementation.

Parameters:
sigBytes - 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 the engine 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.

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)

@Deprecated
protected abstract void engineSetParameter(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. Replaced by engineSetParameter sample code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.SignatureSpi.engineSetParameter(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.

engineSetParameter sample code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec) definition code for java.security.SignatureSpi.engineSetParameter(java.security.spec.AlgorithmParameterSpec)

protected void engineSetParameter(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 

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

Parameters:
params - the parameters
Throws:
UnsupportedOperationException sample code for java.lang.UnsupportedOperationException definition code for java.lang.UnsupportedOperationException - if this method is not overridden by a provider
InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException - if this method is overridden by a provider and the the given parameters are inappropriate for this signature engine

engineGetParameters sample code for java.security.SignatureSpi.engineGetParameters() definition code for java.security.SignatureSpi.engineGetParameters()

protected AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters  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.

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

Returns:
the parameters used with this signature engine, or null if this signature engine does not use any parameters
Throws:
UnsupportedOperationException sample code for java.lang.UnsupportedOperationException definition code for java.lang.UnsupportedOperationException - if this method is not overridden by a provider

engineGetParameter sample code for java.security.SignatureSpi.engineGetParameter(java.lang.String) definition code for java.security.SignatureSpi.engineGetParameter(java.lang.String)

@Deprecated
protected abstract Object sample code for java.lang.Object definition code for java.lang.Object  engineGetParameter(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.

clone sample code for java.security.SignatureSpi.clone() definition code for java.security.SignatureSpi.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.lang.Object.clone() definition code for java.lang.Object.clone() in class Object sample code for java.lang.Object definition code for java.lang.Object
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