Cryptography Tutorials - Herong's Tutorial Examples - v5.42, by Herong Yang
DsaSignatureGenerator.java Test Results
This section provides test results from DsaSignatureGenerator.java on a binary file with different DSA private keys. DSA digital signature size is 46 bytes when generated with the Java SHA1withDSA algorithm.
Want to see some test output from DsaSignatureGenerator.java? Here is the first test on the DsaSignatureGenerator.class binary file with the DSA 512-bit private key generated in the previous tutorial:
herong> javac DsaSignatureGenerator.java herong> java DsaSignatureGenerator \ dsa_512.pri DsaSignatureGenerator.class dsa_512.sig Private Key Info: Algorithm = DSA Signature Object Info: Algorithm = SHA1withDSA Provider = SUN version 12 Sign Processing Info: Number of input bytes = 2859 Number of output bytes = 46 herong> java HexWriter dsa_512.sig dsa_512.hex Number of input bytes: 46 herong> more dsa_512.hex 302C02141F5BD5A1B756874480D223B7 1CB18A85D8BEE09C02147C9B3CAD3317 A757F8C9CFC51A7925437BA17D0D
My DsaSignatureGenerator.java program seems to be working. A 46-byte digital signature is generated from the DsaSignatureGenerator.class file with a 512-bit DSA private key using the SHA-1 hashing algorithm.
What happens if I run the program again with the input message and the same private key? Is the digital signature going to be different?
herong> java DsaSignatureGenerator \ dsa_512.pri DsaSignatureGenerator.class dsa_512x.sig Private Key Info: Algorithm = DSA Signature Object Info: Algorithm = SHA1withDSA Provider = SUN version 12 Sign Processing Info: Number of input bytes = 2859 Number of output bytes = 46 herong> java HexWriter dsa_512x.sig dsa_512x.hex Number of input bytes: 46 herong> more dsa_512x.hex 302C021459E171244C1A1C23EFE33B72 4464DF8971C436A4021473F09A1EB7DA D1224C6ACE291DDE1B965C735E4E
The output shows that a different digital signature is generated. This proves that a random number, "k", is used in the DSA signature generation process. A different new digital signature will be generated each time the same input message and same private key is used.
Here is the second test with the 1024-bit private key on the same binary file, DsaSignatureGenerator.class:
herong> java DsaSignatureGenerator \ dsa_1024.pri DsaSignatureGenerator.class dsa_1024.sig Private Key Info: Algorithm = DSA Signature Object Info: Algorithm = SHA1withDSA Provider = SUN version 12 Sign Processing Info: Number of input bytes = 2859 Number of output bytes = 46 herong> java HexWriter dsa_1024.sig dsa_1024.hex Number of input bytes: 46 herong> more dsa_1024.hex 302C02147182608511EA79A038806F0A 6206D7D086DCD27B02145496D01B967A 73B9E60626B0523502A4C12697AE
Of course, we are getting a different digital signature. But it has the same length: 46 bytes.
Table of Contents
Introduction to AES (Advanced Encryption Standard)
DES Algorithm - Illustrated with Java Programs
DES Algorithm Java Implementation
DES Algorithm - Java Implementation in JDK JCE
DES Encryption Operation Modes
PHP Implementation of DES - mcrypt
Blowfish - 8-Byte Block Cipher
Secret Key Generation and Management
Cipher - Secret Key Encryption and Decryption
RSA Implementation using java.math.BigInteger Class
Introduction of DSA (Digital Signature Algorithm)
►Java Default Implementation of DSA
DsaKeyGenerator.java - Generating DSA Key Pair
DSA 512-bit and 1024-bit Key Pair Examples
DsaKeyChecker.java - Reading and Checking DSA Keys
Example of DSA Key Parameters and Properties
java.security.Signature - The Data Signing Class
DsaSignatureGenerator.java - Generating DSA Digital Signature
►DsaSignatureGenerator.java Test Results
DsaSignatureVerifier.java - Verifying DSA Digital Signature
DsaSignatureVerifier.java Test Results
Private key and Public Key Pair Generation
PKCS#8/X.509 Private/Public Encoding Standards
Cipher - Public Key Encryption and Decryption
OpenSSL Introduction and Installation
OpenSSL Generating and Managing RSA Keys
OpenSSL Generating and Signing CSR
OpenSSL Validating Certificate Path
"keytool" and "keystore" from JDK
"OpenSSL" Signing CSR Generated by "keytool"
Migrating Keys from "keystore" to "OpenSSL" Key Files
Certificate X.509 Standard and DER/PEM Formats
Migrating Keys from "OpenSSL" Key Files to "keystore"