This chapter provides tutorial notes and example codes on digital signature. Topics include algorithm and steps of signing a document; algorithm and steps of verifying a signature; digital signature generation and verification sample programs; sample signatures of SHA1withRSA and SHA1withDSA algorithms.
Generating and verification digital signatures are done by encrypting and decrypting
the message digest of the input data with private keys and public keys.
JDK provides several digital signature algorithms: SHA1withDSA, SHA1withRSA,
MD2withDSA, and MD2withRSA.
Of course, you must choose a digital signature algorithm that is compatible with
the type of the private key.
Keys are stored in files in encoded formats. The default encoding for private key is
PKCS#8, and the default encoding for public key is X.509.
Sample programs listed in this chapter have been tested with
JDK 1.3.1, 1.4.1 and 1.5.0.
Read my other book "Tutorial Notes on cryptography" for other related topics.