Class DHKeyExServer

All Implemented Interfaces:
InterKeyExServer, InterProtocolServer

public class DHKeyExServer
extends org.logi.crypto.protocols.DHKeyEx
implements InterKeyExServer

Diffie-Hellman key exchange server. It expects to talk to a DHKeyExClient object.

Logi Ragnarsson (
See Also:

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
Constructor Summary
DHKeyExServer(DHPrivateKey pri, java.lang.String keyType)
          Create a new DHKeyExServer object.
DHKeyExServer(int n, java.lang.String keyType)
          Create a new DHKeyExClient object.
Method Summary
 boolean completed()
          Returns true iff this end of the protocol i completed.
 int maxMessageSize()
          Returns the maximum expected size of a message for this protocol.
 byte[] message(byte[] received)
          Get the next message in the protocol.
 Key sessionKey()
          Returns the key if it has been decided upon, or null otherwise.
Methods inherited from class org.logi.crypto.Crypto
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.logi.crypto.protocols.InterKeyExServer
Methods inherited from interface org.logi.crypto.protocols.InterProtocolServer
completed, maxMessageSize

Constructor Detail


public DHKeyExServer(DHPrivateKey pri,
                     java.lang.String keyType)
              throws KeyException
Create a new DHKeyExServer object. It uses the private DH key from pri.
KeyException - if the key is not private.


public DHKeyExServer(int n,
                     java.lang.String keyType)
Create a new DHKeyExClient object. It uses an n bit modulus and the named key type.

There are pre-computed public modulus and gnerator pairs for these values of n: 256, 512, 1024, 2048. Using one of these values saves you from a rather long wait.

Method Detail


public byte[] message(byte[] received)
               throws CryptoProtocolException
Get the next message in the protocol.

received is the last message received form the client and has not yet been sent to the client.

The returned value is the next message to send to the client or null if no more messages need to be sent and the protocol is terminated.

Specified by:
message in interface InterProtocolServer
CryptoProtocolException - if a problem arises with the protocol.


public Key sessionKey()
Returns the key if it has been decided upon, or null otherwise.


public boolean completed()
Returns true iff this end of the protocol i completed.


public int maxMessageSize()
Returns the maximum expected size of a message for this protocol.

Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL