All Packages Class Hierarchy This Package Previous Next Index
Class is.logi.crypto.io.EncryptStream
java.lang.Object
|
+----java.io.OutputStream
|
+----java.io.FilterOutputStream
|
+----is.logi.crypto.io.EncryptStream
- public class EncryptStream
- extends FilterOutputStream
This OutputStream encrypts everything written to it. It uses an arbitraty
key-exchange protocol, cipher and encryption mode.
Beware that depending on the EncryptMode you use, garbage may be inserted
into the stream when it is flushed or closed.
- Author:
- Logi Ragnarsson
(logir@hi.is)
- See Also:
- DecryptStream
-
EncryptStream(OutputStream, NoninterKeyExClient, EncryptMode)
- Create a new EncryptStream.
-
execute(NoninterProtocolClient)
- Executes a non-interactive protocol.
-
flush()
- Flushes this output stream and forces any buffered output bytes to
be written out to the stream.
-
write(byte[], int, int)
- Writes len bytes from the specified byte array starting at offset
off to this output stream.
-
write(int)
- Writes the specified byte to this output stream.
EncryptStream
public EncryptStream(OutputStream out,
NoninterKeyExClient kex,
EncryptMode emode) throws ProtocolException, IOException
- Create a new EncryptStream. Ciphertext is written to
out
,
emode
is used for encryption and if kex
is not null it will be used to send the session key to the server.
Note that if kex
is not null, it controls which
session key is used and emode
receives the session key
when it has been decided. If kex
is null, then
emode
must be initialized with a key, and the same symmetric
key or matching asymmetric key must be used on the server.
- Throws: ProtocolException
- if a problem arises with the key-exchange protocol.
- Throws: IOException
- if problems arise with the underlying OutputStream.
execute
public void execute(NoninterProtocolClient prot) throws IOException, ProtocolException
- Executes a non-interactive protocol.
- Throws: ProtocolException
- if there is a problem with the protocol.
- Throws: IOException
- if there is a problem with the underlying streams.
write
public synchronized void write(int b) throws IOException
- Writes the specified byte to this output stream.
- Overrides:
- write in class FilterOutputStream
write
public synchronized void write(byte buf[],
int off,
int len) throws IOException
- Writes len bytes from the specified byte array starting at offset
off to this output stream.
- Overrides:
- write in class FilterOutputStream
flush
public synchronized void flush() throws IOException
- Flushes this output stream and forces any buffered output bytes to
be written out to the stream. If the number of bytes written is not
a multiple of the plainBlockSize of the Key used for encryption, up
to one byte less than a whole block of garbage may be appended to
the data when flush is called.
- Overrides:
- flush in class FilterOutputStream
All Packages Class Hierarchy This Package Previous Next Index