Cryptography Reference
In-Depth Information
21289097119134252210652032462292962890192274749104820619339989532999
29747753068016087465910738004515719368489010404514526849086194982928
86796661064671158843778504644018420014267514586262260562581776028857
52446509603402778647138069775001533301
Here, for reasons of anonymity, I have replaced the computers' names and/or IP addresses
with asterisks.
15.3
MESSAGE EXCHANGE
Certainly, the most common use of cryptography has been to exchange messages. A natural
question to ask is, “which cryptographic method is best?” This is a loaded question, because
the answer is, “It depends.” Most algorithms are superior in some ways, but inferior in oth-
ers. We can make a table of the ciphers we have covered, as shown in Table 15.3, listing the
advantages, disadvantages, and weaknesses of each. (I consider a weakness different than
a mere disadvantage.) Some of the weaknesses can be described as potential weaknesses,
since they can be corrected.
15.4
CIPHER CHAT APPLICATION
I have written a chat program to pass enciphered messages back and forth between a machine
running as a client, and another running as a server. The two chatters do not need to share
a secret key, since the client and the server each generate a public key/private key pair, then
send the public key to the other. It doesn't matter if anyone “listening in” captures either of
these public keys. After the client and the server know the other's public key, either can
send encrypted messages.
I should note that the messages in this application are not text, but arrays of bytes. Of
course, this is because the messages are enciphered. Thus, the PrintStream and Buffered-
Reader classes are not appropriate for doing IO. We must use something appropriate for
reading/writing raw bytes, like DataInputStream, and DataOutputStream.
To create these, we would do something like this:
DataInputStream in=new
DataInputStream(connection.getInputStream());
and
DataOutputStream out=new
DataOutputStream(connection.getOutputStream());
To write an array of bytes to the stream, we could use one of the write() methods from
DataOutputStream, like this.
byte[] msg = new byte[100];
out.write(msg);
Search WWH ::




Custom Search