public abstract class Signature extends java.lang.Object
Signatureclass 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.
Signature object can be used to generate and
verify digital signatures.
There are three phases to the use of a
object for verifying a signature:
Depending on the type of initialization, this will update the bytes to be verified.
|Modifier and Type||Method and Description|
Initializes this object for verification.
Updates the data to be verified, using the specified array of bytes, starting at the specified offset.
Verifies the passed-in signature.
public static Signature getInstance(java.lang.String algorithm) throws NoSuchAlgorithmException
Signatureobject that implements the specified digest algorithm.
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.
NoSuchAlgorithmException- if the algorithm is not available in the environment.
public final void initVerify(PublicKey publicKey) throws InvalidKeyException
publicKey- the public key of the identity whose signature is going to be verified.
InvalidKeyException- if the key is invalid.
public 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
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
signature- the signature bytes to be verified.
SignatureException- if this signature object is not initialized properly, or the passed-in signature is improperly encoded or of the wrong type, etc.
public 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.
SignatureException- if this signature object is not initialized properly.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Use is subject to License Terms. Your use of this web site or any of its contents or software indicates your agreement to be bound by these License Terms.