Cryptography Reference
In-Depth Information
input = new DataInputStream(connection.getInputStream());
//Exchange public keys with the server-send yours, get theirs
exchangeKeys();
//Change appearance/functionality of some components
serverField.setEditable(false);
connectButton.setLabel(“Disconnect from server above”);
enterField.setEnabled(true);
//Set up a thread to listen for the connection
listener = new Thread(
new Runnable() {
public void run() {
go();
}
}
);
listener.start();
} catch (IOException ioe) {
displayArea.append(“\nError connecting to “+chatServer);
}
}
}
}
The makeKeys() method here is the same as the one in CipherChatServer.
private void makeKeys() {
PrimeGenerator pg=new PrimeGenerator(513,10,sr);
do {
p=pg.getStrongPrime();
} while(p.subtract(BigIntegerMath.ONE).mod(BigIntegerMath.THREE).equals
(BigIntegerMath.ZERO));
do {
q=pg.getStrongPrime();
} while(q.subtract(BigIntegerMath.ONE).mod(BigIntegerMath.THREE).equals
(BigIntegerMath.ZERO));
modulus=p.multiply(q);
//Use 3 as enciphering exponent - OK since we are using salt
decipherExp=BigIntegerMath.THREE.modInverse(p.subtract(BigIntegerMath.ONE)
.multiply(q.subtract(BigIntegerMath.ONE)));
ciphertextBlockSize=(modulus.bitLength()-1)/8+1;
plaintextBlockSize=ciphertextBlockSize-6;
}
The exchangeKeys() method here is the same as the one in CipherChatServer, except
the client sends its key first, then waits for the public key of the server.
Search WWH ::




Custom Search