All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.OutputStream | +----java.io.FilterOutputStream | +----java.security.CipherOutputStream
This is NOT the implementation from Sun. This class has been developed by IAIK according to the documentation publically available. Only the documentation from Sun has been inserted into the source files.
A FilterOutputStream that encrypts or decrypts the data passing through it.
This class has a constructor that takes a Cipher and an output stream as
arguments. The cipher is used to encrypt or decrypt all data
supplied via calls to one of the write
methods. The
encryption/decryption result is written to the output stream.
A buffer is used for receiving the data to be encrypted or decrypted,
depending on the state of the Cipher. To supply the bytes that need
to be encrypted/decrypted, make one or more calls to one of the
write
methods. After you have supplied all the data,
call flush
to ensure final processing is done.
With an encrypter stream, every time a complete block has been
supplied via calls to write
, the block is encrypted
and written to the output stream. When flush
is called,
the final data is encrypted and the result written to the
output stream. If the final data does not comprise a complete block,
and the cipher is a padding cipher, the data is padded
before encryption. If padding is needed but the cipher is not
a padding cipher, an exception is thrown.
With a decrypter stream, every time a complete block plus one
byte has been supplied via calls to write
, the block
is decrypted and written to the output stream. When flush
is called, exactly one block should be in the buffer. It is decrypted
and written out.
ENCRYPT
or
DECRYPT
.
public CipherOutputStream(OutputStream os, Cipher cipher)
ENCRYPT
or
DECRYPT
.
public synchronized void write(int b) throws IOException
public synchronized void write(byte b[], int off, int len) throws IOException
b
indicating the location
of the first byte to be used.
b
,
starting at offset off
.
public synchronized void flush() throws IOException
For an encrypter stream, the final data is encrypted and the result written to the output stream. If the final data does not comprise a complete block, and the cipher is a padding cipher, the data is padded before encryption. If padding is needed but the cipher is not a padding cipher, an exception is thrown.
For a decrypter stream, when flush
is called,
exactly one block should be in the buffer. It is decrypted
and written out.
All Packages Class Hierarchy This Package Previous Next Index