Package java.security
Class SignatureSpi
java.lang.Object
java.security.SignatureSpi
- Direct Known Subclasses:
DigestSignatureSpi,DSABase,DSASigner,Signature
public abstract class SignatureSpi extends Object
SignatureSpi is the Service Provider Interface (SPI)
definition for Signature.- See Also:
Signature
-
Field Summary
Fields Modifier and Type Field Description protected SecureRandomappRandomImplementation specific source of randomness. -
Constructor Summary
Constructors Constructor Description SignatureSpi() -
Method Summary
Modifier and Type Method Description Objectclone()Creates and returns a copy of thisObject.protected abstract ObjectengineGetParameter(String param)Deprecated.There is no generally accepted parameter naming convention.protected AlgorithmParametersengineGetParameters()Returns theAlgorithmParametersof thisSignatureSpiinstance.protected abstract voidengineInitSign(PrivateKey privateKey)Initializes thisSignatureSpiinstance for signing, using the private key of the identity whose signature is going to be generated.protected voidengineInitSign(PrivateKey privateKey, SecureRandom random)Initializes thisSignatureSpiinstance for signing, using the private key of the identity whose signature is going to be generated and the specified source of randomness.protected abstract voidengineInitVerify(PublicKey publicKey)Initializes thisSignatureSpiinstance for signature verification, using the public key of the identity whose signature is going to be verified.protected abstract voidengineSetParameter(String param, Object value)Deprecated.protected voidengineSetParameter(AlgorithmParameterSpec params)Sets the specifiedAlgorithmParameterSpec.protected abstract byte[]engineSign()Generates and returns the signature of all updated data.protected intengineSign(byte[] outbuf, int offset, int len)Generates and stores the signature of all updated data in the providedbyte[]at the specified position with the specified length.protected abstract voidengineUpdate(byte b)Updates the data to be verified or to be signed, using the specifiedbyte.protected abstract voidengineUpdate(byte[] b, int off, int len)Updates the data to be verified or to be signed, using the givenbyte[], starting form the specified index for the specified length.protected voidengineUpdate(ByteBuffer input)Updates the data to be verified or to be signed, using the specifiedByteBuffer.protected abstract booleanengineVerify(byte[] sigBytes)Indicates whether the givensigBytescan be verified using the public key or a certificate of the signer.protected booleanengineVerify(byte[] sigBytes, int offset, int length)Indicates whether the givensigBytesstarting at indexoffsetwithlengthbytes can be verified using the public key or a certificate of the signer.
-
Field Details
-
appRandom
Implementation specific source of randomness.
-
-
Constructor Details
-
SignatureSpi
public SignatureSpi()
-
-
Method Details
-
engineInitVerify
Initializes thisSignatureSpiinstance for signature verification, using the public key of the identity whose signature is going to be verified.- Parameters:
publicKey- the public key.- Throws:
InvalidKeyException- ifpublicKeyis not valid.
-
engineInitSign
Initializes thisSignatureSpiinstance for signing, using the private key of the identity whose signature is going to be generated.- Parameters:
privateKey- the private key.- Throws:
InvalidKeyException- ifprivateKeyis not valid.
-
engineInitSign
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyExceptionInitializes thisSignatureSpiinstance 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- theSecureRandomto use.- Throws:
InvalidKeyException- ifprivateKeyis not valid.
-
engineUpdate
Updates the data to be verified or to be signed, using the specifiedbyte.- Parameters:
b- the byte to update with.- Throws:
SignatureException- if thisSignatureSpiinstance is not initialized properly.
-
engineUpdate
Updates the data to be verified or to be signed, using the givenbyte[], starting form the specified index for the specified length.- Parameters:
b- the byte array to update with.off- the start index inbof the data.len- the number of bytes to use.- Throws:
SignatureException- if thisSignatureSpiinstance is not initialized properly.
-
engineUpdate
Updates the data to be verified or to be signed, using the specifiedByteBuffer.- Parameters:
input- theByteBufferto update with.- Throws:
RuntimeException- sinceSignatureExceptionis not specified for this method it throws aRuntimeExceptionif underlyingengineUpdate(byte[], int, int)throwsSignatureException.
-
engineSign
Generates and returns the signature of all updated data.This
SignatureSpiinstance 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 thisSignatureSpiinstance is not initialized properly.
-
engineSign
Generates and stores the signature of all updated data in the providedbyte[]at the specified position with the specified length.This
SignatureSpiinstance 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 inoutbufto store.len- the number of bytes allocated for the signature.- Returns:
- the number of bytes stored in
outbuf. - Throws:
SignatureException- if thisSignatureSpiinstance is not initialized properly.IllegalArgumentException- ifoffsetorlenare not valid in respect tooutbuf.
-
engineVerify
Indicates whether the givensigBytescan be verified using the public key or a certificate of the signer.This
SignatureSpiinstance 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:
trueif the signature was verified,falseotherwise.- Throws:
SignatureException- if thisSignatureSpiinstance is not initialized properly.
-
engineVerify
Indicates whether the givensigBytesstarting at indexoffsetwithlengthbytes can be verified using the public key or a certificate of the signer.This
SignatureSpiinstance 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- thebyte[]containing the signature to verify.offset- the start index insigBytesof the signaturelength- the number of bytes allocated for the signature.- Returns:
trueif the signature was verified,falseotherwise.- Throws:
SignatureException- if thisSignatureSpiinstance is not initialized properly.IllegalArgumentException- ifoffsetorlengthare not valid in respect tosigBytes.
-
engineSetParameter
@Deprecated protected abstract void engineSetParameter(String param, Object value) throws InvalidParameterExceptionDeprecated.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.
-
engineSetParameter
protected void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterExceptionSets the specifiedAlgorithmParameterSpec.- Parameters:
params- the parameter to set.- Throws:
InvalidAlgorithmParameterException- if the parameter is invalid, already set or is not allowed to be changed.
-
engineGetParameters
Returns theAlgorithmParametersof thisSignatureSpiinstance.- Returns:
- the
AlgorithmParametersof thisSignatureSpiinstance, maybenull.
-
engineGetParameter
@Deprecated protected abstract Object engineGetParameter(String param) throws InvalidParameterExceptionDeprecated.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- ifparamis not a valid parameter for thisSignatureSpior an other error occurs.
-
clone
Description copied from class:ObjectCreates and returns a copy of thisObject. 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 callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects.- Overrides:
clonein classObject- Returns:
- a copy of this object.
- Throws:
CloneNotSupportedException- if this object's class does not implement theCloneableinterface.
-