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 is done with JDK 1.6.

javac -classpath . JcaKeyFactoryTest.java

java -cp . JcaKeyFactoryTest 512 dsa DSA

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

Private Key Info: 
Algorithm = DSA
Saved File = dsa.pri
Length = 201
Format = PKCS#8
toString = Sun DSA Private 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

x:     7bede213 af9e4dea 58ec0c53 da77353a a136804b

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:
e65f49f0 e5e41323 35a63e1e c0871f48 67d512d9 b54b8c82 218edba8 e32e236e
2bf3def4 1ac14365 38427c83 0ea43b9d c3dc737e dddd0200 6151c422 e5f15905

KeyFactory Object Info: 
Algorithm = DSA
Provider = SUN version 1.6
toString = java.security.KeyFactory@13e205f

Private Key Info: 
Algorithm = DSA
Saved File = dsa.pri
Length = 201
toString = Sun DSA Private 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

x:     7bede213 af9e4dea 58ec0c53 da77353a a136804b


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:
e65f49f0 e5e41323 35a63e1e c0871f48 67d512d9 b54b8c82 218edba8 e32e236e
2bf3def4 1ac14365 38427c83 0ea43b9d c3dc737e dddd0200 6151c422 e5f15905

The program seems to be working:

Last update: 2013.

Table of Contents

 About This Book

 Cryptography Terminology

 Cryptography Basic Concepts

 Introduction to AES (Advanced Encryption Standard)

 Introduction to DES Algorithm

 DES Algorithm - Illustrated with Java Programs

 DES Algorithm Java Implementation

 DES Algorithm - Java Implementation in JDK JCE

 DES Encryption Operation Modes

 DES in Stream Cipher Modes

 PHP Implementation of DES - mcrypt

 Blowfish - 8-Byte Block Cipher

 Secret Key Generation and Management

 Cipher - Secret Key Encryption and Decryption

 Introduction of RSA Algorithm

 RSA Implementation using java.math.BigInteger Class

 Introduction of DSA (Digital Signature Algorithm)

 Java Default Implementation of DSA

 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

 Cipher - Public Key Encryption and Decryption

 MD5 Mesasge Digest Algorithm

 SHA1 Mesasge Digest Algorithm

 OpenSSL Introduction and Installation

 OpenSSL Generating and Managing RSA Keys

 OpenSSL Managing Certificates

 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"

 Using Certificates in IE (Internet Explorer)

 Using Certificates in Firefox

 Using Certificates in Google Chrome

 Outdated Tutorials

 References

 PDF Printing Version