ccs.crypt
Class AbstractBlockCipherInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by ccs.crypt.CipherInputStream
              extended by ccs.crypt.AbstractBlockCipherInputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
BCCHInputStream

public abstract class AbstractBlockCipherInputStream
extends CipherInputStream

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


Field Summary
 
Fields inherited from class ccs.crypt.CipherInputStream
isDelimit, temp8
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
protected AbstractBlockCipherInputStream(DammedInputStream is, boolean isDelimit, AbstractBlockCipher cipher)
           
 
Method Summary
 void finish()
          Finishes with this decryption and releases the decryption engine, but does not close the underlying stream.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of plaintext into b[], starting at off.
protected abstract  void readHeader(java.io.InputStream is)
          Read in the header, not including any self-delimiting information.
 
Methods inherited from class ccs.crypt.CipherInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBlockCipherInputStream

protected AbstractBlockCipherInputStream(DammedInputStream is,
                                         boolean isDelimit,
                                         AbstractBlockCipher cipher)
Method Detail

finish

public void finish()
            throws java.io.IOException
Description copied from class: CipherInputStream
Finishes with this decryption and releases the decryption engine, but does not close the underlying stream.

Specified by:
finish in class CipherInputStream
Throws:
java.io.IOException - if an error occurs.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Description copied from class: CipherInputStream
Reads up to len bytes of plaintext into b[], starting at off. Blocks until some input is available.

Specified by:
read in class CipherInputStream
Parameters:
b - The buffer to read into. Cannot be null.
off - The starting offset.
len - The maximum number of bytes to read.
Returns:
the total number of byes read, or -1 if the stream is exhausted.
Throws:
java.io.IOException - if an I/O error occurs.

readHeader

protected abstract void readHeader(java.io.InputStream is)
                            throws java.io.IOException
Read in the header, not including any self-delimiting information. Typically this is just the IV (if in CBC mode). Unsigned.readFully is your friend. Remember to wash this through your MAC. The AbstractBlockCipher's buffer is available as scratch space.

Parameters:
is - The stream to read from.
Throws:
java.io.IOException