Signaturepublic abstract class Signature extends Object This 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-1. The DSA algorithm using the
SHA-1 message digest algorithm can be specified as SHA1withDSA.
In the case of RSA, there are multiple choices for the message digest
algorithm, so the signing algorithm could be specified as, for example,
MD2withRSA, MD5withRSA, or SHA1withRSA.
The algorithm name must be specified, as there is no default.
When an algorithm name is specified, the system will
determine if there is an implementation of the algorithm requested
available in the environment, and if there is more than one, if
there is a preferred one.
A Signature object can be used to generate and
verify digital signatures.
There are three phases to the use of a Signature
object for verifying a signature:
- Initialization, with a public key, which initializes the
signature for verification
- Updating
Depending on the type of initialization, this will update the
bytes to be verified.
- Verifying a signature on all updated bytes.
|
Fields Summary |
---|
com.sun.midp.crypto.Signature | signSignature implementation. |
Constructors Summary |
---|
Signature(String algorithm)Creates a Signature object for the specified algorithm.
|
Methods Summary |
---|
public static java.security.Signature | getInstance(java.lang.String algorithm)Generates a Signature object that implements
the specified digest
algorithm.
try {
return new SignatureImpl(algorithm,
com.sun.midp.crypto.Signature.getInstance(algorithm));
} catch (com.sun.midp.crypto.NoSuchAlgorithmException e) {
throw new NoSuchAlgorithmException(e.getMessage());
}
| public final void | initVerify(java.security.PublicKey publicKey)Initializes this object for verification. If this method is called
again with a different argument, it negates the effect
of this call.
if (! (publicKey instanceof RSAPublicKey)) {
throw new InvalidKeyException();
}
try {
sign.initVerify(((RSAPublicKey)publicKey).getKey());
} catch (com.sun.midp.crypto.InvalidKeyException e) {
throw new InvalidKeyException(e.getMessage());
}
| public final void | update(byte[] data, int off, int len)Updates the data to be verified, using the specified
array of bytes, starting at the specified offset.
try {
sign.update(data, off, len);
} catch (com.sun.midp.crypto.SignatureException e) {
throw new SignatureException(e.getMessage());
}
| public final boolean | verify(byte[] signature)Verifies the passed-in signature.
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 .
try {
return sign.verify(signature);
} catch (com.sun.midp.crypto.SignatureException e) {
throw new SignatureException(e.getMessage());
}
|
|