Signature
class is used to provide applications the functionality
of a digital signature algorithm. Digital signatures are used for
authentication and integrity assurance of digital data.
The signature algorithm can be, among others, the NIST standard
DSA, using DSA and SHA-256. The DSA algorithm using the
SHA-256 message digest algorithm can be specified as SHA256withDSA
.
In the case of RSA the signing algorithm could be specified as, for example,
SHA256withRSA
.
The algorithm name must be specified, as there is no default.
A Signature
object can be used to generate and verify digital
signatures.
There are three phases to the use of a Signature
object for
either signing data or verifying a signature:
initVerify
), or
initSign(PrivateKey)
and initSign(PrivateKey, SecureRandom)
).
Depending on the type of initialization, this will update the
bytes to be signed or verified. See the
update
methods.
sign
methods and the verify
method.
Note that this class is abstract and extends from
SignatureSpi
for historical reasons.
Application developers should only take notice of the methods defined in
this Signature
class; all the methods in
the superclass are intended for cryptographic service providers who wish to
supply their own implementations of digital signature algorithms.
Every implementation of the Java platform is required to support the
following standard Signature
algorithms:
SHA1withDSA
SHA256withDSA
SHA1withRSA
SHA256withRSA
Modifier and Type | Class and Description |
---|---|
private static class | |
private static class |
Modifier and Type | Field and Description |
---|---|
private String | |
private static final Debug | |
private static final Debug | |
pack-priv Provider | |
private static final String | |
private static final String | |
private static final List | |
protected static final int | |
private static final Map | |
private static final boolean | |
protected int | state
Current state of this |
protected static final int | UNINITIALIZED
Possible |
protected static final int |
Access | Constructor and Description |
---|---|
protected | Signature(String
the standard string name of the algorithm.
See the Signature section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm)Creates a |
Modifier and Type | Method and Description |
---|---|
pack-priv void | |
public Object | Returns: a clone if the implementation is cloneable.Overrides java. Returns a clone if the implementation is cloneable. |
public final String | Returns: the name of the algorithm for thisSignature object.Returns the name of the algorithm for this |
public static Signature | Returns: the newSignature objectthe standard name of the algorithm requested.
See the Signature section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm)Returns a |
private static Signature | |
public static Signature | Returns: the newSignature objectthe name of the algorithm requested.
See the Signature section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm, String the name of the provider. provider)Returns a |
public static Signature | Returns: the newSignature objectthe name of the algorithm requested.
See the Signature section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm, Provider the provider. provider)Returns a |
private static Signature | |
public final Object | Returns: the object that represents the parameter value, ornull if
there is none.the string name of the parameter. param)
Deprecated
Gets the value of the specified algorithm parameter. |
public final AlgorithmParameters | Returns: the parameters used with thisSignature object,
or null Returns the parameters used with this |
public final Provider | Returns: the provider of thisSignature objectReturns the provider of this |
private String | |
private static PublicKey | |
public final void | initSign(PrivateKey
the private key of the identity whose signature
is going to be generated. privateKey)Initialize this object for signing. |
public final void | initSign(PrivateKey
the private key of the identity whose signature
is going to be generated privateKey, SecureRandom the source of randomness for this random)Signature objectInitialize this object for signing. |
pack-priv final void | initSign(PrivateKey
the private key of the identity whose signature
is going to be generated privateKey, AlgorithmParameterSpec the parameters used for generating signature params, SecureRandom the source of randomness for this random)Signature objectInitialize this object for signing. |
public final void | initVerify(PublicKey
the public key of the identity whose signature is
going to be verified. publicKey)Initializes this object for verification. |
pack-priv final void | initVerify(PublicKey
the public key of the identity whose signature is
going to be verified publicKey, AlgorithmParameterSpec the parameters used for verifying this params)Signature
objectInitialize this object for verification. |
public final void | initVerify(Certificate
the certificate of the identity whose signature is
going to be verified. certificate)Initializes this object for verification, using the public key from the given certificate. |
pack-priv final void | initVerify(Certificate
the certificate of the identity whose signature is
going to be verified certificate, AlgorithmParameterSpec the parameters used for verifying this params)Signature
objectInitializes this object for verification, using the public key from the given certificate. |
private static boolean | |
public final void | setParameter(String
the string identifier of the parameter param, Object the parameter value value)
Deprecated
Use
setParameter .
Sets the specified algorithm parameter to the specified value. |
public final void | setParameter(AlgorithmParameterSpec
the parameter values params)Initializes this |
public final byte[] | Returns: the signature bytes of the signing operation's result.Returns the signature bytes of all the data updated. |
public final int | Returns: the number of bytes placed intooutbuf .buffer for the signature result. outbuf, int offset into offset, int outbuf where the signature is
stored.number of bytes within len)outbuf allotted for the
signature.Finishes the signature operation and stores the resulting signature
bytes in the provided buffer |
public String | Returns: a string representation of thisSignature object.Overrides java. Returns a string representation of this |
public final void | |
public final void | update(byte[]
the byte array to use for the update. data)Updates the data to be signed or verified, using the specified array of bytes. |
public final void | update(byte[]
the array of bytes. data, int the offset to start from in the array of bytes. off, int the number of bytes to use, starting at offset. len)Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset. |
public final void | update(ByteBuffer
the ByteBuffer data)Updates the data to be signed or verified using the specified ByteBuffer. |
public final boolean | Returns: true if the signature was verified, false if not.the signature bytes to be verified. signature)Verifies the passed-in signature. |
public final boolean | Returns: true if the signature was verified, false if not.the signature bytes to be verified. signature, int the offset to start from in the array of bytes. offset, int the number of bytes to use, starting at offset. length)Verifies the passed-in signature in the specified array of bytes, starting at the specified offset. |