DiffieHellman Private Key and Public Key Pair Sample

This section provides a tutorial example on how to run JcaKeyPair.java to generate a DiffieHellman private key and public key pair sample. Keys are stored PKCS#8 and X.509 encoding formats.

Now let's see the private key and public key generated by the DiffieHellman algorithm:

java -cp . JcaKeyPair 512 diff DiffieHellman

KeyPairGenerator Object Info:
Algorithm = DiffieHellman
Provider = SunJCE version 1.6
Key Size = 512
toString = java.security.KeyPairGenerator$Delegate@89fbe3

Private Key Info:
Algorithm = DH
Saved File = diff.pri
Size = 212
Format = PKCS#8
toString = SunJCE Diffie-Hellman Private Key:
x:
1cdeaf4b 7ce125ff 405952a0 f2d0808e 3dcfb444 bceaebea 438e11b5 5db2a340
970d3aa8 bd04d347 0c01bc61 7383965e
p:
fca682ce 8e12caba 26efccf7 110e526d b078b05e decbcd1e b4a208f3 ae1617ae
01f35b91 a47e6df6 3413c5e1 2ed0899b cd132acd 50d99151 bdc43ee7 37592e17
g:
678471b2 7a9cf44e e91a49c5 147db1a9 aaf244f0 5a434d64 86931d2d 14271b9e
35030b71 fd73da17 9069b32e 2935630e 1c206235 4d0da20a 6c416e50 be794ca4
l:
384

Public Key Info:
Algorithm = DH
Saved File = diff.pub
Size = 226
Format = X.509
toString = SunJCE Diffie-Hellman Public Key:
y:
47c4fb37 511b7185 c1c67cbf c90d9d64 5ee34431 64097cac ee26b779 acd54a41
296bdf75 b93b7f2b 90052d35 e26e2204 6e562b03 3519cd94 2cddebe8 f96a97e1
p:
fca682ce 8e12caba 26efccf7 110e526d b078b05e decbcd1e b4a208f3 ae1617ae
01f35b91 a47e6df6 3413c5e1 2ed0899b cd132acd 50d99151 bdc43ee7 37592e17
g:
678471b2 7a9cf44e e91a49c5 147db1a9 aaf244f0 5a434d64 86931d2d 14271b9e
35030b71 fd73da17 9069b32e 2935630e 1c206235 4d0da20a 6c416e50 be794ca4
l:
384

java -cp . HexWriter diff.pri diff_pri.hex

type diff_pri.hex
3081D102010030819706092A864886F7
0D010301308189024100FCA682CE8E12
CABA26EFCCF7110E526DB078B05EDECB
CD1EB4A208F3AE1617AE01F35B91A47E
6DF63413C5E12ED0899BCD132ACD50D9
9151BDC43EE737592E170240678471B2
7A9CF44EE91A49C5147DB1A9AAF244F0
5A434D6486931D2D14271B9E35030B71
FD73DA179069B32E2935630E1C206235
4D0DA20A6C416E50BE794CA402020180
043202301CDEAF4B7CE125FF405952A0
F2D0808E3DCFB444BCEAEBEA438E11B5
5DB2A340970D3AA8BD04D3470C01BC61
7383965E

java -cp . HexWriter diff.pub diff_pub.hex

type diff_pub.hex
3081DF30819706092A864886F70D0103
01308189024100FCA682CE8E12CABA26
EFCCF7110E526DB078B05EDECBCD1EB4
A208F3AE1617AE01F35B91A47E6DF634
13C5E12ED0899BCD132ACD50D99151BD
C43EE737592E170240678471B27A9CF4
4EE91A49C5147DB1A9AAF244F05A434D
6486931D2D14271B9E35030B71FD73DA
179069B32E2935630E1C2062354D0DA2
0A6C416E50BE794CA402020180034300
024047C4FB37511B7185C1C67CBFC90D
9D645EE3443164097CACEE26B779ACD5
4A41296BDF75B93B7F2B90052D35E26E
22046E562B033519CD942CDDEBE8F96A
97E1

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

 Private and Public Keys and Related Interfaces

 KeyPair and KeyPairGenerator Classes

 Key Pair Sample Program - JcaKeyPair.java

 DSA Private Key and Public Key Pair Sample

 RSA Private Key and Public Key Pair Sample

DiffieHellman Private Key and Public Key Pair Sample

 PKCS#8/X.509 Private/Public Encoding Standards

 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