Cryptography Reference
In-Depth Information
4.
The crypto objects to store the server's public and private keys, and to store the public
key of the client. Two variables store the length of the ciphertext, and the length of the
plaintext.
private Button disconnectButton=new Button(“Disconnect Client”);
private TextField enterField=new TextField();
private TextArea displayArea=new TextArea();
private Panel top=new Panel();
private Panel bottom=new Panel();
private DataOutputStream output;
private DataInputStream input;
private String message=””;
private static ServerSocket server;
private Socket connection;
private BigInteger p,q,modulus,decipherExp,recipModulus;
private SecureRandom sr=new SecureRandom();
private int ciphertextBlockSize;
private int plaintextBlockSize;
The constructor does the typical thing for a GUI; it lays out all the components on the
frame, and displays it. However, this constructor also produces the public and private keys
of the server when it calls the makeKeys() method, which we will see later.
public CipherChatServer() {
//Lay components on frame and display it
super(“Cipher Chat Server”);
//Establish keys for RSA cipher
makeKeys();
setLayout(new GridLayout(2,1));
top.setLayout(new GridLayout(2,1));
bottom.setLayout(new GridLayout(1,1));
add(top);
add(bottom);
disconnectButton.setEnabled(false);
disconnectButton.addActionListener(this);
top.add(disconnectButton);
enterField.setEnabled(false);
enterField.addActionListener(this);
top.add(enterField,BorderLayout.NORTH);
bottom.add(displayArea);
setSize(400,300);
show();
}
Search WWH ::




Custom Search