com.dyuproject.util
Class DiffieHellman

java.lang.Object
  extended by com.dyuproject.util.DiffieHellman

public final class DiffieHellman
extends Object

Diffie-Hellman key exchange is a cryptographic protocol that allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure communications channel.

Author:
David Yu
Date created:
Sep 7, 2008

Field Summary
static DiffieHellman BASE_2
           
static DiffieHellman BASE_5
           
 
Constructor Summary
DiffieHellman(BigInteger base)
           
 
Method Summary
 BigInteger generatePublicKey(BigInteger privateKey, BigInteger modulus)
          Generates a public key from the given privateKey and modulus.
 BigInteger[] generateRandomKeys(BigInteger modulus)
          Generates a random private Key (element 0) and a random public key (element 1) from the given modulus.
static BigInteger getSharedSecretKey(BigInteger privateKey, BigInteger modulus, BigInteger responseKey)
          Gets/computes the shared secret key from the given privateKey, modulus and responseKey - which is a public key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_2

public static final DiffieHellman BASE_2

BASE_5

public static final DiffieHellman BASE_5
Constructor Detail

DiffieHellman

public DiffieHellman(BigInteger base)
Method Detail

generateRandomKeys

public BigInteger[] generateRandomKeys(BigInteger modulus)
Generates a random private Key (element 0) and a random public key (element 1) from the given modulus.

Parameters:
modulus -
Returns:
BigInteger array. Element 0 is privateKey. Element 1 is publicKey.

generatePublicKey

public BigInteger generatePublicKey(BigInteger privateKey,
                                    BigInteger modulus)
Generates a public key from the given privateKey and modulus.


getSharedSecretKey

public static BigInteger getSharedSecretKey(BigInteger privateKey,
                                            BigInteger modulus,
                                            BigInteger responseKey)
Gets/computes the shared secret key from the given privateKey, modulus and responseKey - which is a public key.



Copyright © 2008-2013. All Rights Reserved.