JDK Tutorials - Herong's Tutorial Examples - Version 6.02, by Dr. Herong Yang
Signature Test Program Result
This section provides test result of JcaSignatureTest.java with SHA1withDSA and SHA1withRSA digital signature algorithms.
Here is the result of my first test of JcaSignatureTest.java with the SHA1withDSA algorithm. It was done with JDK 1.8.
>javac -classpath . JcaSignatureTest.java >java -cp . JcaSignatureTest JcaSignatureTest.class sign.dsa DSA SHA1withDSA Signature Object Info: Algorithm = SHA1withDSA Provider = SUN version 1.8 Sign Processing Info: Number of input bytes = 4022 Number of output bytes = 47 Signature Object Info: Algorithm = SHA1withDSA Provider = SUN version 1.8 Verify Processing Info: Number of input bytes = 4022 Verification result = true >java HexWriter sign.dsa sign_dsa.hex type sign_dsa.hex 302D02141DE6EF6B92A5A2539D10B190 DE3910C8FB9AD27B02150084B5D4EB2A 1079FFD20BEA187C842F954169B243
The program seems to be working:
Of course, you can choose other combinations of different key pair generation algorithms and message digest algorithms. For example, SHA1withRSA:
>java -cp . JcaSignatureTest JcaSignatureTest.class sign.rsa RSA SHA1withRSA Signature Object Info: Algorithm = SHA1withRSA Provider = SunRsaSign version 1.8 Sign Processing Info: Number of input bytes = 4022 Number of output bytes = 64 Signature Object Info: Algorithm = SHA1withRSA Provider = SunRsaSign version 1.8 Verify Processing Info: Number of input bytes = 4022 Verification result = true >java -cp . JcaSignatureTest JcaSignatureTest.class sign_2.rsa RSA MD5withRSA Signature Object Info: Algorithm = MD5withRSA Provider = SunRsaSign version 1.8 Sign Processing Info: Number of input bytes = 4022 Number of output bytes = 64 Signature Object Info: Algorithm = MD5withRSA Provider = SunRsaSign version 1.8 Verify Processing Info: Number of input bytes = 4022 Verification result = true >java -cp . JcaSignatureTest JcaSignatureTest.class sign_3.rsa RSA MD2withRSA Signature Object Info: Algorithm = MD2withRSA Provider = SunRsaSign version 1.8 Sign Processing Info: Number of input bytes = 4022 Number of output bytes = 64 Signature Object Info: Algorithm = MD2withRSA Provider = SunRsaSign version 1.8 Verify Processing Info: Number of input bytes = 4022 Verification result = true
This sample program generates the signature and verifies the signature in single program. But in the real world, we must have at least two programs, one to be used by the sender of the date to generate the signature, and the other to be used by the receiver to verify the signature.
Last update: 2014.
Table of Contents
Downloading and Installing JDK 1.8.0 on Windows
Downloading and Installing JDK 1.7.0 on Windows
Downloading and Installing JDK 1.6.2 on Windows
Date, Time and Calendar Classes
Date and Time Object and String Conversion
Number Object and Numeric String Conversion
Locales, Localization Methods and Resource Bundles
Calling and Importing Classes Defined in Unnamed Packages
HashSet, Vector, HashMap and Collection Classes
Character Set Encoding Classes and Methods
Encoding Conversion Programs for Encoded Text Files
Datagram Network Communication
DOM (Document Object Model) - API for XML Files
DTD (Document Type Definition) - XML Validation
XSD (XML Schema Definition) - XML Validation
XSL (Extensible Stylesheet Language)
Message Digest Algorithm Implementations in JDK
Private key and Public Key Pair Generation
PKCS#8/X.509 Private/Public Encoding Standards
►Digital Signature Algorithm and Sample Program
The Signing Process and the Verification Process
java.security.Signature - The Data Signing Class
JcaSignatureTest.java - Signature Test Program
►Signature Test Program Result
JcaSign.java - Signature Generation Sample Program
JcaVerify.java - Signature Verification Sample Program
"keytool" Commands and "keystore" Files
KeyStore and Certificate Classes
Secret Key Generation and Management
Cipher - Secret Key Encryption and Decryption
The SSL (Secure Socket Layer) Protocol
SSL Socket Communication Testing Programs