public interface DH
The group in question here is the multiplicative group of
the finite field with p
elements. It (or at least
a quite large subgroup of it) should be generated by g
.
Here is a short view of the algorithm (which would work in any group which we could somehow encode as numbers, by the way):
x
,
calculate e = g^x
and send e
to the server.y
, calculates
f = g^y
and sends us f
.{@code K = f^x}
, while the server
calculates K = e^y
(and since multiplication of integers is
commutative, e^y = (g^x)^y = g^(x*y) = g^(y*x) = (g^y)^x = f^x
,
both have the same number.)The methods of this interface will generally be called in the order defined here, each once.
The implementing class has to do the random number generation of x and the modular arithmetic.
The implementing class will be chosen by the
configuration option "dh"
,
a default implementation is delivered with the library.
Modifier and Type  Method and Description 

void 
checkRange() 
byte[] 
getE()
Retrieves the value
e , that is the result of
g^x mod P . 
byte[] 
getK()
Retrieves the secret number K which was created by the key exchange
and will be used to create the key.

void 
init()
initializes the algorithm object for a new exchange.

void 
setF(byte[] f)
Sets the value of
f , that is the result of
g^y mod P 
void 
setG(byte[] g)
Sets the generator of the group.

void 
setP(byte[] p)
Sets the prime number, modulo which the calculations should be done.

void init() throws Exception
Exception
void setP(byte[] p)
void setG(byte[] g)
byte[] getE() throws Exception
e
, that is the result of
g^x mod P
.Exception
void setF(byte[] f)
f
, that is the result of
g^y mod P
byte[] getK() throws Exception
Exception
This is an inofficial Javadoc created by PaĆlo Ebermann. Have a look at the official homepage.