ccs.crypt
Class AbstractBlockCipherOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by ccs.crypt.CipherOutputStream
              extended by ccs.crypt.AbstractBlockCipherOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
BCCHOutputStream

public abstract class AbstractBlockCipherOutputStream
extends CipherOutputStream

A Block-cipher output stream. This handles the housekeeping, and delegates all actual crypto to subclasses.


Field Summary
 
Fields inherited from class ccs.crypt.CipherOutputStream
plainlen, temp8
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
protected AbstractBlockCipherOutputStream(DammedOutputStream os, long plainlen, AbstractBlockCipher cipher)
           
 
Method Summary
 void finish()
          Completes the encryption but does not close the underlying stream.
 void write(byte[] text, int off, int len)
           
protected abstract  void writeHeader(java.io.OutputStream os)
          Write the first part of the "header", not including any required stream length information.
 
Methods inherited from class ccs.crypt.CipherOutputStream
close, flush, write
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBlockCipherOutputStream

protected AbstractBlockCipherOutputStream(DammedOutputStream os,
                                          long plainlen,
                                          AbstractBlockCipher cipher)
Method Detail

write

public void write(byte[] text,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in class CipherOutputStream
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.IOException
Completes the encryption but does not close the underlying stream.

Specified by:
finish in class CipherOutputStream
Throws:
java.io.IOException - if the finish failed for some reason.

writeHeader

protected abstract void writeHeader(java.io.OutputStream os)
                             throws java.io.IOException
Write the first part of the "header", not including any required stream length information. For CBC ciphers, this is usually just the IV. NB. You should wash the header through your MAC. The CCSBlockCipher's buffer is available as scratch space.

Parameters:
os - The stream to write to.
Throws:
java.io.IOException