This section provides a tutorial example on how to run JcaKeyPair.java to generate a DSA private key and public key pair sample. Keys are stored PKCS#8 and X.509 encoding formats.
Here is the result of my first test of JcaKeyPair.java - generating a pair of DSA private key and public key.
It is done with JDK 1.3.1.
Since I am not specifying the provider name,
the implementation of the DSA algorithm provided in the default security package
was selected. Of course, Sun is the provider of the default security package.
The key pair generated from the generateKeyPair() method indeed has two keys,
a private key and a public key.
The private key was written to a file using PKCS#8 format, and the public key
was written to another file using X.509 format.
In order to see the keys, I need to use my other program, HexWriter.java,
to convert binary data to hex numbers. See chapter "Encoding Conversion" for
details.
Here is how to look at DSA key files in hex numbers, 16 bytes per line: