Encryption Usage
----------------
BufferedReader in;
PrintWriter out;
String MonitorKey;
ObjectInputStream oin;
ObjectOutputStream oout;
DHEngine engine;
DHKeyObject dhk;
Cipher cipher;
String MyKey;
================
// Set Encryption - use object in file "DHKeyObject"
// Applied during login procedure to start encryption.
oin = new ObjectInputStream(new FileInputStream("DHKeyObject")); //Read the DHKeyObject from file
dhk = (DHKeyObject)oin.readObject();
oin.close();
engine = new DHEngine(dhk); //Start the DHEngine Object
MyKey = engine.getExchangeKey();
----------------
// Use MyKey to send IDENT for encryption - also send message
String message = "IDENT "+YourIDENTITY+ " "+MyKey;
String message1 = cipher.Encrypt(message);
out.println(message1);
out.flush();
================
// Standard way to encrypt
String message1 = cipher.Encrypt(message);
out.println(message1);
out.flush();
================
// The following pertain to messages coming from the monitor
----------------
// If encryption has been started and the monitor message is encrypted
// Decrypting a message from the Tournament Monitor
String temp = in.readLine();
decrypt = cipher.Decrypt(temp.trim());
----------------
// If encryption has been started and the monitor message is not encrypted.
// Assume response from the monitor contains the monitor key
String temp = in.readLine();
String MonitorKey = parseMessageForMonitorKey(temp,"IDENT");
engine.setExchangeKey(MonitorKey);
BigInteger big = engine.getSharedKey(); //Get the SharedKey
cipher = new Cipher(big); //Create the Cipher Object for Encryption & Decryption
decrypt = cipher.Decrypt(temp.trim());
----------------