|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
de.schlichtherle.crypto.io.CipherOutputStream
public class CipherOutputStream
Similar to javax.crypto.CipherOutputStream
,
with some exceptions:
BufferedBlockCipher
is used for ciphering.
cipher
used for encryption or decryption is accessible to
subclasses.
finish()
method has been added to allow finishing the output
(probably producing padding bytes) without closing the output.
This could be used in a subclass to produce a trailer with additional
information about the ciphered data (e.g. a MAC).
Field Summary | |
---|---|
protected BufferedBlockCipher |
cipher
The buffered block cipher used for preprocessing the output. |
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
CipherOutputStream(OutputStream out,
BufferedBlockCipher cipher)
Creates a new instance of CipherOutputStream. |
Method Summary | |
---|---|
void |
close()
Closes this output stream and releases any resources associated with it. |
void |
finish()
Finishes this stream and resets it to it's initial state. |
void |
write(byte[] buf,
int off,
int len)
Ciphers and writes the contents of the given byte array to the underlying output stream. |
void |
write(int b)
Ciphers and writes the given byte to the underlying output stream. |
Methods inherited from class java.io.FilterOutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected BufferedBlockCipher cipher
Constructor Detail |
---|
public CipherOutputStream(OutputStream out, BufferedBlockCipher cipher)
javax.crypto.CipherOutputStream
,
the cipher does not need to be initialized before calling this
constructor.
However, the cipher must be initialized before anything is actually
written to this stream or before this stream is closed.
out
- The output stream to write the encrypted or decrypted data to.
Maybe null if initialized by the subclass constructor.cipher
- The cipher to use for encryption or decryption.
Maybe null for subsequent initialization by a subclass.Method Detail |
---|
public void write(int b) throws IOException
write
in class FilterOutputStream
b
- The byte to cipher and write.
IOException
- If out or cipher aren't properly initialized,
the stream has been closed or an I/O error occured.public void write(byte[] buf, int off, int len) throws IOException
write
in class FilterOutputStream
buf
- The buffer holding the data to cipher and write.off
- The start offset in the data buffer.len
- The number of bytes to cipher and write.
IOException
- If out or cipher aren't properly initialized,
the stream has been closed or an I/O error occured.public void finish() throws IOException
Please note that subsequent calls to any write operations after this method may cause an error in the output data if padding is used!
IOException
- If out or cipher aren't properly initialized,
the stream has been closed, an I/O error occured the cipher
text is invalid, i.e. required padding information is missing.public void close() throws IOException
finish()
and then closes and nullifies
the underlying output stream FilterOutputStream.out
and the cipher cipher
.
close
in interface Closeable
close
in class FilterOutputStream
IOException
- If an I/O error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |