This section describes the data signing class, java.security.Signature, and its major methods like update() and sign().
The java.security.Signature class is an abstract class providing a link to implementation
classes of digital signature algorithms provided by various security package providers.
Major methods in the KeyPairGenerator class:
getInstance() - Returns a Signature object of the specified algorithm from
the implementation of the specified provider. If provider is not specified,
the default implementation is used. This is a static method.
initSign() - Initializes the current Signature object with the specified private key
to be ready to take input data for generating a new signature.
initVerify() - Initializes the current Signature object with the specified public key
to be ready to take input data for verifying an existing signature.
update() - Adds more data to the current Signature object for signature generation or
signature verification.
sign() - Generates a new signature for the input data received so far in the current Signature
object, and returns the signature as a byte array.
It also removes the input data.
verify() - Verifies the input data received so far in the current Signature
object against the specified signature, and returns true or false.
It also removes the input data.
getAlgorithm() - Returns the algorithm name of the current Signature object.
getProvider() - Returns the provider as a Provider object of the current Signature object.
See the next section on how to write a sample program.