java.lang.Object | +--java.security.SignatureSpi | +--java.security.Signature
Untamed:
protected static int
SIGN
state value, signifying that
this signature object has been initialized for signing.
protected static int
UNINITIALIZED
state value, signifying that
this signature object has not yet been initialized.
protected static int
VERIFY
state value, signifying that
this signature object has been initialized for verification.
static Signature
getInstance(String algorithm)
static Signature
getInstance(String algorithm,
Provider provider)
static Signature
getInstance(String algorithm,
String provider)
AlgorithmParameters
getParameters()
void
initSign(PrivateKey privateKey,
SecureRandom random)
void
initVerify(java.security.cert.Certificate certificate)
void
setParameter(AlgorithmParameterSpec params)
int
sign(byte[] outbuf,
int offset,
int len)
outbuf, starting at
offset.
String
toString()
void
update(byte[] data)
void
update(byte[] data,
int off,
int len)
boolean
verify(byte[] signature,
int offset,
int length)
engineGetParameter, engineGetParameters, engineInitSign, engineInitSign, engineInitVerify, engineSetParameter, engineSetParameter, engineSign, engineSign, engineUpdate, engineUpdate, engineVerify, engineVerify
private static final boolean debug
private String algorithm
private Provider provider
protected static final int UNINITIALIZED
state value, signifying that
this signature object has not yet been initialized.
protected static final int SIGN
state value, signifying that
this signature object has been initialized for signing.
protected static final int VERIFY
state value, signifying that
this signature object has been initialized for verification.
protected int state
protected Signature(String algorithm)
algorithm - the standard string name of the algorithm.
See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for information about standard algorithm names.public static Signature getInstance(String algorithm) throws NoSuchAlgorithmException
algorithm - the standard name of the algorithm requested.
See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for information about standard algorithm names.
NoSuchAlgorithmExceptionpublic static Signature getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - the name of the algorithm requested.
See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for information about standard algorithm names.provider - the name of the provider.
NoSuchAlgorithmException
NoSuchProviderExceptionProviderpublic static Signature getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
provider doesn't have to be registered.
algorithm - the name of the algorithm requested.
See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for information about standard algorithm names.provider - the provider.
NoSuchAlgorithmExceptionProviderpublic final Provider getProvider()
public final void initVerify(PublicKey publicKey) throws InvalidKeyException
publicKey - the public key of the identity whose signature is
going to be verified.
InvalidKeyExceptionpublic final void initVerify(java.security.cert.Certificate certificate) throws InvalidKeyException
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.
certificate - the certificate of the identity whose signature is
going to be verified.
InvalidKeyExceptionpublic final void initSign(PrivateKey privateKey) throws InvalidKeyException
privateKey - the private key of the identity whose signature
is going to be generated.
InvalidKeyExceptionpublic final void initSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException
privateKey - the private key of the identity whose signature
is going to be generated.random - the source of randomness for this signature.
InvalidKeyExceptionpublic final byte[] sign() throws SignatureException
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.
SignatureExceptionpublic final int sign(byte[] outbuf, int offset, int len) throws SignatureException
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.
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.
outbuf.
SignatureExceptionpublic final boolean verify(byte[] signature) throws SignatureException
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.
signature - the signature bytes to be verified.
SignatureExceptionpublic final boolean verify(byte[] signature, int offset, int length) throws SignatureException
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.
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.
SignatureExceptionpublic final void update(byte b) throws SignatureException
b - the byte to use for the update.
SignatureExceptionpublic final void update(byte[] data) throws SignatureException
data - the byte array to use for the update.
SignatureExceptionpublic final void update(byte[] data, int off, int len) throws SignatureException
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.
SignatureExceptionpublic final String getAlgorithm()
public String toString()
public final void setParameter(String param, Object value) throws InvalidParameterException
setParameter.
param - the string identifier of the parameter.value - the parameter value.
InvalidParameterExceptiongetParameter(java.lang.String)public final void setParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
params - the parameters
InvalidAlgorithmParameterExceptiongetParameters()public final AlgorithmParameters getParameters()
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.
setParameter(AlgorithmParameterSpec)public final Object getParameter(String param) throws InvalidParameterException
param - the string name of the parameter.
InvalidParameterExceptionsetParameter(String, Object)public Object clone() throws CloneNotSupportedException
clone in class SignatureSpiCloneNotSupportedExceptionprivate static void debug(String statement)
private static void debug(Exception e)