org.logi.crypto.io
Class CipherStreamClient
java.lang.Object
|
+--org.logi.crypto.Crypto
|
+--org.logi.crypto.io.CipherStream
|
+--org.logi.crypto.io.CipherStreamClient
- All Implemented Interfaces:
- PrettyPrintable
- public class CipherStreamClient
- extends CipherStream
This class can be used to apply an interactive key exchange protocol
to a pair of streams and then encrypt all data going through them with
the session key exchanged.
It can also execute interactive protocols on the streams once they are
initialized.
This class expects to talk to an equivalent server class.
- Author:
- Logi Ragnarsson
(logir@logi.org)
- See Also:
CipherStreamServer
Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
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 |
CipherStreamClient
public CipherStreamClient(java.io.InputStream in,
java.io.OutputStream out,
InterKeyExClient kex,
EncryptSession encrypt,
DecryptSession decrypt)
throws CryptoProtocolException,
java.io.IOException
- Create a new CipherStreamClient object and ecxhange keys.
Create a new object which uses kex
to exchange keys with
a remote server and then encrypt
to encrypt the data to
out
and decrypt
to decrypt data from
in
and out
.
if kex==null
then the key-exchange step is skipped and
the encrypt
and decrypt
objects must have
been initialized with a key beforethis call.
- Throws:
CryptoProtocolException
- if there is a problem exchanging keys.java.io.IOException
- if there is a problem with the underlying streams.
reKey
public void reKey(InterKeyExClient kex,
boolean encrypt)
throws java.io.IOException,
CryptoProtocolException
- Executes an interactive key-exchange protocol. If encrypt is true,
messages will be sent through the encrypted channel. This induces a
flush of the outgoing stream and causes the incoming stream to be
drained.
After the protocol has been executed, the exchanged key will be used
for encryption.
- Throws:
java.io.IOException
- if there is a low-level problem.CryptoProtocolException
- if the protocol could not execute.
execute
public void execute(InterProtocolClient prot,
boolean encrypt)
throws java.io.IOException,
CryptoProtocolException
- Executes an interactive protocol. If encrypt is true, then the
protocol will be executed through the encrypted link. This requires
the object to have been initialized with a key to use.
- Throws:
CryptoProtocolException
- if there is a problem with the protocol keys.java.io.IOException
- if there is a problem with the underlying streams.
Copyright 1997-2000 Logi Ragnarsson