Modifier and Type | Field and Description |
---|---|
java.lang.String |
algorithm
Signature algorithm name.
|
java.lang.String |
digestAlgorithm
Message digest algorithm name.
|
java.lang.String |
keyAlgorithm
Key algorithm name.
|
Constructor and Description |
---|
Signature(java.lang.String algorithm)
Creates a Signature object for the specified algorithm.
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
clean all important content.
|
java.lang.Object |
clone()
Returns a clone if the implementation is cloneable.
|
java.lang.String |
getAlgorithm()
Returns the name of the algorithm for this signature object.
|
static Signature |
getInstance(java.lang.String algorithm)
Algorithm factory, create object by algorithm name that implements the specified algorithm.
|
static Signature |
getInstance(java.lang.String algorithm,
java.security.Provider provider)
Algorithm factory, create object by algorithm name that implements the specified algorithm.
|
static Signature |
getInstance(java.lang.String algorithm,
java.lang.String provider)
Algorithm factory, create object by algorithm name that implements the specified algorithm.
|
java.lang.Object |
getParameter(java.lang.String param)
Deprecated.
|
java.security.AlgorithmParameters |
getParameters()
Returns the parameters used with this signature object.
|
java.security.Provider |
getProvider()
Returns the provider of this object.
|
void |
initSign(java.security.PrivateKey key)
Initialize this object for signing.
|
void |
initSign(java.security.PrivateKey privateKey,
SecureRandom random)
Initialize this object for signing.
|
void |
initVerify(java.security.cert.Certificate certificate)
Initializes this object for verification.
|
void |
initVerify(java.security.PublicKey key)
Initializes this object for verification.
|
void |
setParameter(java.security.spec.AlgorithmParameterSpec params)
Initializes this signature engine with the specified parameter set.
|
void |
setParameter(java.lang.String param,
java.lang.Object value)
Deprecated.
Use
setParameter . |
byte[] |
sign()
Returns the signature bytes of all the data updated.
|
int |
sign(byte[] outbuf,
int offset,
int len)
Finishes the signature operation and stores the resulting signature
bytes in the provided buffer
outbuf , starting at offset . |
java.lang.String |
toString()
Returns a string representation of this signature object.
|
void |
update(byte b)
Updates the data to be signed or verified by a byte.
|
void |
update(byte[] data)
Updates the data to be signed or verified, using the specified array of bytes.
|
void |
update(byte[] data,
int off,
int len)
Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.
|
void |
update(java.nio.ByteBuffer input)
Updates the data to be signed or verified using the specified ByteBuffer.
|
boolean |
verify(byte[] signature)
Verifies the passed-in signature.
|
boolean |
verify(byte[] signature,
int offset,
int length)
Verifies the passed-in signature in the specified array of bytes, starting at the specified offset.
|
public final java.lang.String algorithm
public final java.lang.String keyAlgorithm
public final java.lang.String digestAlgorithm
public Signature(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
algorithm
- the algorithm namejava.security.NoSuchAlgorithmException
- if the specified algorithm is not availablepublic static Signature getInstance(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
Signature.getInstance(String)
.algorithm
- the algorithm name of the algorithm requested.java.security.NoSuchAlgorithmException
- if the specified algorithm is not availablepublic static Signature getInstance(java.lang.String algorithm, java.lang.String provider) throws java.security.NoSuchAlgorithmException
Signature.getInstance(String)
.algorithm
- the algorithm name of the algorithm requested.provider
- unusedjava.security.NoSuchAlgorithmException
- if the specified algorithm is not availablepublic static Signature getInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
Signature.getInstance(String)
.algorithm
- the algorithm name of the algorithm requested.provider
- unusedjava.security.NoSuchAlgorithmException
- if the specified algorithm is not availablepublic java.lang.String getAlgorithm()
public java.security.Provider getProvider()
public void initVerify(java.security.PublicKey key) throws java.security.InvalidKeyException
key
- the public key of the identity whose signature is going to be verified.java.security.InvalidKeyException
- if the key is invalid.public void initVerify(java.security.cert.Certificate certificate) throws java.security.InvalidKeyException
certificate
- certificate of the identity whose signature is going to be verified.java.security.InvalidKeyException
- if the key is invalid.public void initSign(java.security.PrivateKey key) throws java.security.InvalidKeyException
key
- the private key of the identity whose signature is going to be generated.java.security.InvalidKeyException
- if the key is invalid.public void initSign(java.security.PrivateKey privateKey, SecureRandom random) throws java.security.InvalidKeyException
privateKey
- the private key of the identity whose signature is going to be generated.random
- unused the source of randomness for this signature.java.security.InvalidKeyException
- if the key is invalid.public void update(byte b) throws java.security.SignatureException
b
- the byte to use for the update.java.security.SignatureException
- if this signature object is not initialized properly.public void update(byte[] data) throws java.security.SignatureException
data
- the byte array to use for the update.java.security.SignatureException
- if this signature object is not initialized properly.public void update(byte[] data, int off, int len) throws java.security.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.java.security.SignatureException
- if this signature object is not initialized properly.public void update(java.nio.ByteBuffer input) throws java.security.SignatureException
input
- the ByteBufferjava.security.SignatureException
- if this signature object is not initialized properly.public byte[] sign() throws java.security.SignatureException
java.security.SignatureException
- if this signature object is not initialized properly or
if this signature algorithm is unable to process the input data provided.public int sign(byte[] outbuf, int offset, int len) throws java.security.SignatureException
outbuf
, starting at offset
.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
.java.security.SignatureException
- if this signature object 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.public boolean verify(byte[] signature) throws java.security.SignatureException
signature
- the signature bytes to be verified.java.security.SignatureException
- if this signature object 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.public boolean verify(byte[] signature, int offset, int length) throws java.security.SignatureException
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.java.security.SignatureException
- if this signature object 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.public java.lang.String toString()
toString
in class java.lang.Object
@Deprecated public void setParameter(java.lang.String param, java.lang.Object value) throws java.security.InvalidParameterException
setParameter
.param
- the string identifier of the parameter.value
- the parameter value.java.security.InvalidParameterException
- if param is an invalid parameter for this signature algorithm engine.public void setParameter(java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidAlgorithmParameterException
params
- the parametersjava.security.InvalidAlgorithmParameterException
- if the given parameters are inappropriate for this signature enginepublic java.security.AlgorithmParameters getParameters()
@Deprecated public java.lang.Object getParameter(java.lang.String param) throws java.security.InvalidParameterException
param
- the string name of the parameter.java.security.InvalidParameterException
- if param
is an invalid
parameter for this engine, or another exception occurs while
trying to get this parameter.setParameter(String, Object)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if this is called
on an implementation that does not support Cloneable
.