Reading DSA Private and Public Key Files

This section provides a tutorial example on running the test program JcaKeyFactoryTest.java to generate, write, read and convert DSA private and public keys.

Here is the result of my first test on JcaKeyFactoryTest.java for DSA private and public keys. It was done with JDK 1.8.

>javac -classpath . JcaKeyFactoryTest.java

>java -cp . JcaKeyFactoryTest 512 dsa DSA

KeyPairGenerator Object Info:
Algorithm = DSA
Provider = SUN version 1.8
Key Size = 512
toString = sun.security.provider.DSAKeyPairGenerator@a987ac

Private Key Info:
Algorithm = DSA
Saved File = dsa.pri
Length = 201
Format = PKCS#8
toString = sun.security.provider.DSAPrivateKey@2eea8

Public Key Info:
Algorithm = DSA
Saved File = dsa.pub
Length = 244
Format = X.509
toString = Sun DSA Public Key
Parameters:
p:
fca682ce 8e12caba 26efccf7 110e526d b078b05e decbcd1e b4a208f3 ae1617ae
01f35b91 a47e6df6 3413c5e1 2ed0899b cd132acd 50d99151 bdc43ee7 37592e17
q:
962eddcc 369cba8e bb260ee6 b6a126d9 346e38c5
g:
678471b2 7a9cf44e e91a49c5 147db1a9 aaf244f0 5a434d64 86931d2d 14271b9e
35030b71 fd73da17 9069b32e 2935630e 1c206235 4d0da20a 6c416e50 be794ca4

y:
a6813c1b 1ba23d1a 5c24d6f9 8b97f8be 58ee238b 012bcdbb 052503c1 a2b6d8d8
d23cda28 d426aafe dd8a0860 2a90c2d0 7902741b 3c4cc630 d105305f 4a339ae5


KeyFactory Object Info:
Algorithm = DSA
Provider = SUN version 1.8
toString = java.security.KeyFactory@ad8086

Private Key Info:
Algorithm = DSA
Saved File = dsa.pri
Length = 201
toString = sun.security.provider.DSAPrivateKey@2eea8

Public Key Info:
Algorithm = DSA
Saved File = dsa.pub
Length = 244
toString = Sun DSA Public Key
Parameters:DSA
p:     
fca682ce 8e12caba 26efccf7 110e526d b078b05e decbcd1e b4a208f3 ae1617ae
01f35b91 a47e6df6 3413c5e1 2ed0899b cd132acd 50d99151 bdc43ee7 37592e17
q:     
962eddcc 369cba8e bb260ee6 b6a126d9 346e38c5
g:     
678471b2 7a9cf44e e91a49c5 147db1a9 aaf244f0 5a434d64 86931d2d 14271b9e
35030b71 fd73da17 9069b32e 2935630e 1c206235 4d0da20a 6c416e50 be794ca4

y:
a6813c1b 1ba23d1a 5c24d6f9 8b97f8be 58ee238b 012bcdbb 052503c1 a2b6d8d8
d23cda28 d426aafe dd8a0860 2a90c2d0 7902741b 3c4cc630 d105305f 4a339ae5

The program seems to be working:

Last update: 2014.

Table of Contents

 About This JDK Tutorial Book

 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

 Java Date-Time API

 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

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

 Socket Network Communication

 Datagram Network Communication

 DOM (Document Object Model) - API for XML Files

 SAX (Simple API for XML)

 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

 What Is Key Encoding?

 PKCS#8 and X.509 Key Encoding Classes

 java.security.KeyFactory - Reading Encoded Keys

 JcaKeyFactoryTest.java - Key Factory Test Program

Reading DSA Private and Public Key Files

 Reading RSA Private and Public Key Files

 Digital Signature Algorithm and 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

 SSL Client Authentication

 HTTPS (Hypertext Transfer Protocol Secure)

 Outdated Tutorials

 References

 PDF Printing Version